Thread: [fwbuilder-commits] r1367 - in branches/v3_1_secunet: . doc src/gui
Brought to you by:
mikehorn
From: <va...@in...> - 2009-08-29 00:29:44
|
Author: vadim Date: 2009-08-28 17:26:12 -0700 (Fri, 28 Aug 2009) New Revision: 1367 Added: branches/v3_1_secunet/src/gui/events.h Modified: branches/v3_1_secunet/build_num branches/v3_1_secunet/doc/ChangeLog branches/v3_1_secunet/src/gui/ActionsDialog.cpp branches/v3_1_secunet/src/gui/CommentEditorPanel.cpp branches/v3_1_secunet/src/gui/FWWindow.cpp branches/v3_1_secunet/src/gui/FWWindow.h branches/v3_1_secunet/src/gui/FirewallDialog.cpp branches/v3_1_secunet/src/gui/InterfaceDialog.cpp branches/v3_1_secunet/src/gui/MetricEditorPanel.cpp branches/v3_1_secunet/src/gui/NetworkDialogIPv6.cpp branches/v3_1_secunet/src/gui/ObjectEditor.cpp branches/v3_1_secunet/src/gui/ObjectManipulator.cpp branches/v3_1_secunet/src/gui/ObjectManipulator.h branches/v3_1_secunet/src/gui/ObjectTreeView.cpp branches/v3_1_secunet/src/gui/ProjectPanel.cpp branches/v3_1_secunet/src/gui/ProjectPanel.h branches/v3_1_secunet/src/gui/ProjectPanel_state_ops.cpp branches/v3_1_secunet/src/gui/RuleSetView.cpp branches/v3_1_secunet/src/gui/carpOptionsDialog.cpp branches/v3_1_secunet/src/gui/conntrackOptionsDialog.cpp branches/v3_1_secunet/src/gui/freebsdAdvancedDialog.cpp branches/v3_1_secunet/src/gui/global.h branches/v3_1_secunet/src/gui/gui.pro branches/v3_1_secunet/src/gui/heartbeatOptionsDialog.cpp branches/v3_1_secunet/src/gui/instDialog.cpp branches/v3_1_secunet/src/gui/iosAdvancedDialog.cpp branches/v3_1_secunet/src/gui/iosaclAdvancedDialog.cpp branches/v3_1_secunet/src/gui/ipcopAdvancedDialog.cpp branches/v3_1_secunet/src/gui/ipcoposAdvancedDialog.cpp branches/v3_1_secunet/src/gui/ipfAdvancedDialog.cpp branches/v3_1_secunet/src/gui/ipfwAdvancedDialog.cpp branches/v3_1_secunet/src/gui/iptAdvancedDialog.cpp branches/v3_1_secunet/src/gui/linksysAdvancedDialog.cpp branches/v3_1_secunet/src/gui/linux24AdvancedDialog.cpp branches/v3_1_secunet/src/gui/linux24IfaceOptsDialog.cpp branches/v3_1_secunet/src/gui/macosxAdvancedDialog.cpp branches/v3_1_secunet/src/gui/newFirewallDialog.cpp branches/v3_1_secunet/src/gui/newHostDialog.cpp branches/v3_1_secunet/src/gui/openaisOptionsDialog.cpp branches/v3_1_secunet/src/gui/openbsdAdvancedDialog.cpp branches/v3_1_secunet/src/gui/openbsdIfaceOptsDialog.cpp branches/v3_1_secunet/src/gui/pfAdvancedDialog.cpp branches/v3_1_secunet/src/gui/pfsyncOptionsDialog.cpp branches/v3_1_secunet/src/gui/pixAdvancedDialog.cpp branches/v3_1_secunet/src/gui/pixosAdvancedDialog.cpp branches/v3_1_secunet/src/gui/printerStream.cpp branches/v3_1_secunet/src/gui/secuwallAdvancedDialog.cpp branches/v3_1_secunet/src/gui/secuwallIfaceOptsDialog.cpp branches/v3_1_secunet/src/gui/solarisAdvancedDialog.cpp branches/v3_1_secunet/src/gui/vlanOnlyIfaceOptsDialog.cpp branches/v3_1_secunet/src/gui/vrrpOptionsDialog.cpp Log: * ProjectPanel.cpp (ProjectPanel::event): instead of several methods in FWWindow that scan all project panel windows and execute some operation, using user defined events. Currently have two events: dataModifiedEvent and updateObjectInTreeEvent. The first one signals that some object has changed so that ProjectPanel::event() can update timestamps and do other things. It then posts the second event, which it will catch and process on the next event processing run. The second event does UI updates. Both events carry file name and object ID. Only those ProjectPanel objects that have the same file process the event. Events are dispatched to project panels in FWWindow::event(). Concentrating all UI update logic in one place helps avoid unnecessary redraws. This replaces FWWIndow::updateLastModifiedTimestampForOneFirewall, FWWindow::updateLastModifiedTimestampForAllFirewalls, FWWindow::reloadAllWindowsWithFile. Modified: branches/v3_1_secunet/build_num =================================================================== --- branches/v3_1_secunet/build_num 2009-08-28 19:24:18 UTC (rev 1366) +++ branches/v3_1_secunet/build_num 2009-08-29 00:26:12 UTC (rev 1367) @@ -1 +1 @@ -#define BUILD_NUM 1365 +#define BUILD_NUM 1366 Modified: branches/v3_1_secunet/doc/ChangeLog =================================================================== --- branches/v3_1_secunet/doc/ChangeLog 2009-08-28 19:24:18 UTC (rev 1366) +++ branches/v3_1_secunet/doc/ChangeLog 2009-08-29 00:26:12 UTC (rev 1367) @@ -1,5 +1,21 @@ 2009-08-28 vadim <va...@vk...> + * ProjectPanel.cpp (ProjectPanel::event): instead of several + methods in FWWindow that scan all project panel windows and + execute some operation, using user defined events. Currently have + two events: dataModifiedEvent and updateObjectInTreeEvent. The + first one signals that some object has changed so that + ProjectPanel::event() can update timestamps and do other things. + It then posts the second event, which it will catch and process on + the next event processing run. The second event does UI updates. + Both events carry file name and object ID. Only those ProjectPanel + objects that have the same file process the event. Events are + dispatched to project panels in FWWindow::event(). Concentrating + all UI update logic in one place helps avoid unnecessary redraws. + This replaces FWWIndow::updateLastModifiedTimestampForOneFirewall, + FWWindow::updateLastModifiedTimestampForAllFirewalls, + FWWindow::reloadAllWindowsWithFile. + * interfaceProperties.cpp (interfaceProperties::manageIpAddresses): this is a generic method that implements a policy to decide whether generated script should manage ip addresses of a given Modified: branches/v3_1_secunet/src/gui/ActionsDialog.cpp =================================================================== --- branches/v3_1_secunet/src/gui/ActionsDialog.cpp 2009-08-28 19:24:18 UTC (rev 1366) +++ branches/v3_1_secunet/src/gui/ActionsDialog.cpp 2009-08-29 00:26:12 UTC (rev 1367) @@ -213,7 +213,7 @@ emit notify_changes_applied_sign(); - mw->updateLastModifiedTimestampForAllFirewalls(rule); +// mw->updateLastModifiedTimestampForAllFirewalls(rule); } void ActionsDialog::discardChanges() Modified: branches/v3_1_secunet/src/gui/CommentEditorPanel.cpp =================================================================== --- branches/v3_1_secunet/src/gui/CommentEditorPanel.cpp 2009-08-28 19:24:18 UTC (rev 1366) +++ branches/v3_1_secunet/src/gui/CommentEditorPanel.cpp 2009-08-29 00:26:12 UTC (rev 1367) @@ -115,10 +115,12 @@ { if (fwbdebug) qDebug("CommentEditorPanel::applyChanges()"); - mw->updateLastModifiedTimestampForAllFirewalls(rule); +// mw->updateLastModifiedTimestampForAllFirewalls(rule); rule->setComment( string(m_widget->editor->toPlainText().toUtf8().constData()) ); + + emit notify_changes_applied_sign(); } void CommentEditorPanel::getHelpName(QString *str) Modified: branches/v3_1_secunet/src/gui/FWWindow.cpp =================================================================== --- branches/v3_1_secunet/src/gui/FWWindow.cpp 2009-08-28 19:24:18 UTC (rev 1366) +++ branches/v3_1_secunet/src/gui/FWWindow.cpp 2009-08-29 00:26:12 UTC (rev 1367) @@ -64,6 +64,8 @@ #include "transferDialog.h" +#include "events.h" + #include "fwbuilder/FWReference.h" #include "fwbuilder/Policy.h" #include "fwbuilder/NAT.h" @@ -851,7 +853,6 @@ if (activeProject()) { activeProject()->editCut(); - reloadAllWindowsWithFile(activeProject()); } } @@ -860,7 +861,6 @@ if (activeProject()) { activeProject()->editDelete(); - reloadAllWindowsWithFile(activeProject()); } } @@ -869,7 +869,6 @@ if (activeProject()) { activeProject()->editPaste(); - reloadAllWindowsWithFile(activeProject()); } } @@ -1101,9 +1100,11 @@ if (fwbdebug) qDebug("FWWindow::prepareFileMenu(): activeProject()=%p" - " activeProject()->getFileName()='%s'", + " activeProject()->getFileName()='%s'" + " real_file_opened=%d needs_saving=%d", activeProject(), - activeProject()->getFileName().toAscii().constData()); + activeProject()->getFileName().toAscii().constData(), + real_file_opened, needs_saving); m_mainWindow->fileSaveAction->setEnabled(real_file_opened && needs_saving); m_mainWindow->fileCloseAction->setEnabled(real_file_opened); @@ -1279,43 +1280,6 @@ { } -/* - * find all windows that represent the same file as ProjectPanel pp - * and reload objects (except for the window attached to pp) - */ -void FWWindow::reloadAllWindowsWithFile(ProjectPanel *pp) -{ - if (fwbdebug) - qDebug("FWWindow::reloadAllWindowsWithFile pp=%p file=%s", - pp, pp->getRCS()->getFileName().toAscii().constData()); - - QList<QMdiSubWindow*> subWindowList = getMdiArea()->subWindowList(); - QString fileName = pp->getRCS()->getFileName(); - for (int i = 0 ; i < subWindowList.size(); i++) - { - ProjectPanel * other_pp = dynamic_cast<ProjectPanel*>( - subWindowList[i]->widget()); - if (pp==other_pp) continue; - if (other_pp->getRCS()->getFileName()==fileName) - { - FWObject *obj = other_pp->m_panel->om->getOpened(); - - if (fwbdebug) - qDebug("FWWindow::reloadAllWindowsWithFile " - "Object %p is opened in the other window", obj); - - other_pp->m_panel->om->loadObjects(); - - if (fwbdebug) - qDebug("FWWindow::reloadAllWindowsWithFile " - "Reopen object %p in the other window", obj); - - other_pp->m_panel->om->openObject(obj, false); - other_pp->mdiWindow->update(); - } - } -} - void FWWindow::closeRuleSetInAllWindowsWhereOpen(RuleSet *rs) { QList<QMdiSubWindow*> subWindowList = getMdiArea()->subWindowList(); @@ -1376,7 +1340,6 @@ if (activeProject()) { res = activeProject()->createObject(objType, objName, copyFrom); - reloadAllWindowsWithFile(activeProject()); } return res; } @@ -1391,7 +1354,6 @@ { res = activeProject()->createObject(parent, objType, objName, copyFrom); - reloadAllWindowsWithFile(activeProject()); } return res; } @@ -1401,7 +1363,6 @@ if (activeProject()) { activeProject()->moveObject(target, obj); - reloadAllWindowsWithFile(activeProject()); } } @@ -1410,7 +1371,6 @@ if (activeProject()) { activeProject()->moveObject(targetLibName, obj); - reloadAllWindowsWithFile(activeProject()); } } @@ -1419,7 +1379,6 @@ if (activeProject()) { activeProject()->updateLibColor(lib); - reloadAllWindowsWithFile(activeProject()); } } @@ -1428,7 +1387,6 @@ if (activeProject()) { activeProject()->updateLibName(lib); - reloadAllWindowsWithFile(activeProject()); } } @@ -1439,7 +1397,6 @@ if (activeProject()) { activeProject()->updateObjName(obj, oldName, askForAutorename); - reloadAllWindowsWithFile(activeProject()); } } @@ -1452,23 +1409,9 @@ { activeProject()->updateObjName(obj, oldName, oldLabel, askForAutorename); - reloadAllWindowsWithFile(activeProject()); } } - -void FWWindow::updateLastModifiedTimestampForOneFirewall(FWObject *o) -{ - if (activeProject()) - activeProject()->updateLastModifiedTimestampForOneFirewall(o); -} - -void FWWindow::updateLastModifiedTimestampForAllFirewalls(FWObject *o) -{ - if (activeProject()) - activeProject()->updateLastModifiedTimestampForAllFirewalls(o); -} - void FWWindow::updateLastInstalledTimestamp(FWObject *o) { if (activeProject()) activeProject()->updateLastInstalledTimestamp(o); @@ -1491,7 +1434,6 @@ if (activeProject()) { activeProject()->delObj(obj, openobj); - reloadAllWindowsWithFile(activeProject()); } } @@ -1663,7 +1605,6 @@ return false; } - void FWWindow::closeEvent(QCloseEvent* ev) { if (fwbdebug) qDebug("FWWindow::closeEvent"); @@ -1690,6 +1631,21 @@ } } +bool FWWindow::event(QEvent *event) +{ + if (event->type() >= QEvent::User) + { + // dispatch event to all projectpanel windows + QList<QMdiSubWindow*> subWindowList = getMdiArea()->subWindowList(); + for (int i = 0 ; i < subWindowList.size(); i++) + QCoreApplication::sendEvent(subWindowList[i]->widget(), event); + + event->accept(); + return true; + } + return QMainWindow::event(event); +} + void FWWindow::selectActiveSubWindow (/*const QString & text*/) { QObject * sender_ = sender (); Modified: branches/v3_1_secunet/src/gui/FWWindow.h =================================================================== --- branches/v3_1_secunet/src/gui/FWWindow.h 2009-08-28 19:24:18 UTC (rev 1366) +++ branches/v3_1_secunet/src/gui/FWWindow.h 2009-08-29 00:26:12 UTC (rev 1367) @@ -218,7 +218,6 @@ bool checkin(bool unlock); int findFirewallInList(libfwbuilder::FWObject *f); - void reloadAllWindowsWithFile(ProjectPanel *pp); void closeRuleSetInAllWindowsWhereOpen(libfwbuilder::RuleSet *rs); void closeObjectInAllWindowsWhereOpen(libfwbuilder::FWObject *obj); @@ -325,8 +324,6 @@ const QString &oldLabel, bool askForAutorename=true); - void updateLastModifiedTimestampForOneFirewall(libfwbuilder::FWObject *o); - void updateLastModifiedTimestampForAllFirewalls(libfwbuilder::FWObject *o); void updateLastInstalledTimestamp(libfwbuilder::FWObject *o); void updateLastCompiledTimestamp(libfwbuilder::FWObject *o); @@ -389,10 +386,10 @@ protected: - virtual void showEvent( QShowEvent *ev); - virtual void hideEvent( QHideEvent *ev); - virtual void closeEvent( QCloseEvent * ); - + virtual void showEvent(QShowEvent *ev); + virtual void hideEvent(QHideEvent *ev); + virtual void closeEvent(QCloseEvent *ev); + virtual bool event(QEvent *event); }; #endif Modified: branches/v3_1_secunet/src/gui/FirewallDialog.cpp =================================================================== --- branches/v3_1_secunet/src/gui/FirewallDialog.cpp 2009-08-28 19:24:18 UTC (rev 1366) +++ branches/v3_1_secunet/src/gui/FirewallDialog.cpp 2009-08-29 00:26:12 UTC (rev 1367) @@ -320,7 +320,7 @@ Resources::setDefaultTargetOptions(new_host_os, s); } - mw->updateLastModifiedTimestampForAllFirewalls(s); +// mw->updateLastModifiedTimestampForAllFirewalls(s); modified = false; emit notify_changes_applied_sign(); Modified: branches/v3_1_secunet/src/gui/InterfaceDialog.cpp =================================================================== --- branches/v3_1_secunet/src/gui/InterfaceDialog.cpp 2009-08-28 19:24:18 UTC (rev 1366) +++ branches/v3_1_secunet/src/gui/InterfaceDialog.cpp 2009-08-29 00:26:12 UTC (rev 1367) @@ -478,7 +478,8 @@ // update object tree (if interface type has changed, the object properties // summary text may have to change too) mw->activeProject()->updateObjectInTree(obj, true); - mw->updateLastModifiedTimestampForAllFirewalls(obj); +// mw->updateLastModifiedTimestampForAllFirewalls(obj); + emit notify_changes_applied_sign(); } } catch (FWException &ex) Modified: branches/v3_1_secunet/src/gui/MetricEditorPanel.cpp =================================================================== --- branches/v3_1_secunet/src/gui/MetricEditorPanel.cpp 2009-08-28 19:24:18 UTC (rev 1366) +++ branches/v3_1_secunet/src/gui/MetricEditorPanel.cpp 2009-08-29 00:26:12 UTC (rev 1367) @@ -75,9 +75,10 @@ void MetricEditorPanel::applyChanges() { - mw->updateLastModifiedTimestampForAllFirewalls(rule); +// mw->updateLastModifiedTimestampForAllFirewalls(rule); rule->setMetric( value() ); mw->updateRuleSetView(); + emit notify_changes_applied_sign(); } void MetricEditorPanel::discardChanges() Modified: branches/v3_1_secunet/src/gui/NetworkDialogIPv6.cpp =================================================================== --- branches/v3_1_secunet/src/gui/NetworkDialogIPv6.cpp 2009-08-28 19:24:18 UTC (rev 1366) +++ branches/v3_1_secunet/src/gui/NetworkDialogIPv6.cpp 2009-08-29 00:26:12 UTC (rev 1367) @@ -184,7 +184,7 @@ mw->updateObjName(obj,QString::fromUtf8(oldname.c_str())); //apply->setEnabled( false ); - mw->updateLastModifiedTimestampForAllFirewalls(obj); + //mw->updateLastModifiedTimestampForAllFirewalls(obj); emit notify_changes_applied_sign(); Modified: branches/v3_1_secunet/src/gui/ObjectEditor.cpp =================================================================== --- branches/v3_1_secunet/src/gui/ObjectEditor.cpp 2009-08-28 19:24:18 UTC (rev 1366) +++ branches/v3_1_secunet/src/gui/ObjectEditor.cpp 2009-08-29 00:26:12 UTC (rev 1367) @@ -50,8 +50,8 @@ #include "CommentEditorPanel.h" #include "ObjectManipulator.h" #include "Help.h" +#include "events.h" - #include "fwbuilder/Library.h" #include "fwbuilder/Firewall.h" #include "fwbuilder/Cluster.h" @@ -587,7 +587,10 @@ void ObjectEditor::notifyChangesApplied() { applyButton->setEnabled(false); - mw->updateLastModifiedTimestampForAllFirewalls(opened); + // send event so other project panels can reload themselves + QCoreApplication::postEvent( + mw, new dataModifiedEvent(opened->getRoot()->getFileName().c_str(), + opened->getId())); m_project->updateRuleSetView( ); } Modified: branches/v3_1_secunet/src/gui/ObjectManipulator.cpp =================================================================== --- branches/v3_1_secunet/src/gui/ObjectManipulator.cpp 2009-08-28 19:24:18 UTC (rev 1366) +++ branches/v3_1_secunet/src/gui/ObjectManipulator.cpp 2009-08-29 00:26:12 UTC (rev 1367) @@ -48,6 +48,7 @@ #include "FindWhereUsedWidget.h" #include "interfaceProperties.h" #include "interfacePropertiesObjectFactory.h" +#include "events.h" #include <QMessageBox> #include <QTextEdit> @@ -244,10 +245,9 @@ QString ObjectManipulator::getTreeLabel( FWObject *obj ) { - QString name; + QString name = QString::fromUtf8(obj->getName().c_str()); if (RuleSet::isA(obj)) { - name = QString::fromUtf8(obj->getName().c_str()); return name ; } if (Interface::isA(obj)) @@ -264,13 +264,16 @@ if (Interface::constcast(obj)->isSlave()) q =" slave"; if (Interface::constcast(obj)->isUnprotected()) q = q + " unp"; if (q!="") name = name+" (" + q + ")"; + return name; } - else + if (Firewall::isA(obj)) { - name = QString::fromUtf8(obj->getName().c_str()); - if (Library::isA(obj) && obj->isReadOnly()) - name = name+QObject::tr(" ( read only )"); + Firewall *fw = Firewall::cast(obj); + if (fw->needsInstall()) name += " *"; + return name; } + if (Library::isA(obj) && obj->isReadOnly()) + name += QObject::tr(" ( read only )"); return name; } @@ -499,29 +502,39 @@ QTreeWidgetItem *itm = allItems[obj]; assert(itm!=NULL); itm->setText(0, getTreeLabel(obj)); - QTreeWidgetItem *parent = itm->parent(); - if (parent) - { - parent->sortChildren(0, Qt::AscendingOrder);//(); - // workaround for QT4 bug - // http://www.qtsoftware.com/developer/task-tracker/index_html?method=entry&id=233975 - // Affects QT 4.4.1 - parent->setExpanded(false); - parent->setExpanded(true); - } + getCurrentObjectTree()->updateTreeItems(); if (subtree) { for (list<FWObject*>::iterator j=obj->begin(); j!=obj->end(); ++j) { FWObject *child_obj = *j; - // not all child objects are visible in the tree, so check if the tree item exists + // not all child objects are visible in the tree, so check + // if the tree item exists if (allItems.count(child_obj) > 0) { updateObjectInTree(child_obj, subtree); } } } + + QTreeWidgetItem *parent = itm->parent(); + if (parent) + { + parent->sortChildren(0, Qt::AscendingOrder);//(); +#if (QT_VERSION == 0x040401) + // workaround for QT4 bug + // http://www.qtsoftware.com/developer/task-tracker/index_html?method=entry&id=233975 + // Affects QT 4.4.1 + // + // This has a side effect in that the tree loses its scrollong + // position and scrolls all the way to the top. If the object + // being edited was in the middle or close to the bottom, it disappears + // from view. + parent->setExpanded(false); + parent->setExpanded(true); +#endif + } } /* @@ -556,7 +569,9 @@ if (fwbdebug) qDebug("ObjectManipulator::updateObjName autorename done"); } - updateObjectInTree(obj); + // Do not call updateObjectInTree because it will be called + // from ProjectPanel::event when we process updateObjectInTree event + //updateObjectInTree(obj); /* need to update name of the firewall in the drop-down list */ if (Firewall::isA(obj)) @@ -592,7 +607,9 @@ if ((QString::fromUtf8(obj->getName().c_str())!=oldName) && Interface::isA(obj)) autorename(obj, askForAutorename); - updateObjectInTree(obj); + // Do not call updateObjectInTree because it will be called + // from ProjectPanel::event when we process updateObjectInTree event + //updateObjectInTree(obj); Interface *i = Interface::cast(obj); if ((i!=NULL && i->getLabel()!=oldLabel.toLatin1().constData()) || @@ -699,8 +716,8 @@ QString name = getStandardName(parent, objtype, namesuffix); name = makeNameUnique(parent, name, objtype.c_str()); obj->setName(string(name.toUtf8())); - QTreeWidgetItem *itm1 = allItems[obj]; - if (itm1!=NULL) updateObjectInTree(obj); + //QTreeWidgetItem *itm1 = allItems[obj]; + //if (itm1!=NULL) updateObjectInTree(obj); } } @@ -731,15 +748,15 @@ { QString new_name("%1.%2"); obj->setName(new_name.arg(parent->getName().c_str()).arg(vlan_id).toStdString()); - QTreeWidgetItem *itm1 = allItems[obj]; - if (itm1!=NULL) updateObjectInTree(obj); + //QTreeWidgetItem *itm1 = allItems[obj]; + //if (itm1!=NULL) updateObjectInTree(obj); } } } } QString ObjectManipulator::getStandardName(FWObject *parent, - const string &objtype, + const string&, const string &namesuffix) { QStringList names; @@ -1885,9 +1902,12 @@ moveObject(targetLib, obj); } + + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), obj->getId())); } ot->freezeSelection(false); - mw->reloadAllWindowsWithFile(m_project); + } void ObjectManipulator::copyObj() @@ -1919,7 +1939,6 @@ { copyObj(); deleteObj(); // works with the list getCurrentObjectTree()->getSelectedObjects() - mw->reloadAllWindowsWithFile(m_project); } void ObjectManipulator::pasteObj() @@ -1986,7 +2005,6 @@ if (need_to_reload) loadObjects(); openObject(last_object); - mw->reloadAllWindowsWithFile(m_project); } bool ObjectManipulator::validateForPaste(FWObject *target, FWObject *obj, @@ -2232,7 +2250,10 @@ target_item->setExpanded(true); m_project->db()->setDirty(true); - mw->reloadAllWindowsWithFile(m_project); + + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), ta->getId())); + } void ObjectManipulator::lockObject() @@ -2257,8 +2278,11 @@ obj->setReadOnly(true); } getCurrentObjectTree()->setLockFlags(); - getCurrentObjectTree()->updateTreeItems(); - mw->reloadAllWindowsWithFile(m_project); + //getCurrentObjectTree()->updateTreeItems(); + + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), 0)); + } void ObjectManipulator::unlockObject() @@ -2281,8 +2305,11 @@ obj->setReadOnly(false); } getCurrentObjectTree()->setLockFlags(); - getCurrentObjectTree()->updateTreeItems(); - mw->reloadAllWindowsWithFile(m_project); +// getCurrentObjectTree()->updateTreeItems(); + + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), 0)); + } /* @@ -2455,7 +2482,6 @@ { } - mw->reloadAllWindowsWithFile(m_project); } void ObjectManipulator::delObj(FWObject *obj, bool openobj) @@ -2496,13 +2522,12 @@ "mw->closeObjectInAllWindowsWhereOpen"); mw->closeObjectInAllWindowsWhereOpen(obj); - try { - if (!islib && - !isDelObj && - obj->getId()!=FWObjectDatabase::TEMPLATE_LIB_ID) - updateLastModifiedTimestampForAllFirewalls(obj); +// if (!islib && +// !isDelObj && +// obj->getId()!=FWObjectDatabase::TEMPLATE_LIB_ID) +// updateLastModifiedTimestampForAllFirewalls(obj); if (fwbdebug) qDebug("ObjectManipulator::delObj delete islib=%d isfw=%d " @@ -2551,6 +2576,11 @@ QApplication::restoreOverrideCursor(); + // what object should we put in the even - the one that has been deleted + // or its parent? + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), obj->getId())); + // removeObjectFromTreeView(obj); m_project->scheduleRuleSetRedraw(); @@ -2660,6 +2690,9 @@ openObject(newgrp); editObject(newgrp); + + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), newgrp->getId())); } } @@ -3144,8 +3177,10 @@ parent_item->setExpanded(false); parent_item->setExpanded(true); + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), parent->getId())); + m_project->db()->setDirty(true); - mw->reloadAllWindowsWithFile(m_project); return nobj; } @@ -3154,6 +3189,10 @@ if (!validateDialog()) return; FWObject *nlib = m_project->createNewLibrary(m_project->db()); addTreePage( nlib ); + + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), nlib->getId())); + openObject( nlib ); editObject(nlib); } @@ -3174,12 +3213,13 @@ name+=QString().setNum(count); } } - FWObject *o=createObject(currentObj,Policy::TYPENAME,name); + FWObject *o = createObject(currentObj,Policy::TYPENAME,name); if (o!=NULL) { openObject(o); editObject(o); } + this->getCurrentObjectTree()->sortItems(0, Qt::AscendingOrder); } @@ -3200,12 +3240,13 @@ name += QString().setNum(count); } } - FWObject *o=createObject(currentObj,NAT::TYPENAME,name); + FWObject *o = createObject(currentObj,NAT::TYPENAME,name); if (o!=NULL) { openObject(o); editObject(o); } + this->getCurrentObjectTree()->sortItems(0, Qt::AscendingOrder); } @@ -3225,7 +3266,10 @@ openObject(o); editObject(o); } - mw->reloadAllWindowsWithFile(m_project); + + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), o->getId())); + } void ObjectManipulator::newCluster() @@ -3244,7 +3288,10 @@ openObject(o); editObject(o); } - mw->reloadAllWindowsWithFile(m_project); + + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), o->getId())); + } void ObjectManipulator::newClusterIface() @@ -3256,9 +3303,12 @@ Interface::TYPENAME); FWObject *o = createObject(currentObj, Interface::TYPENAME, new_name); - updateObjectInTree(o); + // Do not call updateObjectInTree because it will be called + // from ProjectPanel::event when we process updateObjectInTree event + //updateObjectInTree(o); openObject(o); - updateLastModifiedTimestampForAllFirewalls(o); + +// updateLastModifiedTimestampForAllFirewalls(o); editObject(o); } @@ -3298,7 +3348,7 @@ openObject(o); - updateLastModifiedTimestampForAllFirewalls(o); +// updateLastModifiedTimestampForAllFirewalls(o); editObject(o); } @@ -3324,12 +3374,13 @@ return; } - o = createObject(currentObj, FailoverClusterGroup::TYPENAME, tr("Failover group")); + o = createObject(currentObj, FailoverClusterGroup::TYPENAME, + tr("Failover group")); o->setStr("type", group_type.toStdString()); openObject(o); - updateLastModifiedTimestampForAllFirewalls(o); +// updateLastModifiedTimestampForAllFirewalls(o); editObject(o); } @@ -3349,7 +3400,10 @@ openObject(o); editObject(o); } - mw->reloadAllWindowsWithFile(m_project); + + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), o->getId())); + } QString ObjectManipulator::findNewestInterfaceName(FWObject *parent) @@ -3389,7 +3443,6 @@ supports_advanced_ifaces = Resources::getTargetCapabilityBool(h->getStr("host_OS"), "supports_subinterfaces"); - if (supports_advanced_ifaces) { parent = currentObj; @@ -3398,6 +3451,13 @@ } } + if (parent == NULL) + { + // since we can;t find quitable parent for the new interface, + // we can't create it. + return; + } + QString new_name = makeNameUnique(parent, findNewestInterfaceName(parent), Interface::TYPENAME); new_interface = Interface::cast( @@ -3412,7 +3472,7 @@ openObject(new_interface); - updateLastModifiedTimestampForAllFirewalls(new_interface); +// updateLastModifiedTimestampForAllFirewalls(new_interface); editObject(new_interface); } @@ -3428,7 +3488,7 @@ } void ObjectManipulator::newNetworkIPv6() { - FWObject *o=createObject(NetworkIPv6::TYPENAME,tr("Network IPv6")); + FWObject *o = createObject(NetworkIPv6::TYPENAME,tr("Network IPv6")); if (o!=NULL) { openObject(o); @@ -3522,7 +3582,7 @@ { openObject(o); editObject(o); - updateLastModifiedTimestampForAllFirewalls(o); +// updateLastModifiedTimestampForAllFirewalls(o); } } } @@ -3544,7 +3604,7 @@ { openObject(o); editObject(o); - updateLastModifiedTimestampForAllFirewalls(o); +// updateLastModifiedTimestampForAllFirewalls(o); } } } @@ -3587,7 +3647,7 @@ { openObject(o); editObject(o); - updateLastModifiedTimestampForAllFirewalls(o); +// updateLastModifiedTimestampForAllFirewalls(o); } } } @@ -3878,68 +3938,6 @@ clusters.push_back(Cluster::cast(*m)); } -void ObjectManipulator::updateLastModifiedTimestampForOneFirewall(FWObject *o) -{ - if (fwbdebug) qDebug("ObjectManipulator::updateLastModifiedTimestampForOneFirewall"); - - if (o==NULL) return; - - Firewall *f = Firewall::cast(o); - if (f==NULL) return; - - f->updateLastModifiedTimestamp(); - getCurrentObjectTree()->updateTreeItems (); - info(); -} - - -void ObjectManipulator::updateLastModifiedTimestampForAllFirewalls(FWObject *o) -{ - if (fwbdebug) qDebug("ObjectManipulator::updateLastModifiedTimestampForAllFirewalls"); - - if (o==NULL) return; - - QStatusBar *sb = mw->statusBar(); - sb->showMessage( tr("Searching for firewalls affected by the change...") ); - - QApplication::processEvents(QEventLoop::ExcludeUserInputEvents,100); - - if (fwbdebug) qDebug("ObjectManipulator::updateLastModifiedTimestampForAllFirewalls: setOverrideCursor"); - QApplication::setOverrideCursor(QCursor( Qt::WaitCursor)); - - list<Firewall *> fws = findFirewallsForObject(o); - if (fws.size()) - { - Firewall *f; - for (list<Firewall *>::iterator i=fws.begin(); - i!=fws.end(); - ++i) - { - f = *i; - f->updateLastModifiedTimestamp(); - list<Cluster*> clusters = findClustersUsingFirewall(f); - if (clusters.size() != 0) - { - list<Cluster*>::iterator it; - for (it=clusters.begin(); it!=clusters.end(); ++it) - { - Cluster *cl = *it; - cl->updateLastModifiedTimestamp(); - } - } - - } - - getCurrentObjectTree()->updateTreeItems (); - info(); - } - if (fwbdebug) qDebug("ObjectManipulator::updateLastModifiedTimestampForAllFirewalls: restoreOverrideCursor"); - QApplication::restoreOverrideCursor(); - sb->clearMessage(); - - QApplication::processEvents(QEventLoop::ExcludeUserInputEvents,100); -} - void ObjectManipulator::updateLastInstalledTimestamp(FWObject *o) { if (fwbdebug) qDebug("ObjectManipulator::updateLastInstalledTimestamp"); @@ -3951,7 +3949,8 @@ f->updateLastInstalledTimestamp(); if (visualUpdate) { - getCurrentObjectTree()->updateTreeItems (); + updateObjectInTree(o); +// getCurrentObjectTree()->updateTreeItems (); } info(); } @@ -3987,8 +3986,7 @@ fw->updateLastInstalledTimestamp(); } } - getCurrentObjectTree()->updateTreeItems(); - +// getCurrentObjectTree()->updateTreeItems(); } FWObject* ObjectManipulator::getSelectedObject() Modified: branches/v3_1_secunet/src/gui/ObjectManipulator.h =================================================================== --- branches/v3_1_secunet/src/gui/ObjectManipulator.h 2009-08-28 19:24:18 UTC (rev 1366) +++ branches/v3_1_secunet/src/gui/ObjectManipulator.h 2009-08-29 00:26:12 UTC (rev 1367) @@ -387,8 +387,6 @@ bool &newMenuItem, bool &inDeletedObjects); - void updateLastModifiedTimestampForOneFirewall(libfwbuilder::FWObject *o); - void updateLastModifiedTimestampForAllFirewalls(libfwbuilder::FWObject *o); void updateLastInstalledTimestamp(libfwbuilder::FWObject *o); void updateLastCompiledTimestamp(libfwbuilder::FWObject *o); Modified: branches/v3_1_secunet/src/gui/ObjectTreeView.cpp =================================================================== --- branches/v3_1_secunet/src/gui/ObjectTreeView.cpp 2009-08-28 19:24:18 UTC (rev 1366) +++ branches/v3_1_secunet/src/gui/ObjectTreeView.cpp 2009-08-29 00:26:12 UTC (rev 1367) @@ -193,8 +193,7 @@ return QTreeWidget::event(event); } - -void ObjectTreeView::currentItemChanged(QTreeWidgetItem *cur) +void ObjectTreeView::currentItemChanged(QTreeWidgetItem*) { expandOrCollapse = false; } @@ -323,14 +322,6 @@ if (obj->getRO()) itm->setIcon(0, pm_lock);//setPixmap(0, pm_lock ); else itm->setIcon(0, pm_obj ); - Firewall *fw=Firewall::cast(obj); - if (fw!=NULL) - { - itm->setText(0,(fw->needsInstall())? - QString::fromUtf8(fw->getName().c_str())+" *": - QString::fromUtf8(fw->getName().c_str())); - } - ++it; } Modified: branches/v3_1_secunet/src/gui/ProjectPanel.cpp =================================================================== --- branches/v3_1_secunet/src/gui/ProjectPanel.cpp 2009-08-28 19:24:18 UTC (rev 1366) +++ branches/v3_1_secunet/src/gui/ProjectPanel.cpp 2009-08-29 00:26:12 UTC (rev 1367) @@ -29,10 +29,15 @@ #include "utils.h" #include "utils_no_qt.h" +#include <fwbuilder/Cluster.h> +#include <fwbuilder/Firewall.h> #include <fwbuilder/RuleSet.h> #include <fwbuilder/Policy.h> #include <fwbuilder/NAT.h> #include <fwbuilder/Routing.h> +#include "fwbuilder/RuleSet.h" +#include "fwbuilder/Rule.h" +#include "fwbuilder/RuleElement.h" #include "FWBSettings.h" #include "FWBTree.h" @@ -44,6 +49,8 @@ #include "RCS.h" #include "RuleSetView.h" #include "findDialog.h" +#include "events.h" +#include "ObjectTreeView.h" #include <QMdiSubWindow> #include <QMdiArea> @@ -675,27 +682,6 @@ } -void ProjectPanel::updateLastModifiedTimestampForOneFirewall(FWObject *o) -{ - m_panel->om->updateLastModifiedTimestampForOneFirewall(o); -} - -void ProjectPanel::updateLastModifiedTimestampForAllFirewalls(FWObject *o) -{ - m_panel->om->updateLastModifiedTimestampForAllFirewalls(o); -} - -void ProjectPanel::updateLastInstalledTimestamp(FWObject *o) -{ - m_panel->om->updateLastInstalledTimestamp(o); -} - -void ProjectPanel::updateLastCompiledTimestamp(FWObject *o) -{ - m_panel->om->updateLastCompiledTimestamp(o); -} - - FWObject* ProjectPanel::pasteTo(FWObject *target, FWObject *obj) { return m_panel->om->pasteTo(target, obj); @@ -1401,3 +1387,141 @@ cln->copySet = copySet; return cln; } + +bool ProjectPanel::event(QEvent *event) +{ + if (event->type() == (QEvent::User + DATA_MODIFIED_EVENT)) + { + // This event does not trigger any updates in the UI, this + // purely data structure update event. However, we post + // updateObjectInTreeEvent even here to trigger UI updates. + dataModifiedEvent *ev = dynamic_cast<dataModifiedEvent*>(event); + QString data_file = ev->getFileName(); + int obj_id = ev->getObjectId(); + if ((rcs && rcs->getFileName() == data_file) || + (!rcs && data_file.isEmpty())) + { + FWObject *obj = db()->findInIndex(obj_id); + if (fwbdebug) + qDebug("ProjectPanel %p: dataModifiedEvent received for file %s object %s", + this, data_file.toLatin1().constData(), obj->getName().c_str()); + + if (RuleElement::cast(obj) || Rule::cast(obj) || RuleSet::cast(obj)) + { + FWObject *p = obj; + while (p && Firewall::cast(p)==NULL) p = p->getParent(); + Firewall *f = Firewall::cast(p); + if (f) + { + f->updateLastModifiedTimestamp(); + QCoreApplication::postEvent( + mw, new updateObjectInTreeEvent(data_file, + f->getId())); + } + } else + { + QCoreApplication::postEvent( + mw, new updateObjectInTreeEvent(data_file, obj->getId())); + updateLastModifiedTimestampForAllFirewalls(obj); + } + ev->accept(); + return true; + } + } + + if (event->type() == (QEvent::User + UPDATE_OBJECT_IN_TREE_EVENT)) + { + updateObjectInTreeEvent *ev = dynamic_cast<updateObjectInTreeEvent*>(event); + QString data_file = ev->getFileName(); + int obj_id = ev->getObjectId(); + if ((rcs && rcs->getFileName() == data_file) || + (!rcs && data_file.isEmpty())) + { + if (fwbdebug) + qDebug("ProjectPanel %p: updateObjectInTreeEvent received for file %s", + this, data_file.toLatin1().constData()); + FWObject *obj = db()->findInIndex(obj_id); + if (RuleElement::cast(obj) || Rule::cast(obj) || RuleSet::cast(obj)) + { + ;; + } else + { + m_panel->om->updateObjectInTree(obj, true); + m_panel->om->info(); +// FWObject *currnetly_opened = m_panel->om->getOpened(); +// m_panel->om->loadObjects(); +// m_panel->om->openObject(currnetly_opened, false); +// mdiWindow->update(); + } + mdiWindow->update(); + } + + // we never stop propagation of this event because there can + // be another project panel object with the same file. + } + + return QWidget::event(event); +} + +void ProjectPanel::updateLastModifiedTimestampForAllFirewalls(FWObject *obj) +{ + if (fwbdebug) + qDebug("ProjectPanel::updateLastModifiedTimestampForAllFirewalls"); + + if (obj==NULL) return; + + QStatusBar *sb = mw->statusBar(); + sb->showMessage( tr("Searching for firewalls affected by the change...") ); + + QApplication::processEvents(QEventLoop::ExcludeUserInputEvents,100); + + QApplication::setOverrideCursor(QCursor( Qt::WaitCursor)); + + list<Firewall *> fws = m_panel->om->findFirewallsForObject(obj); + if (fws.size()) + { + Firewall *f; + for (list<Firewall *>::iterator i=fws.begin(); + i!=fws.end(); + ++i) + { + f = *i; + if (f==obj) continue; + + f->updateLastModifiedTimestamp(); + QCoreApplication::postEvent( + mw, new updateObjectInTreeEvent(getFileName(), f->getId())); + + list<Cluster*> clusters = m_panel->om->findClustersUsingFirewall(f); + if (clusters.size() != 0) + { + list<Cluster*>::iterator it; + for (it=clusters.begin(); it!=clusters.end(); ++it) + { + Cluster *cl = *it; + cl->updateLastModifiedTimestamp(); + QCoreApplication::postEvent( + mw, new updateObjectInTreeEvent(getFileName(), cl->getId())); + } + } + } + +// getCurrentObjectTree()->updateTreeItems(); + info(); + } + QApplication::restoreOverrideCursor(); + sb->clearMessage(); + QApplication::processEvents(QEventLoop::ExcludeUserInputEvents,100); +} + +void ProjectPanel::updateLastInstalledTimestamp(FWObject *o) +{ + m_panel->om->updateLastInstalledTimestamp(o); +} + +void ProjectPanel::updateLastCompiledTimestamp(FWObject *o) +{ + m_panel->om->updateLastCompiledTimestamp(o); +} + + Modified: branches/v3_1_secunet/src/gui/ProjectPanel.h =================================================================== --- branches/v3_1_secunet/src/gui/ProjectPanel.h 2009-08-28 19:24:18 UTC (rev 1366) +++ branches/v3_1_secunet/src/gui/ProjectPanel.h 2009-08-29 00:26:12 UTC (rev 1367) @@ -170,8 +170,7 @@ const QString &oldLabel, bool askForAutorename=true); - void updateLastModifiedTimestampForOneFirewall(libfwbuilder::FWObject *o); - void updateLastModifiedTimestampForAllFirewalls(libfwbuilder::FWObject *o); + void updateLastModifiedTimestampForAllFirewalls(libfwbuilder::FWObject *o); void updateLastInstalledTimestamp(libfwbuilder::FWObject *o); void updateLastCompiledTimestamp(libfwbuilder::FWObject *o); @@ -394,6 +393,7 @@ virtual void hideEvent( QHideEvent *ev); virtual void closeEvent( QCloseEvent * ); virtual void resizeEvent ( QResizeEvent * event ); + virtual bool event(QEvent *event); void setMainSplitterPosition(int w1, int w2); void setObjInfoSplitterPosition(int w1, int w2); Modified: branches/v3_1_secunet/src/gui/ProjectPanel_state_ops.cpp =================================================================== --- branches/v3_1_secunet/src/gui/ProjectPanel_state_ops.cpp 2009-08-28 19:24:18 UTC (rev 1366) +++ branches/v3_1_secunet/src/gui/ProjectPanel_state_ops.cpp 2009-08-29 00:26:12 UTC (rev 1367) @@ -48,8 +48,8 @@ // 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). -void ProjectPanel::stateChanged(Qt::WindowStates oldState, - Qt::WindowStates newState) +void ProjectPanel::stateChanged(Qt::WindowStates , + Qt::WindowStates ) { #if 0 // vk 09/16 @@ -112,7 +112,7 @@ if (fwbdebug) qDebug("ProjectPanel::saveState() done"); } -void ProjectPanel::loadState(bool open_objects) +void ProjectPanel::loadState(bool) { int w1 = 0; int w2 = 0; Modified: branches/v3_1_secunet/src/gui/RuleSetView.cpp =================================================================== --- branches/v3_1_secunet/src/gui/RuleSetView.cpp 2009-08-28 19:24:18 UTC (rev 1366) +++ branches/v3_1_secunet/src/gui/RuleSetView.cpp 2009-08-29 00:26:12 UTC (rev 1367) @@ -62,6 +62,7 @@ #include "findDialog.h" #include "platforms.h" #include "FWBTree.h" +#include "events.h" #include <ui_askrulenumberdialog_q.h> @@ -2463,8 +2464,11 @@ setCurrentCell( table_row, currentColumn() ); updateCell(table_row, currentColumn()); - mw->reloadAllWindowsWithFile(m_project); + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), ruleset->getId())); + + return newrule; } @@ -2501,7 +2505,11 @@ insertRule(NULL, insertBefore, NULL); changingRules = false; - mw->updateLastModifiedTimestampForOneFirewall(getFirewall()); + + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), ruleset->getId())); + +// mw->updateLastModifiedTimestampForOneFirewall(getFirewall()); } void RuleSetView::addRuleAfterCurrent() @@ -2515,7 +2523,9 @@ insertRule(current_rule_at_pos, appendAfter, NULL); changingRules = false; - m_project->updateLastModifiedTimestampForOneFirewall(getFirewall()); + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), ruleset->getId())); +// m_project->updateLastModifiedTimestampForOneFirewall(getFirewall()); updateGroups(); } @@ -2584,8 +2594,11 @@ updateGroups(); changingRules = false; - m_project->updateLastModifiedTimestampForOneFirewall(getFirewall()); - mw->reloadAllWindowsWithFile(m_project); +// m_project->updateLastModifiedTimestampForOneFirewall(getFirewall()); + + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), ruleset->getId())); + } } @@ -3668,7 +3681,10 @@ } update(); - mw->reloadAllWindowsWithFile(m_project); + + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), ruleset->getId())); + } void RuleSetView::changeAction(PolicyRule::Action act) @@ -3690,13 +3706,16 @@ { rule->setAction( act ); if (!changingRules) - mw->updateLastModifiedTimestampForOneFirewall(getFirewall()); + { +// mw->updateLastModifiedTimestampForOneFirewall(getFirewall()); + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), ruleset->getId())); + } } ruleopt->setBool("stateless", getStatelessFlagForAction(rule)); mw->actionChangedEditor(rule); - mw->reloadAllWindowsWithFile(m_project); } } @@ -3789,9 +3808,12 @@ if (dir!=old_dir) { if (!changingRules) - mw->updateLastModifiedTimestampForOneFirewall(getFirewall()); + { +// mw->updateLastModifiedTimestampForOneFirewall(getFirewall()); + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), ruleset->getId())); + } rule->setDirection( dir ); - mw->reloadAllWindowsWithFile(m_project); } } } @@ -3821,9 +3843,12 @@ { PolicyRule *rule = PolicyRule::cast( ruleIndex[currentRow()] ); if (!changingRules) - mw->updateLastModifiedTimestampForOneFirewall(getFirewall()); + { +// mw->updateLastModifiedTimestampForOneFirewall(getFirewall()); + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), ruleset->getId())); + } rule->setLogging( true ); - mw->reloadAllWindowsWithFile(m_project); } } @@ -3837,9 +3862,12 @@ { PolicyRule *rule = PolicyRule::cast( ruleIndex[currentRow()] ); if (!changingRules) - mw->updateLastModifiedTimestampForOneFirewall(getFirewall()); + { +// mw->updateLastModifiedTimestampForOneFirewall(getFirewall()); + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), ruleset->getId())); + } rule->setLogging( false ); - mw->reloadAllWindowsWithFile(m_project); } } @@ -3892,8 +3920,8 @@ qDebug("obj->ref_counter=%d",rc); } - if (!changingRules) - mw->updateLastModifiedTimestampForOneFirewall(getFirewall()); +// if (!changingRules) +// mw->updateLastModifiedTimestampForOneFirewall(getFirewall()); re->removeRef(obj); @@ -3911,7 +3939,9 @@ adjustRow(row); updateCell(row,col); m_project->findObjectWidget->reset(); - mw->reloadAllWindowsWithFile(m_project); + + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), ruleset->getId())); } bool RuleSetView::insertObject(int row, int col, FWObject *obj) @@ -3980,10 +4010,12 @@ adjustColumn(col); adjustRow(row); updateCell(row, col); - mw->reloadAllWindowsWithFile(m_project); - if (!changingRules) - m_project->updateLastModifiedTimestampForOneFirewall(getFirewall()); + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), ruleset->getId())); + +// if (!changingRules) +// m_project->updateLastModifiedTimestampForOneFirewall(getFirewall()); return true; } @@ -4028,8 +4060,10 @@ } } - mw->reloadAllWindowsWithFile(m_project); + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), ruleset->getId())); + /* if (FWObjectClipboard::obj_clipboard->getObject()!=NULL) insertObject(currentRow(),currentColumn(), @@ -4048,11 +4082,14 @@ RuleElement *re = getRE(currentRow(),currentColumn()); if (re==NULL) return; re->toggleNeg(); - if (!changingRules) - m_project->updateLastModifiedTimestampForOneFirewall(getFirewall()); +// if (!changingRules) +// m_project->updateLastModifiedTimestampForOneFirewall(getFirewall()); updateCell(currentRow(),currentColumn()); - mw->reloadAllWindowsWithFile(m_project); + + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), ruleset->getId())); + } } @@ -4595,8 +4632,11 @@ QTimer::singleShot( 0, m_project, SLOT(reopenFirewall()) ); changingRules = false; - m_project->updateLastModifiedTimestampForOneFirewall(getFirewall()); - mw->reloadAllWindowsWithFile(m_project); +// m_project->updateLastModifiedTimestampForOneFirewall(getFirewall()); + + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), ruleset->getId())); + m_project->selectRules(); } } @@ -4720,7 +4760,10 @@ } changingRules = false; - m_project->updateLastModifiedTimestampForOneFirewall(getFirewall()); +// m_project->updateLastModifiedTimestampForOneFirewall(getFirewall()); + + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), ruleset->getId())); updateGroups(); } @@ -4776,7 +4819,9 @@ } changingRules = false; - m_project->updateLastModifiedTimestampForOneFirewall(getFirewall()); +// m_project->updateLastModifiedTimestampForOneFirewall(getFirewall()); + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), ruleset->getId())); updateGroups(); } @@ -4797,8 +4842,10 @@ } update(); //changingRules = false; - m_project->updateLastModifiedTimestampForOneFirewall(getFirewall()); - mw->reloadAllWindowsWithFile(m_project); +// m_project->updateLastModifiedTimestampForOneFirewall(getFirewall()); + + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), ruleset->getId())); } void RuleSetView::disableRule() @@ -4818,8 +4865,11 @@ } update(); //changingRules = false; - m_project->updateLastModifiedTimestampForOneFirewall(getFirewall()); - mw->reloadAllWindowsWithFile(m_project); +// m_project->updateLastModifiedTimestampForOneFirewall(getFirewall()); + + QCoreApplication::postEvent( + mw, new dataModifiedEvent(m_project->getFileName(), ruleset->getId())); + } void RuleSetView::editSelected() Modified: branches/v3_1_secunet/src/gui/carpOptionsDialog.cpp =================================================================== --- branches/v3_1_secunet/src/gui/carpOptionsDialog.cpp 2009-08-28 19:24:18 UTC (rev 1366) +++ branches/v3_1_secunet/src/gui/carpOptionsDialog.cpp 2009-08-29 00:26:12 UTC (rev 1367) @@ -85,7 +85,7 @@ { if (!validate()) return; data.saveAll(); - mw->updateLastModifiedTimestampForAllFirewalls(obj); +// mw->updateLastModifiedTimestampForAllFirewalls(obj); QDialog::accept(); } Modified: branches/v3_1_secunet/src/gui/conntrackOptionsDialog.cpp =================================================================== --- branches/v3_1_secunet/src/gui/conntrackOptionsDialog.cpp 2009-08-28 19:24:18 UTC (rev 1366) +++ branches/v3_1_secunet/src/gui/conntrackOptionsDialog.cpp 2009-08-29 00:26:12 UTC (rev 1367) @@ -85,7 +85,7 @@ { if (!validate()) return; data.saveAll(); - mw->updateLastModifiedTimestampForAllFirewalls(obj); +// mw->updateLastModifiedTimestampForAllFirewalls(obj); QDialog::accept(); } Added: branches/v3_1_secunet/src/gui/events.h =================================================================== --- branches/v3_1_secunet/src/gui/events.h (rev 0) +++ branches/v3_1_secunet/src/gui/events.h 2009-08-29 00:26:12 UTC (rev 1367) @@ -0,0 +1,74 @@ +/* + + Firewall Builder + + Copyright (C) 2009 NetCitadel, LLC + + Author: Vadim Kurland va...@fw... + + $Id: global.h 1074 2009-06-15 00:29:25Z vadim $ + + This program is free software which we release under the GNU General Public + License. You may redistribute and/or modify this program under the terms + of that license as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + To get a copy of the GNU General Public License, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ + +#ifndef FWBUILDER_EVENTS_HH +#define FWBUILDER_EVENTS_HH + +#include "global.h" +#include <QEvent> + +/* Custom event types. QEvent::registerEventType is only available + starting QT 4.4 but we have to support QT 4.3 for Ubuntu Hardy so + need to allocate types manually for now. Event types are defined as + increments above QEvent::User +*/ + +#define DATA_MODIFIED_EVENT 1 +#define UPDATE_OBJECT_IN_TREE_EVENT 2 + + +// Using event type DATA_MODIFIED_EVENT defined in global.h +class dataModifiedEvent : public QEvent { + QString data_file_name; + int object_id; +public: + dataModifiedEvent(const QString &file_name, int obj_id) : + QEvent(QEvent::Type(QEvent::User + DATA_MODIFIED_EVENT)) { + data_file_name = file_name; + object_id = obj_id; + } + QString getFileName() { return data_file_name; } + int getObjectId() { return object_id; } +}; + + +class updateObjectInTreeEvent : public QEvent { + QString data_file_name; + int object_id; +public: + updateObjectInTreeEvent(const QString &file_name, int obj_id) : + QEvent(QEvent::Type(QEvent::User + UPDATE_OBJECT_IN_TREE_EVENT)) { + data_file_name = file_name; + object_id = obj_id; + } + QString getFileName() { return data_file_name; } + int getObjectId() { return object_id; } +}; + + + + + +#endif Modified: branches/v3_1_secunet/src/gui/freebsdAdvancedDialog.cpp =================================================================== --- branches/v3_1_secunet/src/gui/freebsdAdvancedDialog.cpp 2009-08-28 19:24:18 UTC (rev 1366) +++ branches/v3_1_secunet/src/gui/freebsdAdvancedDialog.cpp 2009-08-29 00:26:12 UTC (rev 1367) @@ -112,7 +112,7 @@ assert(mgmt!=NULL); data.saveAll(); - mw->updateLastModifiedTimestampForAllFirewalls(obj); +// mw->updateLastModifiedTimestampForAllFirewalls(obj); QDialog::accept(); } Modified: branches/v3_1_secunet/src/gui/global.h =================================================================== --- branches/v3_1_secunet/src/gui/global.h 2009-08-28 19:24:18 UTC (rev 1366) +++ branches/v3_1_secunet/src/gui/global.h 2009-08-29 00:26:12 UTC (rev 1367) @@ -29,6 +29,8 @@ #include "../../VERSION.h" #include <string> +#include <QEvent> + class QApplication; class FWWindow; class FWBSettings; Modified: branches/v3_1_secunet/src/gui/gui.pro =================================================================== --- branches/v3_1_secunet/src/gui/gui.pro 2009-08-28 19:24:18 UTC (rev 1366) +++ branches/v3_1_secunet/src/gui/gui.pro 2009-08-29 00:26:12 UTC (rev 1367) @@ -35,6 +35,7 @@ # CONFIG += precompile_header HEADERS += ../../config.h \ + events.h \ FWWindow.h \ ProjectPanel.h \ utils.h \ Modified: branches/v3_1_secunet/src/gui/heartbeatOptionsDialog.cpp =================================================================== --- branches/v3_1_secunet/src/gui/heartbeatOptionsDialog.cpp 2009-08-28 19:24:18 UTC (rev 1366) +++ branches/v3_1_secunet/src/gui/heartbeatOptionsDialog.cpp 2009-08-29 00:26:12 UTC (rev 1367) @@ -86,7 +86,7 @@ { if (!validate()) return; data.saveAll(); - mw->updateLastModifiedTimestampForAllFirewalls(obj); +// mw->updateLastModifiedTimestampForAllFirewalls(obj); QDialog::accept(); } Modified: branches/v3_1_secunet/src/gui/instDialog.cpp =================================================================== --- branches/v3_1_secunet/src/gui/instDialog.cpp 2009-08-28 19:24:18 UTC (rev 1366) +++ branches/v3_1_secunet/src/gui/instDialog.cpp 2009-08-29 00:26:12 UTC (rev 1367) @@ -407,7 +407,6 @@ bool instDialog::checkSSHPathConfiguration(Firewall *fw) { if (fwbdebug) qDebug("instDialog::checkSSHPathConfiguration"); - FWOptions *fwopt = fw->getOptionsObject(); customScriptFlag = false; Management *mgmt = fw->getManagementObject(); Modified: branches/v3_1_secunet/src/gui/iosAdvancedDialog.cpp =================================================================== --- branches/v3_1_secunet/src/gui/iosAdvancedDialog.cpp 2009-08-28 19:24:18 UTC (rev 1366) +++ branches/v3_1_secunet/src/gui/iosAdvancedDialog.cpp 2009-08-29 00:26:12 UTC (rev 1367) @@ -80,7 +80,7 @@ void iosAdvancedDialog::accept() { data.saveAll(); - mw->updateLastModifiedTimestampForAllFirewalls(obj); +// mw->updateLastModifiedTimestampForAllFirewalls(obj); QDialog::accept(); } Modified: branches/v3_1_secunet/src/gui/iosaclAdvancedDialog.cpp =================================================================== --- branches/v3_1_secunet/src/gui/iosaclAdvancedDialog.cpp 2009-08-28 19:24:18 UTC (rev 1366) +++ branches/v3_1_secunet/src/gui/iosaclAdvancedDialog.cpp 2009-08-29 00:26:12 UTC (rev 1367) @@ -362,7 +362,7 @@ pis->setCommand( m_dialog->installScript->text().toLatin1().constData() ); pis->setArguments( m_dialog->instal... [truncated message content] |