┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/klistview_p.h
diff options
context:
space:
mode:
authorRafael Fernández López <[email protected]>2007-06-17 15:32:31 +0000
committerRafael Fernández López <[email protected]>2007-06-17 15:32:31 +0000
commit11f0a8c50310ebbcaa93318cb097077482268cdd (patch)
tree06df222f3e7812bea96db8b8c1a40256547ec7b0 /src/klistview_p.h
parent1c0341958df6d5cea0a2725afb6245ce498422b2 (diff)
New and powerful KListView. Still pending class renaming. There are two
methods that I need to think about it, and boost. Small issues like reloading all data when sorting role suddenly changes. In general terms it will work nice when you sort by name or size. We have to work further when we sort by other roles. Nice times. svn path=/trunk/KDE/kdebase/apps/; revision=676732
Diffstat (limited to 'src/klistview_p.h')
-rw-r--r--src/klistview_p.h114
1 files changed, 104 insertions, 10 deletions
diff --git a/src/klistview_p.h b/src/klistview_p.h
index 5ada074e5..47be30c56 100644
--- a/src/klistview_p.h
+++ b/src/klistview_p.h
@@ -18,27 +18,121 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __KLISTVIEW_P_H__
-#define __KLISTVIEW_P_H__
+#ifndef KLISTVIEW_P_H
+#define KLISTVIEW_P_H
-class QSortFilterProxyModel;
+class KSortFilterProxyModel;
+/**
+ * @internal
+ */
class KListView::Private
{
public:
Private(KListView *listView);
~Private();
- QModelIndexList intersectionSet(const QRect &rect) const;
+ // Methods
+
+ /**
+ * Returns the list of items that intersects with @p rect
+ */
+ const QModelIndexList &intersectionSet(const QRect &rect);
+
+ /**
+ * Gets the item rect in the viewport for @p index
+ */
+ QRect visualRectInViewport(const QModelIndex &index) const;
+
+ /**
+ * Returns the category rect in the viewport for @p category
+ */
+ QRect visualCategoryRectInViewport(const QString &category) const;
+
+ /**
+ * Caches and returns the rect that corresponds to @p index
+ */
+ const QRect &cacheIndex(const QModelIndex &index);
+
+ /**
+ * Caches and returns the rect that corresponds to @p category
+ */
+ const QRect &cacheCategory(const QString &category);
+
+ /**
+ * Returns the rect that corresponds to @p index
+ * @note If the rect is not cached, it becomes cached
+ */
+ const QRect &cachedRectIndex(const QModelIndex &index);
+
+ /**
+ * Returns the rect that corresponds to @p category
+ * @note If the rect is not cached, it becomes cached
+ */
+ const QRect &cachedRectCategory(const QString &category);
+
+ /**
+ * Returns the visual rect (taking in count x and y offsets) for @p index
+ * @note If the rect is not cached, it becomes cached
+ */
+ QRect visualRect(const QModelIndex &index);
+
+ /**
+ * Returns the visual rect (taking in count x and y offsets) for @p category
+ * @note If the rect is not cached, it becomes cached
+ */
+ QRect categoryVisualRect(const QString &category);
+
+ /**
+ * This method will draw a new category with name @p category on the rect
+ * specified by @p option.rect, with painter @p painter
+ */
+ void drawNewCategory(const QString &category,
+ const QStyleOption &option,
+ QPainter *painter);
+
+ /**
+ * This method will update scrollbars ranges. Called when our model changes
+ * or when the view is resized
+ */
+ void updateScrollbars();
+
+
+ // Attributes
+
+ struct ElementInfo
+ {
+ QString category;
+ int relativeOffsetToCategory;
+ };
+
+ // Basic data
KListView *listView;
- QModelIndex hovered;
- bool modelSortCapable;
- int numCategories;
- QList<QString> categories;
- QHash<QString, int> elementsPerCategory;
KItemCategorizer *itemCategorizer;
- QSortFilterProxyModel *proxyModel;
+
+ // Behavior data
+ bool mouseButtonPressed;
+ QModelIndex hovered;
+ QPoint initialPressPosition;
+ QPoint mousePosition;
+
+ // Cache data
+ // We cannot merge some of them into structs because it would affect
+ // performance
+ QHash<QModelIndex, struct ElementInfo> elementsInfo; // in source model
+ QHash<QModelIndex, QRect> elementsPosition; // in source model
+ QHash<QModelIndex, QModelIndex> elementDictionary; // mapped indexes
+ QHash<QString, QModelIndexList> categoriesIndexes;
+ QHash<QString, QRect> categoriesPosition;
+ QStringList categories;
+ QModelIndexList intersectedIndexes;
+ QModelIndexList tempSelected;
+
+ // Attributes for speed reasons
+ KSortFilterProxyModel *proxyModel;
+ QModelIndexList sourceModelIndexList; // in source model
+ QModelIndex lastIndex;
};
#endif // __KLISTVIEW_P_H__