1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #ifndef HYDROGUI_ListModel_H
24 #define HYDROGUI_ListModel_H
27 #include <HYDROData_Entity.h>
28 #include <QAbstractListModel>
31 const int HYDROGUI_VisibleRole = Qt::UserRole + 1;
32 const int HYDROGUI_EntryRole = Qt::UserRole + 2;
35 * \class HYDROGUI_ListModel
36 * \brief The class representing custom list model for the Z levels
38 class HYDRO_EXPORT HYDROGUI_ListModel : public QAbstractListModel
43 enum OpType { Top, Up, Down, Bottom, DragAndDrop };
45 typedef QPair<Handle(HYDROData_Entity), bool> Object2Visible;
46 typedef QList<Object2Visible> Object2VisibleList;
47 typedef QList<Handle(HYDROData_Entity)> ObjectList;
50 HYDROGUI_ListModel( QObject* theParent = 0 );
51 virtual ~HYDROGUI_ListModel();
53 virtual QVariant data( const QModelIndex &theIndex, int theRole = Qt::DisplayRole ) const;
55 virtual int rowCount( const QModelIndex &theParent = QModelIndex() ) const;
57 virtual QVariant headerData( int theSection,
58 Qt::Orientation theOrientation,
59 int theRole = Qt::DisplayRole ) const;
60 virtual Qt::ItemFlags flags( const QModelIndex& theIndex ) const;
61 virtual QMimeData* mimeData( const QModelIndexList& theIndexes ) const;
62 virtual QStringList mimeTypes() const;
63 virtual bool dropMimeData( const QMimeData* theData, Qt::DropAction theAction,
64 int theRow, int theColumn, const QModelIndex& theParent );
65 virtual Qt::DropActions supportedDropActions() const;
67 QList<int> getIds( const QModelIndexList& theIndexes, bool theIsToSort = true ) const;
69 void setObjects( const Object2VisibleList& theObjects );
70 ObjectList getObjects() const;
72 bool move( const int theItem, const OpType theType, bool theIsVisibleOnly,
73 const int theDropItem = -1 );
74 bool move( const QList<int>& theItems, const OpType theType, bool theIsVisibleOnly,
75 const int theDropItem = -1 );
78 bool isObjectVisible( int theIndex ) const;
79 bool isDragAndDropAllowed( const QList<int>& theItems, const int theDropItem ) const;
82 friend class test_HYDROGUI_ListModel;
84 Object2VisibleList myObjects;
85 QPixmap myEmpty, myEye;