not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / systemsettings / kicongrouppage.h
blobe2303a38d771bb8e1c9ab119684b932322cc5477
1 /*
2 kicongrouppage.h
4 Copyright (c) 2007 Michael D. Stemle, Jr. <manchicken@notsosoft.net>
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
23 #ifndef KICONGROUPPAGE_H
25 #define KICONGROUPPAGE_H
27 #include <QObject>
28 #include <QList>
29 #include <QMap>
30 #include <QBoxLayout>
31 #include <QIcon>
32 #include <QLabel>
33 #include <kicon.h>
35 class KIconGroupPage;
36 class KIconGroupRow;
37 class KIconGroupItem;
39 /* DESIGN
40 VBox contains two rows: title and HBOX (maybe a third for a line?
41 HBOX contains columns of VBOXes
42 Those VBoxes contain two rows: icon and title
44 +---------------Box-----------------+
45 | |
46 | +-------------Box---------------+ |
47 | | | |
48 | | +-----------Box-------------+ | |
49 | | | | | |
50 | | | +--QLabel--+ +--QLabel--+ | | |
51 | | | | | | | | | |
52 | | | | ICON | | ICON | | | |
53 | | | | LABEL | | LABEL | | | |
54 | | | | | | | | | |
55 | | | +----------+ +----------+ | | |
56 | | | | | |
57 | | +---------------------------+ | |
58 | | | |
59 | +-------------------------------+ |
60 | |
61 +-----------------------------------+
67 /**
68 * A page of group icons
69 **/
70 class KIconGroupPage : public QFrame {
71 Q_OBJECT;
73 /**
74 * Property for the page name
75 **/
76 Q_PROPERTY(QString m_pageName READ pageName WRITE setPageName);
78 public:
80 /**
81 * Constructor for KIconGroupPage
83 * @param parent The parent widget for the page..
84 **/
85 explicit KIconGroupPage(QWidget* parent = 0);
87 ~KIconGroupPage();
89 /**
90 * Append a group to the page
92 * @param title The title of the group
93 * @returns A constant pointer to the group that was added.
94 **/
95 void appendGroup(QString name);
97 /**
98 * Append an icon to a group
100 * @param group The group name to append the icon to
101 * @param icon The icon to use
102 * @param label The label to use with the icon
103 * @returns A constant pointer to the item that was added.
105 const KIconGroupItem* appendIconToGroup(const QString& name,
106 const QIcon& icon,
107 const QString& label);
110 * Set the page name
112 * @param name The name to assign.
114 void setPageName(QString name) { m_pageName = name; };
117 * Get the page name
119 * @return Returns the page name
121 QString pageName() const { return m_pageName; };
123 private:
124 void render();
126 // Internal values
127 QString m_pageName;
128 QMap<QString, KIconGroupRow*> m_rows;
129 QBoxLayout* m_layout;
134 * The row of icon groups
136 class KIconGroupRow : public QBoxLayout {
137 Q_OBJECT;
140 * Property for the icon group name
142 Q_PROPERTY(QString m_groupName READ groupName WRITE setGroupName);
144 public:
147 * Constructor for KIconGroupRow
149 * @param parent The parent to stick the KIconGroupRow widget into.
151 explicit KIconGroupRow(QWidget* parent = 0);
154 * Constructor for KIconGroupRow
156 * @param parent The parent to stick the KIconGroupRow widget into.
157 * @param name The name for the icon group row.
159 explicit KIconGroupRow(QString& name, QWidget* parent = 0);
162 * Deconstructor
164 ~KIconGroupRow();
167 * Append an icon
169 * @param icon The icon to add
170 * @param label The label to add
171 * @returns A constant pointer to the item that was just added.
173 const KIconGroupItem* appendIcon( const QIcon& icon, const QString& label );
176 * Set the group name
178 * @param name The name to assign
180 void setGroupName(QString name) { m_groupName = name; };
183 * Get the group name
185 * @return The group name.
187 QString groupName() const { return m_groupName; };
189 private:
190 void render();
192 QString m_groupName;
193 QList<KIconGroupItem*> m_icons;
198 * KIconGroupItem
200 * @notes This is the low-level icon class for the icon groups.
202 class KIconGroupItem : public QLabel {
203 Q_OBJECT;
205 public:
208 * A single icon in the group.
209 * @param parent The parent widget
210 * @param icon The icon to display
211 * @param label The label to display for the icon.
213 explicit KIconGroupItem(QWidget* parent, const QIcon& icon, const QString& label);
216 * Set the parent widget
218 * @param parent The parent widget to set
220 void setParent(QWidget* parent);
223 * Set the icon
225 * @param icon The icon to add to the group item
227 void setIcon(const QIcon& icon);
230 * Get the icon
232 * @return Returns the currently set icon object
234 const QIcon& icon() { return m_icon; };
237 * Set the label
239 * @param label The label to set
241 void setLabel(const QString& label);
244 * Fetch the label
246 const QString& label() { return m_text; };
248 protected:
249 void render();
251 private:
252 Q_DISABLE_COPY(KIconGroupItem);
253 QWidget* m_parent;
254 QIcon m_icon;
255 QString m_text;
258 #endif // KICONGROUPPAGE_H