geom/src/CurveCreator/CurveCreator_TreeView.h

76 lines
2.9 KiB
C
Raw Normal View History

2013-08-20 12:11:43 +06:00
#ifndef CURVECREATOR_TREEVIEW_H
#define CURVECREATOR_TREEVIEW_H
#include <QTreeView>
#include <QAbstractItemModel>
class CurveCreator_Curve;
class CurveCreator_TreeViewModel : public QAbstractItemModel
{
public:
2013-08-21 12:46:20 +06:00
CurveCreator_TreeViewModel( CurveCreator_Curve* theCurve, QObject* parent );
virtual int columnCount(const QModelIndex & parent = QModelIndex()) const;
virtual int rowCount(const QModelIndex & parent = QModelIndex()) const;
virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
virtual QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
virtual QModelIndex parent(const QModelIndex & theIndex) const;
2013-08-20 12:11:43 +06:00
2013-08-21 12:46:20 +06:00
QModelIndex sectionIndex( int theSection ) const;
QModelIndex pointIndex( int theSection, int thePoint ) const;
bool isSection( const QModelIndex& theIndx ) const;
int getSection( const QModelIndex& theIndx ) const;
int getPoint( const QModelIndex& theIndx ) const;
void setCurve( CurveCreator_Curve* theCurve );
2013-08-20 12:11:43 +06:00
private:
2013-08-21 12:46:20 +06:00
enum IconType{ ICON_POLYLINE, ICON_SPLINE, ICON_CLOSED_SPLINE, ICON_CLOSED_POLYLINE, ICON_POINT };
2013-08-20 12:11:43 +06:00
private:
2013-08-21 12:46:20 +06:00
CurveCreator_Curve* myCurve;
QMap<IconType, QPixmap> myCachedIcons;
2013-08-20 12:11:43 +06:00
};
class CurveCreator_TreeView : public QTreeView
{
2013-08-21 12:46:20 +06:00
Q_OBJECT
2013-08-20 12:11:43 +06:00
public:
2013-08-21 12:46:20 +06:00
enum SelectionType{ ST_NOSEL, ST_POINTS, ST_POINTS_ONE_SECTION, ST_SECTIONS, ST_MIXED };
2013-08-20 12:11:43 +06:00
public:
2013-08-21 12:46:20 +06:00
explicit CurveCreator_TreeView( CurveCreator_Curve* theCurve, QWidget *parent = 0);
SelectionType getSelectionType() const;
QList<int> getSelectedSections() const;
QList< QPair< int, int > > getSelectedPoints() const;
void pointsAdded( int theSection, int thePoint, int thePointsCnt=1 );
void pointDataChanged( int theSection, int thePoint );
void pointsRemoved(int theSection, int thePoint, int thePointsCnt=1 );
void pointsSwapped( int theSection, int thePointNum, int theOffset );
2013-08-20 12:11:43 +06:00
2013-08-21 12:46:20 +06:00
void sectionAdded( int theSection );
void sectionChanged(int theSection , int aSectCnt = 1);
void sectionsRemoved( int theSection, int theSectionCnt=1 );
void sectionsSwapped( int theSection, int theOffset );
2013-08-20 12:11:43 +06:00
2013-08-21 12:46:20 +06:00
void setSelectedSections( const QList<int>& theList );
void setSelectedPoints( const QList< QPair<int, int> >& thePointsList );
2013-08-20 12:11:43 +06:00
2013-08-21 12:46:20 +06:00
void setCurve( CurveCreator_Curve* theCurve );
2013-08-20 12:11:43 +06:00
signals:
2013-08-21 12:46:20 +06:00
void selectionChanged();
void sectionEntered(int);
void pointEntered(int,int);
2013-08-20 12:11:43 +06:00
public slots:
protected slots:
2013-08-21 12:46:20 +06:00
void onActivated( QModelIndex theIndx );
2013-08-20 12:11:43 +06:00
protected:
2013-08-21 12:46:20 +06:00
void setIndexState( const QModelIndex& theIndx, bool& isExpanded, bool& isSelected, bool& isCurrent );
void swapIndexes( const QModelIndex& theFirst, const QModelIndex& theSecond );
void getIndexInfo( const QModelIndex& theIndx, bool& isExpanded, bool& isSelected, bool& isCurrent );
2013-08-20 12:11:43 +06:00
};
#endif // CURVECREATOR_TREEVIEW_H