1/*
2 Copyright (C) 2010 Marco Mentasti <marcomentasti@gmail.com>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
7
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
12
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
17*/
18
19#ifndef DATAOUTPUTWIDGET_H
20#define DATAOUTPUTWIDGET_H
21
22class QTextStream;
23class QVBoxLayout;
24class QSqlQuery;
25class DataOutputModel;
26class DataOutputView;
27
28#include <qwidget.h>
29
30class DataOutputWidget : public QWidget
31{
32 Q_OBJECT
33
34 public:
35 enum Option {
36 NoOptions = 0x0,
37 ExportColumnNames = 0x1,
38 ExportLineNumbers = 0x2
39 };
40
41 Q_DECLARE_FLAGS(Options, Option)
42
43 DataOutputWidget(QWidget *parent);
44 ~DataOutputWidget();
45
46 void exportData(QTextStream &stream,
47 const QChar stringsQuoteChar = '\0',
48 const QChar numbersQuoteChar = '\0',
49 const QString fieldDelimiter = "\t",
50 const Options opt = NoOptions);
51
52 DataOutputModel *model() const { return m_model; }
53 DataOutputView *view() const { return m_view; }
54
55 public slots:
56 void showQueryResultSets(QSqlQuery &query);
57 void resizeColumnsToContents();
58 void resizeRowsToContents();
59 void clearResults();
60
61 void slotToggleLocale();
62 void slotCopySelected();
63 void slotExport();
64
65 private:
66 QVBoxLayout *m_dataLayout;
67
68 /// TODO: manage multiple views for query with multiple resultsets
69 DataOutputModel *m_model;
70 DataOutputView *m_view;
71
72 bool m_isEmpty;
73};
74
75Q_DECLARE_OPERATORS_FOR_FLAGS(DataOutputWidget::Options)
76
77#endif // DATAOUTPUTWIDGET_H
78