Salome HOME
Issue #2806: Provide correct selection with Shift button when Multi selector widget...
[modules/shaper.git] / src / XGUI / XGUI_Workshop.cpp
index 030a3b896e2c5b5b8e10bad0ec644e784ba42f4d..e3db137e014486486f5838eb1501c447bd5b4a17 100755 (executable)
@@ -170,8 +170,15 @@ QString XGUI_Workshop::MOVE_TO_END_COMMAND = QObject::tr("Move to the end");
 //#define DEBUG_FEATURE_NAME
 //#define DEBUG_CLEAN_HISTORY
 
-
-static QString MyFilter(QObject::tr("OpenParts files (*.opp)"));
+#ifdef HAVE_SALOME
+static QString MyFilter(QObject::tr("SHAPER files (*.shaper *.opp)"));
+static QString MyFilter2(QObject::tr("SHAPER files (*.shaper)"));
+static QString MyExtension(".shaper");
+#else
+static QString MyFilter(QObject::tr("OpenParts files (*.opp);;All files (*.*)"));
+static QString MyFilter2(QObject::tr("OpenParts files (*.opp)"));
+static QString MyExtension(".opp");
+#endif
 
 
 //******************************************************
@@ -289,8 +296,6 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
   //IMP: an attempt to use result selection with other selection modes
   myViewerSelMode.append(ModuleBase_ResultPrs::Sel_Result);//TopAbs_VERTEX);
   myViewerSelMode.append(TopAbs_COMPSOLID);
-
-  qDebug("### Tmp: %s", qPrintable(myTmpDir.path()));
 }
 
 //******************************************************
@@ -305,6 +310,8 @@ XGUI_Workshop::~XGUI_Workshop(void)
 
   delete myDisplayer;
   delete myDataModelXMLReader;
+  delete mySelectionActivate;
+  delete myMenuMgr;
   clearTemporaryDir();
 }
 
@@ -435,13 +442,13 @@ void XGUI_Workshop::initMenu()
 
   salomeConnector()->addDesktopMenuSeparator("MEN_DESK_EDIT");
 
-  aAction = salomeConnector()->addDesktopCommand("AUTOCOMPUTE_CMD", tr("Block auto-apply"),
+  aAction = salomeConnector()->addDesktopCommand("AUTOCOMPUTE_CMD", tr("Auto rebuild"),
                                               tr("Blocks immediate apply of modifications"),
                                               QIcon(":pictures/autoapply.png"), QKeySequence(),
-                                              true, "MEN_DESK_EDIT");
+                                              false, "MEN_DESK_EDIT");
   salomeConnector()->addActionInToolbar( aAction, aToolBarTitle );
 
-  connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onAutoApply(bool)));
+  connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onAutoApply()));
 
   salomeConnector()->addDesktopMenuSeparator("MEN_DESK_EDIT");
 
@@ -949,7 +956,8 @@ void XGUI_Workshop::openFile(const QString& theDirectory)
   aSession->closeAll();
 
   clearTemporaryDir();
-  XGUI_CompressFiles::uncompress(myCurrentFile, myTmpDir.path());
+  if (!XGUI_CompressFiles::uncompress(myCurrentFile, myTmpDir.path()))
+    return;
 
   aSession->load(myTmpDir.path().toLatin1().constData());
   myObjectBrowser->rebuildDataTree();
@@ -1067,7 +1075,8 @@ bool XGUI_Workshop::onSave()
 
   std::list<std::string> aFiles;
   saveDocument(myTmpDir.path(), aFiles);
-  XGUI_CompressFiles::compress(myCurrentFile, aFiles);
+  if (!XGUI_CompressFiles::compress(myCurrentFile, aFiles))
+    return false;
 
   updateCommandStatus();
 #ifndef HAVE_SALOME
@@ -1081,13 +1090,18 @@ bool XGUI_Workshop::onSaveAs()
 {
   if(!myOperationMgr->abortAllOperations(XGUI_OperationMgr::XGUI_InformationMessage))
     return false;
-#ifndef HAVE_SALOME
   myCurrentFile = QFileDialog::getSaveFileName(desktop(), tr("Select name to save file..."),
-    QString(), MyFilter);
+    QString(), MyFilter2);
   if (!myCurrentFile.isNull()) {
+    if (!myCurrentFile.endsWith(MyExtension)) {
+      myCurrentFile += MyExtension;
+    }
+  }
+  else
+    return false;
+#ifndef HAVE_SALOME
     myMainWindow->setCurrentDir(myCurrentFile, false);
     myMainWindow->setModifiedState(false);
-  }
 #endif
   return onSave();
 }
@@ -2709,9 +2723,7 @@ void XGUI_Workshop::highlightResults(const QObjectPtrList& theObjects)
   }
   if (aSelList.count() > theObjects.count()) {
     // if something was found
-    bool aBlocked = objectBrowser()->blockSignals(true);
     objectBrowser()->setObjectsSelected(aSelList);
-    objectBrowser()->blockSignals(aBlocked);
     objectBrowser()->ensureVisible(aNewSel.first());
   }
   if (aHasHidden)
@@ -2738,9 +2750,7 @@ void XGUI_Workshop::highlightFeature(const QObjectPtrList& theObjects)
   }
   if (aSelList.count() > theObjects.count()) {
     // if something was found
-    bool aBlocked = objectBrowser()->blockSignals(true);
     objectBrowser()->setObjectsSelected(aSelList);
-    objectBrowser()->blockSignals(aBlocked);
     objectBrowser()->ensureVisible(aNewSel.first());
   }
 }