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
|
#ifndef MDIAREA_H
#define MDIAREA_H
#include "mdiwindow.h"
#include "guiSQLiteStudio_global.h"
#include <QMdiArea>
class TaskBar;
class QActionGroup;
class MdiChild;
class GUI_API_EXPORT MdiArea : public QMdiArea
{
Q_OBJECT
public:
explicit MdiArea(QWidget *parent = 0);
MdiWindow* addSubWindow(MdiChild* mdiChild);
MdiWindow* getActiveWindow();
MdiWindow* getWindowByTitle(const QString& title);
MdiWindow* getWindowByChild(MdiChild* child);
MdiWindow* getCurrentWindow();
bool isActiveSubWindow(MdiWindow* window);
bool isActiveSubWindow(MdiChild* child);
QStringList getWindowTitles();
void setTaskBar(TaskBar *value);
TaskBar* getTaskBar() const;
QAction* getTaskByWindow(MdiWindow* window);
QList<MdiWindow*> getWindows() const;
QList<MdiChild*> getMdiChilds() const;
void enforceTaskSelectionAfterWindowClose(QAction* task);
void enforceCurrentTaskSelectionAfterWindowClose();
template<class T>
QList<T*> getMdiChilds() const;
private:
QList<MdiWindow*> getWindowsToTile() const;
TaskBar* taskBar = nullptr;
QHash<QAction*,MdiWindow*> actionToWinMap;
QHash<MdiWindow*,QAction*> winToActionMap;
QAction* taskToSelectAfterWindowClose = nullptr;
signals:
void windowListChanged();
void sessionValueChanged();
private slots:
void taskActivated();
void windowActivated();
public slots:
void windowDestroyed(MdiWindow* window);
void tileHorizontally();
void tileVertically();
void closeAllButActive();
void closeAllLeftToActive();
void closeAllRightToActive();
};
template<class T>
QList<T*> MdiArea::getMdiChilds() const
{
QList<T*> childs;
T* child = nullptr;
for (MdiWindow* win : getWindows())
{
child = dynamic_cast<T*>(win->getMdiChild());
if (child)
childs << child;
}
return childs;
}
#define MDIAREA MainWindow::getInstance()->getMdiArea()
#endif // MDIAREA_H
|