1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
|
/*****
*
* TOra - An Oracle Toolkit for DBA's and developers
* Copyright (C) 2003-2005 Quest Software, Inc
* Portions Copyright (C) 2005 Other Contributors
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; only version 2 of
* the License is valid for this program.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* As a special exception, you have permission to link this program
* with the Oracle Client libraries and distribute executables, as long
* as you follow the requirements of the GNU GPL in regard to all of the
* software in the executable aside from Oracle client libraries.
*
* Specifically you are not permitted to link this program with the
* Qt/UNIX, Qt/Windows or Qt Non Commercial products of TrollTech.
* And you are not permitted to distribute binaries compiled against
* these libraries without written consent from Quest Software, Inc.
* Observe that this does not disallow linking to the Qt Free Edition.
*
* You may link this product with any GPL'd Qt library such as Qt/Free
*
* All trademarks belong to their respective owners.
*
*****/
#ifndef TOTEMPLATE_H
#define TOTEMPLATE_H
#include "config.h"
#include "tobackground.h"
#include "tohelp.h"
#include "toresultview.h"
#include <list>
#include <map>
#include <qvbox.h>
class QListView;
class QListViewItem;
class QSplitter;
class QTextView;
class QToolBar;
class toConnection;
class toListView;
class toTemplateItem;
class toTemplateProvider;
class toNoBlockQuery;
/** Not part of the API.
* @internal
*/
class toTemplate : public QVBox, public toHelpContext
{
Q_OBJECT
QToolBar *Toolbar;
toListView *List;
QWidget *WidgetExtra;
QWidget *Result;
QVBox *Frame;
public:
toTemplate(TODock *parent);
virtual ~toTemplate();
void setWidget(QWidget *widget);
QWidget *widget(void)
{
return WidgetExtra;
}
QWidget *frame(void);
static QWidget *parentWidget(QListViewItem *item);
static toTemplate *templateWidget(QListViewItem *item);
static toTemplate *templateWidget(QListView *obj);
static bool templateShown();
virtual bool canHandle(toConnection &)
{
return true;
}
void closeFrame(void);
void showResult(bool show);
void hideEvent(QHideEvent *);
void showEvent(QShowEvent *);
public slots:
void expand(QListViewItem *item);
void collapse(QListViewItem *item);
void selected(QListViewItem *item);
void hideTemplates();
};
/**
* This is the base class of a provider of template items. Usually it is created with
* a static object just like the tools. It can also be assumed that a maximum of one
* template window will be opened.
*/
class toTemplateProvider
{
/** List of currently available template providers.
*/
static std::list<toTemplateProvider *> *Providers;
static bool Shown;
static QCString *ToolKey;
;
QCString Name;
bool Open;
public:
toTemplateProvider(const QCString &name);
virtual ~toTemplateProvider()
{ }
/** Get name of this template provider.
*/
const QCString name()
{
return Name;
}
/** Insert a parent item for this template provider into a list view.
* @param parent The list into which to insert the item.
* @param toolbar The template toolbar if any buttons are to be added on it.
*/
virtual void insertItems(QListView *parent, QToolBar *toolbar) = 0;
/** Save settings for this template provider.
* @param data Map of data.
* @param prefix Prefix of where to save info.
*/
virtual void exportData(std::map<QCString, QString> &data, const QCString &prefix);
/** Save settings for all template providers.
* @param data Map of data.
* @param prefix Prefix of where to save info.
*/
static void exportAllData(std::map<QCString, QString> &data, const QCString &prefix);
/** Import data
* @param data Data to read from a map.
* @param prefix Prefix to read data from.
*/
virtual void importData(std::map<QCString, QString> &data, const QCString &prefix);
/** Import data for all template providers.
* @param data Data to read from a map.
* @param prefix Prefix to read data from.
*/
static void importAllData(std::map<QCString, QString> &data, const QCString &prefix);
/** Used internally to indicate if template help is shown.
*/
static void setShown(bool shown);
/** Used internally to indicate tool key string
*/
static void setToolKey(const QCString &key);
friend class toTemplate;
};
/** This is an item that is contained in a template. It is different in the expand and
* collapse methods that are called when this item is expanded or collapsed from the
* template widget.
*/
class toTemplateItem : public toResultViewItem
{
/** The provider responsible for this item.
*/
toTemplateProvider &Provider;
public:
/** Create an item.
* @param prov Provider for this item.
* @param parent Parent of this item.
* @param name Contents of the first column of the item.
*/
toTemplateItem(toTemplateProvider &prov, QListView *parent, const QString &name)
: toResultViewItem(parent, NULL, name), Provider(prov)
{ }
/** Create an item.
* @param parent Parent of this item.
* @param name Contents of the first column of the item.
* @param after The item to put this item after.
*/
toTemplateItem(toTemplateItem *parent, const QString &name, QListViewItem *after = NULL)
: toResultViewItem(parent, after, name), Provider(parent->provider())
{ }
/** Get a reference to the provider of this item.
* @return Reference to provider.
*/
toTemplateProvider &provider(void)
{
return Provider;
}
/** This function is called when the item is expanded and can be used to fill up the
* list when needed.
*/
virtual void expand(void)
{ }
/** This function is called when the item is selected by doubleclicking or pressing return.
*/
virtual void selected(void)
{ }
/** This function is called when the item is collapsed.
*/
virtual void collapse(void)
{ }
/** This function can be used to return a widget that is displays extra information for
* this item. Return NULL if no widget is to be displayed. The widget will be deleted
* when this item is no longer shown.
*/
virtual QWidget *selectedWidget(QWidget *parent);
/** Reimplemented for internal reasons.
*/
virtual void setSelected(bool sel);
};
/** This class represent a template item that have an extra text to describe it if it is
* selected.
*/
class toTemplateText : public toTemplateItem
{
/** The note to display.
*/
const QString Note;
public:
/** Create an item.
* @param parent Parent of this item.
* @param name Contents of the first column of the item.
* @param note Extra text to display if item is selected.
*/
toTemplateText(toTemplateItem *parent, const QString &name, const QString ¬e)
: toTemplateItem(parent, name), Note(note)
{ }
/** Reimplemented for internal reasons.
*/
virtual QWidget *selectedWidget(QWidget *parent);
};
class toTemplateSQL;
/** Used by toTemplateSQL. Only for internal use.
* @internal
*/
class toTemplateSQLObject : public QObject
{
Q_OBJECT
toNoBlockQuery *Query;
toBackground Poll;
toTemplateSQL *Parent;
toTemplateSQLObject(toTemplateSQL *parent);
virtual ~toTemplateSQLObject();
void expand(void);
friend class toTemplateSQL;
private slots:
void poll(void);
};
/** This class represent an item that when expanded will execute an SQL statement
* and create child items which are the result of the query.
*/
class toTemplateSQL : public toTemplateItem
{
toTemplateSQLObject Object;
/** Connection to run statement in
*/
toConnection *Connection;
/** Statement to run.
*/
QString SQL;
protected:
/** Create an item.
* @param conn Connection to query.
* @param parent Parent of this item.
* @param name Contents of the first column of the item.
* @param sql SQL statement.
*/
toTemplateSQL(toTemplateItem *parent,
const QString &name, const QString &sql);
public:
/** Create an item.
* @param conn Connection to query.
* @param parent Parent of this item.
* @param name Contents of the first column of the item.
* @param sql SQL statement.
*/
toTemplateSQL(toConnection &conn, toTemplateItem *parent,
const QString &name, const QString &sql);
/** Get connection of this item.
* @return Reference to connection.
*/
virtual toConnection &connection()
{
return *Connection;
}
/** Create a child of this item.
* @param name Name of the child.
* @return A newly created item.
*/
virtual toTemplateItem *createChild(const QString &name)
{
return new toTemplateItem(this, name);
}
/** Get parameters to pass to query.
* @return List of strings to pass as input parameters to query
*/
virtual toQList parameters(void)
{
toQList ret;
return ret;
}
/** Reimplemented for internal reasons.
*/
virtual void expand(void);
friend class toTemplateSQLObject;
};
#endif
|