File indexing completed on 2024-04-28 04:37:33
0001 /* 0002 SPDX-FileCopyrightText: 2006-2007 Alexander Dymo <adymo@kdevelop.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KDEVPLATFORM_SUBLIMEMAINWINDOW_P_H 0008 #define KDEVPLATFORM_SUBLIMEMAINWINDOW_P_H 0009 0010 #include <QMap> 0011 #include <QObject> 0012 #include <QPointer> 0013 #include <QSet> 0014 0015 #include "area.h" 0016 #include "sublimedefs.h" 0017 0018 #include "mainwindow.h" 0019 #include <QPushButton> 0020 0021 class QAction; 0022 class QSplitter; 0023 class IdealToolBar; 0024 0025 namespace Sublime { 0026 0027 class View; 0028 class Container; 0029 class Controller; 0030 class AreaIndex; 0031 class IdealMainWidget; 0032 class IdealController; 0033 class MessageWidget; 0034 class Message; 0035 0036 class MainWindowPrivate: public QObject { 0037 Q_OBJECT 0038 public: 0039 MainWindowPrivate(MainWindow *w, Controller* controller); 0040 ~MainWindowPrivate() override; 0041 0042 /**Use this to create tool views for an area.*/ 0043 class IdealToolViewCreator { 0044 public: 0045 explicit IdealToolViewCreator(MainWindowPrivate *_d): d(_d) {} 0046 Area::WalkerMode operator() (View *view, Sublime::Position position); 0047 private: 0048 MainWindowPrivate* const d; 0049 }; 0050 0051 /**Use this to create views for an area.*/ 0052 class ViewCreator { 0053 public: 0054 explicit ViewCreator(MainWindowPrivate* _d, const QList<View*>& _topViews = QList<View*>()) 0055 : d(_d) 0056 , topViews(_topViews.begin(), _topViews.end()) 0057 {} 0058 Area::WalkerMode operator() (AreaIndex *index); 0059 private: 0060 MainWindowPrivate* const d; 0061 const QSet<View*> topViews; 0062 }; 0063 0064 /**Reconstructs the mainwindow according to the current area.*/ 0065 void reconstruct(); 0066 /**Reconstructs the views according to the current area index.*/ 0067 void reconstructViews(const QList<View*>& topViews = QList<View*>()); 0068 /**Clears the area leaving mainwindow empty.*/ 0069 void clearArea(); 0070 0071 /** Sets a @p w widget that will be shown when there are no documents on the area */ 0072 void setBackgroundCentralWidget(QWidget* w); 0073 0074 void activateFirstVisibleView(); 0075 0076 Controller* const controller; 0077 Area *area; 0078 QList<View*> docks; 0079 QMap<View*, Container*> viewContainers; 0080 QMap<QWidget*, View*> widgetToView; 0081 0082 View *activeView; 0083 View *activeToolView; 0084 0085 QWidget *centralWidget; 0086 QWidget* bgCentralWidget; 0087 MessageWidget* messageWidget; 0088 ViewBarContainer* viewBarContainer; 0089 QSplitter* splitterCentralWidget; 0090 0091 IdealController *idealController; 0092 bool ignoreDockShown; 0093 bool autoAreaSettingsSave; 0094 0095 bool eventFilter(QObject* obj, QEvent* event) override; 0096 void disableConcentrationMode(); 0097 0098 void postMessage(Message* message); 0099 0100 public Q_SLOTS: 0101 void toggleDocksShown(); 0102 0103 void viewAdded(Sublime::AreaIndex *index, Sublime::View *view); 0104 void viewRemovedInternal(Sublime::AreaIndex *index, Sublime::View *view); 0105 void raiseToolView(Sublime::View* view); 0106 void aboutToRemoveView(Sublime::AreaIndex *index, Sublime::View *view); 0107 void toolViewAdded(Sublime::View *toolView, Sublime::Position position); 0108 void aboutToRemoveToolView(Sublime::View *toolView, Sublime::Position position); 0109 void toolViewMoved(Sublime::View *toolView, Sublime::Position position); 0110 0111 void setTabBarLeftCornerWidget(QWidget* widget); 0112 0113 private Q_SLOTS: 0114 void updateAreaSwitcher(Sublime::Area *area); 0115 void slotDockShown(Sublime::View*, Sublime::Position, bool); 0116 void widgetCloseRequest(QWidget* widget); 0117 0118 void showLeftDock(bool b); 0119 void showRightDock(bool b); 0120 void showBottomDock(bool b); 0121 void focusEditor(); 0122 void selectNextDock(); 0123 void selectPreviousDock(); 0124 0125 void messageDestroyed(Message* message); 0126 0127 private: 0128 void restoreConcentrationMode(); 0129 0130 void setBackgroundVisible(bool v); 0131 Qt::DockWidgetArea positionToDockArea(Position position); 0132 void cleanCentralWidget(); 0133 0134 MainWindow* const m_mainWindow; 0135 // uses QPointer to make already-deleted splitters detectable 0136 QMap<AreaIndex*, QPointer<QSplitter> > m_indexSplitters; 0137 0138 QMap<Area*, QAction*> m_areaActions; 0139 QPointer<QWidget> m_leftTabbarCornerWidget; 0140 QPointer<QToolBar> m_concentrateToolBar; 0141 IdealToolBar* m_bottomToolBar; 0142 IdealToolBar* m_rightToolBar; 0143 IdealToolBar* m_leftToolBar; 0144 0145 QAction* m_concentrationModeAction; 0146 0147 QHash<Message*, QVector<QSharedPointer<QAction>>> m_messageHash; 0148 }; 0149 0150 } 0151 0152 #endif 0153