sublime
tooldocument.h
00001 /*************************************************************************** 00002 * Copyright 2006-2007 Alexander Dymo <adymo@kdevelop.org> * 00003 * * 00004 * This program is free software; you can redistribute it and/or modify * 00005 * it under the terms of the GNU Library General Public License as * 00006 * published by the Free Software Foundation; either version 2 of the * 00007 * License, or (at your option) any later version. * 00008 * * 00009 * This program is distributed in the hope that it will be useful, * 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00012 * GNU General Public License for more details. * 00013 * * 00014 * You should have received a copy of the GNU Library General Public * 00015 * License along with this program; if not, write to the * 00016 * Free Software Foundation, Inc., * 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 00018 ***************************************************************************/ 00019 #ifndef SUBLIMETOOLDOCUMENT_H 00020 #define SUBLIMETOOLDOCUMENT_H 00021 00022 #include "document.h" 00023 00024 #include "sublimeexport.h" 00025 00026 #include <QtCore/QDebug> 00027 00028 class QAction; 00029 00030 namespace Sublime { 00031 00032 class ToolDocument; 00033 00037 class SUBLIME_EXPORT ToolFactory { 00038 public: 00039 virtual ~ToolFactory() {} 00040 virtual QWidget* create(ToolDocument *doc, QWidget *parent = 0) = 0; 00041 virtual QList<QAction*> toolBarActions( QWidget* viewWidget ) const = 0; 00042 virtual QString id() const = 0; 00043 }; 00044 00048 template <class Widget> 00049 class SimpleToolWidgetFactory: public ToolFactory { 00050 public: 00051 SimpleToolWidgetFactory(const QString &id): ToolFactory(), m_id(id) {} 00052 virtual QWidget* create(ToolDocument * /*doc*/, QWidget *parent = 0) 00053 { 00054 return new Widget(parent); 00055 } 00056 virtual QList<QAction*> toolBarActions( QWidget* ) const { return QList<QAction*>(); } 00057 virtual QString id() const { return m_id; } 00058 private: 00059 QString m_id; 00060 }; 00061 00065 class SUBLIME_EXPORT ToolDocument: public Document { 00066 public: 00069 ToolDocument(const QString &title, Controller *controller, ToolFactory *factory); 00070 ~ToolDocument(); 00071 00072 virtual QString documentType() const; 00073 00074 virtual QString documentSpecifier() const; 00075 00076 protected: 00077 virtual QWidget *createViewWidget(QWidget *parent = 0); 00078 ToolFactory *factory() const; 00079 00080 private: 00081 struct ToolDocumentPrivate * const d; 00082 00083 friend class View; 00084 }; 00085 00086 } 00087 00088 #endif 00089
KDE 4.2 API Reference