Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
BackupPlugin.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
42 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 #ifndef BACKUPPLUGIN_HH
51 #define BACKUPPLUGIN_HH
52 
63 
64 #include <QObject>
65 #include <QMenuBar>
66 
67 #include "GroupData.hh"
68 
70 {
71 Q_OBJECT
72 Q_INTERFACES(BaseInterface)
73 Q_INTERFACES(KeyInterface)
74 Q_INTERFACES(MenuInterface)
75 Q_INTERFACES(BackupInterface)
76 Q_INTERFACES(LoggingInterface)
77 Q_INTERFACES(ToolbarInterface)
78 Q_INTERFACES(LoadSaveInterface)
79 Q_INTERFACES(ContextMenuInterface)
80 Q_INTERFACES(OptionsInterface)
81 
82 #if QT_VERSION >= 0x050000
83  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-Backup")
84 #endif
85 
86 signals:
87  // BaseInterface
88  void updateView();
89  void updatedObject(int _identifier, const UpdateType& _type);
90  void setSlotDescription(QString _slotName , QString _slotDescription,
91  QStringList _parameters , QStringList _descriptions);
92 
93  // LoggingInterface
94  void log(Logtype _type, QString _message);
95  void log(QString _message);
96 
97  // MenuInterface
98  void getMenubarMenu (QString _name, QMenu *& _menu, bool _create);
99 
100  // BackupInterface
101  void undo(int _objectid);
102  void undo();
103  void redo(int _objectid);
104  void redo();
105  void aboutToRestore(int _objectid);
106  void restored(int _objectid);
107  void generateBackup( int _id, QString _name, UpdateType _type);
108 
109  // ToolBarInterface
110  void addToolbar(QToolBar* _toolbar);
111  void getToolBar( QString _name, QToolBar*& _toolbar);
112 
113  //KeyInterface
114  void registerKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description, bool _multiUse = false);
115 
116  //ContextMenuInterface
117  void addContextMenuItem(QAction* _action , DataType _objectType, ContextMenuType _type);
118 
119 private slots:
120 
121  // BaseInterface
122  void initializePlugin();
123  void pluginsInitialized();
124 
125  void slotAllCleared();
126 
127  // KeyInterface
128  void slotKeyEvent( QKeyEvent* _event );
129 
130  // LoadSaveInterface
131  void objectDeleted (int _objectid);
132 
133  // Backup Interface
134  void slotCreateBackup( int _objectid, QString _name, UpdateType _type = UPDATE_ALL);
135  void slotCreateBackup( IdList _objectids , QString _name, std::vector<UpdateType> _types);
136  void slotUndo(int _objectid);
137  void slotRedo(int _objectid);
138  void slotUndo();
139  void slotRedo();
140 
141  //ContextMenuInterface
142  void slotUpdateContextMenu( int _objectId );
143 
144  // OptionsInterface
145  bool initializeOptionsWidget(QWidget*& _widget);
146  void applyOptions();
147 
148 private slots:
149 
150  void updateButtons();
151 
154 
155  void slotObjectUndo();
156  void slotObjectRedo();
157 
158 public slots:
159  QString version() { return QString("0.1"); };
160 
161  void createBackup(int _objectId, QString _name, UpdateType _type= UPDATE_ALL);
162 
163 public:
164  ~BackupPlugin() {};
165  BackupPlugin();
166 
167  QString name() { return (QString("Backup")); };
168  QString description( ) { return (QString("Creates Backups of objects when supported by plugins")); };
169 
170 private :
171  GroupData globalBackup_;
172 
174  QMenu* backupMenu_;
175 
176  QAction* backupsEnabledAction_;
177 
178  QAction* undoMenuAction_;
179  QAction* redoMenuAction_;
180 
181  QAction* undoToolAction_;
182  QAction* redoToolAction_;
183 
184  QAction* undoContextAction_;
185  QAction* redoContextAction_;
186 
187  QSpinBox* maxBackupSpinBox_;
188 };
189 
190 #endif //BACKUPPLUGIN_HH
Interface class from which all plugins have to be created.
Keyboard Event Interface.
Definition: KeyInterface.hh:76
Logtype
Log types for Message Window.
Update type class.
Definition: UpdateType.hh:70
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
Class that is used to store global(group) backups.
Definition: GroupData.hh:60
void slotEnableDisableBackups()
Backups enabled or disabled checkbox.
Interface for all Plugins which do logging to the logging window of the framework.
QMenu * backupMenu_
The backup Menu.
Options Dialog interface.
std::vector< int > IdList
Standard Type for id Lists used for scripting.
Definition: DataTypes.hh:192
QString description()
Return a description of what the plugin is doing.
Add a toolbox to OpenFlipper.
Interface for all plugins which want to Load or Save files and create Objects.
Interface class for backup handling.
Interface class for creating custom context menus.
QString name()
Return a name for the plugin.
Predefined datatypes.
Definition: DataTypes.hh:96
Interface for all plugins which provide entries to the main menubar.
void createBackup(int _objectId, QString _name, UpdateType _type=UPDATE_ALL)
Tell Backup Plugin to create a backup.