~ubuntu-branches/ubuntu/wily/tora/wily-proposed

« back to all changes in this revision

Viewing changes to doc/help/api/toresultview_h.html

  • Committer: Bazaar Package Importer
  • Author(s): Albin Tonnerre
  • Date: 2007-05-29 13:13:36 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070529131336-85ygaddivvmkd3xc
Tags: 1.3.21pre22-1ubuntu1
* Merge from Debian unstable. Remaining Ubuntu changes:
  - debian/rules: call dh_iconcache
  - Remove g++ build dependency
* Modify Maintainer value to match Debian-Maintainer-Field Spec

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<HTML>
 
2
<HEAD>
 
3
<TITLE>Source: toresultview.h</TITLE>
 
4
 
 
5
<META NAME="Generator" CONTENT="KDOC ">
 
6
</HEAD>
 
7
<BODY bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#000099" alink= "#ffffff">
 
8
<TABLE WIDTH="100%" BORDER="0">
 
9
<TR>
 
10
<TD>
 
11
        <TABLE BORDER="0">
 
12
                <TR><TD valign="top" align="left" cellspacing="10">
 
13
                <h1>Source: toresultview.h</h1>
 
14
                </TD>
 
15
                <TD valign="top" align="right" colspan="1"></TD></TR>
 
16
        </TABLE>
 
17
        <HR>
 
18
        <TABLE BORDER="0">
 
19
                
 
20
        </TABLE>
 
21
        </TD>
 
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>
 
28
<pre>
 
29
/*****
 
30
 *
 
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
 
34
 * 
 
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.
 
39
 * 
 
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.
 
44
 * 
 
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.
 
48
 *
 
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.
 
53
 *
 
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.
 
59
 *
 
60
 *      You may link this product with any GPL'd Qt library such as Qt/Free
 
61
 *
 
62
 * All trademarks belong to their respective owners.
 
63
 *
 
64
 *****/
 
65
 
 
66
#ifndef TORESULTVIEW_H
 
67
#define TORESULTVIEW_H
 
68
 
 
69
#include "toeditwidget.h"
 
70
#include "toresult.h"
 
71
#include "toresultlistformatui.h"
 
72
 
 
73
#include <qlistview.h>
 
74
 
 
75
#include <map>
 
76
 
 
77
class QListViewItem;
 
78
class QPopupMenu;
 
79
class TOPrinter;
 
80
class toListTip;
 
81
class toQuery;
 
82
class toResultCols;
 
83
class toResultView;
 
84
class toSQL;
 
85
class toSearchReplace;
 
86
 
 
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.
 
89
 */
 
90
class toResultFilter {
 
91
public:
 
92
  toResultFilter()
 
93
  { }
 
94
  virtual ~toResultFilter()
 
95
  { }
 
96
  virtual void startingQuery(void)
 
97
  { }
 
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.
 
102
   */
 
103
  virtual bool check(const QListViewItem *item) = 0;
 
104
  /** Create a copy of this filter.
 
105
   * @return A newly created copy of this filter.
 
106
   */
 
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.
 
111
   */
 
112
  virtual void exportData(std::map<QCString,QString> &data,const QCString &prefix);
 
113
  /** Import data
 
114
   * @param data Data to read from a map.
 
115
   * @param prefix Prefix to read data from.
 
116
   */
 
117
  virtual void importData(std::map<QCString,QString> &data,const QCString &prefix);
 
118
};
 
119
 
 
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.
 
123
 */
 
124
class toResultViewItem : public QListViewItem {
 
125
  struct keyData {
 
126
    QString Data;
 
127
    QString KeyAsc;
 
128
    QString KeyDesc;
 
129
    int Width;
 
130
    enum { String,Number } Type;
 
131
  };
 
132
  int ColumnCount;
 
133
  keyData *ColumnData;
 
134
  QString firstText(int col) const;
 
135
protected:
 
136
  virtual int realWidth(const QFontMetrics &fm, const QListView *top, int column,const QString &txt) const;
 
137
public:
 
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
 
142
   */
 
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
 
150
   */
 
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.
 
155
   */
 
156
  virtual ~toResultViewItem()
 
157
  { delete[] ColumnData; }
 
158
  /** Reimplemented for internal reasons.
 
159
   */
 
160
  virtual void setText (int col,const QString &txt);
 
161
  /** Set from database.
 
162
   */
 
163
  virtual void setText (int col,const toQValue &val);
 
164
  /** Reimplemented for internal reasons.
 
165
   */
 
166
  virtual void paintCell(QPainter * p,const QColorGroup & cg,int column,int width,int align);
 
167
  /** Reimplemented for internal reasons.
 
168
   */
 
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.
 
172
   * @param col Column
 
173
   * @param asc Wether to sort ascending or not.
 
174
   */
 
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.
 
178
   */
 
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.
 
182
   * @param col Column.
 
183
   * @return All of the text.
 
184
   */
 
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.
 
188
   * @param col Column.
 
189
   * @return The text to display as tooltip.
 
190
   */
 
191
  virtual QString tooltip(int col) const
 
192
  { return allText(col); }
 
193
};
 
