2
* This file is part of the KDE project
3
* Copyright (C) 2007 Rafael Fernández López <ereslibre@kde.org>
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.
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.
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.
21
#ifndef KCATEGORIZEDVIEW_P_H
22
#define KCATEGORIZEDVIEW_P_H
24
class KCategorizedSortFilterProxyModel;
25
class KCategoryDrawer;
30
class KCategorizedView::Private
33
Private(KCategorizedView *listView);
40
* Returns the list of items that intersects with @p rect
42
const QModelIndexList &intersectionSet(const QRect &rect);
45
* Gets the item rect in the viewport for @p index
47
QRect visualRectInViewport(const QModelIndex &index) const;
50
* Returns the category rect in the viewport for @p category
52
QRect visualCategoryRectInViewport(const QString &category) const;
55
* Caches and returns the rect that corresponds to @p index
57
const QRect &cacheIndex(const QModelIndex &index);
60
* Caches and returns the rect that corresponds to @p category
62
const QRect &cacheCategory(const QString &category);
65
* Returns the rect that corresponds to @p index
66
* @note If the rect is not cached, it becomes cached
68
const QRect &cachedRectIndex(const QModelIndex &index);
71
* Returns the rect that corresponds to @p category
72
* @note If the rect is not cached, it becomes cached
74
const QRect &cachedRectCategory(const QString &category);
77
* Returns the visual rect (taking in count x and y offsets) for @p index
78
* @note If the rect is not cached, it becomes cached
80
QRect visualRect(const QModelIndex &index);
83
* Returns the visual rect (taking in count x and y offsets) for @p category
84
* @note If the rect is not cached, it becomes cached
86
QRect categoryVisualRect(const QString &category);
89
* Returns the contents size of this view (topmost category to bottommost index + spacing)
94
* This method will draw a new category represented by index
95
* @p index on the rect specified by @p option.rect, with
98
void drawNewCategory(const QModelIndex &index,
100
const QStyleOption &option,
104
* This method will update scrollbars ranges. Called when our model changes
105
* or when the view is resized
107
void updateScrollbars();
110
* This method will draw dragged items in the painting operation
112
void drawDraggedItems(QPainter *painter);
115
* This method will determine which rect needs to be updated because of a
118
void drawDraggedItems();
121
* This method will, starting from the index at begin in the given (sorted) modelIndex List,
122
* find the last index having the same category as the index to begin with.
124
int categoryUpperBound(const QVector<QModelIndex> &modelIndexList, int begin, int averageSize = 0);
127
* Returns a QItemSelection for all items intersection rect.
129
QItemSelection selectionForRect(const QRect &rect);
136
int relativeOffsetToCategory;
140
KCategorizedView* listView;
141
KCategoryDrawer* categoryDrawer;
142
QSize biggestItemSize;
145
bool mouseButtonPressed;
146
bool rightMouseButtonPressed;
147
bool dragLeftViewport;
148
bool drawItemsWhileDragging;
150
QString hoveredCategory;
151
QPoint initialPressPosition;
152
QPoint mousePosition;
153
int forcedSelectionPosition;
156
// We cannot merge some of them into structs because it would affect
158
QVector<struct ElementInfo> elementsInfo;
159
QHash<int, QRect> elementsPosition;
160
QHash<QString, QVector<int> > categoriesIndexes;
161
QHash<QString, QRect> categoriesPosition;
162
QStringList categories;
163
QModelIndexList intersectedIndexes;
164
QRect lastDraggedItemsRect;
165
QItemSelection lastSelection;
167
// Attributes for speed reasons
168
KCategorizedSortFilterProxyModel* proxyModel;
171
#endif // KCATEGORIZEDVIEW_P_H