~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to kexi/main/KexiMainWindow_p.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-09-21 15:36:35 UTC
  • mfrom: (1.4.1 upstream) (60.2.11 maverick)
  • Revision ID: james.westby@ubuntu.com-20100921153635-6tejqkiro2u21ydi
Tags: 1:2.2.2-0ubuntu3
Add kubuntu_03_fix-crash-on-closing-sqlite-connection-2.2.2.diff and
kubuntu_04_support-large-memo-values-for-msaccess-2.2.2.diff as
recommended by upstream http://kexi-
project.org/wiki/wikiview/index.php@Kexi2.2_Patches.html#sqlite_stab
ility

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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>
 
4
 
 
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.
 
9
 
 
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.
 
14
 
 
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.
 
19
*/
 
20
 
 
21
#ifndef KEXIMAINWINDOW_P_H
 
22
#define KEXIMAINWINDOW_P_H
 
23
 
 
24
#define KEXI_NO_PROCESS_EVENTS
 
25
 
 
26
#ifdef KEXI_NO_PROCESS_EVENTS
 
27
# define KEXI_NO_PENDING_DIALOGS
 
28
#endif
 
29
 
 
30
#define PROJECT_NAVIGATOR_TABBAR_ID 0
 
31
#define PROPERTY_EDITOR_TABBAR_ID 1
 
32
 
 
33
#include <KToolBar>
 
34
#include <QGroupBox>
 
35
#include <QHBoxLayout>
 
36
 
 
37
#include <kexiutils/SmallToolButton.h>
 
38
 
 
39
//! @short Main application's tabbed toolbar
 
40
class KexiTabbedToolBar : public KTabWidget
 
41
{
 
42
    Q_OBJECT
 
43
public:
 
44
    KexiTabbedToolBar(QWidget *parent);
 
45
    virtual ~KexiTabbedToolBar();
 
46
 
 
47
    KToolBar *createWidgetToolBar() const;
 
48
 
 
49
    KToolBar *toolBar(const QString& name) const;
 
50
 
 
51
    void appendWidgetToToolbar(const QString& name, QWidget* widget);
 
52
 
 
53
    void setWidgetVisibleInToolbar(QWidget* widget, bool visible);
 
54
//    void removeWidgetFromToolbar(const QString& name);
 
55
 
 
56
//! @todo replace with the final Actions API
 
57
    void addAction(const QString& toolBarName, QAction *action);
 
58
 
 
59
protected:
 
60
    virtual void mouseMoveEvent(QMouseEvent* event);
 
61
    virtual void leaveEvent(QEvent* event);
 
62
 
 
63
protected slots:
 
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();
 
69
private:
 
70
    void addAction(KToolBar *tbar, const char* actionName);
 
71
    void addSeparatorAndAction(KToolBar *tbar, const char* actionName);
 
72
 
 
73
    class Private;
 
74
    Private * const d;
 
75
};
 
76
 
 
77
//! @internal window container created to speedup opening new tabs
 
78
class KexiWindowContainer : public QWidget
 
79
{
 
80
public:
 
81
    KexiWindowContainer(QWidget* parent)
 
82
            : QWidget(parent)
 
83
            , window(0)
 
84
            , lyr(new QVBoxLayout(this)) {
 
85
        lyr->setContentsMargins(0, 0, 0, 0);
 
86
    }
 
87
    void setWindow(KexiWindow* w) {
 
88
        window = w;
 
89
        if (w)
 
90
            lyr->addWidget(w);
 
91
    }
 
92
    KexiWindow *window;
 
93
private:
 
94
    QVBoxLayout *lyr;
 
95
};
 
96
 
 
97
//! @internal
 
98
class KexiTabbedToolBar::Private
 
99
{
 
100
public:
 
101
    Private(KexiTabbedToolBar *t)
 
102
            : q(t), createWidgetToolBar(0), tabToRaise(-1)
 
103
    {
 
104
        tabRaiseTimer.setSingleShot(true);
 
105
        tabRaiseTimer.setInterval(300);
 
106
    }
 
107
 
 
108
    KToolBar *createToolBar(const char *name, const QString& caption)
 
109
    {
 
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);
 
115
        return tbar;
 
116
    }
 
117
 
 
118
    KexiTabbedToolBar *q;
 
119
    KActionCollection *ac;
 
120
    int createId;
 
121
    KToolBar *createWidgetToolBar;
 
122
    //! Used for delayed tab raising
 
123
    int tabToRaise;
 
124
    //! Used for delayed tab raising
 
