0029748: Samples - Inspector tool - use recently opened files in TInspectorEXE
authornds <nds@opencascade.com>
Tue, 8 May 2018 17:21:08 +0000 (20:21 +0300)
committerabv <abv@opencascade.com>
Wed, 23 May 2018 16:09:35 +0000 (19:09 +0300)
- recently files using in open file dialog
- correction of TInspectorEXE title to show opened file path by Start

14 files changed:
tools/DFBrowser/DFBrowser_Window.cxx
tools/DFBrowser/DFBrowser_Window.hxx
tools/ShapeView/ShapeView_Window.cxx
tools/TInspector/TInspector_Communicator.hxx
tools/TInspector/TInspector_PluginParameters.hxx
tools/TInspector/TInspector_Preferences.cxx
tools/TInspector/TInspector_Window.cxx
tools/TInspector/TInspector_Window.hxx
tools/TInspectorAPI/TInspectorAPI_PluginParameters.hxx
tools/TInspectorEXE/TInspectorEXE.cxx
tools/TInspectorEXE/TInspectorEXE_OpenFileDialog.cxx
tools/TInspectorEXE/TInspectorEXE_OpenFileDialog.hxx
tools/TInspectorEXE/TInspectorEXE_OpenFileViewModel.cxx
tools/VInspector/VInspector_Window.cxx

index 3ef9e4f..5801326 100644 (file)
@@ -222,6 +222,9 @@ void DFBrowser_Window::SetParent (void* theParent)
     QLayout* aLayout = myParent->layout();
     if (aLayout)
       aLayout->addWidget (GetMainWindow());
+
+    if (!myOpenedFileName.isEmpty())
+      myParent->setObjectName(myOpenedFileName);
   }
 }
 
