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.
24 class KSortFilterProxyModel
;
29 class KListView::Private
32 Private(KListView
*listView
);
39 * Returns the list of items that intersects with @p rect
41 const QModelIndexList
&intersectionSet(const QRect
&rect
);
44 * Gets the item rect in the viewport for @p index
46 QRect
visualRectInViewport(const QModelIndex
&index
) const;
49 * Returns the category rect in the viewport for @p category
51 QRect
visualCategoryRectInViewport(const QString
&category
) const;
54 * Caches and returns the rect that corresponds to @p index
56 const QRect
&cacheIndex(const QModelIndex
&index
);
59 * Caches and returns the rect that corresponds to @p category
61 const QRect
&cacheCategory(const QString
&category
);
64 * Returns the rect that corresponds to @p index
65 * @note If the rect is not cached, it becomes cached
67 const QRect
&cachedRectIndex(const QModelIndex
&index
);
70 * Returns the rect that corresponds to @p category
71 * @note If the rect is not cached, it becomes cached
73 const QRect
&cachedRectCategory(const QString
&category
);
76 * Returns the visual rect (taking in count x and y offsets) for @p index
77 * @note If the rect is not cached, it becomes cached
79 QRect
visualRect(const QModelIndex
&index
);
82 * Returns the visual rect (taking in count x and y offsets) for @p category
83 * @note If the rect is not cached, it becomes cached
85 QRect
categoryVisualRect(const QString
&category
);
88 * This method will draw a new category represented by index
89 * @param index on the rect specified by @p option.rect, with
92 void drawNewCategory(const QModelIndex
&index
,
94 const QStyleOption
&option
,
98 * This method will update scrollbars ranges. Called when our model changes
99 * or when the view is resized
101 void updateScrollbars();
104 * This method will draw dragged items in the painting operation
106 void drawDraggedItems(QPainter
*painter
);
109 * This method will determine which rect needs to be updated because of a
112 void drawDraggedItems();
120 int relativeOffsetToCategory
;
125 KItemCategorizer
*itemCategorizer
;
128 bool mouseButtonPressed
;
130 bool dragLeftViewport
;
132 QString hoveredCategory
;
133 QPoint initialPressPosition
;
134 QPoint mousePosition
;
135 QItemSelection lastSelection
;
136 QModelIndex currentViewIndex
;
137 int forcedSelectionPosition
;
140 // We cannot merge some of them into structs because it would affect
142 QHash
<QModelIndex
, struct ElementInfo
> elementsInfo
; // in source model
143 QHash
<QModelIndex
, QRect
> elementsPosition
; // in source model
144 QHash
<QModelIndex
, QModelIndex
> elementDictionary
; // mapped indexes
145 QHash
<QModelIndex
, QModelIndex
> invertedElementDictionary
; // mapped indexes
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 KSortFilterProxyModel
*proxyModel
;
155 QModelIndexList sourceModelIndexList
; // in source model
156 QModelIndex lastIndex
;
159 #endif // KLISTVIEW_P_H