1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
/**
* This file is part of the System Settings package
* Copyright (C) 2005 Benjamin C Meyer (ben+systempreferences at meyerhome dot net)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "modulesview.h"
#include <tqlabel.h>
#include <klocale.h>
#include <kservicegroup.h>
#include <tqlayout.h>
#include <kiconloader.h>
#include <kcmultidialog.h>
#include <kdialogbase.h>
#include <kiconviewsearchline.h>
#include <kapplication.h>
#include <kaboutapplication.h>
#include <kdebug.h>
#include <tqiconview.h>
#include "kcmsearch.h"
#include "moduleiconitem.h"
#include "tdecmodulemenu.h"
ModulesView::ModulesView( TDECModuleMenu *rootMenu, const TQString &menuPath, TQWidget *parent,
const char *name ) : TQWidget( parent, name ), rootMenu( NULL )
{
this->rootMenu = rootMenu;
this->menuPath = menuPath;
TQVBoxLayout *layout = new TQVBoxLayout( this, 11, 6, "layout" );
displayName = this->rootMenu->caption;
TQValueList<MenuItem> subMenus = rootMenu->menuList(menuPath);
TQValueList<MenuItem>::iterator it;
for ( it = subMenus.begin(); it != subMenus.end(); ++it ){
if( !(*it).menu )
continue;
// After the first time around add a line
if( it != subMenus.begin() ){
TQFrame *line = new TQFrame( this, "line");
line->setFrameShadow( TQFrame::Sunken );
line->setFrameShape( TQFrame::HLine );
layout->addWidget( line );
}
// Build the row of modules/icons
createRow( (*it).subMenu, layout );
}
layout->addStretch(1);
// Make empty iconView for the search widget
if( groups.count()==0 ) {
RowIconView *iconView = new RowIconView( this, "groupiconview" );
iconView->setLineWidth( 0 );
groups.append( iconView );
}
setPaletteBackgroundColor( groups[0]->paletteBackgroundColor() );
// Align them up!
{
uint most = 0;
TQValueList<RowIconView*>::iterator it;
for ( it = groups.begin(); it != groups.end(); ++it ){
TQIconViewItem *item = (*it)->firstItem();
while( item ) {
if(item->width() > most)
most = item->width();
item = item->nextItem();
}
}
for ( it = groups.begin(); it != groups.end(); ++it )
(*it)->setGridX(most);
}
}
ModulesView::~ModulesView()
{
}
void ModulesView::createRow( const TQString &parentPath, TQBoxLayout *boxLayout )
{
KServiceGroup::Ptr group = KServiceGroup::group( parentPath );
if ( !group ){
kdDebug() << "Invalid Group \"" << parentPath << "\". Check your installation."<< endl;
return;
}
// Make header
TQHBoxLayout *rowLayout = new TQHBoxLayout( 0, 0, 6, "rowLayout" );
// Heaer Icon
TQLabel *icon = new TQLabel( this, "groupicon" );
icon->setPixmap( SmallIcon( group->icon() ) );
icon->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)1,
(TQSizePolicy::SizeType)5, 0, 0, icon->sizePolicy().hasHeightForWidth() ) );
rowLayout->addWidget( icon );
// Header Name
TQLabel *textLabel = new TQLabel( this, "groupcaption" );
textLabel->setText( group->caption() );
textLabel->setSizePolicy( TQSizePolicy( (TQSizePolicy::SizeType)7,
(TQSizePolicy::SizeType)5, 0, 0, textLabel->sizePolicy().hasHeightForWidth()));
TQFont textLabel_font( textLabel->font() );
textLabel_font.setBold( true );
textLabel->setFont( textLabel_font );
rowLayout->addWidget( textLabel );
boxLayout->addLayout( rowLayout );
// Make IconView
RowIconView *iconView = new RowIconView( this, "groupiconview" );
iconView->setFrameShape( RowIconView::StyledPanel );
iconView->setLineWidth( 0 );
iconView->setSpacing( 0 );
iconView->setMargin( 0 );
iconView->setItemsMovable( false );
iconView->setSelectionMode(TQIconView::NoSelection);
groups.append( iconView );
connect(iconView, TQT_SIGNAL( clicked( TQIconViewItem* ) ),
this, TQT_SIGNAL( itemSelected( TQIconViewItem* ) ) );
boxLayout->addWidget( iconView );
// Add all the items in their proper order
TQValueList<MenuItem> list = rootMenu->menuList( parentPath );
TQValueList<MenuItem>::iterator it;
for ( it = list.begin(); it != list.end(); ++it ){
if( !(*it).menu )
(void)new ModuleIconItem( iconView, (*it).item );
else
{
TQString path = (*it).subMenu;
KServiceGroup::Ptr group = KServiceGroup::group( path );
if ( group ) {
ModuleIconItem *item = new ModuleIconItem( ((TDEIconView*)iconView),
group->caption(), group->icon() );
item->modules = rootMenu->modules( path );
}
}
}
// Force the height for those items that have two words.
iconView->setMinimumHeight( iconView->minimumSizeHint().height() );
}
void ModulesView::clearSelection() {
TQValueList<RowIconView*>::iterator it;
for ( it = groups.begin(); it != groups.end(); ++it ) {
(*it)->clearSelection();
}
}
#include "modulesview.moc"
|