not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / systemsettings / modulesview.h
blobd80645c3b37ae23dbe446847417c894198848e9b
1 /**
2 * This file is part of the System Preferences package
3 * Copyright (C) 2005 Benjamin C Meyer (ben+systempreferences at meyerhome dot net)
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
21 #ifndef MODULESVIEW_H
22 #define MODULESVIEW_H
24 #include "moduleiconitem.h"
26 #include <QListWidget>
27 #include <QList>
29 #include <KService>
30 /**
31 * Overloaded to give a larger default size that fits with text of two lines.
33 class RowIconView : public QListWidget
36 public:
37 RowIconView( QWidget* parent ) : QListWidget( parent )
39 setResizeMode(Adjust);
40 setViewMode(IconMode);
41 setMovement(Static);
42 setFrameShape(NoFrame);
43 setWordWrap(true);
46 // Figure out the hight/width to have only one row
47 QSize minimumSizeHint() const {
48 int width = 0;
50 for ( QIconViewItem *item = firstItem(); item; item = item->nextItem() )
51 width += item->width();
52 width += spacing()*(count())+(margin()+frameWidth()+lineWidth()+midLineWidth())*2 ;
55 //width = count()*gridX()+frameWidth()*2;
56 width = count()*gridSize().width()+frameWidth()*2;
58 int height =48;
59 //FIXME for ( Q3IconViewItem *item = firstItem(); item; item = item->nextItem() )
60 // if(item->height() > height)
61 // height = item->height();
62 // I honestly don't know where the 4+4 is coming from...
63 // What other spacing did I miss?
64 height += (/*margin()+*/frameWidth()+spacing()+lineWidth()+midLineWidth())*2+8;
66 /*
67 int h = fontMetrics().height();
68 if ( h < 10 )
69 h = 10;
70 int f = 2 * frameWidth();
71 int height = ( 2*h ) + f + spacing() * 2 + 32 + lineWidth()*2 + 10;
72 */
73 return QSize( width, height );
77 class QBoxLayout;
78 class KCModuleMenu;
80 /**
81 * This widget contains the IconView's of all of the modules etc
82 * It is the basic thing that users see.
84 class ModulesView : public QWidget
86 // To search the groups
87 friend class KcmSearch;
89 Q_OBJECT
90 public:
91 void clearSelection();
92 QString displayName;
94 signals:
95 void itemSelected( QListWidgetItem* item );
97 public:
98 ModulesView( KCModuleMenu *rootMenu, const QString &menuPath, QWidget *parent=0 );
99 ~ModulesView();
101 private:
102 QList<RowIconView*> groups;
103 KCModuleMenu *rootMenu;
104 QString menuPath;
105 KService::List categories;
107 void createRow( const QString &parentPath, QBoxLayout *layout );
110 #endif // MODULESVIEW_H