125
    QTimer tabRaiseTimer;
 
126
    //! Toolbars for name
 
127
    QHash<QString, KToolBar*> toolbarsForName;
 
128
    QHash<QWidget*, QAction*> extraActions;
 
129
};
 
130
 
 
131
KexiTabbedToolBar::KexiTabbedToolBar(QWidget *parent)
 
132
        : KTabWidget(parent)
 
133
        , d(new Private(this))
 
134
{
 
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()));
 
138
 
 
139
    d->ac = KexiMainWindowIface::global()->actionCollection();
 
140
    const bool userMode = KexiMainWindowIface::global()->userMode();
 
141
    KToolBar *tbar;
 
142
    QAction* a;
 
143
 
 
144
    KexiUtils::smallFont(this/*init*/);
 
145
    slotSettingsChanged(KGlobalSettings::FontChanged);
 
146
    connect(KGlobalSettings::self(), SIGNAL(settingsChanged(int)), this, SLOT(slotSettingsChanged(int)));
 
147
 
 
148
// KToolBar* helpToolBar = new KToolBar(this);
 
149
// helpToolBar->setFont(Kexi::smallFont());
 
150
    /*
 
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);*/
 
158
 
 
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);
 
169
 
 
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");
 
178
#endif
 
179
    addSeparatorAndAction(tbar, "quit");
 
180
 
 
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");
 
192
 
 
193
    if (!userMode) {
 
194
        d->createWidgetToolBar = d->createToolBar("create", i18n("Create"));
 
195
    }
 
196
 
 
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");
 
202
    if (!userMode)
 
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");
 
211
 
 
212
    tbar = d->createToolBar("external", i18n("External Data"));
 
213
 
 
214
    /*   QGroupBox *gbox = new QGroupBox( i18n("Import"), tbar );
 
215
      gbox->setFlat(true);
 
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);
 
223
    */
 
224
    if (!userMode) {
 
225
        addAction(tbar, "project_import_data_table");
 
226
        addAction(tbar, "tools_import_tables");
 
227
    }
 
228
    /*   gbox = new QGroupBox( i18n("Export"), tbar );
 
229
      gbox->setFlat(true);
 
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);
 
237
    */
 
238
    addSeparatorAndAction(tbar, "project_export_data_table");
 
239
 
 
240
    tbar = d->createToolBar("tools", i18n("Tools"));
 
241
    addAction(tbar, "tools_import_project");
 
242
    addAction(tbar, "tools_compact_database");
 
243
 
 
244
//! @todo move to form plugin
 
245
    tbar = d->createToolBar("form", i18n("Form Design"));
 
246
 
 
247
//! @todo move to report plugin
 
248
    tbar = d->createToolBar("report", i18n("Report Design"));
 
249
    
 
250
// tbar = new KToolBar(this);
 
251
// addTab( tbar, i18n("Settings") );
 
252
//moved up addAction(tbar, "options_configure_keybinding");
 
253
 
 
254
    /*moved up
 
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");
 
264
    */
 
265
 
 
266
    connect(this, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentChanged(int)));
 
267
    /*tmp
 
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 );
 
272
      setPalette( pal );*/
 
273
}
 
274
 
 
275
KexiTabbedToolBar::~KexiTabbedToolBar()
 
276
{
 
277
    delete d;
 
278
}
 
279
 
 
280
void KexiTabbedToolBar::slotSettingsChanged(int category)
 
281
{
 
282
    if (category == KGlobalSettings::FontChanged) {
 
283
        setFont(KGlobalSettings::menuFont());   // toolbar acts like a menu
 
284
    }
 
285
}
 
286
 
 
287
KToolBar* KexiTabbedToolBar::createWidgetToolBar() const
 
288
{
 
289
    return d->createWidgetToolBar;
 
290
}
 
291
 
 
292
void KexiTabbedToolBar::mouseMoveEvent(QMouseEvent* event)
 
293
{
 
294
    QPoint p = event->pos();
 
295
    int tab = tabBar()->tabAt(p);
 
296
    if (d->tabToRaise != -1 && (tab == -1 || tab == currentIndex())) {
 
297
        d->tabRaiseTimer.stop();
 
298
        d->tabToRaise = -1;
 
299
    } else if (d->tabToRaise != tab) {
 
300
        d->tabRaiseTimer.start();
 
301
        d->tabToRaise = tab;
 
302
    }
 
303
    KTabWidget::mouseMoveEvent(event);
 
304
}
 
305
 
 
306
void KexiTabbedToolBar::leaveEvent(QEvent* event)
 