194
 
 
195
/** This item expands the height to commodate all lines in the input buffer.
 
196
 */
 
197
class toResultViewMLine : public toResultViewItem {
 
198
private:
 
199
  /** Number of lines in the largest row.
 
200
   */
 
201
  int Lines;
 
202
protected:
 
203
  virtual int realWidth(const QFontMetrics &fm, const QListView *top, int column,const QString &txt) const;
 
204
public:
 
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
 
209
   */
 
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
 
217
   */
 
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.
 
222
   */
 
223
  virtual void setText (int,const QString &);
 
224
  /** Set from database.
 
225
   */
 
226
  virtual void setText (int col,const toQValue &val);
 
227
  /** Reimplemented for internal reasons.
 
228
   */
 
229
  virtual void setup(void);
 
230
  /** Reimplemented for internal reasons.
 
231
   */
 
232
  virtual QString text(int col) const
 
233
  { return toResultViewItem::allText(col); }
 
234
  /** Reimplemented for internal reasons.
 
235
   */
 
236
  virtual void paintCell (QPainter *pnt,const QColorGroup & cg,int column,int width,int alignment);
 
237
};
 
238
 
 
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.
 
242
 */
 
243
class toResultViewCheck : public QCheckListItem {
 
244
  struct keyData {
 
245
    QString Data;
 
246
    QString KeyAsc;
 
247
    QString KeyDesc;
 
248
    int Width;
 
249
    enum { String,Number } Type;
 
250
  };
 
251
  int ColumnCount;
 
252
  keyData *ColumnData;
 
253
protected:
 
254
  virtual int realWidth(const QFontMetrics &fm, const QListView *top, int column,const QString &txt) const;
 
255
  QString firstText(int col) const;
 
256
public:
 
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.
 
261
   */
 
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.
 
269
   */
 
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.
 
278
   */
 
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.
 
285
   */
 
286
  toResultViewCheck(QListViewItem *parent,QListViewItem *after,const QString &text,QCheckListItem::Type type=Controller);
 
287
  /** Reimplemented for internal reasons.
 
288
   */
 
289
  virtual ~toResultViewCheck()
 
290
  { delete[] ColumnData; }
 
291
  /** Reimplemented for internal reasons.
 
292
   */
 
293
  virtual void setText (int col,const QString &txt);
 
294
  /** Set from database.
 
295
   */
 
296
  virtual void setText (int col,const toQValue &val);
 
297
  /** Reimplemented for internal reasons.
 
298
   */
 
299
  virtual void paintCell(QPainter * p,const QColorGroup & cg,int column,int width,int align);
 
300
  /** Reimplemented for internal reasons.
 
301
   */
 
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.
 
305
   * @param col Column
 
306
   * @param asc Wether to sort ascending or not.
 
307
   */
 
308
  /** String to sort the data on. This is reimplemented so that numbers are sorted as numbers
 
309
   * and not as strings.
 
310
   * @param col Column
 
311
   * @param asc Wether to sort ascending or not.
 
312
   */
 
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.
 
316
   */
 
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.
 
320
   * @param col Column.
 
321
   * @return All of the text.
 
322
   */
 
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.
 
326
   * @param col Column.
 
327
   * @return The text to display as tooltip.
 
328
   */
 
329
  virtual QString tooltip(int col) const
 
330
  { return allText(col); }
 
331
};
 
332
 
 
333
/** This item expands the height to commodate all lines in the input buffer.
 
334
 */
 
