Fix no newlines warnings. Patch by Peter Oberndorfer
[kdevelopdvcssupport.git] / sublime / tooldocument.h
blob497cafbff9883592bb80e2d62b4f58ffa52dbd0c
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 SUBLIMETOOLDOCUMENT_H
20 #define SUBLIMETOOLDOCUMENT_H
22 #include "document.h"
24 #include "sublimeexport.h"
26 #include <QtCore/QDebug>
28 class QAction;
30 namespace Sublime {
32 class ToolDocument;
34 /**
35 @short Factory to create widgets for toolviews
37 class SUBLIME_EXPORT ToolFactory {
38 public:
39 virtual ~ToolFactory() {}
40 virtual QWidget* create(ToolDocument *doc, QWidget *parent = 0) = 0;
41 virtual QList<QAction*> toolBarActions( QWidget* viewWidget ) const = 0;
42 virtual QString id() const = 0;
45 /**
46 @short Simple factory that just creates a new widget of given type
48 template <class Widget>
49 class SimpleToolWidgetFactory: public ToolFactory {
50 public:
51 SimpleToolWidgetFactory(const QString &id): ToolFactory(), m_id(id) {}
52 virtual QWidget* create(ToolDocument * /*doc*/, QWidget *parent = 0)
54 return new Widget(parent);
56 virtual QList<QAction*> toolBarActions( QWidget* ) const { return QList<QAction*>(); }
57 virtual QString id() const { return m_id; }
58 private:
59 QString m_id;
62 /**
63 @short Document to represent and manage widgets as toolviews
65 class SUBLIME_EXPORT ToolDocument: public Document {
66 public:
67 /**Initializes tool document with given @p factory. Document takes
68 ownership over the factory and deletes it together with itself*/
69 ToolDocument(const QString &title, Controller *controller, ToolFactory *factory);
70 ~ToolDocument();
72 virtual QString documentType() const;
74 virtual QString documentSpecifier() const;
76 protected:
77 virtual QWidget *createViewWidget(QWidget *parent = 0);
78 ToolFactory *factory() const;
80 private:
81 struct ToolDocumentPrivate * const d;
83 friend class View;
88 #endif