• 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
expandingwidgetmodel.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) 2007 David Nolden <david.nolden.kdevelop@art-master.de>
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 EXPANDING_WIDGET_MODEL_H
22 #define EXPANDING_WIDGET_MODEL_H
23 
24 #include <QAbstractTableModel>
25 #include <QtCore/QHash>
26 #include <QIcon>
27 #include <QPointer>
28 
29 class KWidget;
30 class QTreeView;
31 class QTextEdit;
32 
36 class ExpandingWidgetModel : public QAbstractTableModel {
37  Q_OBJECT
38  public:
39 
40  ExpandingWidgetModel( QWidget* parent );
41  virtual ~ExpandingWidgetModel();
42 
43  enum ExpandingType {
44  NotExpandable=0,
45  Expandable,
46  Expanded
47  };
48 
51  bool canExpandCurrentItem() const;
53  bool canCollapseCurrentItem() const;
55  void setCurrentItemExpanded( bool );
56 
57  void clearMatchQualities();
58 
60  void clearExpanding();
61 
63  bool isExpandable(const QModelIndex& index) const;
64 
65  enum ExpansionType {
66  NotExpanded = 0,
67  ExpandDownwards, //The additional(expanded) information is shown UNDER the original information
68  ExpandUpwards //The additional(expanded) information is shown ABOVE the original information
69  };
70 
72  ExpansionType isPartiallyExpanded(const QModelIndex& index) const;
73 
75  bool isExpanded(const QModelIndex & row) const;
77  void setExpanded(QModelIndex index, bool expanded);
78 
80  int expandingWidgetsHeight() const;
81 
84  QWidget* expandingWidget(const QModelIndex & row) const;
85 
87  int partiallyExpandWidgetHeight() const;
96  virtual void rowSelected(const QModelIndex & row);
98 
100  QRect partialExpandRect(const QModelIndex & row) const;
101 
102  QString partialExpandText(const QModelIndex & row) const;
103 
106  void placeExpandingWidget(const QModelIndex & row);
107 
108  virtual QTreeView* treeView() const = 0;
109 
111  virtual bool indexIsItem(const QModelIndex& index) const = 0;
112 
114  virtual QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
115 
117  QModelIndex partiallyExpandedRow() const;
118 
120  uint matchColor(const QModelIndex& index) const;
121 
122  public slots:
124  void placeExpandingWidgets();
125 
126  protected:
130  virtual int contextMatchQuality(const QModelIndex & index) const = 0;
131 
132  //Makes sure m_expandedIcon and m_collapsedIcon are loaded
133  void cacheIcons() const;
134 
135  static QIcon m_expandedIcon;
136  static QIcon m_collapsedIcon;
137 
138  //Does not update the view
139  void partiallyUnExpand(const QModelIndex& index);
140  //Finds out the basic height of the row represented by the given index. Basic means without respecting any expansion.
141  int basicRowHeight( const QModelIndex& index ) const;
142 
143  private:
144  QMap<QModelIndex, ExpansionType> m_partiallyExpanded;
145  // Store expanding-widgets and cache whether items can be expanded
146  mutable QMap<QModelIndex, ExpandingType> m_expandState;
147  QMap< QModelIndex, QPointer<QWidget> > m_expandingWidgets; //Map rows to their expanding-widgets
148  QMap< QModelIndex, int > m_contextMatchQualities; //Map rows to their context-match qualities(undefined if unknown, else 0 to 10). Not used yet, eventually remove.
149 };
150 
151 
159 QList<QVariant> mergeCustomHighlighting( QStringList strings, QList<QVariantList> highlights, int gapBetweenStrings = 0 );
160 #endif
QModelIndex
QWidget
ExpandingWidgetModel::partiallyUnExpand
void partiallyUnExpand(const QModelIndex &index)
Definition: expandingwidgetmodel.cpp:146
ExpandingWidgetModel::NotExpandable
Definition: expandingwidgetmodel.h:44
ExpandingWidgetModel::setCurrentItemExpanded
void setCurrentItemExpanded(bool)
Expand/collapse the current item.
ExpandingWidgetModel::rowSelected
virtual void rowSelected(const QModelIndex &row)
Notifies underlying models that the item was selected, collapses any previous partially expanded line...
Definition: expandingwidgetmodel.cpp:157
ExpandingWidgetModel::partiallyExpandedRow
QModelIndex partiallyExpandedRow() const
Returns the first row that is currently partially expanded.
Definition: expandingwidgetmodel.cpp:116
ExpandingWidgetModel::clearExpanding
void clearExpanding()
Unexpand all rows and clear all cached information about them(this includes deleting the expanding-wi...
Definition: expandingwidgetmodel.cpp:123
ExpandingWidgetModel::placeExpandingWidgets
void placeExpandingWidgets()
Place or hides all expanding-widgets to the correct positions. Should be called after the view was sc...
Definition: expandingwidgetmodel.cpp:414
mergeCustomHighlighting
QList< QVariant > mergeCustomHighlighting(QStringList strings, QList< QVariantList > highlights, int gapBetweenStrings=0)
Helper-function to merge custom-highlighting variant-lists.
Definition: expandingwidgetmodel.cpp:490
QAbstractTableModel::index
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const
ExpandingWidgetModel::treeView
virtual QTreeView * treeView() const =0
QAbstractTableModel
ExpandingWidgetModel::partialExpandText
QString partialExpandText(const QModelIndex &row) const
Definition: expandingwidgetmodel.cpp:244
QMap< QModelIndex, ExpansionType >
ExpandingWidgetModel::ExpansionType
ExpansionType
Definition: expandingwidgetmodel.h:65
ExpandingWidgetModel::isPartiallyExpanded
ExpansionType isPartiallyExpanded(const QModelIndex &index) const
Returns whether the given index is currently partially expanded. Does not do any other checks like ca...
Definition: expandingwidgetmodel.cpp:139
ExpandingWidgetModel::m_collapsedIcon
static QIcon m_collapsedIcon
Definition: expandingwidgetmodel.h:136
ExpandingWidgetModel::isExpandable
bool isExpandable(const QModelIndex &index) const
Definition: expandingwidgetmodel.cpp:290
ExpandingWidgetModel::Expanded
Definition: expandingwidgetmodel.h:46
ExpandingWidgetModel::placeExpandingWidget
void placeExpandingWidget(const QModelIndex &row)
Places and shows the expanding-widget for the given row, if it should be visible and is valid...
Definition: expandingwidgetmodel.cpp:370
QRect
ExpandingWidgetModel::data
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Does not request data from index, this only returns local data like highlighting for expanded rows an...
Definition: expandingwidgetmodel.cpp:88
ExpandingWidgetModel::Expandable
Definition: expandingwidgetmodel.h:45
ExpandingWidgetModel::contextMatchQuality
virtual int contextMatchQuality(const QModelIndex &index) const =0
ExpandingWidgetModel::expandingWidget
QWidget * expandingWidget(const QModelIndex &row) const
Definition: expandingwidgetmodel.cpp:431
ExpandingWidgetModel::matchColor
uint matchColor(const QModelIndex &index) const
Returns the match-color for the given index, or zero if match-quality could not be computed...
Definition: expandingwidgetmodel.cpp:58
QString
QList
QStringList
ExpandingWidgetModel::isExpanded
bool isExpanded(const QModelIndex &row) const
Definition: expandingwidgetmodel.cpp:305
ExpandingWidgetModel::ExpandingWidgetModel
ExpandingWidgetModel(QWidget *parent)
Definition: expandingwidgetmodel.cpp:44
ExpandingWidgetModel::partiallyExpandWidgetHeight
int partiallyExpandWidgetHeight() const
Amount by which the height of a row increases when it is partially expanded.
Definition: expandingwidgetmodel.cpp:153
ExpandingWidgetModel::clearMatchQualities
void clearMatchQualities()
Definition: expandingwidgetmodel.cpp:112
ExpandingWidgetModel::canCollapseCurrentItem
bool canCollapseCurrentItem() const
ExpandingWidgetModel::ExpandingType
ExpandingType
Definition: expandingwidgetmodel.h:43
ExpandingWidgetModel::NotExpanded
Definition: expandingwidgetmodel.h:66
ExpandingWidgetModel::setExpanded
void setExpanded(QModelIndex index, bool expanded)
Change the expand-state of the row given through index. The display will be updated.
Definition: expandingwidgetmodel.cpp:311
QTreeView
ExpandingWidgetModel::~ExpandingWidgetModel
virtual ~ExpandingWidgetModel()
Definition: expandingwidgetmodel.cpp:49
ExpandingWidgetModel::ExpandDownwards
Definition: expandingwidgetmodel.h:67
QObject::parent
QObject * parent() const
QTextEdit
ExpandingWidgetModel::m_expandedIcon
static QIcon m_expandedIcon
Definition: expandingwidgetmodel.h:135
ExpandingWidgetModel::canExpandCurrentItem
bool canExpandCurrentItem() const
The following three are convenience-functions for the current item that could be replaced by the late...
ExpandingWidgetModel::expandingWidgetsHeight
int expandingWidgetsHeight() const
Returns the total height added through all open expanding-widgets.
Definition: expandingwidgetmodel.cpp:420
ExpandingWidgetModel::cacheIcons
void cacheIcons() const
Definition: expandingwidgetmodel.cpp:441
ExpandingWidgetModel::basicRowHeight
int basicRowHeight(const QModelIndex &index) const
Definition: expandingwidgetmodel.cpp:357
QIcon
ExpandingWidgetModel::indexIsItem
virtual bool indexIsItem(const QModelIndex &index) const =0
Should return true if the given row should be painted like a contained item(as opposed to label-rows ...
QVariant
ExpandingWidgetModel
Cares about expanding/un-expanding items in a tree-view together with ExpandingDelegate.
Definition: expandingwidgetmodel.h:36
ExpandingWidgetModel::partialExpandRect
QRect partialExpandRect(const QModelIndex &row) const
Returns the rectangle for the partially expanded part of the given row.
Definition: expandingwidgetmodel.cpp:251
ExpandingWidgetModel::ExpandUpwards
Definition: expandingwidgetmodel.h:68
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