Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CurveCreator_TreeView.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2016 CEA/DEN, EDF R&D, 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:
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:
53  QMap<IconType, QPixmap> myCachedIcons;
54 };
55 
57 {
58  Q_OBJECT
59 public:
61 public:
62  explicit CurveCreator_TreeView( CurveCreator_ICurve* theCurve, QWidget *parent = 0);
64  QList<int> getSelectedSections() const;
65 
66  void pointsAdded( int theSection, int thePoint, int thePointsCnt=1 );
67  void pointDataChanged( int theSection, int thePoint );
68  void pointsRemoved(int theSection, int thePoint, int thePointsCnt=1 );
69 
70  void sectionAdded( int theSection );
71  void sectionChanged(int theSection , int aSectCnt = 1);
72  void sectionsRemoved( int theSection, int theSectionCnt=1 );
73  void sectionsSwapped( int theSection, int theOffset );
74 
75  void setSelectedSections( const QList<int>& theList );
76 
77  void setCurve( CurveCreator_ICurve* theCurve );
78 
79  void reset();
80 
81 signals:
82  void selectionChanged();
83  void sectionEntered(int);
84 
85 protected slots:
86  void onActivated( QModelIndex theIndx );
87 protected:
88  void setIndexState( const QModelIndex& theIndx, bool& isExpanded, bool& isSelected, bool& isCurrent );
89  void swapIndexes( const QModelIndex& theFirst, const QModelIndex& theSecond );
90  void getIndexInfo( const QModelIndex& theIndx, bool& isExpanded, bool& isSelected, bool& isCurrent );
91 
92 };
93 
94 #endif // CURVECREATOR_TREEVIEW_H