335
class toResultViewMLCheck : public toResultViewCheck {
 
336
private:
 
337
  /** Number of lines in the largest row.
 
338
   */
 
339
  int Lines;
 
340
protected:
 
341
  virtual int realWidth(const QFontMetrics &fm, const QListView *top, int column,const QString &txt) const;
 
342
public:
 
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.
 
347
   */
 
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.
 
355
   */
 
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.
 
360
   */
 
361
  virtual void setup(void);
 
362
  /** Reimplemented for internal reasons.
 
363
   */
 
364
  virtual void setText (int,const QString &);
 
365
  /** Set from database.
 
366
   */
 
367
  virtual void setText (int col,const toQValue &val);
 
368
  /** Reimplemented for internal reasons.
 
369
   */
 
370
  virtual QString text(int col) const
 
371
  { return toResultViewCheck::allText(col); }
 
372
  /** Reimplemented for internal reasons.
 
373
   */
 
374
  virtual void paintCell (QPainter *pnt,const QColorGroup & cg,int column,int width,int alignment);
 
375
};
 
376
 
 
377
/**
 
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.
 
382
 */
 
383
class toListView : public QListView,public toEditWidget {
 
384
  Q_OBJECT
 
385
 
 
386
  bool FirstSearch;
 
387
 
 
388
  /** Name of this list, used primarily when printing. Also used to be able to edit
 
389
   * SQL displayed in @ref toResultView.
 
390
   */
 
391
  QString Name;
 
392
  /** Used to display tip on fields.
 
393
   */
 
394
  toListTip *AllTip;
 
395
  /** Item selected when popup menu displayed.
 
396
   */
 
397
  QListViewItem *MenuItem;
 
398
  /** Column of item selected when popup menu displayed.
 
399
   */
 
400
  int MenuColumn;
 
401
  /** Popup menu if available.
 
402
   */
 
403
  QPopupMenu *Menu;
 
404
  /** Last move, used to determine if drag has started.
 
405
   */
 
406
  QPoint LastMove;
 
407
 
 
408
  /** Reimplemented for internal reasons.
 
409
   */
 
410
  virtual void contentsMouseDoubleClickEvent (QMouseEvent *e);
 
411
  /** Reimplemented for internal reasons.
 
412
   */
 
413
  virtual void contentsMousePressEvent(QMouseEvent *e);
 
414
  /** Reimplemented for internal reasons.
 
415
   */
 
416
  virtual void contentsMouseReleaseEvent(QMouseEvent *e);
 
417
  /** Reimplemented for internal reasons.
 
418
   */
 
419
  virtual void contentsMouseMoveEvent (QMouseEvent *e);
 
420
 
 
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).
 
430
   */
 
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);
 
434
public:
 
435
  /** Create new list view.
 
436
   * @param parent Parent of list.
 
437
   * @param name Name of list.
 
438
   * @param f Widget flags.
 
439
   */
 
440
  toListView(QWidget *parent,const char *name=NULL,WFlags f=0);
 
441
  virtual ~toListView();
 
442
 
 
443
  /** Get SQL name of list.
 
444
   */
 
445
  virtual QString sqlName(void)
 
446
  { return Name; }
 
447
  /** Set SQL name of list.
 
448
   */
 
449
  virtual void setSQLName(const QString &name)
 
450
  { Name=name; }
 
451
  /** Get the whole text for the item and column selected when menu was poped up.
 
452
   */
 
453
  QString menuText(void);
 
454
 
 
455
  /** Print this list
 
456
   */
 
457
  virtual void editPrint(void);
 
458
  /** Reimplemented for internal reasons.
 
459
   */
 
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.
 
463
   */
 
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.
 
468
   */
 
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.
 
476
   */
 
477
  virtual QString exportAsText(bool includeHeader,bool onlySelection,int type=-1,const QString &separator=";",const QString &delimiter="\"");
 
478
  /** Export list as file.
 
479
   */
 
480
  virtual bool editSave(bool ask);
 
481
 
 
482
  /** Select all contents.
 
483
   */
 
484
  virtual void editSelectAll(void)
 
485
  { selectAll(true); }
 
486
  
 
487
  /** Move to top of data
 
488
   */
 
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.
 
493
   */
 
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.
 
497
   */
 
498
  virtual bool searchCanReplace(bool all);
 
499
 
 
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.
 
503
   */
 
