Changeset View
Changeset View
Standalone View
Standalone View
plugins/quickopen/expandingtree/expandingwidgetmodel.h
Show All 20 Lines | |||||
21 | #ifndef KDEVPLATFORM_PLUGIN_EXPANDING_WIDGET_MODEL_H | 21 | #ifndef KDEVPLATFORM_PLUGIN_EXPANDING_WIDGET_MODEL_H | ||
22 | #define KDEVPLATFORM_PLUGIN_EXPANDING_WIDGET_MODEL_H | 22 | #define KDEVPLATFORM_PLUGIN_EXPANDING_WIDGET_MODEL_H | ||
23 | 23 | | |||
24 | #include <QAbstractTableModel> | 24 | #include <QAbstractTableModel> | ||
25 | #include <QtCore/QHash> | 25 | #include <QtCore/QHash> | ||
26 | #include <QIcon> | 26 | #include <QIcon> | ||
27 | #include <QPersistentModelIndex> | 27 | #include <QPersistentModelIndex> | ||
28 | #include <QPointer> | 28 | #include <QPointer> | ||
29 | #include <QSortFilterProxyModel> | ||||
30 | | ||||
31 | class ExpandingDelegate; | ||||
32 | class ExpandingTree; | ||||
29 | 33 | | |||
30 | class KWidget; | 34 | class KWidget; | ||
31 | class QTreeView; | 35 | class QTreeView; | ||
32 | class QTextEdit; | 36 | class QTextEdit; | ||
33 | 37 | | |||
34 | /** | 38 | /** | ||
35 | * Cares about expanding/un-expanding items in a tree-view together with ExpandingDelegate | 39 | * Cares about expanding/un-expanding items in a tree-view together with ExpandingDelegate | ||
36 | */ | 40 | */ | ||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Line(s) | 41 | class ExpandingWidgetModel : public QAbstractTableModel { | |||
92 | * Does nothing when nothing needs to be done. | 96 | * Does nothing when nothing needs to be done. | ||
93 | * Does NOT show the expanding-widget. That is done immediately when painting by ExpandingDelegate, | 97 | * Does NOT show the expanding-widget. That is done immediately when painting by ExpandingDelegate, | ||
94 | * to reduce flickering. @see showPartialExpandWidget() | 98 | * to reduce flickering. @see showPartialExpandWidget() | ||
95 | * @param row The row | 99 | * @param row The row | ||
96 | * */ | 100 | * */ | ||
97 | /// | 101 | /// | ||
98 | virtual void rowSelected(const QModelIndex & row); | 102 | virtual void rowSelected(const QModelIndex & row); | ||
99 | 103 | | |||
100 | ///Returns the rectangle for the partially expanded part of the given row | 104 | /// Returns the rectangle for the partially expanded part of the given row | ||
105 | /// TODO: Do this via QAIM roles? | ||||
101 | QRect partialExpandRect(const QModelIndex & row) const; | 106 | QRect partialExpandRect(const QModelIndex & row) const; | ||
102 | 107 | | |||
108 | /// TODO: Do this via QAIM roles? | ||||
103 | QString partialExpandText(const QModelIndex & row) const; | 109 | QString partialExpandText(const QModelIndex & row) const; | ||
104 | 110 | | |||
105 | ///Places and shows the expanding-widget for the given row, if it should be visible and is valid. | 111 | ///Places and shows the expanding-widget for the given row, if it should be visible and is valid. | ||
106 | ///Also shows the partial-expanding-widget when it should be visible. | 112 | ///Also shows the partial-expanding-widget when it should be visible. | ||
107 | void placeExpandingWidget(const QModelIndex & row); | 113 | void placeExpandingWidget(const QModelIndex & row); | ||
108 | 114 | | |||
109 | virtual QTreeView* treeView() const = 0; | 115 | virtual QTreeView* treeView() const = 0; | ||
110 | 116 | | |||
Show All 14 Lines | |||||
125 | void placeExpandingWidgets(); | 131 | void placeExpandingWidgets(); | ||
126 | 132 | | |||
127 | protected: | 133 | protected: | ||
128 | /** | 134 | /** | ||
129 | * @return the context-match quality from 0 to 10 if it could be determined, else -1 | 135 | * @return the context-match quality from 0 to 10 if it could be determined, else -1 | ||
130 | * */ | 136 | * */ | ||
131 | virtual int contextMatchQuality(const QModelIndex & index) const = 0; | 137 | virtual int contextMatchQuality(const QModelIndex & index) const = 0; | ||
132 | 138 | | |||
139 | QModelIndex mapFromSource(const QModelIndex& index) const; | ||||
140 | QModelIndex mapToSource(const QModelIndex& index) const; | ||||
141 | | ||||
133 | //Makes sure m_expandedIcon and m_collapsedIcon are loaded | 142 | //Makes sure m_expandedIcon and m_collapsedIcon are loaded | ||
134 | void cacheIcons() const; | 143 | void cacheIcons() const; | ||
135 | 144 | | |||
136 | static QIcon m_expandedIcon; | 145 | static QIcon m_expandedIcon; | ||
137 | static QIcon m_collapsedIcon; | 146 | static QIcon m_collapsedIcon; | ||
138 | 147 | | |||
139 | //Does not update the view | 148 | //Does not update the view | ||
140 | void partiallyUnExpand(const QModelIndex& index); | 149 | void partiallyUnExpand(const QModelIndex& index); | ||
141 | //Finds out the basic height of the row represented by the given index. Basic means without respecting any expansion. | 150 | //Finds out the basic height of the row represented by the given index. Basic means without respecting any expansion. | ||
142 | int basicRowHeight( const QModelIndex& index ) const; | 151 | int basicRowHeight( const QModelIndex& index ) const; | ||
143 | 152 | | |||
144 | private: | 153 | private: | ||
154 | friend ExpandingDelegate; | ||||
155 | friend ExpandingTree; | ||||
156 | | ||||
145 | QMap<QModelIndex, ExpansionType> m_partiallyExpanded; | 157 | QMap<QModelIndex, ExpansionType> m_partiallyExpanded; | ||
146 | // Store expanding-widgets and cache whether items can be expanded | 158 | // Store expanding-widgets and cache whether items can be expanded | ||
147 | mutable QMap<QModelIndex, ExpandingType> m_expandState; | 159 | mutable QMap<QModelIndex, ExpandingType> m_expandState; | ||
148 | QMap< QModelIndex, QPointer<QWidget> > m_expandingWidgets; //Map rows to their expanding-widgets | 160 | QMap< QModelIndex, QPointer<QWidget> > m_expandingWidgets; //Map rows to their expanding-widgets | ||
149 | QMap< QModelIndex, int > m_contextMatchQualities; //Map rows to their context-match qualities(undefined if unknown, else 0 to 10). Not used yet, eventually remove. | 161 | QMap< QModelIndex, int > m_contextMatchQualities; //Map rows to their context-match qualities(undefined if unknown, else 0 to 10). Not used yet, eventually remove. | ||
150 | }; | 162 | }; | ||
151 | 163 | | |||
152 | 164 | | |||
Show All 9 Lines |