bool NewGeom_DataModel::close()
{
- SessionPtr aMgr = ModelAPI_Session::get();
- aMgr->moduleDocument()->close();
+ myModule->workshop()->closeDocument();
return LightApp_DataModel::close();
}
XGUI_DocumentDataModel::~XGUI_DocumentDataModel()
{
clearModelIndexes();
+ clearSubModels();
}
void XGUI_DocumentDataModel::processEvent(const boost::shared_ptr<Events_Message>& theMessage)
}
} else { // if sub-objects of first level nodes
XGUI_PartModel* aPartModel = 0;
- QList<XGUI_PartModel*>::const_iterator aIt;
- for (aIt = myPartModels.constBegin(); aIt != myPartModels.constEnd(); ++aIt) {
- if ((*aIt)->hasDocument(aDoc)) {
- aPartModel = (*aIt);
+ foreach (XGUI_PartModel* aPart, myPartModels) {
+ if (aPart->hasDocument(aDoc)) {
+ aPartModel = aPart;
break;
}
}
}
} else {
XGUI_PartModel* aPartModel = 0;
- QList<XGUI_PartModel*>::const_iterator aIt;
- for (aIt = myPartModels.constBegin(); aIt != myPartModels.constEnd(); ++aIt) {
- if ((*aIt)->hasDocument(aDoc)) {
- aPartModel = (*aIt);
+ foreach (XGUI_PartModel* aPart, myPartModels) {
+ if (aPart->hasDocument(aDoc)) {
+ aPartModel = aPart;
break;
}
}
void XGUI_DocumentDataModel::clearModelIndexes()
{
- QList<QModelIndex*>::const_iterator aIt;
- for (aIt = myIndexes.constBegin(); aIt != myIndexes.constEnd(); ++aIt)
- delete (*aIt);
+ foreach (QModelIndex* aIndex, myIndexes)
+ delete aIndex;
myIndexes.clear();
}
+void XGUI_DocumentDataModel::clearSubModels()
+{
+ foreach (XGUI_PartModel* aPart, myPartModels)
+ delete aPart;
+ myPartModels.clear();
+}
+
ObjectPtr XGUI_DocumentDataModel::object(const QModelIndex& theIndex) const
{
if (theIndex.internalId() == PartsFolder)
}
return QModelIndex();
}
+
+
+void XGUI_DocumentDataModel::clear()
+{
+ clearModelIndexes();
+ clearSubModels();
+ myActivePart = 0;
+ myActivePartIndex = QModelIndex();
+ myModel->setItemsColor(ACTIVE_COLOR);
+}
void rebuildDataTree();
+ //! Clear internal data
+ void clear();
+
+
private:
enum
//! Deletes all saved pointers on QModelIndex objects.
void clearModelIndexes();
+ //! Deletes all saved pointers on QModelIndex objects.
+ void clearSubModels();
+
//! Removes sub-model on removing a part object. Also it removes QModelIndex-es which refer to this model
void removeSubModel(int theModelId);
}
}
+void XGUI_DataTree::clear()
+{
+ mySelectedData.clear();
+ XGUI_DocumentDataModel* aModel = dataModel();
+ aModel->clear();
+ reset();
+}
+
//********************************************************************
//********************************************************************
//********************************************************************
{
myDocModel->processEvent(theMessage);
}
+
+
+//***************************************************
+void XGUI_ObjectsBrowser::clearContent()
+{
+ myObjectsList.clear();
+ myTreeView->clear();
+}
//! Emited on context menu request
void contextMenuRequested(QContextMenuEvent* theEvent);
+public slots:
+ virtual void clear();
+
protected slots:
virtual void commitData(QWidget* theEditor);
void processEvent(const boost::shared_ptr<Events_Message>& theMessage);
+ // Resets the object browser into initial state
+ void clearContent();
+
signals:
//! Emited when selection is changed
void selectionChanged();
if (theList.size() > 0)
myDisplayer->updateViewer();
}
+
+//**************************************************************
+void XGUI_Workshop::closeDocument()
+{
+ myDisplayer->closeLocalContexts();
+ myDisplayer->eraseAll();
+ objectBrowser()->clearContent();
+
+ SessionPtr aMgr = ModelAPI_Session::get();
+ aMgr->moduleDocument()->close();
+ objectBrowser()->clearContent();
+}
void activateLastPart();
+ void closeDocument();
+
protected:
bool event(QEvent * theEvent);
//Event-loop processing methods: