Salome HOME
epaisseur des polylignes = 2
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_PriorityTableModel.h
1 // Copyright (C) 2014-2015  EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
6 //
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10 // Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #ifndef HYDROGUI_PriorityTableModel_H
20 #define HYDROGUI_PriorityTableModel_H
21
22 #include <HYDROGUI.h>
23 #include <HYDROData_PriorityQueue.h>
24
25 #include <QAbstractTableModel>
26 #include <QStringList>
27
28
29 class HYDROGUI_Module;
30
31
32 /** 
33  * \class HYDROGUI_PriorityTableModel
34  * \brief The class representing custom table model for the priority rules
35  */
36 class HYDRO_EXPORT HYDROGUI_PriorityTableModel : public QAbstractTableModel
37 {
38   Q_OBJECT
39
40 public:
41   HYDROGUI_PriorityTableModel( QObject* theParent = 0 );
42   virtual ~HYDROGUI_PriorityTableModel();
43
44   virtual Qt::ItemFlags flags( const QModelIndex & theIndex ) const;
45
46   virtual QVariant data( const QModelIndex &theIndex, int theRole = Qt::DisplayRole ) const;  
47   virtual bool setData( const QModelIndex & theIndex, const QVariant & theValue, int theRole = Qt::EditRole );
48
49   virtual int rowCount( const QModelIndex &theParent = QModelIndex() ) const;
50   virtual int columnCount( const QModelIndex &theParent = QModelIndex() ) const;
51
52   virtual QVariant headerData( int theSection,
53                                Qt::Orientation theOrientation,
54                                int theRole = Qt::DisplayRole ) const;
55
56   virtual bool removeRows( int theRow, int theCount, const QModelIndex & theParent = QModelIndex() );
57   
58   bool removeRows( const QList<int> theRows );
59   bool removeAll();
60
61   void setObjects( const QList<Handle(HYDROData_Entity)>& theObjects );
62
63   void setRules( const HYDROData_ListOfRules& theObjects );
64   HYDROData_ListOfRules getRules() const;
65
66   bool createNewRule();
67   bool canCreateNewRule() const;
68
69   void setColumnCount( int theColumnCount );
70
71   void undoLastChange();
72   
73 protected:
74   bool isUsed( const Handle(HYDROData_Entity)& theObj1, 
75                const Handle(HYDROData_Entity)& theObj2 ) const;
76
77   QStringList getAvailablePairs( const Handle(HYDROData_Entity)& theObject ) const;
78   QStringList getAvailableObjectNames() const;
79
80   QString priorityToString( const int thePriority ) const;
81   QString mergeTypeToString( const int theMergeType ) const;
82
83 signals:
84   void showError( const QString& theMsg );
85   void ruleChanged();
86
87 private:
88   const ObjectKind getObjectsKind() const;
89
90   friend class test_HYDROGUI_PriorityTableModel;
91
92   HYDROGUI_Module* myModule;
93
94   HYDROData_ListOfRules myRules, myPrevRules;
95   QList<Handle(HYDROData_Entity)> myObjects;
96
97   int myColumnCount;
98 };
99
100 #endif