[go: up one dir, main page]

File: toresultview.h

package info (click to toggle)
tora 1.3.23-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 15,984 kB
  • ctags: 14,460
  • sloc: cpp: 123,554; sh: 16,181; makefile: 966; xml: 69
file content (942 lines) | stat: -rw-r--r-- 28,450 bytes parent folder | download
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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
/*****
*
* 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 TORESULTVIEW_H
#define TORESULTVIEW_H

#include "config.h"
#include "toeditwidget.h"
#include "toresult.h"
#include "toresultlistformatui.h"

#include <qlistview.h>

#include <map>
#include <algorithm>

class QListViewItem;
class QPopupMenu;
class TOPrinter;
class toListTip;
class toQuery;
class toResultCols;
class toResultView;
class toSQL;
class toSearchReplace;

/** Baseclass for filters to apply to the @ref toResultView to filter out
 * rows that you don't want to add as items to the list.
 */
class toResultFilter
{
public:
    toResultFilter()
    { }
    virtual ~toResultFilter()
    { }
    virtual void startingQuery(void)
    { }
    /** This function can inspect the item to be added and decide if it is
     * valid for adding or not.
     * @param item Item to inspect.
     * @return If false is returned the item isn't added.
     */
    virtual bool check(const QListViewItem *item) = 0;
    /** Create a copy of this filter.
     * @return A newly created copy of this filter.
     */
    virtual toResultFilter *clone(void) = 0;
    /** Export data to a map.
     * @param data A map that can be used to recreate the data of a chart.
     * @param prefix Prefix to add to the map.
     */
    virtual void exportData(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);
};

/** An item to display in a toListView or toResultView. They differ from normal
 * QListViewItems in that they can have a tooltip and actually contain more text
 * than is displayed in the cell of the listview.
 */
class toResultViewItem : public QListViewItem
{
    struct keyData
    {
        QString Data;
        QString KeyAsc;
        QString KeyDesc;
        int Width;
        enum { String, Number } Type;
    };
    int ColumnCount;
    keyData *ColumnData;
    QString firstText(int col) const;
protected:
    virtual int realWidth(const QFontMetrics &fm, const QListView *top, int column, const QString &txt) const;
public:
    /** Create a new item.
     * @param parent Parent list view.
     * @param after Insert after this item.
     * @param buffer String to set as first column
     */
    toResultViewItem(QListView *parent, QListViewItem *after, const QString &buf = QString::null)
            : QListViewItem(parent, after, QString::null)
    {
        ColumnData = NULL;
        ColumnCount = 0;
        if (buf)
            setText(0, buf);
    }
    /** Create a new item.
     * @param parent Parent to this item.
     * @param after Insert after this item.
     * @param buffer String to set as first column
     */
    toResultViewItem(QListViewItem *parent, QListViewItem *after, const QString &buf = QString::null)
            : QListViewItem(parent, after, QString::null)
    {
        ColumnData = NULL;
        ColumnCount = 0;
        if (buf)
            setText(0, buf);
    }
    /** Reimplemented for internal reasons.
     */
    virtual ~toResultViewItem()
    {
        delete[] ColumnData;
    }
    /** Reimplemented for internal reasons.
     */
    virtual void setText (int col, const QString &txt);
    /** Set from database.
     */
    virtual void setText (int col, const toQValue &val);
    /** Reimplemented for internal reasons.
     */
    virtual void paintCell(QPainter * p, const QColorGroup & cg, int column, int width, int align);
    /** Reimplemented for internal reasons.
     */
    virtual QString text(int col) const;
    /** String to sort the data on. This is reimplemented so that numbers are sorted as numbers
     * and not as strings.
     * @param col Column
     * @param asc Wether to sort ascending or not.
     */
    virtual QString key(int col, bool asc) const
    {
        if (col >= ColumnCount)
            return QString::null;
        return asc ? ColumnData[col].KeyAsc : ColumnData[col].KeyDesc;
    }
    /** Reimplemented for internal reasons.
     */
    virtual int width(const QFontMetrics &, const QListView *, int col) const
    {
        if (col >= ColumnCount)
            return 0;
        return ColumnData[col].Width;
    }
    /** Get all text for this item. This is used for copying, drag & drop and memo editing etc.
     * @param col Column.
     * @return All of the text.
     */
    virtual QString allText(int col) const
    {
        if (col >= ColumnCount)
            return QString::null;
        return ColumnData[col].Data;
    }
    /** Get the text to be displayed as tooltip for this item.
     * @param col Column.
     * @return The text to display as tooltip.
     */
    virtual QString tooltip(int col) const
    {
        return allText(col);
    }
};