307
{
 
308
    d->tabRaiseTimer.stop();
 
309
    d->tabToRaise = -1;
 
310
    KTabWidget::leaveEvent(event);
 
311
}
 
312
 
 
313
void KexiTabbedToolBar::slotCurrentChanged(int index)
 
314
{
 
315
    if (index == indexOf(d->createWidgetToolBar) && index != -1) {
 
316
        if (d->createWidgetToolBar->actions().isEmpty()) {
 
317
            QTimer::singleShot(10, this, SLOT(setupCreateWidgetToolbar()));
 
318
        }
 
319
    }
 
320
}
 
321
 
 
322
void KexiTabbedToolBar::setupCreateWidgetToolbar()
 
323
{
 
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));
 
329
        if (a) {
 
330
            d->createWidgetToolBar->addAction(a);//->icon(), a->text());
 
331
        } else {
 
332
            //! @todo err
 
333
        }
 
334
    }
 
335
}
 
336
 
 
337
void KexiTabbedToolBar::slotDelayedTabRaise()
 
338
{
 
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) {
 
342
        d->tabToRaise = -1;
 
343
    } else if (d->tabToRaise != -1) {
 
344
        setCurrentIndex(d->tabToRaise);
 
345
        d->tabToRaise = -1;
 
346
    }
 
347
}
 
348
 
 
349
KToolBar *KexiTabbedToolBar::toolBar(const QString& name) const
 
350
{
 
351
    return d->toolbarsForName[name];
 
352
}
 
353
 
 
354
void KexiTabbedToolBar::addAction(KToolBar *tbar, const char* actionName)
 
355
{
 
356
    QAction *a = d->ac->action(actionName);
 
357
    if (a)
 
358
        tbar->addAction(a);
 
359
}
 
360
 
 
361
void KexiTabbedToolBar::addAction(const QString& toolBarName, QAction *action)
 
362
{
 
363
    if (!action)
 
364
        return;
 
365
    KToolBar *tbar = d->toolbarsForName[toolBarName];
 
366
    if (!tbar)
 
367
        return;
 
368
    tbar->addAction(action);
 
369
}
 
370
 
 
371
void KexiTabbedToolBar::addSeparatorAndAction(KToolBar *tbar, const char* actionName)
 
372
{
 
373
    QAction *a = d->ac->action(actionName);
 
374
    if (a) {
 
375
        tbar->addSeparator();
 
376
        tbar->addAction(a);
 
377
    }
 
378
}
 
379
 
 
380
void KexiTabbedToolBar::appendWidgetToToolbar(const QString& name, QWidget* widget)
 
381
{
 
382
    KToolBar *tbar = d->toolbarsForName[name];
 
383
    if (!tbar) {
 
384
        return;
 
385
    }
 
386
    QAction *action = tbar->addWidget(widget);
 
387
    d->extraActions.insert(widget, action);
 
388
}
 
389
 
 
390
void KexiTabbedToolBar::setWidgetVisibleInToolbar(QWidget* widget, bool visible)
 
391
{
 
392
    QAction *action = d->extraActions[widget];
 
393
    if (!action) {
 
394
        return;
 
395
    }
 
396
    action->setVisible(visible);
 
397
}
 
398
 
 
399
/*
 
400
class KexiTopDockWidget : public QDockWidget
 
401
{
 
402
  public:
 
403
    KexiTopDockWidget(QWidget *parent)
 
404
     : QDockWidget(parent)
 
405
    {
 
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") );
 
415
 
 
416
      KToolBar *tbar = new KToolBar(m_widget);
 
417
      m_widget->addTab( tbar, i18n("Project") );
 
418
 
 
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() );
 
424
 
 
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") );
 
429
    }
 
430
    ~KexiTopDockWidget()
 
431
    {
 
432
    }
 
433
  private:
 
434
    KTabWidget *m_widget;
 
435
};
 
436
*/
 
437
 
 
438
//! @short A widget being main part of KexiMainWindow
 
439
class KexiMainWidget : public KMainWindow
 