504
  virtual void exportData(std::map<QCString,QString> &data,const QCString &prefix);
 
505
  /** Import data
 
506
   * @param data Data to read from a map.
 
507
   * @param prefix Prefix to read data from.
 
508
   */
 
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.
 
512
   */
 
513
  virtual toListView *copyTransposed(void);
 
514
signals:
 
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.
 
517
   */
 
518
  void displayMenu(QPopupMenu *menu);
 
519
public slots:
 
520
  /** set the popup menu --> see displayMenu()
 
521
   * @param item Item to display.
 
522
   */
 
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.
 
528
   */
 
529
  virtual void displayMenu(QListViewItem *item,const QPoint &pnt,int col);
 
530
  /** Display memo of selected menu column
 
531
   */
 
532
  virtual void displayMemo(void);
 
533
protected slots:
 
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.
 
537
   */
 
538
  virtual void menuCallback(int id);
 
539
};
 
540
 
 
541
/**
 
542
 * This class defines a list which displays the result of a query.
 
543
 *
 
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.
 
546
 */
 
547
 
 
548
class toResultView : public toListView, public toResult {
 
549
  Q_OBJECT
 
550
 
 
551
  int SortColumn;
 
552
  bool SortAscending;
 
553
  bool SortConnected;
 
554
 
 
555
  /** Reimplemented for internal reasons.
 
556
   */
 
557
  virtual void keyPressEvent (QKeyEvent * e);
 
558
protected:
 
559
  /** Connection to execute statement on.
 
560
   */
 
561
  toQuery *Query;
 
562
  /** Last added item.
 
563
   */
 
564
  QListViewItem *LastItem;
 
565
 
 
566
  /** Number of rows in list.
 
567
   */
 
568
  int RowNumber;
 
569
  /** If column names are to be made more readable.
 
570
   */
 
571
  bool ReadableColumns;
 
572
  /** Wether to display first number column or not.
 
573
   */
 
574
  bool NumberColumn;
 
575
  /** If all the available data should be read at once.
 
576
   */
 
577
  bool ReadAll;
 
578
  /** Input filter if any.
 
579
   */
 
580
  toResultFilter *Filter;
 
581
 
 
582
  /** Setup the list.
 
583
   * @param readable Wether to display first number column or not.
 
584
   * @param dispCol Wether to display first number column or not.
 
585
   */
 
586
  void setup(bool readable,bool dispCol);
 
587
 
 
588
  /** Check if end of query is detected yet or not.
 
589
   */
 
590
  virtual bool eof(void);
 
591
 
 
592
public:
 
593
  /** Create list.
 
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.
 
600
   */
 
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.
 
606
   */
 
607
  toResultView(QWidget *parent,const char *name=NULL,WFlags f=0);
 
608
  ~toResultView();
 
609
 
 
610
  /** Set the read all flag.
 
611
   * @param all New value of flag.
 
612
   */
 
613
  void setReadAll(bool all)
 
614
  { ReadAll=all;}
 
615
 
 
616
  /** Get read all flag
 
617
   * @return Value of read all flag.
 
618
   */
 
619
  virtual void editReadAll(void);
 
620
 
 
621
  /** Get the number of columns in query.
 
622
   * @return Columns in query.
 
623
   */
 
624
  int queryColumns() const;
 
625
 
 
626
  /** Get the query used to execute this.
 
627
   */
 
628
  toQuery *query()
 
629
  { return Query; }
 
630
 
 
631
  /** Set a filter to this list.
 
632
   * @param filter The new filter or NULL if no filter is to be used.
 
633
   */
 
634
  void setFilter(toResultFilter *filter)
 
635
  { Filter=filter; }
 
636
  /** Get the current filter.
 
637
   * @return Current filter or NULL if no filter.
 
638
   */
 
639
  toResultFilter *filter(void)
 
640
  { return Filter; }
 
641
 
 
642
  /** Get number column flag.
 
643
   * @return Wether or not the numbercolumn is displayed.
 
644
   */
 
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.
 
651
   */
 
652
  void setNumberColumn(bool val)
 
653
  { NumberColumn=val; }
 
654
 
 
655
  /** Get readable column flag.
 
656
   * @return Wether or not the readable column names.
 
657
   */
 
658
  bool readableColumn() const
 
659
  { return ReadableColumns; }
 
660
  /** Set readable column flag.
 
661
   */
 
662
  void setReadableColumns(bool val)
 
663
  { ReadableColumns=val; }
 
664
 
 
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.
 
670
   */
 
671
  virtual QListViewItem *createItem(QListViewItem *last,const QString &str);
 
672
 
 
673
  /** Reimplemented for internal reasons.
 
674
   */
 
675
  virtual void query(const QString &sql,const toQList &param);
 
676
 
 
677
  /** Get SQL name of list.
 
678
   */
 
679
  virtual QString sqlName(void)
 
680
  { return toListView::sqlName(); }
 
681
  /** Set SQL name of list.
 
682
   */
 
683
  virtual void setSQLName(const QString &name)
 
684
  { toListView::setSQLName(name); }
 
685
 
 
686
  // Why are these needed?
 
687
#if 1
 
688
  /** Set the SQL statement of this list
 
689
   * @param sql String containing statement.
 
690
   */
 
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.
 
695
   */
 
696
  void setSQL(const toSQL &sql)
 
697
  { toResult::setSQL(sql); }
 
698
  /** Set new SQL and run query.
 
699
   * @param sql New sql.
 
700
   * @see setSQL
 
701
   */
 
702
  void query(const QString &sql)
 
703
  { toResult::query(sql); }
 
704
  /** Set new SQL and run query.
 
705
   * @param sql New sql.
 
706
   * @see setSQL
 
707
   */
 
708
  void query(const toSQL &sql)
 
709
  { toResult::query(sql); }
 
710
  /** Set new SQL and run query.
 
711
   * @param sql New sql.
 
712
   * @see setSQL
 
713
   */
 
714
  void query(const toSQL &sql,toQList &par)
 
715
  { toResult::query(sql,par); }
 
716
#endif
 
717
 
 
718
  /** Reimplemented for internal reasons.
 
719
   */
 
720
  virtual void editPrint(void)
 
721
  { editReadAll(); toListView::editPrint(); }
 
722
  /** Reimplemented for internal reasons.
 
723
   */
 
724
  virtual QString middleString();
 
725
 
 
726
  /** Reimplemented for internal reasons.
 
727
   */
 
728
  virtual void addMenues(QPopupMenu *);
 
729
  /** Reimplemented for internal reasons.
 
730
   */
 
731
  virtual void setSorting(int col,bool asc=true);
 
732
  /** Reimplemented for internal reasons.
 
733
   */
 
734
  virtual int sortColumn() const
 
735
  { return SortColumn; }
 
736
public slots:
 
737
  /** Reimplemented for internal reasons.
 
738
   */
 
739
  virtual void refresh(void);
 
740
  /** Reimplemented for internal reasons.
 
741
   */
 
742
  virtual void changeParams(const QString &Param1)
 
743
  { toResult::changeParams(Param1); }
 
744
  /** Reimplemented For internal reasons.
 
745
   */
 
746
  virtual void changeParams(const QString &Param1,const QString &Param2)
 
747
  { toResult::changeParams(Param1,Param2); }
 
748
  /** Reimplemented for internal reasons.
 
749
   */
 
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.
 
753
   */
 
754
  virtual void addItem(void);
 
755
  /** Handle any connection by default
 
756
   */
 
757
  virtual bool canHandle(toConnection &)
 
758
  { return true; }
 
759
private slots:
 
760
  void headingClicked(int col);
 
761
  void checkHeading(void); 
 
762
protected slots:
 
763
  /** Reimplemented for internal reasons.
 
764
   */
 
765
  virtual void menuCallback(int);
 
766
};
 
767
 
 
768
/***
 
769
 * Used internally by toListView.
 
770
 * @internal
 
771
 */
 
772
 
 
773
class toResultListFormat : public toResultListFormatUI {
 
774
  Q_OBJECT
 
775
public:
 
776
  toResultListFormat(QWidget *parent,const char *name);
 
777
  void saveDefault(void);
 
778
public slots:
 
779
  virtual void formatChanged(int pos);
 
780
};
 
781
 
 
782
#endif
 
783
</pre>
 
784
<HR>
 
785
        <table>
 
786
        <tr><td><small>Generated by: nneul on skyhawk on Wed Feb 23 19:49:58 2005, using kdoc 2.0a54.</small></td></tr>
 
787
        </table>
 
788
</BODY>
 
789
</HTML>