Salome HOME
Merge branch 'BR_v14_rc' of ssh://git.salome-platform.org/modules/hydro into BR_v14_rc
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_PriorityWidget.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_PRIORITYWIDGET_H
20 #define HYDROGUI_PRIORITYWIDGET_H
21
22 #include <HYDROGUI.h>
23
24 #include <HYDROData_Entity.h>
25 #include <HYDROData_PriorityQueue.h>
26
27 #include <QStyledItemDelegate>
28 #include <QWidget>
29
30 class QTableView;
31 class QToolButton;
32
33 /** 
34  * \class HYDROGUI_PriorityWidget
35  * \brief The class representing widget for tuning of the objects priorities and bathymetry conflicts
36  *
37  * The widget represents a table and a set of buttons (add and remove)
38  * providing the possibility to define priority rules.
39  */
40 class HYDRO_EXPORT HYDROGUI_PriorityWidget : public QWidget
41 {
42   Q_OBJECT
43
44   class Delegate;
45
46 public:
47   HYDROGUI_PriorityWidget( QWidget* theParent );
48   virtual ~HYDROGUI_PriorityWidget();
49
50   void setObjects( const QList<Handle(HYDROData_Entity)>& theObjects );
51
52   HYDROData_ListOfRules getRules() const;
53   void setRules( const HYDROData_ListOfRules& theRules );
54
55   QTableView* getTable() const;
56
57   void undoLastChange();
58
59 protected:
60   void updateControls();
61
62 signals:
63   void ruleChanged();
64
65 protected slots:
66   void onAddRule();
67   void onRemoveRule();
68   void onClearRules();
69
70   void onSelectionChanged();
71
72   void onShowError( const QString& theMsg );
73
74 private:
75   QTableView*  myTable;  ///< the table view
76   QToolButton* myAdd;    ///< the add rule button
77   QToolButton* myRemove; ///< the remove rule button
78   QToolButton* myClear;  ///< the clear all rules button
79 };
80
81 /** 
82  * \class HYDROGUI_PriorityWidget::Delegate
83  * \brief The class representing custom item delegate (combobox)
84  */
85 class HYDROGUI_PriorityWidget::Delegate : public QStyledItemDelegate
86 {
87   Q_OBJECT
88
89 public:
90   Delegate( QObject* theParent = 0 );
91   
92   QWidget* createEditor( QWidget*, const QStyleOptionViewItem&,
93                          const QModelIndex& ) const;
94   
95   void setEditorData( QWidget*, const QModelIndex& ) const;
96   void setModelData( QWidget*, QAbstractItemModel*, const QModelIndex& ) const;
97
98 protected slots:
99   void finishEditing();
100 };
101
102 #endif