1
/* This file is part of the KDE project
2
Copyright (C) 2003 Lucijan Busch <lucijan@kde.org>
3
Copyright (C) 2003-2009 Jarosław Staniek <staniek@kde.org>
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Library General Public
7
License as published by the Free Software Foundation; either
8
version 2 of the License, or (at your option) any later version.
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Library General Public License for more details.
15
You should have received a copy of the GNU Library General Public License
16
along with this library; see the file COPYING.LIB. If not, write to
17
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
* Boston, MA 02110-1301, USA.
21
#ifndef KEXIMAINWINDOW_P_H
22
#define KEXIMAINWINDOW_P_H
24
#define KEXI_NO_PROCESS_EVENTS
26
#ifdef KEXI_NO_PROCESS_EVENTS
27
# define KEXI_NO_PENDING_DIALOGS
30
#define PROJECT_NAVIGATOR_TABBAR_ID 0
31
#define PROPERTY_EDITOR_TABBAR_ID 1
35
#include <QHBoxLayout>
37
#include <kexiutils/SmallToolButton.h>
39
//! @short Main application's tabbed toolbar
40
class KexiTabbedToolBar : public KTabWidget
44
KexiTabbedToolBar(QWidget *parent);
45
virtual ~KexiTabbedToolBar();
47
KToolBar *createWidgetToolBar() const;
49
KToolBar *toolBar(const QString& name) const;
51
void appendWidgetToToolbar(const QString& name, QWidget* widget);
53
void setWidgetVisibleInToolbar(QWidget* widget, bool visible);
54
// void removeWidgetFromToolbar(const QString& name);
56
//! @todo replace with the final Actions API
57
void addAction(const QString& toolBarName, QAction *action);
60
virtual void mouseMoveEvent(QMouseEvent* event);
61
virtual void leaveEvent(QEvent* event);
64
void slotCurrentChanged(int index);
65
void slotDelayedTabRaise();
66
void slotSettingsChanged(int category);
67
//! Used for delayed loading of the "create" toolbar. Called only once.
68
void setupCreateWidgetToolbar();
70
void addAction(KToolBar *tbar, const char* actionName);
71
void addSeparatorAndAction(KToolBar *tbar, const char* actionName);
77
//! @internal window container created to speedup opening new tabs
78
class KexiWindowContainer : public QWidget
81
KexiWindowContainer(QWidget* parent)
84
, lyr(new QVBoxLayout(this)) {
85
lyr->setContentsMargins(0, 0, 0, 0);
87
void setWindow(KexiWindow* w) {
98
class KexiTabbedToolBar::Private
101
Private(KexiTabbedToolBar *t)
102
: q(t), createWidgetToolBar(0), tabToRaise(-1)
104
tabRaiseTimer.setSingleShot(true);
105
tabRaiseTimer.setInterval(300);
108
KToolBar *createToolBar(const char *name, const QString& caption)
110
KToolBar *tbar = new KToolBar(q);
111
toolbarsForName.insert(name, tbar);
112
tbar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
113
tbar->setObjectName(name);
114
q->addTab(tbar, caption);
118
KexiTabbedToolBar *q;
119
KActionCollection *ac;
121
KToolBar *createWidgetToolBar;
122
//! Used for delayed tab raising
124
//! Used for delayed tab raising
125
QTimer tabRaiseTimer;
126
//! Toolbars for name
127
QHash<QString, KToolBar*> toolbarsForName;
128
QHash<QWidget*, QAction*> extraActions;
131
KexiTabbedToolBar::KexiTabbedToolBar(QWidget *parent)
133
, d(new Private(this))
135
setMouseTracking(true); // for mouseMoveEvent()
136
setWhatsThis(i18n("Task-based tabbed toolbar groups commands for application using tabs."));
137
connect(&d->tabRaiseTimer, SIGNAL(timeout()), this, SLOT(slotDelayedTabRaise()));
139
d->ac = KexiMainWindowIface::global()->actionCollection();
140
const bool userMode = KexiMainWindowIface::global()->userMode();
144
KexiUtils::smallFont(this/*init*/);
145
slotSettingsChanged(KGlobalSettings::FontChanged);
146
connect(KGlobalSettings::self(), SIGNAL(settingsChanged(int)), this, SLOT(slotSettingsChanged(int)));
148
// KToolBar* helpToolBar = new KToolBar(this);
149
// helpToolBar->setFont(Kexi::smallFont());
151
helpToolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
152
helpToolBar->setIconSize( QSize(IconSize(KIconLoader::Small), IconSize(KIconLoader::Small)) );
153
a = d->ac->action("help_whats_this");
154
helpToolBar->addAction(a);
155
a = d->ac->action("help_contents");
156
helpToolBar->addAction(a);
157
setCornerWidget(helpToolBar, Qt::TopRightCorner);*/
159
QWidget *helpWidget = new QWidget(this);
160
helpWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
161
QHBoxLayout *helpLyr = new QHBoxLayout(helpWidget);
162
helpLyr->setContentsMargins(0, 0, 0, 2);
163
helpLyr->setSpacing(2);
164
a = d->ac->action("help_whats_this");
165
helpLyr->addWidget(new KexiSmallToolButton(a, helpWidget));
166
a = d->ac->action("help_contents");
167
helpLyr->addWidget(new KexiSmallToolButton(a, helpWidget));
168
setCornerWidget(helpWidget, Qt::TopRightCorner);
170
tbar = d->createToolBar("kexi", i18nc("Application name as menu entry", "Kexi"));
171
addAction(tbar, "options_configure");
172
addAction(tbar, "options_configure_keybinding");
173
addSeparatorAndAction(tbar, "help_about_app");
174
addAction(tbar, "help_about_kde");
175
#ifdef KEXI_NO_REPORTBUG_COMMAND
176
//remove "bug report" action to avoid confusion for with commercial technical support
177
addSeparatorAndAction(tbar, "help_report_bug");
179
addSeparatorAndAction(tbar, "quit");
181
tbar = d->createToolBar("project", i18n("Project"));
182
setCurrentWidget(tbar); // the default
183
addAction(tbar, "project_new");
184
addAction(tbar, "project_open");
185
//! @todo re-add addAction(tbar, "project_print");
186
//! @todo re-add addAction(tbar, "project_print_preview");
187
//! @todo re-add addAction(tbar, "project_print_setup");
188
//no "project_save" here...
189
//! @todo re-add addSeparatorAndAction(tbar, "project_saveas");
190
//! @todo re-add addSeparatorAndAction(tbar, "project_properties");
191
addSeparatorAndAction(tbar, "project_close");
194
d->createWidgetToolBar = d->createToolBar("create", i18n("Create"));
197
tbar = d->createToolBar("data", i18n("Data"));
198
addAction(tbar, "edit_cut");
199
addAction(tbar, "edit_copy");
200
//moved to project navigator addAction(tbar, "edit_copy_special_data_table");
201
addAction(tbar, "edit_paste");
203
addAction(tbar, "edit_paste_special_data_table");
204
tbar->addSeparator();
205
// todo move undo/redo to quickbar:
206
/* moved to local toolbars
207
addAction(tbar, "edit_undo");
208
addAction(tbar, "edit_redo");
209
tbar->addSeparator();*/
210
addAction(tbar, "edit_find");
212
tbar = d->createToolBar("external", i18n("External Data"));
214
/* QGroupBox *gbox = new QGroupBox( i18n("Import"), tbar );
216
gbox->setFont(Kexi::smallFont(this));
217
tbar->addWidget( gbox );
218
QVBoxLayout *gbox_lyr = new QVBoxLayout(gbox);
219
gbox_lyr->setContentsMargins(0,0,0,0);
220
gbox_lyr->setSpacing(2); //ok?
221
QToolBar *sub_tbar = new KToolBar(gbox);
222
gbox_lyr->addWidget(sub_tbar);
225
addAction(tbar, "project_import_data_table");
226
addAction(tbar, "tools_import_tables");
228
/* gbox = new QGroupBox( i18n("Export"), tbar );
230
gbox->setFont(Kexi::smallFont(this));
231
tbar->addWidget( gbox );
232
gbox_lyr = new QVBoxLayout(gbox);
233
gbox_lyr->setContentsMargins(0,0,0,0);
234
gbox_lyr->setSpacing(2); //ok?
235
sub_tbar = new KToolBar(gbox);
236
gbox_lyr->addWidget(sub_tbar);
238
addSeparatorAndAction(tbar, "project_export_data_table");
240
tbar = d->createToolBar("tools", i18n("Tools"));
241
addAction(tbar, "tools_import_project");
242
addAction(tbar, "tools_compact_database");
244
//! @todo move to form plugin
245
tbar = d->createToolBar("form", i18n("Form Design"));
247
//! @todo move to report plugin
248
tbar = d->createToolBar("report", i18n("Report Design"));
250
// tbar = new KToolBar(this);
251
// addTab( tbar, i18n("Settings") );
252
//moved up addAction(tbar, "options_configure_keybinding");
255
tbar = new KToolBar(this);
256
addTab( tbar, i18n("Help") );
257
addAction(tbar, "help_contents");
258
addAction(tbar, "help_whats_this");
259
addAction(tbar, "help_report_bug");
260
a = d->ac->action("help_report_bug");
261
a->setIcon(KIcon("tools-report-bug"));
262
addAction(tbar, "help_about_app");
263
addAction(tbar, "help_about_kde");
266
connect(this, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentChanged(int)));
268
QPalette pal(palette());
269
QBrush bg( pal.brush( backgroundRole() ) );
270
bg.setColor( Qt::red ); //pal.color( QPalette::Button ) );
271
pal.setColor( QPalette::Window, Qt::red );
275
KexiTabbedToolBar::~KexiTabbedToolBar()
280
void KexiTabbedToolBar::slotSettingsChanged(int category)
282
if (category == KGlobalSettings::FontChanged) {
283
setFont(KGlobalSettings::menuFont()); // toolbar acts like a menu
287
KToolBar* KexiTabbedToolBar::createWidgetToolBar() const
289
return d->createWidgetToolBar;
292
void KexiTabbedToolBar::mouseMoveEvent(QMouseEvent* event)
294
QPoint p = event->pos();
295
int tab = tabBar()->tabAt(p);
296
if (d->tabToRaise != -1 && (tab == -1 || tab == currentIndex())) {
297
d->tabRaiseTimer.stop();
299
} else if (d->tabToRaise != tab) {
300
d->tabRaiseTimer.start();
303
KTabWidget::mouseMoveEvent(event);
306
void KexiTabbedToolBar::leaveEvent(QEvent* event)
308
d->tabRaiseTimer.stop();
310
KTabWidget::leaveEvent(event);
313
void KexiTabbedToolBar::slotCurrentChanged(int index)
315
if (index == indexOf(d->createWidgetToolBar) && index != -1) {
316
if (d->createWidgetToolBar->actions().isEmpty()) {
317
QTimer::singleShot(10, this, SLOT(setupCreateWidgetToolbar()));
322
void KexiTabbedToolBar::setupCreateWidgetToolbar()
324
//! @todo separate core object types from custom....
325
KexiPart::PartInfoList *plist = Kexi::partManager().partInfoList(); //this list is properly sorted
326
foreach(KexiPart::Info *info, *plist) {
327
QAction* a = d->ac->action(
328
KexiPart::nameForCreateAction(*info));
330
d->createWidgetToolBar->addAction(a);//->icon(), a->text());
337
void KexiTabbedToolBar::slotDelayedTabRaise()
339
QPoint p = mapFromGlobal(QCursor::pos()); // make sure cursor is still over the tab
340
int tab = tabBar()->tabAt(p);
341
if (tab != d->tabToRaise) {
343
} else if (d->tabToRaise != -1) {
344
setCurrentIndex(d->tabToRaise);
349
KToolBar *KexiTabbedToolBar::toolBar(const QString& name) const
351
return d->toolbarsForName[name];
354
void KexiTabbedToolBar::addAction(KToolBar *tbar, const char* actionName)
356
QAction *a = d->ac->action(actionName);
361
void KexiTabbedToolBar::addAction(const QString& toolBarName, QAction *action)
365
KToolBar *tbar = d->toolbarsForName[toolBarName];
368
tbar->addAction(action);
371
void KexiTabbedToolBar::addSeparatorAndAction(KToolBar *tbar, const char* actionName)
373
QAction *a = d->ac->action(actionName);
375
tbar->addSeparator();
380
void KexiTabbedToolBar::appendWidgetToToolbar(const QString& name, QWidget* widget)
382
KToolBar *tbar = d->toolbarsForName[name];
386
QAction *action = tbar->addWidget(widget);
387
d->extraActions.insert(widget, action);
390
void KexiTabbedToolBar::setWidgetVisibleInToolbar(QWidget* widget, bool visible)
392
QAction *action = d->extraActions[widget];
396
action->setVisible(visible);
400
class KexiTopDockWidget : public QDockWidget
403
KexiTopDockWidget(QWidget *parent)
404
: QDockWidget(parent)
406
setFeatures(QDockWidget::NoDockWidgetFeatures);
407
QWidget *topSpacer = new QWidget(this);
408
topSpacer->setFixedHeight( 10 );//KDialog::marginHint() );
409
setTitleBarWidget(topSpacer);
410
m_widget = new KTabWidget(this);
411
setWidget( m_widget );
412
// QMenuBar *menu = new QMenuBar(m_widget);
413
// menu->addAction( i18n("Open..") );
414
// m_widget->addTab( menu, i18n("Project") );
416
KToolBar *tbar = new KToolBar(m_widget);
417
m_widget->addTab( tbar, i18n("Project") );
419
tbar->addAction( KIcon("document-new"), i18n("&New...") );
420
KAction* a = KStandardAction::open(0, 0, this);
421
tbar->addAction( a->icon(), a->text() );
422
a = KStandardAction::close(0, 0, this);
423
tbar->addAction( a->icon(), a->text() );
425
m_widget->addTab( new QWidget(m_widget), i18n("Create") );
426
m_widget->addTab( new QWidget(m_widget), i18n("External Data") );
427
m_widget->addTab( new QWidget(m_widget), i18n("Tools") );
428
m_widget->addTab( new QWidget(m_widget), i18n("Help") );
434
KTabWidget *m_widget;
438
//! @short A widget being main part of KexiMainWindow
439
class KexiMainWidget : public KMainWindow
444
virtual ~KexiMainWidget();
446
void setParent(KexiMainWindow* mainWindow) {
447
KMainWindow::setParent(mainWindow); m_mainWindow = mainWindow;
450
KexiMainWindowTabWidget* tabWidget() const {
454
virtual bool queryClose();
455
virtual bool queryExit();
457
void slotCurrentTabIndexChanged(int index);
460
void setupCentralWidget();
462
KexiMainWindowTabWidget* m_tabWidget;
463
KexiMainWindow *m_mainWindow;
464
QPointer<KexiWindow> m_previouslyActiveWindow;
466
friend class KexiMainWindow;
467
friend class KexiMainWindowTabWidget;
470
KexiMainWidget::KexiMainWidget()
471
: KMainWindow(0, Qt::Widget)
474
setupCentralWidget();
477
KexiMainWidget::~KexiMainWidget()
481
void KexiMainWidget::setupCentralWidget()
483
QWidget *centralWidget = new QWidget(this);
484
QVBoxLayout *centralWidgetLyr = new QVBoxLayout(centralWidget);
485
m_tabWidget = new KexiMainWindowTabWidget(centralWidget, this);
486
connect(m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentTabIndexChanged(int)));
487
centralWidgetLyr->setContentsMargins(0, 0, 0, 0);
488
//centralWidgetLyr->setContentsMargins( 0, KDialog::marginHint()/2, 0, 0 );
489
centralWidgetLyr->addWidget(m_tabWidget);
490
setCentralWidget(centralWidget);
491
// connect( m_tabWidget, SIGNAL( closeTab() ), m_mainWindow, SLOT(closeCurrentWindow()) );
494
bool KexiMainWidget::queryClose()
496
return m_mainWindow ? m_mainWindow->queryClose() : true;
499
bool KexiMainWidget::queryExit()
501
return m_mainWindow ? m_mainWindow->queryExit() : true;
504
void KexiMainWidget::slotCurrentTabIndexChanged(int index)
506
KexiWindowContainer* cont = dynamic_cast<KexiWindowContainer*>(m_tabWidget->widget(index));
507
if (! cont || (KexiWindow*)m_previouslyActiveWindow == cont->window)
510
m_mainWindow->activeWindowChanged(cont->window, (KexiWindow*)m_previouslyActiveWindow);
511
m_previouslyActiveWindow = cont->window;
514
//------------------------------------------
516
//! @internal safer dictionary
517
typedef QMap< int, KexiWindow* > KexiWindowDict;
520
class KexiMainWindow::Private
523
Private(KexiMainWindow* w)
526
dummy_KXMLGUIClient = new KXMLGUIClient();
527
dummy_KXMLGUIFactory = new KXMLGUIFactory(0);
529
actionCollection = new KActionCollection(w);
531
propEditorDockWidget = 0;
533
//2.0: unused propEditorToolWindow=0;
534
propEditorTabWidget = 0;
535
KexiProjectData *pdata = Kexi::startupHandler().projectData();
536
userMode = Kexi::startupHandler().forcedUserMode() /* <-- simply forced the user mode */
537
/* project has 'user mode' set as default and not 'design mode' override is found: */
538
|| (pdata && pdata->userMode() && !Kexi::startupHandler().forcedDesignMode());
539
isProjectNavigatorVisible = Kexi::startupHandler().isProjectNavigatorVisible();
541
//2.0: unused navToolWindow=0;
543
config = KGlobal::config();
544
curWindowGUIClient = 0;
545
curWindowViewGUIClient = 0;
546
closedWindowGUIClient = 0;
547
closedWindowViewGUIClient = 0;
551
//2.0: unused block_KMdiMainFrm_eventFilter=false;
552
focus_before_popup = 0;
554
//moved privateIDCounter=0;
556
action_view_propeditor = 0;
557
action_view_mainarea = 0;
558
action_open_recent_projects_title_id = -1;
559
action_open_recent_connections_title_id = -1;
560
forceWindowClosing = false;
561
insideCloseWindow = false;
562
#ifndef KEXI_NO_PENDING_DIALOGS
563
actionToExecuteWhenPendingJobsAreFinished = NoAction;
565
// callSlotLastChildViewClosedAfterCloseDialog=false;
567
showImportantInfoOnStartup = true;
568
// disableErrorMessages=false;
569
// last_checked_mode=0;
570
propEditorDockSeparatorPos = -1;
571
navDockSeparatorPos = -1;
572
// navDockSeparatorPosWithAutoOpen=-1;
574
windowExistedBeforeCloseProject = false;
575
#ifndef KEXI_SHOW_UNIMPLEMENTED
576
dummy_action = new KActionMenu(QString(), wnd);
578
maximizeFirstOpenedChildFrm = false;
579
#ifdef HAVE_KNEWSTUFF
582
//2.0: unused mdiModeToSwitchAfterRestart = (KMdi::MdiMode)0;
583
forceShowProjectNavigatorOnCreation = false;
584
forceHideProjectNavigatorOnCreation = false;
585
navWasVisibleBeforeProjectClosing = false;
586
saveSettingsForShowProjectNavigator = true;
587
propertyEditorCollapsed = false;
588
enable_slotPropertyEditorVisibilityChanged = true;
591
qDeleteAll(m_openedCustomObjectsForItem);
594
#ifndef KEXI_NO_PENDING_DIALOGS
595
//! Job type. Currently used for marking items as being opened or closed.
596
enum PendingJobType {
602
KexiWindow *openedWindowFor(const KexiPart::Item* item, PendingJobType &pendingType) {
603
return openedWindowFor(item->identifier(), pendingType);
606
KexiWindow *openedWindowFor(int identifier, PendingJobType &pendingType) {
607
//todo(threads) QMutexLocker dialogsLocker( &dialogsMutex );
608
QHash<int, PendingJobType>::ConstIterator it = pendingWindows.find(identifier);
609
if (it == pendingWindows.end())
612
pendingType = it.value();
614
if (pendingType == WindowOpeningJob) {
617
return windows.contains(identifier) ? (KexiWindow*)windows.value(identifier) : 0;
620
KexiWindow *openedWindowFor(const KexiPart::Item* item) {
621
return openedWindowFor(item->identifier());
624
KexiWindow *openedWindowFor(int identifier) {
625
//todo(threads) QMutexLocker dialogsLocker( &dialogsMutex );
626
return windows.contains(identifier) ? (KexiWindow*)windows.value(identifier) : 0;
630
void insertWindow(KexiWindow *window) {
631
//todo(threads) QMutexLocker dialogsLocker( &dialogsMutex );
632
windows.insert(window->id(), window);
633
#ifndef KEXI_NO_PENDING_DIALOGS
634
pendingWindows.remove(window->id());
638
#ifndef KEXI_NO_PENDING_DIALOGS
639
void addItemToPendingWindows(const KexiPart::Item* item, PendingJobType jobType) {
640
//todo(threads) QMutexLocker dialogsLocker( &dialogsMutex );
641
pendingWindows.insert(item->identifier(), jobType);
644
bool pendingWindowsExist() {
645
if (pendingWindows.begin() != pendingWindows.end())
646
kDebug() << pendingWindows.constBegin().key() << " " << (int)pendingWindows.constBegin().value();
647
//todo(threads) QMutexLocker dialogsLocker( &dialogsMutex );
648
return !pendingWindows.isEmpty();
652
void updateWindowId(KexiWindow *window, int oldItemID) {
653
//todo(threads) QMutexLocker dialogsLocker( &dialogsMutex );
654
windows.remove(oldItemID);
655
#ifndef KEXI_NO_PENDING_DIALOGS
656
pendingWindows.remove(oldItemID);
658
windows.insert(window->id(), window);
661
void removeWindow(int identifier) {
662
//todo(threads) QMutexLocker dialogsLocker( &dialogsMutex );
663
windows.remove(identifier);
666
#ifndef KEXI_NO_PENDING_DIALOGS
667
void removePendingWindow(int identifier) {
668
//todo(threads) QMutexLocker dialogsLocker( &dialogsMutex );
669
pendingWindows.remove(identifier);
673
uint openedWindowsCount() {
674
//todo(threads) QMutexLocker dialogsLocker( &dialogsMutex );
675
return windows.count();
678
//! Used in KexiMainWindowe::closeProject()
679
void clearWindows() {
680
//todo(threads) QMutexLocker dialogsLocker( &dialogsMutex );
682
#ifndef KEXI_NO_PENDING_DIALOGS
683
pendingWindows.clear();
687
/* UNUSED, see KexiToggleViewModeAction
688
// Toggles last checked view mode radio action, if available.
689
void toggleLastCheckedMode()
691
if (!wnd->currentWindow())
693
KToggleAction *ta = actions_for_view_modes.value( (int)wnd->currentWindow()->currentViewMode() );
695
ta->setChecked(true);
696
// if (!last_checked_mode)
698
// last_checked_mode->setChecked(true);
702
void updatePropEditorDockWidthInfo() {
704
KDockWidget *dw = (KDockWidget *)propEditor->parentWidget();
705
#if defined(KDOCKWIDGET_P)
706
KDockSplitter *ds = (KDockSplitter *)dw->parentWidget();
708
propEditorDockSeparatorPos = ds->separatorPosInPercent();*/
709
/* if (propEditorDockSeparatorPos<=0) {
710
config->setGroup("MainWindow");
711
propEditorDockSeparatorPos = config->readEntry("RightDockPosition", 80);
712
ds->setSeparatorPos(propEditorDockSeparatorPos, true);
719
void showStartProcessMsg(const QStringList& args) {
720
wnd->showErrorMessage(i18n("Could not start %1 application.", QString(KEXI_APP_NAME)),
721
i18n("Command \"%1\" failed.", args.join(" ")));
724
/* void hideMenuItem(const QString& menuName, const QString& itemText, bool alsoSeparator)
726
Q3PopupMenu *pm = popups[menuName.toLatin1()];
729
const QList<QAction*> actions( pm->actions() );
730
bool nowHideSeparator = false;
731
foreach( QAction *action, actions ) {
732
kDebug() << action->text();
733
if (nowHideSeparator) {
734
if (action->isSeparator())
735
action->setVisible(false);
738
else if (action->text().toLower().trimmed() == itemText.toLower().trimmed()) {
740
#warning OK? this should only hide menu item, not global action... action->setVisible(false);
742
action->setVisible(false);
744
nowHideSeparator = true; //continue look to find separtator, if present
751
void disableMenuItem(const QString& menuName, const QString& itemText)
754
#warning reimplement disableMenuItem()
756
#pragma WARNING( reimplement disableMenuItem() )
758
Q3PopupMenu *pm = popups[menuName.toLatin1()];
761
const QList<QAction*> actions( pm->actions() );
762
foreach( QAction *action, actions ) {
763
if (action->text().toLower().trimmed()==itemText.toLower().trimmed()) {
764
action->setEnabled(false);
770
//! Updates Property Editor Pane's visibility for the current window and the @a viewMode view mode.
771
/*! @a info can be provided to hadle cases when current window is not yet defined (in openObject()). */
772
void updatePropEditorVisibility(Kexi::ViewMode viewMode, KexiPart::Info *info = 0) {
773
if (!propEditorDockWidget)
775
KexiWindow *currentWindow = wnd->currentWindow();
776
if (!info && currentWindow) {
777
info = currentWindow->part()->info();
779
const bool visible = (viewMode == Kexi::DesignViewMode)
780
&& ((currentWindow && currentWindow->propertySet()) || info->isPropertyEditorAlwaysVisibleInDesignMode());
781
kDebug() << "visible == " << visible;
782
enable_slotPropertyEditorVisibilityChanged = false;
783
if (visible && propertyEditorCollapsed) { // used when we're switching back to a window with propeditor available but collapsed
784
propEditorDockWidget->setVisible(!visible);
785
setPropertyEditorTabBarVisible(true);
788
propEditorDockWidget->setVisible(visible);
789
setPropertyEditorTabBarVisible(false);
791
enable_slotPropertyEditorVisibilityChanged = true;
794
void setPropertyEditorTabBarVisible(bool visible) {
795
KMultiTabBar *mtbar = multiTabBars[KMultiTabBar::Right];
796
int id = PROPERTY_EDITOR_TABBAR_ID;
798
mtbar->removeTab(id);
800
else if (!mtbar->tab(id)) {
801
QString t(propEditorDockWidget->windowTitle());
803
mtbar->appendTab(QPixmap(), id, t);
804
KMultiTabBarTab *tab = mtbar->tab(id);
805
QObject::connect(tab, SIGNAL(clicked(int)), wnd, SLOT(slotMultiTabBarTabClicked(int)));
811
void restoreNavigatorWidth() {
812
#if defined(KDOCKWIDGET_P)
813
if (wnd->mdiMode() == KMdi::ChildframeMode || wnd->mdiMode() == KMdi::TabPageMode) {
814
KDockWidget *dw = (KDockWidget *)nav->parentWidget();
815
KDockSplitter *ds = (KDockSplitter *)dw->parentWidget();
816
// ds->setKeepSize(true);
818
config->setGroup("MainWindow");
819
if (wasAutoOpen) //(dw2->isVisible())
820
// ds->setSeparatorPosInPercent( 100 * nav->width() / wnd->width() );
821
ds->setSeparatorPosInPercent(
822
qMax(qMax(config->readEntry("LeftDockPositionWithAutoOpen", 20),
823
config->readEntry("LeftDockPosition", 20)), 20)
826
ds->setSeparatorPosInPercent(
827
qMax(20, config->readEntry("LeftDockPosition", 20/* % */)));
829
// dw->resize( d->config->readEntry("LeftDockPosition", 115/* % */), dw->height() );
830
//if (!wasAutoOpen) //(dw2->isVisible())
831
// ds->setSeparatorPos( ds->separatorPos(), true );
839
type *openedCustomObjectsForItem(KexiPart::Item* item, const char* name) {
840
if (!item || !name) {
842
"KexiMainWindow::Private::openedCustomObjectsForItem(): !item || !name";
845
QByteArray key(QByteArray::number(item->identifier()) + name);
846
return qobject_cast<type*>(m_openedCustomObjectsForItem.value(key));
849
void addOpenedCustomObjectForItem(KexiPart::Item* item, QObject* object, const char* name) {
850
QByteArray key(QByteArray::number(item->identifier()) + name);
851
m_openedCustomObjectsForItem.insert(key, object);
854
KexiFindDialog *findDialog() {
856
m_findDialog = new KexiFindDialog(wnd);
857
m_findDialog->setActions(action_edit_findnext, action_edit_findprev,
858
action_edit_replace, action_edit_replace_all);
859
/* connect(m_findDialog, SIGNAL(findNext()), action_edit_findnext, SLOT(trigger()));
860
connect(m_findDialog, SIGNAL(find()), wnd, SLOT(slotEditFindNext()));
861
connect(m_findDialog, SIGNAL(replace()), wnd, SLOT(slotEditReplaceNext()));
862
connect(m_findDialog, SIGNAL(replaceAll()), wnd, SLOT(slotEditReplaceAll()));*/
867
/*! Updates the find/replace dialog depending on the active view.
868
Nothing is performed if the dialog is not instantiated yet or is invisible. */
869
void updateFindDialogContents(bool createIfDoesNotExist = false) {
870
if (!wnd->currentWindow())
872
if (!createIfDoesNotExist && (!m_findDialog || !m_findDialog->isVisible()))
874
KexiSearchAndReplaceViewInterface* iface = currentViewSupportingSearchAndReplaceInterface();
877
m_findDialog->setButtonsEnabled(false);
878
m_findDialog->setLookInColumnList(QStringList(), QStringList());
882
//! @todo use ->caption() here, depending on global settings related to displaying captions
883
findDialog()->setObjectNameForCaption(wnd->currentWindow()->partItem()->name());
885
QStringList columnNames;
886
QStringList columnCaptions;
887
QString currentColumnName; // for 'look in'
888
if (!iface->setupFindAndReplace(columnNames, columnCaptions, currentColumnName)) {
889
m_findDialog->setButtonsEnabled(false);
890
m_findDialog->setLookInColumnList(QStringList(), QStringList());
893
m_findDialog->setButtonsEnabled(true);
895
/* //update "look in" list
896
KexiTableViewColumn::List columns( dataAwareObject()->data()->columns );
897
QStringList columnNames;
898
QStringList columnCaptions;
899
for (KexiTableViewColumn::ListIterator it(columns); it.current(); ++it) {
900
if (!it.current()->visible())
902
columnNames.append( it.current()->field()->name() );
903
columnCaptions.append( it.current()->captionAliasOrName() );
905
const QString prevColumnName(m_findDialog->currentLookInColumnName());
906
m_findDialog->setLookInColumnList(columnNames, columnCaptions);
907
m_findDialog->setCurrentLookInColumnName(prevColumnName);
910
//! \return the current view if it supports \a actionName, otherwise returns 0.
911
KexiView *currentViewSupportingAction(const char* actionName) const {
912
if (!wnd->currentWindow())
914
KexiView *view = wnd->currentWindow()->selectedView();
917
QAction *action = view->sharedAction(actionName);
918
if (!action || !action->isEnabled())
923
//! \return the current view if it supports KexiSearchAndReplaceViewInterface.
924
KexiSearchAndReplaceViewInterface* currentViewSupportingSearchAndReplaceInterface() const {
925
if (!wnd->currentWindow())
927
KexiView *view = wnd->currentWindow()->selectedView();
930
return dynamic_cast<KexiSearchAndReplaceViewInterface*>(view);
933
KXMLGUIClient* dummy_KXMLGUIClient;
934
KXMLGUIFactory* dummy_KXMLGUIFactory;
937
KexiMainWidget *mainWidget;
938
// KexiMainWindowTabWidget *tabWidget;
939
KActionCollection *actionCollection;
940
KexiStatusBar *statusBar;
943
KSharedConfig::Ptr config;
944
#ifndef KEXI_NO_CTXT_HELP
945
KexiContextHelp *ctxHelp;
947
KexiProjectListView *nav;
948
KexiTabbedToolBar *tabbedToolBar;
949
KexiDockWidget *navDockWidget;
950
KTabWidget *propEditorTabWidget;
951
KexiDockWidget *propEditorDockWidget;
952
QPointer<KexiDockableWidget> propEditorDockableWidget;
953
//! poits to kexi part which has been previously used to setup proppanel's tabs using
954
//! KexiPart::setupCustomPropertyPanelTabs(), in updateCustomPropertyPanelTabs().
955
QPointer<KexiPart::Part> partForPreviouslySetupPropertyPanelTabs;
956
QMap<KexiPart::Part*, int> recentlySelectedPropertyPanelPages;
957
QPointer<KexiPropertyEditorView> propEditor;
958
QPointer<KoProperty::Set> propertySet;
960
KXMLGUIClient *curWindowGUIClient, *curWindowViewGUIClient,
961
*closedWindowGUIClient, *closedWindowViewGUIClient;
962
//unused QPointer<KexiWindow> curWindow;
964
KexiNameDialog *nameDialog;
966
QTimer timer; //helper timer
967
// QSignalMapper *actionMapper;
969
//! @todo move menu handling outside
970
// Q3AsciiDict<QPopupMenu> popups; //list of menu popups
971
// QMenu *createMenu;
973
// QString origAppCaption; //<! original application's caption (without project name)
974
QString appCaptionPrefix; //<! application's caption prefix - prj name (if opened), else: null
976
#ifndef KEXI_SHOW_UNIMPLEMENTED
977
KActionMenu *dummy_action;
981
KAction *action_save, *action_save_as, *action_close,
982
*action_project_properties, *action_open_recent_more,
983
*action_project_relations, *action_project_import_data_table,
984
*action_project_export_data_table,
985
*action_project_print, *action_project_print_preview,
986
*action_project_print_setup;
987
// KRecentFilesAction *action_open_recent;
988
KActionMenu *action_open_recent, *action_show_other;
989
// int action_open_recent_more_id;
990
int action_open_recent_projects_title_id,
991
action_open_recent_connections_title_id;
994
KAction *action_edit_delete, *action_edit_delete_row,
995
*action_edit_cut, *action_edit_copy, *action_edit_paste,
996
*action_edit_find, *action_edit_findnext, *action_edit_findprev,
997
*action_edit_replace, *action_edit_replace_all,
998
*action_edit_select_all,
999
*action_edit_undo, *action_edit_redo,
1000
*action_edit_insert_empty_row,
1001
*action_edit_edititem, *action_edit_clear_table,
1002
*action_edit_paste_special_data_table,
1003
*action_edit_copy_special_data_table;
1006
KAction *action_view_nav, *action_view_propeditor, *action_view_mainarea;
1007
//! todo see FormManager::createActions() for usage
1008
/* UNUSED, see KexiToggleViewModeAction
1009
QActionGroup* action_view_mode;
1010
KToggleAction *action_view_data_mode, *action_view_design_mode, *action_view_text_mode;
1011
QHash<int, KToggleAction*> actions_for_view_modes;*/
1012
#ifndef KEXI_NO_CTXT_HELP
1013
KToggleAction *action_show_helper;
1016
KAction *action_data_save_row;
1017
KAction *action_data_cancel_row_changes;
1018
KAction *action_data_execute;
1021
KAction *action_format_font;
1024
KAction *action_tools_data_migration, *action_tools_compact_database, *action_tools_data_import;
1025
KActionMenu *action_tools_scripts;
1028
KAction *action_window_next, *action_window_previous;
1031
KAction *action_configure;
1033
//! for dock windows
1034
//2.0: unused KMdiToolViewAccessor* navToolWindow;
1035
//2.0: unused KMdiToolViewAccessor* propEditorToolWindow;
1037
QPointer<QWidget> focus_before_popup;
1038
// KexiRelationPart *relationPart;
1040
//moved int privateIDCounter; //!< counter: ID for private "document" like Relations window
1042
//! Set to true only in destructor, used by closeWindow() to know if
1043
//! user can cancel window closing. If true user even doesn't see any messages
1044
//! before closing a window. This is for extremely sanity... and shouldn't be even needed.
1045
bool forceWindowClosing;
1047
//! Indicates that we're inside closeWindow() method - to avoid inf. recursion
1048
//! on window removing
1049
bool insideCloseWindow;
1051
#ifndef KEXI_NO_PENDING_DIALOGS
1052
//! Used in executeActionWhenPendingJobsAreFinished().
1053
enum ActionToExecuteWhenPendingJobsAreFinished {
1058
ActionToExecuteWhenPendingJobsAreFinished actionToExecuteWhenPendingJobsAreFinished;
1060
void executeActionWhenPendingJobsAreFinished() {
1061
ActionToExecuteWhenPendingJobsAreFinished a = actionToExecuteWhenPendingJobsAreFinished;
1062
actionToExecuteWhenPendingJobsAreFinished = NoAction;
1067
case CloseProjectAction:
1068
wnd->closeProject();
1075
//! Used for delayed windows closing for 'close all'
1076
QList<KexiWindow*> windowsToClose;
1078
//! Opened page setup dialogs, used by printOrPrintPreviewForItem().
1079
QHash<int, KexiWindow*> pageSetupWindows;
1081
/*! A map from Kexi dialog to "print setup" part item's ID of the data item
1082
used by closeWindow() to find an ID of the data item, so the entry
1083
can be removed from pageSetupWindows dictionary. */
1084
QMap<int, int> pageSetupWindowItemID2dataItemID_map;
1086
//! Used in several places to show info dialog at startup (only once per session)
1087
//! before displaying other stuff
1088
bool showImportantInfoOnStartup;
1090
// //! Used sometimes to block showErrorMessage()
1091
// bool disableErrorMessages;
1093
//! Indicates if project is started in User Mode
1096
//! Indicates if project navigator should be visible
1097
bool isProjectNavigatorVisible;
1099
//! Used on opening 1st child window
1100
bool maximizeFirstOpenedChildFrm;
1102
//! Set in restoreSettings() and used in initNavigator()
1103
//! to customize navigator visibility on startup
1104
bool forceShowProjectNavigatorOnCreation;
1105
bool forceHideProjectNavigatorOnCreation;
1107
bool navWasVisibleBeforeProjectClosing;
1108
bool saveSettingsForShowProjectNavigator;
1109
#ifdef HAVE_KNEWSTUFF
1110
KexiNewStuff *newStuff;
1113
//! Used by openedCustomObjectsForItem() and addOpenedCustomObjectForItem()
1114
QHash<QByteArray, QObject*> m_openedCustomObjectsForItem;
1116
int propEditorDockSeparatorPos, navDockSeparatorPos;
1117
// int navDockSeparatorPosWithAutoOpen;
1119
bool windowExistedBeforeCloseProject;
1121
//2.0: unused KMdi::MdiMode mdiModeToSwitchAfterRestart;
1123
QMap<KMultiTabBar::KMultiTabBarPosition, KMultiTabBar*> multiTabBars;
1124
bool propertyEditorCollapsed;
1126
bool enable_slotPropertyEditorVisibilityChanged;
1129
//! @todo move to KexiProject
1130
KexiWindowDict windows;
1131
#ifndef KEXI_NO_PROCESS_EVENTS
1132
QHash<int, PendingJobType> pendingWindows; //!< part item identifiers for windows whoose opening has been started
1133
//todo(threads) QMutex dialogsMutex; //!< used for locking windows and pendingWindows dicts
1135
KexiFindDialog *m_findDialog;