summaryrefslogtreecommitdiffstats
path: root/src/newui/dmainwindow.h
blob: abb7491944e15cdbe6bbf56be21a19ca7e42deea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/***************************************************************************
 *   Copyright (C) 2005 by Alexander Dymo                                  *
 *   adymo@kdevelop.org                                                    *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Library General Public License as       *
 *   published by the Free Software Foundation; either version 2 of the    *
 *   License, or (at your option) any later version.                       *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU Library General Public     *
 *   License along with this program; if not, write to the                 *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef DMAINWINDOW_H
#define DMAINWINDOW_H

#include <kxmlguiclient.h>
#include <kparts/mainwindow.h>

#include "ddockwindow.h"

class DTabWidget;
namespace Ideal {
    class DockSplitter;
}

/**Main window which provides simplified IDEA mode.*/
class DMainWindow: public KParts::MainWindow {
    Q_OBJECT
public:
    DMainWindow(QWidget *parent = 0, const char *name = 0);
    virtual ~DMainWindow();

    /**@return The tool window in given @p position.*/
    DDockWindow *toolWindow(DDockWindow::Position position) const;

    /**Adds a tabbed widget into the active (focused) tab widget.
    If @p widget is null then only tab is created.*/
    virtual void addWidget(QWidget *widget, const QString &title);
    virtual void addWidget(DTabWidget *tab, QWidget *widget, const QString &title);
    /**Removes widget. Does not delete it.*/
    virtual void removeWidget(QWidget *widget);
   /**Moves a widget from an existing dockposition to a new position**/
    virtual void moveWidget(DDockWindow::Position newPosition, QWidget *widget, const QString & title);

    /**Adds a dock widget into given position.*/
    virtual void addDockWidget(DDockWindow::Position position, QWidget *view, const QString &title);
    /**Removes a dock widget.*/
    virtual void removeDockWidget(QWidget *view);

    virtual void saveSettings();

    bool hasDockWidget(QWidget *view);
    DDockWindow::Position dockWidgetPosition(QWidget *view);

public slots:
    DTabWidget *splitHorizontal();
    DTabWidget *splitVertical();

protected slots:
    /**This does nothing. Reimplement in subclass to close the tab
    when corner close button is pressed.*/
    virtual void closeTab();
    /**This does nothing. Reimplement in subclass to close the tab
    when hover close button is pressed.*/
    virtual void closeTab(QWidget*);
    /**This does nothing. Reimplement in subclass to show tab context menu.*/
    virtual void tabContext(QWidget*,const QPoint &);

    void widgetDestroyed();

signals:
    void widgetChanged(QWidget *);

protected:
    bool eventFilter(QObject *obj, QEvent *ev);

    virtual void loadSettings();

    virtual void createToolWindows();
    virtual DTabWidget *createTab();

    DDockWindow *m_leftDock;
    DDockWindow *m_rightDock;
    DDockWindow *m_bottomDock;

    QMap<QWidget*, DDockWindow::Position> m_docks;

    Ideal::DockSplitter *m_central;
    DTabWidget *m_activeTabWidget;

    QValueList<DTabWidget*> m_tabs;

    bool m_openTabAfterCurrent;
    bool m_showIconsOnTabs;
    bool m_firstRemoved;

    QValueList<QWidget*> m_widgets;
    QMap<QWidget*, DTabWidget*> m_widgetTabs;
    QWidget *m_currentWidget;

private slots:
    void invalidateActiveTabWidget();

};

#endif