440
{
 
441
    Q_OBJECT
 
442
public:
 
443
    KexiMainWidget();
 
444
    virtual ~KexiMainWidget();
 
445
 
 
446
    void setParent(KexiMainWindow* mainWindow) {
 
447
        KMainWindow::setParent(mainWindow); m_mainWindow = mainWindow;
 
448
    }
 
449
 
 
450
    KexiMainWindowTabWidget* tabWidget() const {
 
451
        return m_tabWidget;
 
452
    }
 
453
protected:
 
454
    virtual bool queryClose();
 
455
    virtual bool queryExit();
 
456
protected slots:
 
457
    void slotCurrentTabIndexChanged(int index);
 
458
 
 
459
private:
 
460
    void setupCentralWidget();
 
461
 
 
462
    KexiMainWindowTabWidget* m_tabWidget;
 
463
    KexiMainWindow *m_mainWindow;
 
464
    QPointer<KexiWindow> m_previouslyActiveWindow;
 
465
 
 
466
    friend class KexiMainWindow;
 
467
    friend class KexiMainWindowTabWidget;
 
468
};
 
469
 
 
470
KexiMainWidget::KexiMainWidget()
 
471
        : KMainWindow(0, Qt::Widget)
 
472
        , m_mainWindow(0)
 
473
{
 
474
    setupCentralWidget();
 
475
}
 
476
 
 
477
KexiMainWidget::~KexiMainWidget()
 
478
{
 
479
}
 
480
 
 
481
void KexiMainWidget::setupCentralWidget()
 
482
{
 
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()) );
 
492
}
 
493
 
 
494
bool KexiMainWidget::queryClose()
 
495
{
 
496
    return m_mainWindow ? m_mainWindow->queryClose() : true;
 
497
}
 
498
 
 
499
bool KexiMainWidget::queryExit()
 
500
{
 
501
    return m_mainWindow ? m_mainWindow->queryExit() : true;
 
502
}
 
503
 
 
504
void KexiMainWidget::slotCurrentTabIndexChanged(int index)
 
505
{
 
506
    KexiWindowContainer* cont = dynamic_cast<KexiWindowContainer*>(m_tabWidget->widget(index));
 
507
    if (! cont || (KexiWindow*)m_previouslyActiveWindow == cont->window)
 
508
        return;
 
509
    if (m_mainWindow)
 
510
        m_mainWindow->activeWindowChanged(cont->window, (KexiWindow*)m_previouslyActiveWindow);
 
511
    m_previouslyActiveWindow = cont->window;
 
512
}
 
513
 
 
514
//------------------------------------------
 
515
 
 
516
//! @internal safer dictionary
 
517
typedef QMap< int, KexiWindow* > KexiWindowDict;
 
518
 
 
519
//! @internal
 
520
class KexiMainWindow::Private
 
521
{
 
522
public:
 
523
    Private(KexiMainWindow* w)
 
524
//  : dialogs(401)
 
525
            : wnd(w) {
 
526
        dummy_KXMLGUIClient = new KXMLGUIClient();
 
527
        dummy_KXMLGUIFactory = new KXMLGUIFactory(0);
 
528
 
 
529
        actionCollection = new KActionCollection(w);
 
530
        propEditor = 0;
 
531
        propEditorDockWidget = 0;
 
532
        navDockWidget = 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();
 
540
        nav = 0;
 
541
//2.0: unused    navToolWindow=0;
 
542
        prj = 0;
 
543
        config = KGlobal::config();
 
544
        curWindowGUIClient = 0;
 
545
        curWindowViewGUIClient = 0;
 
546
        closedWindowGUIClient = 0;
 
547
        closedWindowViewGUIClient = 0;
 
548
        nameDialog = 0;
 
549
//  curWindow=0;
 
550
        m_findDialog = 0;
 
551
//2.0: unused  block_KMdiMainFrm_eventFilter=false;
 
552
        focus_before_popup = 0;
 
553
//  relationPart=0;
 
554
//moved  privateIDCounter=0;
 
555
        action_view_nav = 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;
 
564
#endif
 
565
//  callSlotLastChildViewClosedAfterCloseDialog=false;
 
566
//        createMenu = 0;
 
567
        showImportantInfoOnStartup = true;
 
568
//  disableErrorMessages=false;
 
569
//  last_checked_mode=0;
 
570
        propEditorDockSeparatorPos = -1;
 
571
        navDockSeparatorPos = -1;
 
572
//  navDockSeparatorPosWithAutoOpen=-1;
 
573
        wasAutoOpen = false;
 
574
        windowExistedBeforeCloseProject = false;
 
575
#ifndef KEXI_SHOW_UNIMPLEMENTED
 
576
        dummy_action = new KActionMenu(QString(), wnd);
 
577
#endif
 
578
        maximizeFirstOpenedChildFrm = false;
 
579
#ifdef HAVE_KNEWSTUFF
 
580
        newStuff = 0;
 
581
#endif
 
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;
 
589
    }
 
590
    ~Private() {
 
591
        qDeleteAll(m_openedCustomObjectsForItem);
 
592
    }
 
593
 
 
594
#ifndef KEXI_NO_PENDING_DIALOGS
 
595
    //! Job type. Currently used for marking items as being opened or closed.
 
596
    enum PendingJobType {
 
597
        NoJob = 0,
 
598
        WindowOpeningJob,
 
599
        WindowClosingJob
 
600
    };
 
601
 
 
602
    KexiWindow *openedWindowFor(const KexiPart::Item* item, PendingJobType &pendingType) {
 
603
        return openedWindowFor(item->identifier(), pendingType);
 
604
    }
 
605
 
 
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())
 
