1
0
mirror of https://github.com/fwbuilder/fwbuilder synced 2026-03-25 20:57:29 +01:00
This commit is contained in:
Vadim Kurland 2009-09-25 17:26:42 +00:00
parent e20d0bb7e0
commit bd9f77f6f0
17 changed files with 82 additions and 83 deletions

View File

@ -1 +1 @@
#define BUILD_NUM 1500
#define BUILD_NUM 1501

View File

@ -26,8 +26,7 @@
#include "../../config.h"
#include "global.h"
#include <qobject.h>
#include <qmessagebox.h>
#include <QtDebug>
#include "FWBTree.h"
@ -64,7 +63,7 @@
using namespace std;
using namespace libfwbuilder;
const char* systemObjects[] = {
const char* standardFolders[] = {
"Objects",
"Objects/Addresses",
"Objects/DNS Names",
@ -83,9 +82,9 @@ const char* systemObjects[] = {
"Services/UDP",
"Services/TagServices",
"Services/Users",
"Firewalls",
"Clusters",
"Time",
NULL
@ -346,12 +345,18 @@ bool FWBTree::isSystem(FWObject *obj)
if (FWObjectDatabase::isA(obj)) return true;
string path=obj->getPath(true); // relative path
return isStandardFolder(obj);
}
for (const char **cptr=systemObjects; *cptr!=NULL; cptr++)
/**
* returns true if @obj is a standard folder,e.g. "Firewalls", "Objects",
* "Objects/Hosts" etc.
*/
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;
}

View File

@ -47,6 +47,7 @@ class FWBTree {
FWBTree();
bool isSystem(libfwbuilder::FWObject *obj);
bool isStandardFolder(libfwbuilder::FWObject *obj);
bool isStandardId(libfwbuilder::FWObject *obj);
bool validateForInsertion(libfwbuilder::FWObject *target,libfwbuilder::FWObject *obj);

View File

@ -302,8 +302,6 @@ public slots:
QString outputFileName);
bool isSystem(libfwbuilder::FWObject *obj);
protected:
virtual void showEvent(QShowEvent *ev);

View File

@ -537,12 +537,6 @@ QString FWWindow::printHeader()
return "";
}
bool FWWindow::isSystem(FWObject *obj)
{
if (activeProject()) return activeProject()->isSystem(obj);
return false;
}
bool FWWindow::editingLibrary()
{
if (activeProject()) return activeProject()->editingLibrary();

View File

@ -578,11 +578,14 @@ void FindObjectWidget::replaceDisable()
void FindObjectWidget::showObject(FWObject* o)
{
if (fwbdebug) qDebug("FindObjectWidget::showObject");
if (fwbdebug)
qDebug("FindObjectWidget::showObject o: %s parent: %s",
o->getName().c_str(), o->getParent()->getName().c_str());
FWReference* ref=FWReference::cast(o);
if (ref!=NULL && RuleElement::cast(o->getParent())!=NULL)
{
// found object in rules
project_panel->closeEditor();
project_panel->clearManipulatorFocus();
project_panel->ensureObjectVisibleInRules( ref );
@ -591,8 +594,12 @@ void FindObjectWidget::showObject(FWObject* o)
project_panel->unselectRules();
if (Group::cast(o->getParent())!=NULL &&
!project_panel->isSystem(o->getParent()))
if (fwbdebug)
qDebug("FindObjectWidget::showObject checkpoint #1");
if (!FWBTree().isStandardFolder(o) &&
Group::cast(o->getParent())!=NULL &&
!FWBTree().isStandardFolder(o->getParent()))
{
project_panel->openObject( o->getParent() );
project_panel->editObject( o->getParent() );
@ -600,6 +607,9 @@ void FindObjectWidget::showObject(FWObject* o)
return;
}
if (fwbdebug)
qDebug("FindObjectWidget::showObject checkpoint #2");
project_panel->closeEditor();
project_panel->openObject( o );
project_panel->select(); // selects an item in the tree and assigns kbd focus to it

View File

@ -256,7 +256,7 @@ void GroupObjectDialog::insertObject(FWObject *o)
if(obj_id==cp_id) return;
}
addIcon(o, ! m_project->isSystem(obj) );
addIcon(o, ! FWBTree().isSystem(obj) );
changed();
}
@ -330,8 +330,8 @@ void GroupObjectDialog::loadFWObject(FWObject *o)
m_dialog->obj_name->setText( QString::fromUtf8(g->getName().c_str()) );
m_dialog->comment->setText( QString::fromUtf8(g->getComment().c_str()) );
m_dialog->obj_name->setEnabled( !m_project->isSystem(obj) );
m_dialog->comment->setEnabled( !m_project->isSystem(obj) );
m_dialog->obj_name->setEnabled( !FWBTree().isSystem(obj) );
m_dialog->comment->setEnabled( !FWBTree().isSystem(obj) );
listView->clear();
iconView->clear();
@ -361,10 +361,10 @@ void GroupObjectDialog::loadFWObject(FWObject *o)
//apply->setEnabled( false );
m_dialog->obj_name->setEnabled(!o->isReadOnly() && !m_project->isSystem(o));
m_dialog->obj_name->setEnabled(!o->isReadOnly() && !FWBTree().isSystem(o));
setDisabledPalette(m_dialog->obj_name);
m_dialog->comment->setEnabled(!o->isReadOnly() && !m_project->isSystem(o));
m_dialog->comment->setEnabled(!o->isReadOnly() && !FWBTree().isSystem(o));
setDisabledPalette(m_dialog->comment);
// listView->setEnabled(!o->isReadOnly());
@ -444,7 +444,7 @@ void GroupObjectDialog::applyChanges()
for (set<int>::iterator k=diff.begin(); k!=diff.end(); ++k)
{
FWObject *o = m_project->db()->findInIndex(*k);
if (m_project->isSystem(obj))
if (FWBTree().isSystem(obj))
m_project->delObj(o, false);
else
obj->removeRef(o);
@ -461,7 +461,7 @@ void GroupObjectDialog::applyChanges()
for (set<int>::iterator k1=diff.begin(); k1!=diff.end(); ++k1)
{
FWObject *o = m_project->db()->findInIndex(*k1);
if (m_project->isSystem(o))
if (FWBTree().isSystem(o))
m_project->pasteTo(obj, o);
else
obj->addRef(o);
@ -604,14 +604,14 @@ void GroupObjectDialog::setupPopupMenu(const QPoint &pos)
QAction *delID =popup->addAction(tr("Delete"),this, SLOT(deleteObj()));
copyID->setEnabled(selectedObject!=NULL &&
! m_project->isSystem(selectedObject) );
! FWBTree().isSystem(selectedObject) );
cutID->setEnabled(selectedObject!=NULL &&
! m_project->isSystem(obj) &&
! FWBTree().isSystem(obj) &&
! obj->isReadOnly() );
pasteID->setEnabled(! m_project->isSystem(obj) &&
pasteID->setEnabled(! FWBTree().isSystem(obj) &&
! obj->isReadOnly() );
delID->setEnabled(selectedObject!=NULL &&
! m_project->isSystem(obj) &&
! FWBTree().isSystem(obj) &&
! obj->isReadOnly() );
popup->exec( pos );
@ -625,7 +625,7 @@ void GroupObjectDialog::copyObj()
{
FWObject* selectedObject = m_project->db()->findInIndex(*it);
if (selectedObject!=NULL && ! m_project->isSystem(selectedObject) )
if (selectedObject!=NULL && ! FWBTree().isSystem(selectedObject) )
{
FWObjectClipboard::obj_clipboard->add(selectedObject,
this->m_project );

View File

@ -114,7 +114,7 @@ void LibraryDialog::changed()
void LibraryDialog::changeIds(FWObject *root)
{
if (m_project->isStandardId(root))
if (FWBTree().isStandardId(root))
root->setId(FWObjectDatabase::generateUniqueId());
for (FWObject::iterator i=root->begin(); i!=root->end(); i++)

View File

@ -643,10 +643,19 @@ void ObjectEditor::changed()
applyButton->setEnabled(true);
}
/*
* For groups, select object in the group dialog. Argument @o is the
* child object that has to be selected in the dialog, <opened> is
* currently opened object (which should be the parent of @o or hold
* reference to @o)
*/
void ObjectEditor::selectObject(FWObject *o)
{
qDebug("ObjectEditor::selectObject");
if (Group::cast(opened)==NULL || current_dialog_idx==-1) return;
// class Library inherits Group but has its own dialog where
// children objects are not shown.
if (Library::cast(opened)!=NULL || Group::cast(opened)==NULL || current_dialog_idx==-1)
return;
((GroupObjectDialog *) dialogs[current_dialog_idx])->selectObject(o);
}

View File

@ -351,12 +351,8 @@ ObjectTreeViewItem* ObjectManipulator::insertObject(ObjectTreeViewItem *itm,
ObjectTreeViewItem *nitm = NULL;
QString icn_filename;
if (fwbdebug)
qDebug("insertObject: obj=%p %s", obj, obj->getName().c_str());
if (m_project->isSystem(obj))
if (FWBTree().isStandardFolder(obj))
icn_filename = ":/Icons/SystemGroup/icon-tree";
// icn_filename = ":/Icons/folder1.png";
else
icn_filename = (":/Icons/" + obj->getTypeName() + "/icon-tree").c_str();
@ -364,7 +360,7 @@ ObjectTreeViewItem* ObjectManipulator::insertObject(ObjectTreeViewItem *itm,
if (Resources::global_res->getResourceBool(
string("/FWBuilderResources/Type/") +
obj->getTypeName() + "/hidden") ) return NULL;
obj->getTypeName() + "/hidden")) return NULL;
nitm = new ObjectTreeViewItem( itm );
@ -399,7 +395,7 @@ void ObjectManipulator::insertSubtree(ObjectTreeViewItem *itm, FWObject *obj)
ObjectTreeViewItem *nitm = insertObject(itm, obj);
if (nitm==NULL) return;
if ( m_project->isSystem(obj) ) nitm->setExpanded( st->getExpandTree() );
if ( FWBTree().isStandardFolder(obj) ) nitm->setExpanded( st->getExpandTree() );
if (Cluster::isA(obj))
{
@ -1184,10 +1180,12 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos)
tr("Edit"), this, SLOT( editSelectedObject()));
QMenu *duptargets = NULL;
QAction *dupID = NULL;
QMenu *movetargets = NULL;
int moveTargetsCounter = 0;
if (!Interface::isA(currentObj) && RuleSet::cast(currentObj)==NULL)
if (!Interface::isA(currentObj) && RuleSet::cast(currentObj)==NULL &&
!Library::isA(currentObj) && !FWBTree().isStandardFolder(currentObj))
{
duptargets = popup->addMenu( tr("Duplicate ...") );
movetargets = popup->addMenu( tr("Move ...") );
@ -1221,10 +1219,10 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos)
lib->isReadOnly())
continue;
QAction* dact = duptargets->addAction(
dupID = duptargets->addAction(
tr("place in library %1").arg(
QString::fromUtf8(lib->getName().c_str())));
dact->setData(libid);
dupID->setData(libid);
/* can't move to the same library or if selected object is
* a library
@ -1242,12 +1240,9 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos)
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() ) );
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()));
popup->addSeparator();
@ -1487,7 +1482,7 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos)
if (getCurrentObjectTree()->getNumSelected()==1)
{
edtID->setEnabled(! m_project->isSystem(currentObj) );
edtID->setEnabled( !FWBTree().isStandardFolder(currentObj));
} else
edtID->setEnabled(false);
@ -1503,8 +1498,8 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos)
dupMenuItem, moveMenuItem, copyMenuItem, pasteMenuItem,
delMenuItem, newMenuItem, inDeletedObjects);
// dupID->setEnabled(dupMenuItem);
// movID->setEnabled(moveMenuItem);
if (dupID) dupID->setEnabled(dupMenuItem);
// movetargets->setEnabled(moveMenuItem);
copyID->setEnabled(copyMenuItem);
pasteID->setEnabled(pasteMenuItem);
@ -1584,13 +1579,13 @@ void ObjectManipulator::getMenuState(bool haveMoveTargets,
}
dupMenuItem=
(dupMenuItem && ! m_project->isSystem(obj) && ! Library::isA(obj) );
(dupMenuItem && ! FWBTree().isStandardFolder(obj) && ! Library::isA(obj) );
inDeletedObjects = (del_obj_library!=NULL && obj->isChildOf(del_obj_library));
dupMenuItem = dupMenuItem && !inDeletedObjects;
// can't move system objects
moveMenuItem = moveMenuItem && ! m_project->isSystem(obj);
// can't move system objects or libraries
moveMenuItem = moveMenuItem && ! FWBTree().isStandardFolder(obj) && ! Library::isA(obj);
// can't move interfaces unless parent host object is also selected
if ( Interface::isA(obj) &&
@ -1616,9 +1611,9 @@ void ObjectManipulator::getMenuState(bool haveMoveTargets,
if (!haveMoveTargets && ! inDeletedObjects) moveMenuItem = false;
// copyMenuItem= (copyMenuItem &&
// ! m_project->isSystem(currentObj) &&
// ! FWBTree().isSystem(currentObj) &&
// ! Library::isA(currentObj));
// delMenuItem= (delMenuItem && ! m_project->isSystem(currentObj));
// delMenuItem= (delMenuItem && ! FWBTree().isSystem(currentObj));
newMenuItem= (newMenuItem && ! obj->isReadOnly() );
Interface *intf = Interface::cast(obj);
@ -1804,7 +1799,7 @@ void ObjectManipulator::duplicateObj(QAction *action)
for (vector<FWObject*>::iterator i=so.begin(); i!=so.end(); ++i)
{
obj= *i;
if ( m_project->isSystem(obj) || Interface::isA(obj) ) continue;
if ( FWBTree().isSystem(obj) || Interface::isA(obj) ) continue;
FWObject *cl = idxToLibs[libid];
nobj = duplicateObject(cl, obj, "", false);
}
@ -1940,7 +1935,7 @@ void ObjectManipulator::moveObj(QAction* action)
{
if (obj->isChildOf(targetLib)) continue;
if ( m_project->isSystem(obj) ||
if ( FWBTree().isSystem(obj) ||
Interface::isA(obj) ||
Interface::isA(obj->getParent())) continue;
@ -1965,7 +1960,7 @@ void ObjectManipulator::copyObj()
for (vector<FWObject*>::iterator i=so.begin(); i!=so.end(); ++i)
{
obj = *i;
if ( ! m_project->isSystem(obj) )
if ( ! FWBTree().isSystem(obj) )
{
// while obj is still part of the tree, do some clean up
// to avoid problems in the future. Create
@ -2063,7 +2058,7 @@ bool ObjectManipulator::validateForPaste(FWObject *target, FWObject *obj,
.arg(obj->getTypeName().c_str())
.arg(ta->getName().c_str());
if (m_project->isSystem(ta))
if (FWBTree().isSystem(ta))
return m_project->validateForInsertion(ta, obj);
Host *hst = Host::cast(ta);
@ -2498,7 +2493,7 @@ void ObjectManipulator::deleteObj()
// openObject(obj,false);
if ( ! m_project->isSystem(obj) )
if ( ! FWBTree().isSystem(obj) )
{
if (Library::isA(obj))
{

View File

@ -304,7 +304,7 @@ void ObjectTreeView::updateTreeIcons()
otvi=dynamic_cast<ObjectTreeViewItem*>(itm);
obj=otvi->getFWObject();
if (m_project->isSystem(obj))
if (FWBTree().isSystem(obj))
icn = ":/Icons/SystemGroup/icon-tree";
else
icn = (":/Icons/"+obj->getTypeName()+"/icon-tree").c_str();
@ -346,7 +346,7 @@ void ObjectTreeView::startDrag(Qt::DropActions supportedActions)
the end of void QListView::mouseMoveEvent( QMouseEvent * e)
(See code after they decided that they do not need to call startDrag())
if (m_project->isSystem(obj)) return NULL;
if (FWBTree().isSystem(obj)) return NULL;
*/
QString icn = (":/Icons/"+current_obj->getTypeName()+"/icon-ref").c_str();
@ -506,7 +506,7 @@ void ObjectTreeView::dragMoveEvent( QDragMoveEvent *ev)
FWObject *dragobj = *i;
assert(dragobj!=NULL);
if (m_project->isSystem(dragobj))
if (FWBTree().isSystem(dragobj))
{
// can not drop system folder anywhere
ev->setAccepted(false);

View File

@ -52,6 +52,7 @@
#include "events.h"
#include "ObjectTreeView.h"
#include <QtDebug>
#include <QMdiSubWindow>
#include <QMdiArea>
#include <QTimer>
@ -1075,16 +1076,6 @@ bool ProjectPanel::requestEditorOwnership(QWidget *w,
return true;
}
bool ProjectPanel::isSystem(FWObject *obj)
{
return objectTreeFormat->isSystem(obj);
}
bool ProjectPanel::isStandardId(FWObject *obj)
{
return objectTreeFormat->isStandardId(obj);
}
bool ProjectPanel::validateForInsertion(FWObject *target, FWObject *obj)
{
return objectTreeFormat->validateForInsertion(target, obj);

View File

@ -366,8 +366,6 @@ public:
void releaseEditor();
void connectEditor(QWidget *w);
bool isSystem(libfwbuilder::FWObject *obj);
bool isStandardId(libfwbuilder::FWObject *obj);
bool validateForInsertion(libfwbuilder::FWObject *target,libfwbuilder::FWObject *obj);
bool getCopyMenuState(const QString &objPath);
bool getCutMenuState(const QString &objPath);

View File

@ -102,7 +102,7 @@ void PrototypeDialog::applyChanges()
init=true;
/* move to another lib if we have to */
if (! m_project->isSystem(obj) && libs->currentText() != QString(obj->getLibrary()->getName().c_str()))
if (! FWBTree().isSystem(obj) && libs->currentText() != QString(obj->getLibrary()->getName().c_str()))
mw->moveObject(libs->currentText(), obj);
init=false;

View File

@ -274,7 +274,7 @@ QVariant RuleSetModel::getGroupDataForDisplayRole(const QModelIndex &index, Rule
QVariant RuleSetModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (fwbdebug) qDebug() << "RuleSetModel::headerData";
//if (fwbdebug) qDebug() << "RuleSetModel::headerData"; // too chatty
if (orientation == Qt::Vertical)
return QVariant();
if (role != Qt::DisplayRole)

View File

@ -1476,8 +1476,6 @@ void RuleSetView::selectObject(FWObject *object, const QModelIndex &index)
{
if (fwbdebug) qDebug() << "select object:" << object->getName().c_str();
FWObject* oldObject = fwosm->selectedObject;
fwosm->setSelected(object, index);
setCurrentIndex(index);
viewport()->update((viewport()->rect()));

View File

@ -289,7 +289,7 @@ loop:
}
if (Group::cast(o->getParent())!=NULL &&
!m_project->isSystem(o->getParent()))
!FWBTree().isSystem(o->getParent()))
{
m_project->openObject( o->getParent() );
m_project->editObject( o->getParent() );