2016-02-17 10:11:00 +03:00
|
|
|
/***************************************************************************
|
|
|
|
* This file is part of the Lime Report project *
|
2021-08-18 20:21:36 +03:00
|
|
|
* Copyright (C) 2021 by Alexander Arin *
|
2016-02-17 10:11:00 +03:00
|
|
|
* 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 <http://www.gnu.org/licenses/>. *
|
|
|
|
* *
|
|
|
|
** 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 <http://www.gnu.org/licenses/>. *
|
|
|
|
* *
|
|
|
|
* 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 LRDATABROWSER_H
|
|
|
|
#define LRDATABROWSER_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QTreeWidget>
|
|
|
|
#include <QToolButton>
|
|
|
|
#include <QDockWidget>
|
|
|
|
|
|
|
|
#include "lrreportdesignwidget.h"
|
|
|
|
#include "lrsqleditdialog.h"
|
2019-04-04 04:37:18 +03:00
|
|
|
#include "lrdatabrowsertree.h"
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2016-03-04 04:53:34 +03:00
|
|
|
namespace LimeReport{
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
namespace Ui {
|
|
|
|
class DataBrowser;
|
|
|
|
}
|
|
|
|
|
|
|
|
class DataBrowser : public QWidget, public IConnectionController
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
|
|
|
|
explicit DataBrowser(QWidget *parent = 0);
|
|
|
|
~DataBrowser();
|
|
|
|
QSize sizeHint() const;
|
|
|
|
void setReportEditor(LimeReport::ReportDesignWidget* report);
|
|
|
|
void setMainWindow(QMainWindow* mainWindow);
|
|
|
|
void initConnections();
|
|
|
|
void updateDataTree();
|
|
|
|
void updateVariablesTree();
|
|
|
|
void closeAllDataWindows();
|
|
|
|
void setSettings(QSettings* value, bool owned = false);
|
|
|
|
QSettings* settings();
|
2016-02-25 00:27:11 +03:00
|
|
|
QString lastError() const;
|
|
|
|
void setLastError(const QString &lastError);
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
private slots:
|
|
|
|
void slotDatasourcesChanged();
|
|
|
|
void slotAddConnection();
|
|
|
|
void slotDeleteConnection();
|
|
|
|
void slotAddDataSource();
|
|
|
|
void slotViewDatasource();
|
|
|
|
void slotEditDatasource();
|
|
|
|
void slotDeleteDatasource();
|
|
|
|
void slotSQLEditingFinished(SQLEditResult result);
|
|
|
|
void slotClear();
|
|
|
|
void slotDataWindowClosed();
|
|
|
|
void slotChangeConnection();
|
|
|
|
void slotChangeConnectionState();
|
|
|
|
void slotVariableEditorAccept(const QString &variable);
|
|
|
|
void on_dataTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
|
|
|
void on_editVariable_clicked();
|
|
|
|
void on_deleteVariable_clicked();
|
|
|
|
void on_addVariable_clicked();
|
|
|
|
void on_variablesTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
|
|
|
void on_errorMessage_clicked();
|
2016-06-07 00:44:21 +03:00
|
|
|
void on_varToReport_clicked();
|
|
|
|
void on_variablesTree_itemDoubleClicked(QTreeWidgetItem *item, int);
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
private:
|
2017-02-15 02:52:11 +03:00
|
|
|
enum NameType{NameForUser, NameForReport};
|
2016-02-17 10:11:00 +03:00
|
|
|
QString getDatasourceName();
|
2017-02-15 02:52:11 +03:00
|
|
|
QString getConnectionName(NameType nameType);
|
2016-02-17 10:11:00 +03:00
|
|
|
QString getVariable();
|
|
|
|
bool isClosingWindows() const {return m_closingWindows;}
|
|
|
|
QTreeWidgetItem * findByNameAndType(QString name, int itemType);
|
|
|
|
void fillFields(QTreeWidgetItem *parentItem, LimeReport::IDataSource *dataSource);
|
|
|
|
QDockWidget* createDataWindow(QString datasourceName);
|
|
|
|
void closeDataWindow(QString datasourceName);
|
|
|
|
QDockWidget* dataWindow(QString datasourceName);
|
|
|
|
void showDataWindow(QString datasourceName);
|
|
|
|
void removeDatasource(QString datasourceName);
|
|
|
|
void addQuery(SQLEditResult result);
|
|
|
|
void changeQuery(SQLEditResult result);
|
|
|
|
void addSubQuery(SQLEditResult result);
|
|
|
|
void changeSubQuery(SQLEditResult result);
|
|
|
|
void addProxy(SQLEditResult result);
|
|
|
|
void changeProxy(SQLEditResult result);
|
2019-04-04 04:37:18 +03:00
|
|
|
void addCSV(SQLEditResult result);
|
|
|
|
void changeCSV(SQLEditResult result);
|
2018-05-21 21:10:16 +03:00
|
|
|
|
|
|
|
SQLEditResult::ResultMode currentDatasourceType(const QString& datasourceName);
|
|
|
|
void applyChanges(SQLEditResult result);
|
|
|
|
void addDatasource(SQLEditResult result);
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
void addConnectionDesc(ConnectionDesc *connection);
|
|
|
|
void changeConnectionDesc(ConnectionDesc *connection);
|
2016-02-25 00:27:11 +03:00
|
|
|
bool checkConnectionDesc(ConnectionDesc *connection);
|
2017-02-15 02:52:11 +03:00
|
|
|
bool containsDefaultConnection();
|
2019-04-04 04:37:18 +03:00
|
|
|
void activateItem(const QString &name, DataBrowserTree::NodeType type);
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
Ui::DataBrowser* ui;
|
|
|
|
ReportDesignWidget* m_report;
|
|
|
|
QMap<QString,QDockWidget*> m_dataWindows;
|
|
|
|
QMainWindow* m_mainWindow;
|
|
|
|
bool m_closingWindows;
|
|
|
|
QSettings* m_settings;
|
|
|
|
bool m_ownedSettings;
|
2016-02-25 00:27:11 +03:00
|
|
|
QString m_lastError;
|
2016-02-17 10:11:00 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif // LRDATABROWSER_H
|