610
            pendingType = NoJob;
 
611
        else
 
612
            pendingType = it.value();
 
613
 
 
614
        if (pendingType == WindowOpeningJob) {
 
615
            return 0;
 
616
        }
 
617
        return windows.contains(identifier) ? (KexiWindow*)windows.value(identifier) : 0;
 
618
    }
 
619
#else
 
620
    KexiWindow *openedWindowFor(const KexiPart::Item* item) {
 
621
        return openedWindowFor(item->identifier());
 
622
    }
 
623
 
 
624
    KexiWindow *openedWindowFor(int identifier) {
 
625
//todo(threads)  QMutexLocker dialogsLocker( &dialogsMutex );
 
626
        return windows.contains(identifier) ? (KexiWindow*)windows.value(identifier) : 0;
 
627
    }
 
628
#endif
 
629
 
 
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());
 
635
#endif
 
636
    }
 
637
 
 
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);
 
642
    }
 
643
 
 
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();
 
649
    }
 
650
#endif
 
651
 
 
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);
 
657
#endif
 
658
        windows.insert(window->id(), window);
 
659
    }
 
660
 
 
661
    void removeWindow(int identifier) {
 
662
//todo(threads)  QMutexLocker dialogsLocker( &dialogsMutex );
 
663
        windows.remove(identifier);
 
664
    }
 
665
 
 
666
#ifndef KEXI_NO_PENDING_DIALOGS
 
667
    void removePendingWindow(int identifier) {
 
668
//todo(threads)  QMutexLocker dialogsLocker( &dialogsMutex );
 
669
        pendingWindows.remove(identifier);
 
670
    }
 
671
#endif
 
672
 
 
673
    uint openedWindowsCount() {
 
674
//todo(threads)  QMutexLocker dialogsLocker( &dialogsMutex );
 
675
        return windows.count();
 
676
    }
 
677
 
 
678
    //! Used in KexiMainWindowe::closeProject()
 
679
    void clearWindows() {
 
680
//todo(threads)  QMutexLocker dialogsLocker( &dialogsMutex );
 
681
        windows.clear();
 
682
#ifndef KEXI_NO_PENDING_DIALOGS
 
683
        pendingWindows.clear();
 
684
#endif
 
685
    }
 
686
 
 
687
    /* UNUSED, see KexiToggleViewModeAction
 
688
      // Toggles last checked view mode radio action, if available.
 
689
      void toggleLastCheckedMode()
 
690
      {
 
691
        if (!wnd->currentWindow())
 
692
          return;
 
693
        KToggleAction *ta = actions_for_view_modes.value( (int)wnd->currentWindow()->currentViewMode() );
 
694
        if (ta)
 
695
          ta->setChecked(true);
 
696
    //  if (!last_checked_mode)
 
697
    //   return;
 
698
    //  last_checked_mode->setChecked(true);
 
699
      }*/
 
700
 
 
701
    /*
 
702
    void updatePropEditorDockWidthInfo() {
 
703
        if (propEditor) {
 
704
          KDockWidget *dw = (KDockWidget *)propEditor->parentWidget();
 
705
    #if defined(KDOCKWIDGET_P)
 
706
          KDockSplitter *ds = (KDockSplitter *)dw->parentWidget();
 
707
          if (ds) {
 
708
            propEditorDockSeparatorPos = ds->separatorPosInPercent();*/
 
709
    /*    if (propEditorDockSeparatorPos<=0) {
 
710
                config->setGroup("MainWindow");
 
711
                propEditorDockSeparatorPos = config->readEntry("RightDockPosition", 80);
 
712
                ds->setSeparatorPos(propEditorDockSeparatorPos, true);
 
713
            }*/
 
714
    /*}
 
715
    #endif
 
716
    }
 
717
    }*/
 
718
 
 
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(" ")));
 
722
    }
 
