From 6b7d1f5806bb80fa1644db88908d7ee3e99931ea Mon Sep 17 00:00:00 2001 From: Vadim Kurland Date: Sat, 12 Mar 2011 18:20:23 -0800 Subject: [PATCH] fixes #2216 regression: system groups appear with user group icons and are editable --- src/libfwbuilder/src/fwbuilder/FWObject.cpp | 4 +- src/libgui/FWBTree.cpp | 58 ++++++++++----------- src/libgui/FWBTree.h | 2 + 3 files changed, 34 insertions(+), 30 deletions(-) diff --git a/src/libfwbuilder/src/fwbuilder/FWObject.cpp b/src/libfwbuilder/src/fwbuilder/FWObject.cpp index 1a4755d8f..0618aad37 100644 --- a/src/libfwbuilder/src/fwbuilder/FWObject.cpp +++ b/src/libfwbuilder/src/fwbuilder/FWObject.cpp @@ -546,7 +546,9 @@ string FWObject::getPath(bool relative, bool detailed) const p = p->getParent(); } - return std::for_each(res.begin(), res.end(), pathAccumulator()); + string path = std::for_each(res.begin(), res.end(), pathAccumulator()); + if (relative && path[0] == '/') path.erase(0, 1); + return path; } const string& FWObject::getComment() const diff --git a/src/libgui/FWBTree.cpp b/src/libgui/FWBTree.cpp index e4ff40001..e0feb31eb 100644 --- a/src/libgui/FWBTree.cpp +++ b/src/libgui/FWBTree.cpp @@ -74,33 +74,8 @@ using namespace std; using namespace libfwbuilder; -const char* standardFolders[] = { - "Objects", - "Objects/Addresses", - "Objects/DNS Names", - "Objects/Address Tables", - "Objects/Address Ranges", - "Objects/Groups", - "Objects/Hosts", - "Objects/Networks", - - "Services", - "Services/Custom", - "Services/Groups", - "Services/IP", - "Services/ICMP", - "Services/TCP", - "Services/UDP", - "Services/TagServices", - "Services/Users", - - "Firewalls", - "Clusters", - "Time", - - NULL -}; +QStringList FWBTree::standardFolders; QSet FWBTree::standardIDs; QMap FWBTree::systemGroupTypes; QMap FWBTree::systemGroupNames; @@ -121,6 +96,33 @@ void FWBTree::init_statics() { if (systemGroupPaths.size() == 0) { + // Names of the standard folders should be translatable. + // Function isStandardFolder() takes this into account. + + standardFolders << "Objects"; + standardFolders << "Objects/Addresses"; + standardFolders << "Objects/DNS Names"; + standardFolders << "Objects/Address Tables"; + standardFolders << "Objects/Address Ranges"; + standardFolders << "Objects/Groups"; + standardFolders << "Objects/Hosts"; + standardFolders << "Objects/Networks"; + + standardFolders << "Services"; + standardFolders << "Services/Custom"; + standardFolders << "Services/Groups"; + standardFolders << "Services/IP"; + standardFolders << "Services/ICMP"; + standardFolders << "Services/TCP"; + standardFolders << "Services/UDP"; + standardFolders << "Services/TagServices"; + standardFolders << "Services/Users"; + + standardFolders << "Firewalls"; + standardFolders << "Clusters"; + standardFolders << "Time"; + + systemGroupPaths[Library::TYPENAME] = ""; systemGroupPaths[IPv4::TYPENAME] = "Objects/Addresses"; @@ -387,9 +389,7 @@ bool FWBTree::isSystem(FWObject *obj) bool FWBTree::isStandardFolder(FWObject *obj) { string path = obj->getPath(true); // relative path - for (const char **cptr=standardFolders; *cptr!=NULL; cptr++) - if (path== *cptr) return true; - return false; + return (standardFolders.contains(QString::fromUtf8(path.c_str()))); } bool FWBTree::isStandardId(FWObject *obj) diff --git a/src/libgui/FWBTree.h b/src/libgui/FWBTree.h index b7f048bee..5d7f2e8e7 100644 --- a/src/libgui/FWBTree.h +++ b/src/libgui/FWBTree.h @@ -42,6 +42,8 @@ namespace libfwbuilder { class FWBTree { + static QStringList standardFolders; + static QMap systemGroupTypes; static QMap systemGroupNames; static QMap systemGroupPaths;