Fix no newlines warnings. Patch by Peter Oberndorfer
[kdevelopdvcssupport.git] / sublime / mainwindow.h
blob8f96f938c09a5748bb352b8513b406c9da7e1d81
1 /***************************************************************************
2 * Copyright 2006-2007 Alexander Dymo <adymo@kdevelop.org> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU Library General Public License as *
6 * published by the Free Software Foundation; either version 2 of the *
7 * License, or (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU Library General Public *
15 * License along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
19 #ifndef SUBLIMEMAINWINDOW_H
20 #define SUBLIMEMAINWINDOW_H
22 #include <QtCore/QList>
23 #include <kparts/mainwindow.h>
25 #include "sublimeexport.h"
27 class QDockWidget;
29 namespace Sublime {
31 class Area;
32 class View;
33 class Controller;
34 class MainWindowOperator;
36 /**
37 @short Sublime Main Window
39 The area-enabled mainwindow to show Sublime views and toolviews.
41 To use, a controller and constructed areas are necessary:
42 @code
43 MainWindow w(controller);
44 controller->showArea(area, &w);
45 @endcode
47 class SUBLIME_EXPORT MainWindow: public KParts::MainWindow {
48 Q_OBJECT
49 public:
50 /**Creates a mainwindow and adds it to the controller.*/
51 explicit MainWindow(Controller *controller, Qt::WindowFlags flags = KDE_DEFAULT_WINDOWFLAGS);
52 ~MainWindow();
54 /**@return the list of dockwidgets that contain area's toolviews.*/
55 QList<View*> toolDocks() const;
56 /**@return area which mainwindow currently shows or 0 if no area has been set.*/
57 Area *area() const;
58 /**@return controller for this mainwindow.*/
59 Controller *controller() const;
61 /**@return active view inside this mainwindow.*/
62 View *activeView();
63 /**@return active toolview inside this mainwindow.*/
64 View *activeToolView();
66 /**Enable saving of per-area UI settings (like toolbar properties
67 and position) whenever area is changed. This should be
68 called after all areas are restored, and main window area is
69 set, to prevent saving a half-broken state. */
70 void enableAreaSettingsSave();
72 public slots:
73 /**Shows the @p view and makes it active.*/
74 void activateView(Sublime::View *view);
76 Q_SIGNALS:
77 /**Emitted before the area is cleared from this mainwindow.*/
78 void areaCleared(Sublime::Area*);
79 /**Emitted after the new area has been shown in this mainwindow.*/
80 void areaChanged(Sublime::Area*);
81 /**Emitted when the active view is changed.*/
82 void activeViewChanged(Sublime::View*);
83 /**Emitted when the active toolview is changed.*/
84 void activeToolViewChanged(Sublime::View*);
85 /**Emitted when the user interface settings have changed.*/
86 void settingsLoaded();
88 protected:
89 public: // FIXME?
90 /**Saves size/toolbar/menu/statusbar settings to the global configuration file.
91 Reimplement in subclasses to save more and don't forget to call inherited method.*/
92 virtual void saveSettings();
93 /**Loads size/toolbar/menu/statusbar settings to the global configuration file.
94 Reimplement in subclasses to load more and don't forget to call inherited method.*/
95 virtual void loadSettings();
97 /**Reimplemented to save settings.*/
98 virtual bool queryClose();
100 private:
101 Q_PRIVATE_SLOT(d, void viewAdded(Sublime::AreaIndex*, Sublime::View*))
102 Q_PRIVATE_SLOT(d, void aboutToRemoveView(Sublime::AreaIndex*, Sublime::View*))
103 Q_PRIVATE_SLOT(d, void toolViewAdded(Sublime::View*, Sublime::Position))
104 Q_PRIVATE_SLOT(d, void raiseToolView(Sublime::View*))
105 Q_PRIVATE_SLOT(d, void aboutToRemoveToolView(Sublime::View*, Sublime::Position))
106 Q_PRIVATE_SLOT(d, void toolViewMoved(Sublime::View*, Sublime::Position))
108 //Inherit MainWindowOperator to access four methods below
109 /**Sets the area of main window and fills it with views.*/
110 void setArea(Area *area);
111 /**Unsets the area clearing main window.*/
112 void clearArea();
113 /**Sets the active view and focuses it.*/
114 void setActiveView(Sublime::View *view);
115 /**Sets the active toolview and focuses it.*/
116 void setActiveToolView(View *view);
117 /**Sets the status icon for the given \a view in the \a mainWindow to \a icon.*/
118 void setStatusIcon(View* view, const QIcon& icon);
120 void resizeEvent(QResizeEvent* event);
122 void saveGeometry(KConfigGroup &config);
123 void loadGeometry(const KConfigGroup &config);
125 struct MainWindowPrivate *const d;
126 friend class MainWindowOperator;
127 friend class MainWindowPrivate;
133 #endif