mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-09-16 01:49:23 +02:00
bugs 2091225 2099631
This commit is contained in:
@@ -1,3 +1,15 @@
|
||||
2008-09-09 Vadim Kurland <vadim@vk.crocodile.org>
|
||||
|
||||
* FWBSettings.cpp (FWBSettings::setExpandedObjectIds): bug
|
||||
#2091225: "Can objects in the left pane remember last state.". The
|
||||
program saves state of the object tree branches (expanded or
|
||||
collapsed) between sessions.
|
||||
|
||||
* FWBSettings.cpp (FWBSettings::getVisibleRuleSetId): bug #2099631
|
||||
"GUI should rememver firewall object that was opened last". The
|
||||
program remembers opened ruleset between sessions.
|
||||
|
||||
|
||||
2008-09-08 Vadim Kurland <vadim@vk.crocodile.org>
|
||||
|
||||
* fwbedit.cpp (usage): fixed "usage" in fwbedit, command line
|
||||
|
||||
@@ -90,6 +90,7 @@ const char* groupModeSetpath = SETTINGS_PATH_PREFIX "/UI/GroupViewMode";
|
||||
const char* groupColsSetpath = SETTINGS_PATH_PREFIX "/UI/GroupViewColumns";
|
||||
const char* objTooltips = SETTINGS_PATH_PREFIX "/UI/objTooltips";
|
||||
const char* tooltipDelay = SETTINGS_PATH_PREFIX "/UI/tooltipDelay";
|
||||
|
||||
const char* emptyRCSLog = SETTINGS_PATH_PREFIX "/RCS/emptyLog";
|
||||
const char* dontSaveStdLib = SETTINGS_PATH_PREFIX "/DataFormat/dontSaveStdLib";
|
||||
const char* WindowGeometrySetpath= SETTINGS_PATH_PREFIX "/Layout/";
|
||||
@@ -685,4 +686,47 @@ void FWBSettings::setCheckUpdatesProxy(const QString &proxy_line)
|
||||
setValue(checkUpdatesProxy, proxy_line);
|
||||
}
|
||||
|
||||
void FWBSettings::getExpandedObjectIds(const QString &filename,
|
||||
const QString &lib,
|
||||
std::set<int> &ids)
|
||||
{
|
||||
ids.clear();
|
||||
QString ids_str = value(
|
||||
QString(SETTINGS_PATH_PREFIX "/") +
|
||||
"Window/" + filename + "/" + lib + "/ExpandedTreeItems").toString();
|
||||
QStringList strl = ids_str.split(":");
|
||||
for (QStringList::iterator i=strl.begin(); i!=strl.end(); ++i)
|
||||
ids.insert(i->toInt());
|
||||
}
|
||||
|
||||
void FWBSettings::setExpandedObjectIds(const QString &filename,
|
||||
const QString &lib,
|
||||
const std::set<int> &ids)
|
||||
{
|
||||
QStringList strl;
|
||||
for (set<int>::iterator i=ids.begin(); i!=ids.end(); ++i)
|
||||
strl.push_back(QString("%1").arg(*i));
|
||||
setValue(
|
||||
QString(SETTINGS_PATH_PREFIX "/") +
|
||||
"Window/" + filename + "/" + lib + "/ExpandedTreeItems",
|
||||
strl.join(":"));
|
||||
}
|
||||
|
||||
int FWBSettings::getVisibleRuleSetId(const QString &filename,
|
||||
const QString &lib)
|
||||
{
|
||||
string str_id = value(
|
||||
QString(SETTINGS_PATH_PREFIX "/") +
|
||||
"Window/" + filename + "/" + lib + "/OpenedRuleSet").toString().toStdString();
|
||||
return FWObjectDatabase::getIntId(str_id);
|
||||
}
|
||||
|
||||
void FWBSettings::setVisibleRuleSet(const QString &filename,
|
||||
const QString &lib,
|
||||
FWObject *ruleset)
|
||||
{
|
||||
setValue(QString(SETTINGS_PATH_PREFIX "/") +
|
||||
"Window/" + filename + "/" + lib + "/OpenedRuleSet",
|
||||
FWObjectDatabase::getStringId(ruleset->getId()).c_str() );
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
#include <qprinter.h>
|
||||
#include <qfont.h>
|
||||
|
||||
#include <set>
|
||||
|
||||
class QWidget;
|
||||
|
||||
/*
|
||||
@@ -164,6 +166,20 @@ class FWBSettings : public QSettings {
|
||||
QString getCheckUpdatesProxy();
|
||||
void setCheckUpdatesProxy(const QString &proxy_line);
|
||||
|
||||
void getExpandedObjectIds(const QString &filename,
|
||||
const QString &lib,
|
||||
std::set<int> &ids);
|
||||
void setExpandedObjectIds(const QString &filename,
|
||||
const QString &lib,
|
||||
const std::set<int> &ids);
|
||||
|
||||
int getVisibleRuleSetId(const QString &filename,
|
||||
const QString &lib);
|
||||
void setVisibleRuleSet(const QString &filename,
|
||||
const QString &lib,
|
||||
libfwbuilder::FWObject *ruleset);
|
||||
|
||||
|
||||
private:
|
||||
QFont getFontByType(const char*type);
|
||||
};
|
||||
|
||||
@@ -1079,7 +1079,7 @@ void FWWindow::closeRuleSetInAllWindowsWhereOpen(RuleSet *rs)
|
||||
}
|
||||
}
|
||||
|
||||
void FWWindow::closeObjectInAllWindowsWhereOpen(FWObject *obj)
|
||||
void FWWindow::closeObjectInAllWindowsWhereOpen(FWObject*)
|
||||
{
|
||||
QList<QMdiSubWindow*> subWindowList = getMdiArea()->subWindowList();
|
||||
for (int i = 0 ; i < subWindowList.size(); i++)
|
||||
|
||||
@@ -718,7 +718,7 @@ void ObjectManipulator::loadObjects()
|
||||
if (fwbdebug) qDebug("ObjectManipulator::loadObjects %p done", this);
|
||||
}
|
||||
|
||||
void ObjectManipulator::addLib( FWObject *lib,QTreeWidget* otv)
|
||||
void ObjectManipulator::addLib( FWObject *lib, QTreeWidget* otv)
|
||||
{
|
||||
QString newlibname = QString::fromUtf8(lib->getName().c_str());
|
||||
int N = m_objectManipulator->libs->count();
|
||||
@@ -754,7 +754,7 @@ void ObjectManipulator::addTreePage( FWObject *lib)
|
||||
ObjectTreeView *objTreeView = new ObjectTreeView(
|
||||
m_project, m_objectManipulator->widgetStack, OBJTREEVIEW_WIDGET_NAME );
|
||||
|
||||
addLib(lib,objTreeView);
|
||||
addLib(lib, objTreeView);
|
||||
|
||||
QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
policy.setHorizontalStretch(0);
|
||||
@@ -843,6 +843,7 @@ void ObjectManipulator::addTreePage( FWObject *lib)
|
||||
|
||||
for (list<FWObject*>::iterator m=lib->begin(); m!=lib->end(); m++)
|
||||
insertSubtree( itm1, (*m) );
|
||||
|
||||
objTreeView->updateTreeItems();
|
||||
objTreeView->sortByColumn(0,Qt::AscendingOrder);
|
||||
}
|
||||
@@ -1803,8 +1804,6 @@ FWObject* ObjectManipulator::duplicateWithDependencies(FWObject *target,
|
||||
// create copy of this object
|
||||
if (fwbdebug) qDebug("Create object %s", old_obj->getName().c_str());
|
||||
|
||||
int repl_counter = 0;
|
||||
|
||||
if (Interface::isA(old_obj) ||
|
||||
(
|
||||
(IPv4::isA(old_obj) ||
|
||||
@@ -3432,8 +3431,31 @@ void ObjectManipulator::reopenCurrentItemParent()
|
||||
current_tree_view->scrollToItem(itm);
|
||||
}
|
||||
|
||||
void ObjectManipulator::loadExpandedTreeItems()
|
||||
{
|
||||
for (int i=0; i<m_objectManipulator->libs->count(); i++)
|
||||
{
|
||||
ObjectTreeView *objTreeView =
|
||||
dynamic_cast<ObjectTreeView*>(idxToTrees[i]);
|
||||
FWObject *lib = idxToLibs[i];
|
||||
set<int> expanded_objects;
|
||||
st->getExpandedObjectIds(m_project->getFileName(),
|
||||
lib->getName().c_str(),
|
||||
expanded_objects);
|
||||
objTreeView->ExpandTreeItems(expanded_objects);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void ObjectManipulator::saveExpandedTreeItems()
|
||||
{
|
||||
for (int i=0; i<m_objectManipulator->libs->count(); i++)
|
||||
{
|
||||
ObjectTreeView *objTreeView =
|
||||
dynamic_cast<ObjectTreeView*>(idxToTrees[i]);
|
||||
FWObject *lib = idxToLibs[i];
|
||||
st->setExpandedObjectIds(m_project->getFileName(),
|
||||
lib->getName().c_str(),
|
||||
objTreeView->getListOfExpandedObjectIds());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -359,7 +359,9 @@ public:
|
||||
libfwbuilder::FWObject *o);
|
||||
void findAllFirewalls (std::list<libfwbuilder::Firewall *> &fws);
|
||||
|
||||
|
||||
void loadExpandedTreeItems();
|
||||
void saveExpandedTreeItems();
|
||||
|
||||
signals:
|
||||
/**
|
||||
* the dialog class should have a slot that can load object's data
|
||||
|
||||
@@ -205,18 +205,32 @@ void ObjectTreeView::currentItemChanged(QTreeWidgetItem *cur)
|
||||
|
||||
void ObjectTreeView::itemCollapsed(QTreeWidgetItem* itm)
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectTreeView::collapsed itm=%s",
|
||||
itm->text(0).toAscii().constData());
|
||||
expandOrCollapse = true;
|
||||
|
||||
ObjectTreeViewItem *otvi = dynamic_cast<ObjectTreeViewItem*>(itm);
|
||||
assert(otvi!=NULL);
|
||||
FWObject *o = otvi->getFWObject();
|
||||
if (o)
|
||||
{
|
||||
int id = o->getId();
|
||||
expanded_objects.erase(id);
|
||||
if (fwbdebug) qDebug("Tree item for object id=%d collapsed", id);
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectTreeView::itemExpanded(QTreeWidgetItem* itm)
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectTreeView::expanded itm=%s",
|
||||
itm->text(0).toAscii().constData());
|
||||
expandOrCollapse = true;
|
||||
|
||||
ObjectTreeViewItem *otvi=dynamic_cast<ObjectTreeViewItem*>(itm);
|
||||
assert(otvi!=NULL);
|
||||
FWObject *o = otvi->getFWObject();
|
||||
if (o)
|
||||
{
|
||||
int id = o->getId();
|
||||
expanded_objects.insert(id);
|
||||
if (fwbdebug) qDebug("Tree item for object id=%d expanded", id);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -541,7 +555,7 @@ void ObjectTreeView::dropEvent(QDropEvent *ev)
|
||||
if (fwbdebug) qDebug("ObjectTreeView::dropEvent done");
|
||||
}
|
||||
|
||||
FWObject *ObjectTreeView::getDropTarget(QDropEvent *ev, FWObject* dragobj)
|
||||
FWObject *ObjectTreeView::getDropTarget(QDropEvent *ev, FWObject*)
|
||||
{
|
||||
QTreeWidgetItem *ovi = itemAt(ev->pos());
|
||||
|
||||
@@ -845,3 +859,18 @@ void ObjectTreeView::updateAfterPrefEdit()
|
||||
{
|
||||
setFont(st->getTreeFont());
|
||||
}
|
||||
|
||||
void ObjectTreeView::ExpandTreeItems(const set<int> &ids)
|
||||
{
|
||||
QTreeWidgetItemIterator it(this);
|
||||
while ( *it )
|
||||
{
|
||||
QTreeWidgetItem *itm = *it;
|
||||
ObjectTreeViewItem *otvi=dynamic_cast<ObjectTreeViewItem*>(itm);
|
||||
FWObject *obj = otvi->getFWObject();
|
||||
if (ids.count(obj->getId()))
|
||||
itm->setExpanded(true);
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+25
-19
@@ -40,6 +40,7 @@
|
||||
#include <QDragLeaveEvent>
|
||||
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
namespace libfwbuilder {
|
||||
class FWObject;
|
||||
@@ -51,23 +52,22 @@ class ObjectTreeView : public QTreeWidget {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
QTreeWidgetItem *item_before_drag_started;
|
||||
QTreeWidgetItem *lastSelected;
|
||||
QItemSelection lastSelection;
|
||||
bool second_click;
|
||||
|
||||
bool selectionFrozen;
|
||||
bool expandOrCollapse;
|
||||
bool Lockable;
|
||||
bool Unlockable;
|
||||
bool startingDrag;
|
||||
|
||||
bool visible;
|
||||
|
||||
bool process_mouse_release_event;
|
||||
|
||||
std::vector<libfwbuilder::FWObject*> selectedObjects;
|
||||
QTreeWidgetItem *item_before_drag_started;
|
||||
QTreeWidgetItem *lastSelected;
|
||||
QItemSelection lastSelection;
|
||||
bool second_click;
|
||||
bool selectionFrozen;
|
||||
bool expandOrCollapse;
|
||||
bool Lockable;
|
||||
bool Unlockable;
|
||||
bool startingDrag;
|
||||
bool visible;
|
||||
bool process_mouse_release_event;
|
||||
std::set<int> expanded_objects;
|
||||
std::vector<libfwbuilder::FWObject*> selectedObjects;
|
||||
ProjectPanel* m_project;
|
||||
|
||||
|
||||
bool isCurrReadOnly(QDragMoveEvent *ev);
|
||||
libfwbuilder::FWObject *getDropTarget(
|
||||
QDropEvent *ev, libfwbuilder::FWObject* dragobj);
|
||||
@@ -99,9 +99,12 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
ObjectTreeView(ProjectPanel* project, QWidget* parent = 0, const char * name = 0, Qt::WFlags f = 0);
|
||||
ObjectTreeView(ProjectPanel* project,
|
||||
QWidget* parent = 0,
|
||||
const char * name = 0,
|
||||
Qt::WFlags f = 0);
|
||||
|
||||
void freezeSelection(bool f) { selectionFrozen=f; }
|
||||
void freezeSelection(bool f) { selectionFrozen = f; }
|
||||
|
||||
std::vector<libfwbuilder::FWObject*>& getSelectedObjects()
|
||||
{ return selectedObjects; }
|
||||
@@ -133,7 +136,10 @@ protected:
|
||||
std::vector<libfwbuilder::FWObject*> getSimplifiedSelection();
|
||||
|
||||
void ignoreNextMouseReleaseEvent() { process_mouse_release_event = false; }
|
||||
|
||||
|
||||
void ExpandTreeItems(const std::set<int> &ids);
|
||||
const std::set<int>& getListOfExpandedObjectIds() { return expanded_objects; }
|
||||
|
||||
public slots:
|
||||
|
||||
void itemSelectionChanged();
|
||||
|
||||
@@ -282,7 +282,8 @@ void ProjectPanel::clearFirewallTabs()
|
||||
while (m_panel->ruleSets->count()!=0)
|
||||
{
|
||||
QWidget *p = m_panel->ruleSets->widget(0);
|
||||
m_panel->ruleSets->removeWidget(m_panel->ruleSets->widget(m_panel->ruleSets->indexOf(p)));
|
||||
m_panel->ruleSets->removeWidget(
|
||||
m_panel->ruleSets->widget(m_panel->ruleSets->indexOf(p)));
|
||||
delete p;
|
||||
}
|
||||
m_panel->rulesetname->setText("");
|
||||
|
||||
@@ -350,6 +350,9 @@ public:
|
||||
void saveState();
|
||||
void loadState();
|
||||
|
||||
void loadOpenedRuleSet();
|
||||
void saveOpenedRuleSet();
|
||||
|
||||
bool checkin(bool unlock);
|
||||
void loadLibrary(const std::string &libfpath);
|
||||
|
||||
|
||||
@@ -117,6 +117,10 @@ void ProjectPanel::saveState()
|
||||
arg = QString("%1,%2").arg(sl[0]).arg(sl[1]);
|
||||
if (sl[0] || sl[1])
|
||||
st->setStr("Window/" + FileName + "/ObjInfoSplitter", arg );
|
||||
|
||||
m_panel->om->saveExpandedTreeItems();
|
||||
|
||||
saveOpenedRuleSet();
|
||||
}
|
||||
|
||||
void ProjectPanel::loadState()
|
||||
@@ -195,6 +199,10 @@ void ProjectPanel::loadState()
|
||||
|
||||
setObjInfoSplitterPosition(w1, w2);
|
||||
|
||||
m_panel->om->loadExpandedTreeItems();
|
||||
|
||||
loadOpenedRuleSet();
|
||||
|
||||
if (fwbdebug) qDebug("ProjectPanel::loadState done");
|
||||
}
|
||||
|
||||
@@ -222,4 +230,40 @@ void ProjectPanel::setObjInfoSplitterPosition(int w1, int w2)
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectPanel::loadOpenedRuleSet()
|
||||
{
|
||||
if (rcs==NULL) return;
|
||||
QString filename = rcs->getFileName();
|
||||
|
||||
int id = st->getVisibleRuleSetId(
|
||||
filename, m_panel->om->getCurrentLib()->getName().c_str());
|
||||
|
||||
if (id)
|
||||
{
|
||||
FWObject *obj = db()->getById(id, true);
|
||||
if (obj)
|
||||
{
|
||||
m_panel->om->openObject(obj);
|
||||
openRuleSet(RuleSet::cast(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectPanel::saveOpenedRuleSet()
|
||||
{
|
||||
if (rcs==NULL) return;
|
||||
QString filename = rcs->getFileName();
|
||||
|
||||
if (visibleRuleSet!=NULL)
|
||||
{
|
||||
st->setVisibleRuleSet(filename,
|
||||
visibleRuleSet->getLibrary()->getName().c_str(),
|
||||
visibleRuleSet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user