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.
38
#ifndef TORESULTCONTENT_H
39
#define TORESULTCONTENT_H
42
#include "tobackground.h"
43
#include "toconnection.h"
44
#include "toeditwidget.h"
45
#include "tomemoeditor.h"
59
class toResultContent;
60
class toSearchReplace;
62
/** Implement memo editor in result content editor. Only for internal use.
66
class toResultContentMemo : public toMemoEditor
70
toResultContentEditor *contentEditor();
72
toResultContentMemo(QWidget *parent, const QString &data, int row, int col,
75
virtual void firstColumn();
76
virtual void nextColumn();
77
virtual void previousColumn();
78
virtual void lastColumn();
80
virtual void changePosition(int row, int cols);
83
/** This widget is used for single record view in the content editor. Only for internal use.
87
class toResultContentSingle : public QScrollView
93
std::list<QCheckBox *> Null;
94
std::list<QLineEdit *> Value;
96
toResultContentSingle(QWidget *parent);
98
void changeSource(QTable *table);
99
void changeRow(QTable *table, int row);
100
void saveRow(QTable *table, int row);
102
virtual void showMemo(int row);
105
/** This widget allows the user to browse the contents of a table and also edit
106
* the content. The table is specified by the first and second parameter in the query.
107
* The sql is not used in the query. Only for internal use.
110
class toResultContentEditor : public QTable, public toEditWidget
114
/** Single record form.
116
toResultContentSingle *SingleEdit;
123
/** The SQL used to read the data.
126
/** Original values of rows currently being edited.
128
std::list<QString> OrigValues;
129
/** Original values of rows currently being edited.
132
/** Stream to read data from.
134
toNoBlockQuery *Query;
136
toQDescList Description;
141
/** Number of rows read from stream.
144
/** Current row of editing.
147
/** Current row of editing.
150
/** Used to detect drag.
154
/** Popup menu if available.
157
/** Column of item selected when popup menu displayed.
160
/** Row of item selected when popup menu displayed.
164
/** Current sorting row.
167
/** Indicate if sorting ascending or descending.
171
/** Use filter for all tables.
174
/** Filter selection criteria
176
static std::map<QCString, QString> Criteria;
177
/** Filter retrieve order
179
static std::map<QCString, QString> Order;
180
/** Current filter name in map
183
/** Never use returning.
187
/** Throw an exception about wrong usage.
189
void wrongUsage(void);
192
/** Reimplemented for internal reasons.
194
virtual void drawContents(QPainter * p, int cx, int cy, int cw, int ch);
195
/** Reimplemented for internal reasons.
197
virtual QWidget *beginEdit(int row, int col, bool replace);
198
virtual void endEdit(int row, int col, bool accept, bool replace);
200
/** Reimplemented for internal reasons.
202
virtual void paintCell(QPainter *p, int row, int col, const QRect &cr, bool selected);
203
/** Reimplemented for internal reasons.
205
virtual bool eventFilter(QObject *o, QEvent *e);
206
/** Reimplemented for internal reasons.
208
virtual void keyPressEvent(QKeyEvent *e);
209
/** Reimplemented for internal reasons.
211
virtual void activateNextCell();
213
/** Reimplemented for internal reasons.
215
virtual void dragEnterEvent(QDragEnterEvent *event);
216
/** Reimplemented for internal reasons.
218
virtual void dropEvent(QDropEvent *event);
219
/** Reimplemented for internal reasons.
221
virtual void contentsMousePressEvent(QMouseEvent *e);
222
/** Reimplemented for internal reasons.
224
virtual void contentsMouseReleaseEvent(QMouseEvent *e);
225
/** Reimplemented for internal reasons.
227
virtual void contentsMouseMoveEvent (QMouseEvent *e);
228
/** Reimplemented for internal reasons.
230
virtual void focusInEvent (QFocusEvent *e);
231
/** A setCurrentCell() replacement; makes sure that we have focus.
233
virtual void setCurrentCellFocus(int row, int col);
239
toConnection &connection();
240
QLineEdit *CurrentEditor;
244
class contentItem : public QTableItem
247
contentItem(QTable *table, const QString &text);
248
virtual QString key(void) const;
251
toListView *copySelection(bool);
253
/** Indicate that editor should never use returning clauses even if this is oracle.
255
void useNoReturning(bool use)
257
NoUseReturning = use;
259
/** Create the widget.
260
* @param parent Parent widget.
261
* @param name Name of widget.
263
toResultContentEditor(QWidget *parent, const char *name = NULL);
266
~toResultContentEditor();
267
/** Reimplemented for internal reasons.
269
virtual void query(const QString &, const toQList &);
270
/** Reimplemented for internal reasons.
272
virtual void changeParams(const QString &Param1, const QString &Param2)
275
pars.insert(pars.end(), Param1);
276
pars.insert(pars.end(), Param2);
277
query(QString::null, pars);
280
/** Print this editor.
282
virtual void editPrint(void);
283
/** Reimplemented for internal reasons.
285
virtual bool editSave(bool ask);
286
/** Reimplemented for internal reasons.
288
virtual void editReadAll(void);
289
/** Select all contents. Default NOP.
291
virtual void editSelectAll(void);
293
/** Reimplemented for internal reasons.
295
virtual void setText(int row, int col, const QString &text);
297
/** Set a new filter setting.
298
* @param all Apply filter to all tables, otherwise only for this table.
299
* @param criteria Criteria to filter on.
300
* @param order Order to read data on.
302
void changeFilter(bool all, const QString &criteria, const QString &order);
304
/** Get information about if filter affect all tables.
311
friend class contentItem;
312
friend class toResultContent;
314
/** Export data to a map.
315
* @param data A map that can be used to recreate the data of a chart.
316
* @param prefix Prefix to add to the map.
318
virtual void exportData(std::map<QCString, QString> &data, const QCString &prefix);
320
* @param data Data to read from a map.
321
* @param prefix Prefix to read data from.
323
virtual void importData(std::map<QCString, QString> &data, const QCString &prefix);
325
/** Erase last parameters
327
virtual void clearParams(void)
329
Owner = Table = QString::null;
331
/** Change sorting column
332
* @param col Column selected to change as sorting.
334
virtual void changeSort(int col);
335
/** Current cell changed.
336
* @param row New row.
337
* @param col New column.
339
void changePosition(int row, int col);
341
/** Display popup menu
342
* @param p Point to display popup at.
344
virtual void displayMenu(const QPoint &p);
345
/** Display editable memo viewer at current position.
347
virtual void displayMemo(void);
348
/** Save unsaved changes in the editor
350
virtual void saveUnsaved(void);
351
/** Delete the current row from the table.
353
virtual void deleteCurrent(void);
354
/** Add a new record to the table.
356
virtual void addRecord(void);
357
/** Duplicate a new record for editing.
359
virtual void duplicateRecord(void);
360
/** Discard the changes made to the table.
362
virtual void cancelEdit(void);
363
/** Goto the last record in the table.
365
virtual void gotoLastRecord(void);
366
/** Goto the first record in the table.
368
virtual void gotoFirstRecord(void);
369
/** Goto the previous record in the table.
371
virtual void gotoPreviousRecord(void);
372
/** Goto the next record in the table.
374
virtual void gotoNextRecord(void);
375
/** Display single record form.
377
virtual void singleRecordForm(bool display);
379
/** Move to top of data
381
virtual void searchTop(void)
383
setCurrentCell(0, 0);
385
/** Search for next entry
386
* @return True if found, should select the found text.
388
virtual bool searchNext(toSearchReplace *search);
389
/** Replace entry with new data
391
virtual void searchReplace(const QString &newData);
392
/** Check if data can be modified by search
393
* @param all If true can replace all, otherwise can replace right now.
395
virtual bool searchCanReplace(bool all);
397
/** Emitted to indicate wether a filter is used.
399
void filterEnabled(bool);
400
//* Emitted when changes were saved.
403
/** Callback from popup menu.
404
* @param cmd Command ID.
406
virtual void menuCallback(int cmd);
407
/** Change data at specified position.
408
* @param row Row to change.
409
* @param col Column to change.
410
* @param data New contents of data.
412
virtual void changeData(int row, int col, const QString &data);
414
virtual void poll(void);
417
/** This widget allows the user to browse the contents of a table and also edit
418
* the content. The table is specified by the first and second parameter in the query.
419
* The sql is not used in the query.
422
class toResultContent : public QVBox, public toResult
426
toResultContentEditor *Editor;
428
/** Create the widget.
429
* @param parent Parent widget.
430
* @param name Name of widget.
432
toResultContent(QWidget *parent, const char *name = NULL);
434
/** Get content editor table widget
435
* @return Pointer to editor.
437
toResultContentEditor *editor(void)
442
/** Read all rows from the table.
444
virtual void editReadAll(void)
446
Editor->editReadAll();
448
/** Print the contents.
450
virtual void editPrint(void)
454
/** Export contents to file.
456
virtual void editSave(bool ask)
458
Editor->editSave(ask);
461
/** Export data to a map.
462
* @param data A map that can be used to recreate the data of a chart.
463
* @param prefix Prefix to add to the map.
465
virtual void exportData(std::map<QCString, QString> &data, const QCString &prefix)
467
Editor->exportData(data, prefix);
470
* @param data Data to read from a map.
471
* @param prefix Prefix to read data from.
473
virtual void importData(std::map<QCString, QString> &data, const QCString &prefix)
475
Editor->importData(data, prefix);
477
/** Indicate that editor should never use returning clauses even if this is oracle.
479
void useNoReturning(bool use)
481
Editor->useNoReturning(use);
484
void changeFilter(void);
485
void removeFilter(void);
487
//* Emitted when changes were saved.
488
void changesSaved(void);
490
/** Erase last parameters
492
virtual void clearParams(void)
494
toResult::clearParams();
495
Editor->clearParams();
497
/** Reimplemented for internal reasons.
499
virtual void refresh(void)
503
/** Reimplemented for internal reasons.
505
virtual void query(const QString &sql, const toQList ¶m)
507
if (!setSQLParams(sql, param))
509
Editor->query(sql, param);
511
/** Reimplemented for internal reasons.
513
virtual void changeParams(const QString &Param1)
515
toResult::changeParams(Param1);
517
/** Reimplemented for internal reasons.
519
virtual void changeParams(const QString &Param1, const QString &Param2)
521
toResult::changeParams(Param1, Param2);
523
/** Reimplemented for internal reasons.
525
virtual void changeParams(const QString &Param1, const QString &Param2, const QString &Param3)
527
toResult::changeParams(Param1, Param2, Param3);
529
/** Save unsaved changes in the editor
531
virtual void saveUnsaved(void)
533
Editor->saveUnsaved();
535
/** Commit connection
536
* @param conn Connection commit is made on.
537
* @param cmt If commit or rollback
539
virtual void saveUnsaved(toConnection &conn, bool cmt);
541
/** Handle all databases
543
virtual bool canHandle(toConnection &);