723
 
 
724
    /* void hideMenuItem(const QString& menuName, const QString& itemText, bool alsoSeparator)
 
725
      {
 
726
        Q3PopupMenu *pm = popups[menuName.toLatin1()];
 
727
        if (!pm)
 
728
          return;
 
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);
 
736
            break;
 
737
          }
 
738
          else if (action->text().toLower().trimmed() == itemText.toLower().trimmed()) {
 
739
    #ifdef __GNUC__
 
740
    #warning OK? this should only hide menu item, not global action... action->setVisible(false);
 
741
    #endif
 
742
            action->setVisible(false);
 
743
            if (alsoSeparator)
 
744
              nowHideSeparator = true; //continue look to find separtator, if present
 
745
            else
 
746
              break;
 
747
          }
 
748
        }
 
749
      }
 
750
 
 
751
      void disableMenuItem(const QString& menuName, const QString& itemText)
 
752
      {
 
753
    #ifdef __GNUC__
 
754
    #warning reimplement disableMenuItem()
 
755
    #else
 
756
    #pragma WARNING( reimplement disableMenuItem() )
 
757
    #endif
 
758
        Q3PopupMenu *pm = popups[menuName.toLatin1()];
 
759
        if (!pm)
 
760
          return;
 
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);
 
765
            break;
 
766
          }
 
767
        }
 
768
      }*/
 
769
 
 
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)
 
774
            return;
 
775
        KexiWindow *currentWindow = wnd->currentWindow();
 
776
        if (!info && currentWindow) {
 
777
            info = currentWindow->part()->info();
 
778
        }
 
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);
 
786
        }
 
787
        else {
 
788
            propEditorDockWidget->setVisible(visible);
 
789
            setPropertyEditorTabBarVisible(false);
 
790
        }
 
791
        enable_slotPropertyEditorVisibilityChanged = true;
 
792
    }
 
793
 
 
794
    void setPropertyEditorTabBarVisible(bool visible) {
 
795
        KMultiTabBar *mtbar = multiTabBars[KMultiTabBar::Right];
 
796
        int id = PROPERTY_EDITOR_TABBAR_ID;
 
797
        if (!visible) {
 
798
            mtbar->removeTab(id);
 
799
        }
 
800
        else if (!mtbar->tab(id)) {
 
801
            QString t(propEditorDockWidget->windowTitle());
 
802
            t.remove('&');
 
803
            mtbar->appendTab(QPixmap(), id, t);
 
804
            KMultiTabBarTab *tab = mtbar->tab(id);
 
805
            QObject::connect(tab, SIGNAL(clicked(int)), wnd, SLOT(slotMultiTabBarTabClicked(int)));
 
806
        }
 
807
    }
 
808
 
 
809
//2.0: unused
 
810
#if 0
 
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);
 
817
 
 
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)
 
824
                );
 
825
            else
 
826
                ds->setSeparatorPosInPercent(
 
827
                    qMax(20, config->readEntry("LeftDockPosition", 20/* % */)));
 
828
 
 
829
            //   dw->resize( d->config->readEntry("LeftDockPosition", 115/* % */), dw->height() );
 
830
            //if (!wasAutoOpen) //(dw2->isVisible())
 
831
//     ds->setSeparatorPos( ds->separatorPos(), true );
 
832
        }
 
833
#endif
 
834
 
 
835
    }
 
836
#endif
 
837
 
 
838
    template<class type>
 
839
    type *openedCustomObjectsForItem(KexiPart::Item* item, const char* name) {
 
840
        if (!item || !name) {
 
841
            kWarning() <<
 
842
            "KexiMainWindow::Private::openedCustomObjectsForItem(): !item || !name";
 
843
            return 0;
 
844
        }
 
845
        QByteArray key(QByteArray::number(item->identifier()) + name);
 
846
        return qobject_cast<type*>(m_openedCustomObjectsForItem.value(key));
 
847
    }
 
848
 
 
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);
 
852
    }
 
853
 
 
854
    KexiFindDialog *findDialog() {
 
855
        if (!m_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()));*/
 
863
        }
 
864
        return m_findDialog;
 
865
    }
 
866
 
 
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())
 
871
            return;
 
872
        if (!createIfDoesNotExist && (!m_findDialog || !m_findDialog->isVisible()))
 
873
            return;
 
874
        KexiSearchAndReplaceViewInterface* iface = currentViewSupportingSearchAndReplaceInterface();
 
875
        if (!iface) {
 
876
            if (m_findDialog) {
 
877
                m_findDialog->setButtonsEnabled(false);
 
878
                m_findDialog->setLookInColumnList(QStringList(), QStringList());
 
879
            }
 
880
            return;
 
881
        }
 
