Split out Labels view from Bars view.

Both are QAbstractItemViews and can be used on top of a PartitionModel,
together or separately.
This commit is contained in:
Teo Mrnjavac 2015-12-03 19:38:56 +01:00
parent b65fe87503
commit eed8d3b83b
5 changed files with 405 additions and 209 deletions

View file

@ -32,7 +32,7 @@ class PartitionBarsView : public QAbstractItemView
{
public:
explicit PartitionBarsView( QWidget* parent = nullptr );
~PartitionBarsView();
virtual ~PartitionBarsView();
QSize minimumSizeHint() const override;
@ -45,8 +45,6 @@ public:
QRect visualRect( const QModelIndex& index ) const override;
void scrollTo( const QModelIndex& index, ScrollHint hint = EnsureVisible ) override;
void setLabelsVisible( bool visible = true );
protected:
// QAbstractItemView API
QRegion visualRegionForSelection( const QItemSelection& selection ) const override;
@ -61,13 +59,6 @@ protected slots:
private:
void drawPartitions( QPainter* painter, const QRect& rect, const QModelIndex& parent );
void drawLabels( QPainter* painter, const QRect& rect, const QModelIndex& parent );
QSize sizeForAllLabels( int maxLineWidth ) const;
QSize sizeForLabel( const QStringList& text ) const;
void drawLabel( QPainter* painter, const QStringList& text, const QColor& color, const QPoint& pos );
QModelIndexList getIndexesToDraw( const QModelIndex& parent ) const;
bool m_showLabels;
};
#endif /* PARTITIONPREVIEW_H */