mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-03-19 17:57:22 +01:00
see #1895 added context menu item Expand/Collapse
This commit is contained in:
parent
5e099e5c97
commit
da2c04e6f4
@ -1,5 +1,16 @@
|
||||
2011-02-12 vadim <vadim@netcitadel.com>
|
||||
|
||||
* ObjectManipulator_tree_ops.cpp (expandOrCollapseCurrentTreeNode):
|
||||
fixes #1895 "Add context menu option to expand all child nodes in
|
||||
object tree". Added menu item "Expand" to the context menu
|
||||
associated with all objects in the object tree. This item recursively
|
||||
expands all tree nodes under the given object and automatically
|
||||
changes to "Collapse" if the item is expanded. Also changed behavior
|
||||
of the double click on the object in tree: before, double click
|
||||
opened object in the editor and expanded or collapsed subtree. Now
|
||||
it only opens object in the editor but does not expand/collapse
|
||||
subtree.
|
||||
|
||||
* fixes #2083 Added new services to the Standard Objects Library:
|
||||
rtmp, xmpp-client, xmpp-server, nrpe
|
||||
|
||||
|
||||
@ -363,6 +363,17 @@ void ObjectManipulator::contextMenuRequested(const QPoint &pos)
|
||||
|
||||
popup_menu->clear();
|
||||
|
||||
if (item->childCount() > 0)
|
||||
{
|
||||
if (item->isExpanded())
|
||||
popup_menu->addAction(tr("Collapse"), this,
|
||||
SLOT(collapseCurrentTreeNode()));
|
||||
else
|
||||
popup_menu->addAction(tr("Expand"), this,
|
||||
SLOT(expandCurrentTreeNode()));
|
||||
popup_menu->addSeparator();
|
||||
}
|
||||
|
||||
QAction *edtID;
|
||||
|
||||
if (currentObj->isReadOnly())
|
||||
@ -1245,10 +1256,9 @@ void ObjectManipulator::showObjectInTree(ObjectTreeViewItem *otvi)
|
||||
m_objectManipulator->widgetStack->setCurrentWidget(otv);
|
||||
|
||||
otvi->getTree()->clearSelection();
|
||||
otvi->getTree()->scrollToItem(otvi,
|
||||
QAbstractItemView::PositionAtTop); // QAbstractItemView::EnsureVisible );
|
||||
otvi->getTree()->setCurrentItem( otvi );
|
||||
otvi->setSelected( true );
|
||||
otvi->getTree()->scrollToItem(otvi, QAbstractItemView::PositionAtTop);
|
||||
otvi->getTree()->setCurrentItem(otvi);
|
||||
otvi->setSelected(true);
|
||||
otvi->getTree()->setFocus(Qt::OtherFocusReason);
|
||||
}
|
||||
|
||||
@ -1259,13 +1269,8 @@ void ObjectManipulator::expandObjectInTree(FWObject *obj)
|
||||
|
||||
QTreeWidgetItem *it = allItems[o];
|
||||
if (it==NULL) return;
|
||||
it->setExpanded(true);
|
||||
|
||||
for (list<FWObject*>::iterator i=o->begin(); i!=o->end(); ++i)
|
||||
{
|
||||
FWObject *o1 = *i;
|
||||
if (o1 && o1->size() > 0) expandObjectInTree(o1);
|
||||
}
|
||||
expandOrCollapseCurrentTreeNode(it, true);
|
||||
}
|
||||
|
||||
void ObjectManipulator::libChangedById(int obj_id)
|
||||
|
||||
@ -132,6 +132,8 @@ class ObjectManipulator : public QWidget
|
||||
|
||||
void makeNameUnique(libfwbuilder::FWObject* p,libfwbuilder::FWObject* obj);
|
||||
|
||||
void expandOrCollapseCurrentTreeNode(QTreeWidgetItem*, bool);
|
||||
|
||||
/* find the name of the interface that was created last */
|
||||
QString findNewestInterfaceName(libfwbuilder::FWObject *parent);
|
||||
|
||||
@ -177,6 +179,9 @@ public slots:
|
||||
virtual void switchingTrees(QWidget* w);
|
||||
virtual void currentTreePageChanged(int i);
|
||||
|
||||
void expandCurrentTreeNode();
|
||||
void collapseCurrentTreeNode();
|
||||
|
||||
void newClusterFromSelected();
|
||||
|
||||
void selectionChanged(QTreeWidgetItem *cur);
|
||||
|
||||
@ -171,6 +171,29 @@ QString ObjectManipulator::getTreeLabel(FWObject *obj, int col)
|
||||
return "";
|
||||
}
|
||||
|
||||
void ObjectManipulator::expandOrCollapseCurrentTreeNode(QTreeWidgetItem *item,
|
||||
bool expand)
|
||||
{
|
||||
item->setExpanded(expand);
|
||||
for (int i=0; i<item->childCount(); ++i)
|
||||
expandOrCollapseCurrentTreeNode(item->child(i), expand);
|
||||
}
|
||||
|
||||
void ObjectManipulator::expandCurrentTreeNode()
|
||||
{
|
||||
if (getCurrentObjectTree()->getNumSelected()==0) return;
|
||||
QTreeWidgetItem *item = getCurrentObjectTree()->currentItem();
|
||||
expandOrCollapseCurrentTreeNode(item, true);
|
||||
}
|
||||
|
||||
void ObjectManipulator::collapseCurrentTreeNode()
|
||||
{
|
||||
if (getCurrentObjectTree()->getNumSelected()==0) return;
|
||||
QTreeWidgetItem *item = getCurrentObjectTree()->currentItem();
|
||||
expandOrCollapseCurrentTreeNode(item, false);
|
||||
}
|
||||
|
||||
|
||||
ObjectTreeViewItem* ObjectManipulator::insertObject(ObjectTreeViewItem *itm,
|
||||
FWObject *obj)
|
||||
{
|
||||
|
||||
@ -83,6 +83,9 @@ ObjectTreeView::ObjectTreeView(ProjectPanel* project,
|
||||
setObjectName(name);
|
||||
this->setParent(parent, f);
|
||||
setFont(st->getTreeFont());
|
||||
|
||||
setExpandsOnDoubleClick(false);
|
||||
|
||||
// setAcceptDrops( TRUE );
|
||||
item_before_drag_started=NULL;
|
||||
lastSelected = NULL;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user