3
<TITLE>Source: toresultview.h</TITLE>
5
<META NAME="Generator" CONTENT="KDOC ">
7
<BODY bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#000099" alink= "#ffffff">
8
<TABLE WIDTH="100%" BORDER="0">
12
<TR><TD valign="top" align="left" cellspacing="10">
13
<h1>Source: toresultview.h</h1>
15
<TD valign="top" align="right" colspan="1"></TD></TR>
22
<TD align="right"><TABLE BORDER="0"><TR><TD><small><A HREF="index-long.html">Annotated List</A></small></TD></TR>
23
<TR><TD><small><A HREF="header-list.html">Files</A></small></TD></TR>
24
<TR><TD><small><A HREF="all-globals.html">Globals</A></small></TD></TR>
25
<TR><TD><small><A HREF="hier.html">Hierarchy</A></small></TD></TR>
26
<TR><TD><small><A HREF="index.html">Index</A></small></TD></TR>
27
</TABLE></TD></TR></TABLE>
31
* TOra - An Oracle Toolkit for DBA's and developers
32
* Copyright (C) 2003-2005 Quest Software, Inc
33
* Portions Copyright (C) 2005 Other Contributors
35
* This program is free software; you can redistribute it and/or
36
* modify it under the terms of the GNU General Public License
37
* as published by the Free Software Foundation; only version 2 of
38
* the License is valid for this program.
40
* This program is distributed in the hope that it will be useful,
41
* but WITHOUT ANY WARRANTY; without even the implied warranty of
42
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43
* GNU General Public License for more details.
45
* You should have received a copy of the GNU General Public License
46
* along with this program; if not, write to the Free Software
47
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
49
* As a special exception, you have permission to link this program
50
* with the Oracle Client libraries and distribute executables, as long
51
* as you follow the requirements of the GNU GPL in regard to all of the
52
* software in the executable aside from Oracle client libraries.
54
* Specifically you are not permitted to link this program with the
55
* Qt/UNIX, Qt/Windows or Qt Non Commercial products of TrollTech.
56
* And you are not permitted to distribute binaries compiled against
57
* these libraries without written consent from Quest Software, Inc.
58
* Observe that this does not disallow linking to the Qt Free Edition.
60
* You may link this product with any GPL'd Qt library such as Qt/Free
62
* All trademarks belong to their respective owners.
66
#ifndef TORESULTVIEW_H
67
#define TORESULTVIEW_H
69
#include "toeditwidget.h"
71
#include "toresultlistformatui.h"
73
#include <qlistview.h>
85
class toSearchReplace;
87
/** Baseclass for filters to apply to the @ref toResultView to filter out
88
* rows that you don't want to add as items to the list.
90
class toResultFilter {
94
virtual ~toResultFilter()
96
virtual void startingQuery(void)
98
/** This function can inspect the item to be added and decide if it is
99
* valid for adding or not.
100
* @param item Item to inspect.
101
* @return If false is returned the item isn't added.
103
virtual bool check(const QListViewItem *item) = 0;
104
/** Create a copy of this filter.
105
* @return A newly created copy of this filter.
107
virtual toResultFilter *clone(void) = 0;
108
/** Export data to a map.
109
* @param data A map that can be used to recreate the data of a chart.
110
* @param prefix Prefix to add to the map.
112
virtual void exportData(std::map<QCString,QString> &data,const QCString &prefix);
114
* @param data Data to read from a map.
115
* @param prefix Prefix to read data from.
117
virtual void importData(std::map<QCString,QString> &data,const QCString &prefix);
120
/** An item to display in a toListView or toResultView. They differ from normal
121
* QListViewItems in that they can have a tooltip and actually contain more text
122
* than is displayed in the cell of the listview.
124
class toResultViewItem : public QListViewItem {
130
enum { String,Number } Type;
134
QString firstText(int col) const;
136
virtual int realWidth(const QFontMetrics &fm, const QListView *top, int column,const QString &txt) const;
138
/** Create a new item.
139
* @param parent Parent list view.
140
* @param after Insert after this item.
141
* @param buffer String to set as first column
143
toResultViewItem(QListView *parent,QListViewItem *after,const QString &buf=QString::null)
144
: QListViewItem(parent,after,QString::null)
145
{ ColumnData=NULL; ColumnCount=0; if (buf) setText(0,buf); }
146
/** Create a new item.
147
* @param parent Parent to this item.
148
* @param after Insert after this item.
149
* @param buffer String to set as first column
151
toResultViewItem(QListViewItem *parent,QListViewItem *after,const QString &buf=QString::null)
152
: QListViewItem(parent,after,QString::null)
153
{ ColumnData=NULL; ColumnCount=0; if (buf) setText(0,buf); }
154
/** Reimplemented for internal reasons.
156
virtual ~toResultViewItem()
157
{ delete[] ColumnData; }
158
/** Reimplemented for internal reasons.
160
virtual void setText (int col,const QString &txt);
161
/** Set from database.
163
virtual void setText (int col,const toQValue &val);
164
/** Reimplemented for internal reasons.
166
virtual void paintCell(QPainter * p,const QColorGroup & cg,int column,int width,int align);
167
/** Reimplemented for internal reasons.
169
virtual QString text(int col) const;
170
/** String to sort the data on. This is reimplemented so that numbers are sorted as numbers
171
* and not as strings.
173
* @param asc Wether to sort ascending or not.
175
virtual QString key(int col,bool asc) const
176
{ if (col>=ColumnCount) return QString::null; return asc?ColumnData[col].KeyAsc:ColumnData[col].KeyDesc; }
177
/** Reimplemented for internal reasons.
179
virtual int width(const QFontMetrics &, const QListView *, int col) const
180
{ if (col>=ColumnCount) return 0; return ColumnData[col].Width; }
181
/** Get all text for this item. This is used for copying, drag & drop and memo editing etc.
183
* @return All of the text.
185
virtual QString allText(int col) const
186
{ if (col>=ColumnCount) return QString::null; return ColumnData[col].Data; }
187
/** Get the text to be displayed as tooltip for this item.
189
* @return The text to display as tooltip.
191
virtual QString tooltip(int col) const
192
{ return allText(col); }
195
/** This item expands the height to commodate all lines in the input buffer.
197
class toResultViewMLine : public toResultViewItem {
199
/** Number of lines in the largest row.
203
virtual int realWidth(const QFontMetrics &fm, const QListView *top, int column,const QString &txt) const;
205
/** Create a new item.
206
* @param parent Parent list view.
207
* @param after Insert after this item.
208
* @param buffer String to set as first column
210
toResultViewMLine(QListView *parent,QListViewItem *after,const QString &buf=QString::null)
211
: toResultViewItem(parent,after,QString::null)
212
{ Lines=1; if (buf) setText(0,buf); }
213
/** Create a new item.
214
* @param parent Parent to this item.
215
* @param after Insert after this item.
216
* @param buffer String to set as first column
218
toResultViewMLine(QListViewItem *parent,QListViewItem *after,const QString &buf=QString::null)
219
: toResultViewItem(parent,after,QString::null)
220
{ Lines=1; if (buf) setText(0,buf); }
221
/** Reimplemented for internal reasons.
223
virtual void setText (int,const QString &);
224
/** Set from database.
226
virtual void setText (int col,const toQValue &val);
227
/** Reimplemented for internal reasons.
229
virtual void setup(void);
230
/** Reimplemented for internal reasons.
232
virtual QString text(int col) const
233
{ return toResultViewItem::allText(col); }
234
/** Reimplemented for internal reasons.
236
virtual void paintCell (QPainter *pnt,const QColorGroup & cg,int column,int width,int alignment);
239
/** An item to display in a toListView or toResultView. They differ from normal
240
* QListViewItems in that they can have a tooltip and actually contain more text
241
* than is displayed in the cell of the listview.
243
class toResultViewCheck : public QCheckListItem {
249
enum { String,Number } Type;
254
virtual int realWidth(const QFontMetrics &fm, const QListView *top, int column,const QString &txt) const;
255
QString firstText(int col) const;
257
/** Create a new item.
258
* @param parent Parent list view.
259
* @param text Text of first column.
260
* @param type Type of check on this item.
262
toResultViewCheck(QListView *parent,const QString &text,QCheckListItem::Type type=Controller)
263
: QCheckListItem(parent,QString::null,type)
264
{ ColumnData=NULL; ColumnCount=0; if (!text.isNull()) setText(0,text); }
265
/** Create a new item.
266
* @param parent Parent item.
267
* @param text Text of first column.
268
* @param type Type of check on this item.
270
toResultViewCheck(QListViewItem *parent,const QString &text,QCheckListItem::Type type=Controller)
271
: QCheckListItem(parent,QString::null,type)
272
{ ColumnData=NULL; ColumnCount=0; if (!text.isNull()) setText(0,text); }
273
/** Create a new item.
274
* @param parent Parent list view.
275
* @param after After last item.
276
* @param text Text of first column.
277
* @param type Type of check on this item.
279
toResultViewCheck(QListView *parent,QListViewItem *after,const QString &text,QCheckListItem::Type type=Controller);
280
/** Create a new item.
281
* @param parent Parent item.
282
* @param after After last item.
283
* @param text Text of first column.
284
* @param type Type of check on this item.
286
toResultViewCheck(QListViewItem *parent,QListViewItem *after,const QString &text,QCheckListItem::Type type=Controller);
287
/** Reimplemented for internal reasons.
289
virtual ~toResultViewCheck()
290
{ delete[] ColumnData; }
291
/** Reimplemented for internal reasons.
293
virtual void setText (int col,const QString &txt);
294
/** Set from database.
296
virtual void setText (int col,const toQValue &val);
297
/** Reimplemented for internal reasons.
299
virtual void paintCell(QPainter * p,const QColorGroup & cg,int column,int width,int align);
300
/** Reimplemented for internal reasons.
302
virtual QString text(int col) const;
303
/** String to sort the data on. This is reimplemented so that numbers are sorted as numbers
304
* and not as strings.
306
* @param asc Wether to sort ascending or not.
308
/** String to sort the data on. This is reimplemented so that numbers are sorted as numbers
309
* and not as strings.
311
* @param asc Wether to sort ascending or not.
313
virtual QString key(int col,bool asc) const
314
{ if (col>=ColumnCount) return QString::null; return asc?ColumnData[col].KeyAsc:ColumnData[col].KeyDesc; }
315
/** Reimplemented for internal reasons.
317
virtual int width(const QFontMetrics &, const QListView *, int col) const
318
{ if (col>=ColumnCount) return 0; return ColumnData[col].Width; }
319
/** Get all text for this item. This is used for copying, drag & drop and memo editing etc.
321
* @return All of the text.
323
virtual QString allText(int col) const
324
{ if (col>=ColumnCount) return QString::null; return ColumnData[col].Data; }
325
/** Get the text to be displayed as tooltip for this item.
327
* @return The text to display as tooltip.
329
virtual QString tooltip(int col) const
330
{ return allText(col); }
333
/** This item expands the height to commodate all lines in the input buffer.
335
class toResultViewMLCheck : public toResultViewCheck {
337
/** Number of lines in the largest row.
341
virtual int realWidth(const QFontMetrics &fm, const QListView *top, int column,const QString &txt) const;
343
/** Create a new item.
344
* @param parent Parent list view.
345
* @param text Text of first column.
346
* @param type Type of check on this item.
348
toResultViewMLCheck(QListView *parent,const QString &text,QCheckListItem::Type type=Controller)
349
: toResultViewCheck(parent,QString::null,type)
350
{ Lines=1; if (!text.isNull()) setText(0,text); }
351
/** Create a new item.
352
* @param parent Parent item.
353
* @param text Text of first column.
354
* @param type Type of check on this item.
356
toResultViewMLCheck(QListViewItem *parent,const QString &text,QCheckListItem::Type type=Controller)
357
: toResultViewCheck(parent,QString::null,type)
358
{ Lines=1; if (!text.isNull()) setText(0,text); }
359
/** Reimplemented for internal reasons.
361
virtual void setup(void);
362
/** Reimplemented for internal reasons.
364
virtual void setText (int,const QString &);
365
/** Set from database.
367
virtual void setText (int col,const toQValue &val);
368
/** Reimplemented for internal reasons.
370
virtual QString text(int col) const
371
{ return toResultViewCheck::allText(col); }
372
/** Reimplemented for internal reasons.
374
virtual void paintCell (QPainter *pnt,const QColorGroup & cg,int column,int width,int alignment);
378
* The TOra implementation of a listview which offers a few extra goodies to the baseclass.
379
* First of all tooltip which can display contents that doesn't fit in the list, printing,
380
* integration into toMain with Edit menu etc, drag & drop, export as file, display item
381
* as memo and context menu.
383
class toListView : public QListView,public toEditWidget {
388
/** Name of this list, used primarily when printing. Also used to be able to edit
389
* SQL displayed in @ref toResultView.
392
/** Used to display tip on fields.
395
/** Item selected when popup menu displayed.
397
QListViewItem *MenuItem;
398
/** Column of item selected when popup menu displayed.
401
/** Popup menu if available.
404
/** Last move, used to determine if drag has started.
408
/** Reimplemented for internal reasons.
410
virtual void contentsMouseDoubleClickEvent (QMouseEvent *e);
411
/** Reimplemented for internal reasons.
413
virtual void contentsMousePressEvent(QMouseEvent *e);
414
/** Reimplemented for internal reasons.
416
virtual void contentsMouseReleaseEvent(QMouseEvent *e);
417
/** Reimplemented for internal reasons.
419
virtual void contentsMouseMoveEvent (QMouseEvent *e);
421
/** Used to print one page of the list.
422
* @param printer Printer to print to.
423
* @param painter Painter to print page to.
424
* @param top Item at top of page.
425
* @param column Column to start printing at. Will be changed to where you are when done.
426
* @param level The indentation level of the top item.
427
* @param pageNo Page number.
428
* @param paint If just testing to determine how many pages are needed set this to false.
429
* @return The next item to print to (Pass as top to this function).
431
virtual QListViewItem *printPage(TOPrinter *printer,QPainter *painter,QListViewItem *top,
432
int &column,int &level,int pageNo,bool paint=true);
433
int exportType(QString &separator,QString &delimiter);
435
/** Create new list view.
436
* @param parent Parent of list.
437
* @param name Name of list.
438
* @param f Widget flags.
440
toListView(QWidget *parent,const char *name=NULL,WFlags f=0);
441
virtual ~toListView();
443
/** Get SQL name of list.
445
virtual QString sqlName(void)
447
/** Set SQL name of list.
449
virtual void setSQLName(const QString &name)
451
/** Get the whole text for the item and column selected when menu was poped up.
453
QString menuText(void);
457
virtual void editPrint(void);
458
/** Reimplemented for internal reasons.
460
virtual void focusInEvent (QFocusEvent *e);
461
/** The string to be displayed in the middle of the footer when printing.
462
* @return String to be placed in middle.
464
virtual QString middleString()
465
{ return QString::null; }
466
/** Adds option to add menues to the popup menu before it is displayed.
467
* @param menu Menu to add entries to.
469
virtual void addMenues(QPopupMenu *menu);
470
/** Export list as a string.
471
* @param includeHeader Include header.
472
* @param onlySelection Only include selection.
473
* @param type Format of exported list.
474
* @param separator Separator for CSV format.
475
* @param delimiter Delimiter for CSV format.
477
virtual QString exportAsText(bool includeHeader,bool onlySelection,int type=-1,const QString &separator=";",const QString &delimiter="\"");
478
/** Export list as file.
480
virtual bool editSave(bool ask);
482
/** Select all contents.
484
virtual void editSelectAll(void)
487
/** Move to top of data
489
virtual void searchTop(void)
490
{ if (firstChild()) setCurrentItem(firstChild()); FirstSearch=true; }
491
/** Search for next entry
492
* @return True if found, should select the found text.
494
virtual bool searchNext(toSearchReplace *search);
495
/** Check if data can be modified by search
496
* @param all If true can replace all, otherwise can replace right now.
498
virtual bool searchCanReplace(bool all);
500
/** Export data to a map.
501
* @param data A map that can be used to recreate the data of a chart.
502
* @param prefix Prefix to add to the map.
504
virtual void exportData(std::map<QCString,QString> &data,const QCString &prefix);
506
* @param data Data to read from a map.
507
* @param prefix Prefix to read data from.
509
virtual void importData(std::map<QCString,QString> &data,const QCString &prefix);
510
/** Create transposed copy of list
511
* @return Pointer to newly allocated transposed listview.
513
virtual toListView *copyTransposed(void);
515
/** Called before the menu is displayed so that you can add items to it before it is shown.
516
* @param menu Pointer to the menu about to be shown.
518
void displayMenu(QPopupMenu *menu);
520
/** set the popup menu --> see displayMenu()
521
* @param item Item to display.
523
virtual void setDisplayMenu(QPopupMenu *item);
524
/** Display the menu at the given point and column.
525
* @param item Item to display.
526
* @param pnt Point to display menu at.
527
* @param col Column to display menu for.
529
virtual void displayMenu(QListViewItem *item,const QPoint &pnt,int col);
530
/** Display memo of selected menu column
532
virtual void displayMemo(void);
534
/** Callback when menu is selected. If you override this make sure you
535
* call the parents function when you have parsed your entries.
536
* @param id ID of the menu item selected.
538
virtual void menuCallback(int id);
542
* This class defines a list which displays the result of a query.
544
* One special thing to know about this class is that columns at the end in which the
545
* description start with a '-' characters are not displayed.
548
class toResultView : public toListView, public toResult {
555
/** Reimplemented for internal reasons.
557
virtual void keyPressEvent (QKeyEvent * e);
559
/** Connection to execute statement on.
564
QListViewItem *LastItem;
566
/** Number of rows in list.
569
/** If column names are to be made more readable.
571
bool ReadableColumns;
572
/** Wether to display first number column or not.
575
/** If all the available data should be read at once.
578
/** Input filter if any.
580
toResultFilter *Filter;
583
* @param readable Wether to display first number column or not.
584
* @param dispCol Wether to display first number column or not.
586
void setup(bool readable,bool dispCol);
588
/** Check if end of query is detected yet or not.
590
virtual bool eof(void);
594
* @param readable Indicate if columns are to be made more readable. This means that the
595
* descriptions are capitalised and '_' are converted to ' '.
596
* @param numCol If number column is to be displayed.
597
* @param parent Parent of list.
598
* @param name Name of widget.
599
* @param f Widget flags.
601
toResultView(bool readable,bool numCol,QWidget *parent,const char *name=NULL,WFlags f=0);
602
/** Create list. The columns are not readable and the number column is displayed.
603
* @param parent Parent of list.
604
* @param name Name of widget.
605
* @param f Widget flags.
607
toResultView(QWidget *parent,const char *name=NULL,WFlags f=0);
610
/** Set the read all flag.
611
* @param all New value of flag.
613
void setReadAll(bool all)
616
/** Get read all flag
617
* @return Value of read all flag.
619
virtual void editReadAll(void);
621
/** Get the number of columns in query.
622
* @return Columns in query.
624
int queryColumns() const;
626
/** Get the query used to execute this.
631
/** Set a filter to this list.
632
* @param filter The new filter or NULL if no filter is to be used.
634
void setFilter(toResultFilter *filter)
636
/** Get the current filter.
637
* @return Current filter or NULL if no filter.
639
toResultFilter *filter(void)
642
/** Get number column flag.
643
* @return Wether or not the numbercolumn is displayed.
645
bool numberColumn() const
646
{ return NumberColumn; }
647
/** Set number column flag. Don't change this while a query is running. Observe
648
* that not all descendants of this class support changing this on the fly. The base
649
* class and @ref toResultLong does though.
650
* @param val New value of number column.
652
void setNumberColumn(bool val)
653
{ NumberColumn=val; }
655
/** Get readable column flag.
656
* @return Wether or not the readable column names.
658
bool readableColumn() const
659
{ return ReadableColumns; }
660
/** Set readable column flag.
662
void setReadableColumns(bool val)
663
{ ReadableColumns=val; }
665
/** Create a new item in this list. Can be used if a special kind of item is wanted
666
* in the list. The rest of the columns will be filled with setText.
667
* @param last Where to insert the item.
668
* @param str String to set first column to.
669
* @return Allocated item.
671
virtual QListViewItem *createItem(QListViewItem *last,const QString &str);
673
/** Reimplemented for internal reasons.
675
virtual void query(const QString &sql,const toQList ¶m);
677
/** Get SQL name of list.
679
virtual QString sqlName(void)
680
{ return toListView::sqlName(); }
681
/** Set SQL name of list.
683
virtual void setSQLName(const QString &name)
684
{ toListView::setSQLName(name); }
686
// Why are these needed?
688
/** Set the SQL statement of this list
689
* @param sql String containing statement.
691
void setSQL(const QString &sql)
692
{ toResult::setSQL(sql); }
693
/** Set the SQL statement of this list. This will also affect @ref Name.
694
* @param sql SQL containing statement.
696
void setSQL(const toSQL &sql)
697
{ toResult::setSQL(sql); }
698
/** Set new SQL and run query.
699
* @param sql New sql.
702
void query(const QString &sql)
703
{ toResult::query(sql); }
704
/** Set new SQL and run query.
705
* @param sql New sql.
708
void query(const toSQL &sql)
709
{ toResult::query(sql); }
710
/** Set new SQL and run query.
711
* @param sql New sql.
714
void query(const toSQL &sql,toQList &par)
715
{ toResult::query(sql,par); }
718
/** Reimplemented for internal reasons.
720
virtual void editPrint(void)
721
{ editReadAll(); toListView::editPrint(); }
722
/** Reimplemented for internal reasons.
724
virtual QString middleString();
726
/** Reimplemented for internal reasons.
728
virtual void addMenues(QPopupMenu *);
729
/** Reimplemented for internal reasons.
731
virtual void setSorting(int col,bool asc=true);
732
/** Reimplemented for internal reasons.
734
virtual int sortColumn() const
735
{ return SortColumn; }
737
/** Reimplemented for internal reasons.
739
virtual void refresh(void);
740
/** Reimplemented for internal reasons.
742
virtual void changeParams(const QString &Param1)
743
{ toResult::changeParams(Param1); }
744
/** Reimplemented For internal reasons.
746
virtual void changeParams(const QString &Param1,const QString &Param2)
747
{ toResult::changeParams(Param1,Param2); }
748
/** Reimplemented for internal reasons.
750
virtual void changeParams(const QString &Param1,const QString &Param2,const QString &Param3)
751
{ toResult::changeParams(Param1,Param2,Param3); }
752
/** Try to add an item to the list if available.
754
virtual void addItem(void);
755
/** Handle any connection by default
757
virtual bool canHandle(toConnection &)
760
void headingClicked(int col);
761
void checkHeading(void);
763
/** Reimplemented for internal reasons.
765
virtual void menuCallback(int);
769
* Used internally by toListView.
773
class toResultListFormat : public toResultListFormatUI {
776
toResultListFormat(QWidget *parent,const char *name);
777
void saveDefault(void);
779
virtual void formatChanged(int pos);
786
<tr><td><small>Generated by: nneul on skyhawk on Wed Feb 23 19:49:58 2005, using kdoc 2.0a54.</small></td></tr>