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