1 // Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef CURVECREATOR_TREEVIEW_H
21 #define CURVECREATOR_TREEVIEW_H
24 #include <QAbstractItemModel>
26 class CurveCreator_ICurve;
28 class CurveCreator_TreeViewModel : public QAbstractItemModel
31 CurveCreator_TreeViewModel( CurveCreator_ICurve* theCurve, QObject* parent );
32 virtual int columnCount(const QModelIndex & parent = QModelIndex()) const;
33 virtual int rowCount(const QModelIndex & parent = QModelIndex()) const;
34 virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
35 virtual QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
36 virtual QModelIndex parent(const QModelIndex & theIndex) const;
37 // virtual bool setHeaderData(int section, Qt::Orientation orientation, const QVariant & value, int role = Qt::EditRole);
39 QModelIndex sectionIndex( int theSection ) const;
40 QModelIndex nbPointsIndex( int theSection ) const;
41 QModelIndex pointIndex( int theSection, int thePoint ) const;
43 bool isSection( const QModelIndex& theIndx ) const;
44 int getSection( const QModelIndex& theIndx ) const;
45 int getPoint( const QModelIndex& theIndx ) const;
47 void setCurve( CurveCreator_ICurve* theCurve );
50 enum IconType{ ICON_POLYLINE, ICON_SPLINE, ICON_CLOSED_SPLINE, ICON_CLOSED_POLYLINE, ICON_POINT };
52 CurveCreator_ICurve* myCurve;
53 QMap<IconType, QPixmap> myCachedIcons;
56 class CurveCreator_TreeView : public QTreeView
60 enum SelectionType{ ST_NOSEL, ST_POINTS, ST_POINTS_ONE_SECTION, ST_SECTIONS, ST_MIXED };
62 explicit CurveCreator_TreeView( CurveCreator_ICurve* theCurve, QWidget *parent = 0);
63 SelectionType getSelectionType() const;
64 QList<int> getSelectedSections() const;
65 QList< QPair< int, int > > getSelectedPoints() const;
67 void pointsAdded( int theSection, int thePoint, int thePointsCnt=1 );
68 void pointDataChanged( int theSection, int thePoint );
69 void pointsRemoved(int theSection, int thePoint, int thePointsCnt=1 );
70 void pointsSwapped( int theSection, int thePointNum, int theOffset );
72 void sectionAdded( int theSection );
73 void sectionChanged(int theSection , int aSectCnt = 1);
74 void sectionsRemoved( int theSection, int theSectionCnt=1 );
75 void sectionsSwapped( int theSection, int theOffset );
77 void setSelectedSections( const QList<int>& theList );
78 void setSelectedPoints( const QList< QPair<int, int> >& thePointsList );
80 void setCurve( CurveCreator_ICurve* theCurve );
85 void selectionChanged();
86 void sectionEntered(int);
87 void pointEntered(int,int);
90 void onActivated( QModelIndex theIndx );
92 void setIndexState( const QModelIndex& theIndx, bool& isExpanded, bool& isSelected, bool& isCurrent );
93 void swapIndexes( const QModelIndex& theFirst, const QModelIndex& theSecond );
94 void getIndexInfo( const QModelIndex& theIndx, bool& isExpanded, bool& isSelected, bool& isCurrent );
98 #endif // CURVECREATOR_TREEVIEW_H