1
/* This file is part of Clementine.
2
Copyright 2010, David Sansome <me@davidsansome.com>
4
Clementine is free software: you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation, either version 3 of the License, or
7
(at your option) any later version.
9
Clementine is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
18
#ifndef GROUPEDICONVIEW_H
19
#define GROUPEDICONVIEW_H
23
class MultiSortFilterProxy;
26
class GroupedIconView : public QListView {
29
// Vertical space separating a header from the items above and below it.
30
Q_PROPERTY(int header_spacing READ header_spacing WRITE set_header_spacing)
32
// Horizontal space separating a header from the left and right edges of the widget.
33
Q_PROPERTY(int header_indent READ header_indent WRITE set_header_indent)
35
// Horizontal space separating an item from the left and right edges of the widget.
36
Q_PROPERTY(int item_indent READ item_indent WRITE set_item_indent)
38
// The text of each group's header. Must contain "%1".
39
Q_PROPERTY(QString header_text READ header_text WRITE set_header_text);
42
GroupedIconView(QWidget* parent = 0);
48
void AddSortSpec(int role, Qt::SortOrder order = Qt::AscendingOrder);
50
int header_spacing() const { return header_spacing_; }
51
int header_indent() const { return header_indent_; }
52
int item_indent() const { return item_indent_; }
53
const QString& header_text() const { return header_text_;}
55
void set_header_spacing(int value) { header_spacing_ = value; }
56
void set_header_indent(int value) { header_indent_ = value; }
57
void set_item_indent(int value) { item_indent_ = value; }
58
void set_header_text(const QString& value) { header_text_ = value; }
61
QModelIndex moveCursor(CursorAction action, Qt::KeyboardModifiers modifiers);
62
void setModel(QAbstractItemModel* model);
64
static void DrawHeader(QPainter* painter, const QRect& rect,
65
const QFont& font, const QPalette& palette,
69
virtual int header_height() const;
72
void paintEvent(QPaintEvent* e);
73
void resizeEvent(QResizeEvent* e);
76
void dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
77
QModelIndex indexAt(const QPoint& p) const;
78
void rowsInserted(const QModelIndex& parent, int start, int end);
79
void setSelection(const QRect& rect, QItemSelectionModel::SelectionFlags command);
80
QRect visualRect(const QModelIndex& index) const;
81
QRegion visualRegionForSelection(const QItemSelection& selection) const;
87
static const int kBarThickness;
88
static const int kBarMarginTop;
96
// Returns the items that are wholly or partially inside the rect.
97
QVector<QModelIndex> IntersectingItems(const QRect& rect) const;
99
// Returns the index of the item above (d=-1) or below (d=+1) the given item.
100
int IndexAboveOrBelow(int index, int d) const;
102
MultiSortFilterProxy* proxy_model_;
103
QVector<QRect> visual_rects_;
104
QVector<Header> headers_;
106
const int default_header_height_;
110
QString header_text_;
113
#endif // GROUPEDICONVIEW_H