diff --git a/VERSION b/VERSION index 3f3c985ba..57390dd42 100644 --- a/VERSION +++ b/VERSION @@ -3,18 +3,18 @@ FWB_MAJOR_VERSION=3 FWB_MINOR_VERSION=0 -FWB_MICRO_VERSION=0 -VERSION="3.0.0" -SHORTVERSION="300" +FWB_MICRO_VERSION=1 +VERSION="3.0.1" +SHORTVERSION="301" # RELEASE="1" RELEASE="b@BUILD_NUM@" BETA="no" -REQUIRED_LIBFWBUILDER_VERSION="3.0.0" +REQUIRED_LIBFWBUILDER_VERSION="3.0.1" # current (or major) version number of the library so file # -LIBFWBUILDER_SOMAJOR=7 +LIBFWBUILDER_SOMAJOR=8 diff --git a/VERSION.h b/VERSION.h index 5fe4a5c66..d6e53db3c 100644 --- a/VERSION.h +++ b/VERSION.h @@ -1,2 +1,2 @@ -#define VERSION "3.0.0" +#define VERSION "3.0.1" #define RELEASE_NUM "" diff --git a/build_num b/build_num index 7ee8312bb..e6553aad9 100644 --- a/build_num +++ b/build_num @@ -1 +1 @@ -#define BUILD_NUM 507 +#define BUILD_NUM 515 diff --git a/doc/ChangeLog b/doc/ChangeLog index 8deac4e5a..3a8908462 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,5 +1,23 @@ 2008-09-06 Vadim Kurland + * FWWindow.cpp (FWWindow::projectWindowClosed): fixed bug + #2091520: "Crash FWB". The GUI crashed if user closed mdi window + showing just standard objects and then tried to close the main + window. + + * FWWindow.cpp (FWWindow::fileNew): fixed bug #2091507: "Create + New Firewall problem.". If user created new data file using + File/New main menu item, items in the main menu File used to stay + disabled and file could only be saved using "File/Save As" (which + did not make sense because the name has already been assigned to + the file during File/New operation). + + * ProjectPanel_file_ops.cpp (ProjectPanel::fileSaveAs): bugfix: if + user called "Save As" and then hit Cancel in the dialog where they + choose file name, internal RCS object used to be deleted anyway. + + * v3.0.1 started + * v3.0.0 released Sep 1, 2008. Merged branch "v3" r512 to trunk 2008-09-01 Vadim Kurland diff --git a/qmake.inc b/qmake.inc index a6121cd74..2cf2938de 100644 --- a/qmake.inc +++ b/qmake.inc @@ -12,7 +12,7 @@ DEFINES += $$(DEFINES) LANGUAGE = C++ UI_DIR = ui MANDIR = /home/vadim/src/fwb3-branch-v3/install_root/share/man/ -DOCDIR = /home/vadim/src/fwb3-branch-v3/install_root/share/doc/fwbuilder-3.0.0 +DOCDIR = /home/vadim/src/fwb3-branch-v3/install_root/share/doc/fwbuilder-3.0.1 HAVE_ANTLR_RUNTIME = 1 HAVE_EXTERNAL_ANTLR = 0 @@ -43,7 +43,7 @@ unix { target.path = $$PREFIX/bin dtd.path = @TEMPLATE_DIR@/ migration.path = @TEMPLATE_DIR@/migration - doc.path = /home/vadim/src/fwb3-branch-v3/install_root/share/doc/fwbuilder-3.0.0 + doc.path = /home/vadim/src/fwb3-branch-v3/install_root/share/doc/fwbuilder-3.0.1 datadir.path = /home/vadim/src/fwb3-branch-v3/install_root/share/ @@ -51,10 +51,10 @@ unix { # unix:target.path = $$PREFIX/share/fwbuilder/ # macx:target.path = $$PREFIX/ - res.path = /home/vadim/src/fwb3-branch-v3/install_root/share/fwbuilder-3.0.0 - res_os.path = /home/vadim/src/fwb3-branch-v3/install_root/share/fwbuilder-3.0.0/os/ - res_platform.path = /home/vadim/src/fwb3-branch-v3/install_root/share/fwbuilder-3.0.0/platform/ - res_help.path = /home/vadim/src/fwb3-branch-v3/install_root/share/fwbuilder-3.0.0/help/ + res.path = /home/vadim/src/fwb3-branch-v3/install_root/share/fwbuilder-3.0.1 + res_os.path = /home/vadim/src/fwb3-branch-v3/install_root/share/fwbuilder-3.0.1/os/ + res_platform.path = /home/vadim/src/fwb3-branch-v3/install_root/share/fwbuilder-3.0.1/platform/ + res_help.path = /home/vadim/src/fwb3-branch-v3/install_root/share/fwbuilder-3.0.1/help/ res_desktop.path = /home/vadim/src/fwb3-branch-v3/install_root/share//applications/ INSTALLS += res diff --git a/src/gui/FWWindow.cpp b/src/gui/FWWindow.cpp index b584a4e5c..ee6c6399a 100644 --- a/src/gui/FWWindow.cpp +++ b/src/gui/FWWindow.cpp @@ -197,10 +197,12 @@ FWWindow::FWWindow() : QMainWindow(), // QMainWindow(NULL, Qt::Desktop), connect( m_mainWindow->ObjectMenu, SIGNAL (aboutToShow() ), this, SLOT( prepareObjectMenu() )); + + connect( m_mainWindow->fileMenu, SIGNAL (aboutToShow() ), + this, SLOT( prepareFileMenu() )); + connect( m_space, SIGNAL(subWindowActivated (QMdiSubWindow *)), this, SLOT(changeActiveSubwindow())); - if (fwbdebug) - qDebug("/FWWindow constructor"); recreateWindowsMenu(); disableActions(false); @@ -247,7 +249,7 @@ ProjectPanel* FWWindow::activeProject() { QMdiSubWindow *w = m_space->currentSubWindow(); if (w) return dynamic_cast(w->widget()); - return 0; + return NULL; } void FWWindow::killInstDialog() @@ -260,7 +262,7 @@ void FWWindow::killInstDialog() } } -void FWWindow::updateWindowTitle () +void FWWindow::updateWindowTitle() { if (activeProject()) { @@ -343,7 +345,7 @@ void FWWindow::fileNew() if (proj->fileNew()) { showSub(proj); - proj->startupLoad(); + //proj->startupLoad(); } else { @@ -351,26 +353,6 @@ void FWWindow::fileNew() } } -void FWWindow::addToRCSActionSetEn(bool en) -{ - m_mainWindow->addToRCSAction->setEnabled(en); -} - -void FWWindow::fileDiscardActionSetEn(bool en) -{ - m_mainWindow->fileDiscardAction->setEnabled(en); -} - -void FWWindow::fileCommitActionSetEn(bool en) -{ - m_mainWindow->fileCommitAction->setEnabled(en); -} - -void FWWindow::fileSaveActionSetEn(bool en) -{ - m_mainWindow->fileSaveAction->setEnabled(en); -} - void FWWindow::fileOpen() { std::auto_ptr proj(newProjectPanel()); @@ -386,7 +368,19 @@ void FWWindow::fileOpen() void FWWindow::fileClose() { - if (activeProject()) activeProject()->fileClose(); + if (fwbdebug) qDebug("FWWindow::fileClose()"); + + if (activeProject()) + { + ProjectPanel * project = activeProject(); + if (!project->saveIfModified()) return; // abort operation + project->saveState(); + project->fileClose(); + } + + if (fwbdebug) qDebug("subWindowList().size()=%d", + m_space->subWindowList().size()); + recreateWindowsMenu(); } @@ -460,34 +454,29 @@ void FWWindow::importPolicy() void FWWindow::load(QWidget *dialogs_parent) { - if (activeProject()) - activeProject()->load(dialogs_parent); + if (activeProject()) activeProject()->load(dialogs_parent); } FWObject* FWWindow::getVisibleFirewalls() { - if (activeProject()) - return activeProject()->getVisibleFirewall(); + if (activeProject()) return activeProject()->getVisibleFirewall(); return 0; } void FWWindow::load(QWidget *dialogs_parent,RCS *_rcs) { - if (activeProject()) - activeProject()->load(dialogs_parent, _rcs); + if (activeProject()) activeProject()->load(dialogs_parent, _rcs); } bool FWWindow::checkin(bool unlock) { - if (activeProject()) - return activeProject()->checkin(unlock); + if (activeProject()) return activeProject()->checkin(unlock); return false; } void FWWindow::save() { - if (activeProject()) - activeProject()->save(); + if (activeProject()) activeProject()->save(); } void FWWindow::loadLibrary(const string &libfpath) @@ -498,35 +487,30 @@ void FWWindow::loadLibrary(const string &libfpath) void FWWindow::fileImport() { - if (activeProject()) - activeProject()->fileImport(); + if (activeProject()) activeProject()->fileImport(); } void FWWindow::fileCompare() { - if (activeProject()) - activeProject()->fileCompare(); + if (activeProject()) activeProject()->fileCompare(); } void FWWindow::findExternalRefs(FWObject *lib, FWObject *root, list &extRefs) { - if (activeProject()) - activeProject()->findExternalRefs(lib, root, extRefs); + if (activeProject()) activeProject()->findExternalRefs(lib, root, extRefs); } void FWWindow::setSafeMode(bool f) { - if (activeProject()) - activeProject()->setSafeMode(f); + if (activeProject()) activeProject()->setSafeMode(f); } void FWWindow::setStartupFileName(const QString &fn) { - if (activeProject()) - activeProject()->setStartupFileName(fn); + if (activeProject()) activeProject()->setStartupFileName(fn); } bool FWWindow::exportLibraryTest(list &selectedLibs) @@ -562,8 +546,7 @@ void FWWindow::exportLibraryTo(QString fname,list &selectedLibs, bool void FWWindow::fileExport() { - if (activeProject()) - activeProject()->fileExport(); + if (activeProject()) activeProject()->fileExport(); } void FWWindow::setActionsEnabled(bool en) @@ -585,15 +568,13 @@ void FWWindow::setActionsEnabled(bool en) int FWWindow::findFirewallInList(FWObject *f) { - if (activeProject()) - return activeProject()->findFirewallInList(f); + if (activeProject()) return activeProject()->findFirewallInList(f); return -1; } void FWWindow::ensureObjectVisibleInRules(FWReference *obj) { - if (activeProject()) - activeProject()->ensureObjectVisibleInRules(obj); + if (activeProject()) activeProject()->ensureObjectVisibleInRules(obj); } /* @@ -601,14 +582,12 @@ void FWWindow::ensureObjectVisibleInRules(FWReference *obj) */ void FWWindow::ensureRuleIsVisible(Rule *rule, int col) { - if (activeProject()) - activeProject()->ensureRuleIsVisible(rule, col); + if (activeProject()) activeProject()->ensureRuleIsVisible(rule, col); } void FWWindow::updateRuleSetViewSelection() { - if (activeProject()) - activeProject()->updateRuleSetViewSelection(); + if (activeProject()) activeProject()->updateRuleSetViewSelection(); } void FWWindow::updateTreeViewItemOrder() @@ -616,44 +595,37 @@ void FWWindow::updateTreeViewItemOrder() //this is for case when tree becomes to be resorted //if we do not reopen parent item, some of child //items mix incorrectly (maybe bug of QT?) - if (activeProject()) - activeProject()->updateTreeViewItemOrder(); + if (activeProject()) activeProject()->updateTreeViewItemOrder(); } void FWWindow::updateRuleSetView() { - if (activeProject()) - activeProject()->updateRuleSetView(); + if (activeProject()) activeProject()->updateRuleSetView(); } void FWWindow::updateRuleOptions() { - if (activeProject()) - activeProject()->updateRuleOptions(); + if (activeProject()) activeProject()->updateRuleOptions(); } void FWWindow::updateFirewallName(FWObject *obj,const QString &str) { - if (activeProject()) - activeProject()->updateFirewallName(obj, str); + if (activeProject()) activeProject()->updateFirewallName(obj, str); } void FWWindow::scheduleRuleSetRedraw() { - if (activeProject()) - activeProject()->scheduleRuleSetRedraw(); + if (activeProject()) activeProject()->scheduleRuleSetRedraw(); } void FWWindow::redrawRuleSets() { - if (activeProject()) - activeProject()->redrawRuleSets(); + if (activeProject()) activeProject()->redrawRuleSets(); } void FWWindow::reopenFirewall() { - if (activeProject()) - activeProject()->reopenFirewall(); + if (activeProject()) activeProject()->reopenFirewall(); } void FWWindow::setEnabledAfterRF() @@ -689,14 +661,12 @@ void FWWindow::selectRules() m_mainWindow ->compileAction->setEnabled( true ); m_mainWindow ->installAction->setEnabled( true ); - if (activeProject()) - activeProject()->selectRules(); + if (activeProject()) activeProject()->selectRules(); } void FWWindow::unselectRules() { - if (activeProject()) - activeProject()->unselectRules(); + if (activeProject()) activeProject()->unselectRules(); } void FWWindow::disableActions(bool havePolicies) @@ -718,8 +688,7 @@ void FWWindow::disableActions(bool havePolicies) void FWWindow::editCopy() { - if (activeProject()) - activeProject()->editCopy(); + if (activeProject()) activeProject()->editCopy(); } void FWWindow::editCut() @@ -799,14 +768,12 @@ void FWWindow::install() void FWWindow::changeInfoStyle() { - if (activeProject()) - activeProject()->changeInfoStyle(); + if (activeProject()) activeProject()->changeInfoStyle(); } void FWWindow::insertRule() { - if (activeProject()) - activeProject()->insertRule(); + if (activeProject()) activeProject()->insertRule(); } void FWWindow::addRuleAfterCurrent() @@ -817,62 +784,52 @@ void FWWindow::addRuleAfterCurrent() void FWWindow::removeRule() { - if (activeProject()) - activeProject()->removeRule(); + if (activeProject()) activeProject()->removeRule(); } void FWWindow::moveRule() { - if (activeProject()) - activeProject()->moveRule(); + if (activeProject()) activeProject()->moveRule(); } void FWWindow::moveRuleUp() { - if (activeProject()) - activeProject()->moveRuleUp(); + if (activeProject()) activeProject()->moveRuleUp(); } void FWWindow::moveRuleDown() { - if (activeProject()) - activeProject()->moveRuleDown(); + if (activeProject()) activeProject()->moveRuleDown(); } void FWWindow::copyRule() { - if (activeProject()) - activeProject()->copyRule(); + if (activeProject()) activeProject()->copyRule(); } void FWWindow::cutRule() { - if (activeProject()) - activeProject()->cutRule(); + if (activeProject()) activeProject()->cutRule(); } void FWWindow::pasteRuleAbove() { - if (activeProject()) - activeProject()->pasteRuleAbove(); + if (activeProject()) activeProject()->pasteRuleAbove(); } void FWWindow::pasteRuleBelow() { - if (activeProject()) - activeProject()->pasteRuleBelow(); + if (activeProject()) activeProject()->pasteRuleBelow(); } void FWWindow::search() { - if (activeProject()) - activeProject()->search(); + if (activeProject()) activeProject()->search(); } void FWWindow::findWhereUsed(FWObject * obj) { - if (activeProject()) - activeProject()->findWhereUsed(obj); + if (activeProject()) activeProject()->findWhereUsed(obj); } void FWWindow::showEvent(QShowEvent *ev) @@ -889,14 +846,12 @@ void FWWindow::hideEvent(QHideEvent *ev) void FWWindow::back() { - if (activeProject()) - activeProject()->back(); + if (activeProject()) activeProject()->back(); } void FWWindow::newObject() { - if (activeProject()) - activeProject()->newObject(); + if (activeProject()) activeProject()->newObject(); } // ObjectManipulator::lockObject calls @@ -904,8 +859,7 @@ void FWWindow::newObject() // other windows void FWWindow::lockObject() { - if (activeProject()) - activeProject()->lockObject(); + if (activeProject()) activeProject()->lockObject(); } // ObjectManipulator::unlockObject calls @@ -913,8 +867,7 @@ void FWWindow::lockObject() // other windows void FWWindow::unlockObject() { - if (activeProject()) - activeProject()->unlockObject(); + if (activeProject()) activeProject()->unlockObject(); } void FWWindow::prepareObjectMenu() @@ -926,49 +879,81 @@ void FWWindow::prepareObjectMenu() m_mainWindow->ObjectLockAction->setEnabled(otv->isLockable()); } +void FWWindow::prepareFileMenu() +{ + if (!activeProject()) + { + m_mainWindow->fileCloseAction->setEnabled(false); + m_mainWindow->fileSaveAction->setEnabled(false); + m_mainWindow->fileSaveAsAction->setEnabled(false); + m_mainWindow->addToRCSAction->setEnabled(false); + m_mainWindow->fileCommitAction->setEnabled(false); + m_mainWindow->fileDiscardAction->setEnabled(false); + m_mainWindow->filePropAction->setEnabled(false); + return; + } + + bool real_file_opened = (activeProject()->getFileName() != ""); + bool in_rcs = (activeProject()->getRCS() != NULL && + activeProject()->getRCS()->isCheckedOut()); + + if (fwbdebug) + qDebug("FWWindow::prepareFileMenu(): activeProject()=%p" + " activeProject()->getFileName()='%s'", + activeProject(), + activeProject()->getFileName().toAscii().constData()); + + m_mainWindow->fileSaveAction->setEnabled(real_file_opened); + m_mainWindow->fileCloseAction->setEnabled(real_file_opened); + m_mainWindow->filePropAction->setEnabled(real_file_opened); + m_mainWindow->filePrintAction->setEnabled(real_file_opened); + m_mainWindow->libExportAction->setEnabled(real_file_opened); + + m_mainWindow->addToRCSAction->setEnabled(real_file_opened && !in_rcs); + m_mainWindow->fileCommitAction->setEnabled(real_file_opened && in_rcs); + m_mainWindow->fileDiscardAction->setEnabled(real_file_opened && in_rcs); + + m_mainWindow->fileNewAction->setEnabled(true); + m_mainWindow->fileOpenAction->setEnabled(true); + m_mainWindow->fileSaveAsAction->setEnabled(true); +} + void FWWindow::setupAutoSave() { - if (activeProject()) - activeProject()->setupAutoSave(); + if (activeProject()) activeProject()->setupAutoSave(); } QString FWWindow::getCurrentFileName() { - if (activeProject()) - return activeProject()->getCurrentFileName(); + if (activeProject()) return activeProject()->getCurrentFileName(); return ""; } RCS * FWWindow::getRCS() { - if (activeProject()) - return activeProject()->getRCS(); + if (activeProject()) return activeProject()->getRCS(); return 0; } void FWWindow::findObject(FWObject *o) { - if (activeProject()) - activeProject()->findObject(o); + if (activeProject()) activeProject()->findObject(o); } void FWWindow::closeAuxiliaryPanel() { - if (activeProject()) - activeProject()->closeAuxiliaryPanel(); + if (activeProject()) activeProject()->closeAuxiliaryPanel(); } void FWWindow::closeEditorPanel() { - if (activeProject()) - activeProject()->closeEditorPanel(); + if (activeProject()) activeProject()->closeEditorPanel(); } void FWWindow::openEditorPanel() { - if (activeProject()) - activeProject()->openEditorPanel(); + if (activeProject()) activeProject()->openEditorPanel(); } void FWWindow::editPrefs() @@ -1508,7 +1493,9 @@ void FWWindow::minimize() QList subWindowList = m_space->subWindowList(); for (int i = 0 ; i < subWindowList.size();i++) { - ProjectPanel * pp = dynamic_cast(subWindowList[i]->widget()); + ProjectPanel * pp = dynamic_cast( + subWindowList[i]->widget()); + if (pp!=NULL) { pp->loadState(); @@ -1547,6 +1534,7 @@ void FWWindow::recreateWindowsMenu () connect(cascade, SIGNAL(triggered()), m_space, SLOT(cascadeSubWindows())); connect(next, SIGNAL(triggered()),m_space, SLOT(activateNextSubWindow())); connect(previous, SIGNAL(triggered()),m_space, SLOT(activatePreviousSubWindow())); + QList subWindowList = getMdiArea()->subWindowList(); QActionGroup * ag = new QActionGroup ( this ); ag->setExclusive ( true ); @@ -1618,4 +1606,15 @@ void FWWindow::checkForUpgrade(const QString& server_response) } } +/* + * This slot is called after one of the mdi windows is closed. + */ +void FWWindow::projectWindowClosed() +{ + if (fwbdebug) qDebug("FWWindow::projectWindowClosed()"); + + if (m_space->subWindowList().size() == 0) + QCoreApplication::exit(0); +} + diff --git a/src/gui/FWWindow.h b/src/gui/FWWindow.h index c92778ebf..9d2c59a4d 100644 --- a/src/gui/FWWindow.h +++ b/src/gui/FWWindow.h @@ -157,7 +157,10 @@ public slots: virtual void newObject(); virtual void lockObject(); virtual void unlockObject(); + virtual void prepareObjectMenu(); + virtual void prepareFileMenu(); + virtual void toolsDiscoveryDruid(); virtual void closeAuxiliaryPanel(); virtual void closeEditorPanel(); @@ -166,7 +169,9 @@ public slots: virtual void killInstDialog(); virtual void checkForUpgrade(const QString&); - + + virtual void projectWindowClosed(); + public: Ui::FWBMainWindow_q *m_mainWindow; @@ -346,11 +351,6 @@ public slots: //find dialog functions wrapers void setFDObject(libfwbuilder::FWObject *o); - void addToRCSActionSetEn(bool en); - void fileDiscardActionSetEn(bool en); - void fileCommitActionSetEn(bool en); - void fileSaveActionSetEn(bool en); - QPrinter* getPrinter(); libfwbuilder::FWObjectDatabase* db(); QString printHeader(); diff --git a/src/gui/ProjectPanel.cpp b/src/gui/ProjectPanel.cpp index c206be133..e0e14aead 100644 --- a/src/gui/ProjectPanel.cpp +++ b/src/gui/ProjectPanel.cpp @@ -64,11 +64,26 @@ void ProjectPanel::initMain(FWWindow *main) // mdiWindow changes state several times right after it is opened, // but we call saveState to store splitter position and its geometry - // when state changed. Flag "ready" is false after ProjectPanel is created + // when state changes. Flag "ready" is false after ProjectPanel is created // and until FWWindow decides that ProjectPanel is ready for operation. // Do not load or save state if flag ready is false. ready = false; + int total_width = DEFAULT_H_SPLITTER_POSITION; + int total_height = DEFAULT_V_SPLITTER_POSITION; + + if (mainW) + { + total_width = mainW->width(); + total_height = mainW->height(); + } + + setMainSplitterPosition(DEFAULT_H_SPLITTER_POSITION, + total_width - DEFAULT_H_SPLITTER_POSITION); + setObjInfoSplitterPosition(DEFAULT_V_SPLITTER_POSITION, + total_height - DEFAULT_V_SPLITTER_POSITION); + + enableAvtoSaveState=true ; oldState=-1; if (st->getInfoStyle()!=0) m_panel->oi->show(); @@ -126,8 +141,7 @@ ProjectPanel::ProjectPanel(QWidget *parent): findObjectWidget(0), findWhereUsedWidget(0) { - if (fwbdebug) - qDebug("ProjectPanel constructor"); + if (fwbdebug) qDebug("ProjectPanel constructor"); m_panel = new Ui::ProjectPanel_q(); m_panel->setupUi(this); firstTimeNormal = st->getInt("Window/maximized"); @@ -550,7 +564,7 @@ QString ProjectPanel::getDestDir(const QString &fname) void ProjectPanel::setFileName(const QString &fname) { - systemFile=false; + systemFile = false; rcs->setFileName(fname); db()->setFileName(fname.toLatin1().constData()); @@ -1313,13 +1327,16 @@ void ProjectPanel::closeEvent( QCloseEvent * ev) mw->updateWindowTitle(); mw->recreateWindowsMenu(); - if (fwbdebug) qDebug("ProjectPanel::closeEvent all done"); + QTimer::singleShot( 0, mw, SLOT(projectWindowClosed()) ); + if (fwbdebug) qDebug("ProjectPanel::closeEvent all done"); // emit closed(); } QString ProjectPanel::getFileName() { + if (fwbdebug) qDebug("ProjectPanel::getFileName() : rcs=%p", rcs); + if (rcs!=NULL) { QString FileName = rcs->getFileName(); diff --git a/src/gui/ProjectPanel.h b/src/gui/ProjectPanel.h index 550998080..77711ba75 100644 --- a/src/gui/ProjectPanel.h +++ b/src/gui/ProjectPanel.h @@ -55,6 +55,10 @@ class FindWhereUsedWidget; class listOfLibraries; class FWBTree; +#define DEFAULT_H_SPLITTER_POSITION 250 +#define DEFAULT_V_SPLITTER_POSITION 450 + + class ProjectPanel: public QWidget { Q_OBJECT @@ -386,6 +390,9 @@ protected: virtual void resizeEvent ( QResizeEvent * event ); bool loadFile(const QString &fileName); + + void setMainSplitterPosition(int w1, int w2); + void setObjInfoSplitterPosition(int w1, int w2); }; #endif diff --git a/src/gui/ProjectPanel_file_ops.cpp b/src/gui/ProjectPanel_file_ops.cpp index 9070548d7..b9ef07f67 100644 --- a/src/gui/ProjectPanel_file_ops.cpp +++ b/src/gui/ProjectPanel_file_ops.cpp @@ -145,8 +145,10 @@ void ProjectPanel::fileProp() bool ProjectPanel::fileNew() { + if (fwbdebug) qDebug("ProjectPanel::fileNew()"); + QString nfn = chooseNewFileName( - st->getWDir(),true, + st->getWDir(), true, tr("Choose name and location for the new file")); if ( !nfn.isEmpty() ) @@ -162,22 +164,12 @@ bool ProjectPanel::fileNew() save(); setupAutoSave(); } - if (rcs!=NULL) - { - mainW->addToRCSActionSetEn( - !rcs->isInRCS() && !rcs->isRO() && !rcs->isTemp()); - mainW->fileDiscardActionSetEn( - rcs->isInRCS() && !rcs->isRO() && !rcs->isTemp()); - mainW->fileCommitActionSetEn( - rcs->isInRCS() && !rcs->isRO() && !rcs->isTemp()); - mainW->fileSaveActionSetEn( !rcs->isRO() && !rcs->isTemp() ); - return true ; - } - else - { - return false ; - } + if (fwbdebug) + qDebug("ProjectPanel::fileNew() rcs=%p rcs->getFileName()='%s'", + rcs, rcs->getFileName().toAscii().constData()); + + return (rcs!=NULL); } bool ProjectPanel::fileOpen() @@ -277,7 +269,7 @@ void ProjectPanel::fileClose() { if (fwbdebug) qDebug("ProjectPanel::fileClose(): start"); - closing=true ; + closing = true ; findObjectWidget->init(); if (isEditorVisible()) hideEditor(); @@ -328,13 +320,7 @@ void ProjectPanel::fileSaveAs() /* need to close the file without asking and saving, then reopen it again */ - db()->setDirty(false); // so it wont ask if user wants to save - rcs->abandon(); - QString oldFileName = rcs->getFileName(); - if (rcs!=NULL) delete rcs; - - rcs = new RCS(""); QString nfn = chooseNewFileName( oldFileName, true, @@ -342,17 +328,16 @@ void ProjectPanel::fileSaveAs() if (!nfn.isEmpty()) { + db()->setDirty(false); // so it wont ask if user wants to save + rcs->abandon(); + + if (rcs!=NULL) delete rcs; + + rcs = new RCS(""); + setFileName(nfn); save(); - - mainW->addToRCSActionSetEn( - !rcs->isInRCS() && !rcs->isRO() && !rcs->isTemp()); - mainW->fileDiscardActionSetEn( - rcs->isInRCS() && !rcs->isRO() && !rcs->isTemp()); - mainW->fileCommitActionSetEn( - rcs->isInRCS() && !rcs->isRO() && !rcs->isTemp()); - mainW->fileSaveActionSetEn( !rcs->isRO() && !rcs->isTemp() ); } } @@ -455,12 +440,6 @@ void ProjectPanel::fileAddToRCS() if (rcs->isRO()) caption = caption + " " + tr("(read-only)"); setWindowTitle( QString("Firewall Builder: ")+caption ); - - mainW->addToRCSActionSetEn( !rcs->isInRCS() && !rcs->isRO()); - mainW->fileDiscardActionSetEn( - rcs->isInRCS() && !rcs->isRO() && !rcs->isTemp()); - mainW->fileCommitActionSetEn( - rcs->isInRCS() && !rcs->isRO() && !rcs->isTemp()); } void ProjectPanel::fileImport() @@ -1005,11 +984,6 @@ void ProjectPanel::load(QWidget*) setWindowTitle( "Firewall Builder" ); - mainW->fileSaveActionSetEn( false ); - mainW->addToRCSActionSetEn( false ); - mainW->fileDiscardActionSetEn( false ); - mainW->fileCommitActionSetEn( false ); - loadObjects(); setupAutoSave(); @@ -1050,7 +1024,7 @@ void ProjectPanel::load(QWidget*, RCS* _rcs, FWObjectDatabase* clone) try { - systemFile=false; + systemFile = false; objdb = clone; sb->showMessage( tr("Loading system objects...") ); QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); @@ -1204,10 +1178,6 @@ void ProjectPanel::load(QWidget*, RCS* _rcs, FWObjectDatabase* clone) setWindowTitle( QString("Firewall Builder: ")+caption ); - mainW->fileSaveActionSetEn( !rcs->isRO() && !rcs->isTemp()); - mainW->addToRCSActionSetEn( !rcs->isInRCS() && !rcs->isRO()); - mainW->fileDiscardActionSetEn( rcs->isInRCS() && !rcs->isRO()); - mainW->fileCommitActionSetEn( rcs->isInRCS() && !rcs->isRO()); mainW->disableActions(m_panel->ruleSets->count()!=0); } catch(FWException &ex) @@ -1298,7 +1268,7 @@ void ProjectPanel::load(QWidget*, RCS *_rcs) try { /* load the data file */ - systemFile=false; + systemFile = false; objdb = new FWObjectDatabase(); @@ -1512,10 +1482,6 @@ void ProjectPanel::load(QWidget*, RCS *_rcs) setWindowTitle( QString("Firewall Builder: ")+caption ); - mainW->fileSaveActionSetEn( !rcs->isRO() && !rcs->isTemp()); - mainW->addToRCSActionSetEn( !rcs->isInRCS() && !rcs->isRO()); - mainW->fileDiscardActionSetEn( rcs->isInRCS() && !rcs->isRO()); - mainW->fileCommitActionSetEn( rcs->isInRCS() && !rcs->isRO()); mainW->disableActions(m_panel->ruleSets->count()!=0); } catch(FWException &ex) @@ -1536,12 +1502,12 @@ void ProjectPanel::load(QWidget*, RCS *_rcs) elem.truncate(LONG_ERROR_CUTOFF); msg+="\n"+tr("XML element : %1").arg(elem); } - QMessageBox::critical( - this,"Firewall Builder", - tr("The program encountered error trying to load data file.\n" - "The file has not been loaded. Error:\n%1").arg(msg), - tr("&Continue"), QString::null,QString::null, - 0, 1 ); + QMessageBox::critical( + this,"Firewall Builder", + tr("The program encountered error trying to load data file.\n" + "The file has not been loaded. Error:\n%1").arg(msg), + tr("&Continue"), QString::null,QString::null, + 0, 1 ); } else { QString error_txt = ex.toString().c_str(); @@ -1551,13 +1517,13 @@ void ProjectPanel::load(QWidget*, RCS *_rcs) error_txt += "\n\n" + tr("(Long error message was truncated)"); } - QMessageBox::critical( - this,"Firewall Builder", - tr("The program encountered error trying to load data file.\n" - "The file has not been loaded. Error:\n%1").arg( - error_txt), - tr("&Continue"), QString::null,QString::null, - 0, 1 ); + QMessageBox::critical( + this,"Firewall Builder", + tr("The program encountered error trying to load data file.\n" + "The file has not been loaded. Error:\n%1").arg( + error_txt), + tr("&Continue"), QString::null,QString::null, + 0, 1 ); } // load standard objects so the window does not remain empty load(this); @@ -1603,7 +1569,9 @@ bool ProjectPanel::checkin(bool unlock) QDialog *fsd_dialog = new QDialog(this); fsd.setupUi(fsd_dialog); fsd.checkinDialogTitle->setText( - QString("")+tr("Checking file %1 in RCS").arg(rcs->getFileName())+QString("") + QString("") + + tr("Checking file %1 in RCS").arg(rcs->getFileName()) + + QString("") ); if ( fsd_dialog->exec()== QDialog::Rejected ) { @@ -1647,8 +1615,12 @@ bool ProjectPanel::checkin(bool unlock) void ProjectPanel::save() { if (fwbdebug) - qDebug("ProjectPanel::save: rcs=%p rcs->isRO=%d rcs->isTemp=%d rcs->getFileName=%s", - rcs, rcs->isRO(), rcs->isTemp(), rcs->getFileName().toLatin1().constData()); + qDebug("ProjectPanel::save: rcs=%p rcs->isRO=%d " + "rcs->isTemp=%d rcs->getFileName=%s", + rcs, + rcs->isRO(), + rcs->isTemp(), + rcs->getFileName().toLatin1().constData()); if (!rcs->isRO() && !rcs->isTemp()) { @@ -1690,8 +1662,12 @@ void ProjectPanel::save() /* exported libraries are always read-only */ list ll = ndb->getByType(Library::TYPENAME); for (FWObject::iterator i=ll.begin(); i!=ll.end(); i++) - if ((*i)->getId()!=FWObjectDatabase::STANDARD_LIB_ID && - (*i)->getId()!=FWObjectDatabase::DELETED_OBJECTS_ID) (*i)->setReadOnly( true ); + { + if ((*i)->getId()!=FWObjectDatabase::STANDARD_LIB_ID + && + (*i)->getId()!=FWObjectDatabase::DELETED_OBJECTS_ID) + (*i)->setReadOnly( true ); + } } ndb->resetTimeLastModified( db()->getTimeLastModified() ); @@ -1718,10 +1694,9 @@ void ProjectPanel::save() * error message in the exception, let's check for obvious problems here */ QString err; - if (access( rcs->getFileName().toLatin1().constData(), W_OK)!=0 && errno==EACCES) - err=tr("File is read-only"); - else - err=ex.toString().c_str(); + if (access( rcs->getFileName().toLatin1().constData(), W_OK)!=0 && + errno==EACCES) err=tr("File is read-only"); + else err=ex.toString().c_str(); QMessageBox::critical( this,"Firewall Builder", diff --git a/src/gui/ProjectPanel_state_ops.cpp b/src/gui/ProjectPanel_state_ops.cpp index e72e67e99..a605cf655 100644 --- a/src/gui/ProjectPanel_state_ops.cpp +++ b/src/gui/ProjectPanel_state_ops.cpp @@ -41,9 +41,6 @@ using namespace Ui; using namespace libfwbuilder; using namespace std; -#define DEFAULT_H_SPLITTER_POSITION 250 -#define DEFAULT_V_SPLITTER_POSITION 450 - // this slot is called when user hits "maximize" or "minimize" buttons // on the title bar of the internal window. Need to restore window // geometry and splitter position when window becomes normal (not maximized). @@ -179,11 +176,7 @@ void ProjectPanel::loadState() qDebug(QString("%1: %2x%3").arg(h_splitter_setting). arg(w1).arg(w2).toAscii().data()); - QList sl; - sl.push_back(w1); - sl.push_back(w2); - if (w1 && w2) - m_panel->mainSplitter->setSizes( sl ); + setMainSplitterPosition(w1, w2); if (fwbdebug) qDebug("Restore info window splitter position"); @@ -200,14 +193,33 @@ void ProjectPanel::loadState() qDebug(QString("%1: %2x%3").arg(v_splitter_setting). arg(w1).arg(w2).toAscii().data()); - sl.clear(); - sl.push_back(w1); - sl.push_back(w2); - if (w1 && w2) - m_panel->objInfoSplitter->setSizes( sl ); - + setObjInfoSplitterPosition(w1, w2); if (fwbdebug) qDebug("ProjectPanel::loadState done"); } +void ProjectPanel::setMainSplitterPosition(int w1, int w2) +{ + if (w1 && w2) + { + QList sl; + sl.push_back(w1); + sl.push_back(w2); + if (fwbdebug) qDebug("Setting main splitter position: %d,%d", w1, w2); + m_panel->mainSplitter->setSizes( sl ); + } +} + +void ProjectPanel::setObjInfoSplitterPosition(int w1, int w2) +{ + if (w1 && w2) + { + QList sl; + sl.clear(); + sl.push_back(w1); + sl.push_back(w2); + m_panel->objInfoSplitter->setSizes( sl ); + } +} + diff --git a/src/res/os/freebsd.xml b/src/res/os/freebsd.xml index 9548c5f8d..6cc9a561f 100644 --- a/src/res/os/freebsd.xml +++ b/src/res/os/freebsd.xml @@ -1,5 +1,5 @@ - + FreeBSD freebsd diff --git a/src/res/os/fwsm_os.xml b/src/res/os/fwsm_os.xml index 64c329048..94cf48fd4 100644 --- a/src/res/os/fwsm_os.xml +++ b/src/res/os/fwsm_os.xml @@ -1,5 +1,5 @@ - + Cisco FWSM fwb_pix diff --git a/src/res/os/ios.xml b/src/res/os/ios.xml index 31bad8a5b..35077f1f7 100644 --- a/src/res/os/ios.xml +++ b/src/res/os/ios.xml @@ -1,5 +1,5 @@ - + Cisco IOS fwb_iosacl diff --git a/src/res/os/linksys.xml b/src/res/os/linksys.xml index 2e0703d98..2d278d657 100644 --- a/src/res/os/linksys.xml +++ b/src/res/os/linksys.xml @@ -1,5 +1,5 @@ - + Linksys/Sveasoft linux24 diff --git a/src/res/os/linux24.xml b/src/res/os/linux24.xml index 7013f5493..41b05748d 100644 --- a/src/res/os/linux24.xml +++ b/src/res/os/linux24.xml @@ -1,5 +1,5 @@ - + Linux 2.4/2.6 linux24 diff --git a/src/res/os/macosx.xml b/src/res/os/macosx.xml index 2e4e7333c..c0bbd6470 100644 --- a/src/res/os/macosx.xml +++ b/src/res/os/macosx.xml @@ -1,5 +1,5 @@ - + Mac OS X macosx diff --git a/src/res/os/openbsd.xml b/src/res/os/openbsd.xml index 736747479..436762321 100644 --- a/src/res/os/openbsd.xml +++ b/src/res/os/openbsd.xml @@ -1,5 +1,5 @@ - + OpenBSD openbsd diff --git a/src/res/os/pix_os.xml b/src/res/os/pix_os.xml index 7a23d2f34..0b11f5a1d 100644 --- a/src/res/os/pix_os.xml +++ b/src/res/os/pix_os.xml @@ -1,5 +1,5 @@ - + Cisco PIX fwb_pix diff --git a/src/res/os/solaris.xml b/src/res/os/solaris.xml index fe1e2b26f..a2c0b2f24 100644 --- a/src/res/os/solaris.xml +++ b/src/res/os/solaris.xml @@ -1,5 +1,5 @@ - + Solaris solaris diff --git a/src/res/os/unknown_os.xml b/src/res/os/unknown_os.xml index 13f019686..e9fb604b0 100644 --- a/src/res/os/unknown_os.xml +++ b/src/res/os/unknown_os.xml @@ -1,5 +1,5 @@ - + Unknown unknown diff --git a/src/res/platform/fwsm.xml b/src/res/platform/fwsm.xml index 30685896d..5a9a00e67 100644 --- a/src/res/platform/fwsm.xml +++ b/src/res/platform/fwsm.xml @@ -1,5 +1,5 @@ - + FWSM fwb_pix diff --git a/src/res/platform/iosacl.xml b/src/res/platform/iosacl.xml index bee1afaaa..470cfa61c 100644 --- a/src/res/platform/iosacl.xml +++ b/src/res/platform/iosacl.xml @@ -1,5 +1,5 @@ - + IOS ACL fwb_iosacl diff --git a/src/res/platform/ipf.xml b/src/res/platform/ipf.xml index bb5056dc4..f9cbdc93b 100644 --- a/src/res/platform/ipf.xml +++ b/src/res/platform/ipf.xml @@ -1,5 +1,5 @@ - + ipfilter fwb_ipf diff --git a/src/res/platform/ipfw.xml b/src/res/platform/ipfw.xml index c2258b157..ff8ebd191 100644 --- a/src/res/platform/ipfw.xml +++ b/src/res/platform/ipfw.xml @@ -1,5 +1,5 @@ - + ipfw fwb_ipfw diff --git a/src/res/platform/iptables.xml b/src/res/platform/iptables.xml index 57076da31..ac8e93cab 100644 --- a/src/res/platform/iptables.xml +++ b/src/res/platform/iptables.xml @@ -1,5 +1,5 @@ - + iptables fwb_ipt diff --git a/src/res/platform/pf.xml b/src/res/platform/pf.xml index f196aead8..4e73a6de5 100644 --- a/src/res/platform/pf.xml +++ b/src/res/platform/pf.xml @@ -1,5 +1,5 @@ - + PF fwb_pf diff --git a/src/res/platform/pix.xml b/src/res/platform/pix.xml index df5e3995b..a346c93bd 100644 --- a/src/res/platform/pix.xml +++ b/src/res/platform/pix.xml @@ -1,5 +1,5 @@ - + PIX fwb_pix diff --git a/src/res/platform/unknown.xml b/src/res/platform/unknown.xml index 580ca29ad..0f00126e7 100644 --- a/src/res/platform/unknown.xml +++ b/src/res/platform/unknown.xml @@ -1,5 +1,5 @@ - + Unknown diff --git a/src/res/resources.xml b/src/res/resources.xml index c1cd072d6..e1e6290d5 100644 --- a/src/res/resources.xml +++ b/src/res/resources.xml @@ -1,5 +1,5 @@ - + @PACKAGE_PIXMAPS_DIR@