Add (and install) svg for the new krunner interface.
[kdebase/uwolfer.git] / workspace / systemsettings / modulesview.h
blob756a61a2bfd36f6cdcafd2ae0bb5ba963a31cb52
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);
44 setItemDelegate(new ModuleIconItemDelegate(this));
47 // Figure out the hight/width to have only one row
48 QSize minimumSizeHint() const {
49 int width = 0;
51 for ( QIconViewItem *item = firstItem(); item; item = item->nextItem() )
52 width += item->width();
53 width += spacing()*(count())+(margin()+frameWidth()+lineWidth()+midLineWidth())*2 ;
56 //width = count()*gridX()+frameWidth()*2;
57 width = count()*gridSize().width()+frameWidth()*2;
59 int height =48;
60 //FIXME for ( Q3IconViewItem *item = firstItem(); item; item = item->nextItem() )
61 // if(item->height() > height)
62 // height = item->height();
63 // I honestly don't know where the 4+4 is coming from...
64 // What other spacing did I miss?
65 height += (/*margin()+*/frameWidth()+spacing()+lineWidth()+midLineWidth())*2+8;
67 /*
68 int h = fontMetrics().height();
69 if ( h < 10 )
70 h = 10;
71 int f = 2 * frameWidth();
72 int height = ( 2*h ) + f + spacing() * 2 + 32 + lineWidth()*2 + 10;
73 */
74 return QSize( width, height );
78 class QBoxLayout;
79 class KCModuleMenu;
81 /**
82 * This widget contains the IconView's of all of the modules etc
83 * It is the basic thing that users see.
85 class ModulesView : public QWidget
87 // To search the groups
88 friend class KcmSearch;
90 Q_OBJECT
91 public:
92 void clearSelection();
93 QString displayName;
95 signals:
96 void itemSelected( QListWidgetItem* item );
98 public:
99 ModulesView( KCModuleMenu *rootMenu, const QString &menuPath, QWidget *parent=0 );
100 ~ModulesView();
102 private:
103 QList<RowIconView*> groups;
104 KCModuleMenu *rootMenu;
105 QString menuPath;
106 KService::List categories;
108 void createRow( const QString &parentPath, QBoxLayout *layout );
111 #endif // MODULESVIEW_H