/** This item expands the height to commodate all lines in the input buffer.
 */
class toResultViewMLine : public toResultViewItem
{
private:
    /** Number of lines in the largest row.
     */
    int Lines;
protected:
    virtual int realWidth(const QFontMetrics &fm, const QListView *top, int column, const QString &txt) const;
public:
    /** Create a new item.
     * @param parent Parent list view.
     * @param after Insert after this item.
     * @param buffer String to set as first column
     */
    toResultViewMLine(QListView *parent, QListViewItem *after, const QString &buf = QString::null)
            : toResultViewItem(parent, after, QString::null)
    {
        Lines = 1;
        if (buf)
            setText(0, buf);
    }
    /** Create a new item.
     * @param parent Parent to this item.
     * @param after Insert after this item.
     * @param buffer String to set as first column
     */
    toResultViewMLine(QListViewItem *parent, QListViewItem *after, const QString &buf = QString::null)
            : toResultViewItem(parent, after, QString::null)
    {
        Lines = 1;
        if (buf)
            setText(0, buf);
    }
    /** Reimplemented for internal reasons.
     */
    virtual void setText (int, const QString &);
    /** Set from database.
     */
    virtual void setText (int col, const toQValue &val);
    /** Reimplemented for internal reasons.
     */
    virtual void setup(void);
    /** Reimplemented for internal reasons.
     */
    virtual QString text(int col) const
    {
        return toResultViewItem::allText(col);
    }
    /** Reimplemented for internal reasons.
     */
    virtual void paintCell (QPainter *pnt, const QColorGroup & cg, int column, int width, int alignment);
};

/** An item to display in a toListView or toResultView. They differ from normal
 * QListViewItems in that they can have a tooltip and actually contain more text
 * than is displayed in the cell of the listview.
 */
