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 ***************************************************************************/
19 #ifndef SUBLIMETOOLDOCUMENT_H
20 #define SUBLIMETOOLDOCUMENT_H
24 #include "sublimeexport.h"
26 #include <QtCore/QDebug>
35 @short Factory to create widgets for toolviews
37 class SUBLIME_EXPORT ToolFactory
{
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;
46 @short Simple factory that just creates a new widget of given type
48 template <class Widget
>
49 class SimpleToolWidgetFactory
: public ToolFactory
{
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
; }
63 @short Document to represent and manage widgets as toolviews
65 class SUBLIME_EXPORT ToolDocument
: public Document
{
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
);
72 virtual QString
documentType() const;
74 virtual QString
documentSpecifier() const;
77 virtual QWidget
*createViewWidget(QWidget
*parent
= 0);
78 ToolFactory
*factory() const;
81 struct ToolDocumentPrivate
* const d
;