~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to plasma/generic/applets/quicklaunch/icongridlayout.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2010 - 2011 by Ingomar Wesp <ingomar@wesp.name>         *
 
3
 *                                                                         *
 
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.                                   *
 
8
 *                                                                         *
 
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.                          *
 
13
 *                                                                         *
 
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
 
21
 
 
22
// Qt
 
23
#include <Qt>
 
24
#include <QtGlobal>
 
25
#include <QtCore/QList>
 
26
#include <QtCore/QSizeF>
 
27
#include <QtGui/QGraphicsLayout>
 
28
 
 
29
class QEvent;
 
30
class QRectF;
 
31
class QGraphicsLayoutItem;
 
32
 
 
33
namespace Quicklaunch {
 
34
 
 
35
class IconGridLayout : public QGraphicsLayout {
 
36
 
 
37
public:
 
38
 
 
39
    enum Mode {
 
40
        PreferColumns, /**< Prefer columns over rows. */
 
41
        PreferRows     /**< Prefer rows over columns. */
 
42
    };
 
43
 
 
44
    IconGridLayout(QGraphicsLayoutItem *parent = 0);
 
45
    ~IconGridLayout();
 
46
 
 
47
    Mode mode() const;
 
48
    void setMode(Mode mode);
 
49
 
 
50
    int cellSpacing() const;
 
51
    void setCellSpacing(int cellSpacing);
 
52
    int maxSectionCount() const;
 
53
 
 
54
    /**
 
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.
 
60
     *
 
61
     * Setting @a maxSectionCount to @c 0 disables the limitation.
 
62
     *
 
63
     * @param maxSectionCount the maximum number of rows or columns
 
64
     *    (depending on the mode) that should be displayed.
 
65
     */
 
66
    void setMaxSectionCount(int maxSectionCount);
 
67
 
 
68
    bool maxSectionCountForced() const;
 
69
 
 
70
    void setMaxSectionCountForced(bool enable);
 
71
 
 
72
    void addItem(QGraphicsLayoutItem *item);
 
73
    void insertItem(int index, QGraphicsLayoutItem *item);
 
74
 
 
75
    int count() const;
 
76
    int columnCount() const;
 
77
    int rowCount() 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);
 
82
 
 
83
    void setGeometry(const QRectF &rect);
 
84
    QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
 
85
 
 
86
    static const int DEFAULT_CELL_SPACING;
 
87
 
 
88
private:
 
89
    void computeGridParameters(
 
90
            QList<int> &rowHeights, QList<int> &columnWidths,
 
91
            QSizeF &preferredSize) const;
 
92
 
 
93
    void updateGridParameters();
 
94
 
 
95
    QList<QGraphicsLayoutItem*> m_items;
 
96
    Mode m_mode;
 
97
    int m_cellSpacing;
 
98
    int m_maxSectionCount;
 
99
    bool m_maxSectionCountForced;
 
100
 
 
101
    int m_rowCount;
 
102
    int m_columnCount;
 
103
    QList<int> m_rowHeights;
 
104
    QList<int> m_columnWidths;
 
105
    QSizeF m_preferredSizeHint;
 
106
};
 
107
}
 
108
 
 
109
#endif /* QUICKLAUNCH_ICONGRIDLAYOUT_H */