1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
|
/* This file is part of the KDE project
Copyright (C) 2003 Lucijan Busch <[email protected]>
Copyright (C) 2003-2007 Jaroslaw Staniek <[email protected]>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KEXIMAINWINDOWIMPL_H
#define KEXIMAINWINDOWIMPL_H
#include <kmessagebox.h>
#include "core/keximainwindow.h"
#include "core/kexiguimsghandler.h"
class KexiProjectData;
class KexiActionProxy;
class KMdiChildView;
class KexiSimplePrintingSettings;
namespace KexiDB {
class Object;
class ConnectionData;
}
namespace KexiPart {
class Info;
class Part;
}
/**
* @short Kexi's main window implementation
*/
class KEXIMAIN_EXPORT KexiMainWindowImpl : public KexiMainWindow, public KexiGUIMessageHandler
{
Q_OBJECT
public:
/*! Creates an empty mainwindow. */
KexiMainWindowImpl();
virtual ~KexiMainWindowImpl();
/*! Used by the main kexi routine. Creates a new Kexi main window and a new TDEApplication object.
kdemain() has to destroy the latter on exit.
\return result 1 on error and 0 on success (the result can be used as a result of kdemain()) */
static int create(int argc, char *argv[], TDEAboutData* aboutdata = 0);
//! \return KexiMainWindowImpl singleton (if it is instantiated)
static KexiMainWindowImpl* self() { return dynamic_cast<KexiMainWindowImpl*>(tqApp->mainWidget()); }
//! Project data of currently opened project or NULL if no project here yet.
virtual KexiProject *project();
/*! Registers dialog \a dlg for watching and adds it to the main window's stack. */
virtual void registerChild(KexiDialogBase *dlg);
/*! Activates a window by it's document identifier.
\return false if doc couldn't be raised or isn't opened. */
bool activateWindow(int id);
/*! Like above, using \a dlg passed explicitly. Above method just calls this one. */
bool activateWindow(KexiDialogBase *dlg);
/*! Performs startup actions. \return false if application should exit immediately
with an error status. */
tristate startup();
/*! \return true if the application window is in the User Mode. */
virtual bool userMode() const;
/*! \return true if opening of item \a item in \a viewMode mode is allowed.
userMode() is taken into account as well
as KexiPart::Part::supportedUserViewModes() for \a item. */
bool openingAllowed(KexiPart::Item* item, int viewMode);
virtual bool eventFilter( TQObject *obj, TQEvent * e );
//! \return popup menu for \a popupName name.
virtual TQPopupMenu* findPopupMenu(const char *popupName);
/*! Implemented for KexiMainWindow. */
virtual KActionPtrList allActions() const;
/*! \return currently active dialog (window) od 0 if there is no active dialog.
Implemented for KexiMainWindow. */
virtual KexiDialogBase* currentDialog() const;
//! @todo move to kexiproject
/*! Generates ID for private "document" like Relations window.
Private IDs are negative numbers (while ID regular part instance's IDs are >0)
Private means that the object is not stored as-is in the project but is somewhat
generated and in most cases there is at most one unique instance document of such type (part).
To generate this ID, just app-wide internal counter is used. */
virtual int generatePrivateID();
/*! Reimplemented */
virtual void readProperties(KConfig *config);
virtual void saveProperties(KConfig *config);
virtual void saveGlobalProperties( KConfig* sessionConfig );
public slots:
/*! Inherited from KMdiMainFrm: we need to do some tasks before child is closed.
Just calls closeDialog(). Use closeDialog() if you need, not this one. */
virtual void closeWindow(KMdiChildView *pWnd, bool layoutTaskBar = true);
/*! Reimplemented for internal reasons. */
virtual void addWindow( KMdiChildView* pView, int flags = KMdi::StandardAdd );
/*! Implemented for KexiMainWindow */
virtual tristate closeDialog(KexiDialogBase *dlg);
/*! Internal implementation. If \a doNotSaveChanges is true,
messages asking for saving the will be skipped and the changes will be dropped.
This should not be usually used, maybe except for test suites
(see kexi/tests/altertable/ directory). */
tristate closeDialog(KexiDialogBase *dlg, bool layoutTaskBar, bool doNotSaveChanges = false);
virtual void detachWindow(KMdiChildView *pWnd,bool bShow=true);
virtual void attachWindow(KMdiChildView *pWnd,bool bShow=true,bool bAutomaticResize=false);
//! @todo move part of this to KexiProject, because currently KexiProject::openObject() allows multiple opens!
/*! Opens object pointed by \a item in a view \a viewMode.
\a staticObjectArgs can be passed for static object
(only works when part for this item is of type KexiPart::StaticPart).
\a openingCancelled is set to true is opening has been cancelled.
\a errorMessage, if not 0, points to a string that can be set to error message
if one encountered. */
virtual KexiDialogBase* openObject(KexiPart::Item *item, int viewMode,
bool &openingCancelled, TQMap<TQString,TQString>* staticObjectArgs = 0,
TQString* errorMessage = 0);
//! For convenience
virtual KexiDialogBase* openObject(const TQCString& mime, const TQString& name,
int viewMode, bool &openingCancelled, TQMap<TQString,TQString>* staticObjectArgs = 0);
/*! Closes the object for \a item.
\return true on success (closing can be dealyed though), false on failure and cancelled
if the object has "opening" job assigned. */
virtual tristate closeObject(KexiPart::Item* item);
/*! Implemented for KexiMainWindow */
virtual tristate saveObject( KexiDialogBase *dlg,
const TQString& messageWhenAskingForName = TQString(), bool dontAsk = false );
/*! Implemented for KexiMainWindow */
virtual tristate getNewObjectInfo( KexiPart::Item *partItem, KexiPart::Part *part,
bool& allowOverwriting, const TQString& messageWhenAskingForName = TQString() );
/*! Implemented for KexiMainWindow */
virtual void highlightObject(const TQCString& mime, const TQCString& name);
/*! Opens project pointed by \a projectData.
Application state (e.g. actions) is updated.
\a projectData is copied into a project structures.
\return true on success */
tristate openProject(const KexiProjectData& projectData);
/*! Helper. Opens project pointed by \a aFileName.
If \a aFileName is empty, a connection shortcut (.kexic file name) is obtained from
global connection set using \a cdata (if present).
In this case:
* If connection shortcut has been found and \a dbName (a server database name) is provided
'kexi --skip-dialog --connection file.kexic dbName' is executed (or the project
is opened directly if there's no project opened in the current Kexi main window.
* If connection shortcut has been found and \a dbName is not provided,
'kexi --skip-dialog file.kexic' is executed (or the connection is opened
directly if there's no porject opened in the current Kexi main window. */
tristate openProject(const TQString& aFileName, KexiDB::ConnectionData *cdata,
const TQString& dbName = TQString(),
const TQValueList<KexiProjectData::ObjectInfo>& autoopenObjects = TQValueList<KexiProjectData::ObjectInfo>());
/*! Helper. Opens project pointed by \a aFileName.
Like above but \a fileNameForConnectionData can be passed instead of
a pointer to connection data itself.
\return false if \a fileNameForConnectionData is not empty but there is no such
connection in Kexi::connset() for this filename.
\a fileNameForConnectionData can be empty. */
tristate openProject(const TQString& aFileName,
const TQString& fileNameForConnectionData, const TQString& dbName = TQString());
/*! Creates a new project usign template pointed by \a projectData.
Application state (e.g. actions) is updated.
New project data is copied into a project structures.
\return true on success */
tristate createProjectFromTemplate(const KexiProjectData& projectData);
/*! Closes current project, \return true on success.
Application state (e.g. actions) is updated.
\return true on success.
If closing was cancelled by user, cancelled is returned. */
tristate closeProject();
//! Shows "print" dialog for \a item.
//! \return true on success.
virtual tristate printItem(KexiPart::Item* item);
//! Shows "print preview" dialog.
//! \return true on success.
virtual tristate printPreviewForItem(KexiPart::Item* item);
//! Shows "page setup" dialog for \a item.
//! \return true on success and cancelled when the action was cancelled.
virtual tristate showPageSetupForItem(KexiPart::Item* item);
/*! Executes custom action for the main window, usually provided by a plugin.
Also used by KexiFormEventAction. */
virtual tristate executeCustomActionForObject(KexiPart::Item* item, const TQString& actionName);
signals:
//! Emitted after opening a project, even after slotAutoOpenObjectsLater().
void projectOpened();
protected:
/*! Initialises the User Mode: constructs window according to kexi__final database
and loads the specified part.
\return true on success or false if e.g. kexi__final does not exist
or a fatal exception happened */
bool initUserMode(KexiProjectData *projectData);
/*!
Creates navigator (if it's not yet created),
lookups items for current project and fills the nav. with not-opened items
*/
void initNavigator();
void initContextHelp();
void initPropertyEditor();
//! reimplementation of events
// virtual void closeEvent(TQCloseEvent *);
/*! Creates standard actions like new, open, save ... */
void initActions();
/*! Creates user project-wide actions */
void initUserActions();
/*! Sets up the window from user settings (e.g. mdi mode). */
void restoreSettings();
/*! Writes user settings back. */
void storeSettings();
/*! Invalidates availability of all actions for current application state. */
void invalidateActions();
/*! Invalidates action availability for current application state.
These actions are dependent on curently selected dialog. */
virtual void invalidateSharedActions(TQObject *o);
/*! Invalidates action availability for current application state.
These actions only depend on project availability, not on curently selected dialog. */
void invalidateProjectWideActions();
/*! Invalidates action availability for current application state.
These actions only depend on curently selected dialog and currently selected view
(KexiViewBase derived object) within this dialog. */
void invalidateViewModeActions();
/*! Shows dialog for creating new blank project,
and creates one. Dialog is not shown if option for automatic creation
is checked or Kexi::startupHandler().projectData() was provided from command line.
\a cancelled is set to true if creation has been cancelled (e.g. user answered
no when asked for database overwriting, etc.
\return true if database was created, false on error or when cancel was pressed */
tristate createBlankProject();
/*! Shows dialog for creating new blank project,
and return a data describing it. It the dialog was cancelled,
\a cancelled will be set to true (false otherwise).
\a shortcutFileName, if not 0, will be set to a shortcut filename
(in case when server database project was selected). */
KexiProjectData* createBlankProjectData(bool &cancelled, bool confirmOverwrites = true,
TQString *shortcutFileName = 0);
void setWindowMenu(TQPopupMenu *menu);
/*! \return focused kexi window (KexiDialogBase or KexiDockBase subclass) */
// TQWidget* focusWindow() const;
/*! Reimplemented from KexiSharedActionHost:
accepts only KexiDockBase and KexiDialogBase subclasses. */
virtual bool acceptsSharedActions(TQObject *w);
/*! Performs lookup like in KexiSharedActionHost::focusWindow()
but starting from \a w instead of a widget returned by TQWidget::focusWidget().
\return NULL if no widget matches acceptsSharedActions() or if \a w is NULL. */
TQWidget* findWindow(TQWidget *w);
/*! Updates application's caption - also shows project's name. */
void updateAppCaption();
void restoreWindowConfiguration(KConfig *config);
void storeWindowConfiguration(KConfig *config);
virtual bool queryClose();
virtual bool queryExit();
/*! Helper: switches to view \a mode. */
bool switchToViewMode(int viewMode);
/*! Helper. Removes and/or adds GUI client for current dialog's view;
on switching to other dialog (activeWindowChanged())
or on switching to other view within the same dialog (switchToViewMode()). */
void updateDialogViewGUIClient(KXMLGUIClient *viewClient);
/*! Helper. Updates setup of property panel's tabs. Used when switching
from \a prevDialog dialog to a current dialog. */
void updateCustomPropertyPanelTabs(KexiDialogBase *prevDialog, int prevViewMode);
/*! @overload void updateCustomPropertyPanelTabs(KexiDialogBase *prevDialog, int prevViewMode) */
void updateCustomPropertyPanelTabs(
KexiPart::Part *prevDialogPart, int prevViewMode, KexiPart::Part *curDialogPart, int curViewMode );
/*! Used in openProject when running another Kexi process is required. */
tristate openProjectInExternalKexiInstance(const TQString& aFileName,
KexiDB::ConnectionData *cdata, const TQString& dbName);
/*! Used in openProject when running another Kexi process is required. */
tristate openProjectInExternalKexiInstance(const TQString& aFileName,
const TQString& fileNameForConnectionData, const TQString& dbName);
protected slots:
/*! Called once after timeout (after ctors are executed). */
void slotAutoOpenObjectsLater();
/*! This slot is called if a window changes */
void activeWindowChanged(KMdiChildView *dlg);
/*! Tthis slot is called if a window gets colsed and will unregister stuff */
void childClosed(KMdiChildView *dlg);
void slotPartLoaded(KexiPart::Part* p);
void slotCaptionForCurrentMDIChild(bool childrenMaximized);
void slotNoMaximizedChildFrmLeft(KMdiChildFrm*);
void slotLastChildViewClosed();
void slotChildViewIsDetachedNow(TQWidget*);
//! internal - creates and initializes kexi project
void createKexiProject(KexiProjectData* new_data);
/*! Handles event when user double clicked (or single -depending on settings)
or pressed Return key on the part item in the navigator.
This differs from openObject() signal in that if the object is already opened
in view mode other than \a viewMode, the mode is not changed.
\sa KexiBrowser::openOrActivateItem() */
KexiDialogBase* openObjectFromNavigator(KexiPart::Item* item, int viewMode,
bool &openingCancelled);
//! For convenience
KexiDialogBase* openObjectFromNavigator(KexiPart::Item* item, int viewMode);
/*! Creates new object of type defined by \a info part info.
\a openingCancelled is set to true is opening has been cancelled.
\return true on success. */
virtual bool newObject( KexiPart::Info *info, bool& openingCancelled );
//! For convenience
bool newObject( KexiPart::Info *info ) {
bool openingCancelled;
return newObject(info, openingCancelled);
}
//! For convenience
KexiDialogBase* openObject(KexiPart::Item *item, int viewMode,
TQMap<TQString,TQString>* staticObjectArgs = 0)
{
bool openingCancelled;
return openObject(item, viewMode, openingCancelled, staticObjectArgs);
}
/*! Removes object pointed by \a item from current project.
Asks for confirmation. \return true on success
or cancelled if removing was cancelled (only possible if \a dontAsk is false). */
tristate removeObject( KexiPart::Item *item, bool dontAsk = false );
/*! Renames object pointed by \a item to a new name \a _newName.
Sets \a success to false on failure. Used as a slot connected
to KexiBrowser::renameItem() signal. */
void renameObject( KexiPart::Item *item, const TQString& _newName, bool &succes );
/*! Reaction for object rename (signalled by KexiProject).
If this item has opened dialog, it's caption is updated,
and also optionally application's caption. */
virtual void slotObjectRenamed(const KexiPart::Item &item, const TQCString& oldName);
virtual void fillWindowMenu();
void invalidateSharedActions();
void invalidateSharedActionsLater();
//! Updates the statusbar, navigator and "Insert->....." actions, dependent on read-only state.
//! Only called on project opening and closing.
void updateReadOnlyState();
void slotProjectNew();
void slotProjectOpen();
void slotProjectOpenRecentAboutToShow();
void slotProjectOpenRecent(int id);
void slotProjectOpenRecentMore();
void slotProjectSave();
void slotProjectSaveAs();
void slotProjectPrint();
void slotProjectPrintPreview();
void slotProjectPageSetup();
void slotProjectProperties();
void slotProjectClose();
void slotProjectRelations();
void slotProjectImportDataTable();
void slotProjectExportDataTable();
void slotProjectQuit();
void slotEditPasteSpecialDataTable();
void slotEditCopySpecialDataTable();
void slotEditFind();
void slotEditFind(bool next); //!< helper
void slotEditFindNext();
void slotEditFindPrevious();
void slotEditReplace(bool all); //!< helper
void slotEditReplace();
void slotEditReplaceNext();
void slotEditReplaceAll();
void slotViewNavigator();
void slotViewMainArea();
void slotViewPropertyEditor();
void slotViewDataMode();
void slotViewDesignMode();
void slotViewTextMode(); //!< sometimes called "SQL View"
void slotShowSettings();
void slotConfigureKeys();
void slotConfigureToolbars();
void slotToolsProjectMigration();
void slotToolsCompactDatabase();
/// TMP: Display a dialog to download db examples from internet
void slotGetNewStuff();
void slotTipOfTheDay();
//! Shows 'important info' dialog, is \a onStartup is false, it's always shown
void importantInfo(bool onStartup);
void slotImportantInfo(); //!< just importantInfo(false);
void slotStartFeedbackAgent();
void slotOptionsEnableForms(bool show, bool noMessage = false); //temp.
void slotImportFile();
void slotImportServer();
//! There are performed all actions that need to be done immediately after ctro (using timer)
void slotLastActions();
virtual void acceptPropertySetEditing();
virtual void propertySetSwitched(KexiDialogBase *dlg, bool force=false,
bool preservePrevSelection = true, const TQCString& propertyToSelect = TQCString());
/*! Handles changes in 'dirty' flag for dialogs. */
void slotDirtyFlagChanged(KexiDialogBase*);
void slotMdiModeHasBeenChangedTo(KMdi::MdiMode);
//! reimplemented to add "restart is required" message box
virtual void switchToIDEAlMode();
void switchToIDEAlMode(bool showMessage);
virtual void switchToChildframeMode();
void switchToChildframeMode(bool showMessage);
/*! Shows Project Migration Wizard. \return true on successful migration,
cancelled on cancellation, and false on failure.
If \a mimeType and \a databaseName are not empty, the wizard will only ask about
parameters of destination project and skip pages related to source project.
\a cdata connection data can be also provided to preselect server-based connections. */
tristate showProjectMigrationWizard(const TQString& mimeType, const TQString& databaseName,
const KexiDB::ConnectionData *cdata = 0);
//! Receives "selectionChanged()" signal from navigator to update some actions.
void slotPartItemSelectedInNavigator(KexiPart::Item* item);
/*! Receives the "executeItem" signal from navigator to perform "execute" action
on \a item. \return true on success */
tristate executeItem(KexiPart::Item* item);
//! Shows "exports as data table" dialog for \a item.
tristate exportItemAsDataTable(KexiPart::Item* item);
//! Shows "copy special as data table" dialog for \a item.
tristate copyItemToClipboardAsDataTable(KexiPart::Item* item);
//! Shows "print" dialog for \a item.
//! \return true on success.
bool printItem(KexiPart::Item* item, const TQString& titleText);
//! Shows "print" dialog for \a item and \a settings.
//! \return true on success.
bool printItem(KexiPart::Item* item, const KexiSimplePrintingSettings& settings,
const TQString& titleText = TQString());
/*! Shows "print preview" dialog for \a item.
The preview dialog is cached, so \a reload == true is sometimes needed
if data or print settings have changed in the meantime.
\return true on success. */
bool printPreviewForItem(KexiPart::Item* item, const TQString& titleText,
bool reload);
//! Shows "print preview" dialog.
//! \return true on success.
bool printPreviewForItem(KexiPart::Item* item, const KexiSimplePrintingSettings& settings,
const TQString& titleText = TQString(), bool reload = false);
/*! Implemented for KexiMainWindow. Helper for printItem() and printPreviewForItem().
Also used by KexiFormEventAction.
\return true on success and cancelled when the action was cancelled. */
tristate printActionForItem(KexiPart::Item* item, PrintActionType action);
private:
class MessageHandler;
class Private;
Private *d;
friend class KexiDialogBase;
};
#endif
|