Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / apps / kinfocenter / indexwidget.cpp
blob8da02f0ec53619665d303881ce3fba9b6655905c
1 /*
2 Copyright (c) 2000 Matthias Elter <elter@kde.org>
3 Copyright (c) 2003 Frauke Oster <frauke.oster@t-online.de>
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 program 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
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include "indexwidget.h"
21 #include "moduletreeview.h"
22 #include "moduleiconview.h"
24 #include <Qt3Support/Q3CheckListItem>
26 #include "indexwidget.moc"
28 IndexWidget::IndexWidget(ConfigModuleList *modules, QWidget *parent ,const char *)
29 : QStackedWidget(parent)
30 , _tree(0L)
31 , _icon(0L)
32 , _modules(modules)
33 , viewMode(Icon)
35 activateView(Icon);
38 IndexWidget::~IndexWidget() {}
40 void IndexWidget::reload()
42 if (_icon)
43 _icon->fill();
46 Q3ListViewItem *IndexWidget::firstTreeViewItem()
48 if (_tree)
49 return _tree->firstChild();
50 else
51 return 0L;
54 void IndexWidget::moduleSelected(ConfigModule *m)
56 const QObject *obj = sender();
57 if(!m) return;
59 emit moduleActivated(m);
61 if (obj->inherits("ModuleIconView") && _tree)
63 _tree->makeVisible(m);
65 _tree->disconnect(SIGNAL(moduleSelected(ConfigModule*)));
66 _tree->makeSelected(m);
67 connect(_tree, SIGNAL(moduleSelected(ConfigModule*)),
68 this, SLOT(moduleSelected(ConfigModule*)));
70 else if (obj->inherits("ModuleTreeView") && _icon)
72 _icon->makeVisible(m);
74 _icon->disconnect(SIGNAL(moduleSelected(ConfigModule*)));
75 _icon->makeSelected(m);
76 connect(_icon, SIGNAL(moduleSelected(ConfigModule*)),
77 this, SLOT(moduleSelected(ConfigModule*)));
81 void IndexWidget::makeSelected(ConfigModule *module)
83 if (_icon)
85 _icon->disconnect(SIGNAL(moduleSelected(ConfigModule*)));
86 _icon->makeSelected(module);
87 connect(_icon, SIGNAL(moduleSelected(ConfigModule*)),
88 this, SLOT(moduleSelected(ConfigModule*)));
90 if (_tree)
92 _tree->disconnect(SIGNAL(moduleSelected(ConfigModule*)));
93 _tree->makeSelected(module);
94 connect(_tree, SIGNAL(moduleSelected(ConfigModule*)),
95 this, SLOT(moduleSelected(ConfigModule*)));
99 void IndexWidget::makeVisible(ConfigModule *module)
101 if (_icon)
102 _icon->makeVisible(module);
103 if (_tree)
104 _tree->makeVisible(module);
107 void IndexWidget::activateView(IndexViewMode mode)
109 viewMode = mode;
111 if (mode == Icon)
113 if (!_icon)
115 _icon=new ModuleIconView(_modules, this);
116 addWidget (_icon);
117 _icon->fill();
118 connect(_icon, SIGNAL(moduleSelected(ConfigModule*)),
119 this, SLOT(moduleSelected(ConfigModule*)));
121 setCurrentWidget( _icon );
123 else
125 if (!_tree)
127 _tree=new ModuleTreeView(_modules, this);
128 addWidget (_tree);
129 _tree->fill();
130 connect(_tree, SIGNAL(moduleSelected(ConfigModule*)),
131 this, SLOT(moduleSelected(ConfigModule*)));
132 connect(_tree, SIGNAL(categorySelected(Q3ListViewItem*)),
133 this, SIGNAL(categorySelected(Q3ListViewItem*)));
135 setCurrentWidget( _tree );