summaryrefslogtreecommitdiff
path: root/src/frontend/cmdiarea.h
blob: 14200071c76d938e815b1b254cdf496dfa8375fb (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
114
115
116
/*********
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
* Copyright 1999-2008 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/

#ifndef CMDIAREA_H
#define CMDIAREA_H

//Qt includes
#include <QMdiArea>
#include <QList>

class CSwordModuleInfo;
class QEvent;
class QResizeEvent;
class QMdiSubWindow;

/** The MDI widget we use in BibleTime.
 * Enhances QMdiArea.
 */
class CMDIArea : public QMdiArea {
        Q_OBJECT
        Q_PROPERTY(MDIArrangementMode m_mdiArrangementMode READ getMDIArrangementMode WRITE setMDIArrangementMode)

    public:
        /**
        * The options you can set for this widget.
        */
        enum MDIArrangementMode {
            ArrangementModeTileVertical = 1,
            ArrangementModeTileHorizontal = 2,
            ArrangementModeCascade = 3,
            ArrangementModeManual = 4,
            MDIArrangementModeMIN = ArrangementModeTileVertical,
            MDIArrangementModeMAX = ArrangementModeManual
        };
        CMDIArea(QWidget *parent);
        /** Reimplementation
        */
        virtual QMdiSubWindow* addSubWindow(QWidget* widget, Qt::WindowFlags windowFlags = 0);
        /**
         */
        void setMDIArrangementMode( const MDIArrangementMode );
        /** */
        MDIArrangementMode getMDIArrangementMode(void) const;
        /**
        */
        void emitWindowCaptionChanged();
        /**
        * Forces an update of the currently chosen window arrangement.
        */
        void triggerWindowUpdate();
        /** Lists all subWindows which are not minimized or hidden
         */
        QList<QMdiSubWindow*> usableWindowList();

    public slots:
        /**
        * Called whan a client window was activated
        */
        void slotClientActivated(QMdiSubWindow* client);
        /**
        * Deletes all the presenters in the MDI area.
        */
        void deleteAll();
        /** Our own cascade version which, if only one window is left, shows this maximized.
        * Also necessary for autoCasacde feature
        */
        void myCascade();
        /** Our own cascade version which, if only one window is left, shows this maximized.
        * Also necessary for autoTile feature
        */
        void myTileVertical();
        /** Horizontal tile function
        * This function was taken from Qt's MDI example.
        */
        void myTileHorizontal();
        /**
         * Emits the signal to create a new display window in the MDI area.
         */
        inline void emitCreateDisplayWindow(QList<CSwordModuleInfo*> modules, const QString keyName);

    signals: // Signals
        /**
        * Emits a signal to set the acption of the toplevel widget.
        */
        void sigSetToplevelCaption(const QString&);
        /**
         */
        void createReadDisplayWindow(QList<CSwordModuleInfo*> modules, const QString& keyName);

    private:
        /**
        * Reimplementation
        */
        virtual void resizeEvent(QResizeEvent* e);
        /**
         * Used to handle Events of MDI windows
         * */
        bool eventFilter( QObject *o, QEvent *e );
        /**
         */
        MDIArrangementMode m_mdiArrangementMode;
};

/** Emits the signal to create a new display window in the MDI area. */
inline void CMDIArea::emitCreateDisplayWindow(QList<CSwordModuleInfo*> modules, const QString keyName) {
    emit createReadDisplayWindow(modules, keyName);
}


#endif