Version: 9.12.0
CurveCreator_TreeView.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2023 CEA, EDF, OPEN CASCADE
2 //
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, or (at your option) any later version.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef CURVECREATOR_TREEVIEW_H
21 #define CURVECREATOR_TREEVIEW_H
22 
23 #include <QTreeView>
24 #include <QAbstractItemModel>
25 
27 
29 {
30 public:
31  CurveCreator_TreeViewModel( CurveCreator_ICurve* theCurve, QObject* parent, bool toDrawColorIcon );
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);
38 
39  QModelIndex sectionIndex( int theSection ) const;
40  QModelIndex nbPointsIndex( int theSection ) const;
41  QModelIndex pointIndex( int theSection, int thePoint ) const;
42 
43  bool isSection( const QModelIndex& theIndx ) const;
44  int getSection( const QModelIndex& theIndx ) const;
45  int getPoint( const QModelIndex& theIndx ) const;
46 
47  void setCurve( CurveCreator_ICurve* theCurve );
48 
49 private:
51 private:
54  QMap<IconType, QPixmap> myCachedIcons;
55 };
56 
58 {
59  Q_OBJECT
60 public:
62 public:
63  explicit CurveCreator_TreeView( CurveCreator_ICurve* theCurve, QWidget *parent = 0, bool toDrawColorIcon = true);
65  QList<int> getSelectedSections() const;
66 
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 
71  void sectionAdded( int theSection );
72  void sectionChanged(int theSection , int aSectCnt = 1);
73  void sectionsRemoved( int theSection, int theSectionCnt=1 );
74  void sectionsSwapped( int theSection, int theOffset );
75 
76  void setSelectedSections( const QList<int>& theList );
77 
78  void setCurve( CurveCreator_ICurve* theCurve );
79 
80  void reset();
81 
82 signals:
84  void sectionEntered(int);
85 
86 protected slots:
87  void onActivated( QModelIndex theIndx );
88 protected:
89  void setIndexState( const QModelIndex& theIndx, bool& isExpanded, bool& isSelected, bool& isCurrent );
90  void swapIndexes( const QModelIndex& theFirst, const QModelIndex& theSecond );
91  void getIndexInfo( const QModelIndex& theIndx, bool& isExpanded, bool& isSelected, bool& isCurrent );
92 
93 };
94 
95 #endif // CURVECREATOR_TREEVIEW_H
The CurveCreator_ICurve object is represented as one or more sets of connected points; thus CurveCrea...
Definition: CurveCreator_ICurve.hxx:73
Definition: CurveCreator_TreeView.h:29
QModelIndex sectionIndex(int theSection) const
Definition: CurveCreator_TreeView.cxx:186
QMap< IconType, QPixmap > myCachedIcons
Definition: CurveCreator_TreeView.h:54
bool isSection(const QModelIndex &theIndx) const
Definition: CurveCreator_TreeView.cxx:201
virtual QModelIndex parent(const QModelIndex &theIndex) const
Definition: CurveCreator_TreeView.cxx:157
QModelIndex nbPointsIndex(int theSection) const
Definition: CurveCreator_TreeView.cxx:191
CurveCreator_ICurve * myCurve
Definition: CurveCreator_TreeView.h:52
bool myDrawColorIcon
Definition: CurveCreator_TreeView.h:53
CurveCreator_TreeViewModel(CurveCreator_ICurve *theCurve, QObject *parent, bool toDrawColorIcon)
Definition: CurveCreator_TreeView.cxx:33
int getSection(const QModelIndex &theIndx) const
Definition: CurveCreator_TreeView.cxx:208
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Definition: CurveCreator_TreeView.cxx:145
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
Definition: CurveCreator_TreeView.cxx:68
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
Definition: CurveCreator_TreeView.cxx:168
int getPoint(const QModelIndex &theIndx) const
Definition: CurveCreator_TreeView.cxx:215
void setCurve(CurveCreator_ICurve *theCurve)
Definition: CurveCreator_TreeView.cxx:222
IconType
Definition: CurveCreator_TreeView.h:50
@ ICON_CLOSED_POLYLINE
Definition: CurveCreator_TreeView.h:50
@ ICON_CLOSED_SPLINE
Definition: CurveCreator_TreeView.h:50
@ ICON_POLYLINE
Definition: CurveCreator_TreeView.h:50
@ ICON_POINT
Definition: CurveCreator_TreeView.h:50
@ ICON_SPLINE
Definition: CurveCreator_TreeView.h:50
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Definition: CurveCreator_TreeView.cxx:76
QModelIndex pointIndex(int theSection, int thePoint) const
Definition: CurveCreator_TreeView.cxx:196
Definition: CurveCreator_TreeView.h:58
void pointsRemoved(int theSection, int thePoint, int thePointsCnt=1)
Definition: CurveCreator_TreeView.cxx:285
void sectionAdded(int theSection)
Definition: CurveCreator_TreeView.cxx:298
QList< int > getSelectedSections() const
Definition: CurveCreator_TreeView.cxx:249
CurveCreator_TreeView(CurveCreator_ICurve *theCurve, QWidget *parent=0, bool toDrawColorIcon=true)
Definition: CurveCreator_TreeView.cxx:230
void onActivated(QModelIndex theIndx)
Definition: CurveCreator_TreeView.cxx:437
void getIndexInfo(const QModelIndex &theIndx, bool &isExpanded, bool &isSelected, bool &isCurrent)
Definition: CurveCreator_TreeView.cxx:342
SelectionType
Definition: CurveCreator_TreeView.h:61
@ ST_POINTS
Definition: CurveCreator_TreeView.h:61
@ ST_POINTS_ONE_SECTION
Definition: CurveCreator_TreeView.h:61
@ ST_NOSEL
Definition: CurveCreator_TreeView.h:61
@ ST_SECTIONS
Definition: CurveCreator_TreeView.h:61
@ ST_MIXED
Definition: CurveCreator_TreeView.h:61
void reset()
Definition: CurveCreator_TreeView.cxx:456
void sectionsSwapped(int theSection, int theOffset)
Definition: CurveCreator_TreeView.cxx:367
void pointsAdded(int theSection, int thePoint, int thePointsCnt=1)
Definition: CurveCreator_TreeView.cxx:265
void sectionsRemoved(int theSection, int theSectionCnt=1)
Definition: CurveCreator_TreeView.cxx:320
void pointDataChanged(int theSection, int thePoint)
Definition: CurveCreator_TreeView.cxx:276
void setIndexState(const QModelIndex &theIndx, bool &isExpanded, bool &isSelected, bool &isCurrent)
Definition: CurveCreator_TreeView.cxx:332
void setSelectedSections(const QList< int > &theList)
Definition: CurveCreator_TreeView.cxx:377
SelectionType getSelectionType() const
Definition: CurveCreator_TreeView.cxx:398
void sectionChanged(int theSection, int aSectCnt=1)
Definition: CurveCreator_TreeView.cxx:310
void swapIndexes(const QModelIndex &theFirst, const QModelIndex &theSecond)
Definition: CurveCreator_TreeView.cxx:349
void setCurve(CurveCreator_ICurve *theCurve)
Definition: CurveCreator_TreeView.cxx:448