00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifdef KEXI_NO_PROCESS_EVENTS
00022 # define KEXI_NO_PENDING_DIALOGS
00023 #endif
00024
00026 typedef QMap< int, QGuardedPtr<KexiDialogBase> > KexiDialogDict;
00027
00029 class KexiMainWindowImpl::Private
00030 {
00031 public:
00032 Private(KexiMainWindowImpl* w)
00033
00034 : wnd(w)
00035 , m_openedCustomObjectsForItem(1019, true)
00036 {
00037 propEditor=0;
00038 propEditorToolWindow=0;
00039 propEditorTabWidget=0;
00040 userMode = false;
00041 nav=0;
00042 navToolWindow=0;
00043 prj = 0;
00044 curDialogGUIClient=0;
00045 curDialogViewGUIClient=0;
00046 closedDialogGUIClient=0;
00047 closedDialogViewGUIClient=0;
00048 nameDialog=0;
00049 curDialog=0;
00050 block_KMdiMainFrm_eventFilter=false;
00051 focus_before_popup=0;
00052
00053 privateIDCounter=0;
00054 action_view_nav=0;
00055 action_view_propeditor=0;
00056 action_view_mainarea=0;
00057 action_open_recent_projects_title_id = -1;
00058 action_open_recent_connections_title_id = -1;
00059 forceDialogClosing=false;
00060 insideCloseDialog=false;
00061 #ifndef KEXI_NO_PENDING_DIALOGS
00062 actionToExecuteWhenPendingJobsAreFinished = NoAction;
00063 #endif
00064
00065 createMenu=0;
00066 showImportantInfoOnStartup=true;
00067
00068
00069 propEditorDockSeparatorPos=-1;
00070 navDockSeparatorPos=-1;
00071
00072 wasAutoOpen = false;
00073 dialogExistedBeforeCloseProject = false;
00074 #ifndef KEXI_SHOW_UNIMPLEMENTED
00075 dummy_action = new KActionMenu("", wnd);
00076 #endif
00077 maximizeFirstOpenedChildFrm = false;
00078 #ifdef HAVE_KNEWSTUFF
00079 newStuff = 0;
00080 #endif
00081 mdiModeToSwitchAfterRestart = (KMdi::MdiMode)0;
00082 forceShowProjectNavigatorOnCreation = false;
00083 forceHideProjectNavigatorOnCreation = false;
00084 navWasVisibleBeforeProjectClosing = false;
00085 saveSettingsForShowProjectNavigator = true;
00086 m_openedCustomObjectsForItem.setAutoDelete(true);
00087 }
00088 ~Private() {
00089 }
00090
00091 #ifndef KEXI_NO_PENDING_DIALOGS
00092
00093 enum PendingJobType {
00094 NoJob = 0,
00095 DialogOpeningJob,
00096 DialogClosingJob
00097 };
00098
00099 KexiDialogBase *openedDialogFor( const KexiPart::Item* item, PendingJobType &pendingType )
00100 {
00101 return openedDialogFor( item->identifier(), pendingType );
00102 }
00103
00104 KexiDialogBase *openedDialogFor( int identifier, PendingJobType &pendingType )
00105 {
00106
00107 QMap<int, PendingJobType>::ConstIterator it = pendingDialogs.find( identifier );
00108 if (it==pendingDialogs.constEnd())
00109 pendingType = NoJob;
00110 else
00111 pendingType = it.data();
00112
00113 if (pendingType == DialogOpeningJob) {
00114 return 0;
00115 }
00116 return (KexiDialogBase*)dialogs[ identifier ];
00117 }
00118 #else
00119 KexiDialogBase *openedDialogFor( const KexiPart::Item* item )
00120 {
00121 return openedDialogFor( item->identifier() );
00122 }
00123
00124 KexiDialogBase *openedDialogFor( int identifier )
00125 {
00126
00127 return (KexiDialogBase*)dialogs[ identifier ];
00128 }
00129 #endif
00130
00131 void insertDialog(KexiDialogBase *dlg) {
00132
00133 dialogs.insert(dlg->id(), QGuardedPtr<KexiDialogBase>(dlg));
00134 #ifndef KEXI_NO_PENDING_DIALOGS
00135 pendingDialogs.remove(dlg->id());
00136 #endif
00137 }
00138
00139 #ifndef KEXI_NO_PENDING_DIALOGS
00140 void addItemToPendingDialogs(const KexiPart::Item* item, PendingJobType jobType) {
00141
00142 pendingDialogs.replace( item->identifier(), jobType );
00143 }
00144
00145 bool pendingDialogsExist() {
00146 if (pendingDialogs.constBegin()!=pendingDialogs.constEnd())
00147 kdDebug() << pendingDialogs.constBegin().key() << " " << (int)pendingDialogs.constBegin().data() << endl;
00148
00149 return !pendingDialogs.isEmpty();
00150 }
00151 #endif
00152
00153 void updateDialogId(KexiDialogBase *dlg, int oldItemID) {
00154
00155 dialogs.remove(oldItemID);
00156 #ifndef KEXI_NO_PENDING_DIALOGS
00157 pendingDialogs.remove(oldItemID);
00158 #endif
00159 dialogs.insert(dlg->id(), QGuardedPtr<KexiDialogBase>(dlg));
00160 }
00161
00162 void removeDialog(int identifier) {
00163
00164 dialogs.remove(identifier);
00165 }
00166
00167 #ifndef KEXI_NO_PENDING_DIALOGS
00168 void removePendingDialog(int identifier) {
00169
00170 pendingDialogs.remove(identifier);
00171 }
00172 #endif
00173
00174 uint openedDialogsCount() {
00175
00176 return dialogs.count();
00177 }
00178
00180 void clearDialogs() {
00181
00182 dialogs.clear();
00183 #ifndef KEXI_NO_PENDING_DIALOGS
00184 pendingDialogs.clear();
00185 #endif
00186 }
00187
00189 void toggleLastCheckedMode()
00190 {
00191 if (curDialog.isNull())
00192 return;
00193 KRadioAction *ra = actions_for_view_modes[ curDialog->currentViewMode() ];
00194 if (ra)
00195 ra->setChecked(true);
00196
00197
00198
00199 }
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219 void showStartProcessMsg(const QStringList& args)
00220 {
00221 wnd->showErrorMessage(i18n("Could not start %1 application.").arg(KEXI_APP_NAME),
00222 i18n("Command \"%1\" failed.").arg(args.join(" ")));
00223 }
00224
00225 void hideMenuItem(const QString& menuName, const QString& itemText, bool alsoSeparator)
00226 {
00227 QPopupMenu *pm = popups[menuName.ascii()];
00228 if (!pm)
00229 return;
00230 uint i=0;
00231 const uint c = pm->count();
00232 for (;i<c;i++) {
00233 kdDebug() << pm->text( pm->idAt(i) ) <<endl;
00234 if (pm->text( pm->idAt(i) ).lower().stripWhiteSpace()==itemText.lower().stripWhiteSpace())
00235 break;
00236 }
00237 if (i<c) {
00238 pm->setItemVisible( pm->idAt(i), false );
00239 if (alsoSeparator)
00240 pm->setItemVisible( pm->idAt(i+1), false );
00241 }
00242 }
00243
00244 void disableMenuItem(const QString& menuName, const QString& itemText)
00245 {
00246 QPopupMenu *pm = popups[menuName.ascii()];
00247 if (!pm)
00248 return;
00249 uint i=0;
00250 const uint c = pm->count();
00251 for (;i<c;i++) {
00252 if (pm->text( pm->idAt(i) ).lower().stripWhiteSpace()==itemText.lower().stripWhiteSpace())
00253 break;
00254 }
00255 if (i<c)
00256 pm->setItemEnabled( pm->idAt(i), false );
00257 }
00258
00259 void updatePropEditorVisibility(int viewMode)
00260 {
00261 if (propEditorToolWindow) {
00262 if (viewMode==0 || viewMode==Kexi::DataViewMode) {
00263 #ifdef PROPEDITOR_VISIBILITY_CHANGES
00264 wnd->makeDockInvisible( wnd->manager()->findWidgetParentDock(propEditor) );
00265
00266 #endif
00267 } else {
00268
00269 QWidget *origFocusWidget = qApp->focusWidget();
00270 wnd->makeWidgetDockVisible(propEditorTabWidget);
00271 if (origFocusWidget)
00272 origFocusWidget->setFocus();
00273
00274
00275
00276
00277
00278
00279 }
00280 }
00281 }
00282
00283 void restoreNavigatorWidth()
00284 {
00285 #if defined(KDOCKWIDGET_P)
00286 if (wnd->mdiMode()==KMdi::ChildframeMode || wnd->mdiMode()==KMdi::TabPageMode) {
00287 KDockWidget *dw = (KDockWidget *)nav->parentWidget();
00288 KDockSplitter *ds = (KDockSplitter *)dw->parentWidget();
00289
00290
00291 config->setGroup("MainWindow");
00292 # if KDE_VERSION >= KDE_MAKE_VERSION(3,4,0)
00293
00294 if (wasAutoOpen)
00295
00296 ds->setSeparatorPosInPercent(
00297 QMAX(QMAX( config->readNumEntry("LeftDockPositionWithAutoOpen",20),
00298 config->readNumEntry("LeftDockPosition",20)),20)
00299 );
00300 else
00301 ds->setSeparatorPosInPercent(
00302 QMAX(20, config->readNumEntry("LeftDockPosition", 20)));
00303
00304
00305 # else
00306
00307 ds->setSeparatorPosInPercent( 20 );
00308 # endif
00309
00310
00311 }
00312 #endif
00313 }
00314
00315 template<class type>
00316 type *openedCustomObjectsForItem(KexiPart::Item* item, const char* name)
00317 {
00318 if (!item || !name) {
00319 kdWarning() <<
00320 "KexiMainWindowImpl::Private::openedCustomObjectsForItem(): !item || !name" << endl;
00321 return 0;
00322 }
00323 QString key( QString::number(item->identifier()) + name );
00324 return dynamic_cast<type*>( m_openedCustomObjectsForItem.find( key.latin1() ) );
00325 }
00326
00327 void addOpenedCustomObjectForItem(KexiPart::Item* item, QObject* object, const char* name)
00328 {
00329 QString key = QString::number(item->identifier()) + name;
00330 m_openedCustomObjectsForItem.insert( key.latin1(), object );
00331 }
00332
00333 KexiMainWindowImpl *wnd;
00334 KexiStatusBar *statusBar;
00335 KexiProject *prj;
00336 KConfig *config;
00337 #ifndef KEXI_NO_CTXT_HELP
00338 KexiContextHelp *ctxHelp;
00339 #endif
00340 KexiBrowser *nav;
00341 KTabWidget *propEditorTabWidget;
00344 QGuardedPtr<KexiPart::Part> partForPreviouslySetupPropertyPanelTabs;
00345 QMap<KexiPart::Part*, int> recentlySelectedPropertyPanelPages;
00346 QGuardedPtr<KexiPropertyEditorView> propEditor;
00347 QGuardedPtr<KoProperty::Set> propBuffer;
00348
00349 KXMLGUIClient *curDialogGUIClient, *curDialogViewGUIClient,
00350 *closedDialogGUIClient, *closedDialogViewGUIClient;
00351 QGuardedPtr<KexiDialogBase> curDialog;
00352
00353 KexiNameDialog *nameDialog;
00354
00355 QTimer timer;
00356
00357
00358 QAsciiDict<QPopupMenu> popups;
00359 QPopupMenu *createMenu;
00360
00361 QString origAppCaption;
00362 QString appCaptionPrefix;
00363
00364 #ifndef KEXI_SHOW_UNIMPLEMENTED
00365 KActionMenu *dummy_action;
00366 #endif
00367
00369 KAction *action_save, *action_save_as, *action_close,
00370 *action_project_properties, *action_open_recent_more,
00371 *action_project_relations, *action_project_import_data_table,
00372 *action_project_export_data_table,
00373 *action_project_print, *action_project_print_preview,
00374 *action_project_print_setup;
00375
00376 KActionMenu *action_open_recent, *action_show_other;
00377
00378 int action_open_recent_projects_title_id,
00379 action_open_recent_connections_title_id;
00380
00382 KAction *action_edit_delete, *action_edit_delete_row,
00383 *action_edit_cut, *action_edit_copy, *action_edit_paste,
00384 *action_edit_select_all,
00385 *action_edit_undo, *action_edit_redo,
00386 *action_edit_insert_empty_row,
00387 *action_edit_edititem, *action_edit_clear_table,
00388 *action_edit_paste_special_data_table,
00389 *action_edit_copy_special_data_table;
00390
00392 KAction *action_view_nav, *action_view_propeditor, *action_view_mainarea;
00393 KRadioAction *action_view_data_mode, *action_view_design_mode, *action_view_text_mode;
00394 QIntDict<KRadioAction> actions_for_view_modes;
00395
00396 #ifndef KEXI_NO_CTXT_HELP
00397 KToggleAction *action_show_helper;
00398 #endif
00399
00400 KAction *action_data_save_row;
00401 KAction *action_data_cancel_row_changes;
00402 KAction *action_data_execute;
00403
00405 KAction *action_format_font;
00406
00408 KAction *action_tools_data_migration, *action_tools_compact_database;
00409 KActionMenu *action_tools_scripts;
00410
00412 KAction *action_window_next, *action_window_previous;
00413
00415 KAction *action_configure;
00416
00418 KMdiToolViewAccessor* navToolWindow;
00419 KMdiToolViewAccessor* propEditorToolWindow;
00420
00421 QGuardedPtr<QWidget> focus_before_popup;
00422
00423
00424 int privateIDCounter;
00425
00426 bool block_KMdiMainFrm_eventFilter : 1;
00427
00431 bool forceDialogClosing : 1;
00432
00435 bool insideCloseDialog : 1;
00436
00437 #ifndef KEXI_NO_PENDING_DIALOGS
00438
00439 enum ActionToExecuteWhenPendingJobsAreFinished {
00440 NoAction,
00441 QuitAction,
00442 CloseProjectAction
00443 };
00444 ActionToExecuteWhenPendingJobsAreFinished actionToExecuteWhenPendingJobsAreFinished;
00445
00446 void executeActionWhenPendingJobsAreFinished() {
00447 ActionToExecuteWhenPendingJobsAreFinished a = actionToExecuteWhenPendingJobsAreFinished;
00448 actionToExecuteWhenPendingJobsAreFinished = NoAction;
00449 switch (a) {
00450 case QuitAction:
00451 qApp->quit();
00452 break;
00453 case CloseProjectAction:
00454 wnd->closeProject();
00455 break;
00456 default:;
00457 }
00458 }
00459 #endif
00460
00462 QPtrList<KexiDialogBase> windowsToClose;
00463
00465 QIntDict<KexiDialogBase> pageSetupDialogs;
00466
00470 QMap<int, int> pageSetupDialogItemID2dataItemID_map;
00471
00474 bool showImportantInfoOnStartup : 1;
00475
00476
00477
00478
00480 bool userMode : 1;
00481
00483 bool isProjectNavigatorVisible : 1;
00484
00486 bool maximizeFirstOpenedChildFrm : 1;
00487
00490 bool forceShowProjectNavigatorOnCreation : 1;
00491 bool forceHideProjectNavigatorOnCreation : 1;
00492
00493 bool navWasVisibleBeforeProjectClosing : 1;
00494 bool saveSettingsForShowProjectNavigator : 1;
00495 #ifdef HAVE_KNEWSTUFF
00496 KexiNewStuff *newStuff;
00497 #endif
00498
00500 QAsciiDict<QObject> m_openedCustomObjectsForItem;
00501
00502 int propEditorDockSeparatorPos, navDockSeparatorPos;
00503
00504 bool wasAutoOpen;
00505 bool dialogExistedBeforeCloseProject;
00506
00507 KMdi::MdiMode mdiModeToSwitchAfterRestart;
00508
00509 protected:
00511 KexiDialogDict dialogs;
00512 #ifndef KEXI_NO_PROCESS_EVENTS
00513 QMap<int, PendingJobType> pendingDialogs;
00514
00515 #endif
00516 };