korganizer Library API Documentation

kodialogmanager.cpp

00001 /*
00002   This file is part of KOrganizer.
00003 
00004   Copyright (c) 2001
00005   Cornelius Schumacher <schumacher@kde.org>
00006 
00007   This program is free software; you can redistribute it and/or modify
00008   it under the terms of the GNU General Public License as published by
00009   the Free Software Foundation; either version 2 of the License, or
00010   (at your option) any later version.
00011 
00012   This program is distributed in the hope that it will be useful,
00013   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015   GNU General Public License for more details.
00016 
00017   You should have received a copy of the GNU General Public License
00018   along with this program; if not, write to the Free Software
00019   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020 */
00021 
00022 #include <libkdepim/categoryeditdialog.h>
00023 
00024 #include "calendarview.h"
00025 #include "incomingdialog.h"
00026 #include "outgoingdialog.h"
00027 #include "koprefsdialog.h"
00028 #include "koeventeditor.h"
00029 #include "koprefs.h"
00030 #include "kotodoeditor.h"
00031 #include "searchdialog.h"
00032 #include "filtereditdialog.h"
00033 #ifndef KORG_NOPLUGINS
00034 #include "plugindialog.h"
00035 #endif
00036 #ifndef KORG_NOARCHIVE
00037 #include "archivedialog.h"
00038 #endif
00039 
00040 #include "kodialogmanager.h"
00041 #include "kodialogmanager.moc"
00042 
00043 KODialogManager::KODialogManager( CalendarView *mainView ) :
00044   QObject(), mMainView( mainView )
00045 {
00046   mOutgoingDialog = 0;
00047   mIncomingDialog = 0;
00048   mOptionsDialog = 0;
00049   mSearchDialog = 0;
00050   mArchiveDialog = 0;
00051   mFilterEditDialog = 0;
00052   mPluginDialog = 0;
00053 
00054   mCategoryEditDialog = new KPIM::CategoryEditDialog(KOPrefs::instance(),mMainView);
00055 }
00056 
00057 KODialogManager::~KODialogManager()
00058 {
00059   delete mOutgoingDialog;
00060   delete mIncomingDialog;
00061   delete mOptionsDialog;
00062   delete mSearchDialog;
00063   delete mArchiveDialog;
00064   delete mFilterEditDialog;
00065   delete mPluginDialog;
00066 }
00067 
00068 OutgoingDialog *KODialogManager::outgoingDialog()
00069 {
00070   createOutgoingDialog();
00071   return mOutgoingDialog;
00072 }
00073 
00074 void KODialogManager::createOutgoingDialog()
00075 {
00076   if (!mOutgoingDialog) {
00077     mOutgoingDialog = new OutgoingDialog(mMainView->calendar(),mMainView);
00078     if (mIncomingDialog) mIncomingDialog->setOutgoingDialog(mOutgoingDialog);
00079     connect(mOutgoingDialog,SIGNAL(numMessagesChanged(int)),
00080             mMainView,SIGNAL(numOutgoingChanged(int)));
00081   }
00082 }
00083 
00084 void KODialogManager::showOptionsDialog()
00085 {
00086   if (!mOptionsDialog) {
00087     mOptionsDialog = new KOPrefsDialog(mMainView);
00088     mOptionsDialog->readConfig();
00089     connect(mOptionsDialog,SIGNAL(configChanged()),
00090             mMainView,SLOT(updateConfig()));
00091     connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()),
00092             mOptionsDialog,SLOT(updateCategories()));
00093   }
00094 
00095   mOptionsDialog->readConfig();
00096   mOptionsDialog->show();
00097 }
00098 
00099 void KODialogManager::showOutgoingDialog()
00100 {
00101   createOutgoingDialog();
00102   mOutgoingDialog->show();
00103   mOutgoingDialog->raise();
00104 }
00105 
00106 IncomingDialog *KODialogManager::incomingDialog()
00107 {
00108   createOutgoingDialog();
00109   if (!mIncomingDialog) {
00110     mIncomingDialog = new IncomingDialog(mMainView->calendar(),mOutgoingDialog,mMainView);
00111     connect(mIncomingDialog,SIGNAL(numMessagesChanged(int)),
00112             mMainView,SIGNAL(numIncomingChanged(int)));
00113     connect(mIncomingDialog,SIGNAL(calendarUpdated()),
00114             mMainView,SLOT(updateView()));
00115   }
00116   return mIncomingDialog;
00117 }
00118 
00119 void KODialogManager::createIncomingDialog()
00120 {
00121   createOutgoingDialog();
00122   if (!mIncomingDialog) {
00123     mIncomingDialog = new IncomingDialog(mMainView->calendar(),mOutgoingDialog,mMainView);
00124     connect(mIncomingDialog,SIGNAL(numMessagesChanged(int)),
00125             mMainView,SIGNAL(numIncomingChanged(int)));
00126     connect(mIncomingDialog,SIGNAL(calendarUpdated()),
00127             mMainView,SLOT(updateView()));
00128   }
00129 }
00130 
00131 void KODialogManager::showIncomingDialog()
00132 {
00133   createIncomingDialog();
00134   mIncomingDialog->show();
00135   mIncomingDialog->raise();
00136 }
00137 
00138 void KODialogManager::showCategoryEditDialog()
00139 {
00140   mCategoryEditDialog->show();
00141 }
00142 
00143 void KODialogManager::showSearchDialog()
00144 {
00145   if (!mSearchDialog) {
00146     mSearchDialog = new SearchDialog(mMainView->calendar(),mMainView);
00147     connect(mSearchDialog,SIGNAL(showEventSignal(Event *)),
00148             mMainView,SLOT(showEvent(Event *)));
00149     connect(mSearchDialog,SIGNAL(editEventSignal(Event *)),
00150             mMainView,SLOT(editEvent(Event *)));
00151     connect(mSearchDialog,SIGNAL(deleteEventSignal(Event *)),
00152             mMainView, SLOT(deleteEvent(Event *)));
00153     connect(mMainView,SIGNAL(closingDown()),mSearchDialog,SLOT(reject()));
00154   }
00155   // make sure the widget is on top again
00156   mSearchDialog->show();
00157   mSearchDialog->raise();
00158 }
00159 
00160 void KODialogManager::showArchiveDialog()
00161 {
00162 #ifndef KORG_NOARCHIVE
00163   if (!mArchiveDialog) {
00164     mArchiveDialog = new ArchiveDialog(mMainView->calendar(),mMainView);
00165     connect(mArchiveDialog,SIGNAL(eventsDeleted()),
00166             mMainView,SLOT(updateView()));
00167   }
00168   mArchiveDialog->show();
00169   mArchiveDialog->raise();
00170 
00171   // Workaround.
00172   QApplication::restoreOverrideCursor();
00173 #endif
00174 }
00175 
00176 void KODialogManager::showFilterEditDialog(QPtrList<CalFilter> *filters)
00177 {
00178   if (!mFilterEditDialog) {
00179     mFilterEditDialog = new FilterEditDialog(filters,mMainView);
00180     connect(mFilterEditDialog,SIGNAL(filterChanged()),
00181             mMainView,SLOT(filterEdited()));
00182   }
00183   mFilterEditDialog->show();
00184   mFilterEditDialog->raise();
00185 }
00186 
00187 void KODialogManager::showPluginDialog()
00188 {
00189 #ifndef KORG_NOPLUGINS
00190   if (!mPluginDialog) {
00191     mPluginDialog = new PluginDialog(mMainView);
00192     connect(mPluginDialog,SIGNAL(configChanged()),
00193             mMainView,SLOT(updateConfig()));
00194   }
00195   mPluginDialog->show();
00196   mPluginDialog->raise();
00197 #endif
00198 }
00199 
00200 KOEventEditor *KODialogManager::getEventEditor()
00201 {
00202   KOEventEditor *eventEditor = new KOEventEditor( mMainView->calendar(),
00203                                                   mMainView );
00204 
00205   connect(eventEditor,SIGNAL(eventAdded(Event *)),
00206           mMainView,SLOT(eventAdded(Event *)));
00207   connect(eventEditor,SIGNAL(eventChanged(Event *)),
00208           mMainView,SLOT(eventChanged(Event *)));
00209   connect(eventEditor,SIGNAL(eventDeleted()),
00210           mMainView,SLOT(eventDeleted()));
00211   connect(eventEditor,SIGNAL(deleteAttendee(Incidence *)),
00212           mMainView,SLOT(schedule_cancel(Incidence *)));
00213 
00214   connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()),
00215           eventEditor,SLOT(updateCategoryConfig()));
00216   connect(eventEditor,SIGNAL(editCategories()),
00217           mCategoryEditDialog,SLOT(show()));
00218   connect(eventEditor,SIGNAL(dialogClose(Incidence*)),
00219           mMainView,SLOT(dialogClosing(Incidence*)));
00220 
00221   connect(mMainView,SIGNAL(closingDown()),eventEditor,SLOT(reject()));
00222 
00223   return eventEditor;
00224 }
00225 
00226 KOTodoEditor *KODialogManager::getTodoEditor()
00227 {
00228   KOTodoEditor *todoEditor = new KOTodoEditor( mMainView->calendar(),
00229                                                mMainView );
00230 
00231   connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()),
00232           todoEditor,SLOT(updateCategoryConfig()));
00233   connect(todoEditor,SIGNAL(editCategories()),mCategoryEditDialog,SLOT(show()));
00234 
00235   connect(todoEditor,SIGNAL(todoAdded(Todo *)),
00236           mMainView,SLOT(updateTodoViews()));
00237   connect(todoEditor,SIGNAL(todoChanged(Todo *)),
00238           mMainView,SLOT(updateTodoViews()));
00239   connect(todoEditor,SIGNAL(todoDeleted()),
00240           mMainView,SLOT(updateTodoViews()));
00241   connect(todoEditor,SIGNAL(dialogClose(Incidence*)),
00242           mMainView,SLOT(dialogClosing(Incidence*)));
00243 
00244   connect(mMainView,SIGNAL(closingDown()),todoEditor,SLOT(reject()));
00245 
00246   return todoEditor;
00247 }
00248 
00249 void KODialogManager::updateSearchDialog()
00250 {
00251   if (mSearchDialog) mSearchDialog->updateView();
00252 }
00253 
00254 void KODialogManager::setDocumentId( const QString &id )
00255 {
00256   if (mOutgoingDialog) mOutgoingDialog->setDocumentId( id );
00257 }
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 15 11:41:09 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001