Back to index

salome-gui  6.5.0
SalomeApp_NoteBookDlg.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 // File:    SalomeApp_NoteBookDlg.h
00021 // Author : Roman NIKOLAEV, Open CASCADE S.A.S.
00022 // Module : GUI
00023 //
00024 #ifndef SALOMEAPP_NOTEBOOKDLG_H
00025 #define SALOMEAPP_NOTEBOOKDLG_H
00026 
00027 #include "SalomeApp.h"
00028 
00029 #include "SALOMEDSClient_ClientFactory.hxx" 
00030 #include CORBA_SERVER_HEADER(SALOMEDS)
00031 
00032 #include <QDialog>
00033 #include <QTableWidget>
00034 #include <QList>
00035 
00036 class QWidget;
00037 class QPushButton;
00038 class QTableWidgetItem;
00039 class NoteBook_Table;
00040 
00041 struct NoteBoox_Variable
00042 {
00043   NoteBoox_Variable() {}
00044   NoteBoox_Variable( const QString& theName, const QString& theValue )
00045   {
00046     Name = theName;
00047     Value = theValue;
00048   }
00049   QString Name;
00050   QString Value;
00051 };
00052 
00053 typedef QMap< int, NoteBoox_Variable > VariableMap;
00054 
00055 class SALOMEAPP_EXPORT NoteBook_TableRow : public QWidget
00056 {
00057  public:
00058   NoteBook_TableRow(int, NoteBook_Table* parentTable, QWidget* parent=0 );
00059   virtual ~NoteBook_TableRow();
00060 
00061   int  GetIndex() const { return myIndex; }
00062   
00063   void AddToTable(QTableWidget *theTable);
00064   
00065   void SetName(const QString theName);
00066   void SetValue(const QString theValue);
00067 
00068   QString GetValue() const;
00069   QString GetName() const;
00070 
00071   bool CheckName();
00072   bool CheckValue();
00073 
00074   QTableWidgetItem* GetVariableItem();
00075   QTableWidgetItem* GetNameItem();
00076   QTableWidgetItem* GetHeaderItem();
00077 
00078   static bool IsRealValue(const QString theValue, double* theResult = 0);
00079   static bool IsIntegerValue(const QString theValue, int* theResult = 0);
00080   static bool IsBooleanValue(const QString theValue, bool* theResult = 0);
00081   bool IsValidStringValue(const QString theName);
00082   
00083  private:
00084   int               myIndex;
00085   NoteBook_Table*   myParentTable;
00086   QTableWidgetItem* myRowHeader;
00087   QTableWidgetItem* myVariableName;
00088   QTableWidgetItem* myVariableValue;
00089 };
00090 
00091 class SALOMEAPP_EXPORT NoteBook_Table : public QTableWidget
00092 {
00093   Q_OBJECT
00094  public:
00095   NoteBook_Table(QWidget * parent = 0);
00096   virtual ~NoteBook_Table();
00097 
00098   void Init(_PTR(Study) theStudy);
00099   static QString Variable2String(const std::string& theVarName,
00100                                  _PTR(Study) theStudy);
00101 
00102   bool IsValid() const;
00103 
00104   void AddRow( const QString& theName = QString::null, const QString& theValue = QString::null );
00105   void AddEmptyRow();
00106   NoteBook_TableRow* GetRowByItem(const QTableWidgetItem* theItem) const;
00107   bool IsLastRow(const NoteBook_TableRow* aRow) const;
00108 
00109   void RemoveSelected();
00110 
00111   void SetProcessItemChangedSignalFlag(const bool enable);
00112   bool GetProcessItemChangedSignalFlag()const;
00113 
00114   bool IsUniqueName(const NoteBook_TableRow* theRow) const;
00115   QList<NoteBook_TableRow*> GetRows() const;
00116 
00117   const bool         IsModified() const { return myIsModified; }
00118   const QList<int>&  GetRemovedRows() const { return myRemovedRows; }
00119   const VariableMap& GetVariableMap() const { return myVariableMap; }
00120   const VariableMap& GetVariableMapRef() const { return myVariableMapRef; }
00121   void  RenamberRowItems();
00122 
00123   void ResetMaps();
00124 
00125   QList<NoteBook_TableRow*>          myRows;
00126 
00127   public slots:
00128     void onItemChanged(QTableWidgetItem* theItem);
00129 
00130  private:
00131     int  getUniqueIndex() const;
00132     
00133  private:
00134   bool isProcessItemChangedSignal;
00135 
00136   bool        myIsModified;
00137   QList<int>  myRemovedRows;
00138   VariableMap myVariableMapRef;
00139   VariableMap myVariableMap;
00140 
00141   _PTR(Study)      myStudy;
00142 };
00143 
00144 class SALOMEAPP_EXPORT SalomeApp_NoteBookDlg : public QDialog 
00145 {
00146   Q_OBJECT
00147  public:
00148   SalomeApp_NoteBookDlg(QWidget * parent , _PTR(Study) theStudy);
00149   virtual ~SalomeApp_NoteBookDlg();
00150 
00151   void Init(_PTR(Study) theStudy);
00152   
00153  public slots:
00154    void onOK();
00155    void onApply();
00156    void onCancel();
00157    void onRemove();
00158    void onUpdateStudy();
00159    void onHelp();
00160 
00161  protected:
00162    bool updateStudy();
00163    void clearStudy();
00164 
00165  private:
00166   NoteBook_Table*  myTable;
00167   QPushButton*     myRemoveButton;
00168   QPushButton*     myUpdateStudyBtn;
00169   QPushButton*     myOkBtn;
00170   QPushButton*     myApplyBtn;
00171   QPushButton*     myCancelBtn;
00172   QPushButton*     myHelpBtn;
00173   
00174   _PTR(Study)      myStudy;
00175 };
00176 
00177 #endif //SALOMEAPP_NOTEBOOKDLG_H