mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-29 14:00:49 +03:00
Coding - Apply .clang-format formatting #286
Update empty method guards to new style with regex (see PR). Used clang-format 18.1.8. New actions to validate code formatting is added. Update .clang-format with disabling of include sorting. It is temporary changes, then include will be sorted. Apply formatting for /src and /tools folder. The files with .hxx,.cxx,.lxx,.h,.pxx,.hpp,*.cpp extensions.
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <inspector/TInspector_Communicator.hxx>
|
||||
|
||||
@@ -36,14 +36,14 @@ TInspector_Communicator::TInspector_Communicator()
|
||||
{
|
||||
if (!qApp)
|
||||
{
|
||||
static int argc = 1;
|
||||
static char* argv[] = { (char*)"", 0 };
|
||||
static int argc = 1;
|
||||
static char* argv[] = {(char*)"", 0};
|
||||
#if QT_VERSION > 0x050000
|
||||
TCollection_AsciiString aPlugindsDirName;
|
||||
if (TInspector_Communicator::PluginsDir (aPlugindsDirName))
|
||||
QApplication::addLibraryPath (aPlugindsDirName.ToCString());
|
||||
if (TInspector_Communicator::PluginsDir(aPlugindsDirName))
|
||||
QApplication::addLibraryPath(aPlugindsDirName.ToCString());
|
||||
#endif
|
||||
new QApplication (argc, argv);
|
||||
new QApplication(argc, argv);
|
||||
}
|
||||
myWindow = new TInspector_Window();
|
||||
}
|
||||
@@ -52,16 +52,16 @@ TInspector_Communicator::TInspector_Communicator()
|
||||
// function : PluginsDir
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean TInspector_Communicator::PluginsDir (TCollection_AsciiString& thePlugindsDirName)
|
||||
Standard_Boolean TInspector_Communicator::PluginsDir(TCollection_AsciiString& thePlugindsDirName)
|
||||
{
|
||||
OSD_Environment anEnvironment ("QTDIR");
|
||||
OSD_Environment anEnvironment("QTDIR");
|
||||
TCollection_AsciiString aQtDirValue = anEnvironment.Value();
|
||||
if (!aQtDirValue.IsEmpty())
|
||||
{
|
||||
thePlugindsDirName = aQtDirValue + "/plugins";
|
||||
return Standard_True;
|
||||
}
|
||||
anEnvironment = OSD_Environment ("PATH");
|
||||
anEnvironment = OSD_Environment("PATH");
|
||||
TCollection_AsciiString aPathValue = anEnvironment.Value();
|
||||
TCollection_AsciiString aPathSep =
|
||||
#ifdef _WIN32
|
||||
@@ -71,18 +71,20 @@ Standard_Boolean TInspector_Communicator::PluginsDir (TCollection_AsciiString& t
|
||||
#endif
|
||||
for (int i = 1; !aPathValue.IsEmpty(); i++)
|
||||
{
|
||||
Standard_Integer aSepIndex = aPathValue.FirstLocationInSet (aPathSep, 1, aPathValue.Length());
|
||||
Standard_Integer aSepIndex = aPathValue.FirstLocationInSet(aPathSep, 1, aPathValue.Length());
|
||||
if (aSepIndex <= 1)
|
||||
break;
|
||||
|
||||
TCollection_AsciiString aCurPath = aPathValue.SubString (1, aSepIndex - 1);
|
||||
aPathValue = aSepIndex < aPathValue.Length() ? aPathValue.SubString (aSepIndex + 1, aPathValue.Length()) : "";
|
||||
TCollection_AsciiString aCurPath = aPathValue.SubString(1, aSepIndex - 1);
|
||||
aPathValue = aSepIndex < aPathValue.Length()
|
||||
? aPathValue.SubString(aSepIndex + 1, aPathValue.Length())
|
||||
: "";
|
||||
if (aCurPath.IsEmpty())
|
||||
continue;
|
||||
|
||||
aCurPath += "/../plugins";
|
||||
OSD_Path aPath (aCurPath);
|
||||
OSD_Directory aCurDir (aPath);
|
||||
OSD_Path aPath(aCurPath);
|
||||
OSD_Directory aCurDir(aPath);
|
||||
if (aCurDir.Exists())
|
||||
{
|
||||
thePlugindsDirName = aCurPath;
|
||||
@@ -96,9 +98,9 @@ Standard_Boolean TInspector_Communicator::PluginsDir (TCollection_AsciiString& t
|
||||
// function : SetVisible
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspector_Communicator::SetVisible (const bool theVisible)
|
||||
void TInspector_Communicator::SetVisible(const bool theVisible)
|
||||
{
|
||||
myWindow->GetMainWindow()->setVisible (theVisible);
|
||||
myWindow->GetMainWindow()->setVisible(theVisible);
|
||||
#ifndef _WIN32
|
||||
// window is not visualized on X11 patform under DRAW tool without the next row
|
||||
QApplication::processEvents();
|
||||
@@ -109,7 +111,7 @@ void TInspector_Communicator::SetVisible (const bool theVisible)
|
||||
// function : Move
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspector_Communicator::Move (const int theXPosition, const int theYPosition)
|
||||
void TInspector_Communicator::Move(const int theXPosition, const int theYPosition)
|
||||
{
|
||||
myWindow->GetMainWindow()->move (theXPosition, theYPosition);
|
||||
myWindow->GetMainWindow()->move(theXPosition, theYPosition);
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef TInspector_Communicator_H
|
||||
#define TInspector_Communicator_H
|
||||
@@ -33,7 +33,6 @@ class QPushButton;
|
||||
class TInspector_Communicator
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
Standard_EXPORT TInspector_Communicator();
|
||||
|
||||
@@ -41,77 +40,108 @@ public:
|
||||
virtual ~TInspector_Communicator() {}
|
||||
|
||||
//! Returns directory of Qt plugins. Firstly it founds it in QTDIR, else if not defined in PATH
|
||||
Standard_EXPORT static Standard_Boolean PluginsDir (TCollection_AsciiString& thePlugindsDirName);
|
||||
Standard_EXPORT static Standard_Boolean PluginsDir(TCollection_AsciiString& thePlugindsDirName);
|
||||
|
||||
//! Registers plugin into TInspector window
|
||||
//! \param thePluginName a name of the plugin
|
||||
void RegisterPlugin (const TCollection_AsciiString& thePluginName) { myWindow->RegisterPlugin (thePluginName); }
|
||||
void RegisterPlugin(const TCollection_AsciiString& thePluginName)
|
||||
{
|
||||
myWindow->RegisterPlugin(thePluginName);
|
||||
}
|
||||
|
||||
//! Returns list of registered plugins
|
||||
//! \return container of plugin names
|
||||
NCollection_List<TCollection_AsciiString> RegisteredPlugins() const { return myWindow->RegisteredPlugins(); }
|
||||
NCollection_List<TCollection_AsciiString> RegisteredPlugins() const
|
||||
{
|
||||
return myWindow->RegisteredPlugins();
|
||||
}
|
||||
|
||||
//! Stores parameters for the plugin
|
||||
//! \param theParameters container of parameters(e.g. AIS_InteractiveContext, TDocStd_Application)
|
||||
//! \param theAppend boolean state whether the parameters should be added to existing
|
||||
void Init (const NCollection_List<Handle(Standard_Transient)>& theParameters,
|
||||
const Standard_Boolean theAppend = Standard_False)
|
||||
{ myWindow->Init ("", theParameters, theAppend); }
|
||||
void Init(const NCollection_List<Handle(Standard_Transient)>& theParameters,
|
||||
const Standard_Boolean theAppend = Standard_False)
|
||||
{
|
||||
myWindow->Init("", theParameters, theAppend);
|
||||
}
|
||||
|
||||
//! Stores parameters for the plugin
|
||||
//! \param thePluginName a name of the plugin
|
||||
//! \param theParameters container of parameters(e.g. AIS_InteractiveContext, TDocStd_Application)
|
||||
//! \param theAppend boolean state whether the parameters should be added to existing
|
||||
void Init (const TCollection_AsciiString& thePluginName,
|
||||
const NCollection_List<Handle(Standard_Transient)>& theParameters,
|
||||
const Standard_Boolean theAppend = Standard_False)
|
||||
{ myWindow->Init (thePluginName, theParameters, theAppend); }
|
||||
void Init(const TCollection_AsciiString& thePluginName,
|
||||
const NCollection_List<Handle(Standard_Transient)>& theParameters,
|
||||
const Standard_Boolean theAppend = Standard_False)
|
||||
{
|
||||
myWindow->Init(thePluginName, theParameters, theAppend);
|
||||
}
|
||||
|
||||
//! Updates content for the TInspector window
|
||||
void UpdateContent() { myWindow->UpdateContent(); }
|
||||
|
||||
//! Sets open button for the TInspector window
|
||||
void SetOpenButton (QPushButton* theButton) { myWindow->SetOpenButton (theButton); }
|
||||
void SetOpenButton(QPushButton* theButton) { myWindow->SetOpenButton(theButton); }
|
||||
|
||||
//! Opens file in TInspector window
|
||||
void OpenFile (const TCollection_AsciiString& thePluginName, const TCollection_AsciiString& theFileName)
|
||||
{ myWindow->OpenFile (thePluginName, theFileName); }
|
||||
void OpenFile(const TCollection_AsciiString& thePluginName,
|
||||
const TCollection_AsciiString& theFileName)
|
||||
{
|
||||
myWindow->OpenFile(thePluginName, theFileName);
|
||||
}
|
||||
|
||||
//! Activates plugin
|
||||
//! \param thePluginName a name of the plugin
|
||||
void Activate (const TCollection_AsciiString& thePluginName) { myWindow->ActivateTool (thePluginName); }
|
||||
void Activate(const TCollection_AsciiString& thePluginName)
|
||||
{
|
||||
myWindow->ActivateTool(thePluginName);
|
||||
}
|
||||
|
||||
//! Sets item selected in the active plugin
|
||||
//! \param theItemName a container of name of items in plugin that should become selected
|
||||
void SetSelected (const NCollection_List<TCollection_AsciiString>& theItemNames) { myWindow->SetSelected (theItemNames); }
|
||||
void SetSelected(const NCollection_List<TCollection_AsciiString>& theItemNames)
|
||||
{
|
||||
myWindow->SetSelected(theItemNames);
|
||||
}
|
||||
|
||||
//! Sets objects to be selected in the plugin
|
||||
//! \param theObjects an objects
|
||||
void SetSelected (const NCollection_List<Handle(Standard_Transient)>& theObjects) { myWindow->SetSelected (theObjects); }
|
||||
void SetSelected(const NCollection_List<Handle(Standard_Transient)>& theObjects)
|
||||
{
|
||||
myWindow->SetSelected(theObjects);
|
||||
}
|
||||
|
||||
//! Sets path to a directory for temporary plugin files
|
||||
//! \param thePath a path
|
||||
void SetTemporaryDirectory (const TCollection_AsciiString& thePath) { myWindow->SetTemporaryDirectory (thePath); }
|
||||
void SetTemporaryDirectory(const TCollection_AsciiString& thePath)
|
||||
{
|
||||
myWindow->SetTemporaryDirectory(thePath);
|
||||
}
|
||||
|
||||
//! Returns path to a directory for temporary plugin files
|
||||
//! \return path
|
||||
TCollection_AsciiString GetTemporaryDirectory() const { return myWindow->GetTemporaryDirectory(); }
|
||||
TCollection_AsciiString GetTemporaryDirectory() const
|
||||
{
|
||||
return myWindow->GetTemporaryDirectory();
|
||||
}
|
||||
|
||||
//! Changes window visibility
|
||||
//! \param theVisible boolean state
|
||||
Standard_EXPORT virtual void SetVisible (const bool theVisible);
|
||||
Standard_EXPORT virtual void SetVisible(const bool theVisible);
|
||||
|
||||
//! Changes window position
|
||||
//! \param theX X pixel position of top left corner of the window
|
||||
//! \param theY Y pixel position
|
||||
Standard_EXPORT virtual void Move (const int theXPosition, const int theYPosition);
|
||||
Standard_EXPORT virtual void Move(const int theXPosition, const int theYPosition);
|
||||
|
||||
//! Puts in the stream information about communicator
|
||||
//! \param theStream stream for output
|
||||
void Dump (Standard_OStream& theStream) const { return myWindow->Dump (theStream); }
|
||||
void Dump(Standard_OStream& theStream) const { return myWindow->Dump(theStream); }
|
||||
|
||||
//! Returns plugins parameters container
|
||||
Handle(TInspectorAPI_PluginParameters) const GetPluginParameters() { return myWindow->GetPluginParameters(); }
|
||||
Handle(TInspectorAPI_PluginParameters) const GetPluginParameters()
|
||||
{
|
||||
return myWindow->GetPluginParameters();
|
||||
}
|
||||
|
||||
private:
|
||||
TInspector_Window* myWindow; //!< current window
|
||||
|
@@ -11,7 +11,7 @@
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <inspector/TInspector_OpenButton.hxx>
|
||||
|
||||
@@ -30,8 +30,9 @@ const int RECENT_FILES_CACHE_SIZE = 10;
|
||||
// function : Constructor
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TInspector_OpenButton::TInspector_OpenButton (QObject* theParent)
|
||||
: QObject (theParent), myStartButton (0)
|
||||
TInspector_OpenButton::TInspector_OpenButton(QObject* theParent)
|
||||
: QObject(theParent),
|
||||
myStartButton(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -44,8 +45,8 @@ QPushButton* TInspector_OpenButton::StartButton()
|
||||
if (!myStartButton)
|
||||
{
|
||||
myStartButton = new QPushButton();
|
||||
myStartButton->setIcon (QIcon (":folder_open.png"));
|
||||
connect (myStartButton, SIGNAL (clicked()), this, SLOT (onStartButtonClicked()));
|
||||
myStartButton->setIcon(QIcon(":folder_open.png"));
|
||||
connect(myStartButton, SIGNAL(clicked()), this, SLOT(onStartButtonClicked()));
|
||||
}
|
||||
return myStartButton;
|
||||
}
|
||||
@@ -56,37 +57,42 @@ QPushButton* TInspector_OpenButton::StartButton()
|
||||
// =======================================================================
|
||||
void TInspector_OpenButton::onStartButtonClicked()
|
||||
{
|
||||
QPushButton* aButton = (QPushButton*)sender();
|
||||
TCollection_AsciiString aPluginName (aButton->objectName().toStdString().c_str());
|
||||
QPushButton* aButton = (QPushButton*)sender();
|
||||
TCollection_AsciiString aPluginName(aButton->objectName().toStdString().c_str());
|
||||
if (aPluginName.IsEmpty())
|
||||
return;
|
||||
|
||||
|
||||
QStringList aPluginRecentlyOpenedFiles;
|
||||
if (myRecentlyOpenedFiles.contains(aPluginName))
|
||||
{
|
||||
QStringList aFileNames = myRecentlyOpenedFiles[aPluginName];
|
||||
for (int i = 0; i < aFileNames.size(); i++)
|
||||
{
|
||||
QFileInfo aFileInfo (aFileNames[i]);
|
||||
QFileInfo aFileInfo(aFileNames[i]);
|
||||
if (aFileInfo.exists() && aFileInfo.isFile())
|
||||
aPluginRecentlyOpenedFiles.append(aFileInfo.absoluteFilePath());
|
||||
}
|
||||
}
|
||||
|
||||
QString aFileName = TInspector_OpenFileDialog::OpenFile (0, aPluginRecentlyOpenedFiles);
|
||||
aFileName = QDir().toNativeSeparators (aFileName);
|
||||
if (!aFileName.isEmpty()) {
|
||||
QApplication::setOverrideCursor (Qt::WaitCursor);
|
||||
TInspector_OpenFileDialog::Communicator()->OpenFile (aPluginName, TCollection_AsciiString (aFileName.toUtf8().data()));
|
||||
QString aFileName = TInspector_OpenFileDialog::OpenFile(0, aPluginRecentlyOpenedFiles);
|
||||
aFileName = QDir().toNativeSeparators(aFileName);
|
||||
if (!aFileName.isEmpty())
|
||||
{
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
TInspector_OpenFileDialog::Communicator()->OpenFile(
|
||||
aPluginName,
|
||||
TCollection_AsciiString(aFileName.toUtf8().data()));
|
||||
|
||||
QFileInfo aFileInfo (aFileName);
|
||||
if (!aPluginRecentlyOpenedFiles.contains (aFileInfo.absoluteFilePath()))
|
||||
QFileInfo aFileInfo(aFileName);
|
||||
if (!aPluginRecentlyOpenedFiles.contains(aFileInfo.absoluteFilePath()))
|
||||
{
|
||||
myRecentlyOpenedFiles[aPluginName].append (aFileInfo.absoluteFilePath());
|
||||
myRecentlyOpenedFiles[aPluginName].append(aFileInfo.absoluteFilePath());
|
||||
for (int i = 0; i < myRecentlyOpenedFiles[aPluginName].size() - RECENT_FILES_CACHE_SIZE; i++)
|
||||
myRecentlyOpenedFiles[aPluginName].removeFirst();
|
||||
TInspector_OpenFileDialog::SetPluginRecentlyOpenedFiles (aPluginName,
|
||||
TInspector_OpenFileDialog::Communicator(), myRecentlyOpenedFiles[aPluginName]);
|
||||
TInspector_OpenFileDialog::SetPluginRecentlyOpenedFiles(
|
||||
aPluginName,
|
||||
TInspector_OpenFileDialog::Communicator(),
|
||||
myRecentlyOpenedFiles[aPluginName]);
|
||||
|
||||
TInspector_OpenFileDialog::Communicator()->GetPluginParameters()->StorePreferences();
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef TInspectorEXE_OpenButton_H
|
||||
#define TInspectorEXE_OpenButton_H
|
||||
@@ -27,36 +27,38 @@
|
||||
class QPushButton;
|
||||
|
||||
//! \class TInspector_OpenButton
|
||||
//! Class that contains push button and the button processing. It obtains a file name from the default or current
|
||||
//! directory and gives the name into TInspector communicator
|
||||
//! Object name of the button is the name of the plugin to get the default directory, or the current directory is used.
|
||||
//! Class that contains push button and the button processing. It obtains a file name from the
|
||||
//! default or current directory and gives the name into TInspector communicator Object name of the
|
||||
//! button is the name of the plugin to get the default directory, or the current directory is used.
|
||||
class TInspector_OpenButton : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
Standard_EXPORT TInspector_OpenButton (QObject* theParent);
|
||||
Standard_EXPORT TInspector_OpenButton(QObject* theParent);
|
||||
|
||||
//! Destructor
|
||||
virtual ~TInspector_OpenButton() {}
|
||||
|
||||
//! Returns the start button, if this is the first call, it creates the button and connect it to the slot
|
||||
//! Returns the start button, if this is the first call, it creates the button and connect it to
|
||||
//! the slot
|
||||
Standard_EXPORT QPushButton* StartButton();
|
||||
|
||||
//! Sets the default directory of plugin.
|
||||
void SetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
|
||||
const QStringList& theRecentlyOpenedFiles)
|
||||
{ myRecentlyOpenedFiles[thePluginName] = theRecentlyOpenedFiles; }
|
||||
void SetPluginRecentlyOpenedFiles(const TCollection_AsciiString& thePluginName,
|
||||
const QStringList& theRecentlyOpenedFiles)
|
||||
{
|
||||
myRecentlyOpenedFiles[thePluginName] = theRecentlyOpenedFiles;
|
||||
}
|
||||
|
||||
private slots:
|
||||
|
||||
//! Processes the button click, open default/current directory to select open file, calls OpenFile of communicator
|
||||
//! Processes the button click, open default/current directory to select open file, calls OpenFile
|
||||
//! of communicator
|
||||
void onStartButtonClicked();
|
||||
|
||||
private:
|
||||
|
||||
QPushButton* myStartButton; //!< processed button
|
||||
//!< plugins recently opened files
|
||||
QMap<TCollection_AsciiString, QStringList> myRecentlyOpenedFiles;
|
||||
|
@@ -11,7 +11,7 @@
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <inspector/TInspector_OpenFileDialog.hxx>
|
||||
|
||||
@@ -42,10 +42,10 @@
|
||||
|
||||
static const int ICON_SIZE = 40;
|
||||
|
||||
static const int OPEN_DIALOG_WIDTH = 550;
|
||||
static const int OPEN_DIALOG_WIDTH = 550;
|
||||
static const int OPEN_DIALOG_HEIGHT = 200;
|
||||
|
||||
static const int MARGIN_DIALOG = 4;
|
||||
static const int MARGIN_DIALOG = 4;
|
||||
static const int SPACING_DIALOG = 2;
|
||||
|
||||
static const int RECENT_FILES_CACHE_SIZE = 10;
|
||||
@@ -56,66 +56,70 @@ TInspector_Communicator* MyCommunicator;
|
||||
// function : changeMargins
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void changeMargins (QBoxLayout* theLayout)
|
||||
void changeMargins(QBoxLayout* theLayout)
|
||||
{
|
||||
theLayout->setContentsMargins (MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG);
|
||||
theLayout->setSpacing (SPACING_DIALOG);
|
||||
theLayout->setContentsMargins(MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG);
|
||||
theLayout->setSpacing(SPACING_DIALOG);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Constructor
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TInspector_OpenFileDialog::TInspector_OpenFileDialog (QWidget* theParent, const QStringList& theRecentlyOpenedFiles)
|
||||
: QDialog (theParent), myRecentlyOpenedFiles (theRecentlyOpenedFiles)
|
||||
TInspector_OpenFileDialog::TInspector_OpenFileDialog(QWidget* theParent,
|
||||
const QStringList& theRecentlyOpenedFiles)
|
||||
: QDialog(theParent),
|
||||
myRecentlyOpenedFiles(theRecentlyOpenedFiles)
|
||||
{
|
||||
setWindowTitle (tr ("Open File"));
|
||||
setWindowTitle(tr("Open File"));
|
||||
|
||||
QVBoxLayout* aDialogLay = new QVBoxLayout (this);
|
||||
changeMargins (aDialogLay);
|
||||
QVBoxLayout* aDialogLay = new QVBoxLayout(this);
|
||||
changeMargins(aDialogLay);
|
||||
|
||||
// Samples View
|
||||
QGroupBox* aSamplesBox = new QGroupBox (this);
|
||||
aSamplesBox->setTitle (tr ("Recent files"));
|
||||
aDialogLay->addWidget (aSamplesBox);
|
||||
QVBoxLayout* aSampleLay = new QVBoxLayout (aSamplesBox);
|
||||
changeMargins (aSampleLay);
|
||||
mySamplesView = createTableView (theRecentlyOpenedFiles);
|
||||
aSampleLay->addWidget (mySamplesView);
|
||||
QGroupBox* aSamplesBox = new QGroupBox(this);
|
||||
aSamplesBox->setTitle(tr("Recent files"));
|
||||
aDialogLay->addWidget(aSamplesBox);
|
||||
QVBoxLayout* aSampleLay = new QVBoxLayout(aSamplesBox);
|
||||
changeMargins(aSampleLay);
|
||||
mySamplesView = createTableView(theRecentlyOpenedFiles);
|
||||
aSampleLay->addWidget(mySamplesView);
|
||||
|
||||
// Select file
|
||||
QGroupBox* aSelectFileBox = new QGroupBox (this);
|
||||
aSelectFileBox->setTitle (tr ("Select file"));
|
||||
aDialogLay->addWidget (aSelectFileBox);
|
||||
QGridLayout* aSelectFileLay = new QGridLayout (aSelectFileBox);
|
||||
aSelectFileLay->setContentsMargins (MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG);
|
||||
QGroupBox* aSelectFileBox = new QGroupBox(this);
|
||||
aSelectFileBox->setTitle(tr("Select file"));
|
||||
aDialogLay->addWidget(aSelectFileBox);
|
||||
QGridLayout* aSelectFileLay = new QGridLayout(aSelectFileBox);
|
||||
aSelectFileLay->setContentsMargins(MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG, MARGIN_DIALOG);
|
||||
|
||||
mySelectedName = new QLineEdit (aSelectFileBox);
|
||||
QCompleter* aCompleter = new QCompleter();
|
||||
mySelectedName = new QLineEdit(aSelectFileBox);
|
||||
QCompleter* aCompleter = new QCompleter();
|
||||
QFileSystemModel* aFileSystemModel = new QFileSystemModel;
|
||||
aFileSystemModel->setRootPath (QDir::rootPath());
|
||||
aCompleter->setModel (aFileSystemModel);
|
||||
mySelectedName->setCompleter (aCompleter);
|
||||
aSelectFileLay->addWidget (mySelectedName, 1, 0);
|
||||
aFileSystemModel->setRootPath(QDir::rootPath());
|
||||
aCompleter->setModel(aFileSystemModel);
|
||||
mySelectedName->setCompleter(aCompleter);
|
||||
aSelectFileLay->addWidget(mySelectedName, 1, 0);
|
||||
|
||||
QToolButton* aSelectFileBtn = new QToolButton (aSelectFileBox);
|
||||
aSelectFileBtn->setIcon (QIcon (":folder_open.png"));
|
||||
aSelectFileLay->addWidget (aSelectFileBtn, 1, 1);
|
||||
QToolButton* aSelectFileBtn = new QToolButton(aSelectFileBox);
|
||||
aSelectFileBtn->setIcon(QIcon(":folder_open.png"));
|
||||
aSelectFileLay->addWidget(aSelectFileBtn, 1, 1);
|
||||
|
||||
connect (aSelectFileBtn, SIGNAL (clicked()), this, SLOT (onSelectClicked()));
|
||||
connect (mySelectedName, SIGNAL (returnPressed()), this, SLOT (onApplySelectClicked()));
|
||||
connect(aSelectFileBtn, SIGNAL(clicked()), this, SLOT(onSelectClicked()));
|
||||
connect(mySelectedName, SIGNAL(returnPressed()), this, SLOT(onApplySelectClicked()));
|
||||
|
||||
resize (OPEN_DIALOG_WIDTH, OPEN_DIALOG_HEIGHT);
|
||||
resize(OPEN_DIALOG_WIDTH, OPEN_DIALOG_HEIGHT);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : OpenFile
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QString TInspector_OpenFileDialog::OpenFile (QWidget* theParent, const QStringList& theRecentlyOpenedFiles)
|
||||
QString TInspector_OpenFileDialog::OpenFile(QWidget* theParent,
|
||||
const QStringList& theRecentlyOpenedFiles)
|
||||
{
|
||||
QString aFileName;
|
||||
TInspector_OpenFileDialog* aDialog = new TInspector_OpenFileDialog (theParent, theRecentlyOpenedFiles);
|
||||
QString aFileName;
|
||||
TInspector_OpenFileDialog* aDialog =
|
||||
new TInspector_OpenFileDialog(theParent, theRecentlyOpenedFiles);
|
||||
if (aDialog->exec() == QDialog::Accepted)
|
||||
aFileName = aDialog->GetFileName();
|
||||
|
||||
@@ -137,15 +141,17 @@ TInspector_Communicator* TInspector_OpenFileDialog::Communicator()
|
||||
// function : GetPluginRecentlyOpenedFiles
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspector_OpenFileDialog::GetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
|
||||
TInspector_Communicator* theCommunicator,
|
||||
QStringList& theFileNames)
|
||||
void TInspector_OpenFileDialog::GetPluginRecentlyOpenedFiles(
|
||||
const TCollection_AsciiString& thePluginName,
|
||||
TInspector_Communicator* theCommunicator,
|
||||
QStringList& theFileNames)
|
||||
{
|
||||
Handle(TInspectorAPI_PluginParameters) aParameters = theCommunicator->GetPluginParameters();
|
||||
TInspectorAPI_PreferencesDataMap aPreferencesItem;
|
||||
aParameters->GetPreferences (thePluginName, aPreferencesItem);
|
||||
TInspectorAPI_PreferencesDataMap aPreferencesItem;
|
||||
aParameters->GetPreferences(thePluginName, aPreferencesItem);
|
||||
|
||||
for (TInspectorAPI_IteratorOfPreferencesDataMap anItemIt (aPreferencesItem); anItemIt.More(); anItemIt.Next())
|
||||
for (TInspectorAPI_IteratorOfPreferencesDataMap anItemIt(aPreferencesItem); anItemIt.More();
|
||||
anItemIt.Next())
|
||||
{
|
||||
if (!anItemIt.Key().IsEqual("recently_opened_files"))
|
||||
continue;
|
||||
@@ -161,25 +167,27 @@ void TInspector_OpenFileDialog::GetPluginRecentlyOpenedFiles (const TCollection_
|
||||
// function : SetPluginRecentlyOpenedFiles
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspector_OpenFileDialog::SetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
|
||||
TInspector_Communicator* theCommunicator,
|
||||
QStringList& theFileNames)
|
||||
void TInspector_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->GetPreferences(thePluginName, aPreferencesItem);
|
||||
aPreferencesItem.Bind("recently_opened_files",
|
||||
TCollection_AsciiString(theFileNames.join(";").toUtf8().data()));
|
||||
|
||||
aParameters->SetPreferences (thePluginName, aPreferencesItem);
|
||||
aParameters->SetPreferences(thePluginName, aPreferencesItem);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : onSampleSelectionChanged
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspector_OpenFileDialog::onSampleSelectionChanged (const QItemSelection& theSelected,
|
||||
const QItemSelection&)
|
||||
void TInspector_OpenFileDialog::onSampleSelectionChanged(const QItemSelection& theSelected,
|
||||
const QItemSelection&)
|
||||
{
|
||||
QItemSelectionModel* aSelectionModel = (QItemSelectionModel*)sender();
|
||||
if (!aSelectionModel)
|
||||
@@ -191,7 +199,7 @@ void TInspector_OpenFileDialog::onSampleSelectionChanged (const QItemSelection&
|
||||
if (!anIndex.isValid())
|
||||
return;
|
||||
|
||||
myFileName = aSelectionModel->model()->data (anIndex, Qt::ToolTipRole).toString();
|
||||
myFileName = aSelectionModel->model()->data(anIndex, Qt::ToolTipRole).toString();
|
||||
accept();
|
||||
}
|
||||
|
||||
@@ -205,17 +213,16 @@ void TInspector_OpenFileDialog::onSelectClicked()
|
||||
QString aDirName = mySelectedName->text();
|
||||
if (!aDirName.isEmpty())
|
||||
{
|
||||
QDir aDir (aDirName);
|
||||
QDir aDir(aDirName);
|
||||
if (aDir.exists())
|
||||
anEnteredPath = aDirName;
|
||||
}
|
||||
|
||||
QString aFileName = QFileDialog::getOpenFileName (0, "Open document", anEnteredPath);
|
||||
QString aFileName = QFileDialog::getOpenFileName(0, "Open document", anEnteredPath);
|
||||
|
||||
if (aFileName.isEmpty())
|
||||
return; // do nothing, left the previous value
|
||||
|
||||
|
||||
myFileName = aFileName;
|
||||
accept();
|
||||
}
|
||||
@@ -228,7 +235,7 @@ void TInspector_OpenFileDialog::onApplySelectClicked()
|
||||
{
|
||||
QString aFileName = mySelectedName->text();
|
||||
|
||||
QFileInfo aFileInfo (aFileName);
|
||||
QFileInfo aFileInfo(aFileName);
|
||||
if (!aFileInfo.exists() || !aFileInfo.isFile())
|
||||
return;
|
||||
|
||||
@@ -240,30 +247,33 @@ void TInspector_OpenFileDialog::onApplySelectClicked()
|
||||
// function : createTableView
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QTableView* TInspector_OpenFileDialog::createTableView (const QStringList& theFileNames)
|
||||
QTableView* TInspector_OpenFileDialog::createTableView(const QStringList& theFileNames)
|
||||
{
|
||||
QTableView* aTableView = new QTableView (this);
|
||||
aTableView->setFrameStyle (QFrame::NoFrame);
|
||||
QPalette aPalette = aTableView->viewport()->palette();
|
||||
QColor aWindowColor = aPalette.color (QPalette::Window);
|
||||
aPalette.setBrush (QPalette::Base, aWindowColor);
|
||||
aTableView->viewport()->setPalette (aPalette);
|
||||
QTableView* aTableView = new QTableView(this);
|
||||
aTableView->setFrameStyle(QFrame::NoFrame);
|
||||
QPalette aPalette = aTableView->viewport()->palette();
|
||||
QColor aWindowColor = aPalette.color(QPalette::Window);
|
||||
aPalette.setBrush(QPalette::Base, aWindowColor);
|
||||
aTableView->viewport()->setPalette(aPalette);
|
||||
|
||||
aTableView->horizontalHeader()->setVisible (false);
|
||||
aTableView->verticalHeader()->setVisible (false);
|
||||
aTableView->setGridStyle (Qt::NoPen);
|
||||
aTableView->setModel (createModel (theFileNames));
|
||||
aTableView->setItemDelegateForRow (0, new TInspectorEXE_OpenFileItemDelegate (aTableView,
|
||||
aPalette.color (QPalette::Highlight)));
|
||||
aTableView->viewport()->setAttribute (Qt::WA_Hover);
|
||||
aTableView->horizontalHeader()->setVisible(false);
|
||||
aTableView->verticalHeader()->setVisible(false);
|
||||
aTableView->setGridStyle(Qt::NoPen);
|
||||
aTableView->setModel(createModel(theFileNames));
|
||||
aTableView->setItemDelegateForRow(
|
||||
0,
|
||||
new TInspectorEXE_OpenFileItemDelegate(aTableView, aPalette.color(QPalette::Highlight)));
|
||||
aTableView->viewport()->setAttribute(Qt::WA_Hover);
|
||||
int aCellHeight = ICON_SIZE + aTableView->verticalHeader()->defaultSectionSize();
|
||||
aTableView->setRowHeight (0, aCellHeight);
|
||||
aTableView->setRowHeight(0, aCellHeight);
|
||||
int aScrollHeight = aTableView->horizontalScrollBar()->sizeHint().height();
|
||||
aTableView->setMinimumHeight (aCellHeight + aScrollHeight);
|
||||
QItemSelectionModel* aSelectionModel = new QItemSelectionModel (aTableView->model());
|
||||
connect (aSelectionModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
|
||||
this, SLOT (onSampleSelectionChanged (const QItemSelection&, const QItemSelection&)));
|
||||
aTableView->setSelectionModel (aSelectionModel);
|
||||
aTableView->setMinimumHeight(aCellHeight + aScrollHeight);
|
||||
QItemSelectionModel* aSelectionModel = new QItemSelectionModel(aTableView->model());
|
||||
connect(aSelectionModel,
|
||||
SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
|
||||
this,
|
||||
SLOT(onSampleSelectionChanged(const QItemSelection&, const QItemSelection&)));
|
||||
aTableView->setSelectionModel(aSelectionModel);
|
||||
|
||||
return aTableView;
|
||||
}
|
||||
@@ -272,9 +282,9 @@ QTableView* TInspector_OpenFileDialog::createTableView (const QStringList& theFi
|
||||
// function : createModel
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QAbstractItemModel* TInspector_OpenFileDialog::createModel (const QStringList& theFileNames)
|
||||
QAbstractItemModel* TInspector_OpenFileDialog::createModel(const QStringList& theFileNames)
|
||||
{
|
||||
TInspector_OpenFileViewModel* aModel = new TInspector_OpenFileViewModel (this);
|
||||
aModel->Init (theFileNames);
|
||||
TInspector_OpenFileViewModel* aModel = new TInspector_OpenFileViewModel(this);
|
||||
aModel->Init(theFileNames);
|
||||
return aModel;
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef TInspectorEXE_OpenFileDialog_H
|
||||
#define TInspectorEXE_OpenFileDialog_H
|
||||
@@ -39,18 +39,18 @@ class QWidget;
|
||||
|
||||
//! \class TInspector_OpenFileDialog
|
||||
//! Control that contains table view of samples and line to select a file name from other directory.
|
||||
//! Click on element of samples table view calls this sample opening else after entering(or opening) file name
|
||||
//! the import becomes active. Click on the button will open selected file if it is possible
|
||||
//! Click on element of samples table view calls this sample opening else after entering(or opening)
|
||||
//! file name the import becomes active. Click on the button will open selected file if it is
|
||||
//! possible
|
||||
class TInspector_OpenFileDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
|
||||
//! Constructor
|
||||
Standard_EXPORT TInspector_OpenFileDialog (QWidget* theParent, const QStringList& theRecentlyOpenedFiles);
|
||||
Standard_EXPORT TInspector_OpenFileDialog(QWidget* theParent,
|
||||
const QStringList& theRecentlyOpenedFiles);
|
||||
|
||||
public:
|
||||
|
||||
//! Destructor
|
||||
virtual ~TInspector_OpenFileDialog() Standard_OVERRIDE {}
|
||||
|
||||
@@ -58,7 +58,8 @@ 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
|
||||
Standard_EXPORT static QString OpenFile (QWidget* theParent, const QStringList& theRecentlyOpenedFiles);
|
||||
Standard_EXPORT static QString OpenFile(QWidget* theParent,
|
||||
const QStringList& theRecentlyOpenedFiles);
|
||||
|
||||
//! Returns selection name from the dialog
|
||||
QString GetFileName() const { return myFileName; }
|
||||
@@ -70,22 +71,26 @@ public:
|
||||
//! \param thePluginName name of the plugin
|
||||
//! \param theCommunicator source of preferences
|
||||
//! \param[out] theFileNames container of recently opened file names
|
||||
Standard_EXPORT static void GetPluginRecentlyOpenedFiles (const TCollection_AsciiString& thePluginName,
|
||||
TInspector_Communicator* theCommunicator,
|
||||
QStringList& theFileNames);
|
||||
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);
|
||||
//! \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);
|
||||
void onSampleSelectionChanged(const QItemSelection& theSelected,
|
||||
const QItemSelection& theDeselected);
|
||||
|
||||
//! Opens file dialog to select a file name. Fills file name line, enable import button
|
||||
void onSelectClicked();
|
||||
@@ -94,23 +99,21 @@ private slots:
|
||||
void onApplySelectClicked();
|
||||
|
||||
private:
|
||||
|
||||
//! Creates view of file names in samples directory
|
||||
//! \param theFileNames a container of names
|
||||
//! \return table view
|
||||
QTableView* createTableView (const QStringList& theFileNames);
|
||||
QTableView* createTableView(const QStringList& theFileNames);
|
||||
|
||||
//! Creates view model and fills it by the file names
|
||||
//! \param theFileNames a container of names
|
||||
//! \return model
|
||||
QAbstractItemModel* createModel (const QStringList& theFileNames);
|
||||
QAbstractItemModel* createModel(const QStringList& theFileNames);
|
||||
|
||||
private:
|
||||
|
||||
QStringList myRecentlyOpenedFiles; //!< recently opened files
|
||||
QString myFileName; //!< result file name
|
||||
QTableView* mySamplesView; //!< view of sample file names
|
||||
QLineEdit* mySelectedName; //!< alternative control to open file
|
||||
QString myFileName; //!< result file name
|
||||
QTableView* mySamplesView; //!< view of sample file names
|
||||
QLineEdit* mySelectedName; //!< alternative control to open file
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -11,7 +11,7 @@
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <inspector/TInspector_OpenFileViewModel.hxx>
|
||||
|
||||
@@ -28,32 +28,33 @@ const int ICON_SIZE = 40;
|
||||
// function : paint
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspectorEXE_OpenFileItemDelegate::paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
|
||||
const QModelIndex& theIndex) const
|
||||
void TInspectorEXE_OpenFileItemDelegate::paint(QPainter* thePainter,
|
||||
const QStyleOptionViewItem& theOption,
|
||||
const QModelIndex& theIndex) const
|
||||
{
|
||||
// highlight cell
|
||||
if (theOption.state & QStyle::State_MouseOver)
|
||||
thePainter->fillRect (theOption.rect, myColor);
|
||||
thePainter->fillRect(theOption.rect, myColor);
|
||||
|
||||
// action icon for all indices before the last one
|
||||
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);
|
||||
thePainter->drawPixmap (QRect (theOption.rect.left() + aDX,
|
||||
theOption.rect.top() + aMargin,
|
||||
anIconSize.width(),
|
||||
anIconSize.height()),
|
||||
anIcon.pixmap(anIconSize.width(), anIconSize.height()));
|
||||
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);
|
||||
thePainter->drawPixmap(QRect(theOption.rect.left() + aDX,
|
||||
theOption.rect.top() + aMargin,
|
||||
anIconSize.width(),
|
||||
anIconSize.height()),
|
||||
anIcon.pixmap(anIconSize.width(), anIconSize.height()));
|
||||
// default paint
|
||||
QItemDelegate::paint (thePainter, theOption, theIndex);
|
||||
QItemDelegate::paint(thePainter, theOption, theIndex);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Init
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspector_OpenFileViewModel::Init (const QStringList& theValues)
|
||||
void TInspector_OpenFileViewModel::Init(const QStringList& theValues)
|
||||
{
|
||||
myValues = theValues;
|
||||
}
|
||||
@@ -62,14 +63,18 @@ void TInspector_OpenFileViewModel::Init (const QStringList& theValues)
|
||||
// function : data
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QVariant TInspector_OpenFileViewModel::data (const QModelIndex& theIndex, int theRole) const
|
||||
QVariant TInspector_OpenFileViewModel::data(const QModelIndex& theIndex, int theRole) const
|
||||
{
|
||||
switch (theRole)
|
||||
{
|
||||
case Qt::DisplayRole: return QFileInfo (myValues[theIndex.column()]).fileName();
|
||||
case Qt::ToolTipRole: return myValues[theIndex.column()];
|
||||
case Qt::TextAlignmentRole: return QVariant (Qt::AlignBottom | Qt::AlignHCenter);
|
||||
default: break;
|
||||
case Qt::DisplayRole:
|
||||
return QFileInfo(myValues[theIndex.column()]).fileName();
|
||||
case Qt::ToolTipRole:
|
||||
return myValues[theIndex.column()];
|
||||
case Qt::TextAlignmentRole:
|
||||
return QVariant(Qt::AlignBottom | Qt::AlignHCenter);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef TInspectorEXE_OpenFileViewModel_H
|
||||
#define TInspectorEXE_OpenFileViewModel_H
|
||||
@@ -28,15 +28,18 @@ class QObject;
|
||||
class QPainter;
|
||||
|
||||
//! \class TInspectorEXE_OpenFileItemDelegate
|
||||
//! Draws large(40x40) icons in cell. The icon background in colored in highlight when mouse is over button
|
||||
//! Draws large(40x40) icons in cell. The icon background in colored in highlight when mouse is over
|
||||
//! button
|
||||
class TInspectorEXE_OpenFileItemDelegate : public QItemDelegate
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
TInspectorEXE_OpenFileItemDelegate (QObject* theParent, const QColor& theHighlightColor)
|
||||
: QItemDelegate (theParent), myColor(theHighlightColor) {}
|
||||
TInspectorEXE_OpenFileItemDelegate(QObject* theParent, const QColor& theHighlightColor)
|
||||
: QItemDelegate(theParent),
|
||||
myColor(theHighlightColor)
|
||||
{
|
||||
}
|
||||
|
||||
//! Destructor
|
||||
virtual ~TInspectorEXE_OpenFileItemDelegate() {}
|
||||
@@ -45,11 +48,11 @@ public:
|
||||
//! \param thePainter a painter
|
||||
//! \param theOption a paint options
|
||||
//! \param theIndex a view index
|
||||
virtual void paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
|
||||
const QModelIndex& theIndex) const Standard_OVERRIDE;
|
||||
virtual void paint(QPainter* thePainter,
|
||||
const QStyleOptionViewItem& theOption,
|
||||
const QModelIndex& theIndex) const Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
QColor myColor; //!< highlight color
|
||||
};
|
||||
|
||||
@@ -60,38 +63,44 @@ class TInspector_OpenFileViewModel : public QAbstractTableModel
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
TInspector_OpenFileViewModel (QObject* theParent = 0) : QAbstractTableModel (theParent) {}
|
||||
TInspector_OpenFileViewModel(QObject* theParent = 0)
|
||||
: QAbstractTableModel(theParent)
|
||||
{
|
||||
}
|
||||
|
||||
//! Destructor
|
||||
virtual ~TInspector_OpenFileViewModel() {}
|
||||
|
||||
//! Store values
|
||||
//! \param theValues a container of values to fill model
|
||||
void Init (const QStringList& theValues);
|
||||
void Init(const QStringList& theValues);
|
||||
|
||||
//! Returns content of the model index for the given role, it is obtained from internal container of values
|
||||
//! It returns value only for DisplayRole.
|
||||
//! \param theIndex a model index
|
||||
//! \param theRole a view role
|
||||
//! \return value interpreted depending on the given role
|
||||
virtual QVariant data (const QModelIndex& theIndex, int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
|
||||
//! Returns content of the model index for the given role, it is obtained from internal container
|
||||
//! of values It returns value only for DisplayRole. \param theIndex a model index \param theRole
|
||||
//! a view role \return value interpreted depending on the given role
|
||||
virtual QVariant data(const QModelIndex& theIndex,
|
||||
int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
|
||||
|
||||
//! Returns number of rows
|
||||
//! \param theParent an index of the parent item
|
||||
//! \return an integer value
|
||||
virtual int rowCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
|
||||
{ (void)theParent; return 1; }
|
||||
virtual int rowCount(const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
|
||||
{
|
||||
(void)theParent;
|
||||
return 1;
|
||||
}
|
||||
|
||||
//! Returns number of columns
|
||||
//! \param theParent an index of the parent item
|
||||
//! \return an integer value
|
||||
virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
|
||||
{ (void)theParent; return myValues.size(); }
|
||||
virtual int columnCount(const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
|
||||
{
|
||||
(void)theParent;
|
||||
return myValues.size();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
QStringList myValues; //!< file names
|
||||
};
|
||||
|
||||
|
@@ -11,8 +11,7 @@
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <inspector/TInspector_PluginParameters.hxx>
|
||||
#include <inspector/TInspector_Preferences.hxx>
|
||||
@@ -21,37 +20,39 @@
|
||||
// function : Constructor
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TInspector_PluginParameters::TInspector_PluginParameters (TInspector_Window* theWindow)
|
||||
: myWindow (theWindow), myPreferences (new TInspector_Preferences())
|
||||
TInspector_PluginParameters::TInspector_PluginParameters(TInspector_Window* theWindow)
|
||||
: myWindow(theWindow),
|
||||
myPreferences(new TInspector_Preferences())
|
||||
{
|
||||
myPreferences->SetDirectory (GetTemporaryDirectory());
|
||||
myPreferences->SetDirectory(GetTemporaryDirectory());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetParameters
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspector_PluginParameters::SetParameters (const TCollection_AsciiString& thePluginName,
|
||||
const NCollection_List<Handle(Standard_Transient)>& theParameters,
|
||||
const Standard_Boolean& theToActivatePlugin)
|
||||
void TInspector_PluginParameters::SetParameters(
|
||||
const TCollection_AsciiString& thePluginName,
|
||||
const NCollection_List<Handle(Standard_Transient)>& theParameters,
|
||||
const Standard_Boolean& theToActivatePlugin)
|
||||
{
|
||||
TInspectorAPI_PluginParameters::SetParameters (thePluginName, theParameters, Standard_False);
|
||||
TInspectorAPI_PluginParameters::SetParameters(thePluginName, theParameters, Standard_False);
|
||||
|
||||
if (!theToActivatePlugin)
|
||||
return;
|
||||
|
||||
SetSelected (thePluginName, theParameters);
|
||||
myWindow->ActivateTool (thePluginName);
|
||||
SetSelected(thePluginName, theParameters);
|
||||
myWindow->ActivateTool(thePluginName);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetTemporaryDirectory
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspector_PluginParameters::SetTemporaryDirectory (const TCollection_AsciiString& thePath)
|
||||
void TInspector_PluginParameters::SetTemporaryDirectory(const TCollection_AsciiString& thePath)
|
||||
{
|
||||
if (thePath.IsEqual (myPreferences->GetDirectory()))
|
||||
if (thePath.IsEqual(myPreferences->GetDirectory()))
|
||||
return;
|
||||
|
||||
myPreferences->SetDirectory (thePath);
|
||||
myPreferences->SetDirectory(thePath);
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef DFBrowser_Communicator_H
|
||||
#define DFBrowser_Communicator_H
|
||||
@@ -24,13 +24,13 @@
|
||||
#include <inspector/TInspector_Window.hxx>
|
||||
|
||||
//! \class TInspector_PluginParameters.
|
||||
//! \brief This is plugin parameters extended by a possibility to activate module during setting new parameters
|
||||
//! \brief This is plugin parameters extended by a possibility to activate module during setting new
|
||||
//! parameters
|
||||
class TInspector_PluginParameters : public TInspectorAPI_PluginParameters
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
Standard_EXPORT TInspector_PluginParameters (TInspector_Window* theWindow);
|
||||
Standard_EXPORT TInspector_PluginParameters(TInspector_Window* theWindow);
|
||||
|
||||
//! Destructor
|
||||
virtual ~TInspector_PluginParameters() {}
|
||||
@@ -39,26 +39,31 @@ public:
|
||||
//! \param thePluginName a plugin name
|
||||
//! \param theParameters a list of parameters
|
||||
//! \param theToActivatePlugin a state whether the plugin should be immediately activated
|
||||
Standard_EXPORT virtual void SetParameters (const TCollection_AsciiString& thePluginName,
|
||||
const NCollection_List<Handle(Standard_Transient)>& theParameters,
|
||||
const Standard_Boolean& theToActivatePlugin = Standard_False) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual void SetParameters(
|
||||
const TCollection_AsciiString& thePluginName,
|
||||
const NCollection_List<Handle(Standard_Transient)>& theParameters,
|
||||
const Standard_Boolean& theToActivatePlugin = Standard_False) Standard_OVERRIDE;
|
||||
|
||||
//! Sets path to a directory for temporary plugin files. Sets the directory into preferences loader
|
||||
//! \param thePath a path
|
||||
virtual void SetTemporaryDirectory (const TCollection_AsciiString& thePath) Standard_OVERRIDE;
|
||||
//! Sets path to a directory for temporary plugin files. Sets the directory into preferences
|
||||
//! loader \param thePath a path
|
||||
virtual void SetTemporaryDirectory(const TCollection_AsciiString& thePath) Standard_OVERRIDE;
|
||||
|
||||
//! Returns plugin preferences
|
||||
//! \param thePluginName a plugin name
|
||||
virtual void GetPreferences (const TCollection_AsciiString& thePluginName,
|
||||
TInspectorAPI_PreferencesDataMap& theItem) Standard_OVERRIDE
|
||||
{ myPreferences->GetPreferences (thePluginName, theItem); }
|
||||
virtual void GetPreferences(const TCollection_AsciiString& thePluginName,
|
||||
TInspectorAPI_PreferencesDataMap& theItem) Standard_OVERRIDE
|
||||
{
|
||||
myPreferences->GetPreferences(thePluginName, theItem);
|
||||
}
|
||||
|
||||
//! Stores plugin preferences
|
||||
//! \param thePluginName a plugin name
|
||||
//! \theItem container of plugin preferences values in form: <name, value>
|
||||
virtual void SetPreferences (const TCollection_AsciiString& thePluginName,
|
||||
const TInspectorAPI_PreferencesDataMap& theItem) Standard_OVERRIDE
|
||||
{ myPreferences->SetPreferences (thePluginName, theItem); }
|
||||
virtual void SetPreferences(const TCollection_AsciiString& thePluginName,
|
||||
const TInspectorAPI_PreferencesDataMap& theItem) Standard_OVERRIDE
|
||||
{
|
||||
myPreferences->SetPreferences(thePluginName, theItem);
|
||||
}
|
||||
|
||||
//! Stores plugin preferences into a preferences file
|
||||
virtual void StorePreferences() Standard_OVERRIDE { myPreferences->StorePreferences(); }
|
||||
@@ -67,8 +72,7 @@ public:
|
||||
void RemovePreferences() { myPreferences->RemovePreferences(); }
|
||||
|
||||
private:
|
||||
|
||||
TInspector_Window* myWindow; //!< the current window
|
||||
TInspector_Window* myWindow; //!< the current window
|
||||
TInspector_Preferences* myPreferences; //!< the preferences loader
|
||||
};
|
||||
|
||||
|
@@ -11,7 +11,7 @@
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <inspector/TInspector_Preferences.hxx>
|
||||
|
||||
@@ -28,15 +28,15 @@
|
||||
// function : GetPreferences
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspector_Preferences::GetPreferences (const TCollection_AsciiString& thePluginName,
|
||||
TInspectorAPI_PreferencesDataMap& theItem)
|
||||
void TInspector_Preferences::GetPreferences(const TCollection_AsciiString& thePluginName,
|
||||
TInspectorAPI_PreferencesDataMap& theItem)
|
||||
{
|
||||
if (!myIsLoadedPreferences)
|
||||
{
|
||||
loadPreferences();
|
||||
myIsLoadedPreferences = Standard_True;
|
||||
}
|
||||
myLoadedPreferences.Find (thePluginName, theItem);
|
||||
myLoadedPreferences.Find(thePluginName, theItem);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -48,37 +48,46 @@ void TInspector_Preferences::StorePreferences()
|
||||
if (myLoadedPreferences.IsEmpty())
|
||||
return;
|
||||
|
||||
QString aFileName = QString (GetDirectory().ToCString()) + QDir::separator() + PreferencesFileName();
|
||||
QString aFileName =
|
||||
QString(GetDirectory().ToCString()) + QDir::separator() + PreferencesFileName();
|
||||
QFile aFile(aFileName);
|
||||
if (!aFile.open (QFile::WriteOnly))
|
||||
if (!aFile.open(QFile::WriteOnly))
|
||||
return;
|
||||
|
||||
QDomDocument aDomDocument (documentKey());
|
||||
QDomComment aComment = aDomDocument.createComment("\nThis file is automatically created by TInspector application.\nChanges made in this file can be lost.\n");
|
||||
aDomDocument.appendChild (aComment);
|
||||
QDomElement aRootElement = aDomDocument.createElement (documentKey());
|
||||
aDomDocument.appendChild (aRootElement);
|
||||
QDomDocument aDomDocument(documentKey());
|
||||
QDomComment aComment =
|
||||
aDomDocument.createComment("\nThis file is automatically created by TInspector "
|
||||
"application.\nChanges made in this file can be lost.\n");
|
||||
aDomDocument.appendChild(aComment);
|
||||
QDomElement aRootElement = aDomDocument.createElement(documentKey());
|
||||
aDomDocument.appendChild(aRootElement);
|
||||
|
||||
for (NCollection_DataMap<TCollection_AsciiString, TInspectorAPI_PreferencesDataMap>::Iterator aPrefsIt (myLoadedPreferences);
|
||||
aPrefsIt.More(); aPrefsIt.Next())
|
||||
for (NCollection_DataMap<TCollection_AsciiString, TInspectorAPI_PreferencesDataMap>::Iterator
|
||||
aPrefsIt(myLoadedPreferences);
|
||||
aPrefsIt.More();
|
||||
aPrefsIt.Next())
|
||||
{
|
||||
QDomElement aPluginElement = aDomDocument.createElement (pluginKey());
|
||||
aPluginElement.setAttribute (nameKey(), aPrefsIt.Key().ToCString());
|
||||
aRootElement.appendChild (aPluginElement);
|
||||
QDomElement aPluginElement = aDomDocument.createElement(pluginKey());
|
||||
aPluginElement.setAttribute(nameKey(), aPrefsIt.Key().ToCString());
|
||||
aRootElement.appendChild(aPluginElement);
|
||||
|
||||
const TInspectorAPI_PreferencesDataMap& aPluginMap = aPrefsIt.Value();
|
||||
for (TInspectorAPI_IteratorOfPreferencesDataMap aPluginPrefsIt (aPluginMap); aPluginPrefsIt.More(); aPluginPrefsIt.Next())
|
||||
for (TInspectorAPI_IteratorOfPreferencesDataMap aPluginPrefsIt(aPluginMap);
|
||||
aPluginPrefsIt.More();
|
||||
aPluginPrefsIt.Next())
|
||||
{
|
||||
QDomElement aParameterElement = aDomDocument.createElement (parameterKey());
|
||||
aParameterElement.setAttribute (nameKey(), aPluginPrefsIt.Key().ToCString());
|
||||
aParameterElement.setAttribute (valueKey(), aPluginPrefsIt.Value().ToCString());
|
||||
aPluginElement.appendChild (aParameterElement);
|
||||
QDomElement aParameterElement = aDomDocument.createElement(parameterKey());
|
||||
aParameterElement.setAttribute(nameKey(), aPluginPrefsIt.Key().ToCString());
|
||||
aParameterElement.setAttribute(valueKey(), aPluginPrefsIt.Value().ToCString());
|
||||
aPluginElement.appendChild(aParameterElement);
|
||||
}
|
||||
}
|
||||
|
||||
QTextStream aTextStream (&aFile);
|
||||
QStringList aDocumentStr = aDomDocument.toString().split ("\n");
|
||||
for (QStringList::ConstIterator aContentIt = aDocumentStr.begin(); aContentIt != aDocumentStr.end(); ++aContentIt)
|
||||
QTextStream aTextStream(&aFile);
|
||||
QStringList aDocumentStr = aDomDocument.toString().split("\n");
|
||||
for (QStringList::ConstIterator aContentIt = aDocumentStr.begin();
|
||||
aContentIt != aDocumentStr.end();
|
||||
++aContentIt)
|
||||
{
|
||||
aTextStream << *aContentIt << '\n';
|
||||
}
|
||||
@@ -91,10 +100,11 @@ void TInspector_Preferences::StorePreferences()
|
||||
// =======================================================================
|
||||
void TInspector_Preferences::RemovePreferences()
|
||||
{
|
||||
QString aFileName = QString (GetDirectory().ToCString()) + QDir::separator() + PreferencesFileName();
|
||||
QDir aDir (GetDirectory().ToCString());
|
||||
if (aDir.exists (aFileName))
|
||||
aDir.remove (aFileName);
|
||||
QString aFileName =
|
||||
QString(GetDirectory().ToCString()) + QDir::separator() + PreferencesFileName();
|
||||
QDir aDir(GetDirectory().ToCString());
|
||||
if (aDir.exists(aFileName))
|
||||
aDir.remove(aFileName);
|
||||
reset();
|
||||
}
|
||||
|
||||
@@ -104,13 +114,14 @@ void TInspector_Preferences::RemovePreferences()
|
||||
// =======================================================================
|
||||
void TInspector_Preferences::loadPreferences()
|
||||
{
|
||||
QString aFileName = QString (GetDirectory().ToCString()) + QDir::separator() + PreferencesFileName();
|
||||
QFile aFile (aFileName);
|
||||
if (!aFile.open (QFile::ReadOnly))
|
||||
QString aFileName =
|
||||
QString(GetDirectory().ToCString()) + QDir::separator() + PreferencesFileName();
|
||||
QFile aFile(aFileName);
|
||||
if (!aFile.open(QFile::ReadOnly))
|
||||
return;
|
||||
|
||||
QDomDocument aDomDocument;
|
||||
bool aResult = aDomDocument.setContent (&aFile);
|
||||
bool aResult = aDomDocument.setContent(&aFile);
|
||||
aFile.close();
|
||||
if (!aResult)
|
||||
return;
|
||||
@@ -125,11 +136,11 @@ void TInspector_Preferences::loadPreferences()
|
||||
if (aPluginNode.isElement())
|
||||
{
|
||||
QDomElement aPluginElement = aPluginNode.toElement();
|
||||
if (aPluginElement.tagName() == pluginKey() && aPluginElement.hasAttribute (nameKey()))
|
||||
if (aPluginElement.tagName() == pluginKey() && aPluginElement.hasAttribute(nameKey()))
|
||||
{
|
||||
TInspectorAPI_PreferencesDataMap anItem;
|
||||
readPluginItem (aPluginElement, anItem);
|
||||
myLoadedPreferences.Bind (aPluginElement.attribute (nameKey()).toStdString().c_str(), anItem);
|
||||
readPluginItem(aPluginElement, anItem);
|
||||
myLoadedPreferences.Bind(aPluginElement.attribute(nameKey()).toStdString().c_str(), anItem);
|
||||
}
|
||||
}
|
||||
aPluginNode = aPluginNode.nextSibling();
|
||||
@@ -140,7 +151,8 @@ void TInspector_Preferences::loadPreferences()
|
||||
// function : readPluginItem
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspector_Preferences::readPluginItem (const QDomElement thePluginElement, TInspectorAPI_PreferencesDataMap& theItem)
|
||||
void TInspector_Preferences::readPluginItem(const QDomElement thePluginElement,
|
||||
TInspectorAPI_PreferencesDataMap& theItem)
|
||||
{
|
||||
QDomNode aParameterNode = thePluginElement.firstChild();
|
||||
while (!aParameterNode.isNull())
|
||||
@@ -148,11 +160,11 @@ void TInspector_Preferences::readPluginItem (const QDomElement thePluginElement,
|
||||
if (aParameterNode.isElement())
|
||||
{
|
||||
QDomElement aParameterElement = aParameterNode.toElement();
|
||||
if (aParameterElement.tagName() == parameterKey() &&
|
||||
aParameterElement.hasAttribute (nameKey()) && aParameterElement.hasAttribute (valueKey()))
|
||||
if (aParameterElement.tagName() == parameterKey() && aParameterElement.hasAttribute(nameKey())
|
||||
&& aParameterElement.hasAttribute(valueKey()))
|
||||
{
|
||||
theItem.Bind (aParameterElement.attribute (nameKey()).toStdString().c_str(),
|
||||
aParameterElement.attribute (valueKey()).toStdString().c_str());
|
||||
theItem.Bind(aParameterElement.attribute(nameKey()).toStdString().c_str(),
|
||||
aParameterElement.attribute(valueKey()).toStdString().c_str());
|
||||
}
|
||||
}
|
||||
aParameterNode = aParameterNode.nextSibling();
|
||||
|
@@ -11,7 +11,7 @@
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef TInspector_Preferences_H
|
||||
#define TInspector_Preferences_H
|
||||
@@ -40,7 +40,11 @@ public:
|
||||
|
||||
//! Sets path to a preferences file
|
||||
//! \param thePath a path
|
||||
void SetDirectory (const TCollection_AsciiString& thePath) { reset(); myDirectory = thePath; }
|
||||
void SetDirectory(const TCollection_AsciiString& thePath)
|
||||
{
|
||||
reset();
|
||||
myDirectory = thePath;
|
||||
}
|
||||
|
||||
//! Returns path to a preferences file
|
||||
//! \return path
|
||||
@@ -48,14 +52,17 @@ public:
|
||||
|
||||
//! Returns plugin preferences
|
||||
//! \param thePluginName a plugin name
|
||||
Standard_EXPORT void GetPreferences (const TCollection_AsciiString& thePluginName,
|
||||
TInspectorAPI_PreferencesDataMap& theItem);
|
||||
Standard_EXPORT void GetPreferences(const TCollection_AsciiString& thePluginName,
|
||||
TInspectorAPI_PreferencesDataMap& theItem);
|
||||
|
||||
//! Stores plugin preferences
|
||||
//! \param thePluginName a plugin name
|
||||
//! \theItem container of plugin preferences values in form: <name, value>
|
||||
void SetPreferences (const TCollection_AsciiString& thePluginName, const TInspectorAPI_PreferencesDataMap& theItem)
|
||||
{ myLoadedPreferences.Bind(thePluginName, theItem); }
|
||||
void SetPreferences(const TCollection_AsciiString& thePluginName,
|
||||
const TInspectorAPI_PreferencesDataMap& theItem)
|
||||
{
|
||||
myLoadedPreferences.Bind(thePluginName, theItem);
|
||||
}
|
||||
|
||||
//! Stores plugin preferences into a preferences file
|
||||
Standard_EXPORT void StorePreferences();
|
||||
@@ -68,10 +75,15 @@ private:
|
||||
void loadPreferences();
|
||||
|
||||
//! Clears all internal containers with information of already loaded file
|
||||
void reset() { myLoadedPreferences.Clear(); myIsLoadedPreferences = Standard_False; }
|
||||
void reset()
|
||||
{
|
||||
myLoadedPreferences.Clear();
|
||||
myIsLoadedPreferences = Standard_False;
|
||||
}
|
||||
|
||||
//! Reads plugin preferences and fill container
|
||||
void readPluginItem(const QDomElement thePluginElement, TInspectorAPI_PreferencesDataMap& theItem);
|
||||
void readPluginItem(const QDomElement thePluginElement,
|
||||
TInspectorAPI_PreferencesDataMap& theItem);
|
||||
|
||||
//! Returns text of attribute document
|
||||
static Standard_CString documentKey() { return "document"; }
|
||||
@@ -92,7 +104,8 @@ private:
|
||||
//! directory of preferences file
|
||||
TCollection_AsciiString myDirectory;
|
||||
//! container of already loaded preferences : cache
|
||||
NCollection_DataMap<TCollection_AsciiString, TInspectorAPI_PreferencesDataMap> myLoadedPreferences;
|
||||
NCollection_DataMap<TCollection_AsciiString, TInspectorAPI_PreferencesDataMap>
|
||||
myLoadedPreferences;
|
||||
//! state whether the preferences of the current directory is loaded
|
||||
Standard_Boolean myIsLoadedPreferences;
|
||||
};
|
||||
|
@@ -11,7 +11,7 @@
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <inspector/TInspector_Shortcut.hxx>
|
||||
|
||||
@@ -26,30 +26,31 @@
|
||||
// function : Constructor
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TInspector_Shortcut::TInspector_Shortcut (QObject* theParent, TInspector_Window* theWindow)
|
||||
: QObject (theParent), myWindow (theWindow)
|
||||
TInspector_Shortcut::TInspector_Shortcut(QObject* theParent, TInspector_Window* theWindow)
|
||||
: QObject(theParent),
|
||||
myWindow(theWindow)
|
||||
{
|
||||
qApp->installEventFilter (this);
|
||||
qApp->installEventFilter(this);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : eventFilter
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool TInspector_Shortcut::eventFilter (QObject* theObject, QEvent* theEvent)
|
||||
bool TInspector_Shortcut::eventFilter(QObject* theObject, QEvent* theEvent)
|
||||
{
|
||||
if (!myWindow || theEvent->type() != QEvent::KeyRelease)
|
||||
return QObject::eventFilter (theObject, theEvent);
|
||||
return QObject::eventFilter(theObject, theEvent);
|
||||
|
||||
QKeyEvent* aKeyEvent = dynamic_cast<QKeyEvent*> (theEvent);
|
||||
QKeyEvent* aKeyEvent = dynamic_cast<QKeyEvent*>(theEvent);
|
||||
switch (aKeyEvent->key())
|
||||
{
|
||||
case Qt::Key_F5:
|
||||
{
|
||||
case Qt::Key_F5: {
|
||||
myWindow->UpdateContent();
|
||||
return true;
|
||||
}
|
||||
default: break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QObject::eventFilter (theObject, theEvent);
|
||||
return QObject::eventFilter(theObject, theEvent);
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef TInspector_Shortcut_H
|
||||
#define TInspector_Shortcut_H
|
||||
@@ -32,19 +32,17 @@ class QEvent;
|
||||
class TInspector_Shortcut : public QObject
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
Standard_EXPORT TInspector_Shortcut (QObject* theParent, TInspector_Window* theWindow);
|
||||
Standard_EXPORT TInspector_Shortcut(QObject* theParent, TInspector_Window* theWindow);
|
||||
|
||||
//! Destructor
|
||||
virtual ~TInspector_Shortcut() {}
|
||||
|
||||
//! Processes key release event to update view model, otherwise do usual QObject functionality
|
||||
Standard_EXPORT virtual bool eventFilter (QObject *theObject, QEvent* theEvent) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual bool eventFilter(QObject* theObject, QEvent* theEvent) Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
TInspector_Window* myWindow; //!< the current window
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -11,7 +11,7 @@
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <inspector/TInspector_Window.hxx>
|
||||
|
||||
@@ -40,8 +40,8 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <Standard_WarningsRestore.hxx>
|
||||
|
||||
const int TINSPECTOR_DEFAULT_WIDTH = 650;
|
||||
const int TINSPECTOR_DEFAULT_HEIGHT = 500;//350;
|
||||
const int TINSPECTOR_DEFAULT_WIDTH = 650;
|
||||
const int TINSPECTOR_DEFAULT_HEIGHT = 500; // 350;
|
||||
const int TINSPECTOR_DEFAULT_POSITION_X = 200;
|
||||
const int TINSPECTOR_DEFAULT_POSITION_Y = 60;
|
||||
|
||||
@@ -50,77 +50,78 @@ const int TINSPECTOR_DEFAULT_POSITION_Y = 60;
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
TInspector_Window::TInspector_Window()
|
||||
: QObject(), myOpenButton (0)
|
||||
: QObject(),
|
||||
myOpenButton(0)
|
||||
{
|
||||
myMainWindow = new QMainWindow();
|
||||
|
||||
QWidget* aCentralWidget = new QWidget (myMainWindow);
|
||||
myMainWindow->setCentralWidget (aCentralWidget);
|
||||
QVBoxLayout* aCentralLayout = new QVBoxLayout (aCentralWidget);
|
||||
aCentralLayout->setContentsMargins (0, 0, 0, 0);
|
||||
aCentralLayout->setSpacing (0);
|
||||
QWidget* aCentralWidget = new QWidget(myMainWindow);
|
||||
myMainWindow->setCentralWidget(aCentralWidget);
|
||||
QVBoxLayout* aCentralLayout = new QVBoxLayout(aCentralWidget);
|
||||
aCentralLayout->setContentsMargins(0, 0, 0, 0);
|
||||
aCentralLayout->setSpacing(0);
|
||||
|
||||
myToolsStack = new QStackedWidget (aCentralWidget);
|
||||
myToolsStack->setFrameShape (QFrame::Box);
|
||||
aCentralLayout->addWidget (myToolsStack);
|
||||
myToolsStack = new QStackedWidget(aCentralWidget);
|
||||
myToolsStack->setFrameShape(QFrame::Box);
|
||||
aCentralLayout->addWidget(myToolsStack);
|
||||
|
||||
myEmptyWidget = new QWidget (aCentralWidget);
|
||||
myToolsStack->addWidget (myEmptyWidget);
|
||||
myEmptyWidget = new QWidget(aCentralWidget);
|
||||
myToolsStack->addWidget(myEmptyWidget);
|
||||
|
||||
QWidget* aTopWidget = new QWidget (aCentralWidget);
|
||||
QHBoxLayout* aTopWidgetLayout = new QHBoxLayout (aTopWidget);
|
||||
aTopWidgetLayout->setContentsMargins (0, 0, 0, 0);
|
||||
aTopWidgetLayout->setSpacing (0);
|
||||
QWidget* aTopWidget = new QWidget(aCentralWidget);
|
||||
QHBoxLayout* aTopWidgetLayout = new QHBoxLayout(aTopWidget);
|
||||
aTopWidgetLayout->setContentsMargins(0, 0, 0, 0);
|
||||
aTopWidgetLayout->setSpacing(0);
|
||||
|
||||
myButtonWidget = new QWidget (aCentralWidget);
|
||||
myButtonLay = new QHBoxLayout (myButtonWidget);
|
||||
myButtonLay->setContentsMargins (0, 0, 0, 0);
|
||||
myButtonLay->setSpacing (0);
|
||||
myButtonLay->insertStretch (0, 1);
|
||||
myButtonWidget = new QWidget(aCentralWidget);
|
||||
myButtonLay = new QHBoxLayout(myButtonWidget);
|
||||
myButtonLay->setContentsMargins(0, 0, 0, 0);
|
||||
myButtonLay->setSpacing(0);
|
||||
myButtonLay->insertStretch(0, 1);
|
||||
|
||||
myButtonGroup = new QButtonGroup (aCentralWidget);
|
||||
myButtonGroup->setExclusive (true);
|
||||
myButtonGroup = new QButtonGroup(aCentralWidget);
|
||||
myButtonGroup->setExclusive(true);
|
||||
|
||||
myActionsWidget = new QToolButton(aCentralWidget);
|
||||
myActionsWidget->setPopupMode(QToolButton::InstantPopup);
|
||||
myActionsWidget->setIcon (QIcon (":plugin_actions.png"));
|
||||
myActionsWidget->setIconSize (QSize (20, 20));
|
||||
myActionsWidget->setIcon(QIcon(":plugin_actions.png"));
|
||||
myActionsWidget->setIconSize(QSize(20, 20));
|
||||
QMenu* anActionsMenu = new QMenu(myActionsWidget);
|
||||
myActionsWidget->setMenu(anActionsMenu);
|
||||
connect (anActionsMenu, SIGNAL (aboutToShow()), this, SLOT (onShowActionsMenu()));
|
||||
connect(anActionsMenu, SIGNAL(aboutToShow()), this, SLOT(onShowActionsMenu()));
|
||||
|
||||
aTopWidgetLayout->addWidget(myButtonWidget, 1);
|
||||
aTopWidgetLayout->addWidget(myActionsWidget);
|
||||
|
||||
aCentralLayout->addWidget (aTopWidget);
|
||||
aCentralLayout->addWidget (myToolsStack);
|
||||
aCentralLayout->addWidget(aTopWidget);
|
||||
aCentralLayout->addWidget(myToolsStack);
|
||||
|
||||
myMainWindow->resize (TINSPECTOR_DEFAULT_WIDTH, TINSPECTOR_DEFAULT_HEIGHT);
|
||||
myMainWindow->move (TINSPECTOR_DEFAULT_POSITION_X, TINSPECTOR_DEFAULT_POSITION_Y);
|
||||
myMainWindow->setDockOptions (QMainWindow::VerticalTabs);
|
||||
myMainWindow->resize(TINSPECTOR_DEFAULT_WIDTH, TINSPECTOR_DEFAULT_HEIGHT);
|
||||
myMainWindow->move(TINSPECTOR_DEFAULT_POSITION_X, TINSPECTOR_DEFAULT_POSITION_Y);
|
||||
myMainWindow->setDockOptions(QMainWindow::VerticalTabs);
|
||||
|
||||
myParameters = new TInspector_PluginParameters (this);
|
||||
myParameters = new TInspector_PluginParameters(this);
|
||||
|
||||
myDefaultDirectory = defaultTemporaryDirectory();
|
||||
myParameters->SetTemporaryDirectory (myDefaultDirectory);
|
||||
myParameters->SetTemporaryDirectory(myDefaultDirectory);
|
||||
|
||||
applyPreferences();
|
||||
|
||||
myShortcut = new TInspector_Shortcut (myMainWindow, this);
|
||||
myShortcut = new TInspector_Shortcut(myMainWindow, this);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : RegisterPlugin
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspector_Window::RegisterPlugin (const TCollection_AsciiString& thePluginName)
|
||||
void TInspector_Window::RegisterPlugin(const TCollection_AsciiString& thePluginName)
|
||||
{
|
||||
TInspector_ToolInfo anInfo;
|
||||
int aToolId;
|
||||
if (findPlugin (thePluginName, anInfo, aToolId))
|
||||
int aToolId;
|
||||
if (findPlugin(thePluginName, anInfo, aToolId))
|
||||
return;
|
||||
|
||||
myToolNames.append (TInspector_ToolInfo (thePluginName));
|
||||
myToolNames.append(TInspector_ToolInfo(thePluginName));
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -132,7 +133,7 @@ NCollection_List<TCollection_AsciiString> TInspector_Window::RegisteredPlugins()
|
||||
NCollection_List<TCollection_AsciiString> aPlugins;
|
||||
|
||||
for (int aToolId = 0, aSize = myToolNames.size(); aToolId < aSize; aToolId++)
|
||||
aPlugins.Append (myToolNames[aToolId].myName);
|
||||
aPlugins.Append(myToolNames[aToolId].myName);
|
||||
|
||||
return aPlugins;
|
||||
}
|
||||
@@ -141,40 +142,41 @@ NCollection_List<TCollection_AsciiString> TInspector_Window::RegisteredPlugins()
|
||||
// function : Init
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspector_Window::Init (const TCollection_AsciiString& thePluginName,
|
||||
const NCollection_List<Handle(Standard_Transient)>& theParameters,
|
||||
const Standard_Boolean theAppend)
|
||||
void TInspector_Window::Init(const TCollection_AsciiString& thePluginName,
|
||||
const NCollection_List<Handle(Standard_Transient)>& theParameters,
|
||||
const Standard_Boolean theAppend)
|
||||
{
|
||||
if (thePluginName.IsEmpty())
|
||||
{
|
||||
// Init all plugins by the given parameters
|
||||
for (int aToolId = 0, aSize = myToolNames.size(); aToolId < aSize; aToolId++)
|
||||
Init (myToolNames[aToolId].myName, theParameters, theAppend);
|
||||
Init(myToolNames[aToolId].myName, theParameters, theAppend);
|
||||
|
||||
// temporary activation of the first tool
|
||||
if (!myToolNames.isEmpty())
|
||||
ActivateTool (myToolNames[0].myName);
|
||||
ActivateTool(myToolNames[0].myName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (theAppend)
|
||||
{
|
||||
NCollection_List<Handle(Standard_Transient)> aParameters;
|
||||
if (myParameters->FindParameters (thePluginName))
|
||||
aParameters = myParameters->Parameters (thePluginName);
|
||||
if (myParameters->FindParameters(thePluginName))
|
||||
aParameters = myParameters->Parameters(thePluginName);
|
||||
|
||||
for (NCollection_List<Handle(Standard_Transient)>::Iterator anIterator (theParameters);
|
||||
anIterator.More(); anIterator.Next())
|
||||
aParameters.Append (anIterator.Value());
|
||||
for (NCollection_List<Handle(Standard_Transient)>::Iterator anIterator(theParameters);
|
||||
anIterator.More();
|
||||
anIterator.Next())
|
||||
aParameters.Append(anIterator.Value());
|
||||
|
||||
myParameters->SetParameters (thePluginName, aParameters, Standard_False);
|
||||
myParameters->SetParameters(thePluginName, aParameters, Standard_False);
|
||||
}
|
||||
else
|
||||
myParameters->SetParameters (thePluginName, theParameters, Standard_False);
|
||||
myParameters->SetParameters(thePluginName, theParameters, Standard_False);
|
||||
|
||||
TInspector_ToolInfo anInfo;
|
||||
int aToolId;
|
||||
if (!findPlugin (thePluginName, anInfo, aToolId))
|
||||
int aToolId;
|
||||
if (!findPlugin(thePluginName, anInfo, aToolId))
|
||||
return;
|
||||
|
||||
if (anInfo.myButton)
|
||||
@@ -185,11 +187,11 @@ void TInspector_Window::Init (const TCollection_AsciiString& thePluginName,
|
||||
aButtonName = aButtonName.mid(2);
|
||||
|
||||
QPushButton* aButton = new QPushButton(aButtonName, myButtonWidget);
|
||||
aButton->setCheckable (true);
|
||||
connect (aButton, SIGNAL (clicked (bool)), this, SLOT (onButtonClicked()));
|
||||
myButtonLay->insertWidget (myButtonLay->count()-1, aButton);
|
||||
myButtonGroup->addButton (aButton);
|
||||
anInfo.myButton = aButton;
|
||||
aButton->setCheckable(true);
|
||||
connect(aButton, SIGNAL(clicked(bool)), this, SLOT(onButtonClicked()));
|
||||
myButtonLay->insertWidget(myButtonLay->count() - 1, aButton);
|
||||
myButtonGroup->addButton(aButton);
|
||||
anInfo.myButton = aButton;
|
||||
myToolNames[aToolId] = anInfo;
|
||||
}
|
||||
|
||||
@@ -197,7 +199,7 @@ void TInspector_Window::Init (const TCollection_AsciiString& thePluginName,
|
||||
// function : ActivateTool
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspector_Window::ActivateTool (const TCollection_AsciiString& thePluginName)
|
||||
void TInspector_Window::ActivateTool(const TCollection_AsciiString& thePluginName)
|
||||
{
|
||||
int aToolIndex = -1;
|
||||
for (int aToolId = 0, aSize = myToolNames.size(); aToolId < aSize; aToolId++)
|
||||
@@ -211,32 +213,32 @@ void TInspector_Window::ActivateTool (const TCollection_AsciiString& thePluginNa
|
||||
if (aToolIndex < 0)
|
||||
return;
|
||||
|
||||
TInspector_ToolInfo anInfo = myToolNames[aToolIndex];
|
||||
bool isPluginLoaded = false;
|
||||
TInspector_ToolInfo anInfo = myToolNames[aToolIndex];
|
||||
bool isPluginLoaded = false;
|
||||
if (!anInfo.myWidget)
|
||||
{
|
||||
if (!LoadPlugin (thePluginName, anInfo))
|
||||
if (!LoadPlugin(thePluginName, anInfo))
|
||||
{
|
||||
anInfo.myButton->setEnabled (false);
|
||||
anInfo.myButton->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
isPluginLoaded = true;
|
||||
myToolsStack->addWidget (anInfo.myWidget);
|
||||
myToolsStack->addWidget(anInfo.myWidget);
|
||||
myToolNames[aToolIndex] = anInfo;
|
||||
}
|
||||
|
||||
QWidget* aWidget = anInfo.myWidget;
|
||||
myToolsStack->setCurrentWidget (aWidget);
|
||||
myToolsStack->setCurrentWidget(aWidget);
|
||||
if (myOpenButton)
|
||||
myOpenButton->setObjectName (thePluginName.ToCString());
|
||||
myOpenButton->setObjectName(thePluginName.ToCString());
|
||||
|
||||
anInfo.myCommunicator->UpdateContent();
|
||||
if (isPluginLoaded)
|
||||
{
|
||||
// apply preferences
|
||||
TInspectorAPI_PreferencesDataMap aPreferences;
|
||||
myParameters->GetPreferences (thePluginName, aPreferences);
|
||||
anInfo.myCommunicator->SetPreferences (aPreferences);
|
||||
myParameters->GetPreferences(thePluginName, aPreferences);
|
||||
anInfo.myCommunicator->SetPreferences(aPreferences);
|
||||
}
|
||||
onCommuncatorNameChanged();
|
||||
}
|
||||
@@ -245,13 +247,13 @@ void TInspector_Window::ActivateTool (const TCollection_AsciiString& thePluginNa
|
||||
// function : SetSelected
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspector_Window::SetSelected (const NCollection_List<TCollection_AsciiString>& theItemNames)
|
||||
void TInspector_Window::SetSelected(const NCollection_List<TCollection_AsciiString>& theItemNames)
|
||||
{
|
||||
TInspector_ToolInfo anInfo;
|
||||
if (!activeToolInfo (anInfo))
|
||||
if (!activeToolInfo(anInfo))
|
||||
return;
|
||||
|
||||
myParameters->SetSelectedNames (anInfo.myName, theItemNames);
|
||||
myParameters->SetSelectedNames(anInfo.myName, theItemNames);
|
||||
|
||||
TInspectorAPI_Communicator* aCommunicator = anInfo.myCommunicator;
|
||||
if (aCommunicator)
|
||||
@@ -264,13 +266,13 @@ void TInspector_Window::SetSelected (const NCollection_List<TCollection_AsciiStr
|
||||
// function : SetSelected
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspector_Window::SetSelected (const NCollection_List<Handle(Standard_Transient)>& theObjects)
|
||||
void TInspector_Window::SetSelected(const NCollection_List<Handle(Standard_Transient)>& theObjects)
|
||||
{
|
||||
TInspector_ToolInfo anInfo;
|
||||
if (!activeToolInfo (anInfo))
|
||||
if (!activeToolInfo(anInfo))
|
||||
return;
|
||||
|
||||
myParameters->SetSelected (anInfo.myName, theObjects);
|
||||
myParameters->SetSelected(anInfo.myName, theObjects);
|
||||
|
||||
TInspectorAPI_Communicator* aCommunicator = anInfo.myCommunicator;
|
||||
if (aCommunicator)
|
||||
@@ -283,34 +285,34 @@ void TInspector_Window::SetSelected (const NCollection_List<Handle(Standard_Tran
|
||||
// function : SetOpenButton
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspector_Window::SetOpenButton (QPushButton* theButton)
|
||||
void TInspector_Window::SetOpenButton(QPushButton* theButton)
|
||||
{
|
||||
myOpenButton = theButton;
|
||||
TInspector_ToolInfo anInfo;
|
||||
if (activeToolInfo (anInfo))
|
||||
myOpenButton->setObjectName (anInfo.myName.ToCString());
|
||||
myButtonLay->insertWidget (0, theButton);
|
||||
if (activeToolInfo(anInfo))
|
||||
myOpenButton->setObjectName(anInfo.myName.ToCString());
|
||||
myButtonLay->insertWidget(0, theButton);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : OpenFile
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspector_Window::OpenFile (const TCollection_AsciiString& thePluginName,
|
||||
const TCollection_AsciiString& theFileName)
|
||||
void TInspector_Window::OpenFile(const TCollection_AsciiString& thePluginName,
|
||||
const TCollection_AsciiString& theFileName)
|
||||
{
|
||||
if (thePluginName.IsEmpty())
|
||||
{
|
||||
// Apply file name to all plugins
|
||||
for (int aToolId = 0, aSize = myToolNames.size(); aToolId < aSize; aToolId++)
|
||||
OpenFile (myToolNames[aToolId].myName, theFileName);
|
||||
OpenFile(myToolNames[aToolId].myName, theFileName);
|
||||
return;
|
||||
}
|
||||
|
||||
myParameters->AddFileName (thePluginName, theFileName);
|
||||
myParameters->AddFileName(thePluginName, theFileName);
|
||||
|
||||
TInspector_ToolInfo anInfo;
|
||||
if (!activeToolInfo (anInfo) || anInfo.myName != thePluginName)
|
||||
if (!activeToolInfo(anInfo) || anInfo.myName != thePluginName)
|
||||
return;
|
||||
|
||||
TInspectorAPI_Communicator* aCommunicator = anInfo.myCommunicator;
|
||||
@@ -325,7 +327,7 @@ void TInspector_Window::OpenFile (const TCollection_AsciiString& thePluginName,
|
||||
void TInspector_Window::UpdateContent()
|
||||
{
|
||||
TInspector_ToolInfo anInfo;
|
||||
if (activeToolInfo (anInfo) && anInfo.myCommunicator)
|
||||
if (activeToolInfo(anInfo) && anInfo.myCommunicator)
|
||||
anInfo.myCommunicator->UpdateContent();
|
||||
}
|
||||
|
||||
@@ -333,26 +335,31 @@ void TInspector_Window::UpdateContent()
|
||||
// function : LoadPlugin
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool TInspector_Window::LoadPlugin (const TCollection_AsciiString& thePluginName, TInspector_ToolInfo& theInfo)
|
||||
bool TInspector_Window::LoadPlugin(const TCollection_AsciiString& thePluginName,
|
||||
TInspector_ToolInfo& theInfo)
|
||||
{
|
||||
bool aLoaded = false;
|
||||
|
||||
QApplication::setOverrideCursor (Qt::WaitCursor);
|
||||
TInspectorAPI_Communicator* aCommunicator = TInspectorAPI_Communicator::LoadPluginLibrary (thePluginName);
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
TInspectorAPI_Communicator* aCommunicator =
|
||||
TInspectorAPI_Communicator::LoadPluginLibrary(thePluginName);
|
||||
|
||||
if (aCommunicator)
|
||||
{
|
||||
aCommunicator->SetParameters (myParameters);
|
||||
QWidget* aParentWidget = new QWidget (myMainWindow);
|
||||
QVBoxLayout* aLayout = new QVBoxLayout (aParentWidget);
|
||||
aLayout->setContentsMargins (0, 0, 0, 0);
|
||||
aLayout->setSpacing (0);
|
||||
aParentWidget->setLayout (aLayout);
|
||||
aCommunicator->SetParent (aParentWidget);
|
||||
theInfo.myWidget = aParentWidget;
|
||||
aCommunicator->SetParameters(myParameters);
|
||||
QWidget* aParentWidget = new QWidget(myMainWindow);
|
||||
QVBoxLayout* aLayout = new QVBoxLayout(aParentWidget);
|
||||
aLayout->setContentsMargins(0, 0, 0, 0);
|
||||
aLayout->setSpacing(0);
|
||||
aParentWidget->setLayout(aLayout);
|
||||
aCommunicator->SetParent(aParentWidget);
|
||||
theInfo.myWidget = aParentWidget;
|
||||
theInfo.myCommunicator = aCommunicator;
|
||||
#if QT_VERSION >= 0x050000
|
||||
connect (aParentWidget, SIGNAL (objectNameChanged (const QString&)), this, SLOT (onCommuncatorNameChanged()));
|
||||
connect(aParentWidget,
|
||||
SIGNAL(objectNameChanged(const QString&)),
|
||||
this,
|
||||
SLOT(onCommuncatorNameChanged()));
|
||||
#endif
|
||||
aLoaded = true;
|
||||
}
|
||||
@@ -364,21 +371,23 @@ bool TInspector_Window::LoadPlugin (const TCollection_AsciiString& thePluginName
|
||||
// function : GetPreferences
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspector_Window::GetPreferences (TInspectorAPI_PreferencesDataMap& theItem)
|
||||
void TInspector_Window::GetPreferences(TInspectorAPI_PreferencesDataMap& theItem)
|
||||
{
|
||||
theItem.Bind ("geometry", TreeModel_Tools::ToString (myMainWindow->saveGeometry()).toStdString().c_str());
|
||||
theItem.Bind("geometry",
|
||||
TreeModel_Tools::ToString(myMainWindow->saveGeometry()).toStdString().c_str());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetPreferences
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspector_Window::SetPreferences (const TInspectorAPI_PreferencesDataMap& theItem)
|
||||
void TInspector_Window::SetPreferences(const TInspectorAPI_PreferencesDataMap& theItem)
|
||||
{
|
||||
for (TInspectorAPI_IteratorOfPreferencesDataMap anItemIt (theItem); anItemIt.More(); anItemIt.Next())
|
||||
for (TInspectorAPI_IteratorOfPreferencesDataMap anItemIt(theItem); anItemIt.More();
|
||||
anItemIt.Next())
|
||||
{
|
||||
if (anItemIt.Key().IsEqual ("geometry"))
|
||||
myMainWindow->restoreGeometry (TreeModel_Tools::ToByteArray (anItemIt.Value().ToCString()));
|
||||
if (anItemIt.Key().IsEqual("geometry"))
|
||||
myMainWindow->restoreGeometry(TreeModel_Tools::ToByteArray(anItemIt.Value().ToCString()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,7 +395,7 @@ void TInspector_Window::SetPreferences (const TInspectorAPI_PreferencesDataMap&
|
||||
// function : Dump
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TInspector_Window::Dump (Standard_OStream& theStream) const
|
||||
void TInspector_Window::Dump(Standard_OStream& theStream) const
|
||||
{
|
||||
TInspector_ToolInfo anInfo;
|
||||
activeToolInfo(anInfo);
|
||||
@@ -401,10 +410,11 @@ void TInspector_Window::Dump (Standard_OStream& theStream) const
|
||||
// =======================================================================
|
||||
void TInspector_Window::OnStorePreferences()
|
||||
{
|
||||
Handle(TInspector_PluginParameters) aParameters = Handle(TInspector_PluginParameters)::DownCast (myParameters);
|
||||
Handle(TInspector_PluginParameters) aParameters =
|
||||
Handle(TInspector_PluginParameters)::DownCast(myParameters);
|
||||
TInspectorAPI_PreferencesDataMap aPreferences;
|
||||
GetPreferences (aPreferences);
|
||||
aParameters->SetPreferences ("Desktop", aPreferences);
|
||||
GetPreferences(aPreferences);
|
||||
aParameters->SetPreferences("Desktop", aPreferences);
|
||||
|
||||
TInspector_ToolInfo anInfo;
|
||||
for (int aToolId = 0, aSize = myToolNames.size(); aToolId < aSize; aToolId++)
|
||||
@@ -413,9 +423,9 @@ void TInspector_Window::OnStorePreferences()
|
||||
if (!anInfo.myCommunicator)
|
||||
continue;
|
||||
|
||||
aParameters->GetPreferences (anInfo.myName, aPreferences);
|
||||
anInfo.myCommunicator->GetPreferences (aPreferences);
|
||||
myParameters->SetPreferences (anInfo.myName, aPreferences);
|
||||
aParameters->GetPreferences(anInfo.myName, aPreferences);
|
||||
anInfo.myCommunicator->GetPreferences(aPreferences);
|
||||
myParameters->SetPreferences(anInfo.myName, aPreferences);
|
||||
}
|
||||
|
||||
// store preferences parameters into a file
|
||||
@@ -428,7 +438,8 @@ void TInspector_Window::OnStorePreferences()
|
||||
// =======================================================================
|
||||
void TInspector_Window::OnRemovePreferences()
|
||||
{
|
||||
Handle(TInspector_PluginParameters) aParameters = Handle(TInspector_PluginParameters)::DownCast (myParameters);
|
||||
Handle(TInspector_PluginParameters) aParameters =
|
||||
Handle(TInspector_PluginParameters)::DownCast(myParameters);
|
||||
|
||||
// remove preferences file
|
||||
aParameters->RemovePreferences();
|
||||
@@ -440,7 +451,7 @@ void TInspector_Window::OnRemovePreferences()
|
||||
anInfo = myToolNames[aToolId];
|
||||
if (!anInfo.myCommunicator)
|
||||
continue;
|
||||
anInfo.myCommunicator->SetPreferences (TInspectorAPI_PreferencesDataMap());
|
||||
anInfo.myCommunicator->SetPreferences(TInspectorAPI_PreferencesDataMap());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -455,11 +466,11 @@ void TInspector_Window::onButtonClicked()
|
||||
TCollection_AsciiString aPluginName = aButton->text().toStdString().c_str();
|
||||
|
||||
TInspector_ToolInfo anInfo;
|
||||
int aToolId;
|
||||
if (!findPlugin (aPluginName, anInfo, aToolId))
|
||||
aPluginName = TCollection_AsciiString ("TK") + aPluginName;
|
||||
int aToolId;
|
||||
if (!findPlugin(aPluginName, anInfo, aToolId))
|
||||
aPluginName = TCollection_AsciiString("TK") + aPluginName;
|
||||
|
||||
ActivateTool (aPluginName);
|
||||
ActivateTool(aPluginName);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -477,12 +488,16 @@ void TInspector_Window::onShowActionsMenu()
|
||||
anInfo.myCommunicator->FillActionsMenu(aMenu);
|
||||
|
||||
aMenu->addSeparator();
|
||||
aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Store Preferences"),
|
||||
SLOT (OnStorePreferences()), myMainWindow, this));
|
||||
QAction* anAction = ViewControl_Tools::CreateAction (tr ("Remove Preferences"),
|
||||
SLOT (OnRemovePreferences()), myMainWindow, this);
|
||||
anAction->setToolTip ("Default state will be restored after restarting the application");
|
||||
aMenu->addAction (anAction);
|
||||
aMenu->addAction(ViewControl_Tools::CreateAction(tr("Store Preferences"),
|
||||
SLOT(OnStorePreferences()),
|
||||
myMainWindow,
|
||||
this));
|
||||
QAction* anAction = ViewControl_Tools::CreateAction(tr("Remove Preferences"),
|
||||
SLOT(OnRemovePreferences()),
|
||||
myMainWindow,
|
||||
this);
|
||||
anAction->setToolTip("Default state will be restored after restarting the application");
|
||||
aMenu->addAction(anAction);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -493,9 +508,9 @@ void TInspector_Window::onCommuncatorNameChanged()
|
||||
{
|
||||
#if QT_VERSION >= 0x050000
|
||||
TInspector_ToolInfo anInfo;
|
||||
if (!activeToolInfo (anInfo))
|
||||
if (!activeToolInfo(anInfo))
|
||||
return;
|
||||
myMainWindow->setWindowTitle (anInfo.myWidget->objectName());
|
||||
myMainWindow->setWindowTitle(anInfo.myWidget->objectName());
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -503,7 +518,7 @@ void TInspector_Window::onCommuncatorNameChanged()
|
||||
// function : activeToolInfo
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool TInspector_Window::activeToolInfo (TInspector_Window::TInspector_ToolInfo& theToolInfo) const
|
||||
bool TInspector_Window::activeToolInfo(TInspector_Window::TInspector_ToolInfo& theToolInfo) const
|
||||
{
|
||||
QWidget* anActiveWidget = myToolsStack->currentWidget();
|
||||
if (anActiveWidget == myEmptyWidget)
|
||||
@@ -524,8 +539,9 @@ bool TInspector_Window::activeToolInfo (TInspector_Window::TInspector_ToolInfo&
|
||||
// function : findPlugin
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool TInspector_Window::findPlugin (const TCollection_AsciiString& thePluginName, TInspector_ToolInfo& theToolInfo,
|
||||
int& theToolId)
|
||||
bool TInspector_Window::findPlugin(const TCollection_AsciiString& thePluginName,
|
||||
TInspector_ToolInfo& theToolInfo,
|
||||
int& theToolId)
|
||||
{
|
||||
for (int aToolId = 0, aSize = myToolNames.size(); aToolId < aSize; aToolId++)
|
||||
{
|
||||
@@ -533,7 +549,7 @@ bool TInspector_Window::findPlugin (const TCollection_AsciiString& thePluginName
|
||||
if (anInfo.myName != thePluginName)
|
||||
continue;
|
||||
theToolInfo = anInfo;
|
||||
theToolId = aToolId;
|
||||
theToolId = aToolId;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -547,8 +563,8 @@ bool TInspector_Window::findPlugin (const TCollection_AsciiString& thePluginName
|
||||
void TInspector_Window::applyPreferences()
|
||||
{
|
||||
TInspectorAPI_PreferencesDataMap aPreferences;
|
||||
myParameters->GetPreferences ("Desktop", aPreferences);
|
||||
SetPreferences (aPreferences);
|
||||
myParameters->GetPreferences("Desktop", aPreferences);
|
||||
SetPreferences(aPreferences);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -560,32 +576,32 @@ TCollection_AsciiString TInspector_Window::defaultTemporaryDirectory() const
|
||||
// main window creation
|
||||
TCollection_AsciiString aTmpDir;
|
||||
#ifdef _WIN32
|
||||
OSD_Environment anEnvironment ("TEMP");
|
||||
OSD_Environment anEnvironment("TEMP");
|
||||
aTmpDir = anEnvironment.Value();
|
||||
if (aTmpDir.IsEmpty() )
|
||||
if (aTmpDir.IsEmpty())
|
||||
{
|
||||
anEnvironment.SetName ("TMP");
|
||||
anEnvironment.SetName("TMP");
|
||||
aTmpDir = anEnvironment.Value();
|
||||
if (aTmpDir.IsEmpty())
|
||||
aTmpDir = "C:\\";
|
||||
}
|
||||
if (!aTmpDir.EndsWith ("\\"))
|
||||
if (!aTmpDir.EndsWith("\\"))
|
||||
aTmpDir += "\\";
|
||||
OSD_Path aTmpPath (aTmpDir);
|
||||
OSD_Path aTmpPath(aTmpDir);
|
||||
OSD_Directory aTmpDirectory;
|
||||
#else
|
||||
OSD_Directory aTmpDirectory = OSD_Directory::BuildTemporary();
|
||||
OSD_Path aTmpPath;
|
||||
aTmpDirectory.Path (aTmpPath);
|
||||
OSD_Path aTmpPath;
|
||||
aTmpDirectory.Path(aTmpPath);
|
||||
#endif
|
||||
aTmpPath.DownTrek ("TInspector");
|
||||
aTmpDirectory.SetPath (aTmpPath);
|
||||
aTmpPath.DownTrek("TInspector");
|
||||
aTmpDirectory.SetPath(aTmpPath);
|
||||
if (!aTmpDirectory.Exists())
|
||||
aTmpDirectory.Build (OSD_Protection());
|
||||
aTmpDirectory.Build(OSD_Protection());
|
||||
|
||||
aTmpDirectory.Path (aTmpPath);
|
||||
aTmpDirectory.Path(aTmpPath);
|
||||
TCollection_AsciiString aTmpDirectoryName;
|
||||
aTmpPath.SystemName (aTmpDirectoryName);
|
||||
aTmpPath.SystemName(aTmpDirectoryName);
|
||||
|
||||
return aTmpDir;
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef TInspector_Window_H
|
||||
#define TInspector_Window_H
|
||||
@@ -47,23 +47,27 @@ class TInspector_Window : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
|
||||
//! Container of plugin information
|
||||
struct TInspector_ToolInfo
|
||||
{
|
||||
|
||||
//! Constructor
|
||||
TInspector_ToolInfo (const TCollection_AsciiString& theName = TCollection_AsciiString())
|
||||
: myName(theName), myCommunicator (0), myButton (0), myWidget (0) {}
|
||||
TInspector_ToolInfo(const TCollection_AsciiString& theName = TCollection_AsciiString())
|
||||
: myName(theName),
|
||||
myCommunicator(0),
|
||||
myButton(0),
|
||||
myWidget(0)
|
||||
{
|
||||
}
|
||||
|
||||
TCollection_AsciiString myName; //!< plugin name
|
||||
TCollection_AsciiString myName; //!< plugin name
|
||||
TInspectorAPI_Communicator* myCommunicator; //!< plugin communicator
|
||||
QPushButton* myButton; //!< button with plugin name, that will be added into TInspector window layout
|
||||
QPushButton*
|
||||
myButton; //!< button with plugin name, that will be added into TInspector window layout
|
||||
QWidget* myWidget; //!< parent widget of the plugin
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
Standard_EXPORT TInspector_Window();
|
||||
|
||||
@@ -72,25 +76,25 @@ public:
|
||||
|
||||
//! Appends the plugin names into internal container
|
||||
//! \param thePluginName a name of the plugin
|
||||
Standard_EXPORT void RegisterPlugin (const TCollection_AsciiString& thePluginName);
|
||||
Standard_EXPORT void RegisterPlugin(const TCollection_AsciiString& thePluginName);
|
||||
|
||||
//! Returns list of registered plugins
|
||||
//! \return container of plugin names
|
||||
Standard_EXPORT NCollection_List<TCollection_AsciiString> RegisteredPlugins() const;
|
||||
|
||||
//! Stores parameters for the plugin. If the plugin name is empty, it inits all plugins with the parameters
|
||||
//! \param thePluginName a name of the plugin
|
||||
//! \param theParameters container of parameters(e.g. AIS_InteractiveContext, TDocStd_Application)
|
||||
//! \param theAppend boolean state whether the parameters should be added to existing
|
||||
Standard_EXPORT void Init (const TCollection_AsciiString& thePluginName,
|
||||
const NCollection_List<Handle(Standard_Transient)>& theParameters,
|
||||
const Standard_Boolean theAppend = Standard_False);
|
||||
//! Stores parameters for the plugin. If the plugin name is empty, it inits all plugins with the
|
||||
//! parameters \param thePluginName a name of the plugin \param theParameters container of
|
||||
//! parameters(e.g. AIS_InteractiveContext, TDocStd_Application) \param theAppend boolean state
|
||||
//! whether the parameters should be added to existing
|
||||
Standard_EXPORT void Init(const TCollection_AsciiString& thePluginName,
|
||||
const NCollection_List<Handle(Standard_Transient)>& theParameters,
|
||||
const Standard_Boolean theAppend = Standard_False);
|
||||
|
||||
//! Appends to container of parameters the given name, if the given parameter is active, cal UpdateContent
|
||||
//! \param thePluginName a name of the plugin
|
||||
//! \param theParameters container of parameters(e.g. AIS_InteractiveContext, TDocStd_Application)
|
||||
Standard_EXPORT void OpenFile (const TCollection_AsciiString& thePluginName,
|
||||
const TCollection_AsciiString& theFileName);
|
||||
//! Appends to container of parameters the given name, if the given parameter is active, cal
|
||||
//! UpdateContent \param thePluginName a name of the plugin \param theParameters container of
|
||||
//! parameters(e.g. AIS_InteractiveContext, TDocStd_Application)
|
||||
Standard_EXPORT void OpenFile(const TCollection_AsciiString& thePluginName,
|
||||
const TCollection_AsciiString& theFileName);
|
||||
|
||||
//! Calls UpdateContent for the active plugin
|
||||
Standard_EXPORT void UpdateContent();
|
||||
@@ -100,34 +104,39 @@ public:
|
||||
|
||||
//! Activates the plugin. Loads the plugin if it has not been loaded yet
|
||||
//! \param thePluginName a name of the plugin
|
||||
Standard_EXPORT void ActivateTool (const TCollection_AsciiString& thePluginName);
|
||||
Standard_EXPORT void ActivateTool(const TCollection_AsciiString& thePluginName);
|
||||
|
||||
//! Sets item selected in the active plugin
|
||||
//! \param theItemNames a container of name of items in plugin that should become selected
|
||||
Standard_EXPORT void SetSelected (const NCollection_List<TCollection_AsciiString>& theItemNames);
|
||||
Standard_EXPORT void SetSelected(const NCollection_List<TCollection_AsciiString>& theItemNames);
|
||||
|
||||
//! Sets objects to be selected in the plugin
|
||||
//! \param theObjects an objects
|
||||
Standard_EXPORT void SetSelected (const NCollection_List<Handle(Standard_Transient)>& theObjects);
|
||||
Standard_EXPORT void SetSelected(const NCollection_List<Handle(Standard_Transient)>& theObjects);
|
||||
|
||||
//! Sets open button. Stores into objectName for the button the name of the current plugin to know where
|
||||
//! the file should be applied
|
||||
//! \param theButton a button
|
||||
Standard_EXPORT void SetOpenButton (QPushButton* theButton);
|
||||
//! Sets open button. Stores into objectName for the button the name of the current plugin to know
|
||||
//! where the file should be applied \param theButton a button
|
||||
Standard_EXPORT void SetOpenButton(QPushButton* theButton);
|
||||
|
||||
//! Loads plugin, appends the plugin widget into layout, stores the plugin information
|
||||
//! \param thePluginName a name of the plugin
|
||||
//! \param theInfo an output parameter for plugin info
|
||||
Standard_EXPORT bool LoadPlugin (const TCollection_AsciiString& thePluginName, TInspector_ToolInfo& theInfo);
|
||||
Standard_EXPORT bool LoadPlugin(const TCollection_AsciiString& thePluginName,
|
||||
TInspector_ToolInfo& theInfo);
|
||||
|
||||
//! Sets path to a directory for temporary plugin files. If parameter is empty, using default directory
|
||||
//! \param thePath a path
|
||||
void SetTemporaryDirectory (const TCollection_AsciiString& thePath)
|
||||
{ myParameters->SetTemporaryDirectory (thePath.IsEmpty() ? myDefaultDirectory : thePath); }
|
||||
//! Sets path to a directory for temporary plugin files. If parameter is empty, using default
|
||||
//! directory \param thePath a path
|
||||
void SetTemporaryDirectory(const TCollection_AsciiString& thePath)
|
||||
{
|
||||
myParameters->SetTemporaryDirectory(thePath.IsEmpty() ? myDefaultDirectory : thePath);
|
||||
}
|
||||
|
||||
//! Returns path to a directory for temporary plugin files
|
||||
//! \return path
|
||||
TCollection_AsciiString GetTemporaryDirectory() const { return myParameters->GetTemporaryDirectory(); }
|
||||
TCollection_AsciiString GetTemporaryDirectory() const
|
||||
{
|
||||
return myParameters->GetTemporaryDirectory();
|
||||
}
|
||||
|
||||
//! Returns plugins parameters container
|
||||
//! \return instance of parameters container
|
||||
@@ -135,15 +144,15 @@ public:
|
||||
|
||||
//! Returns plugin preferences: dock widgets state, tree view columns.
|
||||
//! \param theItem container of preference elements
|
||||
Standard_EXPORT void GetPreferences (TInspectorAPI_PreferencesDataMap& theItem);
|
||||
Standard_EXPORT void GetPreferences(TInspectorAPI_PreferencesDataMap& theItem);
|
||||
|
||||
//! Applies plugin preferences
|
||||
//! \param theItem container of preference elements
|
||||
Standard_EXPORT void SetPreferences (const TInspectorAPI_PreferencesDataMap& theItem);
|
||||
Standard_EXPORT void SetPreferences(const TInspectorAPI_PreferencesDataMap& theItem);
|
||||
|
||||
//! Puts in the stream information about communicator
|
||||
//! \param theStream stream for output
|
||||
Standard_EXPORT void Dump (Standard_OStream& theStream) const;
|
||||
Standard_EXPORT void Dump(Standard_OStream& theStream) const;
|
||||
|
||||
public slots:
|
||||
//! Stores preferences (current state) of all plugins into a preferences file
|
||||
@@ -160,22 +169,23 @@ protected slots:
|
||||
//! Updates available actions by the active plugin
|
||||
void onShowActionsMenu();
|
||||
|
||||
//! Updates the TInspector window title giving object name of plugin widget (available only in Qt5)
|
||||
//! Updates the TInspector window title giving object name of plugin widget (available only in
|
||||
//! Qt5)
|
||||
void onCommuncatorNameChanged();
|
||||
|
||||
protected:
|
||||
|
||||
//! Activates plugin by the plugin info
|
||||
//! Activates plugin by the plugin info
|
||||
//! \param theToolInfo an information about plugin
|
||||
bool activeToolInfo (TInspector_ToolInfo& theToolInfo) const;
|
||||
bool activeToolInfo(TInspector_ToolInfo& theToolInfo) const;
|
||||
|
||||
//! Returns true if there is plugin registered by the given name
|
||||
//! \param thePluginName a name of the plugin
|
||||
//! \param theToolInfo an output parameter for plugin information
|
||||
//! \param theToolId an index in internal map
|
||||
//! \return true if the plugin is found
|
||||
bool findPlugin (const TCollection_AsciiString& thePluginName, TInspector_ToolInfo& theToolInfo,
|
||||
int& theToolId);
|
||||
bool findPlugin(const TCollection_AsciiString& thePluginName,
|
||||
TInspector_ToolInfo& theToolInfo,
|
||||
int& theToolId);
|
||||
|
||||
//! Applies desktop preferences to window
|
||||
void applyPreferences();
|
||||
@@ -185,19 +195,18 @@ protected:
|
||||
TCollection_AsciiString defaultTemporaryDirectory() const;
|
||||
|
||||
private:
|
||||
|
||||
QWidget* myEmptyWidget; //!< widget that is active in tools stack while no one plugin is loaded
|
||||
QMainWindow* myMainWindow; //!< main control of the window
|
||||
QStackedWidget* myToolsStack; //!< stack widget of plugin windows
|
||||
QWidget* myButtonWidget; //!< container of plugin buttons
|
||||
QPushButton* myOpenButton; //!< button to open file for the active plugin
|
||||
QHBoxLayout* myButtonLay; //!< layout of plugin buttons
|
||||
QButtonGroup* myButtonGroup; //!< exclusive toggled button
|
||||
QToolButton* myActionsWidget; //!< tool button for plugin actions
|
||||
QList<TInspector_ToolInfo> myToolNames; //!< container of plugin names
|
||||
Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container
|
||||
TInspector_Shortcut* myShortcut; //!< listener of key events
|
||||
TCollection_AsciiString myDefaultDirectory; //!< default directory
|
||||
QMainWindow* myMainWindow; //!< main control of the window
|
||||
QStackedWidget* myToolsStack; //!< stack widget of plugin windows
|
||||
QWidget* myButtonWidget; //!< container of plugin buttons
|
||||
QPushButton* myOpenButton; //!< button to open file for the active plugin
|
||||
QHBoxLayout* myButtonLay; //!< layout of plugin buttons
|
||||
QButtonGroup* myButtonGroup; //!< exclusive toggled button
|
||||
QToolButton* myActionsWidget; //!< tool button for plugin actions
|
||||
QList<TInspector_ToolInfo> myToolNames; //!< container of plugin names
|
||||
Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container
|
||||
TInspector_Shortcut* myShortcut; //!< listener of key events
|
||||
TCollection_AsciiString myDefaultDirectory; //!< default directory
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user