2 This file is part of Akonadi.
4 Copyright (c) 2006 Tobias Koenig <tokoe@kde.org>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22 #include "mainwidget.h"
24 #include "agentwidget.h"
25 #include "browserwidget.h"
26 #include "dbbrowser.h"
27 #include "dbconsole.h"
28 #include "debugwidget.h"
29 #include "rawsocketconsole.h"
30 #include "searchdialog.h"
31 #include "searchwidget.h"
32 #include "jobtrackerwidget.h"
33 #include "notificationmonitor.h"
35 #include <akonadi/agentinstancewidget.h>
36 #include <akonadi/agentfilterproxymodel.h>
37 #include <akonadi/control.h>
38 #include <akonadi/searchcreatejob.h>
39 #include <akonadi/servermanager.h>
42 #include <KActionCollection>
43 #include <KCMultiDialog>
44 #include <KXmlGuiWindow>
46 #include <QtGui/QTabWidget>
47 #include <QtGui/QVBoxLayout>
49 MainWidget::MainWidget( KXmlGuiWindow
*parent
)
52 QVBoxLayout
*layout
= new QVBoxLayout( this );
54 QTabWidget
*tabWidget
= new QTabWidget( this );
55 tabWidget
->setObjectName( "mainTab" );
56 layout
->addWidget( tabWidget
);
58 tabWidget
->addTab( new AgentWidget( tabWidget
), "Agents" );
59 BrowserWidget
*browser
= new BrowserWidget( parent
, tabWidget
);
60 tabWidget
->addTab( browser
, "Browser" );
61 tabWidget
->addTab( new DebugWidget( tabWidget
), "Debugger" );
62 tabWidget
->addTab( new RawSocketConsole( tabWidget
), "Raw Socket" );
63 tabWidget
->addTab( new DbBrowser( tabWidget
), "DB Browser" );
64 tabWidget
->addTab( new DbConsole( tabWidget
), "DB Console" );
65 tabWidget
->addTab( new JobTrackerWidget( "jobtracker", tabWidget
), "Job Tracker" );
66 tabWidget
->addTab( new JobTrackerWidget( "resourcesJobtracker", tabWidget
), "Resources Schedulers" );
67 tabWidget
->addTab( new NotificationMonitor( tabWidget
), "Notification Monitor" );
68 tabWidget
->addTab( new SearchWidget( tabWidget
), "Item Search" );
70 KAction
*action
= parent
->actionCollection()->addAction( "akonadiconsole_search" );
71 action
->setText( "Create Search..." );
72 connect( action
, SIGNAL( triggered() ), this, SLOT( createSearch() ) );
74 action
= parent
->actionCollection()->addAction( "akonadiconsole_akonadi2xml" );
75 action
->setText( "Dump to XML..." );
76 connect( action
, SIGNAL(triggered()), browser
, SLOT(dumpToXml()) );
78 action
= parent
->actionCollection()->addAction( "akonadiserver_start" );
79 action
->setText( "Start Server" );
80 connect( action
, SIGNAL(triggered()), SLOT(startServer()) );
82 action
= parent
->actionCollection()->addAction( "akonadiserver_stop" );
83 action
->setText( "Stop Server" );
84 connect( action
, SIGNAL(triggered()), SLOT(stopServer()) );
86 action
= parent
->actionCollection()->addAction( "akonadiserver_restart" );
87 action
->setText( "Restart Server" );
88 connect( action
, SIGNAL(triggered()), SLOT(restartServer()) );
90 action
= parent
->actionCollection()->addAction( "akonadiserver_configure" );
91 action
->setText( "Configure Server..." );
92 action
->setIcon( KIcon("configure") );
93 connect( action
, SIGNAL(triggered()), SLOT(configureServer()) );
96 void MainWidget::createSearch()
102 const QString query
= dlg
.searchQuery();
103 if ( query
.isEmpty() )
106 QString name
= dlg
.searchName();
107 if ( name
.isEmpty() )
110 new Akonadi::SearchCreateJob( name
, query
);
113 void MainWidget::startServer()
115 Akonadi::ServerManager::start();
118 void MainWidget::stopServer()
120 Akonadi::ServerManager::stop();
123 void MainWidget::restartServer()
125 Akonadi::Control::restart( this );
128 void MainWidget::configureServer()
131 dlg
.addModule( "kcm_akonadi_server" );
136 #include "mainwidget.moc"