File indexing completed on 2024-04-21 05:49:00

0001 /*
0002    SPDX-FileCopyrightText: 2010 Marco Mentasti <marcomentasti@gmail.com>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-only
0005 */
0006 
0007 #pragma once
0008 
0009 class QTextStream;
0010 class QVBoxLayout;
0011 class QSqlQuery;
0012 class DataOutputModel;
0013 class DataOutputView;
0014 
0015 #include <QWidget>
0016 
0017 class DataOutputWidget : public QWidget
0018 {
0019     Q_OBJECT
0020 
0021 public:
0022     enum Option { NoOptions = 0x0, ExportColumnNames = 0x1, ExportLineNumbers = 0x2 };
0023 
0024     Q_DECLARE_FLAGS(Options, Option)
0025 
0026     DataOutputWidget(QWidget *parent);
0027     ~DataOutputWidget() override;
0028 
0029     void exportData(QTextStream &stream,
0030                     const QChar stringsQuoteChar = QLatin1Char('\0'),
0031                     const QChar numbersQuoteChar = QLatin1Char('\0'),
0032                     const QString &fieldDelimiter = QStringLiteral("\t"),
0033                     const Options opt = NoOptions);
0034 
0035     DataOutputModel *model() const
0036     {
0037         return m_model;
0038     }
0039     DataOutputView *view() const
0040     {
0041         return m_view;
0042     }
0043 
0044 public Q_SLOTS:
0045     void showQueryResultSets(QSqlQuery &query);
0046     void resizeColumnsToContents();
0047     void resizeRowsToContents();
0048     void clearResults();
0049 
0050     void slotToggleLocale();
0051     void slotCopySelected();
0052     void slotExport();
0053 
0054 private:
0055     QVBoxLayout *m_dataLayout;
0056 
0057     /// TODO: manage multiple views for query with multiple resultsets
0058     DataOutputModel *m_model;
0059     DataOutputView *m_view;
0060 
0061     bool m_isEmpty;
0062 };
0063 
0064 Q_DECLARE_OPERATORS_FOR_FLAGS(DataOutputWidget::Options)