882
//! @todo use ->caption() here, depending on global settings related to displaying captions
 
883
        findDialog()->setObjectNameForCaption(wnd->currentWindow()->partItem()->name());
 
884
 
 
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());
 
891
            return;
 
892
        }
 
893
        m_findDialog->setButtonsEnabled(true);
 
894
 
 
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())
 
901
              continue;
 
902
            columnNames.append( it.current()->field()->name() );
 
903
            columnCaptions.append( it.current()->captionAliasOrName() );
 
904
          }*/
 
905
        const QString prevColumnName(m_findDialog->currentLookInColumnName());
 
906
        m_findDialog->setLookInColumnList(columnNames, columnCaptions);
 
907
        m_findDialog->setCurrentLookInColumnName(prevColumnName);
 
908
    }
 
909
 
 
910
    //! \return the current view if it supports \a actionName, otherwise returns 0.
 
911
    KexiView *currentViewSupportingAction(const char* actionName) const {
 
912
        if (!wnd->currentWindow())
 
913
            return 0;
 
914
        KexiView *view = wnd->currentWindow()->selectedView();
 
915
        if (!view)
 
916
            return 0;
 
917
        QAction *action = view->sharedAction(actionName);
 
918
        if (!action || !action->isEnabled())
 
919
            return 0;
 
920
        return view;
 
921
    }
 
922
 
 
923
    //! \return the current view if it supports KexiSearchAndReplaceViewInterface.
 
924
    KexiSearchAndReplaceViewInterface* currentViewSupportingSearchAndReplaceInterface() const {
 
925
        if (!wnd->currentWindow())
 
926
            return 0;
 
927
        KexiView *view = wnd->currentWindow()->selectedView();
 
928
        if (!view)
 
929
            return 0;
 
930
        return dynamic_cast<KexiSearchAndReplaceViewInterface*>(view);
 
931
    }
 
932
 
 
933
    KXMLGUIClient* dummy_KXMLGUIClient;
 
934
    KXMLGUIFactory* dummy_KXMLGUIFactory;
 
935
 
 
936
    KexiMainWindow *wnd;
 
937
    KexiMainWidget *mainWidget;
 
938
//  KexiMainWindowTabWidget *tabWidget;
 
939
    KActionCollection *actionCollection;
 
940
    KexiStatusBar *statusBar;
 
941
    KHelpMenu *helpMenu;
 
942
    KexiProject *prj;
 
943
    KSharedConfig::Ptr config;
 
944
#ifndef KEXI_NO_CTXT_HELP
 
945
    KexiContextHelp *ctxHelp;
 
946
#endif
 
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;
 
959
 
 
960
    KXMLGUIClient *curWindowGUIClient, *curWindowViewGUIClient,
 
961
    *closedWindowGUIClient, *closedWindowViewGUIClient;
 
962
//unused  QPointer<KexiWindow> curWindow;
 
963
 
 
964
    KexiNameDialog *nameDialog;
 
965
 
 
966
    QTimer timer; //helper timer
 
967
//  QSignalMapper *actionMapper;
 
968
 
 
969
//! @todo move menu handling outside
 
970
//  Q3AsciiDict<QPopupMenu> popups; //list of menu popups
 
971
//    QMenu *createMenu;
 
972
 
 
973
//  QString origAppCaption; //<! original application's caption (without project name)
 
974
    QString appCaptionPrefix; //<! application's caption prefix - prj name (if opened), else: null
 
975
 
 
976
#ifndef KEXI_SHOW_UNIMPLEMENTED
 
977
    KActionMenu *dummy_action;
 
978
#endif
 
979
 
 
980
    //! project menu
 
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;
 
992
 
 
993
    //! edit menu
 
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;
 
1004
 
 
1005
    //! view menu
 
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;
 
1014
#endif
 
1015
    //! data menu
 
1016
    KAction *action_data_save_row;
 
1017
    KAction *action_data_cancel_row_changes;
 
1018
    KAction *action_data_execute;
 
1019
 
 
1020
    //! format menu
 
1021
    KAction *action_format_font;
 
1022
 
 
1023
    //! tools menu
 
1024
    KAction *action_tools_data_migration, *action_tools_compact_database, *action_tools_data_import;
 
1025
    KActionMenu *action_tools_scripts;
 
1026
 
 
1027
    //! window menu
 
1028
    KAction *action_window_next, *action_window_previous;
 
1029
 
 
1030
    //! settings menu
 