class toResultViewCheck : public QCheckListItem
{
    struct keyData
    {
        QString Data;
        QString KeyAsc;
        QString KeyDesc;
        int Width;
        enum { String, Number } Type;
    };
    int ColumnCount;
    keyData *ColumnData;
protected:
    virtual int realWidth(const QFontMetrics &fm, const QListView *top, int column, const QString &txt) const;
    QString firstText(int col) const;
public:
    /** Create a new item.
     * @param parent Parent list view.
     * @param text Text of first column.
     * @param type Type of check on this item.
     */
    toResultViewCheck(QListView *parent, const QString &text, QCheckListItem::Type type = Controller)
            : QCheckListItem(parent, QString::null, type)
    {
        ColumnData = NULL;
        ColumnCount = 0;
        if (!text.isNull())
            setText(0, text);
    }
    /** Create a new item.
     * @param parent Parent item.
     * @param text Text of first column.
     * @param type Type of check on this item.
     */
    toResultViewCheck(QListViewItem *parent, const QString &text, QCheckListItem::Type type = Controller)
            : QCheckListItem(parent, QString::null, type)
    {
        ColumnData = NULL;
        ColumnCount = 0;
        if (!text.isNull())
            setText(0, text);
    }
    /** Create a new item.
     * @param parent Parent list view.
     * @param after After last item.
     * @param text Text of first column.
     * @param type Type of check on this item.
     */
    toResultViewCheck(QListView *parent, QListViewItem *after, const QString &text, QCheckListItem::Type type = Controller);
    /** Create a new item.
     * @param parent Parent item.
     * @param after After last item.
     * @param text Text of first column.
     * @param type Type of check on this item.
     */
    toResultViewCheck(QListViewItem *parent, QListViewItem *after, const QString &text, QCheckListItem::Type type = Controller);
    /** Reimplemented for internal reasons.
     */
    virtual ~toResultViewCheck()
    {
        delete[] ColumnData;
    }
    /** Reimplemented for internal reasons.
     */
    virtual void setText (int col, const QString &txt);
    /** Set from database.
     */
    virtual void setText (int col, const toQValue &val);
    /** Reimplemented for internal reasons.
     */
    virtual void paintCell(QPainter * p, const QColorGroup & cg, int column, int width, int align);
    /** Reimplemented for internal reasons.
     */
    virtual QString text(int col) const;
    /** String to sort the data on. This is reimplemented so that numbers are sorted as numbers
     * and not as strings.
     * @param col Column
     * @param asc Wether to sort ascending or not.
     */
    /** String to sort the data on. This is reimplemented so that numbers are sorted as numbers
     * and not as strings.
     * @param col Column
     * @param asc Wether to sort ascending or not.
     */
    virtual QString key(int col, bool asc) const
    {
        if (col >= ColumnCount)
            return QString::null;
        return asc ? ColumnData[col].KeyAsc : ColumnData[col].KeyDesc;
    }
    /** Reimplemented for internal reasons.
     */
    virtual int width(const QFontMetrics &, const QListView *, int col) const
    {
        if (col >= ColumnCount)
            return 0;
        return ColumnData[col].Width;
    }
    /** Get all text for this item. This is used for copying, drag & drop and memo editing etc.
     * @param col Column.
     * @return All of the text.
     */
    virtual QString allText(int col) const
    {
        if (col >= ColumnCount)
            return QString::null;
        return ColumnData[col].Data;
    }
    /** Get the text to be displayed as tooltip for this item.
     * @param col Column.
     * @return The text to display as tooltip.
     */
    virtual QString tooltip(int col) const
    {
        return allText(col);
    }
};

/** This item expands the height to commodate all lines in the input buffer.
 */
class toResultViewMLCheck : public toResultViewCheck
{
private:
    /** Number of lines in the largest row.
     */
    int Lines;
protected:
    virtual int realWidth(const QFontMetrics &fm, const QListView *top, int column, const QString &txt) const;
public:
    /** Create a new item.
     * @param parent Parent list view.
     * @param text Text of first column.
     * @param type Type of check on this item.
     */
    toResultViewMLCheck(QListView *parent, const QString &text, QCheckListItem::Type type = Controller)
            : toResultViewCheck(parent, QString::null, type)
    {
        Lines = 1;
        if (!text.isNull())
            setText(0, text);
    }
    /** Create a new item.
     * @param parent Parent item.
     * @param text Text of first column.
     * @param type Type of check on this item.
     */
    toResultViewMLCheck(QListViewItem *parent, const QString &text, QCheckListItem::Type type = Controller)
            : toResultViewCheck(parent, QString::null, type)
    {
        Lines = 1;
        if (!text.isNull())
            setText(0, text);
    }
    /** Reimplemented for internal reasons.
     */
    virtual void setup(void);
    /** Reimplemented for internal reasons.
     */
    virtual void setText (int, const QString &);
    /** Set from database.
     */
    virtual void setText (int col, const toQValue &val);
    /** Reimplemented for internal reasons.
     */
    virtual QString text(int col) const
    {
        return toResultViewCheck::allText(col);
    }
    /** Reimplemented for internal reasons.
     */
    virtual void paintCell (QPainter *pnt, const QColorGroup & cg, int column, int width, int alignment);
};

/**
 * The TOra implementation of a listview which offers a few extra goodies to the baseclass.
 * First of all tooltip which can display contents that doesn't fit in the list, printing,
 * integration into toMain with Edit menu etc, drag & drop, export as file, display item
 * as memo and context menu.
 */
class toListView : public QListView, public toEditWidget
{
    Q_OBJECT

    bool FirstSearch;

