1 #ifndef MDIAREA_H 2 #define MDIAREA_H 3 4 #include "mdiwindow.h" 5 #include "guiSQLiteStudio_global.h" 6 #include <QMdiArea> 7 8 class TaskBar; 9 class QActionGroup; 10 class MdiChild; 11 12 class GUI_API_EXPORT MdiArea : public QMdiArea 13 { 14 Q_OBJECT 15 public: 16 explicit MdiArea(QWidget *parent = 0); 17 18 MdiWindow* addSubWindow(MdiChild* mdiChild); 19 MdiWindow* getActiveWindow(); 20 MdiWindow* getWindowByTitle(const QString& title); 21 MdiWindow* getWindowByChild(MdiChild* child); 22 MdiWindow* getCurrentWindow(); 23 bool isActiveSubWindow(MdiWindow* window); 24 bool isActiveSubWindow(MdiChild* child); 25 QStringList getWindowTitles(); 26 void setTaskBar(TaskBar *value); 27 TaskBar* getTaskBar() const; 28 QAction* getTaskByWindow(MdiWindow* window); 29 QList<MdiWindow*> getWindows() const; 30 QList<MdiChild*> getMdiChilds() const; 31 32 template<class T> 33 QList<T*> getMdiChilds() const; 34 35 private: 36 QList<MdiWindow*> getWindowsToTile() const; 37 38 TaskBar* taskBar = nullptr; 39 QHash<QAction*,MdiWindow*> actionToWinMap; 40 QHash<MdiWindow*,QAction*> winToActionMap; 41 42 signals: 43 void windowListChanged(); 44 45 private slots: 46 void taskActivated(); 47 void windowActivated(); 48 49 public slots: 50 void windowDestroyed(MdiWindow* window); 51 void tileHorizontally(); 52 void tileVertically(); 53 void closeAllButActive(); 54 }; 55 56 template<class T> getMdiChilds()57QList<T*> MdiArea::getMdiChilds() const 58 { 59 QList<T*> childs; 60 T* child = nullptr; 61 for (MdiWindow* win : getWindows()) 62 { 63 child = dynamic_cast<T*>(win->getMdiChild()); 64 if (child) 65 childs << child; 66 } 67 68 return childs; 69 } 70 71 #define MDIAREA MainWindow::getInstance()->getMdiArea() 72 73 #endif // MDIAREA_H 74