Simple plugin system and added bibles docker to it
[kworship.git] / kworship / KwPlugin.h
blobed6bc2f8c9475bcb9fbae7d6cf407c0162792713
1 /***************************************************************************
2 * This file is part of KWorship. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
4 * *
5 * KWorship is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * KWorship is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with KWorship. If not, write to the Free Software Foundation, *
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
20 #ifndef _KwPlugin_h_
21 #define _KwPlugin_h_
23 /**
24 * @file KwPlugin.h
25 * @brief An abstract KWorship plugin.
26 * @author James Hogan <james@albanarts.com>
29 #include <QObject>
30 #include <QString>
32 class KwPluginManager;
34 class QMainWindow;
35 class QDockWidget;
37 /// An abstract KWorship plugin.
38 class KwPlugin : public QObject
40 Q_OBJECT
42 public:
45 * Constructors + destructor
48 /** Primary constructor.
49 * @param id Short unique untranslated id.
50 * @param name Translated name of plugin.
51 * @param description Translated description of plugin.
53 KwPlugin(const QString& id, const QString& name, const QString& description);
55 /// Destructor.
56 virtual ~KwPlugin();
59 * Basic information accessors
62 /// Get the id.
63 const QString& id() const;
65 /// Get the name.
66 const QString& name() const;
68 /// Get the description.
69 const QString& description() const;
71 /// Get whether the plugin is loaded.
72 bool isLoaded() const;
75 * Loading and unloading
78 /** Set the manager.
79 * This should only be called by the manager class itself.
80 * @pre Manager must not have already been set.
81 * @param manager New manager object.
83 void setManager(KwPluginManager* manager);
85 /** Load the plugin.
86 * @pre Manager must have been set.
88 void load(QMainWindow* mainWindow);
90 /// Unload the plugin.
91 void unload();
93 protected:
96 * Loading and unloading virtual interface
99 /** Load the plugin.
100 * @pre !isLoaded()
102 virtual void _load(QMainWindow* mainWindow) = 0;
104 /** Unload the plugin.
105 * @pre isLoaded()
107 virtual void _unload() = 0;
109 private:
112 * Constants
115 /// Short unique untranslated id.
116 QString m_id;
118 /// Translated name.
119 QString m_name;
121 /// Translated description.
122 QString m_description;
125 * Variables
128 /// The current plugin manager.
129 KwPluginManager* m_manager;
131 /// Whether the plugin is loaded.
132 bool m_loaded;
136 #endif // _KwPlugin_h_