aLabelWgt->setPalette(aPalet);
myDocModel = new XGUI_DataModel(this);
- myTreeView->setModel(myDocModel);
-
- // It has to be done after setting of model
- myActiveDocLbl->setTreeView(myTreeView);
-
- QItemSelectionModel* aSelMod = myTreeView->selectionModel();
- connect(aSelMod, SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
- this, SLOT(onSelectionChanged(const QItemSelection&, const QItemSelection&)));
+ connect(myDocModel, SIGNAL(modelAboutToBeReset()), SLOT(onBeforeReset()));
+ connect(myDocModel, SIGNAL(treeRebuilt()), SLOT(onAfterModelReset()));
connect(myTreeView, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this,
SLOT(onContextMenuRequested(QContextMenuEvent*)));
{
}
+void XGUI_ObjectsBrowser::setXMLReader(Config_DataModelReader* theReader)
+{
+ myDocModel->setXMLReader(theReader);
+ myTreeView->setModel(myDocModel);
+
+ // It has to be done after setting of model
+ myActiveDocLbl->setTreeView(myTreeView);
+
+ QItemSelectionModel* aSelMod = myTreeView->selectionModel();
+ connect(aSelMod, SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
+ this, SLOT(onSelectionChanged(const QItemSelection&, const QItemSelection&)));
+}
//***************************************************
void XGUI_ObjectsBrowser::onContextMenuRequested(QContextMenuEvent* theEvent)
{
QModelIndexList aIndexes;
QModelIndex aIndex;
- for (int i = 0; i < myDocModel->rowCount(); i++) {
+ for (int i = 0; i < myDocModel->rowCount(theParent); i++) {
aIndex = myDocModel->index(i, 0, theParent);
if (myDocModel->hasChildren(aIndex)) {
if (myTreeView->isExpanded(aIndex)) {
//***************************************************
void XGUI_ObjectsBrowser::rebuildDataTree()
{
- QModelIndexList aIndexList = expandedItems();
myDocModel->rebuildDataTree();
- foreach(QModelIndex aIndex, aIndexList) {
- myTreeView->setExpanded(aIndex, true);
- }
update();
}
}
}
return aList;
-}
\ No newline at end of file
+}
+
+void XGUI_ObjectsBrowser::onBeforeReset()
+{
+ myExpandedItems = expandedItems();
+}
+
+void XGUI_ObjectsBrowser::onAfterModelReset()
+{
+ foreach(QModelIndex aIndex, myExpandedItems) {
+ myTreeView->setExpanded(aIndex, true);
+ }
+}