From: <su...@us...> - 2008-06-17 14:13:55
|
Revision: 2853 http://tora.svn.sourceforge.net/tora/?rev=2853&view=rev Author: subik Date: 2008-06-17 07:13:55 -0700 (Tue, 17 Jun 2008) Log Message: ----------- select children in the tree when the parent gets selection Modified Paths: -------------- branches/1.4-extract/src/toscriptschemawidget.cpp branches/1.4-extract/src/toscriptschemawidget.h Modified: branches/1.4-extract/src/toscriptschemawidget.cpp =================================================================== --- branches/1.4-extract/src/toscriptschemawidget.cpp 2008-06-17 11:12:57 UTC (rev 2852) +++ branches/1.4-extract/src/toscriptschemawidget.cpp 2008-06-17 14:13:55 UTC (rev 2853) @@ -41,6 +41,7 @@ #include "tomain.h" #include "toconnection.h" #include "toscripttreemodel.h" +#include "toscripttreeitem.h" #include "toscriptschemawidget.h" @@ -76,6 +77,11 @@ this, SLOT(addConnection(const QString &))); connect(toMainWidget(), SIGNAL(removedConnection(const QString &)), this, SLOT(delConnection(const QString &))); + + connect(ObjectsView->selectionModel(), + SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), + this, + SLOT(objectsView_selectionChanged(const QItemSelection &, const QItemSelection &))); }; void toScriptSchemaWidget::setTitle(const QString & text) @@ -136,3 +142,43 @@ { return ObjectsView->selectionModel(); } + +void toScriptSchemaWidget::objectsView_selectionChanged(const QItemSelection & selected, + const QItemSelection & deselected) +{ + // all other widgets are disabled until it ends + SchemaComboBox->setEnabled(false); + ConnectionComboBox->setEnabled(false); +// QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + + foreach (QModelIndex i, selected.indexes()) + subSelectionChanged(i); + + +// QApplication::restoreOverrideCursor(); + SchemaComboBox->setEnabled(true); + ConnectionComboBox->setEnabled(true); +} + +void toScriptSchemaWidget::subSelectionChanged(QModelIndex ix) +{ + QCoreApplication::processEvents(); + + QItemSelectionModel * sel = ObjectsView->selectionModel(); + toScriptTreeItem * item = static_cast<toScriptTreeItem*>(ix.internalPointer()); + toScriptTreeItem * subItem; + QModelIndex subIx; + + for (int i = 0; i < item->childCount(); ++i) + { + subIx = Model->index(i, 0, ix); + subItem = static_cast<toScriptTreeItem*>(subIx.internalPointer()); + + if (!sel->isSelected(subIx)) + sel->select(subIx, QItemSelectionModel::Select); + + if (subItem->childCount() > 0) + subSelectionChanged(subIx); + } +} + Modified: branches/1.4-extract/src/toscriptschemawidget.h =================================================================== --- branches/1.4-extract/src/toscriptschemawidget.h 2008-06-17 11:12:57 UTC (rev 2852) +++ branches/1.4-extract/src/toscriptschemawidget.h 2008-06-17 14:13:55 UTC (rev 2853) @@ -73,6 +73,8 @@ private: //! Model for ObjectView QTreeView toScriptTreeModel * Model; + //! Select ObjectView's child items in recursion + void subSelectionChanged(QModelIndex ix); private slots: /*! Handle changes in ConnectionComboBox. @@ -87,6 +89,9 @@ void addConnection(const QString &name); //! Delete a connection as requested from toMain void delConnection(const QString &name); + + void objectsView_selectionChanged(const QItemSelection &, + const QItemSelection &); }; #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |