#include "XGUI_ObjectsBrowser.h"
#include "XGUI_DocumentDataModel.h"
-//#include "XGUI_PartDataModel.h"
-
-//#include <ModelAPI_PluginManager.h>
-//#include <ModelAPI_Iterator.h>
-//#include <ModelAPI_Document.h>
-//#include <ModelAPI_Feature.h>
-//#include <ModelAPI_Object.h>
-//#include <Model_Document.h>
XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent)
: QTreeView(theParent)
{
setHeaderHidden(true);
- XGUI_DocumentDataModel* aDocModel = new XGUI_DocumentDataModel(this);
- //std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
- //std::shared_ptr<ModelAPI_Document> aDocument = aMgr->currentDocument();
- //aDocModel->setDocument(aDocument, 0);
- setModel(aDocModel);
+ myDocModel = new XGUI_DocumentDataModel(this);
+ setModel(myDocModel);
+
+ connect(selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
+ this, SLOT(onSelectionChanged(const QItemSelection&, const QItemSelection&)));
}
{
}
+
+
+void XGUI_ObjectsBrowser::onSelectionChanged(const QItemSelection& theSelected,
+ const QItemSelection& theDeselected)
+{
+ mySelectedData.clear();
+ QModelIndexList aIndexes = selectionModel()->selectedIndexes();
+ QModelIndexList::const_iterator aIt;
+ for (aIt = aIndexes.constBegin(); aIt != aIndexes.constEnd(); ++aIt) {
+ FeaturePtr aFeature = myDocModel->feature(*aIt);
+ if (aFeature)
+ mySelectedData.append(aFeature);
+ }
+ emit selectionChanged();
+}
\ No newline at end of file