    /** Name of this list, used primarily when printing. Also used to be able to edit
     * SQL displayed in @ref toResultView.
     */
    QString Name;
    /** Used to display tip on fields.
     */
    toListTip *AllTip;
    /** Item selected when popup menu displayed.
     */
    QListViewItem *MenuItem;
    /** Column of item selected when popup menu displayed.
     */
    int MenuColumn;
    /** Popup menu if available.
     */
    QPopupMenu *Menu;
    /** Last move, used to determine if drag has started.
     */
    QPoint LastMove;

    /** Reimplemented for internal reasons.
     */
    virtual void contentsMouseDoubleClickEvent (QMouseEvent *e);
    /** Reimplemented for internal reasons.
     */
    virtual void contentsMousePressEvent(QMouseEvent *e);
    /** Reimplemented for internal reasons.
     */
    virtual void contentsMouseReleaseEvent(QMouseEvent *e);
    /** Reimplemented for internal reasons.
     */
    virtual void contentsMouseMoveEvent (QMouseEvent *e);

    /** Used to print one page of the list.
     * @param printer Printer to print to.
     * @param painter Painter to print page to.
     * @param top Item at top of page.
     * @param column Column to start printing at. Will be changed to where you are when done.
     * @param level The indentation level of the top item.
     * @param pageNo Page number.
     * @param paint If just testing to determine how many pages are needed set this to false.
     * @return The next item to print to (Pass as top to this function).
     */
    virtual QListViewItem *printPage(TOPrinter *printer, QPainter *painter, QListViewItem *top,
                                     int &column, int &level, int pageNo, bool paint = true);
    int exportType(QString &separator, QString &delimiter);

    QString owner;
    QString objectName;

    bool includeHeader;
    bool onlySelection;
    QString sep;
    QString del;

public:
     bool getIncludeHeader(){return includeHeader;};
     bool getOnlySelection(){return onlySelection;};
     QString getSep(){return sep;};
     QString getDel(){return del;};

    /** Create new list view.
     * @param parent Parent of list.
     * @param name Name of list.
     * @param f Widget flags.
     */
    toListView(QWidget *parent, const char *name = NULL, WFlags f = 0);
    virtual ~toListView();

    /** Get SQL name of list.
     */
    virtual QString sqlName(void)
    {
        return Name;
    }
    /** Set SQL name of list.
     */
    virtual void setSQLName(const QString &name)
    {
        Name = name;
    }

    /** Set owner
     * introduced to get type information for fields
     */
    virtual void setOwner(QString const & tOwner)
    {
        owner = tOwner;
    }


    /** Set object name 
     * introduced to get type information for fields
     */
    virtual void setObjectName(QString const & tObjectName)
    {
        objectName = tObjectName;
    }

    /** Get owner
     * introduced to get type information for fields
     */
    virtual QString getOwner()
    {
        return owner;
    }


    /** Get object name 
     * introduced to get type information for fields
     */
    virtual QString getObjectName()
    {
        return objectName;
    }

    /** Get the whole text for the item and column selected when menu was poped up.
     */
    QString menuText(void);

    /** Print this list
     */
    virtual void editPrint(void);
    /** Reimplemented for internal reasons.
     */
    virtual void focusInEvent (QFocusEvent *e);
    /** The string to be displayed in the middle of the footer when printing.
     * @return String to be placed in middle.
     */
    virtual QString middleString()
    {
        return QString::null;
    }
    /** Adds option to add menues to the popup menu before it is displayed.
     * @param menu Menu to add entries to.
     */
    virtual void addMenues(QPopupMenu *menu);
    /** Export list as a string.
     * @param includeHeader Include header.
     * @param onlySelection Only include selection.
     * @param type Format of exported list.
     * @param separator Separator for CSV format.
     * @param delimiter Delimiter for CSV format.
     */
    virtual QString exportAsText(bool includeHeader, bool onlySelection, int type = -1, const QString &separator = ";", const QString &delimiter = "\"");
    /** Export list as file.
     */
    virtual bool editSave(bool ask);

    /** Select all contents.
     */
    virtual void editSelectAll(void)
    {
        selectAll(true);
    }