1031
    KAction *action_configure;
 
1032
 
 
1033
    //! for dock windows
 
1034
//2.0: unused  KMdiToolViewAccessor* navToolWindow;
 
1035
//2.0: unused  KMdiToolViewAccessor* propEditorToolWindow;
 
1036
 
 
1037
    QPointer<QWidget> focus_before_popup;
 
1038
//  KexiRelationPart *relationPart;
 
1039
 
 
1040
//moved  int privateIDCounter; //!< counter: ID for private "document" like Relations window
 
1041
 
 
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;
 
1046
 
 
1047
    //! Indicates that we're inside closeWindow() method - to avoid inf. recursion
 
1048
    //! on window removing
 
1049
    bool insideCloseWindow;
 
1050
 
 
1051
#ifndef KEXI_NO_PENDING_DIALOGS
 
1052
    //! Used in executeActionWhenPendingJobsAreFinished().
 
1053
    enum ActionToExecuteWhenPendingJobsAreFinished {
 
1054
        NoAction,
 
1055
        QuitAction,
 
1056
        CloseProjectAction
 
1057
    };
 
1058
    ActionToExecuteWhenPendingJobsAreFinished actionToExecuteWhenPendingJobsAreFinished;
 
1059
 
 
1060
    void executeActionWhenPendingJobsAreFinished() {
 
1061
        ActionToExecuteWhenPendingJobsAreFinished a = actionToExecuteWhenPendingJobsAreFinished;
 
1062
        actionToExecuteWhenPendingJobsAreFinished = NoAction;
 
1063
        switch (a) {
 
1064
        case QuitAction:
 
1065
            qApp->quit();
 
1066
            break;
 
1067
        case CloseProjectAction:
 
1068
            wnd->closeProject();
 
1069
            break;
 
1070
        default:;
 
1071
        }
 
1072
    }
 
1073
#endif
 
1074
 
 
1075
    //! Used for delayed windows closing for 'close all'
 
1076
    QList<KexiWindow*> windowsToClose;
 
1077
 
 
1078
    //! Opened page setup dialogs, used by printOrPrintPreviewForItem().
 
1079
    QHash<int, KexiWindow*> pageSetupWindows;
 
1080
 
 
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;
 
1085
 
 
1086
    //! Used in several places to show info dialog at startup (only once per session)
 
1087
    //! before displaying other stuff
 
1088
    bool showImportantInfoOnStartup;
 
1089
 
 
1090
//  //! Used sometimes to block showErrorMessage()
 
1091
//  bool disableErrorMessages;
 
1092
 
 
1093
    //! Indicates if project is started in User Mode
 
1094
    bool userMode;
 
1095
 
 
1096
    //! Indicates if project navigator should be visible
 
1097
    bool isProjectNavigatorVisible;
 
1098
 
 
1099
    //! Used on opening 1st child window
 
1100
    bool maximizeFirstOpenedChildFrm;
 
1101
 
 
1102
    //! Set in restoreSettings() and used in initNavigator()
 
1103
    //! to customize navigator visibility on startup
 
1104
    bool forceShowProjectNavigatorOnCreation;
 
1105
    bool forceHideProjectNavigatorOnCreation;
 
1106
 
 
1107
    bool navWasVisibleBeforeProjectClosing;
 
1108
    bool saveSettingsForShowProjectNavigator;
 
1109
#ifdef HAVE_KNEWSTUFF
 
1110
    KexiNewStuff  *newStuff;
 
1111
#endif
 
1112
 
 
1113
    //! Used by openedCustomObjectsForItem() and addOpenedCustomObjectForItem()
 
1114
    QHash<QByteArray, QObject*> m_openedCustomObjectsForItem;
 
1115
 
 
1116
    int propEditorDockSeparatorPos, navDockSeparatorPos;
 
1117
// int navDockSeparatorPosWithAutoOpen;
 
1118
    bool wasAutoOpen;
 
1119
    bool windowExistedBeforeCloseProject;
 
1120
 
 
1121
//2.0: unused  KMdi::MdiMode mdiModeToSwitchAfterRestart;
 
1122
 
 
1123
    QMap<KMultiTabBar::KMultiTabBarPosition, KMultiTabBar*> multiTabBars;
 
1124
    bool propertyEditorCollapsed;
 
1125
 
 
1126
    bool enable_slotPropertyEditorVisibilityChanged;
 
1127
 
 
1128
private:
 
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
 
1134
#endif
 
1135
    KexiFindDialog *m_findDialog;
 
1136
};
 
1137
 
 
1138
#endif