1
/***************************************************************************
2
* Copyright (C) 2010 - 2011 by Ingomar Wesp <ingomar@wesp.name> *
4
* This program 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 2 of the License, or *
7
* (at your option) any later version. *
9
* This program 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 this program; if not, write to the *
16
* Free Software Foundation, Inc., *
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18
***************************************************************************/
19
#ifndef QUICKLAUNCH_ICONGRIDLAYOUT_H
20
#define QUICKLAUNCH_ICONGRIDLAYOUT_H
25
#include <QtCore/QList>
26
#include <QtCore/QSizeF>
27
#include <QtGui/QGraphicsLayout>
31
class QGraphicsLayoutItem;
33
namespace Quicklaunch {
35
class IconGridLayout : public QGraphicsLayout {
40
PreferColumns, /**< Prefer columns over rows. */
41
PreferRows /**< Prefer rows over columns. */
44
IconGridLayout(QGraphicsLayoutItem *parent = 0);
48
void setMode(Mode mode);
50
int cellSpacing() const;
51
void setCellSpacing(int cellSpacing);
52
int maxSectionCount() const;
55
* Depending on the mode, @c setMaxSectionCount limits either the
56
* number of rows or the number of columns that are displayed. In
57
* @c PreferColumns mode, @a maxSectionCount limites the maximum
58
* number of columns while in @c PreferRows mode, it applies to
59
* the maximum number of rows.
61
* Setting @a maxSectionCount to @c 0 disables the limitation.
63
* @param maxSectionCount the maximum number of rows or columns
64
* (depending on the mode) that should be displayed.
66
void setMaxSectionCount(int maxSectionCount);
68
bool maxSectionCountForced() const;
70
void setMaxSectionCountForced(bool enable);
72
void addItem(QGraphicsLayoutItem *item);
73
void insertItem(int index, QGraphicsLayoutItem *item);
76
int columnCount() const;
78
QGraphicsLayoutItem *itemAt(int index) const;
79
QGraphicsLayoutItem *itemAt(int row, int column) const;
80
void moveItem(int from, int to);
81
void removeAt(int index);
83
void setGeometry(const QRectF &rect);
84
QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
86
static const int DEFAULT_CELL_SPACING;
89
void computeGridParameters(
90
QList<int> &rowHeights, QList<int> &columnWidths,
91
QSizeF &preferredSize) const;
93
void updateGridParameters();
95
QList<QGraphicsLayoutItem*> m_items;
98
int m_maxSectionCount;
99
bool m_maxSectionCountForced;
103
QList<int> m_rowHeights;
104
QList<int> m_columnWidths;
105
QSizeF m_preferredSizeHint;
109
#endif /* QUICKLAUNCH_ICONGRIDLAYOUT_H */