3
* TOra - An Oracle Toolkit for DBA's and developers
4
* Copyright (C) 2003-2005 Quest Software, Inc
5
* Portions Copyright (C) 2005 Other Contributors
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; only version 2 of
10
* the License is valid for this program.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
* As a special exception, you have permission to link this program
22
* with the Oracle Client libraries and distribute executables, as long
23
* as you follow the requirements of the GNU GPL in regard to all of the
24
* software in the executable aside from Oracle client libraries.
26
* Specifically you are not permitted to link this program with the
27
* Qt/UNIX, Qt/Windows or Qt Non Commercial products of TrollTech.
28
* And you are not permitted to distribute binaries compiled against
29
* these libraries without written consent from Quest Software, Inc.
30
* Observe that this does not disallow linking to the Qt Free Edition.
32
* You may link this product with any GPL'd Qt library such as Qt/Free
34
* All trademarks belong to their respective owners.
42
#include "toconfiguration.h"
54
* Abstract baseclass for tools.
56
* This class is the baseclass of all classes defining tools. It
57
* contains functions for defining the priority and name of the tool,
58
* as well as virtual functions to define it's place in the user
59
* interface. Further it contains methods to access configuration
62
* To use this class you create a child which is then instantiated once
63
* which inserts that tool in the global tool map (See @ref tools). You
64
* should never delete a tool unless on exit. Usually tools are instantiated
65
* statically in the global scope.
68
class toTool : public QObject
77
* Key of the tool, this is used for sorting.
81
* Priority, used to determine in which order the tools should be listed.
85
* A map of @ref Key to tools. Used to keep track of the different tools
88
static std::map<QCString, toTool *> *Tools;
90
* Contain the pixmap of this tool if any. Used for the toolbar and menu entries.
92
QPixmap *ButtonPicture;
97
* Should return the xpm used to create the @ref ButtonPicture.
99
virtual const char **pictureXPM(void);
104
* @return Name of tool.
106
QCString name() const
113
* @return Name of tool.
122
* @return Priority of tool.
129
* This should never be called, but if it is. Erases the tool from the list of
130
* available tools. WARNING: It will not remove any of it's open tools.
135
* Create a tool. Remember that usually the main window is not created here.
137
* @param priority Priority of the created tool.
138
* @param name Name of tool.
140
toTool(int priority, const char *name);
142
* Get the image to display in the toolbar.
144
* @return Pointer to image in toolbar or NULL if no image should be displayed.
146
virtual const QPixmap *toolbarImage();
148
* Get the name of the menuitem to be displayed in the menu.
150
* @return A string containing the name of the menuentry or NULL if no menuentry should
153
virtual const char *menuItem()
158
* Get toolbar tip of the toolbar button. Defaults to same as @ref menuItem.
160
* @return Toolbar tip string.
162
virtual const char *toolbarTip()
167
/** Check if the tool can handle a specific connection. Default is to only handle
168
* connections from the provider Oracle.
169
* @return True if connection can be handled.
171
virtual bool canHandle(toConnection &conn);
173
* This function is called as a last step after the main widget is created. It could
174
* be used to insert the tool pretty much anywhere in the user interface if the toolmenu,
175
* toolbar is not sufficient.
177
* @param toolid The tool menu id that should be used if it inserts a custom menu entry.
179
virtual void customSetup(int toolid);
181
* Create a new tool window.
183
* @param parent Parent window, which is the worksheet of the main window.
184
* @param connection The database connection that this tool should operate on.
186
virtual QWidget *toolWindow(QWidget *parent, toConnection &connection) = 0;
188
* Create and return configuration tab for this tool. The returned widget should also
189
* be a childclass of @ref toSettingTab.
191
* @return A pointer to the widget containing the setup tab for this tool or NULL of
192
* no settings are available.
194
virtual QWidget *configurationTab(QWidget *parent);
196
/** Display an about dialog for this tool.
197
* @param parent The parent widget of the about dialog.
199
virtual void about(QWidget *parent);
200
/** Indicate whether or not this tool has an about dialog.
202
virtual bool hasAbout(void)
208
* Get access to the map of tools. Don't modify it. Observe that the index string is not
209
* the name of the tool but an internal key used to get tools sorted in the correct
213
* @return A reference to the tool map.
215
static std::map<QCString, toTool *> &tools(void)
218
Tools = new std::map<QCString, toTool *>;
222
* Get a pointer to the tool with a specified key.
225
* @return A pointer to the tool or NULL if tool doesn't exist.
227
static toTool *tool(const QCString &key);
230
* Get tool specific settings.
232
* Setting names are hierachical separated by ':' instead of '/' usually used
233
* in filenames. As an example all settings for the tool 'Example' would be
234
* under the 'Example:{settingname}' name.
236
* @param tag The name of the configuration setting.
237
* @param def Contents of this setting.
239
const QString &config(const QCString &tag,const QCString &def);
242
* Change toolspecific setting. Depending on the implementation this can change the
243
* contents on disk or not.
245
* Setting names are hierachical separated by ':' instead of '/' usually used
246
* in filenames. As an example all settings for the tool 'Example' would be
247
* under the 'Example:{settingname}' name.
249
* @param tag The name of the configuration setting.
250
* @param def Default value of the setting, if it is not available.
252
void setConfig(const QCString &tag,const QString &value);
254
virtual void closeWindow(toConnection &connection) = 0;
258
* Create a window of the current tool. This function sets up a toolwindow for
259
* this tool. It calls the @ref toolWindow function to get widget and sets it
262
void createWindow(void);
270
* Abstract baseclass for widgets defining tool settings.
273
class toSettingTab : public toHelpContext
277
* Default constructor.
278
* @param ctx Help context for this setting tab.
280
toSettingTab(const QString &ctx)
284
* This function is called to save the contents of the widget when
285
* a user has pressed the ok button of the dialog. It should simply
286
* save the values in the dialog to the appropriate configuration
287
* entry using the @ref toTool::setConfig function.
289
virtual void saveSetting(void) = 0;
292
/** This class is used to hold connections for @ref toResult classes.
293
* Must be multiply inherited by a widget otherwise it will go kaboom.
294
* It will dynamic cast itself to a QWidget from time to time so if that
295
* doesn't resolve correctly it will not work.
297
class toConnectionWidget
299
toConnection *Connection;
302
/** Constructor with the connection it should be set to initially.
304
toConnectionWidget(toConnection &conn, QWidget *widget);
305
/** Constructor without a connection. Will inherit the connection from a parent connection widget.
307
toConnectionWidget(QWidget *widget);
310
virtual ~toConnectionWidget();
311
/** Change connection of the widget.
313
virtual void setConnection(toConnection &conn);
314
/** Get the connection it is pointed to.
316
virtual toConnection &connection();
319
/** Simple baseclass for widgets defining the main tool widget. It is in
320
* no way mandatory and all it does is register the widget in the connetion.
322
class toToolWidget : public QVBox, public toHelpContext, public toConnectionWidget
328
void parentConnection(void);
330
/** Emitted when the connection is changed.
332
void connectionChange(void);
335
* @param ctx Help context for this tool.
336
* @param parent Parent widget.
337
* @param conn Connection of widget.
338
* @param name Name of widget.
340
toToolWidget(toTool &tool,
344
const char *name = NULL);
346
/** Get the current connection.
347
* @return Reference to connection.
349
toConnection &connection()
351
return toConnectionWidget::connection();
353
/** Get the tool for this tool widget.
354
* @return Reference to a tool object.
360
/** Check if this tool can handle a specific connection.
361
* @param provider Name of connection.
362
* @return True if connection is handled.
364
virtual bool canHandle(toConnection &conn)
366
return Tool.canHandle(conn);
368
/** Change connection of tool.
370
void setConnection(toConnection &conn);
371
/** Get timer of tool. Used by some results to get update time.
372
* @return Pointer to a timer object.
374
toTimer *timer(void);
376
/** Export data to a map.
377
* @param data A map that can be used to recreate the data of a chart.
378
* @param prefix Prefix to add to the map.
380
virtual void exportData(std::map<QCString, QString> &data, const QCString &prefix);
382
* @param data Data to read from a map.
383
* @param prefix Prefix to read data from.
385
virtual void importData(std::map<QCString, QString> &data, const QCString &prefix);