Salome HOME
Merge remote-tracking branch 'remotes/origin/BR_v14_rc' into BR_SHP_FORMAT
[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 protected:
58   void updateControls();
59
60 protected slots:
61   void onAddRule();
62   void onRemoveRule();
63   void onClearRules();
64
65   void onSelectionChanged();
66
67   void onShowError( const QString& theMsg );
68
69 private:
70   QTableView*  myTable;  ///< the table view
71   QToolButton* myAdd;    ///< the add rule button
72   QToolButton* myRemove; ///< the remove rule button
73   QToolButton* myClear;  ///< the clear all rules button
74 };
75
76 /** 
77  * \class HYDROGUI_PriorityWidget::Delegate
78  * \brief The class representing custom item delegate (combobox)
79  */
80 class HYDROGUI_PriorityWidget::Delegate : public QStyledItemDelegate
81 {
82   Q_OBJECT
83
84 public:
85   Delegate( QObject* theParent = 0 );
86   
87   QWidget* createEditor( QWidget*, const QStyleOptionViewItem&,
88                          const QModelIndex& ) const;
89   
90   void setEditorData( QWidget*, const QModelIndex& ) const;
91   void setModelData( QWidget*, QAbstractItemModel*, const QModelIndex& ) const;
92
93 protected slots:
94   void finishEditing();
95 };
96
97 #endif