korganizer Library API Documentation

kodialogmanager.cpp

00001 /* 00002 This file is part of KOrganizer. 00003 00004 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00019 00020 As a special exception, permission is given to link this program 00021 with any edition of Qt, and distribute the resulting executable, 00022 without including the source code for Qt in the source distribution. 00023 */ 00024 00025 #include <kcmultidialog.h> 00026 #include <ksettings/dialog.h> 00027 00028 #include <libkdepim/categoryeditdialog.h> 00029 00030 #include "calendarview.h" 00031 #include "incomingdialog.h" 00032 #include "outgoingdialog.h" 00033 #include "koprefsdialog.h" 00034 #include "koprefs.h" 00035 #include "koeventeditor.h" 00036 #include "kotodoeditor.h" 00037 #include "kojournaleditor.h" 00038 #include "searchdialog.h" 00039 #include "filtereditdialog.h" 00040 #ifndef KORG_NOPLUGINS 00041 #include "plugindialog.h" 00042 #endif 00043 #ifndef KORG_NOARCHIVE 00044 #include "archivedialog.h" 00045 #endif 00046 #include "koviewmanager.h" 00047 #include "koagendaview.h" 00048 #include "koglobals.h" 00049 00050 #include "kodialogmanager.h" 00051 #include "kodialogmanager.moc" 00052 00053 00054 // TODO: Handle KOEventViewerDialogs in dialog manager. Pass 00055 // KOPrefs::mCompactDialog. 00056 00057 KODialogManager::KODialogManager( CalendarView *mainView ) : 00058 QObject(), mMainView( mainView ) 00059 { 00060 mOutgoingDialog = 0; 00061 mIncomingDialog = 0; 00062 mOptionsDialog = 0; 00063 mSearchDialog = 0; 00064 mArchiveDialog = 0; 00065 mFilterEditDialog = 0; 00066 mPluginDialog = 0; 00067 00068 mCategoryEditDialog = new KPIM::CategoryEditDialog( KOPrefs::instance(), mMainView ); 00069 connect( mainView, SIGNAL( categoriesChanged() ), 00070 mCategoryEditDialog, SLOT( reload() ) ); 00071 KOGlobals::fitDialogToScreen( mCategoryEditDialog ); 00072 } 00073 00074 KODialogManager::~KODialogManager() 00075 { 00076 delete mOutgoingDialog; 00077 delete mIncomingDialog; 00078 delete mOptionsDialog; 00079 delete mSearchDialog; 00080 #ifndef KORG_NOARCHIVE 00081 delete mArchiveDialog; 00082 #endif 00083 delete mFilterEditDialog; 00084 #ifndef KORG_NOPLUGINS 00085 delete mPluginDialog; 00086 #endif 00087 } 00088 00089 void KODialogManager::errorSaveEvent( QWidget *parent ) 00090 { 00091 KMessageBox::sorry( parent, i18n("Unable to save event.") ); 00092 } 00093 00094 void KODialogManager::errorSaveTodo( QWidget *parent ) 00095 { 00096 KMessageBox::sorry( parent, i18n("Unable to save todo item.") ); 00097 } 00098 00099 void KODialogManager::errorSaveJournal( QWidget *parent ) 00100 { 00101 KMessageBox::sorry( parent, i18n("Unable to save journal entry.") ); 00102 } 00103 00104 OutgoingDialog *KODialogManager::outgoingDialog() 00105 { 00106 createOutgoingDialog(); 00107 return mOutgoingDialog; 00108 } 00109 00110 void KODialogManager::createOutgoingDialog() 00111 { 00112 if (!mOutgoingDialog) { 00113 mOutgoingDialog = new OutgoingDialog(mMainView->calendar(),mMainView); 00114 if (mIncomingDialog) mIncomingDialog->setOutgoingDialog(mOutgoingDialog); 00115 connect(mOutgoingDialog,SIGNAL(numMessagesChanged(int)), 00116 mMainView,SIGNAL(numOutgoingChanged(int))); 00117 } 00118 } 00119 00120 void KODialogManager::showOptionsDialog() 00121 { 00122 if (!mOptionsDialog) { 00123 #if 0 00124 mOptionsDialog = new KConfigureDialog(); 00125 // mOptionsDialog = new KConfigureDialog( KConfigureDialog::Configurable ); 00126 // mOptionsDialog = new KConfigureDialog( mMainView ); 00127 connect( mOptionsDialog->dialog(), 00128 SIGNAL( configCommitted( const QCString & ) ), 00129 mMainView, SLOT( updateConfig() ) ); 00130 #else 00131 mOptionsDialog = new KCMultiDialog( mMainView, "KorganizerPreferences" ); 00132 connect( mOptionsDialog, SIGNAL( configCommitted( const QCString & ) ), 00133 mMainView, SLOT( updateConfig() ) ); 00134 #if 0 00135 connect( mOptionsDialog, SIGNAL( applyClicked() ), 00136 mMainView, SLOT( updateConfig() ) ); 00137 connect( mOptionsDialog, SIGNAL( okClicked() ), 00138 mMainView, SLOT( updateConfig() ) ); 00139 // TODO Find a way to do this with KCMultiDialog 00140 connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()), 00141 mOptionsDialog,SLOT(updateCategories())); 00142 #endif 00143 00144 QStringList modules; 00145 00146 modules.append( "korganizer_configmain.desktop" ); 00147 modules.append( "korganizer_configtime.desktop" ); 00148 modules.append( "korganizer_configviews.desktop" ); 00149 modules.append( "korganizer_configfonts.desktop" ); 00150 modules.append( "korganizer_configcolors.desktop" ); 00151 modules.append( "korganizer_configprinting.desktop" ); 00152 modules.append( "korganizer_configgroupscheduling.desktop" ); 00153 modules.append( "korganizer_configgroupautomation.desktop" ); 00154 modules.append( "korganizer_configfreebusy.desktop" ); 00155 00156 // add them all 00157 QStringList::iterator mit; 00158 for ( mit = modules.begin(); mit != modules.end(); ++mit ) 00159 mOptionsDialog->addModule( *mit ); 00160 #endif 00161 } 00162 00163 mOptionsDialog->show(); 00164 mOptionsDialog->raise(); 00165 } 00166 00167 void KODialogManager::showOutgoingDialog() 00168 { 00169 createOutgoingDialog(); 00170 mOutgoingDialog->show(); 00171 mOutgoingDialog->raise(); 00172 } 00173 00174 IncomingDialog *KODialogManager::incomingDialog() 00175 { 00176 createIncomingDialog(); 00177 return mIncomingDialog; 00178 } 00179 00180 void KODialogManager::createIncomingDialog() 00181 { 00182 createOutgoingDialog(); 00183 if (!mIncomingDialog) { 00184 mIncomingDialog = new IncomingDialog(mMainView->calendar(),mOutgoingDialog,mMainView); 00185 connect(mIncomingDialog,SIGNAL(numMessagesChanged(int)), 00186 mMainView,SIGNAL(numIncomingChanged(int))); 00187 connect(mIncomingDialog,SIGNAL(calendarUpdated()), 00188 mMainView,SLOT(updateView())); 00189 } 00190 } 00191 00192 void KODialogManager::showIncomingDialog() 00193 { 00194 createIncomingDialog(); 00195 mIncomingDialog->show(); 00196 mIncomingDialog->raise(); 00197 } 00198 00199 void KODialogManager::showCategoryEditDialog() 00200 { 00201 mCategoryEditDialog->show(); 00202 } 00203 00204 void KODialogManager::showSearchDialog() 00205 { 00206 if (!mSearchDialog) { 00207 mSearchDialog = new SearchDialog(mMainView->calendar(),mMainView); 00208 connect(mSearchDialog,SIGNAL(showIncidenceSignal(Incidence *)), 00209 mMainView,SLOT(showIncidence(Incidence *))); 00210 connect(mSearchDialog,SIGNAL(editIncidenceSignal(Incidence *)), 00211 mMainView,SLOT(editIncidence(Incidence *))); 00212 connect(mSearchDialog,SIGNAL(deleteIncidenceSignal(Incidence *)), 00213 mMainView, SLOT(deleteIncidence(Incidence *))); 00214 connect(mMainView,SIGNAL(closingDown()),mSearchDialog,SLOT(reject())); 00215 } 00216 // make sure the widget is on top again 00217 mSearchDialog->show(); 00218 mSearchDialog->raise(); 00219 } 00220 00221 void KODialogManager::showArchiveDialog() 00222 { 00223 #ifndef KORG_NOARCHIVE 00224 if (!mArchiveDialog) { 00225 mArchiveDialog = new ArchiveDialog(mMainView->calendar(),mMainView); 00226 connect(mArchiveDialog,SIGNAL(eventsDeleted()), 00227 mMainView,SLOT(updateView())); 00228 connect(mArchiveDialog,SIGNAL(autoArchivingSettingsModified()), 00229 mMainView,SLOT(slotAutoArchivingSettingsModified())); 00230 } 00231 mArchiveDialog->show(); 00232 mArchiveDialog->raise(); 00233 00234 // Workaround. 00235 QApplication::restoreOverrideCursor(); 00236 #endif 00237 } 00238 00239 void KODialogManager::showFilterEditDialog( QPtrList<CalFilter> *filters ) 00240 { 00241 if ( !mFilterEditDialog ) { 00242 mFilterEditDialog = new FilterEditDialog( filters, mMainView ); 00243 connect( mFilterEditDialog, SIGNAL( filterChanged() ), 00244 mMainView, SLOT( filterEdited() ) ); 00245 connect( mFilterEditDialog, SIGNAL( editCategories() ), 00246 mCategoryEditDialog, SLOT( show() ) ); 00247 connect( mCategoryEditDialog, SIGNAL( categoryConfigChanged() ), 00248 mFilterEditDialog, SLOT( updateCategoryConfig() ) ); 00249 } 00250 mFilterEditDialog->show(); 00251 mFilterEditDialog->raise(); 00252 } 00253 00254 void KODialogManager::showPluginDialog() 00255 { 00256 #ifndef KORG_NOPLUGINS 00257 if (!mPluginDialog) { 00258 mPluginDialog = new PluginDialog(mMainView); 00259 connect(mPluginDialog,SIGNAL(configChanged()), 00260 mMainView,SLOT(updateConfig())); 00261 } 00262 mPluginDialog->show(); 00263 mPluginDialog->raise(); 00264 #endif 00265 } 00266 00267 KOEventEditor *KODialogManager::getEventEditor() 00268 { 00269 KOEventEditor *eventEditor = new KOEventEditor( mMainView->calendar(), 00270 mMainView ); 00271 connectEditor( eventEditor ); 00272 return eventEditor; 00273 } 00274 00275 void KODialogManager::connectTypeAhead( KOEventEditor *editor, 00276 KOAgendaView *agenda ) 00277 { 00278 if ( editor && agenda ) { 00279 agenda->setTypeAheadReceiver( editor->typeAheadReceiver() ); 00280 connect( editor, SIGNAL( focusReceivedSignal() ), 00281 agenda, SLOT( finishTypeAhead() ) ); 00282 } 00283 } 00284 00285 void KODialogManager::connectEditor( KOIncidenceEditor*editor ) 00286 { 00287 connect( editor, SIGNAL( incidenceAdded( Incidence * ) ), 00288 mMainView, SLOT( incidenceAdded( Incidence * ) ) ); 00289 connect( editor, SIGNAL( incidenceChanged( Incidence *, Incidence * ) ), 00290 mMainView, SLOT( incidenceChanged( Incidence *, Incidence * ) ) ); 00291 connect( editor, SIGNAL( incidenceToBeDeleted( Incidence * ) ), 00292 mMainView, SLOT( incidenceToBeDeleted( Incidence * ) ) ); 00293 connect( editor, SIGNAL( incidenceDeleted( Incidence * ) ), 00294 mMainView, SLOT( incidenceDeleted( Incidence * ) ) ); 00295 00296 connect( mCategoryEditDialog, SIGNAL( categoryConfigChanged() ), 00297 editor, SLOT( updateCategoryConfig() ) ); 00298 connect( editor, SIGNAL( editCategories() ), 00299 mCategoryEditDialog, SLOT( show() ) ); 00300 00301 connect( editor, SIGNAL( dialogClose( Incidence * ) ), 00302 mMainView, SLOT( dialogClosing( Incidence * ) ) ); 00303 connect( editor, SIGNAL( editCanceled( Incidence * ) ), 00304 mMainView, SLOT( editCanceled( Incidence * ) ) ); 00305 connect( mMainView, SIGNAL( closingDown() ), editor, SLOT( reject() ) ); 00306 00307 connect( editor, SIGNAL( deleteAttendee( Incidence * ) ), 00308 mMainView, SLOT( schedule_cancel( Incidence * ) ) ); 00309 } 00310 00311 KOTodoEditor *KODialogManager::getTodoEditor() 00312 { 00313 KOTodoEditor *todoEditor = new KOTodoEditor( mMainView->calendar(), mMainView ); 00314 connectEditor( todoEditor ); 00315 connect( todoEditor, SIGNAL( todoCompleted( Todo * ) ), 00316 mMainView, SLOT( recurTodo( Todo *) ) ) ; 00317 return todoEditor; 00318 } 00319 00320 KOJournalEditor *KODialogManager::getJournalEditor() 00321 { 00322 KOJournalEditor *journalEditor = new KOJournalEditor( mMainView->calendar(), mMainView ); 00323 connectEditor( journalEditor ); 00324 return journalEditor; 00325 } 00326 00327 void KODialogManager::updateSearchDialog() 00328 { 00329 if (mSearchDialog) mSearchDialog->updateView(); 00330 } 00331 00332 void KODialogManager::setDocumentId( const QString &id ) 00333 { 00334 if (mOutgoingDialog) mOutgoingDialog->setDocumentId( id ); 00335 }
KDE Logo
This file is part of the documentation for korganizer Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 27 12:53:22 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003