    /** Move to top of data
     */
    virtual void searchTop(void)
    {
        if (firstChild())
            setCurrentItem(firstChild());
        FirstSearch = true;
    }
    /** Search for next entry
     * @return True if found, should select the found text.
     */
    virtual bool searchNext(toSearchReplace *search);
    /** Check if data can be modified by search
     * @param all If true can replace all, otherwise can replace right now.
     */
    virtual bool searchCanReplace(bool all);

    /** Export data to a map.
     * @param data A map that can be used to recreate the data of a chart.
     * @param prefix Prefix to add to the map.
     */
    virtual void exportData(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);
    /** Create transposed copy of list
     * @return Pointer to newly allocated transposed listview.
     */
    virtual toListView *copyTransposed(void);
signals:
    /** Called before the menu is displayed so that you can add items to it before it is shown.
     * @param menu Pointer to the menu about to be shown.
     */
    void displayMenu(QPopupMenu *menu);
public slots:
    /** set the popup menu --> see displayMenu()
     * @param item Item to display.
     */
    virtual void setDisplayMenu(QPopupMenu *item);
    /** Display the menu at the given point and column.
     * @param item Item to display.
     * @param pnt Point to display menu at.
     * @param col Column to display menu for.
     */
    virtual void displayMenu(QListViewItem *item, const QPoint &pnt, int col);
    /** Display memo of selected menu column
     */
    virtual void displayMemo(void);
protected slots:
    /** Callback when menu is selected. If you override this make sure you
     * call the parents function when you have parsed your entries.
     * @param id ID of the menu item selected.
     */
    virtual void menuCallback(int id);
};

/**
 * This class defines a list which displays the result of a query.
 *
 * One special thing to know about this class is that columns at the end in which the
 * description start with a '-' characters are not displayed.
 */

class toResultView : public toListView, public toResult
{
    Q_OBJECT

    int SortColumn;
    bool SortAscending;
    bool SortConnected;

    /** Reimplemented for internal reasons.
     */
    virtual void keyPressEvent (QKeyEvent * e);
protected:
    /** Connection to execute statement on.
     */
    toQuery *Query;
    /** Last added item.
     */
    QListViewItem *LastItem;

    /** Number of rows in list.
     */
    int RowNumber;
    /** If column names are to be made more readable.
     */
    bool ReadableColumns;
    /** Wether to display first number column or not.
     */
    bool NumberColumn;
    /** If all the available data should be read at once.
     */
    bool ReadAll;
    /** Input filter if any.
     */
    toResultFilter *Filter;

    /** Setup the list.
     * @param readable Wether to display first number column or not.
     * @param dispCol Wether to display first number column or not.
     */
    void setup(bool readable, bool dispCol);

    /** Check if end of query is detected yet or not.
     */
    virtual bool eof(void);

public:
    /** Create list.
     * @param readable Indicate if columns are to be made more readable. This means that the
     * descriptions are capitalised and '_' are converted to ' '.
     * @param numCol If number column is to be displayed.
     * @param parent Parent of list.
     * @param name Name of widget.
     * @param f Widget flags.
     */
    toResultView(bool readable, bool numCol, QWidget *parent, const char *name = NULL, WFlags f = 0);
    /** Create list. The columns are not readable and the number column is displayed.
     * @param parent Parent of list.
     * @param name Name of widget.
     * @param f Widget flags.
     */
    toResultView(QWidget *parent, const char *name = NULL, WFlags f = 0);
    ~toResultView();

    /** Set the read all flag.
     * @param all New value of flag.
     */
    void setReadAll(bool all)
    {
        ReadAll = all;
    }

    /** Get read all flag
     * @return Value of read all flag.
     */
    virtual void editReadAll(void);

    /** Get the number of columns in query.
     * @return Columns in query.
     */
    int queryColumns() const;

    /** Get the query used to execute this.
     */
    toQuery *query()
    {
        return Query;
    }

    /** Set a filter to this list.
     * @param filter The new filter or NULL if no filter is to be used.
     */
    void setFilter(toResultFilter *filter)
    {
        Filter = filter;
    }
    /** Get the current filter.
     * @return Current filter or NULL if no filter.
     */
    toResultFilter *filter(void)
    {
        return Filter;
    }

