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.
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.
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
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #ifndef HYDROGUI_PriorityTableModel_H
20 #define HYDROGUI_PriorityTableModel_H
23 #include <HYDROData_PriorityQueue.h>
25 #include <QAbstractTableModel>
26 #include <QStringList>
29 class HYDROGUI_Module;
33 * \class HYDROGUI_PriorityTableModel
34 * \brief The class representing custom table model for the priority rules
36 class HYDRO_EXPORT HYDROGUI_PriorityTableModel : public QAbstractTableModel
41 HYDROGUI_PriorityTableModel( QObject* theParent = 0 );
42 virtual ~HYDROGUI_PriorityTableModel();
44 virtual Qt::ItemFlags flags( const QModelIndex & theIndex ) const;
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 );
49 virtual int rowCount( const QModelIndex &theParent = QModelIndex() ) const;
50 virtual int columnCount( const QModelIndex &theParent = QModelIndex() ) const;
52 virtual QVariant headerData( int theSection,
53 Qt::Orientation theOrientation,
54 int theRole = Qt::DisplayRole ) const;
56 virtual bool removeRows( int theRow, int theCount, const QModelIndex & theParent = QModelIndex() );
58 bool removeRows( const QList<int> theRows );
61 void setObjects( const QList<Handle(HYDROData_Entity)>& theObjects );
63 void setRules( const HYDROData_ListOfRules& theObjects );
64 HYDROData_ListOfRules getRules() const;
67 bool canCreateNewRule() const;
69 void setColumnCount( int theColumnCount );
71 void undoLastChange();
74 bool isUsed( const Handle(HYDROData_Entity)& theObj1,
75 const Handle(HYDROData_Entity)& theObj2 ) const;
77 QStringList getAvailablePairs( const Handle(HYDROData_Entity)& theObject ) const;
78 QStringList getAvailableObjectNames() const;
80 QString priorityToString( const int thePriority ) const;
81 QString mergeTypeToString( const int theMergeType ) const;
84 void showError( const QString& theMsg );
88 const ObjectKind getObjectsKind() const;
90 friend class test_HYDROGUI_PriorityTableModel;
92 HYDROGUI_Module* myModule;
94 HYDROData_ListOfRules myRules, myPrevRules;
95 QList<Handle(HYDROData_Entity)> myObjects;