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