    /** Get number column flag.
     * @return Wether or not the numbercolumn is displayed.
     */
    bool numberColumn() const
    {
        return NumberColumn;
    }
    /** Set number column flag. Don't change this while a query is running. Observe
     * that not all descendants of this class support changing this on the fly. The base
     * class and @ref toResultLong does though.
     * @param val New value of number column.
     */
    void setNumberColumn(bool val)
    {
        NumberColumn = val;
    }

    /** Get readable column flag.
     * @return Wether or not the readable column names.
     */
    bool readableColumn() const
    {
        return ReadableColumns;
    }
    /** Set readable column flag.
     */
    void setReadableColumns(bool val)
    {
        ReadableColumns = val;
    }

    /** Create a new item in this list. Can be used if a special kind of item is wanted
     * in the list. The rest of the columns will be filled with setText.
     * @param last Where to insert the item.
     * @param str String to set first column to.
     * @return Allocated item.
     */
    virtual QListViewItem *createItem(QListViewItem *last, const QString &str);

    /** Reimplemented for internal reasons.
     */
    virtual void query(const QString &sql, const toQList &param);

    /** Get SQL name of list.
     */
    virtual QString sqlName(void)
    {
        return toListView::sqlName();
    }
    /** Set SQL name of list.
     */
    virtual void setSQLName(const QString &name)
    {
        toListView::setSQLName(name);
    }

    // Why are these needed?
#if 1
    /** Set the SQL statement of this list
     * @param sql String containing statement.
     */
    void setSQL(const QString &sql)
    {
        toResult::setSQL(sql);
    }
    /** Set the SQL statement of this list. This will also affect @ref Name.
     * @param sql SQL containing statement.
     */
    void setSQL(const toSQL &sql)
    {
        toResult::setSQL(sql);
    }
    /** Set new SQL and run query.
     * @param sql New sql.
     * @see setSQL
     */
    void query(const QString &sql)
    {
        toResult::query(sql);
    }
    /** Set new SQL and run query.
     * @param sql New sql.
     * @see setSQL
     */
    void query(const toSQL &sql)
    {
        toResult::query(sql);
    }
    /** Set new SQL and run query.
     * @param sql New sql.
     * @see setSQL
     */
    void query(const toSQL &sql, toQList &par)
    {
        toResult::query(sql, par);
    }
#endif

    /** Reimplemented for internal reasons.
     */
    virtual void editPrint(void)
    {
        editReadAll();
        toListView::editPrint();
    }
    /** Reimplemented for internal reasons.
     */
    virtual QString middleString();

    /** Reimplemented for internal reasons.
     */
    virtual void addMenues(QPopupMenu *);
    /** Reimplemented for internal reasons.
     */
    virtual void setSorting(int col, bool asc = true);
    /** Reimplemented for internal reasons.
     */
    virtual int sortColumn() const
    {
        return SortColumn;
    }
public slots:
    /** Reimplemented for internal reasons.
     */
    virtual void refresh(void);
    /** Reimplemented for internal reasons.
     */
    virtual void changeParams(const QString &Param1)
    {
        toResult::changeParams(Param1);
    }
    /** Reimplemented For internal reasons.
     */
    virtual void changeParams(const QString &Param1, const QString &Param2)
    {
        toResult::changeParams(Param1, Param2);
    }
    /** Reimplemented for internal reasons.
     */
    virtual void changeParams(const QString &Param1, const QString &Param2, const QString &Param3)
    {
        toResult::changeParams(Param1, Param2, Param3);
    }
    /** Try to add an item to the list if available.
     */
    virtual void addItem(void);
    /** Handle any connection by default
     */
    virtual bool canHandle(toConnection &)
    {
        return true;
    }
private slots:
    void headingClicked(int col);
    void checkHeading(void);
protected slots:
    /** Reimplemented for internal reasons.
     */
    virtual void menuCallback(int);
};

/***
 * Used internally by toListView.
 * @internal
 */

class toResultListFormat : public toResultListFormatUI
{
    Q_OBJECT
public:
    toResultListFormat(QWidget *parent, const char *name);
    void saveDefault(void);
public slots:
    virtual void formatChanged(int pos);
};

#endif