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.
24 #include "moduleiconitem.h"
26 #include <QListWidget>
31 * Overloaded to give a larger default size that fits with text of two lines.
33 class RowIconView
: public QListWidget
37 RowIconView( QWidget
* parent
) : QListWidget( parent
)
39 setResizeMode(Adjust
);
40 setViewMode(IconMode
);
42 setFrameShape(NoFrame
);
44 setItemDelegate(new ModuleIconItemDelegate(this));
47 // Figure out the hight/width to have only one row
48 QSize
minimumSizeHint() const {
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;
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;
68 int h = fontMetrics().height();
71 int f = 2 * frameWidth();
72 int height = ( 2*h ) + f + spacing() * 2 + 32 + lineWidth()*2 + 10;
74 return QSize( width
, height
);
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
;
92 void clearSelection();
96 void itemSelected( QListWidgetItem
* item
);
99 ModulesView( KCModuleMenu
*rootMenu
, const QString
&menuPath
, QWidget
*parent
=0 );
103 QList
<RowIconView
*> groups
;
104 KCModuleMenu
*rootMenu
;
106 KService::List categories
;
108 void createRow( const QString
&parentPath
, QBoxLayout
*layout
);
111 #endif // MODULESVIEW_H