1 /***************************************************************************
2 * Copyright 2006-2007 Alexander Dymo <adymo@kdevelop.org> *
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. *
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. *
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 ***************************************************************************/
22 #include <QtCore/QObject>
24 #include "sublimeexport.h"
33 @short View - the wrapper to the widget that knows about its document
35 Views are the convenient way to manage a widget. It is specifically designed to be
36 light and fast. Use @ref Document::createView() to get the new view for the document
37 and call @ref View::widget() to create and get the actual widget.
39 It is not possible to create a view by hand. You need either subclass it or use a Document.
41 If you create a subclass of View you need to override Sublime::View::createWidget to
42 provide a custom widget for your view.
45 class SUBLIME_EXPORT View
: public QObject
{
50 /**@return the toolbar actions for this view, this needs to be called _after_ the first call to widget() */
51 QList
<QAction
*> toolBarActions() const;
53 /**@return the document for this view.*/
54 Document
*document() const;
55 /**@return widget for this view (creates it if it's not yet created).*/
56 QWidget
*widget(QWidget
*parent
= 0);
57 /**@return true if this view has an initialized widget.*/
58 bool hasWidget() const;
60 /// Retrieve information to be placed in the status bar.
61 virtual QString
viewStatus() const;
63 /// Retrieve view state for saving into configuration.
64 virtual QString
viewState() const;
65 /// Restore view state from configuration
66 virtual void setState(const QString
& state
);
69 void raise(Sublime::View
*);
70 /// Notify that the status for this document has changed
71 void statusChanged(Sublime::View
*);
79 * override this function to create a custom widget in your View subclass
80 * @param parent the parent widget
81 * @returns a new widget which is used for this view
83 virtual QWidget
*createWidget(QWidget
*parent
);
86 Q_PRIVATE_SLOT(d
, void unsetWidget())
89 //copy is not allowed, create a new view from the document instead
91 struct ViewPrivate
*const d
;
93 friend class Document
;