2017-09-13 17:16:54 +03:00
|
|
|
#ifndef LRSCRIPTEDITOR_H
|
|
|
|
#define LRSCRIPTEDITOR_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QCompleter>
|
|
|
|
#include <QTextEdit>
|
|
|
|
#include <QKeyEvent>
|
|
|
|
#include <QScrollBar>
|
2018-02-15 02:21:00 +03:00
|
|
|
#include <QStandardItemModel>
|
2021-12-16 00:13:39 +03:00
|
|
|
#include "lrcompletermodel.h"
|
2017-09-13 17:16:54 +03:00
|
|
|
|
|
|
|
namespace LimeReport{
|
|
|
|
|
2017-11-24 00:13:47 +03:00
|
|
|
class ReportEnginePrivateInterface;
|
2017-09-13 17:16:54 +03:00
|
|
|
class BaseDesignIntf;
|
2017-09-21 00:44:09 +03:00
|
|
|
class PageDesignIntf;
|
|
|
|
class BandDesignIntf;
|
2017-10-05 01:27:04 +03:00
|
|
|
class DataSourceManager;
|
2017-09-13 17:16:54 +03:00
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class ScriptEditor;
|
|
|
|
}
|
|
|
|
|
2021-12-16 00:13:39 +03:00
|
|
|
struct CacheItem {
|
|
|
|
QList<QSharedPointer<CompleterItem>> propsItems;
|
|
|
|
QList<QSharedPointer<CompleterItem>> slotsItems;
|
|
|
|
};
|
|
|
|
|
2018-02-15 02:21:00 +03:00
|
|
|
class ReportStructureCompleater : public QCompleter{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2021-12-16 00:13:39 +03:00
|
|
|
explicit ReportStructureCompleater(QObject* parent = 0): QCompleter(parent){ setModel(&m_newModel);}
|
2018-02-15 02:21:00 +03:00
|
|
|
explicit ReportStructureCompleater(QAbstractItemModel* model, QObject* parent = 0)
|
2021-12-16 00:13:39 +03:00
|
|
|
:QCompleter(model, parent){ setModel(&m_newModel);}
|
2018-02-15 02:21:00 +03:00
|
|
|
public:
|
|
|
|
// QCompleter interface
|
|
|
|
QString pathFromIndex(const QModelIndex& index) const;
|
|
|
|
QStringList splitPath(const QString& path) const;
|
|
|
|
void updateCompleaterModel(ReportEnginePrivateInterface* report);
|
|
|
|
void updateCompleaterModel(DataSourceManager* dataManager);
|
|
|
|
protected:
|
2018-04-18 21:37:05 +03:00
|
|
|
QStringList extractSignalNames(BaseDesignIntf* item);
|
|
|
|
QStringList extractProperties(BaseDesignIntf* item);
|
2021-12-16 00:13:39 +03:00
|
|
|
void addChildItem(BaseDesignIntf *item, const QString &pageName, CompleterItem *parent);
|
|
|
|
void addAdditionalDatawords(CompleterModel *model, DataSourceManager *dataManager);
|
2018-02-15 02:21:00 +03:00
|
|
|
private:
|
2021-12-16 00:13:39 +03:00
|
|
|
CompleterModel m_newModel;
|
2018-04-18 21:37:05 +03:00
|
|
|
QMap<QString, QStringList> m_properties;
|
|
|
|
QMap<QString, QStringList> m_signals;
|
2018-02-15 02:21:00 +03:00
|
|
|
};
|
|
|
|
|
2017-09-13 17:16:54 +03:00
|
|
|
class ScriptEditor : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit ScriptEditor(QWidget *parent = 0);
|
|
|
|
~ScriptEditor();
|
2017-11-24 00:13:47 +03:00
|
|
|
void setReportEngine(LimeReport::ReportEnginePrivateInterface* reportEngine);
|
2017-09-21 00:44:09 +03:00
|
|
|
void setReportPage(PageDesignIntf* page);
|
|
|
|
void setPageBand(BandDesignIntf* band);
|
2019-01-29 23:18:24 +03:00
|
|
|
void setTabIndention(int charCount);
|
2017-09-13 17:16:54 +03:00
|
|
|
void initCompleter();
|
2017-09-20 00:51:17 +03:00
|
|
|
QByteArray saveState();
|
|
|
|
void restoreState(QByteArray state);
|
|
|
|
void setPlainText(const QString &text);
|
2017-09-21 00:44:09 +03:00
|
|
|
void setEditorFont(QFont font);
|
|
|
|
QFont editorFont();
|
2017-09-20 00:51:17 +03:00
|
|
|
QString toPlainText();
|
2019-02-05 21:51:46 +03:00
|
|
|
bool hasChanges() const;
|
|
|
|
void setHasChanges(bool hasChanges);
|
2017-09-21 00:44:09 +03:00
|
|
|
signals:
|
|
|
|
void splitterMoved(int, int);
|
2019-02-05 21:51:46 +03:00
|
|
|
void textChanged();
|
2017-10-05 01:27:04 +03:00
|
|
|
protected:
|
|
|
|
void initEditor(DataSourceManager* dm);
|
|
|
|
|
2017-09-20 00:51:17 +03:00
|
|
|
private slots:
|
|
|
|
void on_twData_doubleClicked(const QModelIndex &index);
|
|
|
|
void on_twScriptEngine_doubleClicked(const QModelIndex &index);
|
2017-10-05 01:27:04 +03:00
|
|
|
void slotOnCurrentChanged(const QModelIndex& to, const QModelIndex&);
|
2019-02-05 21:51:46 +03:00
|
|
|
|
2017-09-13 17:16:54 +03:00
|
|
|
private:
|
|
|
|
Ui::ScriptEditor *ui;
|
2017-11-24 00:13:47 +03:00
|
|
|
ReportEnginePrivateInterface* m_reportEngine;
|
2017-09-21 00:44:09 +03:00
|
|
|
PageDesignIntf* m_page;
|
2018-02-15 02:21:00 +03:00
|
|
|
ReportStructureCompleater* m_completer;
|
2019-01-29 23:18:24 +03:00
|
|
|
int m_tabIndention;
|
2017-09-13 17:16:54 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace LimeReport
|
|
|
|
|
|
|
|
#endif // LRSCRIPTEDITOR_H
|