2 * This file is part of the KDE project
3 * Copyright (C) 2007 Rafael Fernández López <ereslibre@gmail.com>
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 * This method will draw a new category represented by index
90 * @param index on the rect specified by @p option.rect, with
93 void drawNewCategory(const QModelIndex
&index
,
95 const QStyleOption
&option
,
99 * This method will update scrollbars ranges. Called when our model changes
100 * or when the view is resized
102 void updateScrollbars();
105 * This method will draw dragged items in the painting operation
107 void drawDraggedItems(QPainter
*painter
);
110 * This method will determine which rect needs to be updated because of a
113 void drawDraggedItems();
121 int relativeOffsetToCategory
;
125 KCategorizedView
*listView
;
126 KCategoryDrawer
*categoryDrawer
;
127 QSize biggestItemSize
;
130 bool mouseButtonPressed
;
132 bool dragLeftViewport
;
134 QString hoveredCategory
;
135 QPoint initialPressPosition
;
136 QPoint mousePosition
;
137 QItemSelection lastSelection
;
138 QModelIndex currentViewIndex
;
139 int forcedSelectionPosition
;
142 // We cannot merge some of them into structs because it would affect
144 QHash
<int, struct ElementInfo
> elementsInfo
;
145 QHash
<int, QRect
> elementsPosition
;
146 QHash
<QString
, QModelIndexList
> categoriesIndexes
;
147 QHash
<QString
, QRect
> categoriesPosition
;
148 QStringList categories
;
149 QModelIndexList intersectedIndexes
;
150 QRect lastDraggedItemsRect
;
151 QRect lastSelectionRect
;
153 // Attributes for speed reasons
154 KCategorizedSortFilterProxyModel
*proxyModel
;
155 QModelIndexList modelIndexList
;
158 #endif // KCATEGORIZEDVIEW_P_H