KGantt

kganttlegend.h
1 /*
2  * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
3  *
4  * This file is part of the KGantt library.
5  *
6  * SPDX-License-Identifier: GPL-2.0-or-later
7  */
8 
9 #ifndef KGANTTLEGEND_H
10 #define KGANTTLEGEND_H
11 
12 #include <QAbstractItemView>
13 
14 #include "kganttglobal.h"
15 #include "kganttstyleoptionganttitem.h"
16 
17 namespace KGantt
18 {
19 
20  /*!\class KGantt::Legend kganttlegend.h KGanttLegend
21  * \ingroup KGantt
22  * \brief Legend showing an image and a description for Gantt items
23  *
24  * This is an item view class showing a small Gantt item and it's
25  * text defined by LegendRole.
26  */
27  class KGANTT_EXPORT Legend : public QAbstractItemView
28  {
29  Q_OBJECT
30  KGANTT_DECLARE_PRIVATE_BASE_POLYMORPHIC( Legend )
31  public:
32  /*! Constructor. Creates a Legend with parent \a parent.
33  * The QObject parent is not used for anything internally. */
34  explicit Legend( QWidget* parent = nullptr );
35 
36  /*! Destructor. Does nothing */
37  ~Legend() override;
38 
39  /*reimp*/ QModelIndex indexAt( const QPoint& point ) const override;
40  /*reimp*/ QRect visualRect( const QModelIndex& index ) const override;
41 
42  /*reimp*/ void scrollTo( const QModelIndex&, ScrollHint = EnsureVisible ) override {}
43 
44  /*reimp*/ QSize sizeHint() const override;
45  /*reimp*/ QSize minimumSizeHint() const override;
46 
47  /*reimp*/ void setModel( QAbstractItemModel* model ) override;
48 
49  protected:
50  /*! Draws the legend item at \a index and all of it's children recursively
51  * at \a pos onto \a painter.
52  * Reimplement this if you want to draw items in an user defined way.
53  * \returns the rectangle drawn.
54  */
55  virtual QRect drawItem( QPainter* painter, const QModelIndex& index, const QPoint& pos = QPoint() ) const;
56 
57  /*! Calculates the needed space for the legend item at \a index and, if \a recursive is true,
58  * all child items.
59  */
60  virtual QSize measureItem( const QModelIndex& index, bool recursive = true ) const;
61 
62  /*! Creates a StyleOptionGanttItem with all style options filled in
63  * except the target rectangles.
64  */
65  virtual StyleOptionGanttItem getStyleOption( const QModelIndex& index ) const;
66 
67  /*reimp*/ void paintEvent( QPaintEvent* event ) override;
68 
69  /*reimp*/ int horizontalOffset() const override { return 0; }
70  /*reimp*/ bool isIndexHidden( const QModelIndex& ) const override { return false; }
71  /*reimp*/ QModelIndex moveCursor( CursorAction, Qt::KeyboardModifiers ) override { return QModelIndex(); }
72  /*reimp*/ void setSelection( const QRect&, QItemSelectionModel::SelectionFlags ) override {}
73  /*reimp*/ int verticalOffset() const override { return 0; }
74  /*reimp*/ QRegion visualRegionForSelection( const QItemSelection& ) const override { return QRegion(); }
75 
76  protected Q_SLOTS:
77  /*! Triggers repainting of the legend.
78  */
79  virtual void modelDataChanged();
80  };
81 }
82 
83 #endif
typedef KeyboardModifiers
QStyleOption subclass for gantt items.
Global namespace.
Contains KGantt macros.
Legend showing an image and a description for Gantt items.
Definition: kganttlegend.h:27
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Dec 5 2021 22:32:42 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.