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 #include "kicongrouppage.h"
25 #include <QtAlgorithms>
28 /*********** KIconGroupPage **************/
29 KIconGroupPage::KIconGroupPage(QWidget
* parent
) : QFrame(parent
) {
33 KIconGroupPage::~KIconGroupPage() {
39 const KIconGroupRow
* KIconGroupPage::appendGroup(QString name
) {
40 KIconGroupRow
* group
= new KIconGroupRow(name
, parentWidget());
42 m_rows
.insert(name
, group
);
49 const KIconGroupItem
* KIconGroupPage::appendIconToGroup(const QString
& group
,
51 const QString
& label
) {
52 if (!m_rows
.contains(group
)) {
56 return m_rows
[group
]->appendIcon(icon
, label
);
59 void KIconGroupPage::render() {
60 m_layout
= new QBoxLayout(QBoxLayout::TopToBottom
, parentWidget());
64 /*********** KIconGroupRow **************/
65 KIconGroupRow::KIconGroupRow(QWidget
* parent
) : QBoxLayout(QBoxLayout::LeftToRight
, parent
) {
69 KIconGroupRow::KIconGroupRow(QString
& name
, QWidget
* parent
) : QBoxLayout(QBoxLayout::LeftToRight
, parent
) {
74 KIconGroupRow::~KIconGroupRow() {
75 // Let's delete our icons
76 qDeleteAll(m_icons
.begin(), m_icons
.end());
80 const KIconGroupItem
* KIconGroupRow::appendIcon( const QIcon
& icon
, const QString
& label
) {
81 KIconGroupItem
* item
= new KIconGroupItem(parentWidget(),icon
,label
);
82 item
->setParent(parentWidget());
89 void KIconGroupRow::render() {
93 /*********** KIconGroupItem **************/
94 KIconGroupItem::KIconGroupItem(QWidget
* parent
,
96 const QString
& label
) : QLabel(parent
) {
99 m_text
= label
; // Lets keep our own copy...
104 void KIconGroupItem::render() {
107 // If there's no parent, we've got no style, can't draw an icon.
112 setPixmap(static_cast<const QPixmap
&>(m_icon
.pixmap(m_parent
->style()->pixelMetric(QStyle::PM_IconViewIconSize
))));
116 void KIconGroupItem::setParent(QWidget
* parent
) {
122 void KIconGroupItem::setIcon(const QIcon
& icon
) {
128 void KIconGroupItem::setLabel(const QString
& label
) {
134 #include "kicongrouppage.moc"