Fix crash if key bindings specified in profile cannot be found. Improve
[personal-kdebase.git] / apps / kinfocenter / indexwidget.cpp
blobe8c6ee7b2bd0f8037ec563550f24c5d979327590
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"
22 #include <QWidget>
23 #include <QVBoxLayout>
24 #include <QHBoxLayout>
25 #include <QLabel>
27 #include "moduletreeview.h"
29 #include <kdebug.h>
30 #include <klocale.h>
32 #include "indexwidget.moc"
34 IndexWidget::IndexWidget(ConfigModuleList *modules, QWidget *parent) :
35 QWidget(parent) {
37 QVBoxLayout* mainLayout = new QVBoxLayout();
38 setLayout(mainLayout);
40 _tree=new ModuleTreeView(modules, this);
42 QHBoxLayout* searchLayout = new QHBoxLayout();
43 searchLayout->setMargin(0);
45 QLabel* searchLabel = new QLabel(i18n("Filter:"), this);
46 _searchLine = new ModuleWidgetSearchLine(this, _tree);
47 searchLabel->setBuddy(_searchLine);
49 searchLayout->addWidget(searchLabel);
50 searchLayout->addWidget(_searchLine);
52 _tree->fill();
53 connectTree();
55 mainLayout->addLayout(searchLayout);
56 mainLayout->addWidget(_tree);
58 kDebug() << "Index Widget initialized" << endl;
61 IndexWidget::~IndexWidget() {
64 void IndexWidget::reload() {
67 void IndexWidget::selectModule(ConfigModule *module) {
68 kDebug() << "Selecting module..." << endl;
70 ModuleTreeItem* moduleTreeItem = _tree->findMatchingItem(module);
72 disconnectTree();
74 _tree->scrollToItem(moduleTreeItem);
75 moduleTreeItem->setSelected(true);
77 connectTree();
79 emit moduleActivated(module);
82 void IndexWidget::selectGeneral() {
83 _tree->scrollToItem(_tree->generalItem());
85 disconnectTree();
87 _tree->generalItem()->setSelected(true);
89 connectTree();
91 emit generalActivated();
94 void IndexWidget::connectTree() {
95 connect(_tree, SIGNAL(moduleSelected(ConfigModule*)), this, SLOT(selectModule(ConfigModule*)));
96 connect(_tree, SIGNAL(generalSelected()), this, SLOT(selectGeneral()));
99 void IndexWidget::disconnectTree() {
100 _tree->disconnect(SIGNAL(generalSelected()));
101 _tree->disconnect(SIGNAL(moduleSelected(ConfigModule*)));