/*************************************************************************** * This file is part of the Lime Report project * * Copyright (C) 2015 by Alexander Arin * * arin_a@bk.ru * * * ** GNU General Public License Usage ** * * * This library 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, either version 3 of the License, or * * (at your option) any later version. * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * ** GNU Lesser General Public License ** * * * This library is free software: you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * * published by the Free Software Foundation, either version 3 of the * * License, or (at your option) any later version. * * You should have received a copy of the GNU Lesser General Public * * License along with this library. * * If not, see . * * * * This library 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. * ****************************************************************************/ #ifndef LRSQLEDITDIALOG_H #define LRSQLEDITDIALOG_H #include #include #include #include #include "lrreportengine_p.h" #include "lrdatasourcemanager.h" #include "lrdatadesignintf.h" namespace LimeReport{ namespace Ui { class SQLEditDialog; } struct SQLEditResult; class SQLEditDialog : public QDialog { Q_OBJECT public: enum SQLDialogMode {AddMode,EditMode}; explicit SQLEditDialog(QWidget *parent, LimeReport::DataSourceManager* dataSources,SQLDialogMode dialogMode); void setDataSources(LimeReport::DataSourceManager *dataSources,QString datasourceName=""); void setDefaultConnection(QString defaultConnection); ~SQLEditDialog(); QSettings* settings(); void setSettings(QSettings* value, bool owned = false); signals: void signalSqlEditingFinished(SQLEditResult result); protected: void showEvent(QShowEvent *); void closeEvent(QCloseEvent*); void hideEvent(QHideEvent*); void check(); void initConnections(); private slots: void accept(); void slotDataSourceNameEditing(); void on_cbSubdetail_clicked(bool checked); void on_rbProxy_clicked(bool checked); void on_rbSubQuery_clicked(bool checked); void on_pbAddField_clicked(); void initQueryMode(); void initSubQueryMode(); void initProxyMode(); void slotPreviewData(); void slotHidePreview(); private: void writeSetting(); void readSettings(); void hidePreview(); private: Ui::SQLEditDialog *ui; LimeReport::DataSourceManager* m_datasources; SQLDialogMode m_dialogMode; QString m_oldDatasourceName; QCompleter* m_masterDatasources; QString m_defaultConnection; QSettings* m_settings; bool m_ownedSettings; QSharedPointer m_previewModel; }; struct SQLEditResult{ enum ResultMode{Query,SubQuery,SubProxy}; QString connectionName; QString datasourceName; QString oldDatasourceName; QString sql; bool subdetail; ResultMode resultMode; QString masterDatasource; QString childDataSource; SQLEditDialog::SQLDialogMode dialogMode; QList fieldMap; }; } // namespace LimeReport #endif // LRSQLEDITDIALOG_H