From da776105beb80606755d8e61b846e754e34f4f0d Mon Sep 17 00:00:00 2001 From: Vadim Kurland Date: Thu, 24 Feb 2011 10:19:46 -0800 Subject: [PATCH] see #2139 show warning dialog and offer choice: open file for veiwing read-only or cancel --- VERSION | 2 +- VERSION.h | 2 +- doc/ChangeLog | 8 ++++++++ packaging/fwbuilder-static-qt.spec | 2 +- packaging/fwbuilder.control | 2 +- packaging/fwbuilder.spec | 2 +- src/libgui/AddressTableDialog.cpp | 3 ++- src/libgui/AddressTableEditor.cpp | 28 ++++++++++++++++++++-------- src/libgui/AddressTableEditor.h | 3 +++ 9 files changed, 38 insertions(+), 14 deletions(-) diff --git a/VERSION b/VERSION index 3532d0874..ba42097e9 100644 --- a/VERSION +++ b/VERSION @@ -7,7 +7,7 @@ FWB_MICRO_VERSION=0 # build number is like "nano" version number. I am incrementing build # number during development cycle # -BUILD_NUM="3485" +BUILD_NUM="3486" VERSION="$FWB_MAJOR_VERSION.$FWB_MINOR_VERSION.$FWB_MICRO_VERSION.$BUILD_NUM" diff --git a/VERSION.h b/VERSION.h index 430382630..26596b8f5 100644 --- a/VERSION.h +++ b/VERSION.h @@ -1,2 +1,2 @@ -#define VERSION "4.2.0.3485" +#define VERSION "4.2.0.3486" #define GENERATION "4.2" diff --git a/doc/ChangeLog b/doc/ChangeLog index b2e5acd4d..e69515799 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,11 @@ +2011-02-24 vadim + + * AddressTableEditor.cpp (load): fixes #2139 "Provide "Cancel" + button if Address Table file is read-only". IF the file configured + with Address Table object is read-only, the GUI shows warning when + user clicks "Edit" button and offers a choice: open it for viewing + read-only or cancel. + 2011-02-23 vadim * AddressTableEditor.cpp (save): fixes #2135 "Editing table diff --git a/packaging/fwbuilder-static-qt.spec b/packaging/fwbuilder-static-qt.spec index 91588aa82..2a50e388f 100644 --- a/packaging/fwbuilder-static-qt.spec +++ b/packaging/fwbuilder-static-qt.spec @@ -3,7 +3,7 @@ %define name fwbuilder -%define version 4.2.0.3485 +%define version 4.2.0.3486 %define release 1 %if "%_vendor" == "MandrakeSoft" diff --git a/packaging/fwbuilder.control b/packaging/fwbuilder.control index 27191b4c7..57e08ffb5 100644 --- a/packaging/fwbuilder.control +++ b/packaging/fwbuilder.control @@ -4,6 +4,6 @@ Replaces: fwbuilder (<=4.1.1-1), fwbuilder-common, fwbuilder-bsd, fwbuilder-linu Priority: extra Section: checkinstall Maintainer: vadim@fwbuilder.org -Version: 4.2.0.3485-1 +Version: 4.2.0.3486-1 Depends: libqt4-gui (>= 4.3.0), libxml2, libxslt1.1, libsnmp | libsnmp15 Description: Firewall Builder GUI and policy compilers diff --git a/packaging/fwbuilder.spec b/packaging/fwbuilder.spec index d5579c5be..1749006b6 100644 --- a/packaging/fwbuilder.spec +++ b/packaging/fwbuilder.spec @@ -1,6 +1,6 @@ %define name fwbuilder -%define version 4.2.0.3485 +%define version 4.2.0.3486 %define release 1 %if "%_vendor" == "MandrakeSoft" diff --git a/src/libgui/AddressTableDialog.cpp b/src/libgui/AddressTableDialog.cpp index 148ede6f3..7778b0646 100644 --- a/src/libgui/AddressTableDialog.cpp +++ b/src/libgui/AddressTableDialog.cpp @@ -173,6 +173,7 @@ void AddressTableDialog::editFile( void ) { QString filePath = m_dialog->filename->text(); AddressTableEditor editor(this, filePath); - editor.exec(); // its modal dialog + if (editor.load()) + editor.exec(); // its modal dialog } diff --git a/src/libgui/AddressTableEditor.cpp b/src/libgui/AddressTableEditor.cpp index 6fcdde08e..624fdb3eb 100644 --- a/src/libgui/AddressTableEditor.cpp +++ b/src/libgui/AddressTableEditor.cpp @@ -52,6 +52,10 @@ AddressTableEditor::AddressTableEditor(QWidget *parent, m_dialog->setupUi(static_cast(this)); if (!title.isEmpty()) setWindowTitle(title); +} + +bool AddressTableEditor::load() +{ QFile rf(file_name); if (rf.exists()) @@ -60,18 +64,25 @@ AddressTableEditor::AddressTableEditor(QWidget *parent, QObject::tr("File %1 not found").arg(file_name) ); } + QFileInfo fi(file_name); if ( ! fi.isWritable()) { - QMessageBox::critical( - this, "Firewall Builder", - tr("The file is read-only, you can't save the changes."), - tr("&Continue"), QString::null, QString::null, 0, 0 ); + switch ( + QMessageBox::critical( + this, "Firewall Builder", + tr("The file is read-only, you can't save the changes."), + tr("&View the file"), tr("&Cancel"), QString::null, 0, 1 )) + { + case 0: // open read-only + m_dialog->editor->setReadOnly(true); + m_dialog->ok_button->hide(); + m_dialog->cancel_button->setText(tr("Close")); + break; - m_dialog->editor->setReadOnly(true); - - m_dialog->ok_button->hide(); - m_dialog->cancel_button->setText(tr("Close")); + default: // cancel + return false; + } } if (rf.open(QIODevice::ReadOnly)) @@ -84,6 +95,7 @@ AddressTableEditor::AddressTableEditor(QWidget *parent, m_dialog->editor->setPlainText(rf.errorString()); } + return true; } AddressTableEditor::~AddressTableEditor() diff --git a/src/libgui/AddressTableEditor.h b/src/libgui/AddressTableEditor.h index cd895615b..b6c471625 100644 --- a/src/libgui/AddressTableEditor.h +++ b/src/libgui/AddressTableEditor.h @@ -42,6 +42,9 @@ class AddressTableEditor : public QDialog const QString &title=""); ~AddressTableEditor(); + // load data, return true if successful + bool load(); + protected: virtual void closeEvent(QCloseEvent *ev);