mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-03-24 04:07:55 +01:00
getting rid of getAllMdiObjectManipulators in ObjectManipulator, moving loop to FWWindow
This commit is contained in:
parent
0615ac8b1c
commit
a4058de026
@ -1,3 +1,16 @@
|
||||
2008-07-26 Vadim Kurland <vadim@vk.crocodile.org>
|
||||
|
||||
* ObjectManipulator.cpp (ObjectManipulator::moveObj): code
|
||||
refactoring and cleaning up. Movig all loops over mdi child
|
||||
windows from ObjectManipulator class to the FWWindow class that
|
||||
owns all children windows. Along the way fixed few bugs, such as
|
||||
restored functions "Duplicate to .. " and "Move to ..." that are
|
||||
available via context menu associated with an object in the tree.
|
||||
|
||||
* ProjectPanel_file_ops.cpp (ProjectPanel::saveIfModified):
|
||||
refactored class ProjectPanel to keep code more organized in
|
||||
several modules.
|
||||
|
||||
2008-07-25 Vadim Kurland <vadim@vk.crocodile.org>
|
||||
|
||||
* FWWindow.cpp (FWWindow::closeEvent): properly checking for
|
||||
|
||||
@ -545,7 +545,8 @@ QString FWObjectPropertiesFactory::getRuleActionProperties(PolicyRule *rule)
|
||||
|
||||
FWObject *o = rule;
|
||||
while (o!=NULL && Firewall::cast(o)==NULL) o=o->getParent();
|
||||
assert(o!=NULL);
|
||||
if (o==NULL) return "";
|
||||
|
||||
Firewall *f=Firewall::cast(o);
|
||||
string platform=f->getStr("platform");
|
||||
|
||||
|
||||
@ -140,6 +140,8 @@
|
||||
#include <QMdiSubWindow>
|
||||
#include <QSignalMapper>
|
||||
#include "ProjectPanel.h"
|
||||
|
||||
|
||||
using namespace libfwbuilder;
|
||||
using namespace std;
|
||||
using namespace Ui;
|
||||
@ -203,7 +205,6 @@ ProjectPanel *FWWindow::newProjectPanel()
|
||||
{
|
||||
ProjectPanel *projectW = new ProjectPanel(m_space);
|
||||
projectW->initMain(this);
|
||||
|
||||
return projectW;
|
||||
}
|
||||
|
||||
@ -232,8 +233,7 @@ void FWWindow::showSub(ProjectPanel *projectW)
|
||||
ProjectPanel* FWWindow::activeProject()
|
||||
{
|
||||
QMdiSubWindow *w = m_space->currentSubWindow();
|
||||
if (w)
|
||||
return dynamic_cast<ProjectPanel*>(w->widget());
|
||||
if (w) return dynamic_cast<ProjectPanel*>(w->widget());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -283,23 +283,19 @@ void FWWindow::debug()
|
||||
|
||||
void FWWindow::info(FWObject *obj, bool forced)
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug("FWWindow::info called");
|
||||
if (activeProject())
|
||||
activeProject()->info(obj, forced);
|
||||
if (fwbdebug) qDebug("FWWindow::info called");
|
||||
if (activeProject()) activeProject()->info(obj, forced);
|
||||
}
|
||||
|
||||
bool FWWindow::saveIfModified()
|
||||
{
|
||||
if (activeProject())
|
||||
return activeProject()->saveIfModified();
|
||||
if (activeProject()) return activeProject()->saveIfModified();
|
||||
return false;
|
||||
}
|
||||
|
||||
QString FWWindow::getDestDir(const QString &fname)
|
||||
{
|
||||
if (activeProject())
|
||||
return activeProject()->getDestDir(fname);
|
||||
if (activeProject()) return activeProject()->getDestDir(fname);
|
||||
return "";
|
||||
}
|
||||
|
||||
@ -313,14 +309,12 @@ QString FWWindow::chooseNewFileName(const QString &fname,
|
||||
|
||||
void FWWindow::setFileName(const QString &fname)
|
||||
{
|
||||
if (activeProject())
|
||||
activeProject()->setFileName(fname);
|
||||
if (activeProject()) activeProject()->setFileName(fname);
|
||||
}
|
||||
|
||||
void FWWindow::fileProp()
|
||||
{
|
||||
if (activeProject())
|
||||
activeProject()->fileProp();
|
||||
if (activeProject()) activeProject()->fileProp();
|
||||
}
|
||||
|
||||
void FWWindow::fileNew()
|
||||
@ -362,20 +356,6 @@ void FWWindow::fileOpen()
|
||||
std::auto_ptr<ProjectPanel> proj(newProjectPanel());
|
||||
if (proj->fileOpen())
|
||||
{
|
||||
if (activeProject()!=NULL)
|
||||
{
|
||||
if (activeProject()->getRCS()!=NULL)
|
||||
{
|
||||
if (activeProject()->getRCS()->getFileName()=="")
|
||||
{
|
||||
m_space->removeSubWindow(m_space->currentSubWindow());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_space->removeSubWindow(m_space->currentSubWindow());
|
||||
}
|
||||
}
|
||||
showSub(proj.get());
|
||||
proj->readyStatus(true);
|
||||
proj->loadState();
|
||||
@ -386,21 +366,18 @@ void FWWindow::fileOpen()
|
||||
|
||||
void FWWindow::fileClose()
|
||||
{
|
||||
if (activeProject())
|
||||
activeProject()->fileClose();
|
||||
if (activeProject()) activeProject()->fileClose();
|
||||
recreateWindowsMenu();
|
||||
}
|
||||
|
||||
void FWWindow::fileSave()
|
||||
{
|
||||
if (activeProject())
|
||||
activeProject()->fileSave();
|
||||
if (activeProject()) activeProject()->fileSave();
|
||||
}
|
||||
|
||||
void FWWindow::fileSaveAs()
|
||||
{
|
||||
if (activeProject())
|
||||
activeProject()->fileSaveAs();
|
||||
if (activeProject()) activeProject()->fileSaveAs();
|
||||
}
|
||||
|
||||
void FWWindow::fileExit()
|
||||
@ -426,8 +403,7 @@ void FWWindow::fileExit()
|
||||
|
||||
void FWWindow::fileCommit()
|
||||
{
|
||||
if (activeProject())
|
||||
activeProject()->fileCommit();
|
||||
if (activeProject()) activeProject()->fileCommit();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -436,20 +412,17 @@ void FWWindow::fileCommit()
|
||||
*/
|
||||
void FWWindow::fileDiscard()
|
||||
{
|
||||
if (activeProject())
|
||||
activeProject()->fileDiscard();
|
||||
if (activeProject()) activeProject()->fileDiscard();
|
||||
}
|
||||
|
||||
void FWWindow::fileAddToRCS()
|
||||
{
|
||||
if (activeProject())
|
||||
activeProject()->fileAddToRCS();
|
||||
if (activeProject()) activeProject()->fileAddToRCS();
|
||||
}
|
||||
|
||||
bool FWWindow::editingLibrary()
|
||||
{
|
||||
if (activeProject())
|
||||
return activeProject()->editingLibrary();
|
||||
if (activeProject()) return activeProject()->editingLibrary();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -471,7 +444,7 @@ void FWWindow::load(QWidget *dialogs_parent)
|
||||
activeProject()->load(dialogs_parent);
|
||||
}
|
||||
|
||||
libfwbuilder::FWObject* FWWindow::getVisibleFirewalls()
|
||||
FWObject* FWWindow::getVisibleFirewalls()
|
||||
{
|
||||
if (activeProject())
|
||||
return activeProject()->getVisibleFirewall();
|
||||
@ -749,7 +722,7 @@ void FWWindow::editPaste()
|
||||
|
||||
void FWWindow::compile()
|
||||
{
|
||||
std::set<libfwbuilder::Firewall*> emp;
|
||||
std::set<Firewall*> emp;
|
||||
|
||||
instd = new instDialog(NULL,BATCH_COMPILE,emp);
|
||||
instd->show();
|
||||
@ -786,7 +759,7 @@ void FWWindow::install(set<Firewall*> vf)
|
||||
|
||||
void FWWindow::install()
|
||||
{
|
||||
std::set<libfwbuilder::Firewall*> emp;
|
||||
std::set<Firewall*> emp;
|
||||
instd = new instDialog(NULL, BATCH_INSTALL, emp);
|
||||
|
||||
instd->show();
|
||||
@ -976,8 +949,7 @@ void FWWindow::editPrefs()
|
||||
*/
|
||||
void FWWindow::restoreRuleSetTab()
|
||||
{
|
||||
if (activeProject())
|
||||
activeProject()->restoreRuleSetTab();
|
||||
if (activeProject()) activeProject()->restoreRuleSetTab();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1026,15 +998,76 @@ void FWWindow::helpIndex()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* 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();
|
||||
for (int i = 0 ; i < subWindowList.size(); i++)
|
||||
{
|
||||
ProjectPanel * pp = dynamic_cast<ProjectPanel*>(
|
||||
subWindowList[i]->widget());
|
||||
pp->clearFirewallTabs();
|
||||
pp->closeRuleSet(rs);
|
||||
}
|
||||
}
|
||||
|
||||
void FWWindow::closeObjectInAllWindowsWhereOpen(FWObject *obj)
|
||||
{
|
||||
QList<QMdiSubWindow*> subWindowList = getMdiArea()->subWindowList();
|
||||
for (int i = 0 ; i < subWindowList.size(); i++)
|
||||
{
|
||||
ProjectPanel * pp = dynamic_cast<ProjectPanel*>(
|
||||
subWindowList[i]->widget());
|
||||
pp->m_panel->om->closeObject();
|
||||
pp->mdiWindow->update();
|
||||
}
|
||||
}
|
||||
|
||||
//wrapers for some ObjectManipulator functions
|
||||
libfwbuilder::FWObject* FWWindow::getOpened()
|
||||
FWObject* FWWindow::getOpened()
|
||||
{
|
||||
if (activeProject())
|
||||
return activeProject()->getOpened();
|
||||
return 0;
|
||||
}
|
||||
|
||||
libfwbuilder::FWObject* FWWindow::getCurrentLib()
|
||||
FWObject* FWWindow::getCurrentLib()
|
||||
{
|
||||
if (activeProject())
|
||||
return activeProject()->getCurrentLib();
|
||||
@ -1042,123 +1075,151 @@ libfwbuilder::FWObject* FWWindow::getCurrentLib()
|
||||
}
|
||||
|
||||
|
||||
void FWWindow::loadDataFromFw(libfwbuilder::Firewall *fw)
|
||||
void FWWindow::loadDataFromFw(Firewall *fw)
|
||||
{
|
||||
if (activeProject())
|
||||
activeProject()->loadDataFromFw(fw);
|
||||
}
|
||||
|
||||
libfwbuilder::FWObject* FWWindow::createObject(const QString &objType,
|
||||
const QString &objName,
|
||||
libfwbuilder::FWObject *copyFrom)
|
||||
FWObject* FWWindow::createObject(const QString &objType,
|
||||
const QString &objName,
|
||||
FWObject *copyFrom)
|
||||
{
|
||||
FWObject *res = NULL;
|
||||
if (activeProject())
|
||||
return activeProject()->createObject(objType, objName, copyFrom);
|
||||
return 0;
|
||||
{
|
||||
res = activeProject()->createObject(objType, objName, copyFrom);
|
||||
reloadAllWindowsWithFile(activeProject());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
libfwbuilder::FWObject* FWWindow::createObject(libfwbuilder::FWObject *parent,
|
||||
const QString &objType,
|
||||
const QString &objName,
|
||||
libfwbuilder::FWObject *copyFrom)
|
||||
FWObject* FWWindow::createObject(FWObject *parent,
|
||||
const QString &objType,
|
||||
const QString &objName,
|
||||
FWObject *copyFrom)
|
||||
{
|
||||
FWObject *res = NULL;
|
||||
if (activeProject())
|
||||
return activeProject()->createObject(parent, objType, objName, copyFrom);
|
||||
return 0;
|
||||
{
|
||||
res = activeProject()->createObject(parent, objType,
|
||||
objName, copyFrom);
|
||||
reloadAllWindowsWithFile(activeProject());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void FWWindow::moveObject(libfwbuilder::FWObject *target,
|
||||
libfwbuilder::FWObject *obj)
|
||||
void FWWindow::moveObject(FWObject *target, FWObject *obj)
|
||||
{
|
||||
if (activeProject())
|
||||
{
|
||||
activeProject()->moveObject(target, obj);
|
||||
reloadAllWindowsWithFile(activeProject());
|
||||
}
|
||||
}
|
||||
|
||||
void FWWindow::moveObject(const QString &targetLibName,
|
||||
libfwbuilder::FWObject *obj)
|
||||
void FWWindow::moveObject(const QString &targetLibName, FWObject *obj)
|
||||
{
|
||||
if (activeProject())
|
||||
{
|
||||
activeProject()->moveObject(targetLibName, obj);
|
||||
reloadAllWindowsWithFile(activeProject());
|
||||
}
|
||||
}
|
||||
|
||||
void FWWindow::autorename(libfwbuilder::FWObject *obj,
|
||||
const std::string &objtype,
|
||||
const std::string &namesuffix)
|
||||
void FWWindow::autorename(FWObject *obj,
|
||||
const std::string &objtype,
|
||||
const std::string &namesuffix)
|
||||
{
|
||||
if (activeProject())
|
||||
activeProject()->autorename(obj, objtype, namesuffix);
|
||||
if (activeProject()) activeProject()->autorename(obj, objtype, namesuffix);
|
||||
}
|
||||
|
||||
|
||||
void FWWindow::updateLibColor(libfwbuilder::FWObject *lib)
|
||||
void FWWindow::updateLibColor(FWObject *lib)
|
||||
{
|
||||
if (activeProject())
|
||||
{
|
||||
activeProject()->updateLibColor(lib);
|
||||
reloadAllWindowsWithFile(activeProject());
|
||||
}
|
||||
}
|
||||
|
||||
void FWWindow::updateLibName(libfwbuilder::FWObject *lib)
|
||||
void FWWindow::updateLibName(FWObject *lib)
|
||||
{
|
||||
if (activeProject())
|
||||
{
|
||||
activeProject()->updateLibName(lib);
|
||||
reloadAllWindowsWithFile(activeProject());
|
||||
}
|
||||
}
|
||||
|
||||
void FWWindow::updateObjName(libfwbuilder::FWObject *obj,
|
||||
const QString &oldName,
|
||||
bool askForAutorename)
|
||||
void FWWindow::updateObjName(FWObject *obj,
|
||||
const QString &oldName,
|
||||
bool askForAutorename)
|
||||
{
|
||||
if (activeProject())
|
||||
{
|
||||
activeProject()->updateObjName(obj, oldName, askForAutorename);
|
||||
reloadAllWindowsWithFile(activeProject());
|
||||
}
|
||||
}
|
||||
|
||||
void FWWindow::updateObjName(libfwbuilder::FWObject *obj,
|
||||
const QString &oldName,
|
||||
const QString &oldLabel,
|
||||
bool askForAutorename)
|
||||
void FWWindow::updateObjName(FWObject *obj,
|
||||
const QString &oldName,
|
||||
const QString &oldLabel,
|
||||
bool askForAutorename)
|
||||
{
|
||||
if (activeProject())
|
||||
activeProject()->updateObjName(obj, oldName, oldLabel, askForAutorename);
|
||||
{
|
||||
activeProject()->updateObjName(obj,
|
||||
oldName, oldLabel, askForAutorename);
|
||||
reloadAllWindowsWithFile(activeProject());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FWWindow::updateLastModifiedTimestampForOneFirewall(libfwbuilder::FWObject *o)
|
||||
void FWWindow::updateLastModifiedTimestampForOneFirewall(FWObject *o)
|
||||
{
|
||||
if (activeProject())
|
||||
activeProject()->updateLastModifiedTimestampForOneFirewall(o);
|
||||
}
|
||||
|
||||
void FWWindow::updateLastModifiedTimestampForAllFirewalls(libfwbuilder::FWObject *o)
|
||||
void FWWindow::updateLastModifiedTimestampForAllFirewalls(FWObject *o)
|
||||
{
|
||||
if (activeProject())
|
||||
activeProject()->updateLastModifiedTimestampForAllFirewalls(o);
|
||||
}
|
||||
|
||||
void FWWindow::updateLastInstalledTimestamp(libfwbuilder::FWObject *o)
|
||||
void FWWindow::updateLastInstalledTimestamp(FWObject *o)
|
||||
{
|
||||
if (activeProject())
|
||||
activeProject()->updateLastInstalledTimestamp(o);
|
||||
}
|
||||
|
||||
void FWWindow::updateLastCompiledTimestamp(libfwbuilder::FWObject *o)
|
||||
void FWWindow::updateLastCompiledTimestamp(FWObject *o)
|
||||
{
|
||||
if (activeProject())
|
||||
activeProject()->updateLastCompiledTimestamp(o);
|
||||
}
|
||||
|
||||
|
||||
libfwbuilder::FWObject* FWWindow::pasteTo(libfwbuilder::FWObject *target,
|
||||
libfwbuilder::FWObject *obj,
|
||||
bool openobj,
|
||||
bool validateOnly)
|
||||
FWObject* FWWindow::pasteTo(FWObject *target,
|
||||
FWObject *obj,
|
||||
bool openobj,
|
||||
bool validateOnly)
|
||||
{
|
||||
if (activeProject())
|
||||
return activeProject()->pasteTo(target, obj, openobj, validateOnly);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FWWindow::delObj(libfwbuilder::FWObject *obj,bool openobj)
|
||||
void FWWindow::delObj(FWObject *obj,bool openobj)
|
||||
{
|
||||
if (activeProject())
|
||||
{
|
||||
activeProject()->delObj(obj, openobj);
|
||||
reloadAllWindowsWithFile(activeProject());
|
||||
}
|
||||
}
|
||||
|
||||
ObjectTreeView* FWWindow::getCurrentObjectTree()
|
||||
@ -1174,27 +1235,27 @@ void FWWindow::openObject(QTreeWidgetItem *otvi)
|
||||
activeProject()->openObject(otvi);
|
||||
}
|
||||
|
||||
void FWWindow::openObject(libfwbuilder::FWObject *obj)
|
||||
void FWWindow::openObject(FWObject *obj)
|
||||
{
|
||||
if (activeProject())
|
||||
activeProject()->openObject(obj);
|
||||
}
|
||||
|
||||
bool FWWindow::editObject(libfwbuilder::FWObject *obj)
|
||||
bool FWWindow::editObject(FWObject *obj)
|
||||
{
|
||||
if (activeProject())
|
||||
return activeProject()->editObject(obj);
|
||||
return false;
|
||||
}
|
||||
|
||||
void FWWindow::findAllFirewalls (std::list<libfwbuilder::Firewall *> &fws)
|
||||
void FWWindow::findAllFirewalls (std::list<Firewall *> &fws)
|
||||
{
|
||||
if (activeProject())
|
||||
activeProject()->findAllFirewalls (fws);
|
||||
}
|
||||
|
||||
libfwbuilder::FWObject* FWWindow::duplicateObject(libfwbuilder::FWObject *target,
|
||||
libfwbuilder::FWObject *obj,
|
||||
FWObject* FWWindow::duplicateObject(FWObject *target,
|
||||
FWObject *obj,
|
||||
const QString &name,
|
||||
bool askForAutorename)
|
||||
{
|
||||
@ -1272,13 +1333,13 @@ void FWWindow::closeEditor()
|
||||
activeProject()->closeEditor();
|
||||
}
|
||||
|
||||
void FWWindow::openEditor(libfwbuilder::FWObject *o)
|
||||
void FWWindow::openEditor(FWObject *o)
|
||||
{
|
||||
if (activeProject())
|
||||
activeProject()->openEditor(o);
|
||||
}
|
||||
|
||||
void FWWindow::openOptEditor(libfwbuilder::FWObject *o, ObjectEditor::OptType t)
|
||||
void FWWindow::openOptEditor(FWObject *o, ObjectEditor::OptType t)
|
||||
{
|
||||
if (activeProject())
|
||||
activeProject()->openOptEditor(o, t);
|
||||
@ -1291,7 +1352,7 @@ void FWWindow::blankEditor()
|
||||
}
|
||||
|
||||
|
||||
libfwbuilder::FWObject* FWWindow::getOpenedEditor()
|
||||
FWObject* FWWindow::getOpenedEditor()
|
||||
{
|
||||
if (activeProject())
|
||||
return activeProject()->getOpenedEditor();
|
||||
@ -1305,13 +1366,13 @@ ObjectEditor::OptType FWWindow::getOpenedOptEditor()
|
||||
return ObjectEditor::optNone;
|
||||
}
|
||||
|
||||
void FWWindow::selectObjectInEditor(libfwbuilder::FWObject *o)
|
||||
void FWWindow::selectObjectInEditor(FWObject *o)
|
||||
{
|
||||
if (activeProject())
|
||||
activeProject()->selectObjectInEditor(o);
|
||||
}
|
||||
|
||||
void FWWindow::actionChangedEditor(libfwbuilder::FWObject *o)
|
||||
void FWWindow::actionChangedEditor(FWObject *o)
|
||||
{
|
||||
if (activeProject())
|
||||
activeProject()->actionChangedEditor(o);
|
||||
@ -1324,7 +1385,7 @@ bool FWWindow::validateAndSaveEditor()
|
||||
return false;
|
||||
}
|
||||
|
||||
void FWWindow::setFDObject(libfwbuilder::FWObject *o)
|
||||
void FWWindow::setFDObject(FWObject *o)
|
||||
{
|
||||
if (activeProject())
|
||||
activeProject()->setFDObject(o);
|
||||
@ -1335,7 +1396,7 @@ QPrinter* FWWindow::getPrinter()
|
||||
return printer;
|
||||
}
|
||||
|
||||
libfwbuilder::FWObjectDatabase* FWWindow::db()
|
||||
FWObjectDatabase* FWWindow::db()
|
||||
{
|
||||
if (activeProject())
|
||||
return activeProject()->db();
|
||||
@ -1359,7 +1420,7 @@ listOfLibraries *FWWindow::getAddOnLibs()
|
||||
}
|
||||
|
||||
|
||||
bool FWWindow::isSystem(libfwbuilder::FWObject *obj)
|
||||
bool FWWindow::isSystem(FWObject *obj)
|
||||
{
|
||||
if (activeProject())
|
||||
return activeProject()->isSystem(obj);
|
||||
|
||||
@ -44,7 +44,6 @@ namespace libfwbuilder {
|
||||
class PolicyRule;
|
||||
class RuleSet;
|
||||
class FWObject;
|
||||
|
||||
};
|
||||
|
||||
class QMdiSubWindow;
|
||||
@ -178,6 +177,10 @@ public slots:
|
||||
int findFirewallInList(libfwbuilder::FWObject *f);
|
||||
void updateTreeViewItemOrder();
|
||||
|
||||
void reloadAllWindowsWithFile(ProjectPanel *pp);
|
||||
void closeRuleSetInAllWindowsWhereOpen(libfwbuilder::RuleSet *rs);
|
||||
void closeObjectInAllWindowsWhereOpen(libfwbuilder::FWObject *obj);
|
||||
|
||||
bool editingLibrary();
|
||||
|
||||
void ensureObjectVisibleInRules(libfwbuilder::FWReference *obj);
|
||||
@ -353,6 +356,8 @@ public slots:
|
||||
listOfLibraries *getAddOnLibs();
|
||||
|
||||
bool isSystem(libfwbuilder::FWObject *obj);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
virtual void showEvent( QShowEvent *ev);
|
||||
|
||||
@ -45,9 +45,12 @@
|
||||
#include "FWBSettings.h"
|
||||
|
||||
#include "FWWindow.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
|
||||
LibraryDialog::LibraryDialog(ProjectPanel *project, QWidget *parent) : QWidget(parent), m_project(project)
|
||||
{
|
||||
m_dialog = new Ui::LibraryDialog_q;
|
||||
|
||||
@ -452,8 +452,13 @@ bool ObjectEditor::validateAndSave()
|
||||
ischanged = isModified();
|
||||
//emit isChanged_sign(&ischanged);
|
||||
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectEditor::validateAndSave "
|
||||
"ischanged=%d db->isReadOnly()=%d",
|
||||
ischanged, m_project->db()->isReadOnly());
|
||||
|
||||
/* if nothing changed or tree is read-only, just close dialog */
|
||||
if (!ischanged || !isTreeReadWrite(dialogs[ visible ],m_project->db()))
|
||||
if (!ischanged || !isTreeReadWrite(dialogs[visible], m_project->db()))
|
||||
{
|
||||
if (fwbdebug) qDebug("ObjectEditor::validateAndSave: no changes");
|
||||
return true;
|
||||
|
||||
@ -425,9 +425,9 @@ void ObjectManipulator::showDeletedObjects(bool f)
|
||||
QVector <ObjectManipulator*> ObjectManipulator::getAllMdiObjectManipulators()
|
||||
{
|
||||
QVector <ObjectManipulator*> ret ;
|
||||
QList<QMdiSubWindow *> subWindowList = mw->getMdiArea()->subWindowList();
|
||||
if (m_project->getRCS()==NULL)
|
||||
return ret ;
|
||||
QList<QMdiSubWindow *> subWindowList = mw->getMdiArea()->subWindowList();
|
||||
QString fileName = m_project->getRCS()->getFileName();
|
||||
ret.push_back (this);
|
||||
for (int i = 0 ; i < subWindowList.size();i++)
|
||||
@ -464,12 +464,12 @@ void ObjectManipulator::removeObjectFromTreeView(FWObject *obj )
|
||||
|
||||
void ObjectManipulator::updateLibColor(FWObject *lib)
|
||||
{
|
||||
QVector <ObjectManipulator*> oms = getAllMdiObjectManipulators();
|
||||
QString clr=lib->getStr("color").c_str();
|
||||
for (int i = 0 ; i < oms.size(); i++)
|
||||
|
||||
int index = getIdxForLib(lib);
|
||||
if (index >= 0)
|
||||
{
|
||||
ObjectManipulator* pom = oms[i] ;
|
||||
QTreeWidget *objTreeView = pom->idxToTrees[ pom->getIdxForLib(lib) ];
|
||||
QTreeWidget *objTreeView = idxToTrees[index];
|
||||
if (clr=="" || clr=="#000000" || clr=="black") clr="#FFFFFF";
|
||||
QPalette palette = objTreeView->palette();
|
||||
palette.setColor(QPalette::Active, QPalette::Base, QColor( clr ));
|
||||
@ -494,7 +494,7 @@ void ObjectManipulator::updateLibName(FWObject *lib)
|
||||
if (m_objectManipulator->libs->itemText(oldidx)!=newlibname)
|
||||
{
|
||||
removeLib(oldidx);
|
||||
addLib(lib,objTreeView);
|
||||
addLib(lib, objTreeView);
|
||||
}
|
||||
}
|
||||
|
||||
@ -508,51 +508,46 @@ void ObjectManipulator::updateObjName(FWObject *obj,
|
||||
const QString &oldName,
|
||||
bool askForAutorename)
|
||||
{
|
||||
QVector <ObjectManipulator*> oms = getAllMdiObjectManipulators();
|
||||
for (int i = 0 ; i < oms.size(); i++)
|
||||
// update info in case user edited comments and other attributes.
|
||||
info();
|
||||
|
||||
if (oldName == obj->getName().c_str()) return;
|
||||
|
||||
if (obj!=currentObj) openObject(obj);
|
||||
|
||||
QTreeWidgetItem *itm = allItems[obj];
|
||||
assert(itm!=NULL);
|
||||
|
||||
if (fwbdebug)
|
||||
{
|
||||
ObjectManipulator* pom = oms[i] ;
|
||||
pom->info(); // need to update info in case user edited comments and other attributes.
|
||||
|
||||
if (oldName == obj->getName().c_str()) return;
|
||||
|
||||
if (obj!=currentObj) openObject(obj);
|
||||
|
||||
QTreeWidgetItem *itm = pom->allItems[obj];
|
||||
assert(itm!=NULL);
|
||||
qDebug("ObjectManipulator::updateObjName changing name %s -> %s",
|
||||
oldName.toLatin1().constData(), QString::fromUtf8(obj->getName().c_str()).toLatin1().constData());
|
||||
}
|
||||
|
||||
if ((QString::fromUtf8(obj->getName().c_str())!=oldName) &&
|
||||
(Host::isA(obj) || Firewall::isA(obj) || Interface::isA(obj)))
|
||||
{
|
||||
if (fwbdebug)
|
||||
{
|
||||
qDebug("ObjectManipulator::updateObjName changing name %s -> %s",
|
||||
oldName.toLatin1().constData(), QString::fromUtf8(obj->getName().c_str()).toLatin1().constData());
|
||||
}
|
||||
qDebug("ObjectManipulator::updateObjName autorename");
|
||||
autorename(obj, askForAutorename);
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectManipulator::updateObjName autorename done");
|
||||
}
|
||||
|
||||
if ((QString::fromUtf8(obj->getName().c_str())!=oldName) &&
|
||||
(Host::isA(obj) || Firewall::isA(obj) || Interface::isA(obj)))
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectManipulator::updateObjName autorename");
|
||||
pom->autorename(obj,askForAutorename);
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectManipulator::updateObjName autorename done");
|
||||
}
|
||||
itm->setText(0, getTreeLabel( obj ) );
|
||||
|
||||
itm->setText(0, pom->getTreeLabel( obj ) );
|
||||
if (!Library::isA(obj))
|
||||
itm->parent()->sortChildren(0, Qt::AscendingOrder);
|
||||
|
||||
if (!Library::isA(obj))
|
||||
itm->parent()->sortChildren(0, Qt::AscendingOrder);
|
||||
|
||||
/* need to update name of the firewall in the drop-down list */
|
||||
if (Firewall::isA(obj))
|
||||
{
|
||||
pom->m_project->updateFirewallName(obj,oldName);
|
||||
}
|
||||
/* need to update name of the firewall in the drop-down list */
|
||||
if (Firewall::isA(obj))
|
||||
{
|
||||
m_project->updateFirewallName(obj,oldName);
|
||||
}
|
||||
|
||||
if (RuleSet::cast(obj)!=NULL)
|
||||
{
|
||||
pom->m_project->updateFirewallName(obj,oldName);
|
||||
}
|
||||
|
||||
if (RuleSet::cast(obj)!=NULL)
|
||||
{
|
||||
m_project->updateFirewallName(obj,oldName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -576,7 +571,7 @@ void ObjectManipulator::updateObjName(FWObject *obj,
|
||||
}
|
||||
|
||||
if ((QString::fromUtf8(obj->getName().c_str())!=oldName) && Interface::isA(obj))
|
||||
autorename(obj,askForAutorename);
|
||||
autorename(obj, askForAutorename);
|
||||
|
||||
itm->setText(0, getTreeLabel( obj ) );
|
||||
itm->parent()->sortChildren(0, Qt::AscendingOrder);//();
|
||||
@ -658,51 +653,42 @@ void ObjectManipulator::autorename(FWObject *obj,
|
||||
const string &objtype,
|
||||
const string &namesuffix)
|
||||
{
|
||||
QVector <ObjectManipulator*> oms = getAllMdiObjectManipulators();
|
||||
for (int i = 0 ; i < oms.size(); i++)
|
||||
FWObject *hst = obj->getParent();
|
||||
list<FWObject*> ol = obj->getByType(objtype);
|
||||
int sfxn = 1;
|
||||
|
||||
for (list<FWObject*>::iterator j=ol.begin(); j!=ol.end(); ++j,sfxn++)
|
||||
{
|
||||
ObjectManipulator* pom = oms[i] ;
|
||||
QString sfx;
|
||||
if (ol.size()==1) sfx="";
|
||||
else sfx.setNum(sfxn);
|
||||
QString nn = QString("%1:%2:%3%4")
|
||||
.arg(QString::fromUtf8(hst->getName().c_str()))
|
||||
.arg(QString::fromUtf8(obj->getName().c_str()))
|
||||
.arg(namesuffix.c_str())
|
||||
.arg(sfx);
|
||||
|
||||
FWObject *hst = obj->getParent();
|
||||
list<FWObject*> ol = obj->getByType(objtype);
|
||||
int sfxn = 1;
|
||||
|
||||
for (list<FWObject*>::iterator j=ol.begin(); j!=ol.end(); ++j,sfxn++)
|
||||
(*j)->setName(string(nn.toUtf8()));
|
||||
QTreeWidgetItem *itm1 = allItems[ *j ];
|
||||
if (itm1!=NULL)
|
||||
{
|
||||
QString sfx;
|
||||
if (ol.size()==1) sfx="";
|
||||
else sfx.setNum(sfxn);
|
||||
QString nn = QString("%1:%2:%3%4")
|
||||
.arg(QString::fromUtf8(hst->getName().c_str()))
|
||||
.arg(QString::fromUtf8(obj->getName().c_str()))
|
||||
.arg(namesuffix.c_str())
|
||||
.arg(sfx);
|
||||
|
||||
(*j)->setName(string(nn.toUtf8()));
|
||||
QTreeWidgetItem *itm1 = pom->allItems[ *j ];
|
||||
if (itm1!=NULL)
|
||||
{
|
||||
itm1->setText(0, getTreeLabel( *j ) );
|
||||
itm1->parent()->sortChildren(0, Qt::AscendingOrder);//();
|
||||
}
|
||||
itm1->setText(0, getTreeLabel( *j ) );
|
||||
itm1->parent()->sortChildren(0, Qt::AscendingOrder);//();
|
||||
}
|
||||
ol.clear();
|
||||
}
|
||||
ol.clear();
|
||||
}
|
||||
|
||||
void ObjectManipulator::clearObjects()
|
||||
{
|
||||
if (fwbdebug) qDebug("ObjectManipulator::clearObjects start");
|
||||
if (fwbdebug) qDebug("ObjectManipulator::clearObjects %p start",this);
|
||||
|
||||
invalidateDialog();
|
||||
while (history.size()!=0) history.pop();
|
||||
|
||||
if (fwbdebug) qDebug("ObjectManipulator::clearObjects history size: %d",
|
||||
int(history.size()));
|
||||
|
||||
int N = m_objectManipulator->libs->count();
|
||||
|
||||
if (fwbdebug) qDebug("ObjectManipulator::clearObjects %d libs", N);
|
||||
if (fwbdebug) qDebug("ObjectManipulator::clearObjects %d libs", N);
|
||||
|
||||
for (int i=N-1; i>=0; i--)
|
||||
{
|
||||
@ -713,9 +699,9 @@ void ObjectManipulator::clearObjects()
|
||||
removeLib(i);
|
||||
}
|
||||
|
||||
if (fwbdebug) qDebug("ObjectManipulator::clearObjects idxToLibs size: %d",
|
||||
if (fwbdebug) qDebug("ObjectManipulator::clearObjects idxToLibs size: %d",
|
||||
int(idxToLibs.size()));
|
||||
if (fwbdebug) qDebug("ObjectManipulator::clearObjects idxToTrees size: %d",
|
||||
if (fwbdebug) qDebug("ObjectManipulator::clearObjects idxToTrees size: %d",
|
||||
int(idxToTrees.size()));
|
||||
|
||||
idxToLibs.clear();
|
||||
@ -723,31 +709,25 @@ void ObjectManipulator::clearObjects()
|
||||
|
||||
m_objectManipulator->libs->clear();
|
||||
|
||||
if (fwbdebug) qDebug("ObjectManipulator::clearObjects done");
|
||||
if (fwbdebug) qDebug("ObjectManipulator::clearObjects done");
|
||||
}
|
||||
|
||||
void ObjectManipulator::loadObjects()
|
||||
{
|
||||
loadObjects( m_project->db() );
|
||||
}
|
||||
if (fwbdebug) qDebug("ObjectManipulator::loadObjects %p start", this);
|
||||
|
||||
void ObjectManipulator::loadObjects(FWObjectDatabase *)
|
||||
{
|
||||
if (fwbdebug) qDebug("ObjectManipulator::loadObjects start");
|
||||
clearObjects();
|
||||
|
||||
if (m_objectManipulator->libs->count()!=0) clearObjects();
|
||||
|
||||
FWObject *firstUserLib=NULL;
|
||||
FWObject *firstUserLib = NULL;
|
||||
list<FWObject*> ll = m_project->db()->getByType( Library::TYPENAME );
|
||||
|
||||
// ll.sort(FWObjectNameCmpPredicate());
|
||||
|
||||
for (FWObject::iterator i=ll.begin(); i!=ll.end(); i++)
|
||||
{
|
||||
FWObject *lib = (*i);
|
||||
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectManipulator::loadObjects lib %p %s %s",
|
||||
qDebug("ObjectManipulator::loadObjects %p lib %p %s %s",
|
||||
this,
|
||||
lib,
|
||||
FWObjectDatabase::getStringId(lib->getId()).c_str(),
|
||||
lib->getName().c_str() );
|
||||
@ -757,16 +737,17 @@ void ObjectManipulator::loadObjects(FWObjectDatabase *)
|
||||
|
||||
if ( lib->getId()!=FWObjectDatabase::STANDARD_LIB_ID &&
|
||||
lib->getId()!=FWObjectDatabase::TEMPLATE_LIB_ID &&
|
||||
firstUserLib==NULL) firstUserLib=*i;
|
||||
firstUserLib==NULL) firstUserLib = *i;
|
||||
|
||||
addTreePage( lib );
|
||||
|
||||
if (fwbdebug) qDebug("ObjectManipulator::loadObjects added lib %s",
|
||||
lib->getName().c_str());
|
||||
if (fwbdebug) qDebug("ObjectManipulator::loadObjects %p added lib %s",
|
||||
this, lib->getName().c_str());
|
||||
}
|
||||
|
||||
if (firstUserLib==NULL) firstUserLib=ll.front();
|
||||
openLib( firstUserLib );
|
||||
if (fwbdebug) qDebug("ObjectManipulator::loadObjects %p done", this);
|
||||
}
|
||||
|
||||
void ObjectManipulator::addLib( FWObject *lib,QTreeWidget* otv)
|
||||
@ -804,10 +785,11 @@ void ObjectManipulator::addTreePage( FWObject *lib)
|
||||
// {
|
||||
// ObjectManipulator* pom = oms[i] ;
|
||||
|
||||
if (fwbdebug) qDebug("Object Manipulator::addTreePage");
|
||||
if (fwbdebug) qDebug("Object Manipulator::addTreePage %p lib: %s",
|
||||
this, lib->getName().c_str());
|
||||
|
||||
ObjectTreeView *objTreeView = new ObjectTreeView(m_project, m_objectManipulator->widgetStack,
|
||||
OBJTREEVIEW_WIDGET_NAME );
|
||||
ObjectTreeView *objTreeView = new ObjectTreeView(
|
||||
m_project, m_objectManipulator->widgetStack, OBJTREEVIEW_WIDGET_NAME );
|
||||
|
||||
addLib(lib,objTreeView);
|
||||
|
||||
@ -900,39 +882,26 @@ void ObjectManipulator::addTreePage( FWObject *lib)
|
||||
insertSubtree( itm1, (*m) );
|
||||
objTreeView->updateTreeItems();
|
||||
objTreeView->sortByColumn(0,Qt::AscendingOrder);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ObjectManipulator::removeLib(FWObject* lib)
|
||||
{
|
||||
QVector <ObjectManipulator*> oms = getAllMdiObjectManipulators();
|
||||
for (int i = 0 ; i < oms.size(); i++)
|
||||
{
|
||||
ObjectManipulator* pom = oms[i] ;
|
||||
|
||||
pom->removeLib( pom->getIdxForLib(lib) );
|
||||
}
|
||||
removeLib( getIdxForLib(lib) );
|
||||
}
|
||||
|
||||
void ObjectManipulator::removeLib(int id)
|
||||
{
|
||||
QVector <ObjectManipulator*> oms = getAllMdiObjectManipulators();
|
||||
for (int i = 0 ; i < oms.size(); i++)
|
||||
int N = m_objectManipulator->libs->count();
|
||||
int idx = 0;
|
||||
vector<FWObject*>::iterator i1 = idxToLibs.begin();
|
||||
vector<QTreeWidget*>::iterator i2 = idxToTrees.begin();
|
||||
for ( ; idx<N; ++idx,++i1,++i2)
|
||||
{
|
||||
ObjectManipulator* pom = oms[i] ;
|
||||
int N = pom->m_objectManipulator->libs->count();
|
||||
int idx = 0;
|
||||
vector<FWObject*>::iterator i1 = pom->idxToLibs.begin();
|
||||
vector<QTreeWidget*>::iterator i2 = pom->idxToTrees.begin();
|
||||
for ( ; idx<N; ++idx,++i1,++i2)
|
||||
if ( idx==id )
|
||||
{
|
||||
if ( idx==id )
|
||||
{
|
||||
pom->m_objectManipulator->libs->removeItem( idx );
|
||||
pom->idxToLibs.erase(i1);
|
||||
pom->idxToTrees.erase(i2);
|
||||
}
|
||||
m_objectManipulator->libs->removeItem( idx );
|
||||
idxToLibs.erase(i1);
|
||||
idxToTrees.erase(i2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -996,17 +965,18 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos)
|
||||
|
||||
if (currentObj==NULL) currentObj=otvi->getFWObject();
|
||||
|
||||
QMenu *popup=new QMenu(this);
|
||||
QMenu *popup = new QMenu(this);
|
||||
|
||||
QAction *edtID =popup->addAction( tr("Edit"), this, SLOT( editSelectedObject()));
|
||||
QAction *edtID = popup->addAction(
|
||||
tr("Edit"), this, SLOT( editSelectedObject()));
|
||||
|
||||
QMenu *duptargets = new QMenu(popup);
|
||||
QMenu *movetargets = new QMenu(popup);
|
||||
QMenu *duptargets = popup->addMenu( tr("Duplicate ...") );
|
||||
QMenu *movetargets = popup->addMenu( tr("Move ...") );
|
||||
|
||||
connect ( movetargets, SIGNAL ( triggered(QAction*) ),
|
||||
this, SLOT( moveObj(QAction*) ) );
|
||||
connect ( duptargets, SIGNAL ( triggered(QAction*) ),
|
||||
this, SLOT( duplicateObj(QAction*) ) );
|
||||
connect ( movetargets, SIGNAL ( triggered(QAction*) ),
|
||||
this, SLOT( moveObj(QAction*) ) );
|
||||
|
||||
/* we add " ... to library ..." submenu to the "Move " menu item only
|
||||
* if user did not select a library, or if they selected several
|
||||
@ -1019,71 +989,50 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos)
|
||||
|
||||
int libid = 0;
|
||||
|
||||
FWObject *cl=getCurrentLib();
|
||||
int moveTargets=0;
|
||||
FWObject *cl = getCurrentLib();
|
||||
int moveTargetsCounter = 0;
|
||||
vector<FWObject*>::iterator i;
|
||||
|
||||
for (i=idxToLibs.begin(); i!=idxToLibs.end(); ++i,++libid)
|
||||
{
|
||||
FWObject *lib = *i;
|
||||
|
||||
/* can't move to the same library. Will use menu item 'create
|
||||
* here' to duplicate to the same library
|
||||
*/
|
||||
if (lib==cl) continue;
|
||||
|
||||
if ( lib->getId()==FWObjectDatabase::STANDARD_LIB_ID ||
|
||||
lib->getId()==FWObjectDatabase::TEMPLATE_LIB_ID ||
|
||||
lib->getId()==FWObjectDatabase::DELETED_OBJECTS_ID ||
|
||||
lib->isReadOnly())
|
||||
continue;
|
||||
QAction* dact=duptargets->addAction(
|
||||
tr("place in library %1").arg(QString::fromUtf8(lib->getName().c_str()))/*,this, SLOT( duplicateObj(libid))*/
|
||||
);
|
||||
|
||||
//duptargets->connectItem( did, this, SLOT( duplicateObj(int)) ); replaced with preprevious string
|
||||
//duptargets->setItemParameter(did, libid ); replaced with next:
|
||||
QAction* dact = duptargets->addAction(
|
||||
tr("place in library %1").arg(
|
||||
QString::fromUtf8(lib->getName().c_str())));
|
||||
dact->setData(libid);
|
||||
|
||||
if (!libSelected)
|
||||
/* can't move to the same library or if selected object is a library
|
||||
*/
|
||||
if (!libSelected && lib!=cl)
|
||||
{
|
||||
QAction* mact=movetargets->addAction(
|
||||
tr("to library %1").arg(QString::fromUtf8(lib->getName().c_str())));
|
||||
|
||||
moveTargetsCounter++;
|
||||
QAction* mact = movetargets->addAction(
|
||||
tr("to library %1").arg(
|
||||
QString::fromUtf8(lib->getName().c_str())));
|
||||
mact->setData(libid);
|
||||
|
||||
moveTargets++;
|
||||
}
|
||||
}
|
||||
|
||||
duptargets->addAction(tr("place here"), this, SLOT( duplicateObjUnderSameParent()));
|
||||
|
||||
//QAction *dupID = duptargets->addAction( tr("Duplicate ...") ); // BUGFIX-2346
|
||||
QAction *dupID = popup->addAction( tr("Duplicate ..."),this, SLOT (duplicateObjUnderSameParent()));//popup->
|
||||
QAction *movID;
|
||||
|
||||
if (moveTargets!=0)
|
||||
{
|
||||
movID=movetargets->addAction( tr("Move ...") );
|
||||
} else
|
||||
{
|
||||
movID=popup->addAction( tr("Move ...") );
|
||||
movID->setData(-1);
|
||||
}
|
||||
|
||||
|
||||
popup->addSeparator();
|
||||
|
||||
QAction *copyID = popup->addAction( tr("Copy"), this,
|
||||
SLOT( copyObj() ) );
|
||||
QAction *cutID =popup->addAction( tr("Cut"), this,
|
||||
SLOT( cutObj() ) );
|
||||
QAction *pasteID =popup->addAction( tr("Paste"), this,
|
||||
SLOT( pasteObj() ) );
|
||||
SLOT( copyObj() ) );
|
||||
QAction *cutID = popup->addAction( tr("Cut"), this,
|
||||
SLOT( cutObj() ) );
|
||||
QAction *pasteID = popup->addAction( tr("Paste"), this,
|
||||
SLOT( pasteObj() ) );
|
||||
|
||||
popup->addSeparator();
|
||||
|
||||
QAction * delID =popup->addAction( tr("Delete"), this,
|
||||
SLOT( deleteObj() ) );
|
||||
QAction * delID = popup->addAction( tr("Delete"), this,
|
||||
SLOT( deleteObj() ) );
|
||||
|
||||
QAction *newID1=NULL;
|
||||
QAction *newID2=NULL;
|
||||
@ -1247,12 +1196,12 @@ QAction *movID;
|
||||
bool newMenuItem=true;
|
||||
bool inDeletedObjects = false;
|
||||
|
||||
getMenuState( (moveTargets>0),
|
||||
dupMenuItem,moveMenuItem,copyMenuItem,pasteMenuItem,
|
||||
delMenuItem,newMenuItem,inDeletedObjects);
|
||||
getMenuState( (moveTargetsCounter>0),
|
||||
dupMenuItem, moveMenuItem, copyMenuItem, pasteMenuItem,
|
||||
delMenuItem, newMenuItem, inDeletedObjects);
|
||||
|
||||
dupID->setEnabled(dupMenuItem);
|
||||
movID->setEnabled(moveMenuItem);
|
||||
// dupID->setEnabled(dupMenuItem);
|
||||
// movID->setEnabled(moveMenuItem);
|
||||
copyID->setEnabled(copyMenuItem);
|
||||
pasteID->setEnabled(pasteMenuItem);
|
||||
|
||||
@ -1265,7 +1214,7 @@ QAction *movID;
|
||||
newID2->setEnabled(newMenuItem);
|
||||
|
||||
|
||||
if (inDeletedObjects) movID->setText( tr("Undelete...") );
|
||||
// if (inDeletedObjects) movID->setText( tr("Undelete...") );
|
||||
|
||||
popup->exec( objTreeView->mapToGlobal( pos ) );
|
||||
}
|
||||
@ -1513,55 +1462,18 @@ void ObjectManipulator::duplicateObj(QAction *action)
|
||||
ot->freezeSelection(false);
|
||||
}
|
||||
|
||||
void ObjectManipulator::duplicateObjUnderSameParent()
|
||||
{
|
||||
if (getCurrentObjectTree()->getNumSelected()==0) return;
|
||||
|
||||
ObjectTreeView* ot=getCurrentObjectTree();
|
||||
ot->freezeSelection(true);
|
||||
FWObject *obj;
|
||||
FWObject *o = NULL;
|
||||
vector<FWObject*> so = getCurrentObjectTree()->getSimplifiedSelection();
|
||||
for (vector<FWObject*>::iterator i=so.begin(); i!=so.end(); ++i)
|
||||
{
|
||||
obj= *i;
|
||||
|
||||
o=NULL;
|
||||
|
||||
QString n=QString::fromUtf8(obj->getName().c_str());
|
||||
|
||||
openObject(o=createObject(obj->getParent(),
|
||||
obj->getTypeName().c_str(), n, obj));
|
||||
|
||||
if (Host::isA(o) || Firewall::isA(o) || Interface::isA(o))
|
||||
autorename(o,false);
|
||||
|
||||
}
|
||||
if (o!=NULL) editObject(o);
|
||||
ot->freezeSelection(false);
|
||||
}
|
||||
|
||||
void ObjectManipulator::moveObject(FWObject *targetLib, FWObject *obj)
|
||||
{
|
||||
QVector <ObjectManipulator*> oms = getAllMdiObjectManipulators();
|
||||
for (int i = 0 ; i < oms.size(); i++)
|
||||
{
|
||||
ObjectManipulator* pom = oms[i] ;
|
||||
|
||||
FWObject *cl=pom->getCurrentLib();
|
||||
FWObject *cl=getCurrentLib();
|
||||
if (cl==targetLib) return;
|
||||
|
||||
// bool inDeletedObjects = (obj->getParent()->getId()==FWObjectDatabase::DELETED_OBJECTS_ID);
|
||||
|
||||
// QString parentType;
|
||||
// QString parentName;
|
||||
FWObject *grp = NULL;
|
||||
|
||||
if (FWObjectDatabase::isA(targetLib)) grp = targetLib;
|
||||
if (FWObjectDatabase::isA(targetLib)) grp = targetLib;
|
||||
else
|
||||
{
|
||||
grp=pom->m_project->getFWTree()->getStandardSlotForObject(targetLib,
|
||||
obj->getTypeName().c_str());
|
||||
grp = m_project->getFWTree()->getStandardSlotForObject(
|
||||
targetLib, obj->getTypeName().c_str());
|
||||
}
|
||||
|
||||
if (fwbdebug)
|
||||
@ -1570,7 +1482,8 @@ void ObjectManipulator::moveObject(FWObject *targetLib, FWObject *obj)
|
||||
if (grp==NULL) grp=targetLib;
|
||||
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectManipulator::moveObject grp= %s",grp->getName().c_str());
|
||||
qDebug("ObjectManipulator::moveObject grp= %s",
|
||||
grp->getName().c_str());
|
||||
|
||||
if (!grp->isReadOnly())
|
||||
{
|
||||
@ -1578,9 +1491,9 @@ void ObjectManipulator::moveObject(FWObject *targetLib, FWObject *obj)
|
||||
obj->ref();
|
||||
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectManipulator::moveObject removing from the widget");
|
||||
qDebug("ObjectManipulator::moveObject remove from the widget");
|
||||
|
||||
ObjectTreeViewItem *itm = pom->allItems[obj];
|
||||
ObjectTreeViewItem *itm = allItems[obj];
|
||||
if (itm->parent()==NULL) return;
|
||||
|
||||
itm->parent()->takeChild(itm->parent()->indexOfChild(itm));
|
||||
@ -1599,27 +1512,26 @@ void ObjectManipulator::moveObject(FWObject *targetLib, FWObject *obj)
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectManipulator::moveObject adding to the widget");
|
||||
|
||||
if (pom->allItems[grp]==NULL)
|
||||
if (allItems[grp]==NULL)
|
||||
{
|
||||
/* adding to the root, there is not such tree item */
|
||||
/* adding to the root, there is not such tree item */
|
||||
if (Library::isA(obj))
|
||||
{
|
||||
pom->addTreePage(obj);
|
||||
pom->openLib(obj);
|
||||
addTreePage(obj);
|
||||
openLib(obj);
|
||||
} else
|
||||
{
|
||||
/* it screwed up, just print debugging message */
|
||||
/* it screwed up, just print debugging message */
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectManipulator::moveObject no place in the tree corresponding to the object %p %s",grp,grp->getName().c_str());
|
||||
qDebug("ObjectManipulator::moveObject no place in "
|
||||
"the tree corresponding to the object %p %s",
|
||||
grp, grp->getName().c_str());
|
||||
}
|
||||
} else
|
||||
pom->allItems[grp]->addChild(itm);
|
||||
|
||||
allItems[grp]->addChild(itm);
|
||||
}
|
||||
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectManipulator::moveObject all done");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1628,11 +1540,6 @@ void ObjectManipulator::moveObject(FWObject *targetLib, FWObject *obj)
|
||||
void ObjectManipulator::moveObject(const QString &targetLibName,
|
||||
FWObject *obj)
|
||||
{
|
||||
QVector <ObjectManipulator*> oms = getAllMdiObjectManipulators();
|
||||
for (int i = 0 ; i < oms.size(); i++)
|
||||
{
|
||||
ObjectManipulator* pom = oms[i] ;
|
||||
|
||||
list<FWObject*> ll = m_project->db()->getByType( Library::TYPENAME );
|
||||
for (FWObject::iterator i=ll.begin(); i!=ll.end(); i++)
|
||||
{
|
||||
@ -1643,12 +1550,14 @@ void ObjectManipulator::moveObject(const QString &targetLibName,
|
||||
qDebug("ObjectManipulator::moveObject found lib %s",
|
||||
lib->getName().c_str() );
|
||||
|
||||
pom->moveObject(lib,obj);
|
||||
moveObject(lib,obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* moveObj is a slot called from the context menu
|
||||
*/
|
||||
void ObjectManipulator::moveObj(QAction* action)
|
||||
{
|
||||
int libid = action->data().toInt();
|
||||
@ -1685,10 +1594,11 @@ void ObjectManipulator::moveObj(QAction* action)
|
||||
Interface::isA(obj) ||
|
||||
Interface::isA(obj->getParent())) continue;
|
||||
|
||||
moveObject(targetLib,obj);
|
||||
moveObject(targetLib, obj);
|
||||
}
|
||||
}
|
||||
ot->freezeSelection(false);
|
||||
mw->reloadAllWindowsWithFile(m_project);
|
||||
}
|
||||
|
||||
void ObjectManipulator::copyObj()
|
||||
@ -2049,12 +1959,12 @@ void ObjectManipulator::deleteObj()
|
||||
{
|
||||
}
|
||||
|
||||
mw->reloadAllWindowsWithFile(m_project);
|
||||
}
|
||||
|
||||
void ObjectManipulator::delObj(FWObject *obj, bool openobj)
|
||||
{
|
||||
bool firstAction = true ;
|
||||
QVector <ObjectManipulator*> oms = getAllMdiObjectManipulators();
|
||||
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectManipulator::delObj delete obj %p %s openobj=%d",
|
||||
@ -2073,116 +1983,122 @@ void ObjectManipulator::delObj(FWObject *obj, bool openobj)
|
||||
bool isDelObj = (delObjLib!=NULL && obj->isChildOf(delObjLib));
|
||||
|
||||
|
||||
for (int i = 0 ; i < oms.size(); i++)
|
||||
if (obj->getId()==FWObjectDatabase::STANDARD_LIB_ID ||
|
||||
obj->getId()==FWObjectDatabase::DELETED_OBJECTS_ID) return;
|
||||
|
||||
m_project->findObjectWidget->reset();
|
||||
|
||||
if (RuleSet::cast(obj)!=NULL)
|
||||
{
|
||||
ObjectManipulator* pom = oms[i] ;
|
||||
|
||||
if (obj->getId()==FWObjectDatabase::STANDARD_LIB_ID ||
|
||||
obj->getId()==FWObjectDatabase::DELETED_OBJECTS_ID) return;
|
||||
|
||||
pom->m_project->findObjectWidget->reset();
|
||||
try
|
||||
{
|
||||
|
||||
if (!islib && !isDelObj && obj->getId()!=FWObjectDatabase::TEMPLATE_LIB_ID)
|
||||
pom->updateLastModifiedTimestampForAllFirewalls(obj);
|
||||
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectManipulator::delObj delete islib=%d isfw=%d isDelObj=%d",islib,isfw,isDelObj);
|
||||
|
||||
/*
|
||||
* TODO: we have to remove not only the object, but also all its child
|
||||
* objects from the database, as well as all references to them. This
|
||||
* logic should really be in FWObject::removeAllInstances(FWObject*);
|
||||
*/
|
||||
|
||||
/* remove from our internal tables before it is removed from the
|
||||
* object tree so we could use obj->getId()
|
||||
*/
|
||||
if (islib && !isDelObj)
|
||||
{
|
||||
int idx = pom->getIdxForLib(obj);
|
||||
QTreeWidget *otv = pom->idxToTrees[idx];
|
||||
assert(otv!=NULL);
|
||||
pom->m_objectManipulator->widgetStack->removeWidget( otv );
|
||||
pom->removeLib(idx);
|
||||
|
||||
list<FWObject*> fl;
|
||||
}
|
||||
|
||||
QApplication::setOverrideCursor( QCursor( Qt::WaitCursor) );
|
||||
|
||||
if (islib && obj->isReadOnly()) obj->setReadOnly(false);
|
||||
if (obj->getId()==FWObjectDatabase::TEMPLATE_LIB_ID) // special case
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectManipulator::delObj: "
|
||||
"special case: deleting template library");
|
||||
pom->m_project->db()->removeAllInstances(obj);
|
||||
} else
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectManipulator::delObj: "
|
||||
"recursively deleting library and all its objects");
|
||||
pom->m_project->db()->recursivelyRemoveObjFromTree(obj,
|
||||
false);
|
||||
if (islib)
|
||||
parent=pom->m_project->db()->getFirstByType(
|
||||
Library::TYPENAME);
|
||||
}
|
||||
|
||||
QApplication::restoreOverrideCursor();
|
||||
if (fwbdebug) qDebug("ObjectManipulator::delObj: done");
|
||||
|
||||
if (RuleSet::cast(obj)!=NULL)
|
||||
pom->m_project->closeRuleSet(obj);
|
||||
|
||||
pom->removeObjectFromTreeView(obj);
|
||||
if (pom==this)
|
||||
pom->m_project->scheduleRuleSetRedraw();
|
||||
|
||||
if (!isDelObj)
|
||||
{
|
||||
if (pom->allItems[delObjLib]!=NULL)
|
||||
pom->insertSubtree( pom->allItems[delObjLib], obj );
|
||||
} else
|
||||
FWObjectClipboard::obj_clipboard->clear();
|
||||
|
||||
if (openobj && pom==this)
|
||||
{
|
||||
if (isfw && !isDelObj)
|
||||
{
|
||||
std::list<Firewall*> fwlist;
|
||||
pom->findAllFirewalls(fwlist);
|
||||
if (fwlist.size()>0)
|
||||
{
|
||||
FWObject *first_fw = fwlist.front();
|
||||
if (first_fw!=NULL)
|
||||
{
|
||||
pom->openObject( first_fw );
|
||||
}
|
||||
}
|
||||
//QTimer::singleShot( 0, m_project, SLOT(reopenFirewall()) );
|
||||
} else {
|
||||
pom->openObject(parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(FWException &ex)
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectManipulator::delObj: "
|
||||
"catch: restoreOverrideCursor");
|
||||
QApplication::restoreOverrideCursor();
|
||||
QMessageBox::warning(
|
||||
this,"Firewall Builder",
|
||||
ex.toString().c_str(),
|
||||
"&Continue", QString::null,QString::null,
|
||||
0, 1 );
|
||||
throw(ex);
|
||||
}
|
||||
firstAction = false ;
|
||||
if (fwbdebug) qDebug("ObjectManipulator::delObj: call "
|
||||
"mw->closeRuleSetInAllWindowsWhereOpen");
|
||||
mw->closeRuleSetInAllWindowsWhereOpen(RuleSet::cast(obj));
|
||||
}
|
||||
|
||||
if (fwbdebug) qDebug("ObjectManipulator::delObj: call "
|
||||
"mw->closeObjectInAllWindowsWhereOpen");
|
||||
mw->closeObjectInAllWindowsWhereOpen(obj);
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
if (!islib &&
|
||||
!isDelObj &&
|
||||
obj->getId()!=FWObjectDatabase::TEMPLATE_LIB_ID)
|
||||
updateLastModifiedTimestampForAllFirewalls(obj);
|
||||
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectManipulator::delObj delete islib=%d isfw=%d "
|
||||
"isDelObj=%d", islib, isfw, isDelObj);
|
||||
|
||||
/*
|
||||
* TODO: we have to remove not only the object, but also all its child
|
||||
* objects from the database, as well as all references to them. This
|
||||
* logic should really be in FWObject::removeAllInstances(FWObject*);
|
||||
*/
|
||||
|
||||
/* remove from our internal tables before it is removed from the
|
||||
* object tree so we could use obj->getId()
|
||||
*/
|
||||
if (islib && !isDelObj)
|
||||
{
|
||||
int idx = getIdxForLib(obj);
|
||||
QTreeWidget *otv = idxToTrees[idx];
|
||||
assert(otv!=NULL);
|
||||
m_objectManipulator->widgetStack->removeWidget( otv );
|
||||
removeLib(idx);
|
||||
} else
|
||||
removeObjectFromTreeView(obj);
|
||||
|
||||
QApplication::setOverrideCursor( QCursor( Qt::WaitCursor) );
|
||||
|
||||
if (islib && obj->isReadOnly()) obj->setReadOnly(false);
|
||||
if (obj->getId()==FWObjectDatabase::TEMPLATE_LIB_ID) // special case
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectManipulator::delObj: "
|
||||
"special case: deleting template library");
|
||||
m_project->db()->removeAllInstances(obj);
|
||||
} else
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectManipulator::delObj: "
|
||||
"recursively deleting library and all its objects");
|
||||
m_project->db()->recursivelyRemoveObjFromTree(obj,
|
||||
false);
|
||||
if (islib)
|
||||
parent = m_project->db()->getFirstByType(
|
||||
Library::TYPENAME);
|
||||
}
|
||||
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
// removeObjectFromTreeView(obj);
|
||||
m_project->scheduleRuleSetRedraw();
|
||||
|
||||
if (!isDelObj)
|
||||
{
|
||||
if (allItems[delObjLib]!=NULL)
|
||||
insertSubtree( allItems[delObjLib], obj );
|
||||
} else
|
||||
FWObjectClipboard::obj_clipboard->clear();
|
||||
|
||||
if (openobj)
|
||||
{
|
||||
if (isfw && !isDelObj)
|
||||
{
|
||||
std::list<Firewall*> fwlist;
|
||||
findAllFirewalls(fwlist);
|
||||
if (fwlist.size()>0)
|
||||
{
|
||||
FWObject *first_fw = fwlist.front();
|
||||
if (first_fw!=NULL)
|
||||
{
|
||||
openObject( first_fw );
|
||||
}
|
||||
}
|
||||
//QTimer::singleShot( 0, m_project, SLOT(reopenFirewall()) );
|
||||
} else {
|
||||
openObject(parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(FWException &ex)
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectManipulator::delObj: catch: restoreOverrideCursor");
|
||||
QApplication::restoreOverrideCursor();
|
||||
QMessageBox::warning(
|
||||
this,"Firewall Builder",
|
||||
ex.toString().c_str(),
|
||||
"&Continue", QString::null,QString::null,
|
||||
0, 1 );
|
||||
throw(ex);
|
||||
}
|
||||
|
||||
if (fwbdebug) qDebug("ObjectManipulator::delObj done");
|
||||
|
||||
firstAction = false ;
|
||||
}
|
||||
|
||||
void ObjectManipulator::groupObjects()
|
||||
@ -2267,7 +2183,8 @@ void ObjectManipulator::info()
|
||||
void ObjectManipulator::restoreSelection(bool same_widget)
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectManipulator::restoreSelection same_widget=%d",same_widget);
|
||||
qDebug("ObjectManipulator::restoreSelection same_widget=%d",
|
||||
same_widget);
|
||||
|
||||
select();
|
||||
openObject( m_project->getOpenedEditor(), false);
|
||||
@ -2296,36 +2213,7 @@ void ObjectManipulator::editSelectedObject()
|
||||
bool ObjectManipulator::editObject(FWObject *obj)
|
||||
{
|
||||
if (fwbdebug) qDebug("ObjectManipulator::editObject");
|
||||
|
||||
/* if (RuleSet::isA (obj))
|
||||
{
|
||||
// if (m_project->getCurrentRuleSet()!=obj)
|
||||
return -1;
|
||||
}
|
||||
*/
|
||||
if (!m_project->isEditorVisible()) m_project->showEditor();
|
||||
|
||||
/*
|
||||
QList<QMdiSubWindow *> subWindowList = mw->getMdiArea()->subWindowList();
|
||||
QString fileName = m_project->getRCS()->getFileName();
|
||||
for (int i = 0 ; i < subWindowList.size();i++)
|
||||
{
|
||||
ProjectPanel * pp = dynamic_cast <ProjectPanel *>(subWindowList[i]->widget());
|
||||
if (pp!=NULL)
|
||||
{
|
||||
if (pp->getFileName () == fileName)
|
||||
{
|
||||
if (pp->m_panel->om!=this)
|
||||
{
|
||||
//libfwbuilder::FWObject* cl = pp->m_panel->om->getCurrentLib();
|
||||
pp->m_panel->om->loadObjects();
|
||||
pp->m_panel->om->currentTreePageChanged(2);
|
||||
// return true ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
return switchObjectInEditor(obj);
|
||||
}
|
||||
|
||||
@ -2378,6 +2266,11 @@ bool ObjectManipulator::switchObjectInEditor(FWObject *obj)
|
||||
return true; // successfully (re)opened obj in the editor
|
||||
}
|
||||
|
||||
void ObjectManipulator::closeObject()
|
||||
{
|
||||
currentObj = NULL;
|
||||
if (m_project->isEditorVisible()) m_project->hideEditor();
|
||||
}
|
||||
|
||||
void ObjectManipulator::openObject(ObjectTreeViewItem *otvi,
|
||||
bool register_in_history)
|
||||
@ -2401,12 +2294,14 @@ void ObjectManipulator::openObject(FWObject *obj, bool /*register_in_history*/)
|
||||
FWObject *o=obj;
|
||||
if (FWReference::cast(o)!=NULL) o=FWReference::cast(o)->getPointer();
|
||||
|
||||
ObjectTreeViewItem *otvi=allItems[o];
|
||||
ObjectTreeViewItem *otvi = allItems[o];
|
||||
|
||||
// this changes selection and thus calls slot slectionChanged
|
||||
showObjectInTree(otvi);
|
||||
|
||||
m_objectManipulator->libs->setCurrentIndex( getIdxForLib( obj->getLibrary() ) );
|
||||
updateCreateObjectMenu( obj->getLibrary() );
|
||||
m_objectManipulator->libs->setCurrentIndex(
|
||||
getIdxForLib( obj->getLibrary()));
|
||||
updateCreateObjectMenu(obj->getLibrary());
|
||||
}
|
||||
|
||||
void ObjectManipulator::selectionChanged(QTreeWidgetItem *cur)
|
||||
@ -2640,7 +2535,8 @@ FWObject* ObjectManipulator::createObject(const QString &objType,
|
||||
lib->getName().c_str(),
|
||||
FWObjectDatabase::getStringId(lib->getId()).c_str());
|
||||
qDebug("lib: isReadOnly=%d isLoaded=%d",
|
||||
lib->isReadOnly(), m_project->getAddOnLibs()->isLoaded( lib->getName().c_str() ) );
|
||||
lib->isReadOnly(),
|
||||
m_project->getAddOnLibs()->isLoaded( lib->getName().c_str() ) );
|
||||
qDebug("libs->count()=%d", m_objectManipulator->libs->count() );
|
||||
}
|
||||
|
||||
@ -2697,7 +2593,6 @@ FWObject* ObjectManipulator::createObject(FWObject *parent,
|
||||
const QString &objName,
|
||||
FWObject *copyFrom)
|
||||
{
|
||||
|
||||
if (!validateDialog()) return NULL;
|
||||
|
||||
FWObject *lib = getCurrentLib();
|
||||
@ -2730,7 +2625,27 @@ FWObject* ObjectManipulator::createObject(FWObject *parent,
|
||||
if (parent==NULL) parent=lib;
|
||||
|
||||
return actuallyCreateObject(parent,objType,objName,copyFrom);
|
||||
|
||||
|
||||
}
|
||||
|
||||
FWObject* ObjectManipulator::actuallyCreateObject(FWObject *parent,
|
||||
const QString &objType,
|
||||
const QString &objName,
|
||||
FWObject *copyFrom)
|
||||
{
|
||||
FWObject *nobj=NULL;
|
||||
if (!isTreeReadWrite(this, parent)) return NULL;
|
||||
nobj = m_project->db()->create(objType.toLatin1().constData());
|
||||
assert(nobj!=NULL);
|
||||
if (copyFrom!=NULL) nobj->duplicate(copyFrom,true);
|
||||
if (nobj->isReadOnly()) nobj->setReadOnly(false);
|
||||
nobj->setName( string(objName.toUtf8().constData()) );
|
||||
makeNameUnique(parent, nobj);
|
||||
parent->add(nobj);
|
||||
insertSubtree(allItems[parent], nobj);
|
||||
m_project->db()->setDirty(true);
|
||||
mw->reloadAllWindowsWithFile(m_project);
|
||||
return nobj;
|
||||
}
|
||||
|
||||
|
||||
@ -2742,11 +2657,11 @@ FWObject* ObjectManipulator::copyObj2Tree(
|
||||
ids.clear();
|
||||
if (Interface::isA(copyFrom) && Firewall::isA(parent))
|
||||
{
|
||||
FWObject *no = pasteTo (parent,copyFrom, false, false, true);
|
||||
FWObject *no = pasteTo (parent,copyFrom, false, false, true);
|
||||
return no;
|
||||
}
|
||||
FWObject *nobj=copyFrom->getRoot()->create(copyFrom->getTypeName());
|
||||
nobj->duplicate(copyFrom,true);
|
||||
FWObject *nobj = copyFrom->getRoot()->create(copyFrom->getTypeName());
|
||||
nobj->duplicate(copyFrom, true);
|
||||
nobj->setRoot(copyFrom->getRoot());
|
||||
return copyObjWithDeep(nobj);
|
||||
}
|
||||
@ -2821,61 +2736,22 @@ FWObject * ObjectManipulator::copyObjWithDeep(FWObject *copyFrom)
|
||||
|
||||
if (lib->getRoot()->getById(nobj->getId(),true)==NULL)
|
||||
{
|
||||
FWObject *par = m_project->getFWTree()->getStandardSlotForObject(lib, nobj->getTypeName().c_str());
|
||||
QVector <ObjectManipulator*> oms = getAllMdiObjectManipulators();
|
||||
FWObject *par = m_project->getFWTree()->getStandardSlotForObject(
|
||||
lib, nobj->getTypeName().c_str());
|
||||
QVector <ObjectManipulator*> oms = getAllMdiObjectManipulators();
|
||||
pasteTo (par, nobj, false, false, false);
|
||||
}
|
||||
return nobj;
|
||||
|
||||
}
|
||||
|
||||
|
||||
FWObject* ObjectManipulator::actuallyCreateObject(FWObject *parent,
|
||||
const QString &objType,
|
||||
const QString &objName,
|
||||
FWObject *copyFrom)
|
||||
{
|
||||
FWObject *nobj=NULL;
|
||||
bool first = true ;
|
||||
QVector <ObjectManipulator*> oms = getAllMdiObjectManipulators();
|
||||
for (int i = 0 ; i < oms.size(); i++)
|
||||
{
|
||||
ObjectManipulator* pom = oms[i] ;
|
||||
if (first)
|
||||
{
|
||||
|
||||
if (!isTreeReadWrite(pom, parent)) return NULL;
|
||||
nobj = pom->m_project->db()->create(objType.toLatin1().constData());
|
||||
assert(nobj!=NULL);
|
||||
|
||||
if (copyFrom!=NULL) nobj->duplicate(copyFrom,true);
|
||||
if (nobj->isReadOnly()) nobj->setReadOnly(false);
|
||||
|
||||
nobj->setName( string(objName.toUtf8().constData()) );
|
||||
makeNameUnique(parent,nobj);
|
||||
|
||||
parent->add(nobj);
|
||||
}
|
||||
pom->insertSubtree(pom->allItems[parent], nobj);
|
||||
|
||||
pom->m_project->db()->setDirty(true);
|
||||
first=false;
|
||||
}
|
||||
return nobj;
|
||||
}
|
||||
|
||||
void ObjectManipulator::newLibrary()
|
||||
{
|
||||
|
||||
if (!validateDialog()) return;
|
||||
|
||||
FWObject *nlib = m_project->createNewLibrary(m_project->db());
|
||||
|
||||
addTreePage( nlib );
|
||||
|
||||
openObject( nlib );
|
||||
editObject(nlib);
|
||||
|
||||
}
|
||||
|
||||
void ObjectManipulator::newPolicyRuleSet ()
|
||||
@ -2945,12 +2821,12 @@ void ObjectManipulator::newFirewall()
|
||||
|
||||
if (o!=NULL)
|
||||
{
|
||||
QVector <ObjectManipulator*> oms = getAllMdiObjectManipulators();
|
||||
for (int i = 0 ; i < oms.size(); i++)
|
||||
{
|
||||
ObjectManipulator* pom = oms[i] ;
|
||||
pom->openObject(o);
|
||||
}
|
||||
QVector <ObjectManipulator*> oms = getAllMdiObjectManipulators();
|
||||
for (int i = 0 ; i < oms.size(); i++)
|
||||
{
|
||||
ObjectManipulator* pom = oms[i] ;
|
||||
pom->openObject(o);
|
||||
}
|
||||
editObject(o);
|
||||
}
|
||||
|
||||
|
||||
@ -101,7 +101,8 @@ class ObjectManipulator : public QWidget/*ObjectManipulator_q*/ {
|
||||
std::map<libfwbuilder::FWObject*, ObjectTreeViewItem*> allItems;
|
||||
QVector <ObjectManipulator*> getAllMdiObjectManipulators ();
|
||||
|
||||
ObjectTreeViewItem* insertObject( ObjectTreeViewItem *itm,libfwbuilder::FWObject *obj );
|
||||
ObjectTreeViewItem* insertObject( ObjectTreeViewItem *itm,
|
||||
libfwbuilder::FWObject *obj );
|
||||
void insertSubtree( ObjectTreeViewItem *itm,libfwbuilder::FWObject *obj );
|
||||
|
||||
void removeObjectFromTreeView(libfwbuilder::FWObject *obj );
|
||||
@ -122,12 +123,15 @@ class ObjectManipulator : public QWidget/*ObjectManipulator_q*/ {
|
||||
const QString &objType,
|
||||
const QString &objName,
|
||||
libfwbuilder::FWObject *copyFrom=NULL);
|
||||
|
||||
void autorename(libfwbuilder::FWObject *obj,bool ask=true);
|
||||
void extractFirewallsFromGroup(
|
||||
libfwbuilder::ObjectGroup *gr,
|
||||
std::set<libfwbuilder::Firewall*> &fo);
|
||||
|
||||
ProjectPanel *m_project;
|
||||
|
||||
|
||||
public slots:
|
||||
virtual void libChanged(int l);
|
||||
virtual void switchingTrees(QWidget* w);
|
||||
@ -150,6 +154,11 @@ public slots:
|
||||
*/
|
||||
bool editObject(libfwbuilder::FWObject *obj);
|
||||
|
||||
/*
|
||||
* forget about currently opened object; close editor panel if it is open
|
||||
*/
|
||||
void closeObject();
|
||||
|
||||
void editSelectedObject();
|
||||
|
||||
void contextMenuRequested(const QPoint &pos);
|
||||
@ -163,8 +172,11 @@ public slots:
|
||||
const QString &objType,
|
||||
const QString &objName,
|
||||
libfwbuilder::FWObject *copyFrom=NULL);
|
||||
libfwbuilder::FWObject * copyObj2Tree(const QString &objType, const QString &objName,
|
||||
libfwbuilder::FWObject *copyFrom, libfwbuilder::FWObject *parent=NULL, bool ask4Lib=true);
|
||||
libfwbuilder::FWObject * copyObj2Tree(const QString &objType,
|
||||
const QString &objName,
|
||||
libfwbuilder::FWObject *copyFrom,
|
||||
libfwbuilder::FWObject *parent=NULL,
|
||||
bool ask4Lib=true);
|
||||
|
||||
libfwbuilder::FWObject * copyObjWithDeep(libfwbuilder::FWObject *copyFrom);
|
||||
|
||||
@ -199,9 +211,6 @@ public slots:
|
||||
void newInterval();
|
||||
void newPolicyRuleSet ();
|
||||
void newNATRuleSet ();
|
||||
void duplicateObj(QAction*);
|
||||
void duplicateObjUnderSameParent();
|
||||
void moveObj(QAction*);
|
||||
void copyObj();
|
||||
void cutObj();
|
||||
void pasteObj();
|
||||
@ -210,6 +219,9 @@ public slots:
|
||||
void compile();
|
||||
void install();
|
||||
|
||||
void duplicateObj(QAction*);
|
||||
void moveObj(QAction*);
|
||||
|
||||
void groupObjects();
|
||||
|
||||
void openObject(QTreeWidgetItem *otvi);
|
||||
@ -226,152 +238,154 @@ public slots:
|
||||
virtual void findWhereUsedSlot();
|
||||
|
||||
|
||||
public:
|
||||
void libChangedById(int id);
|
||||
void changeFirstNotSystemLib();
|
||||
std::vector<QTreeWidget*> getTreeWidgets() { return idxToTrees;};
|
||||
public:
|
||||
|
||||
void libChangedById(int id);
|
||||
void changeFirstNotSystemLib();
|
||||
std::vector<QTreeWidget*> getTreeWidgets() { return idxToTrees;};
|
||||
Ui::ObjectManipulator_q *m_objectManipulator;
|
||||
void filterFirewallsFromSelection(
|
||||
std::vector<libfwbuilder::FWObject*> &so,
|
||||
std::set<libfwbuilder::Firewall*> &fo);
|
||||
void autorename(libfwbuilder::FWObject *obj,
|
||||
const std::string &objtype,
|
||||
const std::string &namesuffix);
|
||||
void filterFirewallsFromSelection(
|
||||
std::vector<libfwbuilder::FWObject*> &so,
|
||||
std::set<libfwbuilder::Firewall*> &fo);
|
||||
void autorename(libfwbuilder::FWObject *obj,
|
||||
const std::string &objtype,
|
||||
const std::string &namesuffix);
|
||||
|
||||
ObjectManipulator( QWidget *parent);
|
||||
~ObjectManipulator();
|
||||
void loadObjects();
|
||||
void loadObjects(libfwbuilder::FWObjectDatabase *db);
|
||||
void clearObjects();
|
||||
ObjectManipulator( QWidget *parent);
|
||||
~ObjectManipulator();
|
||||
|
||||
void loadObjects();
|
||||
void clearObjects();
|
||||
|
||||
bool validateDialog();
|
||||
void invalidateDialog();
|
||||
bool validateDialog();
|
||||
void invalidateDialog();
|
||||
|
||||
void reopenCurrentItemParent();
|
||||
void reopenCurrentItemParent();
|
||||
|
||||
void openObject(libfwbuilder::FWObject *obj, bool register_in_history);
|
||||
void openObject(ObjectTreeViewItem *otvi, bool register_in_history);
|
||||
void openObject(libfwbuilder::FWObject *obj, bool register_in_history);
|
||||
void openObject(ObjectTreeViewItem *otvi, bool register_in_history);
|
||||
|
||||
libfwbuilder::FWObject* duplicateObject(libfwbuilder::FWObject *target,
|
||||
libfwbuilder::FWObject *obj,
|
||||
const QString &name = QString::null,
|
||||
bool askForAutorename=true);
|
||||
void moveObject(libfwbuilder::FWObject *target,
|
||||
libfwbuilder::FWObject *obj);
|
||||
libfwbuilder::FWObject* duplicateObject(libfwbuilder::FWObject *target,
|
||||
libfwbuilder::FWObject *obj,
|
||||
const QString &name = QString::null,
|
||||
bool askForAutorename=true);
|
||||
void moveObject(libfwbuilder::FWObject *target,
|
||||
libfwbuilder::FWObject *obj);
|
||||
|
||||
void moveObject(const QString &targetLibName,
|
||||
libfwbuilder::FWObject *obj);
|
||||
void moveObject(const QString &targetLibName, libfwbuilder::FWObject *obj);
|
||||
|
||||
libfwbuilder::FWObject* getOpened() { return currentObj; }
|
||||
libfwbuilder::FWObject* getOpened() { return currentObj; }
|
||||
|
||||
void updateLibColor(libfwbuilder::FWObject *lib);
|
||||
void updateLibName(libfwbuilder::FWObject *lib);
|
||||
void updateLibColor(libfwbuilder::FWObject *lib);
|
||||
void updateLibName(libfwbuilder::FWObject *lib);
|
||||
|
||||
void updateObjName(libfwbuilder::FWObject *obj,
|
||||
const QString &oldName,
|
||||
bool askForAutorename=true);
|
||||
void updateObjName(libfwbuilder::FWObject *obj,
|
||||
const QString &oldName,
|
||||
const QString &oldLabel,
|
||||
bool askForAutorename=true);
|
||||
void updateObjName(libfwbuilder::FWObject *obj,
|
||||
const QString &oldName,
|
||||
bool askForAutorename=true);
|
||||
void updateObjName(libfwbuilder::FWObject *obj,
|
||||
const QString &oldName,
|
||||
const QString &oldLabel,
|
||||
bool askForAutorename=true);
|
||||
|
||||
ObjectTreeView* getCurrentObjectTree();
|
||||
libfwbuilder::FWObject* getSelectedObject();
|
||||
ObjectTreeView* getCurrentObjectTree();
|
||||
libfwbuilder::FWObject* getSelectedObject();
|
||||
|
||||
/**
|
||||
* this method opens given library in the tree
|
||||
*/
|
||||
void openLib(libfwbuilder::FWObject *lib);
|
||||
/**
|
||||
* this method opens given library in the tree
|
||||
*/
|
||||
void openLib(libfwbuilder::FWObject *lib);
|
||||
|
||||
/**
|
||||
* returns pointer at a library that is currently opened in the tree
|
||||
*/
|
||||
libfwbuilder::FWObject* getCurrentLib();
|
||||
/**
|
||||
* returns pointer at a library that is currently opened in the tree
|
||||
*/
|
||||
libfwbuilder::FWObject* getCurrentLib();
|
||||
|
||||
/**
|
||||
* this method makes sure the system library is NOT opened in the
|
||||
* tree. If it is, it switches to the 'User' library. If one of
|
||||
* the user's libraries is already opened, it does nothing.
|
||||
*/
|
||||
void closeSystemLib();
|
||||
/**
|
||||
* this method makes sure the system library is NOT opened in the
|
||||
* tree. If it is, it switches to the 'User' library. If one of
|
||||
* the user's libraries is already opened, it does nothing.
|
||||
*/
|
||||
void closeSystemLib();
|
||||
|
||||
libfwbuilder::FWObject* pasteTo(libfwbuilder::FWObject *target,
|
||||
libfwbuilder::FWObject *obj,
|
||||
bool openobj=true,
|
||||
bool validateOnly=false, bool renew_id=true);
|
||||
libfwbuilder::FWObject* pasteTo(libfwbuilder::FWObject *target,
|
||||
libfwbuilder::FWObject *obj,
|
||||
bool openobj=true,
|
||||
bool validateOnly=false,
|
||||
bool renew_id=true);
|
||||
|
||||
|
||||
void delObj(libfwbuilder::FWObject *obj,bool openobj=true);
|
||||
void delObj(libfwbuilder::FWObject *obj,bool openobj=true);
|
||||
|
||||
/**
|
||||
* select whatever object is current in the tree (used to restore
|
||||
* selected state of the tree item after it was unselected)
|
||||
*/
|
||||
void select();
|
||||
/**
|
||||
* select whatever object is current in the tree (used to restore
|
||||
* selected state of the tree item after it was unselected)
|
||||
*/
|
||||
void select();
|
||||
|
||||
/**
|
||||
* unselect whatever object is currently selected
|
||||
*/
|
||||
void unselect();
|
||||
/**
|
||||
* unselect whatever object is currently selected
|
||||
*/
|
||||
void unselect();
|
||||
|
||||
/**
|
||||
* returns true if anything is selected in the tree
|
||||
*/
|
||||
bool isSelected();
|
||||
/**
|
||||
* returns true if anything is selected in the tree
|
||||
*/
|
||||
bool isSelected();
|
||||
|
||||
/**
|
||||
* controls whether "Deleted Objects" library is shown
|
||||
*/
|
||||
void showDeletedObjects(bool f);
|
||||
/**
|
||||
* controls whether "Deleted Objects" library is shown
|
||||
*/
|
||||
void showDeletedObjects(bool f);
|
||||
|
||||
|
||||
/**
|
||||
* get boolean flags that describe state of the menu items.
|
||||
* Can be used for both pop-up context menu and the main menu.
|
||||
*/
|
||||
void getMenuState(bool haveMoveTargets,
|
||||
bool &dupMenuItem,
|
||||
bool &moveMenuItem,
|
||||
bool ©MenuItem,
|
||||
bool &pasteMenuItem,
|
||||
bool &delMenuItem,
|
||||
bool &newMenuItem,
|
||||
bool &inDeletedObjects);
|
||||
/**
|
||||
* get boolean flags that describe state of the menu items.
|
||||
* Can be used for both pop-up context menu and the main menu.
|
||||
*/
|
||||
void getMenuState(bool haveMoveTargets,
|
||||
bool &dupMenuItem,
|
||||
bool &moveMenuItem,
|
||||
bool ©MenuItem,
|
||||
bool &pasteMenuItem,
|
||||
bool &delMenuItem,
|
||||
bool &newMenuItem,
|
||||
bool &inDeletedObjects);
|
||||
|
||||
void updateLastModifiedTimestampForOneFirewall(libfwbuilder::FWObject *o);
|
||||
void updateLastModifiedTimestampForAllFirewalls(libfwbuilder::FWObject *o);
|
||||
void updateLastInstalledTimestamp(libfwbuilder::FWObject *o);
|
||||
void updateLastCompiledTimestamp(libfwbuilder::FWObject *o);
|
||||
void updateLastModifiedTimestampForOneFirewall(libfwbuilder::FWObject *o);
|
||||
void updateLastModifiedTimestampForAllFirewalls(libfwbuilder::FWObject *o);
|
||||
void updateLastInstalledTimestamp(libfwbuilder::FWObject *o);
|
||||
void updateLastCompiledTimestamp(libfwbuilder::FWObject *o);
|
||||
|
||||
std::list<libfwbuilder::Firewall * > findFirewallsForObject(libfwbuilder::FWObject *o);
|
||||
void findAllFirewalls (std::list<libfwbuilder::Firewall *> &fws);
|
||||
std::list<libfwbuilder::Firewall*> findFirewallsForObject(
|
||||
libfwbuilder::FWObject *o);
|
||||
void findAllFirewalls (std::list<libfwbuilder::Firewall *> &fws);
|
||||
|
||||
|
||||
signals:
|
||||
signals:
|
||||
/**
|
||||
* the dialog class should have a slot that can load object's data
|
||||
* into dialog elements when ObjectManipulator emits this signal
|
||||
*/
|
||||
void loadObject_sign(libfwbuilder::FWObject *);
|
||||
void loadObject_sign(libfwbuilder::FWObject *);
|
||||
|
||||
/**
|
||||
* the dialog class should have a slot that can verify data entered by
|
||||
* user in the dialog elements when ObjectManipulator emits this
|
||||
* signal. The validation result is returned in variable "bool *res"
|
||||
*/
|
||||
void validate_sign(bool *res);
|
||||
void validate_sign(bool *res);
|
||||
|
||||
/**
|
||||
* the dialog class should have a slot that can verify if the data in
|
||||
* dialog has been edited.
|
||||
*/
|
||||
void isChanged_sign(bool *res);
|
||||
void isChanged_sign(bool *res);
|
||||
|
||||
/**
|
||||
* the dialog class should have a slot that applies changes made by
|
||||
* the user and saves data in the object.
|
||||
*/
|
||||
void applyChanges_sign();
|
||||
void applyChanges_sign();
|
||||
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
1694
src/gui/ProjectPanel_file_ops.cpp
Normal file
1694
src/gui/ProjectPanel_file_ops.cpp
Normal file
@ -0,0 +1,1694 @@
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
Copyright (C) 2008 NetCitadel, LLC
|
||||
|
||||
Author: alek@codeminders.com
|
||||
refactoring and bugfixes: vadim@fwbuilder.org
|
||||
|
||||
$Id: ProjectPanel.cpp 417 2008-07-26 06:55:44Z 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
|
||||
|
||||
*/
|
||||
|
||||
#include "../../config.h"
|
||||
#include "global.h"
|
||||
#include "utils.h"
|
||||
#include "utils_no_qt.h"
|
||||
|
||||
#include "ProjectPanel.h"
|
||||
|
||||
#include <ui_rcsfilesavedialog_q.h>
|
||||
|
||||
#include "FWWindow.h"
|
||||
#include "RCS.h"
|
||||
#include "filePropDialog.h"
|
||||
#include "FWBSettings.h"
|
||||
#include "RCSFilePreview.h"
|
||||
#include "FindObjectWidget.h"
|
||||
#include "FWObjectClipboard.h"
|
||||
#include "upgradePredicate.h"
|
||||
#include "ObjConflictResolutionDialog.h"
|
||||
#include "LibExportDialog.h"
|
||||
#include "longTextDialog.h"
|
||||
|
||||
//#include "listOfLibraries.h"
|
||||
|
||||
#include <QMdiSubWindow>
|
||||
#include <QMdiArea>
|
||||
|
||||
#include <list>
|
||||
|
||||
|
||||
using namespace Ui;
|
||||
using namespace libfwbuilder;
|
||||
using namespace std;
|
||||
|
||||
bool ProjectPanel::saveIfModified()
|
||||
{
|
||||
if (db() && db()->isDirty())
|
||||
{
|
||||
QString message = "Some objects have been modified but not saved.\n";
|
||||
message+="Do you want to save ";
|
||||
message+=rcs->getFileName();
|
||||
message+=" changes now ?";
|
||||
switch (QMessageBox::information(this, "Firewall Builder",
|
||||
message,
|
||||
tr("&Save"), tr("&Discard"), tr("&Cancel"),
|
||||
0, // Enter = button 0
|
||||
2 ) ) { // Escape == button 2
|
||||
|
||||
case 0:
|
||||
save();
|
||||
break;
|
||||
case 1: // discard
|
||||
db()->setDirty(false);
|
||||
break;
|
||||
case 2: // cancel
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QString ProjectPanel::chooseNewFileName(const QString &fname,
|
||||
bool checkPresence,
|
||||
const QString &title)
|
||||
{
|
||||
QString destdir = getDestDir(fname);
|
||||
|
||||
QString fn = QFileDialog::getSaveFileName( this, title, destdir,
|
||||
tr( "FWB Files (*.fwb);;All Files (*)" ) );
|
||||
if ( fn.isEmpty() ) return "";
|
||||
|
||||
QFileInfo finfo(fn);
|
||||
|
||||
//if (finfo.extension(false)!="fwb") fn=fn+".fwb";
|
||||
if (finfo.suffix()!="fwb") fn=fn+".fwb";
|
||||
|
||||
finfo.setFile(fn);
|
||||
|
||||
if ( ! checkPresence || ! finfo.exists() ||
|
||||
QMessageBox::warning(
|
||||
this,"Firewall Builder",
|
||||
tr("The file %1 already exists.\nDo you want to overwrite it ?")
|
||||
.arg(fn.toLatin1().constData()),
|
||||
tr("&Yes"), tr("&No"), QString::null,
|
||||
0, 1 )==0 )
|
||||
{
|
||||
return fn;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
void ProjectPanel::fileProp()
|
||||
{
|
||||
if (rcs!=NULL)
|
||||
{
|
||||
filePropDialog fpd(this,rcs);
|
||||
fpd.setPrinter(mainW->getPrinter());
|
||||
fpd.exec();
|
||||
}
|
||||
}
|
||||
|
||||
bool ProjectPanel::fileNew()
|
||||
{
|
||||
QString nfn = chooseNewFileName(
|
||||
st->getWDir(),true,
|
||||
tr("Choose name and location for the new file"));
|
||||
|
||||
if ( !nfn.isEmpty() )
|
||||
{
|
||||
//if (!saveIfModified() || !checkin(true)) return;
|
||||
if (!systemFile && rcs!=NULL)
|
||||
fileClose(); // fileClose calls load(this)
|
||||
else
|
||||
load(this);
|
||||
|
||||
visibleFirewall = NULL;
|
||||
setFileName(nfn);
|
||||
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 ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool ProjectPanel::fileOpen()
|
||||
{
|
||||
if (fwbdebug) qDebug("ProjectPanel::fileOpen(): start");
|
||||
|
||||
QString dir;
|
||||
dir=st->getWDir();
|
||||
if (dir.isEmpty()) dir=st->getOpenFileDir();
|
||||
if (dir.isEmpty()) dir=userDataDir.c_str();
|
||||
|
||||
QString fileName = QFileDialog::getOpenFileName(
|
||||
mainW,
|
||||
tr("Open File"),
|
||||
dir,
|
||||
tr("FWB files (*.fwb *.fwl *.xml);;All Files (*)"));
|
||||
|
||||
if (fileName.isEmpty()) return false;
|
||||
|
||||
return loadFile(fileName);
|
||||
}
|
||||
|
||||
bool ProjectPanel::loadFile(const QString &fileName)
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug("ProjectPanel::loadFile fileName=%s",
|
||||
fileName.toAscii().constData());
|
||||
|
||||
RCSFilePreview fp(this);
|
||||
|
||||
bool hasRCS = fp.showFileRLog(fileName);
|
||||
|
||||
if ( (!hasRCS) || (fp.exec() == QDialog::Accepted) )
|
||||
{
|
||||
if (!saveIfModified() || !checkin(true)) return false;
|
||||
if (!systemFile && rcs!=NULL) fileClose();
|
||||
|
||||
//try to get simple rcs instance from RCS preview
|
||||
RCS *new_rcs = fp.getSelectedRev();
|
||||
|
||||
//if preview cannot give RCS,
|
||||
//get a new RCS from file dialog
|
||||
if (new_rcs==NULL)
|
||||
new_rcs = new RCS(fileName);
|
||||
|
||||
//if RCS isn't still formed, it's an error
|
||||
if (new_rcs==NULL)
|
||||
return false;
|
||||
|
||||
/***********************************************************************
|
||||
* TODO : add an option "RCS support"
|
||||
*
|
||||
* if opening read-only, do not checkout
|
||||
* checkout may throw exception, need to catch it
|
||||
*/
|
||||
try
|
||||
{
|
||||
new_rcs->co();
|
||||
|
||||
} catch (FWException &ex)
|
||||
{
|
||||
/* if there was an exception, abort operation. E.g. RCS::co may throw
|
||||
* exception */
|
||||
return false;
|
||||
}
|
||||
/***********************************************************************/
|
||||
|
||||
QList<QMdiSubWindow*> subWindowList = mw->getMdiArea()->subWindowList();
|
||||
|
||||
QString fileName = new_rcs->getFileName();
|
||||
for (int i = 0 ; i < subWindowList.size();i++)
|
||||
{
|
||||
ProjectPanel * pp = dynamic_cast<ProjectPanel*>(
|
||||
subWindowList[i]->widget());
|
||||
if (pp!=NULL && pp->getFileName() == fileName)
|
||||
{
|
||||
load(this, new_rcs, pp->objdb );
|
||||
|
||||
if (new_rcs->isTemp())
|
||||
unlink(new_rcs->getFileName().toLatin1().constData());
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
load(this, new_rcs );
|
||||
|
||||
if (new_rcs->isTemp())
|
||||
unlink(new_rcs->getFileName().toLatin1().constData());
|
||||
|
||||
if (fwbdebug) qDebug("ProjectPanel::loadFile done");
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ProjectPanel::fileClose()
|
||||
{
|
||||
if (fwbdebug) qDebug("ProjectPanel::fileClose(): start");
|
||||
|
||||
closing=true ;
|
||||
|
||||
findObjectWidget->init();
|
||||
if (isEditorVisible()) hideEditor();
|
||||
|
||||
if (!saveIfModified() || !checkin(true)) return;
|
||||
|
||||
if (rcs) delete rcs;
|
||||
rcs=NULL;
|
||||
|
||||
if (fwbdebug) qDebug("ProjectPanel::fileClose(): clearing widgets");
|
||||
|
||||
FWObjectClipboard::obj_clipboard->clear();
|
||||
|
||||
mdiWindow->close();
|
||||
|
||||
firewalls.clear();
|
||||
visibleFirewall = NULL;
|
||||
visibleRuleSet = NULL;
|
||||
clearFirewallTabs();
|
||||
clearObjects();
|
||||
|
||||
if (fwbdebug) qDebug("ProjectPanel::fileClose(): done");
|
||||
}
|
||||
|
||||
void ProjectPanel::fileSave()
|
||||
{
|
||||
QStatusBar *sb = mainW->statusBar();
|
||||
sb->showMessage( tr("Saving data to file...") );
|
||||
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents,100);
|
||||
save();
|
||||
sb->clearMessage();
|
||||
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents,100);
|
||||
}
|
||||
|
||||
void ProjectPanel::fileSaveAs()
|
||||
{
|
||||
if (isEditorVisible()) hideEditor();
|
||||
|
||||
/* we need to save data into the current file before we save it into a
|
||||
* new file, provided we do have current file
|
||||
if (!systemFile && rcs &&
|
||||
!rcs->isRO() && !rcs->isTemp() && !rcs->getFileName().isEmpty() &&
|
||||
(!saveIfModified() || !checkin(true))
|
||||
) return;
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/* 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,
|
||||
tr("Choose name and location for the file"));
|
||||
|
||||
if (!nfn.isEmpty())
|
||||
{
|
||||
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() );
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectPanel::fileExit()
|
||||
{
|
||||
if (saveIfModified() && checkin(true))
|
||||
{
|
||||
saveState();
|
||||
storeLastOpenedLib();
|
||||
if (rcs) delete rcs;
|
||||
qApp->quit();
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectPanel::fileCommit()
|
||||
{
|
||||
save();
|
||||
if (!checkin(true)) return;
|
||||
rcs->co();
|
||||
}
|
||||
|
||||
/*
|
||||
* discard changes done to the file and check out clean copy of the
|
||||
* head revision from RCS
|
||||
*/
|
||||
void ProjectPanel::fileDiscard()
|
||||
{
|
||||
if (QMessageBox::warning(this, "Firewall Builder",
|
||||
tr("This operation discards all changes that have been saved\n"
|
||||
"into the file so far, closes it and replaces it with a clean\n"
|
||||
"copy of its head revision from RCS.\n"
|
||||
"\n"
|
||||
"All changes will be lost if you do this.\n\n"),
|
||||
tr("&Discard changes"),
|
||||
tr("&Cancel"), QString::null,
|
||||
1 )==0 )
|
||||
{
|
||||
/* need to close the file without asking and saving, then
|
||||
* reopen it again
|
||||
*/
|
||||
|
||||
QString fname = rcs->getFileName();
|
||||
|
||||
db()->setDirty(false); // so it wont ask if user wants to save
|
||||
rcs->abandon();
|
||||
|
||||
/* do everything fileClose() does except do not close mdiWindow
|
||||
* because we'll need it again to reopen the file into
|
||||
*/
|
||||
findObjectWidget->init();
|
||||
if (isEditorVisible()) hideEditor();
|
||||
|
||||
if (rcs) delete rcs;
|
||||
rcs=NULL;
|
||||
|
||||
FWObjectClipboard::obj_clipboard->clear();
|
||||
|
||||
firewalls.clear();
|
||||
visibleFirewall = NULL;
|
||||
visibleRuleSet = NULL;
|
||||
clearFirewallTabs();
|
||||
clearObjects();
|
||||
|
||||
/* loadFile calls fileClose, but only if file is currently
|
||||
* open, which it isn't because we reset rcs to NULL
|
||||
*/
|
||||
loadFile(fname);
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectPanel::fileAddToRCS()
|
||||
{
|
||||
if (!saveIfModified()) return;
|
||||
if (rcs && rcs->isCheckedOut()) return;
|
||||
|
||||
try
|
||||
{
|
||||
if (!rcs->isInRCS() && !rcs->isRO())
|
||||
{
|
||||
rcs->add();
|
||||
rcs->co();
|
||||
QMessageBox::information(
|
||||
this,"Firewall Builder",
|
||||
tr("File %1 has been added to RCS.").arg(rcs->getFileName()),
|
||||
tr("&Continue"), QString::null,QString::null,
|
||||
0, 1 );
|
||||
}
|
||||
}
|
||||
catch (FWException &ex)
|
||||
{
|
||||
QMessageBox::critical(
|
||||
this,"Firewall Builder",
|
||||
tr("Error adding file to RCS:\n%1").arg(ex.toString().c_str()),
|
||||
tr("&Continue"), QString::null,QString::null,
|
||||
0, 1 );
|
||||
}
|
||||
|
||||
QString caption = rcs->getFileName().section("/",-1,-1);
|
||||
if (rcs->isInRCS()) caption = caption + ", rev " + rcs->getSelectedRev();
|
||||
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()
|
||||
{
|
||||
resetFD();
|
||||
|
||||
QString fname = QFileDialog::getOpenFileName(
|
||||
mainW,
|
||||
tr("Choose a file to import"),
|
||||
st->getWDir(),
|
||||
"FWB library files (*.fwl);;FWB Files (*.fwb);;All Files (*)");
|
||||
|
||||
if (fname.isEmpty()) return; // Cancel - keep working with old file
|
||||
|
||||
loadLibrary( fname.toLatin1().constData() );
|
||||
|
||||
loadObjects();
|
||||
}
|
||||
|
||||
|
||||
void ProjectPanel::fileCompare()
|
||||
{
|
||||
resetFD();
|
||||
|
||||
QMessageBox initial_question( QMessageBox::Information, "Firewall Builder",
|
||||
tr("This operation inspects two data files (either .fwb or .fwl) and finds conflicting objects. Conflicting objects have the same internal ID but different attributes. Two data files can not be merged, or one imported into another, if they contain such objects. This operation also helps identify changes made to objects in two copies of the same data file.<br><br>This operation does not find objects present in one file but not in the other, such objects present no problem for merge or import operations.<br><br>This operation works with two external files, neither of which needs to be opened in the program. Currently opened data file is not affected by this operation and objects in the tree do not change.<br><br>Do you want to proceed ?"),
|
||||
QMessageBox::Yes | QMessageBox::No);
|
||||
|
||||
initial_question.setTextFormat( Qt::RichText );
|
||||
if (initial_question.exec() != QMessageBox::Yes) return;
|
||||
|
||||
|
||||
QString fname1 = QFileDialog::getOpenFileName(
|
||||
mainW,
|
||||
tr("Choose the first file"),
|
||||
st->getWDir(),
|
||||
"FWB files (*.fwb);;FWB Library Files (*.fwl);;All Files (*)");
|
||||
|
||||
if (fname1.isEmpty()) return; // Cancel
|
||||
|
||||
QString fname2 = QFileDialog::getOpenFileName(
|
||||
mainW,
|
||||
tr("Choose the second file"),
|
||||
st->getWDir(),
|
||||
"FWB files (*.fwb);;FWB Library Files (*.fwl);;All Files (*)");
|
||||
|
||||
if (fname2.isEmpty()) return; // Cancel
|
||||
|
||||
MessageBoxUpgradePredicate upgrade_predicate(mainW);
|
||||
|
||||
FWObjectDatabase *db1;
|
||||
FWObjectDatabase *db2;
|
||||
FWObject *dobj;
|
||||
|
||||
try
|
||||
{
|
||||
db1 = new FWObjectDatabase();
|
||||
db1->load(fname1.toLatin1().constData(),
|
||||
&upgrade_predicate, librespath);
|
||||
|
||||
dobj = db1->findInIndex(FWObjectDatabase::DELETED_OBJECTS_ID);
|
||||
if (dobj) db1->remove(dobj, false);
|
||||
} catch(FWException &ex)
|
||||
{
|
||||
QMessageBox::warning(
|
||||
this,"Firewall Builder",
|
||||
tr("Error loading file %1:\n%2").
|
||||
arg(fname1).arg(ex.toString().c_str()),
|
||||
tr("&Continue"), QString::null,QString::null,
|
||||
0, 1 );
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
db2 = new FWObjectDatabase();
|
||||
db2->load(fname2.toLatin1().constData(),
|
||||
&upgrade_predicate, librespath);
|
||||
|
||||
dobj = db2->findInIndex(FWObjectDatabase::DELETED_OBJECTS_ID);
|
||||
if (dobj) db2->remove(dobj, false);
|
||||
} catch(FWException &ex)
|
||||
{
|
||||
QMessageBox::warning(
|
||||
this,"Firewall Builder",
|
||||
tr("Error loading file %1:\n%2").
|
||||
arg(fname2).arg(ex.toString().c_str()),
|
||||
tr("&Continue"), QString::null,QString::null,
|
||||
0, 1 );
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// CompareObjectsDialog is just like ObjConflictResolutionDialog
|
||||
// except it always returns 'accepted' and keeps record
|
||||
// of all object differences so we can print report in the end
|
||||
|
||||
CompareObjectsDialog cod(this);
|
||||
db1->merge(db2, &cod);
|
||||
list<QString> report = cod.getReport();
|
||||
|
||||
delete db1;
|
||||
delete db2;
|
||||
|
||||
ostringstream str;
|
||||
str << cod.getNumberOfConflicts();
|
||||
|
||||
QMessageBox mb( QMessageBox::Information, "Firewall Builder",
|
||||
tr("Total number of conflicting objects: %1.\nDo you want to generate report?").arg(str.str().c_str()),
|
||||
QMessageBox::Yes | QMessageBox::No);
|
||||
|
||||
if (mb.exec() == QMessageBox::Yes)
|
||||
{
|
||||
// save report to a file
|
||||
|
||||
QString destdir = getDestDir(fname1);
|
||||
|
||||
QString fn = QFileDialog::getSaveFileName( this,
|
||||
tr("Choose name and location for the report file"),
|
||||
destdir,
|
||||
tr( "TXT Files (*.txt);;All Files (*)" ));
|
||||
|
||||
if (fwbdebug)
|
||||
qDebug( QString("Saving report to %1").arg(fn).toAscii().constData() );
|
||||
|
||||
if (fn.isEmpty() ) return ; // Cancel
|
||||
|
||||
if (!fn.endsWith(".txt"))
|
||||
{
|
||||
fn+=".txt";
|
||||
}
|
||||
|
||||
QFile report_file(fn);
|
||||
if (report_file.open(QIODevice::WriteOnly))
|
||||
{
|
||||
QTextStream report_stream(&report_file);
|
||||
for (list<QString>::iterator i=report.begin(); i!=report.end(); ++i)
|
||||
{
|
||||
report_stream << *i;
|
||||
}
|
||||
report_file.close();
|
||||
} else
|
||||
{
|
||||
QMessageBox::critical(
|
||||
this,"Firewall Builder",
|
||||
tr("Can not open report file for writing. File '%1'").arg(fn),
|
||||
tr("&Continue"), QString::null,QString::null,
|
||||
0, 1 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch(FWException &ex)
|
||||
{
|
||||
QMessageBox::warning(
|
||||
this,"Firewall Builder",
|
||||
tr("Unexpected error comparing files %1 and %2:\n%3").
|
||||
arg(fname1).arg(fname2).arg(ex.toString().c_str()),
|
||||
tr("&Continue"), QString::null,QString::null,
|
||||
0, 1 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ProjectPanel::fileExport()
|
||||
{
|
||||
LibExportDialog ed;
|
||||
list<FWObject*> selectedLibs;
|
||||
map<int,FWObject*>::iterator i;
|
||||
QString path="";
|
||||
int lib_idx = -1;
|
||||
do
|
||||
{
|
||||
if (ed.exec()!=QDialog::Accepted) return;
|
||||
|
||||
QList<QListWidgetItem*> selitems = ed.m_dialog->libs->selectedItems();
|
||||
|
||||
for (i=ed.mapOfLibs.begin(); i!=ed.mapOfLibs.end(); i++)
|
||||
if (selitems.contains(ed.m_dialog->libs->item(i->first)))
|
||||
selectedLibs.push_back(i->second);
|
||||
|
||||
lib_idx=ed.m_dialog->libs->currentRow ();
|
||||
|
||||
if (lib_idx<0 || selectedLibs.size()==0)
|
||||
{
|
||||
QMessageBox::critical(
|
||||
this,"Firewall Builder",
|
||||
tr("Please select a library you want to export."),
|
||||
"&Continue", QString::null,QString::null,
|
||||
0, 1 );
|
||||
|
||||
return;
|
||||
}
|
||||
} while (!exportLibraryTest(selectedLibs));
|
||||
|
||||
FWObject *selLib = ed.mapOfLibs[ lib_idx ];
|
||||
path=st->getWDir()+QString::fromUtf8(selLib->getName().c_str())+".fwl";
|
||||
|
||||
resetFD();
|
||||
QString fname;
|
||||
fname = QFileDialog::getSaveFileName(
|
||||
this,
|
||||
"Choose a filename to save under",
|
||||
path,
|
||||
"Firewall Builder 2 files (*.fwl)");
|
||||
|
||||
if (fname.isEmpty()) return;
|
||||
if (QFile::exists(fname) &&
|
||||
QMessageBox::warning(
|
||||
this,"Firewall Builder",
|
||||
tr("The file %1 already exists.\nDo you want to overwrite it ?")
|
||||
.arg(fname),
|
||||
tr("&Yes"), tr("&No"), QString::null,
|
||||
0, 1 )==1 ) return;
|
||||
exportLibraryTo(fname,selectedLibs,ed.m_dialog->exportRO->isChecked());
|
||||
}
|
||||
|
||||
bool ProjectPanel::exportLibraryTest(list<FWObject*> &selectedLibs)
|
||||
{
|
||||
/* VERY IMPORTANT: External library file must be self-contained,
|
||||
* otherwise it can not be exported.
|
||||
*
|
||||
* check if selected libraries have references to objects in other
|
||||
* libraries (not exported to the same file). Exporting such libraries
|
||||
* pulls in other ones because of these references. This is confusing
|
||||
* because it means we end up with multiple copies of such objects (in
|
||||
* exported library file and in user's data file). When user imports
|
||||
* this library and opens their file, it is impossible to say which
|
||||
* library an object belongs to.
|
||||
*
|
||||
* This is prohibited. We check if exported set of libraries has such
|
||||
* references and refuse to export it. The user is supposed to clean
|
||||
* it up by either moving objects into the library they are trying to
|
||||
* export, or by rearranging objects. The only exception for this is
|
||||
* library "Standard", which is assumed to be always present so we can
|
||||
* have references to objects in it.
|
||||
*/
|
||||
QApplication::setOverrideCursor( QCursor( Qt::WaitCursor) );
|
||||
|
||||
list<FWReference*> externalRefs;
|
||||
for (list<FWObject*>::iterator i=selectedLibs.begin(); i!=selectedLibs.end(); ++i)
|
||||
findExternalRefs( *i, *i, externalRefs);
|
||||
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
if (fwbdebug) qDebug("LibExportDialog::accept externalRefs.size()=%d",
|
||||
int(externalRefs.size()) );
|
||||
|
||||
/*
|
||||
* if externalRefs.size()!=0, then there were some references pointing
|
||||
* outside of the libraries we export. Some of these references may
|
||||
* point at other libraries we export, lets find these.
|
||||
*/
|
||||
list<FWReference*> externalRefs2;
|
||||
for (list<FWReference*>::iterator i=externalRefs.begin(); i!=externalRefs.end(); ++i)
|
||||
{
|
||||
FWObject *tgt = (*i)->getPointer();
|
||||
FWObject *tgtlib = tgt->getLibrary();
|
||||
|
||||
if (std::find(selectedLibs.begin(),selectedLibs.end(),tgtlib)!=selectedLibs.end()) continue;
|
||||
externalRefs2.push_back(*i);
|
||||
}
|
||||
|
||||
if (externalRefs2.size()!=0)
|
||||
{
|
||||
QString objlist = "";
|
||||
QString s = "";
|
||||
|
||||
for (list<FWReference*>::iterator i=externalRefs2.begin(); i!=externalRefs2.end(); ++i)
|
||||
{
|
||||
FWReference *robj = *i;
|
||||
FWObject *selLib = robj->getLibrary();
|
||||
FWObject *pp = robj->getParent();
|
||||
FWObject *tgt = robj->getPointer();
|
||||
FWObject *tgtlib = tgt->getLibrary();
|
||||
|
||||
if (fwbdebug)
|
||||
{
|
||||
qDebug("LibExportDialog::accept tgt: %s pp_type: %s lib: %s",
|
||||
tgt->getName().c_str(),
|
||||
pp->getTypeName().c_str(),
|
||||
tgtlib->getName().c_str());
|
||||
}
|
||||
|
||||
if (std::find(selectedLibs.begin(),selectedLibs.end(),tgtlib)!=selectedLibs.end()) continue;
|
||||
|
||||
if (RuleElement::cast(pp)!=NULL)
|
||||
{
|
||||
FWObject *fw = pp;
|
||||
FWObject *rule = pp;
|
||||
FWObject *ruleset = pp;
|
||||
FWObject *iface = pp;
|
||||
|
||||
while (rule!=NULL && Rule::cast(rule)==NULL)
|
||||
rule=rule->getParent();
|
||||
while (ruleset!=NULL && RuleSet::cast(ruleset)==NULL)
|
||||
ruleset=ruleset->getParent();
|
||||
while (iface!=NULL && Interface::cast(iface)==NULL)
|
||||
iface=iface->getParent();
|
||||
while (fw!=NULL && Firewall::cast(fw)==NULL)
|
||||
fw=fw->getParent();
|
||||
|
||||
QString rsname;
|
||||
if (Policy::cast(ruleset)!=NULL)
|
||||
{
|
||||
s =
|
||||
QObject::tr("Library %1: Firewall '%2' (global policy rule #%3) uses object '%4' from library '%5'")
|
||||
.arg(selLib->getName().c_str())
|
||||
.arg(fw->getName().c_str())
|
||||
.arg(Rule::cast(rule)->getPosition())
|
||||
.arg(tgt->getName().c_str())
|
||||
.arg(tgtlib->getName().c_str());
|
||||
}
|
||||
if (InterfacePolicy::cast(ruleset)!=NULL)
|
||||
{
|
||||
QObject::tr("Library %1: Firewall '%2' (interface %3 policy rule #%4) uses object '%5' from library '%6'")
|
||||
.arg(selLib->getName().c_str())
|
||||
.arg(fw->getName().c_str())
|
||||
.arg(iface->getName().c_str())
|
||||
.arg(Rule::cast(rule)->getPosition())
|
||||
.arg(tgt->getName().c_str())
|
||||
.arg(tgtlib->getName().c_str());
|
||||
}
|
||||
if (NAT::cast(ruleset)!=NULL)
|
||||
{
|
||||
s =
|
||||
QObject::tr("Library %1: Firewall '%2' (NAT rule #%3) uses object '%4' from library '%5'")
|
||||
.arg(selLib->getName().c_str())
|
||||
.arg(fw->getName().c_str())
|
||||
.arg(Rule::cast(rule)->getPosition())
|
||||
.arg(tgt->getName().c_str())
|
||||
.arg(tgtlib->getName().c_str());
|
||||
}
|
||||
} else
|
||||
{
|
||||
s =
|
||||
QObject::tr("Library %1: Group '%2' uses object '%3' from library '%4'")
|
||||
.arg(selLib->getName().c_str())
|
||||
.arg(pp->getName().c_str())
|
||||
.arg(tgt->getName().c_str())
|
||||
.arg(tgtlib->getName().c_str());
|
||||
}
|
||||
s = s + "\n";
|
||||
|
||||
if (fwbdebug) qDebug(s.toAscii().constData());
|
||||
|
||||
objlist = objlist + s;
|
||||
}
|
||||
|
||||
longTextDialog ltd( this,
|
||||
|
||||
tr("A library that you are trying to export contains references\n"
|
||||
"to objects in the other libraries and can not be exported.\n"
|
||||
"The following objects need to be moved outside of it or\n"
|
||||
"objects that they refer to moved in it:"),
|
||||
objlist );
|
||||
|
||||
ltd.exec();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ProjectPanel::exportLibraryTo(QString fname,list<FWObject*> &selectedLibs, bool rof)
|
||||
{
|
||||
QApplication::setOverrideCursor( QCursor( Qt::WaitCursor) );
|
||||
|
||||
FWObjectDatabase *ndb = db()->exportSubtree( selectedLibs );
|
||||
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
if (rof)
|
||||
{
|
||||
for (list<FWObject*>::iterator i=selectedLibs.begin(); i!=selectedLibs.end(); ++i)
|
||||
{
|
||||
FWObject *nlib= ndb->findInIndex( (*i)->getId() );
|
||||
if (nlib && nlib->getId()!=FWObjectDatabase::DELETED_OBJECTS_ID)
|
||||
nlib->setReadOnly( true );
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
ndb->saveFile( fname.toLatin1().constData() );
|
||||
}
|
||||
catch (FWException &ex)
|
||||
{
|
||||
/* error saving the file. Since XMLTools does not return any useful
|
||||
* error message in the exception, let's check for obvious problems here
|
||||
*/
|
||||
QString err;
|
||||
if (access( fname.toLatin1().constData(), W_OK)!=0 && errno==EACCES)
|
||||
err=QObject::tr("File is read-only");
|
||||
|
||||
QMessageBox::warning(
|
||||
this,"Firewall Builder",
|
||||
QObject::tr("Error saving file %1: %2")
|
||||
.arg(fname).arg(err),
|
||||
"&Continue", QString::null, QString::null,
|
||||
0, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectPanel::setupAutoSave()
|
||||
{
|
||||
if ( st->getBool("Environment/autoSaveFile") &&
|
||||
rcs!=NULL && rcs->getFileName()!="")
|
||||
{
|
||||
int p = st->getInt("Environment/autoSaveFilePeriod");
|
||||
autosaveTimer->start( p*1000*60 );
|
||||
connect( autosaveTimer, SIGNAL(timeout()), this, SLOT(fileSave()) );
|
||||
} else
|
||||
autosaveTimer->stop();
|
||||
}
|
||||
|
||||
void ProjectPanel::findExternalRefs(FWObject *lib,
|
||||
FWObject *root,
|
||||
list<FWReference*> &extRefs)
|
||||
{
|
||||
FWReference *ref=FWReference::cast(root);
|
||||
if (ref!=NULL)
|
||||
{
|
||||
FWObject *plib = ref->getPointer()->getLibrary();
|
||||
if ( plib->getId()!=FWObjectDatabase::STANDARD_LIB_ID &&
|
||||
plib->getId()!=FWObjectDatabase::DELETED_OBJECTS_ID &&
|
||||
plib!=lib )
|
||||
extRefs.push_back(ref);
|
||||
return;
|
||||
} else
|
||||
{
|
||||
for (FWObject::iterator i=root->begin(); i!=root->end(); i++)
|
||||
findExternalRefs(lib, *i, extRefs);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectPanel::loadLibrary(const string &libfpath)
|
||||
{
|
||||
MessageBoxUpgradePredicate upgrade_predicate(mainW);
|
||||
|
||||
try
|
||||
{
|
||||
FWObjectDatabase *ndb = new FWObjectDatabase();
|
||||
ndb->load(libfpath, &upgrade_predicate, librespath);
|
||||
|
||||
FWObject *dobj = ndb->findInIndex(FWObjectDatabase::DELETED_OBJECTS_ID);
|
||||
if (dobj) ndb->remove(dobj, false);
|
||||
|
||||
#if 0
|
||||
list<FWObject*> newLibs;
|
||||
newLibs= ndb->getByType(Library::TYPENAME);
|
||||
|
||||
list<FWObject*> currentLibs;
|
||||
currentLibs= db()->getByType(Library::TYPENAME);
|
||||
|
||||
list<FWObject*> duplicateLibs;
|
||||
|
||||
for (list<FWObject*>::iterator i=newLibs.begin(); i!=newLibs.end(); i++)
|
||||
{
|
||||
string newLibID = (*i)->getId();
|
||||
if (newLibID==STANDARD_LIB)
|
||||
{
|
||||
duplicateLibs.push_back(*i);
|
||||
continue;
|
||||
}
|
||||
QString name = (*i)->getName().c_str();
|
||||
if (std::find_if(currentLibs.begin(),currentLibs.end(),
|
||||
findFWObjectIDPredicate(newLibID))!=currentLibs.end() )
|
||||
{
|
||||
QMessageBox::warning(
|
||||
NULL,"Firewall Builder",
|
||||
QObject::tr("Duplicate library '%1'").arg(QString::fromUtf8(name)),
|
||||
QObject::tr("&Continue"), QString::null,QString::null,
|
||||
0, 1 );
|
||||
duplicateLibs.push_back(*i);
|
||||
}
|
||||
}
|
||||
|
||||
if (!duplicateLibs.empty())
|
||||
{
|
||||
for (list<FWObject*>::iterator i=duplicateLibs.begin(); i!=duplicateLibs.end(); i++)
|
||||
ndb->remove(*i,false);
|
||||
}
|
||||
#endif
|
||||
MergeConflictRes mcr(this);
|
||||
db()->merge(ndb, &mcr);
|
||||
|
||||
delete ndb;
|
||||
|
||||
} catch(FWException &ex)
|
||||
{
|
||||
QMessageBox::warning(
|
||||
this,"Firewall Builder",
|
||||
tr("The program encountered error trying to load file %1.\n"
|
||||
"The file has not been loaded. Error:\n%2").
|
||||
arg(libfpath.c_str()).arg(ex.toString().c_str()),
|
||||
tr("&Continue"), QString::null,QString::null,
|
||||
0, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Load standard library objects
|
||||
*/
|
||||
void ProjectPanel::load(QWidget*)
|
||||
{
|
||||
if (fwbdebug) qDebug("ProjectPanel::load(): start");
|
||||
|
||||
QStatusBar *sb = mainW->statusBar();
|
||||
|
||||
editingStandardLib = false;
|
||||
editingTemplateLib = false;
|
||||
|
||||
MessageBoxUpgradePredicate upgrade_predicate(mainW);
|
||||
|
||||
resetFD();
|
||||
|
||||
try
|
||||
{
|
||||
// need to drop read-only flag on the database before I load new objects
|
||||
|
||||
objdb = new FWObjectDatabase();
|
||||
objdb->setReadOnly( false );
|
||||
|
||||
sb->showMessage( tr("Loading system objects...") );
|
||||
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents,100);
|
||||
|
||||
// always load system objects
|
||||
if (fwbdebug)
|
||||
qDebug("ProjectPanel::load(): sysfname = %s", sysfname.c_str());
|
||||
|
||||
objdb->load( sysfname, &upgrade_predicate, librespath);
|
||||
objdb->setFileName("");
|
||||
|
||||
if (fwbdebug) qDebug("ProjectPanel::load(): create User library");
|
||||
|
||||
FWObject *userLib = createNewLibrary( objdb );
|
||||
userLib->setName("User");
|
||||
userLib->setStr("color","#d2ffd0");
|
||||
|
||||
objdb->setDirty(false);
|
||||
objdb->setFileName("");
|
||||
|
||||
createRCS("");
|
||||
|
||||
setWindowTitle( "Firewall Builder" );
|
||||
|
||||
mainW->fileSaveActionSetEn( false );
|
||||
mainW->addToRCSActionSetEn( false );
|
||||
mainW->fileDiscardActionSetEn( false );
|
||||
mainW->fileCommitActionSetEn( false );
|
||||
|
||||
loadObjects();
|
||||
setupAutoSave();
|
||||
|
||||
if (fwbdebug) qDebug("ProjectPanel::load(): done");
|
||||
|
||||
} catch(FWException &ex)
|
||||
{
|
||||
QMessageBox::warning(
|
||||
this,"Firewall Builder",
|
||||
tr("Error loading file:\n%1").arg(ex.toString().c_str()),
|
||||
tr("&Continue"), QString::null,QString::null,
|
||||
0, 1 );
|
||||
}
|
||||
|
||||
sb->clearMessage();
|
||||
}
|
||||
|
||||
/*
|
||||
* Load user data file referenced by the RCS object
|
||||
*/
|
||||
void ProjectPanel::load(QWidget*,
|
||||
RCS* _rcs,
|
||||
FWObjectDatabase* clone)
|
||||
{
|
||||
QStatusBar *sb = mainW->statusBar();
|
||||
|
||||
resetFD();
|
||||
|
||||
editingStandardLib = false;
|
||||
editingTemplateLib = false;
|
||||
|
||||
// use this flag to force 'save' operation if file should be renamed
|
||||
bool forceSave=false;
|
||||
|
||||
MessageBoxUpgradePredicate upgrade_predicate(mainW);
|
||||
|
||||
assert(_rcs!=NULL);
|
||||
|
||||
rcs = _rcs;
|
||||
|
||||
try
|
||||
{
|
||||
systemFile=false;
|
||||
objdb = clone;
|
||||
sb->showMessage( tr("Loading system objects...") );
|
||||
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
|
||||
sb->showMessage( tr("Reading and parsing data file...") );
|
||||
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
|
||||
sb->clearMessage();
|
||||
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
|
||||
|
||||
/* loadingLib is true if user wants to open a library or master library file
|
||||
bool loadingLib = editingLibrary();
|
||||
*/
|
||||
|
||||
sb->showMessage( tr("Merging with system objects...") );
|
||||
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents,100);
|
||||
|
||||
MergeConflictRes mcr(mainW);
|
||||
|
||||
sb->clearMessage();
|
||||
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents,100);
|
||||
|
||||
/*
|
||||
* TODO: we should create new FWObjectDatabase object and assign db
|
||||
* instead of using singleton
|
||||
*/
|
||||
// objdb = FWObjectDatabase::db;
|
||||
|
||||
if (fwbdebug)
|
||||
{
|
||||
qDebug("* Merge is done");
|
||||
list<FWObject*> ll = db()->getByType(Library::TYPENAME);
|
||||
for (FWObject::iterator i=ll.begin(); i!=ll.end(); i++)
|
||||
{
|
||||
qDebug("* Library %s %s in the data file",
|
||||
FWObjectDatabase::getStringId((*i)->getId()).c_str(),
|
||||
(*i)->getName().c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* this is a hack: 'Standard' library should be read-only. I have too
|
||||
* many files I already converted to the new API/DTD and I am too lazy
|
||||
* to convert them again, so I patch it up here.
|
||||
*
|
||||
* However, if I am editing standard library, it should not be read-only.
|
||||
*/
|
||||
FWObject *slib = objdb->findInIndex(FWObjectDatabase::STANDARD_LIB_ID);
|
||||
if (slib!=NULL )
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug("standard library read-only status: %d, "
|
||||
"editingStandardLib: %d",
|
||||
slib->isReadOnly(), editingStandardLib);
|
||||
|
||||
slib->setReadOnly(! editingStandardLib);
|
||||
}
|
||||
|
||||
/* if the file name has an old extension .xml, change it to .fwb and
|
||||
* warn the user
|
||||
*/
|
||||
QString fn = rcs->getFileName();
|
||||
QFileInfo ofinfo(fn);
|
||||
|
||||
if ( ofinfo.suffix()=="xml")
|
||||
{
|
||||
if (fwbdebug)
|
||||
{
|
||||
qDebug("Need to rename file: %s",fn.toAscii().constData());
|
||||
qDebug(" dirPath: %s",ofinfo.dir().absolutePath().toAscii().constData());
|
||||
qDebug(" filePath: %s",ofinfo.absoluteFilePath().toAscii().constData());
|
||||
}
|
||||
QString nfn=ofinfo.dir().absolutePath() + "/" + ofinfo.completeBaseName() + ".fwb";
|
||||
|
||||
bool needToRename = true;
|
||||
|
||||
/* need these dances with symlinks to fix bug #1008956: "Existing .fwb
|
||||
* file gets overwritten if has wrong extension"
|
||||
*/
|
||||
QFileInfo nfinfo(nfn);
|
||||
if (nfinfo.exists() && ofinfo.isSymLink() && ofinfo.readLink()==nfn)
|
||||
{
|
||||
// .xml file is a symlink pointing at .fwb file
|
||||
// no need to rename
|
||||
needToRename = false;
|
||||
}
|
||||
|
||||
if (needToRename)
|
||||
{
|
||||
if (nfinfo.exists())
|
||||
{
|
||||
/* .fwb file exists but .xml is not a symlink
|
||||
* .fwb is a separate file with the same name.
|
||||
*
|
||||
* tell the user we need to rename old file but the new file exists,
|
||||
* then ask them to choose a new name. If the user chooses the same
|
||||
* name and agrees to overwrite the file, just use this name. If the
|
||||
* user hits cancel, tell them they need to choose a new name and open
|
||||
* "file save" dialog again.
|
||||
*
|
||||
* Show the first dialog only once. If user hits Cancel, they see
|
||||
* shorted version of the dialog and will be presented with "save
|
||||
* file" dialog again.
|
||||
*/
|
||||
QMessageBox::warning(
|
||||
this,"Firewall Builder",
|
||||
tr("Firewall Builder 2 uses file extension '.fwb' and \nneeds to rename old data file '%1' to '%2',\nbut file '%3' already exists.\nChoose a different name for the new file.")
|
||||
.arg(fn).arg(nfn).arg(nfn),
|
||||
tr("&Continue"), QString::null,QString::null,
|
||||
0, 1 );
|
||||
|
||||
nfn=chooseNewFileName(fn,true,
|
||||
tr("Choose name and location for the new file"));
|
||||
if (nfn.isEmpty())
|
||||
{
|
||||
QString oldFileName = ofinfo.absoluteFilePath() + ".bak";
|
||||
rename(oldFileName.toLatin1().constData(), fn.toLatin1().constData());
|
||||
|
||||
QMessageBox::warning(
|
||||
this,"Firewall Builder",
|
||||
tr("Load operation cancelled and data file reverted to original version."),
|
||||
tr("&Continue"), QString::null,QString::null,
|
||||
0, 1 );
|
||||
|
||||
load(this);
|
||||
return;
|
||||
}
|
||||
nfinfo.setFile(nfn);
|
||||
}
|
||||
|
||||
rename(fn.toLatin1().constData(), nfn.toLatin1().constData());
|
||||
|
||||
|
||||
QMessageBox::warning(
|
||||
this,"Firewall Builder",
|
||||
tr("Firewall Builder 2 uses file extension '.fwb'. Your data file '%1' \nhas been renamed '%2'")
|
||||
.arg(fn).arg(nfn),
|
||||
tr("&Continue"), QString::null,QString::null,
|
||||
0, 1 );
|
||||
|
||||
}
|
||||
|
||||
fn = nfn;
|
||||
}
|
||||
|
||||
rcs->setFileName(fn);
|
||||
db()->setFileName(fn.toLatin1().constData());
|
||||
|
||||
QString caption = rcs->getFileName().section("/",-1,-1);
|
||||
if (rcs->isInRCS()) caption = caption + ", rev " + rcs->getSelectedRev();
|
||||
if (rcs->isRO()) caption = caption + " " + tr("(read-only)");
|
||||
|
||||
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());
|
||||
|
||||
} catch(FWException &ex)
|
||||
{
|
||||
string trans = ex.getProperties()["failed_transformation"];
|
||||
string elem = ex.getProperties()["failed_element"];
|
||||
|
||||
if(!trans.empty() || !elem.empty())
|
||||
{
|
||||
QString msg = tr("Exception: %1").arg(ex.toString().c_str());
|
||||
if (!trans.empty())
|
||||
msg+="\n"+tr("Failed transformation : %1").arg(trans.c_str());
|
||||
if (!elem.empty())
|
||||
msg+="\n"+tr("XML element : %1").arg(elem.c_str());
|
||||
|
||||
QMessageBox::warning(
|
||||
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
|
||||
QMessageBox::warning(
|
||||
this,"Firewall Builder",
|
||||
tr("The program encountered error trying to load data file.\n"
|
||||
"The file has not been loaded. Error:\n%1").arg(
|
||||
ex.toString().c_str()),
|
||||
tr("&Continue"), QString::null,QString::null,
|
||||
0, 1 );
|
||||
|
||||
load(this);
|
||||
return;
|
||||
}
|
||||
|
||||
db()->setReadOnly( rcs->isRO() || rcs->isTemp() );
|
||||
|
||||
// clear dirty flag for all objects, recursively
|
||||
if (!forceSave) db()->setDirty(false);
|
||||
|
||||
sb->showMessage( tr("Building object tree...") );
|
||||
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents, 100);
|
||||
|
||||
loadObjects();
|
||||
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents, 100);
|
||||
|
||||
sb->showMessage( tr("Indexing...") );
|
||||
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents, 100);
|
||||
db()->reIndex();
|
||||
|
||||
sb->clearMessage();
|
||||
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents, 100);
|
||||
|
||||
setupAutoSave();
|
||||
loadLastOpenedLib();
|
||||
}
|
||||
|
||||
|
||||
void ProjectPanel::load(QWidget*, RCS *_rcs)
|
||||
{
|
||||
QStatusBar *sb = mainW->statusBar();
|
||||
|
||||
resetFD();
|
||||
|
||||
editingStandardLib = false;
|
||||
editingTemplateLib = false;
|
||||
|
||||
bool forceSave=false; // use this flag to force 'save' operation if file should be renamed
|
||||
|
||||
MessageBoxUpgradePredicate upgrade_predicate(mainW);
|
||||
|
||||
assert(_rcs!=NULL);
|
||||
|
||||
rcs = _rcs;
|
||||
try
|
||||
{
|
||||
/* load the data file */
|
||||
systemFile=false;
|
||||
|
||||
objdb = new FWObjectDatabase();
|
||||
|
||||
// need to drop read-only flag on the database before I load new objects
|
||||
objdb->setReadOnly( false );
|
||||
|
||||
// always loading system objects
|
||||
sb->showMessage( tr("Loading system objects...") );
|
||||
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
|
||||
|
||||
objdb->load( sysfname, &upgrade_predicate, librespath);
|
||||
objdb->setFileName("");
|
||||
|
||||
// objects from a data file are in database ndb
|
||||
|
||||
sb->showMessage( tr("Reading and parsing data file...") );
|
||||
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
|
||||
|
||||
FWObjectDatabase *ndb = new FWObjectDatabase();
|
||||
ndb->load(rcs->getFileName().toLatin1().constData(),
|
||||
&upgrade_predicate,librespath);
|
||||
time_t oldtimestamp = ndb->getTimeLastModified();
|
||||
|
||||
sb->clearMessage();
|
||||
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
|
||||
|
||||
/* loadingLib is true if user wants to open a library or master library file */
|
||||
bool loadingLib = editingLibrary();
|
||||
|
||||
if (fwbdebug)
|
||||
{
|
||||
list<FWObject*> ll = ndb->getByType(Library::TYPENAME);
|
||||
for (FWObject::iterator i=ll.begin(); i!=ll.end(); i++)
|
||||
{
|
||||
qDebug("* Found library %s %s in the data file",
|
||||
FWObjectDatabase::getStringId((*i)->getId()).c_str(),
|
||||
(*i)->getName().c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
/* if user opens library file, clear read-only flag so they can edit it */
|
||||
if (loadingLib)
|
||||
{
|
||||
list<FWObject*> ll = ndb->getByType(Library::TYPENAME);
|
||||
for (FWObject::iterator i=ll.begin(); i!=ll.end(); i++)
|
||||
{
|
||||
if ((*i)->getId()==FWObjectDatabase::STANDARD_LIB_ID)
|
||||
editingStandardLib=true;
|
||||
if ((*i)->getId()==FWObjectDatabase::TEMPLATE_LIB_ID)
|
||||
editingTemplateLib=true;
|
||||
(*i)->setReadOnly( false );
|
||||
}
|
||||
}
|
||||
|
||||
sb->showMessage( tr("Merging with system objects...") );
|
||||
QCoreApplication::processEvents(
|
||||
QEventLoop::ExcludeUserInputEvents, 100);
|
||||
|
||||
MergeConflictRes mcr(mainW);
|
||||
objdb->merge(ndb, &mcr);
|
||||
|
||||
delete ndb;
|
||||
|
||||
objdb->setFileName(rcs->getFileName().toLatin1().constData());
|
||||
objdb->resetTimeLastModified(oldtimestamp);
|
||||
objdb->setDirty(false);
|
||||
|
||||
sb->clearMessage();
|
||||
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents,100);
|
||||
|
||||
if (fwbdebug)
|
||||
{
|
||||
qDebug("* Merge is done");
|
||||
list<FWObject*> ll = db()->getByType(Library::TYPENAME);
|
||||
for (FWObject::iterator i=ll.begin(); i!=ll.end(); i++)
|
||||
{
|
||||
qDebug("* Library %s %s in the data file",
|
||||
FWObjectDatabase::getStringId((*i)->getId()).c_str(),
|
||||
(*i)->getName().c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* this is a hack: 'Standard' library should be read-only. I
|
||||
* have too many files I already converted to the new API/DTD
|
||||
* and I am too lazy to convert them again, so I patch it up
|
||||
* here.
|
||||
*
|
||||
* However, if I am editing standard library, it should not be
|
||||
* read-only.
|
||||
*/
|
||||
FWObject *slib = objdb->findInIndex(FWObjectDatabase::STANDARD_LIB_ID);
|
||||
if (slib!=NULL )
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug("standard library read-only status: %d, "
|
||||
"editingStandardLib: %d",
|
||||
slib->isReadOnly(), editingStandardLib);
|
||||
|
||||
slib->setReadOnly(! editingStandardLib);
|
||||
}
|
||||
|
||||
/* if the file name has an old extension .xml, change it to .fwb and
|
||||
* warn the user
|
||||
*/
|
||||
QString fn = rcs->getFileName();
|
||||
QFileInfo ofinfo(fn);
|
||||
|
||||
if ( ofinfo.suffix()=="xml")
|
||||
{
|
||||
if (fwbdebug)
|
||||
{
|
||||
qDebug("Need to rename file: %s",
|
||||
fn.toAscii().constData());
|
||||
qDebug(" dirPath: %s",
|
||||
ofinfo.dir().absolutePath().toAscii().constData());
|
||||
qDebug(" filePath: %s",
|
||||
ofinfo.absoluteFilePath().toAscii().constData());
|
||||
}
|
||||
QString nfn = ofinfo.dir().absolutePath()
|
||||
+ "/" + ofinfo.completeBaseName() + ".fwb";
|
||||
|
||||
bool needToRename = true;
|
||||
|
||||
/* need these dances with symlinks to fix bug #1008956:
|
||||
* "Existing .fwb file gets overwritten if has wrong
|
||||
* extension"
|
||||
*/
|
||||
QFileInfo nfinfo(nfn);
|
||||
if (nfinfo.exists() && ofinfo.isSymLink() && ofinfo.readLink()==nfn)
|
||||
{
|
||||
// .xml file is a symlink pointing at .fwb file
|
||||
// no need to rename
|
||||
needToRename = false;
|
||||
}
|
||||
|
||||
if (needToRename)
|
||||
{
|
||||
if (nfinfo.exists())
|
||||
{
|
||||
/* .fwb file exists but .xml is not a symlink
|
||||
* .fwb is a separate file with the same name.
|
||||
*
|
||||
* tell the user we need to rename old file but
|
||||
* the new file exists, then ask them to choose a
|
||||
* new name. If the user chooses the same name and
|
||||
* agrees to overwrite the file, just use this
|
||||
* name. If the user hits cancel, tell them they
|
||||
* need to choose a new name and open "file save"
|
||||
* dialog again.
|
||||
*
|
||||
* Show the first dialog only once. If user hits
|
||||
* Cancel, they see shorted version of the dialog
|
||||
* and will be presented with "save file" dialog
|
||||
* again.
|
||||
*/
|
||||
QMessageBox::warning(
|
||||
this,"Firewall Builder",
|
||||
tr("Firewall Builder 2 uses file extension '.fwb' and\n"
|
||||
"needs to rename old data file '%1' to '%2',\n"
|
||||
"but file '%3' already exists.\n"
|
||||
"Choose a different name for the new file.")
|
||||
.arg(fn).arg(nfn).arg(nfn),
|
||||
tr("&Continue"), QString::null,QString::null,
|
||||
0, 1 );
|
||||
|
||||
nfn = chooseNewFileName(
|
||||
fn,true,
|
||||
tr("Choose name and location for the new file"));
|
||||
if (nfn.isEmpty())
|
||||
{
|
||||
QString oldFileName = ofinfo.absoluteFilePath()
|
||||
+ ".bak";
|
||||
rename(oldFileName.toLatin1().constData(),
|
||||
fn.toLatin1().constData());
|
||||
|
||||
QMessageBox::warning(
|
||||
this,"Firewall Builder",
|
||||
tr("Load operation cancelled and data file reverted"
|
||||
"to original version."),
|
||||
tr("&Continue"), QString::null,QString::null,
|
||||
0, 1 );
|
||||
|
||||
load(this);
|
||||
return;
|
||||
}
|
||||
nfinfo.setFile(nfn);
|
||||
}
|
||||
|
||||
rename(fn.toLatin1().constData(), nfn.toLatin1().constData());
|
||||
|
||||
QMessageBox::warning(
|
||||
this,"Firewall Builder",
|
||||
tr("Firewall Builder 2 uses file extension '.fwb'. Your data"
|
||||
"file '%1' \nhas been renamed '%2'")
|
||||
.arg(fn).arg(nfn),
|
||||
tr("&Continue"), QString::null,QString::null,
|
||||
0, 1 );
|
||||
}
|
||||
|
||||
fn = nfn;
|
||||
}
|
||||
|
||||
rcs->setFileName(fn);
|
||||
db()->setFileName(fn.toLatin1().constData());
|
||||
|
||||
QString caption = rcs->getFileName().section("/",-1,-1);
|
||||
if (rcs->isInRCS()) caption = caption
|
||||
+ ", rev " + rcs->getSelectedRev();
|
||||
if (rcs->isRO()) caption = caption + " " + tr("(read-only)");
|
||||
|
||||
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());
|
||||
|
||||
} catch(FWException &ex)
|
||||
{
|
||||
string trans = ex.getProperties()["failed_transformation"];
|
||||
string elem = ex.getProperties()["failed_element"];
|
||||
|
||||
if(!trans.empty() || !elem.empty())
|
||||
{
|
||||
QString msg = tr("Exception: %1").arg(ex.toString().c_str());
|
||||
if (!trans.empty())
|
||||
msg+="\n"+tr("Failed transformation : %1").arg(trans.c_str());
|
||||
if (!elem.empty())
|
||||
msg+="\n"+tr("XML element : %1").arg(elem.c_str());
|
||||
|
||||
QMessageBox::warning(
|
||||
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
|
||||
QMessageBox::warning(
|
||||
this,"Firewall Builder",
|
||||
tr("The program encountered error trying to load data file.\n"
|
||||
"The file has not been loaded. Error:\n%1").arg(
|
||||
ex.toString().c_str()),
|
||||
tr("&Continue"), QString::null,QString::null,
|
||||
0, 1 );
|
||||
// load standard objects so the window does not remain empty
|
||||
load(this);
|
||||
return;
|
||||
}
|
||||
|
||||
db()->setReadOnly( rcs->isRO() || rcs->isTemp() );
|
||||
|
||||
// clear dirty flag for all objects, recursively
|
||||
if (!forceSave) db()->setDirty(false);
|
||||
|
||||
sb->showMessage( tr("Building object tree...") );
|
||||
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents, 100);
|
||||
|
||||
loadObjects();
|
||||
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents, 100);
|
||||
|
||||
sb->showMessage( tr("Indexing...") );
|
||||
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents, 100);
|
||||
db()->reIndex();
|
||||
|
||||
sb->clearMessage();
|
||||
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents, 100);
|
||||
|
||||
setupAutoSave();
|
||||
loadLastOpenedLib();
|
||||
}
|
||||
|
||||
bool ProjectPanel::checkin(bool unlock)
|
||||
{
|
||||
/* doing checkin only if we did checkout so rcs!=NULL */
|
||||
QString rlog="";
|
||||
|
||||
if (systemFile || rcs==NULL || !rcs->isCheckedOut() || rcs->isTemp())
|
||||
return true;
|
||||
|
||||
if (rcs->isDiff())
|
||||
{
|
||||
// if the file hasn't changed, do not need to ask for the comment
|
||||
if ( ! st->getRCSLogState())
|
||||
{
|
||||
RCSFileSaveDialog_q fsd;
|
||||
QDialog *fsd_dialog = new QDialog(this);
|
||||
fsd.setupUi(fsd_dialog);
|
||||
fsd.checkinDialogTitle->setText(
|
||||
QString("<b>")+tr("Checking file %1 in RCS").arg(rcs->getFileName())+QString("</b>")
|
||||
);
|
||||
if ( fsd_dialog->exec()== QDialog::Rejected )
|
||||
{
|
||||
delete fsd_dialog;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool empty_rcslog = fsd.nolog->isChecked();
|
||||
if (empty_rcslog)
|
||||
{
|
||||
rlog = "";
|
||||
st->setRCSLogState(true);
|
||||
} else
|
||||
rlog = fsd.rcslog->toPlainText();
|
||||
|
||||
delete fsd_dialog;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
try
|
||||
{
|
||||
if (fwbdebug) qDebug("about to check the file in");
|
||||
rcs->ci(rlog,unlock);
|
||||
if (fwbdebug) qDebug("done");
|
||||
}
|
||||
catch (FWException &ex)
|
||||
{
|
||||
QMessageBox::warning(
|
||||
this,"Firewall Builder",
|
||||
tr("Error checking in file %1:\n%2")
|
||||
.arg(rcs->getFileName()).arg(ex.toString().c_str()),
|
||||
tr("&Continue"), QString::null, QString::null,
|
||||
0, 1 );
|
||||
}
|
||||
/***********************************************************************/
|
||||
return true;
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
if (!rcs->isRO() && !rcs->isTemp())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (rcs->getFileName().isEmpty())
|
||||
fileSaveAs(); // eventually calls this method again
|
||||
else
|
||||
{
|
||||
/* editingLibfile is true if user edits a library or master library file */
|
||||
bool editingLibfile=editingLibrary();
|
||||
|
||||
if (st->getDontSaveStdLib()) // this is now default
|
||||
{
|
||||
list<FWObject*> userLibs;
|
||||
list<FWObject*> ll = db()->getByType(Library::TYPENAME);
|
||||
for (FWObject::iterator i=ll.begin(); i!=ll.end(); i++)
|
||||
{
|
||||
if (fwbdebug) qDebug("ProjectPanel::save() lib %s",
|
||||
(*i)->getName().c_str() );
|
||||
|
||||
/* skip standard and template libraries unless we edit them */
|
||||
int id = (*i)->getId();
|
||||
if (id==FWObjectDatabase::STANDARD_LIB_ID &&
|
||||
!editingStandardLib) continue;
|
||||
if (id==FWObjectDatabase::TEMPLATE_LIB_ID &&
|
||||
!editingTemplateLib) continue;
|
||||
|
||||
if (fwbdebug) qDebug(" add");
|
||||
userLibs.push_back( *i );
|
||||
}
|
||||
|
||||
QApplication::setOverrideCursor(QCursor( Qt::WaitCursor));
|
||||
|
||||
FWObjectDatabase *ndb = db()->exportSubtree(userLibs);
|
||||
|
||||
if (editingLibfile)
|
||||
{
|
||||
/* exported libraries are always read-only */
|
||||
list<FWObject*> 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 );
|
||||
}
|
||||
|
||||
ndb->resetTimeLastModified( db()->getTimeLastModified() );
|
||||
ndb->saveFile( rcs->getFileName().toLatin1().constData() );
|
||||
|
||||
delete ndb;
|
||||
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
} else
|
||||
{
|
||||
QApplication::setOverrideCursor(QCursor( Qt::WaitCursor));
|
||||
db()->saveFile( rcs->getFileName().toLatin1().constData() );
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
}
|
||||
db()->setDirty(false);
|
||||
}
|
||||
catch (FWException &ex)
|
||||
{
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
/* error saving the file. Since XMLTools does not return any useful
|
||||
* 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();
|
||||
|
||||
QMessageBox::warning(
|
||||
this,"Firewall Builder",
|
||||
tr("Error saving file %1: %2")
|
||||
.arg(rcs->getFileName()).arg(err),
|
||||
tr("&Continue"), QString::null, QString::null,
|
||||
0, 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
213
src/gui/ProjectPanel_state_ops.cpp
Normal file
213
src/gui/ProjectPanel_state_ops.cpp
Normal file
@ -0,0 +1,213 @@
|
||||
/*
|
||||
|
||||
Firewall Builder
|
||||
|
||||
Copyright (C) 2008 NetCitadel, LLC
|
||||
|
||||
Author: alek@codeminders.com
|
||||
refactoring and bugfixes: vadim@fwbuilder.org
|
||||
|
||||
$Id: ProjectPanel.cpp 417 2008-07-26 06:55:44Z 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
|
||||
|
||||
*/
|
||||
|
||||
#include "../../config.h"
|
||||
#include "global.h"
|
||||
#include "utils.h"
|
||||
#include "utils_no_qt.h"
|
||||
|
||||
#include "ProjectPanel.h"
|
||||
#include "FWBSettings.h"
|
||||
#include "RCS.h"
|
||||
|
||||
#include <QMdiSubWindow>
|
||||
#include <QMdiArea>
|
||||
|
||||
|
||||
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).
|
||||
void ProjectPanel::stateChanged(Qt::WindowStates oldState,
|
||||
Qt::WindowStates newState)
|
||||
{
|
||||
bool is_maximized = ((newState & Qt::WindowMaximized) != 0);
|
||||
bool was_maximized = ((oldState & Qt::WindowMaximized) != 0);
|
||||
// bool is_active = ((newState & Qt::WindowActive) != 0);
|
||||
#if 0
|
||||
if (fwbdebug)
|
||||
qDebug("ProjectPanel::stateChanged "
|
||||
"newState=%d was_maximized=%d is_maximized=%d is_active=%d",
|
||||
int(newState), was_maximized, is_maximized, is_active);
|
||||
#endif
|
||||
st->setInt("Window/maximized", is_maximized);
|
||||
if (!was_maximized && is_maximized) saveState();
|
||||
// restore size only if state of the window changes from "maximized"
|
||||
// to "normal" for the first time. After this, MDI keeps track of
|
||||
// window size automatically.
|
||||
//if (was_maximized && !is_maximized && firstTimeNormal) loadState();
|
||||
firstTimeNormal = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ProjectPanel::saveState()
|
||||
{
|
||||
QString FileName ;
|
||||
if (rcs!=NULL)
|
||||
{
|
||||
FileName = rcs->getFileName();
|
||||
}
|
||||
|
||||
if (fwbdebug)
|
||||
qDebug("ProjectPanel::saveState FileName=%s ready=%d",
|
||||
FileName.toAscii().data(), ready);
|
||||
|
||||
if (!ready) return;
|
||||
|
||||
if (mdiWindow->isMaximized())
|
||||
{
|
||||
if (fwbdebug) qDebug ("Window/maximized true");
|
||||
st->setInt("Window/maximized", 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fwbdebug) qDebug ("Window/maximized false");
|
||||
st->setInt("Window/maximized", 0);
|
||||
}
|
||||
|
||||
if (!mdiWindow->isMaximized())
|
||||
{
|
||||
st->setInt("Window/" + FileName + "/x", mdiWindow->x());
|
||||
st->setInt("Window/" + FileName + "/y", mdiWindow->y());
|
||||
st->setInt("Window/" + FileName + "/width", mdiWindow->width ());
|
||||
st->setInt("Window/" + FileName + "/height", mdiWindow->height ());
|
||||
}
|
||||
|
||||
// Save position of splitters regardless of the window state
|
||||
QList<int> sl = m_panel->mainSplitter->sizes();
|
||||
QString arg = QString("%1,%2").arg(sl[0]).arg(sl[1]);
|
||||
if (sl[0] || sl[1])
|
||||
st->setStr("Window/" + FileName + "/MainWindowSplitter", arg );
|
||||
|
||||
if (fwbdebug)
|
||||
{
|
||||
QString out1 = " save Window/" + FileName + "/MainWindowSplitter";
|
||||
out1+= " " + arg;
|
||||
qDebug(out1.toAscii().data());
|
||||
}
|
||||
|
||||
sl = m_panel->objInfoSplitter->sizes();
|
||||
arg = QString("%1,%2").arg(sl[0]).arg(sl[1]);
|
||||
if (sl[0] || sl[1])
|
||||
st->setStr("Window/" + FileName + "/ObjInfoSplitter", arg );
|
||||
}
|
||||
|
||||
void ProjectPanel::loadState()
|
||||
{
|
||||
int w1 = 0;
|
||||
int w2 = 0;
|
||||
QString w1s, w2s;
|
||||
bool ok = false;
|
||||
|
||||
if (rcs==NULL) return;
|
||||
QString filename = rcs->getFileName();
|
||||
|
||||
if (fwbdebug)
|
||||
{
|
||||
qDebug("ProjectPanel::loadState filename=%s isMaximized=%d",
|
||||
filename.toAscii().data(), isMaximized());
|
||||
qDebug("mdiWindow=%p", mdiWindow);
|
||||
qDebug("ready=%d", ready);
|
||||
}
|
||||
|
||||
if (!ready) return;
|
||||
|
||||
int maximized_status = st->getInt("Window/maximized");
|
||||
if (!maximized_status && mdiWindow)
|
||||
{
|
||||
if (fwbdebug) qDebug("ProjectPanel::loadState show normal");
|
||||
setWindowState(0);
|
||||
int x = st->getInt("Window/"+filename+"/x");
|
||||
int y = st->getInt("Window/"+filename+"/y");
|
||||
int width = st->getInt("Window/"+filename+"/width");
|
||||
int height = st->getInt("Window/"+filename+"/height");
|
||||
if (width==0 || height==0)
|
||||
{
|
||||
x = 10;
|
||||
y = 10;
|
||||
width = 600;
|
||||
height= 600;
|
||||
}
|
||||
if (fwbdebug)
|
||||
qDebug("ProjectPanel::loadState set geometry: %d %d %d %d",
|
||||
x,y,width,height);
|
||||
|
||||
mdiWindow->setGeometry(x,y,width,height);
|
||||
}
|
||||
|
||||
QString h_splitter_setting = "Window/" + filename + "/MainWindowSplitter";
|
||||
QString val = st->getStr(h_splitter_setting);
|
||||
|
||||
w1s = val.split(',')[0];
|
||||
ok = false;
|
||||
w1 = w1s.toInt(&ok, 10);
|
||||
if (!ok || w1 == 0) w1 = DEFAULT_H_SPLITTER_POSITION;
|
||||
|
||||
w2 = mdiWindow->width() - w1;
|
||||
|
||||
if (fwbdebug)
|
||||
qDebug(QString("%1: %2x%3").arg(h_splitter_setting).
|
||||
arg(w1).arg(w2).toAscii().data());
|
||||
|
||||
QList<int> sl;
|
||||
sl.push_back(w1);
|
||||
sl.push_back(w2);
|
||||
if (w1 && w2)
|
||||
m_panel->mainSplitter->setSizes( sl );
|
||||
|
||||
if (fwbdebug) qDebug("Restore info window splitter position");
|
||||
|
||||
QString v_splitter_setting = "Window/" + filename + "/ObjInfoSplitter";
|
||||
val = st->getStr(v_splitter_setting);
|
||||
|
||||
w1s = val.split(',')[0];
|
||||
ok = false;
|
||||
w1 = w1s.toInt(&ok, 10);
|
||||
if (!ok || w1 == 0) w1 = DEFAULT_V_SPLITTER_POSITION;
|
||||
w2 = mdiWindow->height() - w1;
|
||||
|
||||
if (fwbdebug)
|
||||
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 );
|
||||
|
||||
|
||||
if (fwbdebug) qDebug("ProjectPanel::loadState done");
|
||||
}
|
||||
|
||||
|
||||
@ -132,6 +132,8 @@ HEADERS += ../../config.h \
|
||||
RuleRowInfo.h
|
||||
|
||||
SOURCES += ProjectPanel.cpp \
|
||||
ProjectPanel_file_ops.cpp \
|
||||
ProjectPanel_state_ops.cpp \
|
||||
FWWindow.cpp \
|
||||
main.cpp \
|
||||
utils.cpp \
|
||||
|
||||
@ -40,20 +40,6 @@ class MessageBoxUpgradePredicate: public libfwbuilder::XMLTools::UpgradePredicat
|
||||
|
||||
virtual bool operator()(const std::string&) const
|
||||
{
|
||||
/*return QMessageBox::information( parent , "Firewall Builder",
|
||||
QObject::tr(
|
||||
"The data file you are trying to open has been \
|
||||
saved with an older version of Firewall Builder. \
|
||||
Opening it in this version will cause it to be \
|
||||
upgraded, which may prevent older versions of \
|
||||
the program from reading it. Backup copy of your \
|
||||
file in the old format will be made in the same \
|
||||
directory with extension '.bak'.\n\
|
||||
Are you sure you want to open it?"),
|
||||
QObject::tr("&Upgrade"),
|
||||
QObject::tr("&Do not load the file"),
|
||||
QString::null,
|
||||
0, 1 )==0;*/
|
||||
return QMessageBox::information( parent , "Firewall Builder",
|
||||
QObject::tr(
|
||||
"The data file you are trying to open has been \
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user