Changeset View
Changeset View
Standalone View
Standalone View
src/main/KexiMainWindow.h
Show All 19 Lines | |||||
20 | 20 | | |||
21 | #ifndef KEXIMAINWINDOW_H | 21 | #ifndef KEXIMAINWINDOW_H | ||
22 | #define KEXIMAINWINDOW_H | 22 | #define KEXIMAINWINDOW_H | ||
23 | 23 | | |||
24 | //#define KEXI_IMPL_WARNINGS | 24 | //#define KEXI_IMPL_WARNINGS | ||
25 | 25 | | |||
26 | #include "keximain_export.h" | 26 | #include "keximain_export.h" | ||
27 | 27 | | |||
28 | #include <KMainWindow> | | |||
29 | #include <core/KexiMainWindowIface.h> | 28 | #include <core/KexiMainWindowIface.h> | ||
30 | #include <core/kexiguimsghandler.h> | 29 | #include <core/kexiguimsghandler.h> | ||
31 | 30 | | |||
32 | #include <QCommandLineOption> | 31 | #include <QCommandLineOption> | ||
32 | #include <QMainWindow> | ||||
33 | #include <QTabWidget> | 33 | #include <QTabWidget> | ||
34 | 34 | | |||
35 | class QPaintEvent; | 35 | class QPaintEvent; | ||
36 | class KDbObject; | 36 | class KDbObject; | ||
37 | class KDbConnectionData; | 37 | class KDbConnectionData; | ||
38 | class KexiProjectData; | 38 | class KexiProjectData; | ||
39 | class KexiMainWidget; | 39 | class KexiObjectViewWidget; | ||
40 | namespace KexiPart | 40 | namespace KexiPart | ||
41 | { | 41 | { | ||
42 | class Info; | 42 | class Info; | ||
43 | class Part; | 43 | class Part; | ||
44 | } | 44 | } | ||
45 | 45 | | |||
46 | #define KexiMainWindowSuper QWidget //KMainWindow | | |||
47 | | ||||
48 | /** | 46 | /** | ||
49 | * @short Kexi's main window implementation | 47 | * @short Kexi's main window implementation | ||
50 | */ | 48 | */ | ||
51 | class KEXIMAIN_EXPORT KexiMainWindow | 49 | class KEXIMAIN_EXPORT KexiMainWindow | ||
52 | : public QWidget /*KMainWindow*/, public KexiMainWindowIface, public KexiGUIMessageHandler | 50 | : public QMainWindow, public KexiMainWindowIface, public KexiGUIMessageHandler | ||
53 | { | 51 | { | ||
54 | Q_OBJECT | 52 | Q_OBJECT | ||
55 | 53 | | |||
56 | public: | 54 | public: | ||
57 | /*! Creates an empty mainwindow. */ | 55 | /*! Creates an empty mainwindow. */ | ||
58 | explicit KexiMainWindow(QWidget *parent = 0); | 56 | explicit KexiMainWindow(QWidget *parent = 0); | ||
59 | virtual ~KexiMainWindow(); | 57 | virtual ~KexiMainWindow(); | ||
60 | 58 | | |||
61 | virtual KActionCollection* actionCollection() const; | 59 | virtual KActionCollection* actionCollection() const; | ||
62 | 60 | | |||
63 | //! @todo virtual QWidget* focusWidget() const; | 61 | //! @todo virtual QWidget* focusWidget() const; | ||
64 | virtual QWidget* focusWidget() const { | 62 | virtual QWidget* focusWidget() const { | ||
65 | return KexiMainWindowSuper::focusWidget(); | 63 | return QMainWindow::focusWidget(); | ||
66 | } | 64 | } | ||
67 | 65 | | |||
68 | /*! Used by the main Kexi's routine. Creates a new Kexi main window. | 66 | /*! Used by the main Kexi's routine. Creates a new Kexi main window. | ||
69 | For Kexi applications @a arguments are equal to CoreApplication::arguments() but test | 67 | For Kexi applications @a arguments are equal to CoreApplication::arguments() but test | ||
70 | applications alter the list. | 68 | applications alter the list. | ||
71 | If @a componentName is provided, it is assigned to application's KAboutData::componentName. | 69 | If @a componentName is provided, it is assigned to application's KAboutData::componentName. | ||
72 | It's not used by Kexi itself but is useful for test application that are based | 70 | It's not used by Kexi itself but is useful for test application that are based | ||
73 | on KexiMainWindow. | 71 | on KexiMainWindow. | ||
Show All 18 Lines | |||||
92 | 90 | | |||
93 | /*! Performs startup actions. \return false if application should exit immediately | 91 | /*! Performs startup actions. \return false if application should exit immediately | ||
94 | with an error status. */ | 92 | with an error status. */ | ||
95 | tristate startup(); | 93 | tristate startup(); | ||
96 | 94 | | |||
97 | /*! \return true if the application window is in the User Mode. */ | 95 | /*! \return true if the application window is in the User Mode. */ | ||
98 | virtual bool userMode() const; | 96 | virtual bool userMode() const; | ||
99 | 97 | | |||
98 | //! @return current global mode | ||||
99 | Kexi::GlobalViewMode currentMode() const Q_DECL_OVERRIDE; | ||||
100 | | ||||
100 | /*! \return true if opening of item \a item in \a viewMode mode is allowed. | 101 | /*! \return true if opening of item \a item in \a viewMode mode is allowed. | ||
101 | userMode() is taken into account as well | 102 | userMode() is taken into account as well | ||
102 | as KexiPart::PartInfo::supportedUserViewModes() for \a item. */ | 103 | as KexiPart::PartInfo::supportedUserViewModes() for \a item. */ | ||
103 | bool openingAllowed(KexiPart::Item* item, Kexi::ViewMode viewMode, QString* errorMessage = 0); | 104 | bool openingAllowed(KexiPart::Item* item, Kexi::ViewMode viewMode, QString* errorMessage = 0); | ||
104 | 105 | | |||
105 | /*! Implemented for KexiMainWindow. */ | 106 | /*! Implemented for KexiMainWindow. */ | ||
106 | virtual QList<QAction*> allActions() const; | 107 | virtual QList<QAction*> allActions() const; | ||
107 | 108 | | |||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | 151 | public Q_SLOTS: | |||
152 | virtual tristate closeWindow(KexiWindow *window); | 153 | virtual tristate closeWindow(KexiWindow *window); | ||
153 | 154 | | |||
154 | /*! Closes the current window. */ | 155 | /*! Closes the current window. */ | ||
155 | tristate closeCurrentWindow(); | 156 | tristate closeCurrentWindow(); | ||
156 | 157 | | |||
157 | /*! Closes window inside tab @a tabIndex. */ | 158 | /*! Closes window inside tab @a tabIndex. */ | ||
158 | tristate closeWindowForTab(int tabIndex); | 159 | tristate closeWindowForTab(int tabIndex); | ||
159 | 160 | | |||
161 | /*! Closes all windows. */ | ||||
162 | tristate closeAllWindows(); | ||||
163 | | ||||
160 | /*! Internal implementation. If \a doNotSaveChanges is true, | 164 | /*! Internal implementation. If \a doNotSaveChanges is true, | ||
161 | messages asking for saving the will be skipped and the changes will be dropped. | 165 | messages asking for saving the will be skipped and the changes will be dropped. | ||
162 | This should not be usually used, maybe except for test suites | 166 | This should not be usually used, maybe except for test suites | ||
163 | (see kexi/tests/altertable/ directory). */ | 167 | (see kexi/tests/altertable/ directory). */ | ||
164 | tristate closeWindow(KexiWindow *window, bool layoutTaskBar, bool doNotSaveChanges = false); | 168 | tristate closeWindow(KexiWindow *window, bool layoutTaskBar, bool doNotSaveChanges = false); | ||
165 | 169 | | |||
166 | /** | 170 | /** | ||
167 | * Activates next window | 171 | * Activates next window | ||
▲ Show 20 Lines • Show All 163 Lines • ▼ Show 20 Line(s) | 327 | Q_SIGNALS: | |||
331 | 335 | | |||
332 | //! Emitted after closing the project. | 336 | //! Emitted after closing the project. | ||
333 | void projectClosed(); | 337 | void projectClosed(); | ||
334 | 338 | | |||
335 | //! Emitted after opening a project, even after slotAutoOpenObjectsLater(). | 339 | //! Emitted after opening a project, even after slotAutoOpenObjectsLater(). | ||
336 | void projectOpened(); | 340 | void projectOpened(); | ||
337 | 341 | | |||
338 | protected: | 342 | protected: | ||
343 | /*! Setups main menu with sub-menus */ | ||||
344 | void setupMainMenu(); | ||||
345 | | ||||
339 | /*! Setups main widget */ | 346 | /*! Setups main widget */ | ||
340 | void setupMainWidget(); | 347 | void setupMainWidget(); | ||
341 | 348 | | |||
342 | /*! Creates the Project Navigator (if it's not yet created), | 349 | /*! Creates a view widget for object view, used in edit and design global view mode | ||
343 | lookups items for current project and fills the nav. with not-opened items */ | 350 | if it's not yet created. This includes project navigator and property editor. */ | ||
344 | void setupProjectNavigator(); | 351 | void setupObjectView(); | ||
352 | | ||||
353 | //! Setups object view and assigns project to the project navigator. | ||||
354 | void updateObjectView(); | ||||
345 | 355 | | |||
346 | void setupContextHelp(); | 356 | void setupContextHelp(); | ||
347 | 357 | | |||
348 | void setupPropertyEditor(); | 358 | void setupPropertyEditor(); | ||
349 | 359 | | |||
350 | void setupMainMenuActionShortcut(QAction * action); | 360 | void setupMainMenuActionShortcut(QAction * action); | ||
351 | 361 | | |||
352 | /*! Creates standard actions like new, open, save ... */ | 362 | /*! Creates standard actions like new, open, save ... */ | ||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | |||||
396 | \return NULL if no widget matches acceptsSharedActions() or if \a w is NULL. */ | 406 | \return NULL if no widget matches acceptsSharedActions() or if \a w is NULL. */ | ||
397 | virtual QWidget* findWindow(QWidget *w); | 407 | virtual QWidget* findWindow(QWidget *w); | ||
398 | 408 | | |||
399 | /*! Updates application's caption - also shows project's name. */ | 409 | /*! Updates application's caption - also shows project's name. */ | ||
400 | void updateAppCaption(); | 410 | void updateAppCaption(); | ||
401 | 411 | | |||
402 | virtual void closeEvent(QCloseEvent *ev); | 412 | virtual void closeEvent(QCloseEvent *ev); | ||
403 | 413 | | |||
414 | void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; | ||||
415 | | ||||
404 | //! Called by KexiMainWidget::queryClose() | 416 | //! Called by KexiMainWidget::queryClose() | ||
405 | bool queryClose(); | 417 | bool queryClose(); | ||
406 | 418 | | |||
407 | /*! Implemented for KexiMainWindowIface. | 419 | /*! Implemented for KexiMainWindowIface. | ||
408 | Switches \a window to view \a mode. Activates the window if it is not the current window. */ | 420 | Switches \a window to view \a mode. Activates the window if it is not the current window. */ | ||
409 | virtual tristate switchToViewMode(KexiWindow& window, Kexi::ViewMode viewMode); | 421 | virtual tristate switchToViewMode(KexiWindow& window, Kexi::ViewMode viewMode); | ||
410 | 422 | | |||
411 | /*! Helper. Updates setup of property panel's tabs. Used when switching | 423 | /*! Helper. Updates setup of property panel's tabs. Used when switching | ||
412 | from \a prevWindow window to a current window. */ | 424 | from \a prevWindow window to a current window. */ | ||
413 | void updateCustomPropertyPanelTabs(KexiWindow *prevWindow, Kexi::ViewMode prevViewMode); | 425 | void updateCustomPropertyPanelTabs(KexiWindow *prevWindow, Kexi::ViewMode prevViewMode); | ||
414 | 426 | | |||
415 | /*! @overload void updateCustomPropertyPanelTabs(KexiWindow *prevWindow, Kexi::ViewMode prevViewMode) */ | 427 | /*! @overload void updateCustomPropertyPanelTabs(KexiWindow *prevWindow, Kexi::ViewMode prevViewMode) */ | ||
416 | void updateCustomPropertyPanelTabs(KexiPart::Part *prevWindowPart, | 428 | void updateCustomPropertyPanelTabs(KexiPart::Part *prevWindowPart, | ||
417 | Kexi::ViewMode prevViewMode, KexiPart::Part *curWindowPart, Kexi::ViewMode curViewMode); | 429 | Kexi::ViewMode prevViewMode, KexiPart::Part *curWindowPart, Kexi::ViewMode curViewMode); | ||
418 | 430 | | |||
419 | /*! Used in openProject when running another Kexi process is required. */ | 431 | /*! Used in openProject when running another Kexi process is required. */ | ||
420 | tristate openProjectInExternalKexiInstance(const QString& aFileName, KDbConnectionData *cdata, const QString& dbName); | 432 | tristate openProjectInExternalKexiInstance(const QString& aFileName, KDbConnectionData *cdata, const QString& dbName); | ||
421 | 433 | | |||
422 | /*! Used in openProject when running another Kexi process is required. */ | 434 | /*! Used in openProject when running another Kexi process is required. */ | ||
423 | tristate openProjectInExternalKexiInstance(const QString& aFileName, const QString& fileNameForConnectionData, const QString& dbName); | 435 | tristate openProjectInExternalKexiInstance(const QString& aFileName, const QString& fileNameForConnectionData, const QString& dbName); | ||
424 | 436 | | |||
425 | /*! Updates info label of the property editor by reusing properties provided | 437 | /*! Updates info label of the property editor by reusing properties provided | ||
426 | by the current property set. | 438 | by the current property set. | ||
427 | Read documentation of KexiPropertyEditorView class for information about accepted properties. | 439 | Read documentation of KexiPropertyPaneWidget class for information about accepted properties. | ||
428 | If the current property is 0 and @a textToDisplayForNullSet string is not empty, this string is displayed | 440 | | ||
429 | (without icon or any other additional part). | | |||
430 | If the current property is 0 and @a textToDisplayForNullSet string is empty, the info label widget becomes | | |||
431 | hidden. | | |||
432 | Implemented for KexiMainWindow. | 441 | Implemented for KexiMainWindow. | ||
433 | @see KexiPropertyPaneViewBase::updateInfoLabelForPropertySet() */ | 442 | @see KexiPropertyPaneWidget::updateInfoLabelForPropertySet() */ | ||
434 | virtual void updatePropertyEditorInfoLabel(const QString& textToDisplayForNullSet); | 443 | void updatePropertyEditorInfoLabel() Q_DECL_OVERRIDE; | ||
435 | 444 | | |||
436 | //! Activates design tab when switching to design view, according to \a pluginId. | 445 | //! Activates design tab when switching to design view, according to \a pluginId. | ||
437 | void activateDesignTab(const QString &pluginId); | 446 | void activateDesignTab(const QString &pluginId); | ||
438 | 447 | | |||
448 | //! Sets current global mode | ||||
449 | void setCurrentMode(Kexi::GlobalViewMode mode) Q_DECL_OVERRIDE; | ||||
450 | | ||||
451 | void beginPropertyPaneUpdate() Q_DECL_OVERRIDE; | ||||
452 | | ||||
453 | void endPropertyPaneUpdate() Q_DECL_OVERRIDE; | ||||
454 | | ||||
439 | protected Q_SLOTS: | 455 | protected Q_SLOTS: | ||
440 | tristate createNewProject(const KexiProjectData &projectData); | 456 | tristate createNewProject(const KexiProjectData &projectData); | ||
441 | 457 | | |||
442 | /*! Called once after timeout (after ctors are executed). */ | 458 | /*! Called once after timeout (after ctors are executed). */ | ||
443 | void slotAutoOpenObjectsLater(); | 459 | void slotAutoOpenObjectsLater(); | ||
444 | 460 | | |||
445 | /*! Called if a window (tab) changes from \a prevWindow to \a window. Both parameters can be 0. */ | 461 | /*! Called if a window (tab) changes from \a prevWindow to \a window. Both parameters can be 0. */ | ||
446 | void activeWindowChanged(KexiWindow *window, KexiWindow *prevWindow); | 462 | void activeWindowChanged(KexiWindow *window, KexiWindow *prevWindow); | ||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Line(s) | 518 | //! @todo virtual void fillWindowMenu(); | |||
530 | void slotEditFindNext(); | 546 | void slotEditFindNext(); | ||
531 | void slotEditFindPrevious(); | 547 | void slotEditFindPrevious(); | ||
532 | void slotEditReplace(bool all); //!< helper | 548 | void slotEditReplace(bool all); //!< helper | ||
533 | void slotEditReplace(); | 549 | void slotEditReplace(); | ||
534 | void slotEditReplaceNext(); | 550 | void slotEditReplaceNext(); | ||
535 | void slotEditReplaceAll(); | 551 | void slotEditReplaceAll(); | ||
536 | void slotActivateNavigator(); | 552 | void slotActivateNavigator(); | ||
537 | void slotActivateMainArea(); | 553 | void slotActivateMainArea(); | ||
538 | void slotActivatePropertyEditor(); | 554 | void slotActivatePropertyPane(); | ||
539 | void slotShowNavigator(); | 555 | void slotToggleProjectNavigator(); | ||
540 | void slotShowPropertyEditor(); | 556 | void slotTogglePropertyEditor(); | ||
541 | void slotViewDataMode(); | 557 | void slotViewDataMode(); | ||
542 | void slotViewDesignMode(); | 558 | void slotViewDesignMode(); | ||
543 | void slotViewTextMode(); //!< sometimes called "SQL View" | 559 | void slotViewTextMode(); //!< sometimes called "SQL View" | ||
544 | void slotSettings(); | 560 | void slotSettings(); | ||
545 | void slotConfigureKeys(); | 561 | void slotConfigureKeys(); | ||
546 | void slotConfigureToolbars(); | 562 | void slotConfigureToolbars(); | ||
547 | void slotToolsImportProject(); | 563 | void slotToolsImportProject(); | ||
548 | void slotToolsImportTables(); | 564 | void slotToolsImportTables(); | ||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Line(s) | |||||
618 | //! \return true on success. | 634 | //! \return true on success. | ||
619 | //! @todo reenable when ported bool printPreviewForItem(KexiPart::Item* item, const KexiSimplePrintingSettings& settings, const QString& titleText = QString(), bool reload = false); | 635 | //! @todo reenable when ported bool printPreviewForItem(KexiPart::Item* item, const KexiSimplePrintingSettings& settings, const QString& titleText = QString(), bool reload = false); | ||
620 | 636 | | |||
621 | /*! Implemented for KexiMainWindow. Helper for printItem() and printPreviewForItem(). | 637 | /*! Implemented for KexiMainWindow. Helper for printItem() and printPreviewForItem(). | ||
622 | Also used by KexiFormEventAction. | 638 | Also used by KexiFormEventAction. | ||
623 | \return true on success and cancelled when the action was cancelled. */ | 639 | \return true on success and cancelled when the action was cancelled. */ | ||
624 | //! @todo reenable when ported tristate printActionForItem(KexiPart::Item* item, PrintActionType action); | 640 | //! @todo reenable when ported tristate printActionForItem(KexiPart::Item* item, PrintActionType action); | ||
625 | 641 | | |||
626 | void slotSetProjectNavigatorVisible(bool set); | 642 | //void slotSetProjectNavigatorVisible(bool set); | ||
627 | void slotSetPropertyEditorVisible(bool set); | 643 | //void slotSetPropertyEditorVisible(bool set); | ||
644 | //void slotProjectNavigatorVisibilityChanged(bool visible); | ||||
645 | //void slotPropertyEditorVisibilityChanged(bool visible); | ||||
646 | //void slotMultiTabBarTabClicked(int id); | ||||
647 | void slotCurrentModeChanged(Kexi::GlobalViewMode previousMode); | ||||
648 | | ||||
628 | void slotProjectNavigatorVisibilityChanged(bool visible); | 649 | void slotProjectNavigatorVisibilityChanged(bool visible); | ||
629 | void slotPropertyEditorVisibilityChanged(bool visible); | | |||
630 | void slotMultiTabBarTabClicked(int id); | | |||
631 | 650 | | |||
632 | private: | 651 | private: | ||
633 | //! Adds action @a name with text @a text and optional shortcut @a shortcut. | 652 | //! Adds action @a name with text @a text and optional shortcut @a shortcut. | ||
634 | //! This is helper method containing workaround for Kexi | 653 | //! This is helper method containing workaround for Kexi | ||
635 | //! until QAction::setShortcut() works again. | 654 | //! until QAction::setShortcut() works again. | ||
636 | //! @return created action | 655 | //! @return created action | ||
637 | QAction * addAction(const char *name, const QString &text, const char *shortcut = 0); | 656 | QAction * addAction(const char *name, const QString &text, const char *shortcut = 0); | ||
638 | 657 | | |||
639 | //! Like @ref addAction(const char *, const QString&, const char *) but also adds | 658 | //! Like @ref addAction(const char *, const QString&, const char *) but also adds | ||
640 | //! icon @a icon. | 659 | //! icon @a icon. | ||
641 | //! @return created action | 660 | //! @return created action | ||
642 | QAction * addAction(const char *name, const QIcon &icon, const QString& text, | 661 | QAction * addAction(const char *name, const QIcon &icon, const QString& text, | ||
643 | const char *shortcut = 0); | 662 | const char *shortcut = 0); | ||
644 | 663 | | |||
645 | class MessageHandler; | 664 | class MessageHandler; | ||
646 | class Private; | 665 | class Private; | ||
647 | Private * const d; | 666 | Private * const d; | ||
648 | 667 | | |||
649 | friend class KexiWindow; | 668 | friend class KexiWindow; | ||
650 | friend class KexiMainWidget; | 669 | friend class KexiObjectViewWidget; | ||
651 | }; | 670 | }; | ||
652 | 671 | | |||
653 | #endif | 672 | #endif |