• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

Kate

  • kde-4.14
  • applications
  • kate
  • part
  • completion
  • expandingtree
expandingdelegate.h
Go to the documentation of this file.
1 /* This file is part of the KDE libraries and the Kate part.
2  *
3  * Copyright (C) 2006 Hamish Rodda <rodda@kde.org>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef ExpandingDelegate_H
22 #define ExpandingDelegate_H
23 
24 #include <QtGui/QItemDelegate>
25 #include <QItemDelegate>
26 #include <QtGui/QTextLine>
27 #include <QModelIndex>
28 #include <QPoint>
29 
30 class KateRenderer;
31 class KateCompletionWidget;
32 class KateDocument;
33 class KateTextLine;
34 class ExpandingWidgetModel;
35 class QVariant;
36 class QStyleOptionViewItem;
37 
42 class ExpandingDelegate : public QItemDelegate
43 {
44  Q_OBJECT
45 
46  public:
47  explicit ExpandingDelegate(ExpandingWidgetModel* model, QObject* parent = 0L);
48 
49 
50  // Overridden to create highlighting for current index
51  virtual void paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const;
52 
53  // Returns the basic size-hint as reported by QItemDelegate
54  QSize basicSizeHint( const QModelIndex& index ) const;
55 
56  ExpandingWidgetModel* model() const;
57  protected:
58  //Called right before paint to allow last-minute changes to the style
59  virtual void adjustStyle( const QModelIndex& index, QStyleOptionViewItem & option ) const;
60  virtual void drawDisplay ( QPainter * painter, const QStyleOptionViewItem & option, const QRect & rect, const QString & text ) const;
61  virtual QSize sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const;
62  virtual bool editorEvent ( QEvent * event, QAbstractItemModel * model, const QStyleOptionViewItem & option, const QModelIndex & index );
63  virtual void drawBackground ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const;
64  virtual void drawDecoration(QPainter* painter, const QStyleOptionViewItem& option, const QRect& rect, const QPixmap& pixmap) const;
65  //option can be changed
66  virtual QList<QTextLayout::FormatRange> createHighlighting(const QModelIndex& index, QStyleOptionViewItem& option) const;
67 
68  void adjustRect(QRect& rect) const;
69 
73  QList<QTextLayout::FormatRange> highlightingFromVariantList(const QList<QVariant>& customHighlights) const;
74 
75  //Called when an item was expanded/unexpanded and the height changed
76  virtual void heightChanged() const;
77 
78  //Initializes the style options from the index
79  void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const;
80 
81  mutable int m_currentColumnStart; //Text-offset for custom highlighting, will be applied to m_cachedHighlights(Only highlights starting after this will be used). Shoult be zero of the highlighting is not taken from kate.
82  mutable QList<int> m_currentColumnStarts;
83  mutable QList<QTextLayout::FormatRange> m_cachedHighlights;
84 
85  mutable Qt::Alignment m_cachedAlignment;
86  mutable QColor m_backgroundColor;
87  mutable QModelIndex m_currentIndex;
88  private:
89 
90  ExpandingWidgetModel* m_model;
91 };
92 
93 #endif
QModelIndex
ExpandingDelegate::adjustStyle
virtual void adjustStyle(const QModelIndex &index, QStyleOptionViewItem &option) const
Definition: expandingdelegate.cpp:140
QEvent
ExpandingDelegate::paint
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
Definition: expandingdelegate.cpp:73
ExpandingDelegate::m_currentColumnStarts
QList< int > m_currentColumnStarts
Definition: expandingdelegate.h:82
ExpandingDelegate::ExpandingDelegate
ExpandingDelegate(ExpandingWidgetModel *model, QObject *parent=0L)
Definition: expandingdelegate.cpp:34
ExpandingDelegate::sizeHint
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
Definition: expandingdelegate.cpp:125
ExpandingDelegate::heightChanged
virtual void heightChanged() const
Definition: expandingdelegate.cpp:296
ExpandingDelegate::m_currentIndex
QModelIndex m_currentIndex
Definition: expandingdelegate.h:87
ExpandingDelegate::initStyleOption
void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const
ExpandingDelegate::drawDecoration
virtual void drawDecoration(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect, const QPixmap &pixmap) const
Definition: expandingdelegate.cpp:278
Qt::Alignment
typedef Alignment
ExpandingDelegate::editorEvent
virtual bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
Definition: expandingdelegate.cpp:299
QObject::event
virtual bool event(QEvent *e)
KateRenderer
Handles all of the work of rendering the text (used for the views and printing)
Definition: katerenderer.h:50
QRect
KateCompletionWidget
This is the code completion's main widget, and also contains the core interface logic.
Definition: katecompletionwidget.h:55
ExpandingDelegate::createHighlighting
virtual QList< QTextLayout::FormatRange > createHighlighting(const QModelIndex &index, QStyleOptionViewItem &option) const
Definition: expandingdelegate.cpp:115
ExpandingDelegate::adjustRect
void adjustRect(QRect &rect) const
Definition: expandingdelegate.cpp:146
QStyleOptionViewItem
QObject
QPainter
QItemDelegate
ExpandingDelegate::model
ExpandingWidgetModel * model() const
Definition: expandingdelegate.cpp:292
QString
QList< QTextLayout::FormatRange >
QColor
ExpandingDelegate::drawDisplay
virtual void drawDisplay(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect, const QString &text) const
Definition: expandingdelegate.cpp:158
ExpandingDelegate::basicSizeHint
QSize basicSizeHint(const QModelIndex &index) const
Definition: expandingdelegate.cpp:121
ExpandingDelegate::highlightingFromVariantList
QList< QTextLayout::FormatRange > highlightingFromVariantList(const QList< QVariant > &customHighlights) const
Creates a list of FormatRanges as should be returned by createHighlighting from a list of QVariants a...
Definition: expandingdelegate.cpp:315
QPixmap
ExpandingDelegate::m_currentColumnStart
int m_currentColumnStart
Definition: expandingdelegate.h:81
KateDocument
Definition: katedocument.h:74
QSize
ExpandingDelegate::m_cachedAlignment
Qt::Alignment m_cachedAlignment
Definition: expandingdelegate.h:85
ExpandingDelegate
This is a delegate that cares, together with ExpandingWidgetModel, about embedded widgets in tree-vie...
Definition: expandingdelegate.h:42
ExpandingDelegate::drawBackground
virtual void drawBackground(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
Definition: expandingdelegate.cpp:283
QAbstractItemModel
ExpandingDelegate::m_cachedHighlights
QList< QTextLayout::FormatRange > m_cachedHighlights
Definition: expandingdelegate.h:83
QObject::parent
QObject * parent() const
ExpandingDelegate::m_backgroundColor
QColor m_backgroundColor
Definition: expandingdelegate.h:86
QVariant
ExpandingWidgetModel
Cares about expanding/un-expanding items in a tree-view together with ExpandingDelegate.
Definition: expandingwidgetmodel.h:36
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:57 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Kate

Skip menu "Kate"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal