]> SALOME platform Git repositories - modules/gui.git/blob - src/SalomeApp/SalomeApp_NoteBookDlg.h
Salome HOME
431b50ced7d01ea82acf5cb60927e53d2959871f
[modules/gui.git] / src / SalomeApp / SalomeApp_NoteBookDlg.h
1 // Copyright (C) 2008  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // File:    SalomeApp_NoteBookDlg.h
20 // Author : Roman NIKOLAEV, Open CASCADE S.A.S.
21 // Module : GUI
22
23 #ifndef SALOMEAPP_NOTEBOOKDLG_H
24 #define SALOMEAPP_NOTEBOOKDLG_H
25
26 #include "SalomeApp.h"
27
28 #include "SALOMEDSClient_ClientFactory.hxx" 
29 #include CORBA_SERVER_HEADER(SALOMEDS)
30
31 #include <QDialog>
32 #include <QTableWidget>
33 #include <QList>
34
35 class QWidget;
36 class QPushButton;
37 class QTableWidgetItem;
38
39 struct NoteBoox_Variable
40 {
41   NoteBoox_Variable() {}
42   NoteBoox_Variable( const QString& theName, const QString& theValue )
43   {
44     Name = theName;
45     Value = theValue;
46   }
47   QString Name;
48   QString Value;
49 };
50
51 typedef QMap< int, NoteBoox_Variable > VariableMap;
52
53 class SALOMEAPP_EXPORT NoteBook_TableRow : public QWidget
54 {
55  public:
56   NoteBook_TableRow(int, QWidget* parent=0);
57   virtual ~NoteBook_TableRow();
58
59   int  GetIndex() const { return myIndex; }
60   
61   void AddToTable(QTableWidget *theTable);
62   
63   void SetName(const QString theName);
64   void SetValue(const QString theValue);
65
66   QString GetValue() const;
67   QString GetName() const;
68
69   bool CheckName();
70   bool CheckValue();
71
72   QTableWidgetItem* GetVariableItem();
73   QTableWidgetItem* GetNameItem();
74   QTableWidgetItem* GetHeaderItem();
75
76   static bool IsRealValue(const QString theValue, double* theResult = 0);
77   static bool IsIntegerValue(const QString theValue, int* theResult = 0);
78   static bool IsBooleanValue(const QString theValue, bool* theResult = 0);
79   
80  private:
81   int               myIndex;
82   QTableWidgetItem* myRowHeader;
83   QTableWidgetItem* myVariableName;
84   QTableWidgetItem* myVariableValue;
85 };
86
87 class SALOMEAPP_EXPORT NoteBook_Table : public QTableWidget
88 {
89   Q_OBJECT
90  public:
91   NoteBook_Table(QWidget * parent = 0);
92   virtual ~NoteBook_Table();
93
94   void Init(_PTR(Study) theStudy);
95   static QString Variable2String(const std::string& theVarName,
96                                  _PTR(Study) theStudy);
97
98   bool IsValid() const;
99
100   void AddRow( const QString& theName = QString::null, const QString& theValue = QString::null );
101   void AddEmptyRow();
102   NoteBook_TableRow* GetRowByItem(const QTableWidgetItem* theItem) const;
103   bool IsLastRow(const NoteBook_TableRow* aRow) const;
104
105   void RemoveSelected();
106
107   void SetProcessItemChangedSignalFlag(const bool enable);
108   bool GetProcessItemChangedSignalFlag()const;
109
110   bool IsUniqueName(const NoteBook_TableRow* theRow) const;
111   QList<NoteBook_TableRow*> GetRows() const;
112
113   const bool         IsModified() const { return myIsModified; }
114   const QList<int>&  GetRemovedRows() const { return myRemovedRows; }
115   const VariableMap& GetVariableMap() const { return myVariableMap; }
116   const VariableMap& GetVariableMapRef() const { return myVariableMapRef; }
117   void  RenamberRowItems();
118
119   void ResetMaps();
120
121   public slots:
122     void onItemChanged(QTableWidgetItem* theItem);
123
124  private:
125     int  getUniqueIndex() const;
126     
127  private:
128   bool isProcessItemChangedSignal;
129   QList<NoteBook_TableRow*>          myRows;
130
131   bool        myIsModified;
132   QList<int>  myRemovedRows;
133   VariableMap myVariableMapRef;
134   VariableMap myVariableMap;
135
136   _PTR(Study)      myStudy;
137 };
138
139 class SALOMEAPP_EXPORT SalomeApp_NoteBookDlg : public QDialog 
140 {
141   Q_OBJECT
142  public:
143   SalomeApp_NoteBookDlg(QWidget * parent , _PTR(Study) theStudy);
144   virtual ~SalomeApp_NoteBookDlg();
145
146   void Init(_PTR(Study) theStudy);
147   
148  public slots:
149    void onOK();
150    void onApply();
151    void onCancel();
152    void onRemove();
153    void onUpdateStudy();
154    void onHelp();
155
156  protected:
157    bool updateStudy();
158    void clearStudy();
159
160  private:
161   NoteBook_Table*  myTable;
162   QPushButton*     myRemoveButton;
163   QPushButton*     myUpdateStudyBtn;
164   QPushButton*     myOkBtn;
165   QPushButton*     myApplyBtn;
166   QPushButton*     myCancelBtn;
167   QPushButton*     myHelpBtn;
168   
169   _PTR(Study)      myStudy;
170 };
171
172 #endif //SALOMEAPP_NOTEBOOKDLG_H