1 /* 2 SPDX-FileCopyrightText: 2010 Marco Mentasti <marcomentasti@gmail.com> 3 4 SPDX-License-Identifier: LGPL-2.0-only 5 */ 6 7 #ifndef DATAOUTPUTWIDGET_H 8 #define DATAOUTPUTWIDGET_H 9 10 class QTextStream; 11 class QVBoxLayout; 12 class QSqlQuery; 13 class DataOutputModel; 14 class DataOutputView; 15 16 #include <QWidget> 17 18 class DataOutputWidget : public QWidget 19 { 20 Q_OBJECT 21 22 public: 23 enum Option { NoOptions = 0x0, ExportColumnNames = 0x1, ExportLineNumbers = 0x2 }; 24 25 Q_DECLARE_FLAGS(Options, Option) 26 27 DataOutputWidget(QWidget *parent); 28 ~DataOutputWidget() override; 29 30 void exportData(QTextStream &stream, 31 const QChar stringsQuoteChar = QLatin1Char('\0'), 32 const QChar numbersQuoteChar = QLatin1Char('\0'), 33 const QString &fieldDelimiter = QStringLiteral("\t"), 34 const Options opt = NoOptions); 35 model()36 DataOutputModel *model() const 37 { 38 return m_model; 39 } view()40 DataOutputView *view() const 41 { 42 return m_view; 43 } 44 45 public Q_SLOTS: 46 void showQueryResultSets(QSqlQuery &query); 47 void resizeColumnsToContents(); 48 void resizeRowsToContents(); 49 void clearResults(); 50 51 void slotToggleLocale(); 52 void slotCopySelected(); 53 void slotExport(); 54 55 private: 56 QVBoxLayout *m_dataLayout; 57 58 /// TODO: manage multiple views for query with multiple resultsets 59 DataOutputModel *m_model; 60 DataOutputView *m_view; 61 62 bool m_isEmpty; 63 }; 64 65 Q_DECLARE_OPERATORS_FOR_FLAGS(DataOutputWidget::Options) 66 67 #endif // DATAOUTPUTWIDGET_H 68