summaryrefslogtreecommitdiffabout
path: root/korganizer/kodialogmanager.cpp
Unidiff
Diffstat (limited to 'korganizer/kodialogmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kodialogmanager.cpp343
1 files changed, 343 insertions, 0 deletions
diff --git a/korganizer/kodialogmanager.cpp b/korganizer/kodialogmanager.cpp
new file mode 100644
index 0000000..caf7599
--- a/dev/null
+++ b/korganizer/kodialogmanager.cpp
@@ -0,0 +1,343 @@
1/*
2 This file is part of KOrganizer.
3
4 Copyright (c) 2001
5 Cornelius Schumacher <schumacher@kde.org>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20*/
21
22#include <libkdepim/categoryeditdialog.h>
23
24#include "calendarview.h"
25#include "incomingdialog.h"
26#include "outgoingdialog.h"
27#include "koprefsdialog.h"
28#include "koeventeditor.h"
29#include "koprefs.h"
30#include "datenavigator.h"
31#include "kotodoeditor.h"
32#include "searchdialog.h"
33#include "filtereditdialog.h"
34#ifndef KORG_NOPLUGINS
35#include "plugindialog.h"
36#endif
37#ifndef KORG_NOARCHIVE
38#include "archivedialog.h"
39#endif
40
41#include "kconfig.h"
42#include "kodialogmanager.h"
43#include "kodialogmanager.moc"
44
45KODialogManager::KODialogManager( CalendarView *mainView ) :
46 QObject(), mMainView( mainView )
47{
48 mOutgoingDialog = 0;
49 mIncomingDialog = 0;
50 mOptionsDialog = 0;
51 mSearchDialog = 0;
52 mArchiveDialog = 0;
53 mFilterEditDialog = 0;
54 mPluginDialog = 0;
55
56 // mCategoryEditDialog = new KPIM::CategoryEditDialog(KOPrefs::instance(),mMainView);
57 //KOGlobals::fitDialogToScreen( mCategoryEditDialog );
58}
59
60KODialogManager::~KODialogManager()
61{
62 delete mOutgoingDialog;
63 delete mIncomingDialog;
64 delete mOptionsDialog;
65 delete mSearchDialog;
66#ifndef KORG_NOARCHIVE
67 delete mArchiveDialog;
68#endif
69 delete mFilterEditDialog;
70#ifndef KORG_NOPLUGINS
71 delete mPluginDialog;
72#endif
73}
74
75OutgoingDialog *KODialogManager::outgoingDialog()
76{
77 createOutgoingDialog();
78 return mOutgoingDialog;
79}
80
81void KODialogManager::createOutgoingDialog()
82{
83 if (!mOutgoingDialog) {
84 mOutgoingDialog = new OutgoingDialog(mMainView->calendar(),mMainView);
85 if (mIncomingDialog) mIncomingDialog->setOutgoingDialog(mOutgoingDialog);
86 connect(mOutgoingDialog,SIGNAL(numMessagesChanged(int)),
87 mMainView,SIGNAL(numOutgoingChanged(int)));
88 }
89}
90
91void KODialogManager::showOptionsDialog( bool showSync )
92{
93 int curLanguage = KOPrefs::instance()->mPreferredLanguage;
94 if (!mOptionsDialog) {
95 mOptionsDialog = new KOPrefsDialog(mMainView);
96 //mOptionsDialog->readConfig();
97 connect(mOptionsDialog,SIGNAL(configChanged()),
98 mMainView,SLOT(updateConfig()));
99 //connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()),
100 // mOptionsDialog,SLOT(updateCategories()));
101
102 }
103 mOptionsDialog->readConfig();
104#ifndef DESKTOP_VERSION
105 mOptionsDialog->showMaximized();
106#else
107 mOptionsDialog->show();
108#endif
109 if ( showSync )
110 mOptionsDialog->showSyncPage();
111 mOptionsDialog->exec();
112 if ( curLanguage != KOPrefs::instance()->mPreferredLanguage )
113 KOPrefs::instance()->mLanguageChanged = true;
114}
115void KODialogManager::showSyncOptions()
116{
117 showOptionsDialog( true );
118
119}
120void KODialogManager::showOutgoingDialog()
121{
122 createOutgoingDialog();
123 mOutgoingDialog->show();
124 mOutgoingDialog->raise();
125}
126
127IncomingDialog *KODialogManager::incomingDialog()
128{
129 createOutgoingDialog();
130 if (!mIncomingDialog) {
131 mIncomingDialog = new IncomingDialog(mMainView->calendar(),mOutgoingDialog,mMainView);
132 connect(mIncomingDialog,SIGNAL(numMessagesChanged(int)),
133 mMainView,SIGNAL(numIncomingChanged(int)));
134 connect(mIncomingDialog,SIGNAL(calendarUpdated()),
135 mMainView,SLOT(updateView()));
136 }
137 return mIncomingDialog;
138}
139
140void KODialogManager::createIncomingDialog()
141{
142 createOutgoingDialog();
143 if (!mIncomingDialog) {
144 mIncomingDialog = new IncomingDialog(mMainView->calendar(),mOutgoingDialog,mMainView);
145 connect(mIncomingDialog,SIGNAL(numMessagesChanged(int)),
146 mMainView,SIGNAL(numIncomingChanged(int)));
147 connect(mIncomingDialog,SIGNAL(calendarUpdated()),
148 mMainView,SLOT(updateView()));
149 }
150}
151
152void KODialogManager::showIncomingDialog()
153{
154 createIncomingDialog();
155 mIncomingDialog->show();
156 mIncomingDialog->raise();
157}
158/*
159void KODialogManager::showCategoryEditDialog()
160{
161 mCategoryEditDialog->show();
162}
163*/
164void KODialogManager::hideSearchDialog()
165{
166 if (mSearchDialog)
167 mSearchDialog->hide();
168}
169
170void KODialogManager::showSearchDialog()
171{
172 if (!mSearchDialog) {
173 mSearchDialog = new SearchDialog(mMainView->calendar(),mMainView);
174 KOListView * lview = mSearchDialog->listview();
175
176 connect(lview, SIGNAL(showIncidenceSignal(Incidence *)),
177 mMainView, SLOT(showIncidence(Incidence *)));
178 connect(lview, SIGNAL(editIncidenceSignal(Incidence *)),
179 mMainView, SLOT(editIncidence(Incidence *)));
180 connect(lview, SIGNAL(deleteIncidenceSignal(Incidence *)),
181 mMainView, SLOT(deleteIncidence(Incidence *)));
182 connect(lview, SIGNAL(cloneIncidenceSignal(Incidence *)),
183 mMainView, SLOT(cloneIncidence(Incidence *)));
184 connect(lview, SIGNAL(beamIncidenceSignal(Incidence *)),
185 mMainView, SLOT(beamIncidence(Incidence *)));
186 connect(lview, SIGNAL(moveIncidenceSignal(Incidence *)),
187 mMainView, SLOT(moveIncidence(Incidence *)));
188 connect(lview, SIGNAL(beamIncidenceList(QPtrList<Incidence> )),
189 mMainView, SLOT(beamIncidenceList(QPtrList<Incidence> )));
190
191 connect(mMainView, SIGNAL(configChanged()), mSearchDialog, SLOT(updateConfig()));
192 connect(mMainView, SIGNAL(updateSearchDialog()), mSearchDialog, SLOT(updateList()));
193 // connect( lview, SIGNAL( incidenceSelected( Incidence * ) ),
194 // mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
195#ifndef DESKTOP_VERSION
196 mSearchDialog->setMaximumSize( 640, 480 );
197 //mSearchDialog->setGeometry( 40,40, 400, 300);
198 mSearchDialog->showMaximized();
199#else
200 KConfig *config = KOGlobals::config();
201 config->setGroup("WidgetLayout");
202 QStringList list;
203 list = config->readListEntry("SearchLayout");
204 int x,y,w,h;
205 if ( ! list.isEmpty() ) {
206 x = list[0].toInt();
207 y = list[1].toInt();
208 w = list[2].toInt();
209 h = list[3].toInt();
210 mSearchDialog->setGeometry(x,y,w,h);
211
212 }
213
214#endif
215 }
216 // make sure the widget is on top again
217 mSearchDialog->show();
218 mSearchDialog->raise();
219}
220
221SearchDialog * KODialogManager::getSearchDialog()
222{
223 return mSearchDialog;
224}
225void KODialogManager::showArchiveDialog()
226{
227#ifndef KORG_NOARCHIVE
228 if (!mArchiveDialog) {
229 mArchiveDialog = new ArchiveDialog(mMainView->calendar(),mMainView);
230 connect(mArchiveDialog,SIGNAL(eventsDeleted()),
231 mMainView,SLOT(updateView()));
232 }
233 mArchiveDialog->show();
234 mArchiveDialog->raise();
235
236 // Workaround.
237 QApplication::restoreOverrideCursor();
238#endif
239}
240
241void KODialogManager::showFilterEditDialog(QPtrList<CalFilter> *filters)
242{
243 if (!mFilterEditDialog) {
244 mFilterEditDialog = new FilterEditDialog(filters,mMainView);
245 connect(mFilterEditDialog,SIGNAL(filterChanged()),
246 mMainView,SLOT(filterEdited()));
247
248 }
249
250#ifndef DESKTOP_VERSION
251 mFilterEditDialog->showMaximized();
252#else
253 mFilterEditDialog->show();
254#endif
255 mFilterEditDialog->raise();
256}
257
258void KODialogManager::showPluginDialog()
259{
260#ifndef KORG_NOPLUGINS
261 if (!mPluginDialog) {
262 mPluginDialog = new PluginDialog(mMainView);
263 connect(mPluginDialog,SIGNAL(configChanged()),
264 mMainView,SLOT(updateConfig()));
265 }
266 mPluginDialog->show();
267 mPluginDialog->raise();
268#endif
269}
270
271KOEventEditor *KODialogManager::getEventEditor()
272{
273 KOEventEditor *eventEditor = new KOEventEditor( mMainView->calendar(),
274 mMainView );
275
276 connect(eventEditor,SIGNAL(eventAdded(Event *)),
277 mMainView,SLOT(eventAdded(Event *)));
278 connect(eventEditor,SIGNAL(eventChanged(Event *)),
279 mMainView,SLOT(eventChanged(Event *)));
280 connect(eventEditor,SIGNAL(eventDeleted()),
281 mMainView,SLOT(eventDeleted()));
282 connect(eventEditor,SIGNAL(deleteAttendee(Incidence *)),
283 mMainView,SLOT(schedule_cancel(Incidence *)));
284 connect( eventEditor, SIGNAL(jumpToTime( const QDate &)),
285 mMainView->dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
286 connect( eventEditor, SIGNAL( showAgendaView( bool)),
287 mMainView->viewManager(), SLOT( showAgendaView( bool) ) );
288
289 // connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()),
290 // eventEditor,SLOT(updateCategoryConfig()));
291 // connect(eventEditor,SIGNAL(editCategories()),
292 // mCategoryEditDialog,SLOT(show()));
293 connect(eventEditor,SIGNAL(dialogClose(Incidence*)),
294 mMainView,SLOT(dialogClosing(Incidence*)));
295
296 //connect(mMainView,SIGNAL(closingDown()),eventEditor,SLOT(reject()));
297
298 return eventEditor;
299}
300
301KOTodoEditor *KODialogManager::getTodoEditor()
302{
303 KOTodoEditor *todoEditor = new KOTodoEditor( mMainView->calendar(),
304 mMainView );
305
306 // connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()),
307 // todoEditor,SLOT(updateCategoryConfig()));
308 // connect(todoEditor,SIGNAL(editCategories()),mCategoryEditDialog,SLOT(show()));
309
310 connect(todoEditor,SIGNAL(todoAdded(Todo *)),
311 mMainView,SLOT(todoAdded(Todo *)));
312 connect(todoEditor,SIGNAL(todoChanged(Todo *)),
313 mMainView,SLOT(todoChanged(Todo *)));
314 connect(todoEditor,SIGNAL(todoDeleted()),
315 mMainView,SLOT(todoDeleted()));
316 connect(todoEditor,SIGNAL(dialogClose(Incidence*)),
317 mMainView,SLOT(dialogClosing(Incidence*)));
318 connect( todoEditor, SIGNAL(jumpToTime( const QDate &)),
319 mMainView->dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
320 connect( todoEditor, SIGNAL( showAgendaView( bool)),
321 mMainView->viewManager(), SLOT( showAgendaView( bool) ) );
322 // connect(todoEditor,SIGNAL(deleteAttendee(Incidence *)),
323 // mMainView,SLOT(schedule_cancel(Incidence *)));
324 //connect(mMainView,SIGNAL(closingDown()),todoEditor,SLOT(reject()));
325
326 return todoEditor;
327}
328
329void KODialogManager::updateSearchDialog()
330{
331 if (mSearchDialog) mSearchDialog->updateView();
332}
333
334void KODialogManager::setDocumentId( const QString &id )
335{
336 if (mOutgoingDialog) mOutgoingDialog->setDocumentId( id );
337}
338
339void KODialogManager::writeSettings( KConfig *config )
340{
341 if (mSearchDialog)
342 mSearchDialog->listview()->writeSettings(config,"SearchListView Layout");
343}