Developer Documentation
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 #pragma once
43 
54 
55 #include <QObject>
56 #include <QMenuBar>
57 #include <QSpinBox>
58 
59 #include "GroupData.hh"
60 
62 {
63 Q_OBJECT
64 Q_INTERFACES(BaseInterface)
65 Q_INTERFACES(KeyInterface)
66 Q_INTERFACES(MenuInterface)
67 Q_INTERFACES(BackupInterface)
68 Q_INTERFACES(LoggingInterface)
69 Q_INTERFACES(ToolbarInterface)
70 Q_INTERFACES(LoadSaveInterface)
71 Q_INTERFACES(ContextMenuInterface)
72 Q_INTERFACES(OptionsInterface)
73 
74  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-Backup")
75 
76 signals:
77  // BaseInterface
78  void updateView();
79  void updatedObject(int _identifier, const UpdateType& _type);
80  void setSlotDescription(QString _slotName , QString _slotDescription,
81  QStringList _parameters , QStringList _descriptions);
82 
83  // LoggingInterface
84  void log(Logtype _type, QString _message);
85  void log(QString _message);
86 
87  // MenuInterface
88  void getMenubarMenu (QString _name, QMenu *& _menu, bool _create);
89 
90  // BackupInterface
91  void undo(int _objectid);
92  void undo();
93  void redo(int _objectid);
94  void redo();
95  void aboutToRestore(int _objectid);
96  void restored(int _objectid);
97  void generateBackup( int _id, QString _name, UpdateType _type);
98 
99  // ToolBarInterface
100  void addToolbar(QToolBar* _toolbar);
101  void getToolBar( QString _name, QToolBar*& _toolbar);
102 
103  //KeyInterface
104  void registerKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description, bool _multiUse = false);
105 
106  //ContextMenuInterface
107  void addContextMenuItem(QAction* _action , DataType _objectType, ContextMenuType _type);
108 
109 private slots:
110 
111  // BaseInterface
112  void initializePlugin();
113  void pluginsInitialized();
114 
115  void slotAllCleared();
116 
117  // KeyInterface
118  void slotKeyEvent( QKeyEvent* _event );
119 
120  // LoadSaveInterface
121  void objectDeleted (int _objectid);
122 
123  // Backup Interface
124  void slotCreateBackup( int _objectid, QString _name, UpdateType _type = UPDATE_ALL);
125  void slotCreateBackup( IdList _objectids , QString _name, std::vector<UpdateType> _types);
126  void slotUndo(int _objectid);
127  void slotRedo(int _objectid);
128  void slotUndo();
129  void slotRedo();
130 
131  //ContextMenuInterface
132  void slotUpdateContextMenu( int _objectId );
133 
134  // OptionsInterface
135  bool initializeOptionsWidget(QWidget*& _widget);
136  void applyOptions();
137 
138 private slots:
139 
140  void updateButtons();
141 
144 
145  void slotObjectUndo();
146  void slotObjectRedo();
147 
148 public slots:
149  QString version() { return QString("0.1"); };
150 
151  void createBackup(int _objectId, QString _name, UpdateType _type= UPDATE_ALL);
152 
153 public:
154  ~BackupPlugin() {};
155  BackupPlugin();
156 
157  QString name() { return (QString("Backup")); };
158  QString description( ) { return (QString("Creates Backups of objects when supported by plugins")); };
159 
160 private :
161  GroupData globalBackup_;
162 
164  QMenu* backupMenu_;
165 
166  QAction* backupsEnabledAction_;
167 
168  QAction* undoMenuAction_;
169  QAction* redoMenuAction_;
170 
171  QAction* undoToolAction_;
172  QAction* redoToolAction_;
173 
174  QAction* undoContextAction_;
175  QAction* redoContextAction_;
176 
177  QSpinBox* maxBackupSpinBox_;
178 };
179 
Interface class for creating custom context menus.
Update type class.
Definition: UpdateType.hh:60
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
QString name()
Return a name for the plugin.
Logtype
Log types for Message Window.
Interface for all plugins which want to Load or Save files and create Objects.
Interface for all Plugins which do logging to the logging window of the framework.
Class that is used to store global(group) backups.
Definition: GroupData.hh:54
void createBackup(int _objectId, QString _name, UpdateType _type=UPDATE_ALL)
Tell Backup Plugin to create a backup.
std::vector< int > IdList
Standard Type for id Lists used for scripting.
Definition: DataTypes.hh:179
QMenu * backupMenu_
The backup Menu.
Interface class from which all plugins have to be created.
Add a toolbox to OpenFlipper.
Keyboard Event Interface.
Definition: KeyInterface.hh:59
QString description()
Return a description of what the plugin is doing.
Predefined datatypes.
Definition: DataTypes.hh:83
Options Dialog interface.
Interface for all plugins which provide entries to the main menubar.
void slotEnableDisableBackups()
Backups enabled or disabled checkbox.
Interface class for backup handling.