@@ -247,7 +250,6 @@ void DFBrowser_Window::FillActionsMenu (void* theMenu)
 // =======================================================================
 void DFBrowser_Window::GetPreferences (TInspectorAPI_PreferencesDataMap& theItem)
 {
-  theItem.Clear();
   theItem.Bind ("geometry",  TreeModel_Tools::ToString (myMainWindow->saveState()).toStdString().c_str());
 
   QMap<QString, QString> anItems;
@@ -498,6 +500,8 @@ void DFBrowser_Window::OpenFile (const TCollection_AsciiString& theFileName)
   
   if (myParent)
     myParent->setObjectName (isSTEPFileName ? QString (TCollection_AsciiString (theFileName).ToCString()) : getWindowTitle());
+  else
+    myOpenedFileName = isSTEPFileName ? QString(TCollection_AsciiString(theFileName).ToCString()) : getWindowTitle();
 
   if (anApplication.IsNull())
   {
index 9e66ad6..93fb3d7 100644 (file)
@@ -226,6 +226,7 @@ private:
   DFBrowser_Thread* myThread; //!< Threads manipulator, starting thread items, listens finalizing
   ViewControl_MessageDialog* myExportToShapeViewDialog; //!< dialog about exporting TopoDS_Shape to ShapeView plugin
   Handle(TInspectorAPI_PluginParameters) myParameters; //!< contains application, context, files that should be opened
+  QString myOpenedFileName; //!< cached name of opened file between parent is set, apply it by parent setting and nullify
 };
 
 #endif
index 7ec1c82..76eaefa 100644 (file)
@@ -167,7 +167,6 @@ void ShapeView_Window::FillActionsMenu (void* theMenu)
 // =======================================================================
 void ShapeView_Window::GetPreferences (TInspectorAPI_PreferencesDataMap& theItem)
 {
-  theItem.Clear();
   theItem.Bind ("geometry",  TreeModel_Tools::ToString (myMainWindow->saveState()).toStdString().c_str());
 
   QMap<QString, QString> anItems;
index da88bb6..bd5fbc7 100644 (file)
@@ -17,6 +17,7 @@
 #define TInspector_Communicator_H
 
 #include <inspector/TInspector_Window.hxx>
+#include <inspector/TInspectorAPI_PluginParameters.hxx>
 
 #include <NCollection_List.hxx>
 #include <Standard.hxx>
@@ -107,8 +108,10 @@ public:
   //! \param theStream stream for output
   void Dump (Standard_OStream& theStream) const { return myWindow->Dump (theStream); }
 
-private:
+  //! Returns plugins parameters container
+  Handle(TInspectorAPI_PluginParameters) const GetPluginParameters() { return myWindow->GetPluginParameters(); }
 
+private:
   TInspector_Window* myWindow; //!< current window
 };
 
index fcc29dc..0f1810e 100644 (file)
@@ -63,7 +63,7 @@ public:
    { myPreferences->SetPreferences (thePluginName, theItem); }
 
   //! Store plugin preferences into a preferences file
-  void StorePreferences() { myPreferences->StorePreferences(); }
+  virtual void StorePreferences() Standard_OVERRIDE { myPreferences->StorePreferences(); }
 
   //! Remove plugin preferences file
   void RemovePreferences() { myPreferences->RemovePreferences(); }
index 3ccf899..c335fab 100644 (file)
@@ -31,7 +31,6 @@
 void TInspector_Preferences::GetPreferences (const TCollection_AsciiString& thePluginName,
                                              TInspectorAPI_PreferencesDataMap& theItem)
 {
-  theItem.Clear();
   if (!myIsLoadedPreferences)
   {
     loadPreferences();
index 76eacae..8bb89ab 100644 (file)
@@ -366,8 +366,7 @@ bool TInspector_Window::LoadPlugin (const TCollection_AsciiString& thePluginName
 // =======================================================================
 void TInspector_Window::GetPreferences (TInspectorAPI_PreferencesDataMap& theItem)
 {
-  theItem.Clear();
-  theItem.Bind ("geometry",  TreeModel_Tools::ToString (myMainWindow->saveGeometry()).toStdString().c_str());
+  theItem.Bind ("geometry", TreeModel_Tools::ToString (myMainWindow->saveGeometry()).toStdString().c_str());
 }
 
 // =======================================================================
@@ -414,6 +413,7 @@ void TInspector_Window::OnStorePreferences()
     if (!anInfo.myCommunicator)
       continue;
 
+    aParameters->GetPreferences (anInfo.myName, aPreferences);
     anInfo.myCommunicator->GetPreferences (aPreferences);
     myParameters->SetPreferences (anInfo.myName, aPreferences);
   }
index 3c54730..4e7e50b 100644 (file)
@@ -129,6 +129,10 @@ public:
   //! \return path
   TCollection_AsciiString GetTemporaryDirectory() const { return myParameters->GetTemporaryDirectory(); }
 
+  //! Returns plugins parameters container
+  //! \return instance of parameters container
+  Handle(TInspectorAPI_PluginParameters) GetPluginParameters() const { return myParameters; }
+
   //! Returns plugin preferences: dock widgets state, tree view columns.
   //! \param theItem container of preference elements
   Standard_EXPORT void GetPreferences (TInspectorAPI_PreferencesDataMap& theItem);
index 5131569..c92b518 100644 (file)
@@ -131,6 +131,9 @@ public:
   Standard_EXPORT virtual void SetPreferences (const TCollection_AsciiString& thePluginName,
                                                const TInspectorAPI_PreferencesDataMap& theItem) = 0;
 
+  //! Store plugin preferences into a preferences file
+  Standard_EXPORT virtual void StorePreferences() = 0;
+
   //! Converts a Shape parameters excepting TShape into a string value
   //! \param theShape processed shape 
   //! \return string instance
index 9a65a56..10dcf4b 100644 (file)
 // function : fileNameInDataDir
 // purpose :
 // =======================================================================
-TCollection_AsciiString fileNameInDataDir(const TCollection_AsciiString& theEnvironmentDir,
-                                              const TCollection_AsciiString& theName)
+TCollection_AsciiString fileNameInDataDir (const TCollection_AsciiString& theEnvironmentDir,
+                                           const TCollection_AsciiString& theName)
 {
-  OSD_Environment anEnvironment(theEnvironmentDir);
+  OSD_Environment anEnvironment (theEnvironmentDir);
   
   TCollection_AsciiString aFileName = anEnvironment.Value();
-  aFileName += TCollection_AsciiString("/") + theName;
+  aFileName += TCollection_AsciiString ("/") + theName;
 
   return aFileName;
 }
@@ -52,22 +52,31 @@ TCollection_AsciiString fileNameInDataDir(const TCollection_AsciiString& theEnvi
 void setPluginSampleDirectory (const TCollection_AsciiString& theName, TInspector_Communicator* theCommunicator,
                                TInspectorEXE_OpenButton* theButtonControl)
 {
-  if (theName.IsEqual ("TKDFBrowser"))
+  QStringList aRecentlyOpenedFiles;
+  TInspectorEXE_OpenFileDialog::GetPluginRecentlyOpenedFiles (theName, theCommunicator, aRecentlyOpenedFiles);
+  TCollection_AsciiString aFileName, anAdditionalFileName;
+  if (!aRecentlyOpenedFiles.isEmpty())
+    aFileName = TCollection_AsciiString (aRecentlyOpenedFiles.last().toUtf8().data());
+  if (aFileName.IsEmpty())
   {
-    theCommunicator->OpenFile (theName, fileNameInDataDir ("CSF_OCCTDataPath", "step/screw.step"));
-    theButtonControl->SetPluginDir (theName, fileNameInDataDir ("CSF_OCCTDataPath", "step"));
-  }
-  else if (theName.IsEqual ("TKShapeView"))
-  {
-    theCommunicator->OpenFile (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ/hammer.brep"));
-    theButtonControl->SetPluginDir (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ"));
-  }
-  else if (theName.IsEqual ("TKVInspector"))
-  {
-    theCommunicator->OpenFile (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ/face1.brep"));
-    theCommunicator->OpenFile (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ/face2.brep"));
-    theButtonControl->SetPluginDir (theName, fileNameInDataDir ("CSF_OCCTDataPath", "occ"));
+    if (theName.IsEqual ("TKDFBrowser"))
+      aFileName = fileNameInDataDir ("CSF_OCCTDataPath", "step/screw.step");
+    else if (theName.IsEqual ("TKShapeView"))
+      aFileName = fileNameInDataDir ("CSF_OCCTDataPath", "occ/hammer.brep");
+    else if (theName.IsEqual ("TKVInspector"))
+    {
+      aFileName = fileNameInDataDir ("CSF_OCCTDataPath", "occ/face1.brep");
+      anAdditionalFileName = fileNameInDataDir ("CSF_OCCTDataPath", "occ/face2.brep");
+    }
+    aRecentlyOpenedFiles.append (aFileName.ToCString());
+    if (!anAdditionalFileName.IsEmpty())
+      aRecentlyOpenedFiles.append (anAdditionalFileName.ToCString());
   }
+  theCommunicator->OpenFile (theName, aFileName.ToCString());
+  if (!anAdditionalFileName.IsEmpty())
+    theCommunicator->OpenFile (theName, anAdditionalFileName);
+
+  theButtonControl->SetPluginRecentlyOpenedFiles (theName, aRecentlyOpenedFiles);
 }
 
 // =======================================================================
index 618f16a..2393827 100644 (file)
@@ -47,6 +47,8 @@ const int OPEN_DIALOG_HEIGHT = 200;
 const int MARGIN_DIALOG = 4;
 const int SPACING_DIALOG = 2;
 
+const int RECENT_FILES_CACHE_SIZE = 10;
+
 TInspector_Communicator* MyCommunicator;
 
 // =======================================================================
@@ -75,15 +77,36 @@ void TInspectorEXE_OpenButton::onStartButtonClicked()
   if (aPluginName.IsEmpty())
     return;
   
-  QString aDataDirName = QDir::currentPath();
-  if (myDefaultDirs.IsBound (aPluginName))
-    aDataDirName = myDefaultDirs.Find (aPluginName).ToCString();
+  QStringList aPluginRecentlyOpenedFiles;
+  if (myRecentlyOpenedFiles.contains(aPluginName))
+  {
+    QStringList aFileNames = myRecentlyOpenedFiles[aPluginName];
+    for (int i = 0; i < aFileNames.size(); i++)
+    {
+      QFileInfo aFileInfo (aFileNames[i]);
+      if (aFileInfo.exists() && aFileInfo.isFile())
+        aPluginRecentlyOpenedFiles.append(aFileInfo.absoluteFilePath());
+    }
+  }
 
-  QString aFileName = TInspectorEXE_OpenFileDialog::OpenFile (0, aDataDirName);
+  QString aFileName = TInspectorEXE_OpenFileDialog::OpenFile (0, aPluginRecentlyOpenedFiles);
   aFileName = QDir().toNativeSeparators (aFileName);
   if (!aFileName.isEmpty()) {
     QApplication::setOverrideCursor (Qt::WaitCursor);
     TInspectorEXE_OpenFileDialog::Communicator()->OpenFile (aPluginName, TCollection_AsciiString (aFileName.toUtf8().data()));
+
+    QFileInfo aFileInfo (aFileName);
+    if (!aPluginRecentlyOpenedFiles.contains (aFileInfo.absoluteFilePath()))
+    {
+      myRecentlyOpenedFiles[aPluginName].append (aFileInfo.absoluteFilePath());
+      for (int i = 0; i < myRecentlyOpenedFiles[aPluginName].size() - RECENT_FILES_CACHE_SIZE; i++)
+        myRecentlyOpenedFiles[aPluginName].removeFirst();
+      TInspectorEXE_OpenFileDialog::SetPluginRecentlyOpenedFiles (aPluginName,
+        TInspectorEXE_OpenFileDialog::Communicator(), myRecentlyOpenedFiles[aPluginName]);
+
+      TInspectorEXE_OpenFileDialog::Communicator()->GetPluginParameters()->StorePreferences();
+    }
+
     QApplication::restoreOverrideCursor();
   }
 }
@@ -102,26 +125,21 @@ void changeMargins (QBoxLayout* theLayout)
 // function : Constructor
 // purpose :
 // =======================================================================
-TInspectorEXE_OpenFileDialog::TInspectorEXE_OpenFileDialog (QWidget* theParent, const QString& theDataDirName)
-: QDialog(theParent), myDataDir (theDataDirName)
+TInspectorEXE_OpenFileDialog::TInspectorEXE_OpenFileDialog (QWidget* theParent, const QStringList& theRecentlyOpenedFiles)
+: QDialog (theParent), myRecentlyOpenedFiles (theRecentlyOpenedFiles)
 {
-  setWindowTitle (theDataDirName);
+  setWindowTitle (tr ("Open File"));
 
   QVBoxLayout* aDialogLay = new QVBoxLayout (this);
   changeMargins (aDialogLay);
 
-  // Title label
-  QLabel* aTitleLabel = new QLabel (this);
-  aTitleLabel->setText (tr ("Open File"));
-  aDialogLay->addWidget (aTitleLabel);
-
   // Samples View
   QGroupBox* aSamplesBox = new QGroupBox (this);
-  aSamplesBox->setTitle (tr ("Samples"));
+  aSamplesBox->setTitle (tr ("Recent files"));
   aDialogLay->addWidget (aSamplesBox);
   QVBoxLayout* aSampleLay = new QVBoxLayout (aSamplesBox);
   changeMargins (aSampleLay);
-  mySamplesView = createTableView (readSampleNames());
+  mySamplesView = createTableView (theRecentlyOpenedFiles);
   aSampleLay->addWidget (mySamplesView);
 
   // Select file
@@ -143,16 +161,8 @@ TInspectorEXE_OpenFileDialog::TInspectorEXE_OpenFileDialog (QWidget* theParent,
   aSelectFileBtn->setIcon (QIcon (":folder_open.png"));
   aSelectFileLay->addWidget (aSelectFileBtn, 1, 1);
 
-  myFolderApplyOpen = new QToolButton (aSelectFileBox);
-  myFolderApplyOpen->setIcon (QIcon (":folder_import.png"));
-  myFolderApplyOpen->setIconSize (QSize (ICON_SIZE, ICON_SIZE));
-  myFolderApplyOpen->setEnabled (false);
-  aSelectFileLay->addWidget (myFolderApplyOpen, 0, 2, 2, 1);
-
-  connect (mySelectedName, SIGNAL (textChanged (const QString&)),
-           this, SLOT (onNameChanged (const QString&)));
   connect (aSelectFileBtn, SIGNAL (clicked()), this, SLOT (onSelectClicked()));
-  connect (myFolderApplyOpen, SIGNAL (clicked()), this, SLOT (onApplySelectClicked()));
+  connect (mySelectedName, SIGNAL (returnPressed()), this, SLOT (onApplySelectClicked()));
 
   resize (OPEN_DIALOG_WIDTH, OPEN_DIALOG_HEIGHT);
 }
@@ -161,10 +171,10 @@ TInspectorEXE_OpenFileDialog::TInspectorEXE_OpenFileDialog (QWidget* theParent,
 // function : OpenFile
 // purpose :
 // =======================================================================
-QString TInspectorEXE_OpenFileDialog::OpenFile (QWidget* theParent, const QString& theDataDirName)
+QString TInspectorEXE_OpenFileDialog::OpenFile (QWidget* theParent, const QStringList& theRecentlyOpenedFiles)
 {
   QString aFileName;
-  TInspectorEXE_OpenFileDialog* aDialog = new TInspectorEXE_OpenFileDialog(theParent, theDataDirName);
+  TInspectorEXE_OpenFileDialog* aDialog = new TInspectorEXE_OpenFileDialog (theParent, theRecentlyOpenedFiles);
   if (aDialog->exec() == QDialog::Accepted)
     aFileName = aDialog->GetFileName();
 
@@ -182,6 +192,47 @@ TInspector_Communicator* TInspectorEXE_OpenFileDialog::Communicator()
   return MyCommunicator;
 }
 
+// =======================================================================
+// function : GetPluginRecentlyOpenedFiles
+// purpose :
+// =======================================================================
+void TInspectorEXE_OpenFileDialog::GetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
+                                                                 TInspector_Communicator* theCommunicator,
+                                                                 QStringList& theFileNames)
+{
+  Handle(TInspectorAPI_PluginParameters) aParameters = theCommunicator->GetPluginParameters();
+  TInspectorAPI_PreferencesDataMap aPreferencesItem;
+  aParameters->GetPreferences (thePluginName, aPreferencesItem);
+
+  for (TInspectorAPI_IteratorOfPreferencesDataMap anItemIt (aPreferencesItem); anItemIt.More(); anItemIt.Next())
+  {
+    if (!anItemIt.Key().IsEqual("recently_opened_files"))
+      continue;
+    theFileNames = QString(anItemIt.Value().ToCString()).split(";", QString::SkipEmptyParts);
+    if (theFileNames.size() > RECENT_FILES_CACHE_SIZE)
+      for (int i = 0; i < theFileNames.size() - RECENT_FILES_CACHE_SIZE; i++)
+        theFileNames.removeFirst();
+    break;
+  }
+}
+
+// =======================================================================
+// function : SetPluginRecentlyOpenedFiles
+// purpose :
+// =======================================================================
+void TInspectorEXE_OpenFileDialog::SetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
+                                                                 TInspector_Communicator* theCommunicator,
+                                                                 QStringList& theFileNames)
+{
+  Handle(TInspectorAPI_PluginParameters) aParameters = theCommunicator->GetPluginParameters();
+
+  TInspectorAPI_PreferencesDataMap aPreferencesItem;
+  aParameters->GetPreferences (thePluginName, aPreferencesItem);
+  aPreferencesItem.Bind ("recently_opened_files", TCollection_AsciiString (theFileNames.join (";").toUtf8().data()));
+
+  aParameters->SetPreferences (thePluginName, aPreferencesItem);
+}
+
 // =======================================================================
 // function : onSampleSelectionChanged
 // purpose :
@@ -203,17 +254,6 @@ void TInspectorEXE_OpenFileDialog::onSampleSelectionChanged (const QItemSelectio
   accept();
 }
 
-// =======================================================================
-// function : onNameChanged
-// purpose :
-// =======================================================================
-void TInspectorEXE_OpenFileDialog::onNameChanged (const QString& theText)
-{
-  QFileInfo aFileInfo (theText);
-  bool anExists = aFileInfo.exists() && aFileInfo.isFile();
-  myFolderApplyOpen->setEnabled (anExists);
-}
-
 // =======================================================================
 // function : onSelectClicked
 // purpose :
@@ -245,6 +285,12 @@ void TInspectorEXE_OpenFileDialog::onSelectClicked()
 // =======================================================================
 void TInspectorEXE_OpenFileDialog::onApplySelectClicked()
 {
+  QString aFileName = mySelectedName->text();
+
+  QFileInfo aFileInfo (aFileName);
+  if (!aFileInfo.exists() || !aFileInfo.isFile())
+    return;
+
   myFileName = mySelectedName->text();
   accept();
 }
@@ -291,24 +337,3 @@ QAbstractItemModel* TInspectorEXE_OpenFileDialog::createModel (const QStringList
   aModel->Init (theFileNames);
   return aModel;
 }
-
-// =======================================================================
-// function : readSampleNames
-// purpose :
-// =======================================================================
-QStringList TInspectorEXE_OpenFileDialog::readSampleNames()
-{
-  QStringList aNames;
-
-  QDir aDir(myDataDir);
-  aDir.setSorting(QDir::Name);
-
-  QFileInfoList aDirEntries = aDir.entryInfoList();
-  for (int aDirId = 0; aDirId < aDirEntries.size(); ++aDirId)
-  {
-    QFileInfo aFileInfo = aDirEntries.at(aDirId);
-    if (aFileInfo.isFile())
-      aNames.append (aFileInfo.absoluteFilePath());
-  }
-  return aNames;
-}
index 4afa449..b4d63ee 100644 (file)
 #ifndef TInspectorEXE_OpenFileDialog_H
 #define TInspectorEXE_OpenFileDialog_H
 
+#include <inspector/TInspectorAPI_PreferencesDataMap.hxx>
+
 #include <NCollection_DataMap.hxx>
+#include <NCollection_List.hxx>
 #include <TCollection_AsciiString.hxx>
 
 #include <Standard_WarningsDisable.hxx>
@@ -56,8 +59,9 @@ public:
   QPushButton* StartButton();
 
   //! Sets the default directory of plugin.
-  void SetPluginDir (const TCollection_AsciiString& thePluginName, const TCollection_AsciiString& theDefaultDir)
-  { myDefaultDirs.Bind (thePluginName, theDefaultDir); }
+  void SetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
+                                     const QStringList& theRecentlyOpenedFiles)
+  { myRecentlyOpenedFiles[thePluginName] = theRecentlyOpenedFiles; }
 
 private slots:
 
@@ -67,7 +71,8 @@ private slots:
 private:
 
   QPushButton* myStartButton; //!< processed button
-  NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString> myDefaultDirs; //!< plugins default directories
+  //!< plugins recently opened files
+  QMap<TCollection_AsciiString, QStringList> myRecentlyOpenedFiles;
 };
 
 //! \class TInspectorEXE_OpenFileDialog
@@ -80,7 +85,7 @@ class TInspectorEXE_OpenFileDialog : public QDialog
 private:
 
   //! Constructor
-  TInspectorEXE_OpenFileDialog (QWidget* theParent, const QString& theDataDirName);
+  Standard_EXPORT TInspectorEXE_OpenFileDialog (QWidget* theParent, const QStringList& theRecentlyOpenedFiles);
 
 public:
 
@@ -91,23 +96,35 @@ public:
   //! \param theParent a parent for the new dialog
   //! \param theDataDirName path to default samples directory
   //! \returns a file name from the open file dialog
-  static QString OpenFile (QWidget* theParent, const QString& theDataDirName);
+  Standard_EXPORT static QString OpenFile (QWidget* theParent, const QStringList& theRecentlyOpenedFiles);
 
   //! Returns selection name from the dialog
   QString GetFileName() const { return myFileName; }
 
   //! Returns communicator, if this is the first call, create a communicator instance
-  static TInspector_Communicator* Communicator();
+  Standard_EXPORT static TInspector_Communicator* Communicator();
+
+  //! Returns preferences: previous opened documents.
+  //! \param thePluginName name of the plugin
+  //! \param theCommunicator source of preferences
+  //! \param theFileNames [out] container of recently opened file names
+  Standard_EXPORT static void GetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
+                                                            TInspector_Communicator* theCommunicator,
+                                                            QStringList& theFileNames);
+
+  //! Sets preferences: previous opened documents.
+  //! \param thePluginName name of the plugin
+  //! \param theCommunicator source of preferences
+  //! \param theFileNames container of recently opened file names to be set into communicator preferences
+  Standard_EXPORT static void SetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
+                                                            TInspector_Communicator* theCommunicator,
+                                                            QStringList& theFileNames);
 
 private slots:
 
   //! Stores name of selected sample file
   void onSampleSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
 
-  //! Updates enabling state of Open file button, it is enabled if the file by the entered path exists
-  //! \param theText a file name text in line edit
-  void onNameChanged (const QString& theText);
-
   //! Open file dialog to select a file name. Fills file name line, enable import button
   void onSelectClicked();
 
@@ -126,17 +143,12 @@ private:
   //! \return model
   QAbstractItemModel* createModel (const QStringList& theFileNames);
 
-  //! Generates container of file names in samples directory
-  //! \return container of names
-  QStringList readSampleNames();
-
 private:
 
-  QString myDataDir; //!< samples directory
+  QStringList myRecentlyOpenedFiles; //!< recently opened files
   QString myFileName; //!< result file name
   QTableView* mySamplesView; //! <view of sample file names
   QLineEdit* mySelectedName; //!< alternative control to open file
-  QToolButton* myFolderApplyOpen; //! button to open file
 };
 
 #endif
index c7612d1..03be935 100644 (file)
@@ -36,7 +36,7 @@ void TInspectorEXE_OpenFileItemDelegate::paint (QPainter* thePainter, const QSty
     thePainter->fillRect (theOption.rect, myColor);
 
   // action icon for all indices before the last one
-  QIcon anIcon (":/icons/folder_import.png");
+  QIcon anIcon (":folder_import.png");
   QSize anIconSize (ICON_SIZE, ICON_SIZE);
   int aDX = (theOption.rect.width() - anIconSize.width()) / 2;
   int aMargin = qApp->style()->pixelMetric (QStyle::PM_HeaderMargin);
index 6e61cda..42f7e05 100644 (file)
@@ -193,7 +193,6 @@ void VInspector_Window::FillActionsMenu (void* theMenu)
 // =======================================================================
 void VInspector_Window::GetPreferences (TInspectorAPI_PreferencesDataMap& theItem)
 {
-  theItem.Clear();
   theItem.Bind ("geometry",  TreeModel_Tools::ToString (myMainWindow->saveState()).toStdString().c_str());
 
   QMap<QString, QString> anItems;