mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-09-13 16:39:48 +02:00
fix selection problems with qt 4.4.0
This commit is contained in:
@@ -57,7 +57,14 @@ void FWObjectClipboard::clear()
|
||||
for (vector<int>::iterator i=ids.begin(); i!=ids.end(); ++i)
|
||||
{
|
||||
FWObject *obj = mw->db()->findInIndex(*i);
|
||||
if (obj) obj->unref();
|
||||
if (obj)
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug("FWObjectClipboard::clear unref obj=%p (%s)",
|
||||
obj, obj->getName().c_str());
|
||||
|
||||
obj->unref();
|
||||
}
|
||||
}
|
||||
ids.clear();
|
||||
window=NULL;
|
||||
|
||||
+101
-80
@@ -828,28 +828,30 @@ void ObjectManipulator::addTreePage( FWObject *lib)
|
||||
//objTreeView->setContextMenuPolicy( Qt::CustomContextMenu );
|
||||
|
||||
connect(m_objectManipulator->widgetStack, SIGNAL( currentChanged(int) ),
|
||||
this, SLOT( currentTreePageChanged(int) ) );
|
||||
this, SLOT( currentTreePageChanged(int) ) );
|
||||
|
||||
connect(objTreeView,SIGNAL( editCurrentObject_sign() ),
|
||||
this, SLOT( editSelectedObject()) );
|
||||
connect(objTreeView, SIGNAL( editCurrentObject_sign() ),
|
||||
this, SLOT( editSelectedObject()) );
|
||||
|
||||
// connect(objTreeView,SIGNAL( editCurrentObject_sign() ),
|
||||
// this, SLOT( editSelectedObject()) );
|
||||
// this, SLOT( editSelectedObject()) );
|
||||
|
||||
connect(objTreeView,SIGNAL( switchObjectInEditor_sign(libfwbuilder::FWObject*) ),
|
||||
this, SLOT( switchObjectInEditor(libfwbuilder::FWObject*)) );
|
||||
connect(objTreeView,
|
||||
SIGNAL( switchObjectInEditor_sign(libfwbuilder::FWObject*) ),
|
||||
this, SLOT( switchObjectInEditor(libfwbuilder::FWObject*)) );
|
||||
|
||||
connect(objTreeView, SIGNAL( deleteObject_sign(libfwbuilder::FWObject*) ),
|
||||
this, SLOT( deleteObj() ) );
|
||||
this, SLOT( deleteObj() ) );
|
||||
|
||||
connect(objTreeView, SIGNAL( objectDropped_sign(libfwbuilder::FWObject*) ),
|
||||
this, SLOT( openObject(libfwbuilder::FWObject*) ) );
|
||||
this, SLOT( openObject(libfwbuilder::FWObject*) ) );
|
||||
|
||||
connect(objTreeView, SIGNAL( contextMenuRequested_sign(const QPoint&) ),
|
||||
this, SLOT( contextMenuRequested(const QPoint&) ) );
|
||||
this, SLOT( contextMenuRequested(const QPoint&) ) );
|
||||
|
||||
connect(objTreeView, SIGNAL( currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*) ),
|
||||
this, SLOT( selectionChanged(QTreeWidgetItem*) ) );
|
||||
connect(objTreeView,
|
||||
SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*) ),
|
||||
this, SLOT(selectionChanged(QTreeWidgetItem*)));
|
||||
|
||||
|
||||
ObjectTreeViewItem *itm1=new ObjectTreeViewItem( objTreeView );
|
||||
@@ -862,7 +864,7 @@ void ObjectManipulator::addTreePage( FWObject *lib)
|
||||
|
||||
itm1->setFlags(itm1->flags() | Qt::ItemIsDragEnabled);
|
||||
|
||||
itm1->setText( 0 , getTreeLabel( lib ) );
|
||||
itm1->setText( 0, getTreeLabel( lib ) );
|
||||
if (lib->isReadOnly())
|
||||
{
|
||||
QPixmap pm;
|
||||
@@ -885,7 +887,7 @@ void ObjectManipulator::addTreePage( FWObject *lib)
|
||||
itm1->setIcon( 0, pm);
|
||||
}
|
||||
|
||||
//itm1->setProperty("id", lib->getId().c_str() );
|
||||
//itm1->setProperty("id", lib->getId().c_str() );
|
||||
itm1->setProperty("type", lib->getTypeName().c_str() );
|
||||
itm1->setFWObject( lib );
|
||||
allItems[lib] = itm1;
|
||||
@@ -989,7 +991,7 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos)
|
||||
if (otvi==NULL) return; // happens when user clicks outside an item
|
||||
|
||||
if (!getCurrentObjectTree()->isSelected(otvi->getFWObject()))
|
||||
openObject( otvi , true );
|
||||
openObject( otvi, true );
|
||||
|
||||
if (currentObj==NULL) currentObj=otvi->getFWObject();
|
||||
|
||||
@@ -1055,7 +1057,7 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos)
|
||||
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 *dupID = popup->addAction( tr("Duplicate ..."),this, SLOT (duplicateObjUnderSameParent()));//popup->
|
||||
QAction *movID;
|
||||
|
||||
if (moveTargets!=0)
|
||||
@@ -1070,16 +1072,16 @@ QAction *movID;
|
||||
|
||||
popup->addSeparator();
|
||||
|
||||
QAction *copyID = popup->addAction( tr("Copy") , this ,
|
||||
QAction *copyID = popup->addAction( tr("Copy"), this,
|
||||
SLOT( copyObj() ) );
|
||||
QAction *cutID =popup->addAction( tr("Cut") , this ,
|
||||
QAction *cutID =popup->addAction( tr("Cut"), this,
|
||||
SLOT( cutObj() ) );
|
||||
QAction *pasteID =popup->addAction( tr("Paste") , this ,
|
||||
QAction *pasteID =popup->addAction( tr("Paste"), this,
|
||||
SLOT( pasteObj() ) );
|
||||
|
||||
popup->addSeparator();
|
||||
|
||||
QAction * delID =popup->addAction( tr("Delete") , this ,
|
||||
QAction * delID =popup->addAction( tr("Delete"), this,
|
||||
SLOT( deleteObj() ) );
|
||||
|
||||
QAction *newID1=NULL;
|
||||
@@ -1092,115 +1094,115 @@ QAction *movID;
|
||||
if ( (Firewall::isA(currentObj) || Host::isA(currentObj)) &&
|
||||
! currentObj->isReadOnly() )
|
||||
{
|
||||
newID1=popup->addAction( tr("Add Interface"), this ,
|
||||
newID1=popup->addAction( tr("Add Interface"), this,
|
||||
SLOT( newInterface() ) );
|
||||
|
||||
}
|
||||
if ((Firewall::isA(currentObj) &&! currentObj->isReadOnly()))
|
||||
{
|
||||
newID1=popup->addAction( tr("Add Policy Rule Set"), this ,
|
||||
newID1=popup->addAction( tr("Add Policy Rule Set"), this,
|
||||
SLOT( newPolicyRuleSet() ) );
|
||||
newID1=popup->addAction( tr("Add NAT Rule Set"), this ,
|
||||
newID1=popup->addAction( tr("Add NAT Rule Set"), this,
|
||||
SLOT( newNATRuleSet() ) );
|
||||
}
|
||||
if (Interface::isA(currentObj) && ! currentObj->isReadOnly())
|
||||
{
|
||||
newID1=popup->addAction( tr("Add IP Address"), this ,
|
||||
newID1=popup->addAction( tr("Add IP Address"), this,
|
||||
SLOT( newInterfaceAddress() ) );
|
||||
newID1=popup->addAction( tr("Add IPv6 Address"), this ,
|
||||
newID1=popup->addAction( tr("Add IPv6 Address"), this,
|
||||
SLOT( newInterfaceAddressIPv6() ) );
|
||||
newID2=popup->addAction( tr("Add MAC Address"), this ,
|
||||
newID2=popup->addAction( tr("Add MAC Address"), this,
|
||||
SLOT( newPhysicalAddress() ) );
|
||||
}
|
||||
|
||||
if (currentObj->getPath(true)=="Firewalls")
|
||||
newID1=popup->addAction( tr("New Firewall"), this ,
|
||||
newID1=popup->addAction( tr("New Firewall"), this,
|
||||
SLOT( newFirewall() ) );
|
||||
|
||||
if (currentObj->getPath(true)=="Objects/Addresses")
|
||||
{
|
||||
newID1=popup->addAction( tr("New Address"), this ,
|
||||
newID1=popup->addAction( tr("New Address"), this,
|
||||
SLOT( newAddress() ) );
|
||||
}
|
||||
if (currentObj->getPath(true)=="Objects/DNS Names")
|
||||
{
|
||||
newID1=popup->addAction( tr("New DNS Name"), this ,
|
||||
newID1=popup->addAction( tr("New DNS Name"), this,
|
||||
SLOT( newDNSName() ) );
|
||||
}
|
||||
|
||||
if (currentObj->getPath(true)=="Objects/Address Tables")
|
||||
{
|
||||
newID1=popup->addAction( tr("New Address Table"), this ,
|
||||
newID1=popup->addAction( tr("New Address Table"), this,
|
||||
SLOT( newAddressTable() ) );
|
||||
}
|
||||
|
||||
if (currentObj->getPath(true)=="Objects/Address Ranges")
|
||||
newID1=popup->addAction( tr("New Address Range"), this ,
|
||||
newID1=popup->addAction( tr("New Address Range"), this,
|
||||
SLOT( newAddressRange() ) );
|
||||
|
||||
if (currentObj->getPath(true)=="Objects/Hosts")
|
||||
newID1=popup->addAction( tr("New Host"), this ,
|
||||
newID1=popup->addAction( tr("New Host"), this,
|
||||
SLOT( newHost() ) );
|
||||
|
||||
if (currentObj->getPath(true)=="Objects/Networks")
|
||||
newID1=popup->addAction( tr("New Network"), this ,
|
||||
newID1=popup->addAction( tr("New Network"), this,
|
||||
SLOT( newNetwork() ) );
|
||||
|
||||
if (currentObj->getPath(true)=="Objects/Groups")
|
||||
newID1=popup->addAction( tr("New Group"), this ,
|
||||
newID1=popup->addAction( tr("New Group"), this,
|
||||
SLOT( newObjectGroup() ) );
|
||||
|
||||
if (currentObj->getPath(true)=="Services/Custom")
|
||||
newID1=popup->addAction( tr("New Custom Service"),this ,
|
||||
newID1=popup->addAction( tr("New Custom Service"),this,
|
||||
SLOT( newCustom() ) );
|
||||
|
||||
if (currentObj->getPath(true)=="Services/IP")
|
||||
newID1=popup->addAction( tr("New IP Service"), this ,
|
||||
newID1=popup->addAction( tr("New IP Service"), this,
|
||||
SLOT( newIP() ) );
|
||||
|
||||
if (currentObj->getPath(true)=="Services/ICMP")
|
||||
{
|
||||
newID1=popup->addAction( tr("New ICMP Service"), this ,
|
||||
newID1=popup->addAction( tr("New ICMP Service"), this,
|
||||
SLOT( newICMP() ) );
|
||||
newID2=popup->addAction( tr("New ICMP6 Service"), this ,
|
||||
newID2=popup->addAction( tr("New ICMP6 Service"), this,
|
||||
SLOT( newICMP6() ) );
|
||||
}
|
||||
|
||||
if (currentObj->getPath(true)=="Services/TCP")
|
||||
newID1=popup->addAction( tr("New TCP Service"), this ,
|
||||
newID1=popup->addAction( tr("New TCP Service"), this,
|
||||
SLOT( newTCP() ) );
|
||||
|
||||
if (currentObj->getPath(true)=="Services/UDP")
|
||||
newID1=popup->addAction( tr("New UDP Service"), this ,
|
||||
newID1=popup->addAction( tr("New UDP Service"), this,
|
||||
SLOT( newUDP() ) );
|
||||
|
||||
if (currentObj->getPath(true)=="Services/TagServices")
|
||||
newID1=popup->addAction( tr("New TagService"), this ,
|
||||
newID1=popup->addAction( tr("New TagService"), this,
|
||||
SLOT( newTagService() ) );
|
||||
|
||||
if (currentObj->getPath(true)=="Services/Groups")
|
||||
newID1=popup->addAction( tr("New Group"), this ,
|
||||
newID1=popup->addAction( tr("New Group"), this,
|
||||
SLOT( newServiceGroup() ) );
|
||||
|
||||
if (currentObj->getPath(true)=="Time")
|
||||
newID1=popup->addAction( tr("New Time Interval"), this ,
|
||||
newID1=popup->addAction( tr("New Time Interval"), this,
|
||||
SLOT( newInterval() ) );
|
||||
|
||||
popup->addSeparator();
|
||||
popup->addAction( tr("Find") , this , SLOT( findObject()));
|
||||
popup->addAction( tr("Where used") , this , SLOT( findWhereUsedSlot()));
|
||||
popup->addAction( tr("Find"), this, SLOT( findObject()));
|
||||
popup->addAction( tr("Where used"), this, SLOT( findWhereUsedSlot()));
|
||||
/*
|
||||
if (Firewall::cast(currentObj)!=NULL)
|
||||
{
|
||||
popup->addSeparator();
|
||||
popup->addAction( tr("Compile") , this , SLOT( compile()));
|
||||
popup->addAction( tr("Install") , this , SLOT( install()));
|
||||
popup->addAction( tr("Compile"), this, SLOT( compile()));
|
||||
popup->addAction( tr("Install"), this, SLOT( install()));
|
||||
}
|
||||
*/
|
||||
} else
|
||||
{
|
||||
|
||||
popup->addAction( tr("Group"), this ,
|
||||
popup->addAction( tr("Group"), this,
|
||||
SLOT( groupObjects() ) );
|
||||
|
||||
}
|
||||
@@ -1208,17 +1210,17 @@ QAction *movID;
|
||||
if (Firewall::cast(currentObj)!=NULL || ObjectGroup::cast(currentObj)!=NULL)
|
||||
{
|
||||
popup->addSeparator();
|
||||
popup->addAction( tr("Compile") , this , SLOT( compile()));
|
||||
popup->addAction( tr("Install") , this , SLOT( install()));
|
||||
popup->addAction( tr("Compile"), this, SLOT( compile()));
|
||||
popup->addAction( tr("Install"), this, SLOT( install()));
|
||||
|
||||
// popup->addSeparator();
|
||||
// popup->addAction( tr("Simulate install") , this , SLOT( simulateInstall()));
|
||||
// popup->addAction( tr("Simulate install"), this, SLOT( simulateInstall()));
|
||||
}
|
||||
|
||||
popup->addSeparator();
|
||||
QAction* lcID=popup->addAction( tr("Lock"), this ,
|
||||
QAction* lcID=popup->addAction( tr("Lock"), this,
|
||||
SLOT( lockObject() ) );
|
||||
QAction* unlcID=popup->addAction( tr("Unlock"), this ,
|
||||
QAction* unlcID=popup->addAction( tr("Unlock"), this,
|
||||
SLOT( unlockObject() ) );
|
||||
lcID->setEnabled(getCurrentObjectTree()->isLockable());
|
||||
unlcID->setEnabled(getCurrentObjectTree()->isUnlockable());
|
||||
@@ -1227,7 +1229,7 @@ QAction *movID;
|
||||
{
|
||||
/* keep this for debugging */
|
||||
popup->addSeparator();
|
||||
popup->addAction( tr("dump") , this , SLOT( dumpObj()));
|
||||
popup->addAction( tr("dump"), this, SLOT( dumpObj()));
|
||||
}
|
||||
|
||||
if (getCurrentObjectTree()->getNumSelected()==1)
|
||||
@@ -1317,7 +1319,7 @@ void ObjectManipulator::getMenuState(bool haveMoveTargets,
|
||||
//QString s2 = obj->getTypeName().c_str();
|
||||
}
|
||||
QString s3 = obj->getTypeName().c_str();
|
||||
FWObject *nobj=pasteTo( obj , co , false, true);
|
||||
FWObject *nobj=pasteTo( obj, co, false, true);
|
||||
pasteMenuItem = pasteMenuItem && (nobj!=NULL);
|
||||
}
|
||||
}
|
||||
@@ -2257,6 +2259,8 @@ void ObjectManipulator::info()
|
||||
|
||||
if (currentObj)
|
||||
{
|
||||
if (fwbdebug) qDebug("currentObj=%s", currentObj->getName().c_str());
|
||||
|
||||
m_project->info(currentObj, true); //forcing info window update
|
||||
active=true;
|
||||
}
|
||||
@@ -2275,6 +2279,8 @@ void ObjectManipulator::restoreSelection(bool same_widget)
|
||||
|
||||
void ObjectManipulator::editSelectedObject()
|
||||
{
|
||||
if (fwbdebug) qDebug("ObjectManipulator::editSelectedObject");
|
||||
|
||||
if (getCurrentObjectTree()->getNumSelected()==0) return;
|
||||
|
||||
FWObject *obj=getCurrentObjectTree()->getSelectedObjects().front();
|
||||
@@ -2293,6 +2299,8 @@ void ObjectManipulator::editSelectedObject()
|
||||
|
||||
bool ObjectManipulator::editObject(FWObject *obj)
|
||||
{
|
||||
if (fwbdebug) qDebug("ObjectManipulator::editObject");
|
||||
|
||||
/* if (RuleSet::isA (obj))
|
||||
{
|
||||
// if (m_project->getCurrentRuleSet()!=obj)
|
||||
@@ -2300,6 +2308,7 @@ bool ObjectManipulator::editObject(FWObject *obj)
|
||||
}
|
||||
*/
|
||||
if (!m_project->isEditorVisible()) m_project->showEditor();
|
||||
|
||||
/*
|
||||
QList<QMdiSubWindow *> subWindowList = mw->getMdiArea()->subWindowList();
|
||||
QString fileName = m_project->getRCS()->getFileName();
|
||||
@@ -2328,38 +2337,48 @@ bool ObjectManipulator::switchObjectInEditor(FWObject *obj)
|
||||
{
|
||||
if (fwbdebug) qDebug("ObjectManipulator::switchObjectInEditor");
|
||||
|
||||
if (obj && fwbdebug)
|
||||
{
|
||||
qDebug("obj: %s", obj->getName().c_str());
|
||||
FWObject *edt_obj = m_project->getOpenedEditor();
|
||||
if (edt_obj)
|
||||
qDebug("in editor: %s", edt_obj->getName().c_str());
|
||||
}
|
||||
|
||||
m_project->unselectRules();
|
||||
if (RuleSet::cast(obj)!=NULL)
|
||||
{
|
||||
// qDebug("!2");
|
||||
{
|
||||
if (obj!=m_project->getCurrentRuleSet())
|
||||
{
|
||||
// if (m_project->getCurrentRuleSet()!=NULL)
|
||||
m_project->openRuleSet(obj);
|
||||
m_project->openRuleSet(obj);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (!m_project->isEditorVisible()) return false;
|
||||
|
||||
if (!m_project->requestEditorOwnership(this,
|
||||
obj,
|
||||
ObjectEditor::optNone,
|
||||
true))
|
||||
if (!m_project->requestEditorOwnership(
|
||||
this, obj, ObjectEditor::optNone, true))
|
||||
{
|
||||
if (fwbdebug) qDebug("Can not get editor panel ownership");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fwbdebug) qDebug("Calling select");
|
||||
|
||||
select();
|
||||
|
||||
if (obj!=m_project->getOpenedEditor())
|
||||
if (obj != m_project->getOpenedEditor())
|
||||
{
|
||||
|
||||
if (fwbdebug) qDebug("Open object in editor");
|
||||
m_project->openEditor(obj);
|
||||
currentObj=obj;
|
||||
active=true;
|
||||
currentObj = obj;
|
||||
active = true;
|
||||
openObject(obj); // position the tree so that obj is visible
|
||||
// qDebug("!1");
|
||||
|
||||
if (fwbdebug) qDebug("Done");
|
||||
}
|
||||
|
||||
if (fwbdebug) qDebug("ObjectManipulator::switchObjectInEditor done");
|
||||
|
||||
return true; // successfully (re)opened obj in the editor
|
||||
}
|
||||
|
||||
@@ -2406,7 +2425,7 @@ void ObjectManipulator::selectionChanged(QTreeWidgetItem *cur)
|
||||
|
||||
if (otvi==NULL) return;
|
||||
|
||||
FWObject *obj=otvi->getFWObject();
|
||||
FWObject *obj = otvi->getFWObject();
|
||||
if (obj==NULL) return;
|
||||
|
||||
FWObject *o=obj;
|
||||
@@ -2727,7 +2746,7 @@ 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());
|
||||
@@ -3301,23 +3320,25 @@ bool ObjectManipulator::validateDialog()
|
||||
|
||||
void ObjectManipulator::select()
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectManipulator::select()");
|
||||
if (fwbdebug) qDebug("ObjectManipulator::select()");
|
||||
|
||||
if (currentObj==NULL) return;
|
||||
ObjectTreeViewItem *otvi=allItems[currentObj];
|
||||
|
||||
if (fwbdebug) qDebug("currentObj=%s", currentObj->getName().c_str());
|
||||
|
||||
ObjectTreeViewItem *otvi = allItems[currentObj];
|
||||
if (otvi)
|
||||
{
|
||||
otvi->setSelected(true);
|
||||
active=true;
|
||||
otvi->treeWidget()->setFocus();
|
||||
otvi->treeWidget()->update();
|
||||
// Commented out 07/15/08 --vk
|
||||
// otvi->setSelected(true);
|
||||
active = true;
|
||||
// otvi->treeWidget()->setFocus();
|
||||
// otvi->treeWidget()->update();
|
||||
}
|
||||
|
||||
m_project->updateRuleSetViewSelection();
|
||||
|
||||
if (fwbdebug)
|
||||
qDebug("/ObjectManipulator::select()");
|
||||
if (fwbdebug) qDebug("ObjectManipulator::select() done");
|
||||
}
|
||||
|
||||
void ObjectManipulator::unselect()
|
||||
|
||||
+75
-45
@@ -74,9 +74,13 @@ ObjectTreeView* ObjectTreeViewItem::getTree()
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
ObjectTreeView::ObjectTreeView(ProjectPanel* project, QWidget* parent, const char * name, Qt::WFlags f) :
|
||||
ObjectTreeView::ObjectTreeView(ProjectPanel* project,
|
||||
QWidget* parent,
|
||||
const char * name,
|
||||
Qt::WFlags f) :
|
||||
QTreeWidget(parent),
|
||||
singleClickTimer(this), m_project(project)
|
||||
singleClickTimer(this),
|
||||
m_project(project)
|
||||
{
|
||||
setObjectName(name);
|
||||
this->setParent(parent, f);
|
||||
@@ -108,23 +112,23 @@ ObjectTreeView::ObjectTreeView(ProjectPanel* project, QWidget* parent, const cha
|
||||
*/
|
||||
process_mouse_release_event = true;
|
||||
|
||||
connect( this, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
|
||||
this, SLOT(currentItemChanged(QTreeWidgetItem*)) );
|
||||
connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
|
||||
this, SLOT(currentItemChanged(QTreeWidgetItem*)));
|
||||
|
||||
connect( this, SIGNAL( itemSelectionChanged() ),
|
||||
this, SLOT( itemSelectionChanged() ) );
|
||||
connect(this, SIGNAL(itemSelectionChanged()),
|
||||
this, SLOT(itemSelectionChanged()));
|
||||
|
||||
connect(this, SIGNAL( itemCollapsed(QTreeWidgetItem*)),
|
||||
this, SLOT( itemCollapsed(QTreeWidgetItem*)) );
|
||||
connect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)),
|
||||
this, SLOT(itemCollapsed(QTreeWidgetItem*)));
|
||||
|
||||
connect(this, SIGNAL( itemExpanded(QTreeWidgetItem*)),
|
||||
this, SLOT( itemExpanded(QTreeWidgetItem*)) );
|
||||
connect(this, SIGNAL(itemExpanded(QTreeWidgetItem*)),
|
||||
this, SLOT(itemExpanded(QTreeWidgetItem*)));
|
||||
|
||||
connect( &singleClickTimer, SIGNAL( timeout() ),
|
||||
this, SLOT( resetSelection() ) );
|
||||
connect(&singleClickTimer, SIGNAL(timeout()),
|
||||
this, SLOT(resetSelection()));
|
||||
|
||||
connect( this, SIGNAL( itemActivated(QTreeWidgetItem *, int)),
|
||||
this, SLOT( itemOpened() ));
|
||||
connect(this, SIGNAL(itemActivated(QTreeWidgetItem *, int)),
|
||||
this, SLOT(itemOpened()));
|
||||
|
||||
setColumnCount(1);
|
||||
|
||||
@@ -166,7 +170,7 @@ bool ObjectTreeView::event( QEvent *event )
|
||||
FWObject *obj=NULL;
|
||||
QRect cr;
|
||||
|
||||
QTreeWidgetItem *itm = itemAt( QPoint(cx,cy - header()->height()) );
|
||||
QTreeWidgetItem *itm = itemAt(QPoint(cx, cy - header()->height()));
|
||||
if (itm==NULL) return false;
|
||||
ObjectTreeViewItem *oivi = dynamic_cast<ObjectTreeViewItem*>(itm);
|
||||
assert(oivi!=NULL);
|
||||
@@ -177,14 +181,17 @@ bool ObjectTreeView::event( QEvent *event )
|
||||
cr = visualItemRect(itm);
|
||||
|
||||
QRect global = QRect(
|
||||
viewport()->mapToGlobal(cr.topLeft()), viewport()->mapToGlobal(cr.bottomRight()));
|
||||
viewport()->mapToGlobal(cr.topLeft()),
|
||||
viewport()->mapToGlobal(cr.bottomRight()));
|
||||
|
||||
//finally stretch rect up to component's width and even more
|
||||
//(it fixes bug with horizontal scroll)
|
||||
global.setWidth(width() + horizontalOffset());
|
||||
|
||||
QToolTip::showText(mapToGlobal( he->pos() ),
|
||||
FWObjectPropertiesFactory::getObjectPropertiesDetailed(obj,true,true),
|
||||
FWObjectPropertiesFactory::getObjectPropertiesDetailed(obj,
|
||||
true,
|
||||
true),
|
||||
this, global);
|
||||
}
|
||||
|
||||
@@ -197,8 +204,8 @@ bool ObjectTreeView::event( QEvent *event )
|
||||
|
||||
void ObjectTreeView::currentItemChanged(QTreeWidgetItem *cur)
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectTreeView::currentChanged itm=%s",cur->text(0).toAscii().constData());
|
||||
if (fwbdebug) qDebug("ObjectTreeView::currentChanged itm=%s",
|
||||
cur->text(0).toAscii().constData());
|
||||
expandOrCollapse = false;
|
||||
|
||||
// lastSelected = ovi;
|
||||
@@ -208,14 +215,16 @@ void ObjectTreeView::currentItemChanged(QTreeWidgetItem *cur)
|
||||
void ObjectTreeView::itemCollapsed(QTreeWidgetItem* itm)
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectTreeView::collapsed itm=%s",itm->text(0).toAscii().constData());
|
||||
qDebug("ObjectTreeView::collapsed itm=%s",
|
||||
itm->text(0).toAscii().constData());
|
||||
expandOrCollapse = true;
|
||||
}
|
||||
|
||||
void ObjectTreeView::itemExpanded(QTreeWidgetItem* itm)
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectTreeView::expanded itm=%s",itm->text(0).toAscii().constData());
|
||||
qDebug("ObjectTreeView::expanded itm=%s",
|
||||
itm->text(0).toAscii().constData());
|
||||
expandOrCollapse = true;
|
||||
}
|
||||
|
||||
@@ -338,6 +347,9 @@ void ObjectTreeView::startDrag(Qt::DropActions supportedActions)
|
||||
|
||||
FWObject *current_obj = getCurrentObject();
|
||||
|
||||
if (fwbdebug) qDebug("ObjectTreeView::startDrag: this: %p current_obj: %s",
|
||||
this, current_obj->getName().c_str());
|
||||
|
||||
/* can't drag system folders
|
||||
|
||||
in fact, I have to allow to drag system folders because otherwise
|
||||
@@ -357,6 +369,11 @@ void ObjectTreeView::startDrag(Qt::DropActions supportedActions)
|
||||
for (vector<FWObject*>::iterator v=so.begin(); v!=so.end(); v++)
|
||||
{
|
||||
//m_project->check4Depends(*v, dragobj);
|
||||
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectTreeView::startDrag: adding object to drag list: %s",
|
||||
(*v)->getName().c_str());
|
||||
|
||||
dragobj.push_back( *v );
|
||||
}
|
||||
FWObjectDrag *drag = new FWObjectDrag(dragobj, this);
|
||||
@@ -474,7 +491,7 @@ void ObjectTreeView::dragMoveEvent( QDragMoveEvent *ev)
|
||||
if (isCurrReadOnly(ev) ||
|
||||
!ev->mimeData()->hasFormat(FWObjectDrag::FWB_MIME_TYPE))
|
||||
{
|
||||
qDebug("ObjectTreeView::itemOpened");
|
||||
qDebug("ObjectTreeView::dragMoveEvent");
|
||||
ev->setAccepted(false);
|
||||
return;
|
||||
}
|
||||
@@ -627,7 +644,6 @@ void ObjectTreeView::mouseReleaseEvent( QMouseEvent *e )
|
||||
|
||||
QTreeWidget::mouseReleaseEvent(e);
|
||||
|
||||
|
||||
if (!process_mouse_release_event)
|
||||
{
|
||||
// just do not switch object in the editor, otherwise
|
||||
@@ -666,21 +682,32 @@ void ObjectTreeView::mouseReleaseEvent( QMouseEvent *e )
|
||||
*/
|
||||
void ObjectTreeView::editCurrentObject()
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectTreeView::editCurrentObject");
|
||||
|
||||
if (fwbdebug) qDebug("ObjectTreeView::editCurrentObject");
|
||||
emit editCurrentObject_sign();
|
||||
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectTreeView::editCurrentObject done");
|
||||
if (fwbdebug) qDebug("ObjectTreeView::editCurrentObject done");
|
||||
}
|
||||
|
||||
// QAbstractItemView (base class of QTreeWidget) calls this when
|
||||
// element is double-clicked
|
||||
void ObjectTreeView::edit(const QModelIndex & index)
|
||||
{
|
||||
if (fwbdebug) qDebug("ObjectTreeView::edit ");
|
||||
|
||||
FWObject *obj = getCurrentObject();
|
||||
|
||||
/* system folders open on doubleclick, while for regular objects it
|
||||
* opens an editor
|
||||
*/
|
||||
if (m_project->isSystem(obj)) QTreeWidget::edit(index);
|
||||
else editCurrentObject();
|
||||
}
|
||||
|
||||
#if 0
|
||||
void ObjectTreeView::mouseDoubleClickEvent( QMouseEvent *e )
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectTreeView::mouseDoubleClickEvent");
|
||||
if (fwbdebug) qDebug("ObjectTreeView::mouseDoubleClickEvent");
|
||||
|
||||
second_click=true;
|
||||
second_click = true;
|
||||
singleClickTimer.stop();
|
||||
|
||||
FWObject *obj = getCurrentObject();
|
||||
@@ -693,6 +720,7 @@ void ObjectTreeView::mouseDoubleClickEvent( QMouseEvent *e )
|
||||
else
|
||||
editCurrentObject();
|
||||
}
|
||||
#endif
|
||||
|
||||
void ObjectTreeView::keyPressEvent( QKeyEvent* ev )
|
||||
{
|
||||
@@ -749,9 +777,7 @@ void ObjectTreeView::keyReleaseEvent( QKeyEvent* ev )
|
||||
|
||||
void ObjectTreeView::itemOpened ()
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectTreeView::itemOpened");
|
||||
|
||||
if (fwbdebug) qDebug("ObjectTreeView::itemOpened");
|
||||
editCurrentObject();
|
||||
}
|
||||
|
||||
@@ -782,20 +808,24 @@ void ObjectTreeView::itemSelectionChanged()
|
||||
|
||||
selectedObjects.clear();
|
||||
|
||||
QTreeWidgetItemIterator it(this);
|
||||
while ( *it )
|
||||
QList<QTreeWidgetItem*> selected = selectedItems();
|
||||
QList<QTreeWidgetItem*>::Iterator it;
|
||||
// QTreeWidgetItemIterator it(this);
|
||||
// while ( *it )
|
||||
for (it=selected.begin(); it!=selected.end(); it++)
|
||||
{
|
||||
if ((*it)->isSelected())
|
||||
{
|
||||
QTreeWidgetItem *itm= (*it);
|
||||
ObjectTreeViewItem *otvi=dynamic_cast<ObjectTreeViewItem*>(itm);
|
||||
// if ((*it)->isSelected())
|
||||
// {
|
||||
QTreeWidgetItem *itm = (*it);
|
||||
ObjectTreeViewItem *otvi = dynamic_cast<ObjectTreeViewItem*>(itm);
|
||||
|
||||
selectedObjects.push_back(otvi->getFWObject());
|
||||
|
||||
if (fwbdebug)
|
||||
qDebug("ObjectTreeView::selectionChanged: selected otvi=%p object %s", otvi, otvi->getFWObject()->getName().c_str());
|
||||
}
|
||||
++it;
|
||||
if (fwbdebug) qDebug(
|
||||
"ObjectTreeView::selectionChanged: selected otvi=%p object %s",
|
||||
otvi, otvi->getFWObject()->getName().c_str());
|
||||
// }
|
||||
// ++it;
|
||||
}
|
||||
setLockFlags();
|
||||
|
||||
|
||||
+13
-10
@@ -70,8 +70,10 @@ class ObjectTreeView : public QTreeWidget {
|
||||
std::vector<libfwbuilder::FWObject*> selectedObjects;
|
||||
ProjectPanel* m_project;
|
||||
bool isCurrReadOnly(QDragMoveEvent *ev);
|
||||
libfwbuilder::FWObject *getDropTarget(QDropEvent *ev, libfwbuilder::FWObject* dragobj);
|
||||
protected:
|
||||
libfwbuilder::FWObject *getDropTarget(
|
||||
QDropEvent *ev, libfwbuilder::FWObject* dragobj);
|
||||
|
||||
protected:
|
||||
|
||||
bool event( QEvent *event );
|
||||
|
||||
@@ -83,7 +85,7 @@ class ObjectTreeView : public QTreeWidget {
|
||||
virtual void keyPressEvent( QKeyEvent* ev );
|
||||
virtual void mousePressEvent( QMouseEvent *e );
|
||||
virtual void mouseReleaseEvent( QMouseEvent *e );
|
||||
virtual void mouseDoubleClickEvent( QMouseEvent *e );
|
||||
//virtual void mouseDoubleClickEvent( QMouseEvent *e );
|
||||
virtual void mouseMoveEvent( QMouseEvent *e );
|
||||
|
||||
virtual void keyReleaseEvent( QKeyEvent* ev );
|
||||
@@ -132,13 +134,14 @@ class ObjectTreeView : public QTreeWidget {
|
||||
|
||||
public slots:
|
||||
|
||||
void itemSelectionChanged();
|
||||
void resetSelection();
|
||||
void currentItemChanged(QTreeWidgetItem *cur);
|
||||
void itemCollapsed(QTreeWidgetItem *itm);
|
||||
void itemExpanded(QTreeWidgetItem *itm);
|
||||
void itemOpened ();
|
||||
virtual void updateTreeItems();
|
||||
void edit(const QModelIndex & index);
|
||||
void itemSelectionChanged();
|
||||
void resetSelection();
|
||||
void currentItemChanged(QTreeWidgetItem *cur);
|
||||
void itemCollapsed(QTreeWidgetItem *itm);
|
||||
void itemExpanded(QTreeWidgetItem *itm);
|
||||
void itemOpened ();
|
||||
virtual void updateTreeItems();
|
||||
|
||||
signals:
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
QVariant ObjectTreeViewItem::data (int column, int role) const
|
||||
QVariant ObjectTreeViewItem::data(int column, int role) const
|
||||
{
|
||||
if (role == Qt::FontRole)
|
||||
{
|
||||
@@ -62,11 +62,13 @@ QVariant ObjectTreeViewItem::data (int column, int role) const
|
||||
return QTreeWidgetItem::data(column, role);
|
||||
}
|
||||
|
||||
bool ObjectTreeViewItem::operator< ( const QTreeWidgetItem & other ) const
|
||||
bool ObjectTreeViewItem::operator<( const QTreeWidgetItem & other ) const
|
||||
{
|
||||
int rank1 = -1 ;
|
||||
int rank2 = -1;
|
||||
const ObjectTreeViewItem * otvi = dynamic_cast<const ObjectTreeViewItem*>(& other);
|
||||
const ObjectTreeViewItem * otvi =
|
||||
dynamic_cast<const ObjectTreeViewItem*>(& other);
|
||||
|
||||
if (otvi->objptr==NULL)
|
||||
return true ;
|
||||
if (objptr==NULL)
|
||||
|
||||
@@ -813,10 +813,6 @@ void ProjectPanel::fileClose()
|
||||
{
|
||||
if (fwbdebug) qDebug("ProjectPanel::fileClose(): start");
|
||||
|
||||
// These are called from closeEvent()
|
||||
// saveState();
|
||||
// storeLastOpenedLib();
|
||||
|
||||
closing=true ;
|
||||
|
||||
findObjectWidget->init();
|
||||
@@ -829,14 +825,7 @@ void ProjectPanel::fileClose()
|
||||
|
||||
if (fwbdebug) qDebug("ProjectPanel::fileClose(): clearing widgets");
|
||||
|
||||
#if 0
|
||||
firewalls.clear();
|
||||
visibleFirewall = NULL;
|
||||
visibleRuleSet = NULL;
|
||||
clearFirewallTabs();
|
||||
clearObjects();
|
||||
FWObjectClipboard::obj_clipboard->clear();
|
||||
#endif
|
||||
|
||||
mdiWindow->close();
|
||||
|
||||
@@ -845,7 +834,6 @@ void ProjectPanel::fileClose()
|
||||
visibleRuleSet = NULL;
|
||||
clearFirewallTabs();
|
||||
clearObjects();
|
||||
FWObjectClipboard::obj_clipboard->clear();
|
||||
|
||||
if (fwbdebug) qDebug("ProjectPanel::fileClose(): done");
|
||||
}
|
||||
@@ -3048,10 +3036,12 @@ void ProjectPanel::stateChanged(Qt::WindowStates oldState,
|
||||
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"
|
||||
|
||||
+11
-6
@@ -3810,8 +3810,8 @@ void RuleSetView::dragEnterEvent( QDragEnterEvent *ev)
|
||||
|
||||
void RuleSetView::dragMoveEvent( QDragMoveEvent *ev)
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug("RuleSetView::dragMoveEvent");
|
||||
// if (fwbdebug) qDebug("RuleSetView::dragMoveEvent");
|
||||
|
||||
QWidget *fromWidget = ev->source();
|
||||
|
||||
// The source of DnD object must be the same instance of fwbuilder
|
||||
@@ -3883,10 +3883,10 @@ void RuleSetView::dragMoveEvent( QDragMoveEvent *ev)
|
||||
}
|
||||
|
||||
|
||||
void RuleSetView::dropEvent( QDropEvent *ev)
|
||||
void RuleSetView::dropEvent(QDropEvent *ev)
|
||||
{
|
||||
if (fwbdebug)
|
||||
qDebug("RuleSetView::dropEvent");
|
||||
if (fwbdebug) qDebug("RuleSetView::dropEvent");
|
||||
|
||||
if (!isTreeReadWrite(this,ruleset)) return;
|
||||
|
||||
int row = rowAt( ev->pos().y() );
|
||||
@@ -3906,7 +3906,8 @@ void RuleSetView::dropEvent( QDropEvent *ev)
|
||||
|
||||
if (fwbdebug)
|
||||
{
|
||||
qDebug("RuleSetView::dropEvent drop event mode=%d", ev->proposedAction());
|
||||
qDebug("RuleSetView::dropEvent drop event mode=%d",
|
||||
ev->proposedAction());
|
||||
qDebug(" src widget = %p", ev->source());
|
||||
qDebug(" this = %p", this );
|
||||
}
|
||||
@@ -3920,6 +3921,10 @@ void RuleSetView::dropEvent( QDropEvent *ev)
|
||||
FWObject *dragobj = *i;
|
||||
assert(dragobj!=NULL);
|
||||
|
||||
if (fwbdebug)
|
||||
qDebug("RuleSetView::dropEvent dragobj=%s",
|
||||
dragobj->getName().c_str());
|
||||
|
||||
if (ev->source()!=this)
|
||||
{
|
||||
insertObjectFromOther(row, col, dragobj);
|
||||
|
||||
Reference in New Issue
Block a user