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 LRREPORTDESIGNWIDGET_H
|
|
|
|
#define LRREPORTDESIGNWIDGET_H
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
#include "lrcollection.h"
|
2016-02-17 10:11:00 +03:00
|
|
|
#include "lrdatadesignintf.h"
|
|
|
|
#include "lrdatasourcemanager.h"
|
2016-03-30 23:02:35 +03:00
|
|
|
#include "lrgraphicsviewzoom.h"
|
2024-09-04 17:31:16 +03:00
|
|
|
#include "lrpagedesignintf.h"
|
|
|
|
#include "lrreportengine_p.h"
|
|
|
|
|
|
|
|
#include <QGraphicsView>
|
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QTextEdit>
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2021-08-23 08:07:08 +03:00
|
|
|
#if QT_VERSION < 0x050000
|
2017-10-26 12:11:33 +03:00
|
|
|
QT_BEGIN_NAMESPACE
|
2024-09-04 17:31:16 +03:00
|
|
|
class LimeReportTabWidget: public QTabWidget {
|
2017-10-26 12:24:06 +03:00
|
|
|
Q_OBJECT
|
2017-10-26 12:11:33 +03:00
|
|
|
public:
|
2024-09-04 17:31:16 +03:00
|
|
|
explicit LimeReportTabWidget(QWidget* parent = 0): QTabWidget(parent) { }
|
|
|
|
QTabBar* tabBar() const { return QTabWidget::tabBar(); }
|
2017-10-26 12:11:33 +03:00
|
|
|
};
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
#endif
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
namespace LimeReport {
|
|
|
|
|
|
|
|
class ReportEnginePrivate;
|
|
|
|
class DataBrowser;
|
|
|
|
class ReportDesignWindow;
|
2017-04-14 02:43:34 +03:00
|
|
|
class DialogDesignerManager;
|
2017-04-07 21:01:51 +03:00
|
|
|
class DialogDesigner;
|
2017-08-05 01:38:19 +03:00
|
|
|
class TranslationEditor;
|
2017-09-13 17:16:54 +03:00
|
|
|
class ScriptEditor;
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
class Ruler: public QWidget {
|
2019-06-21 20:18:23 +03:00
|
|
|
public:
|
2024-09-04 17:31:16 +03:00
|
|
|
enum RulerType {
|
|
|
|
Horizontal,
|
|
|
|
Vertical
|
|
|
|
};
|
|
|
|
Ruler(RulerType type, QWidget* parent = 0): QWidget(parent), m_page(0), m_type(type) { }
|
2019-06-21 20:18:23 +03:00
|
|
|
void setPage(PageItemDesignIntf* page);
|
2024-09-04 17:31:16 +03:00
|
|
|
void setMousePos(QPoint mousePos) { m_mousePos = mousePos; }
|
|
|
|
|
2019-06-21 20:18:23 +03:00
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent* event);
|
2024-09-04 17:31:16 +03:00
|
|
|
void drawItemWithChildren(QPainter* painter, BaseDesignIntf* item);
|
|
|
|
void drawItem(QPainter* painter, BaseDesignIntf* item);
|
|
|
|
|
2019-06-21 20:18:23 +03:00
|
|
|
private:
|
|
|
|
PageItemDesignIntf* m_page;
|
|
|
|
RulerType m_type;
|
|
|
|
QPoint m_mousePos;
|
|
|
|
};
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
class PageView: public QGraphicsView {
|
2019-06-21 20:18:23 +03:00
|
|
|
public:
|
2024-09-04 17:31:16 +03:00
|
|
|
PageView(QWidget* parent = NULL):
|
|
|
|
QGraphicsView(parent),
|
|
|
|
m_horizontalRuller(0),
|
|
|
|
m_verticalRuller(0)
|
2019-06-21 20:18:23 +03:00
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
setViewportMargins(20, 20, 0, 0);
|
2019-06-21 20:18:23 +03:00
|
|
|
}
|
2024-09-04 17:31:16 +03:00
|
|
|
PageView(QGraphicsScene* scene, QWidget* parent = NULL):
|
2019-06-21 20:18:23 +03:00
|
|
|
QGraphicsView(scene, parent),
|
2024-09-04 17:31:16 +03:00
|
|
|
m_horizontalRuller(0),
|
|
|
|
m_verticalRuller(0)
|
2019-06-21 20:18:23 +03:00
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
setViewportMargins(20, 20, 0, 0);
|
2019-06-21 20:18:23 +03:00
|
|
|
}
|
|
|
|
void setPageItem(PageItemDesignIntf* pageItem);
|
2024-09-04 17:31:16 +03:00
|
|
|
|
2019-06-21 20:18:23 +03:00
|
|
|
protected:
|
2024-09-04 17:31:16 +03:00
|
|
|
bool viewportEvent(QEvent* event);
|
|
|
|
|
2019-06-21 20:18:23 +03:00
|
|
|
private:
|
|
|
|
PageItemDesignIntf* m_pageItem;
|
|
|
|
Ruler* m_horizontalRuller;
|
|
|
|
Ruler* m_verticalRuller;
|
|
|
|
};
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
class ReportDesignWidget: public QWidget {
|
2016-02-17 10:11:00 +03:00
|
|
|
Q_OBJECT
|
2021-08-18 05:32:45 +03:00
|
|
|
Q_PROPERTY(QObject* datasourcesManager READ dataManager)
|
2016-02-17 10:11:00 +03:00
|
|
|
public:
|
2024-09-04 17:31:16 +03:00
|
|
|
enum ToolWindowType {
|
2017-04-07 21:01:51 +03:00
|
|
|
WidgetBox = 1,
|
|
|
|
ObjectInspector = 2,
|
|
|
|
ActionEditor = 3,
|
|
|
|
SignalSlotEditor = 4,
|
|
|
|
PropertyEditor = 5,
|
|
|
|
ResourceEditor = 6
|
|
|
|
};
|
2024-09-04 17:31:16 +03:00
|
|
|
enum EditorTabType {
|
2017-04-07 21:01:51 +03:00
|
|
|
Page,
|
|
|
|
Dialog,
|
2017-08-05 01:38:19 +03:00
|
|
|
Script,
|
2017-09-20 22:25:50 +03:00
|
|
|
Translations,
|
|
|
|
TabTypeCount
|
2017-04-07 21:01:51 +03:00
|
|
|
};
|
2019-01-29 23:18:24 +03:00
|
|
|
ReportDesignWidget(ReportEnginePrivateInterface* report, QSettings* settings,
|
2024-09-04 17:31:16 +03:00
|
|
|
QMainWindow* mainWindow, QWidget* parent = 0);
|
2016-02-17 10:11:00 +03:00
|
|
|
~ReportDesignWidget();
|
2024-09-04 17:31:16 +03:00
|
|
|
PageDesignIntf* createStartPage();
|
2019-06-30 22:00:01 +03:00
|
|
|
void createTabs();
|
2016-02-17 10:11:00 +03:00
|
|
|
void clear();
|
|
|
|
DataSourceManager* dataManager();
|
2016-06-10 18:05:18 +03:00
|
|
|
ScriptEngineManager* scriptManager();
|
|
|
|
ScriptEngineContext* scriptContext();
|
2016-02-17 10:11:00 +03:00
|
|
|
void removeDatasource(const QString& datasourceName);
|
|
|
|
void addBand(const QString& bandType);
|
|
|
|
void addBand(BandDesignIntf::BandsType bandType);
|
|
|
|
void startInsertMode(const QString& itemType);
|
|
|
|
void startEditMode();
|
|
|
|
void updateSize();
|
|
|
|
bool isCanUndo();
|
|
|
|
bool isCanRedo();
|
2024-09-04 17:31:16 +03:00
|
|
|
void deleteItem(QGraphicsItem* item);
|
2016-02-17 10:11:00 +03:00
|
|
|
PageDesignIntf* activePage();
|
2016-06-10 18:05:18 +03:00
|
|
|
QGraphicsView* activeView();
|
2024-09-04 17:31:16 +03:00
|
|
|
QList<QGraphicsItem*> selectedItems();
|
2016-02-17 10:11:00 +03:00
|
|
|
QStringList datasourcesNames();
|
2024-09-04 17:31:16 +03:00
|
|
|
void scale(qreal sx, qreal sy);
|
|
|
|
ReportEnginePrivateInterface* report() { return m_report; }
|
2016-02-17 10:11:00 +03:00
|
|
|
QString reportFileName();
|
|
|
|
bool isNeedToSave();
|
2018-05-23 19:01:30 +03:00
|
|
|
bool emitSaveReport();
|
|
|
|
bool emitSaveReportAs();
|
2016-02-17 10:39:17 +03:00
|
|
|
bool emitLoadReport();
|
2019-02-12 22:28:16 +03:00
|
|
|
void saveState();
|
2019-01-29 23:18:24 +03:00
|
|
|
void loadState();
|
2016-02-18 21:11:59 +03:00
|
|
|
void applySettings();
|
|
|
|
void applyUseGrid();
|
2024-09-04 17:31:16 +03:00
|
|
|
bool useGrid() { return m_useGrid; }
|
2016-02-21 01:08:54 +03:00
|
|
|
bool useMagnet() const;
|
|
|
|
void setUseMagnet(bool useMagnet);
|
2017-04-07 21:01:51 +03:00
|
|
|
EditorTabType activeTabType();
|
2017-04-11 11:23:34 +03:00
|
|
|
#ifdef HAVE_QTDESIGNER_INTEGRATION
|
|
|
|
void initDialogDesignerToolBar(QToolBar* toolBar);
|
|
|
|
void updateDialogs();
|
2024-09-04 17:31:16 +03:00
|
|
|
DialogDesignerManager* dialogDesignerManager() const;
|
2017-04-14 02:43:34 +03:00
|
|
|
QString activeDialogName();
|
|
|
|
DialogDesigner* activeDialogPage();
|
|
|
|
QWidget* toolWindow(ToolWindowType windowType);
|
2017-04-11 11:23:34 +03:00
|
|
|
#endif
|
2016-02-17 10:11:00 +03:00
|
|
|
public slots:
|
2017-04-14 02:43:34 +03:00
|
|
|
bool saveToFile(const QString&);
|
2016-02-17 10:11:00 +03:00
|
|
|
bool save();
|
2016-03-19 13:33:49 +03:00
|
|
|
bool loadFromFile(const QString&);
|
2016-02-17 10:11:00 +03:00
|
|
|
void deleteSelectedItems();
|
2016-06-10 18:05:18 +03:00
|
|
|
void connectPage(PageDesignIntf* page);
|
2016-02-17 10:11:00 +03:00
|
|
|
void undo();
|
|
|
|
void redo();
|
|
|
|
void copy();
|
|
|
|
void paste();
|
|
|
|
void cut();
|
2018-12-23 11:41:24 +03:00
|
|
|
void bringToFront();
|
2016-02-17 10:11:00 +03:00
|
|
|
void sendToBack();
|
|
|
|
void alignToLeft();
|
|
|
|
void alignToRight();
|
|
|
|
void alignToVCenter();
|
|
|
|
void alignToTop();
|
|
|
|
void alignToBottom();
|
|
|
|
void alignToHCenter();
|
|
|
|
void sameHeight();
|
|
|
|
void sameWidth();
|
|
|
|
void editLayoutMode(bool value);
|
|
|
|
void addHLayout();
|
2018-06-21 14:29:00 +03:00
|
|
|
void addVLayout();
|
2024-09-04 17:31:16 +03:00
|
|
|
void setFont(const QFont& font);
|
|
|
|
void setTextAlign(const bool& horizontalAlign, const Qt::AlignmentFlag& alignment);
|
2016-02-17 10:11:00 +03:00
|
|
|
void setBorders(const BaseDesignIntf::BorderLines& borders);
|
2024-09-04 17:31:16 +03:00
|
|
|
void setBordersExt(const BaseDesignIntf::BorderLines& border, const double borderWidth,
|
2022-10-31 21:20:24 +03:00
|
|
|
const LimeReport::BaseDesignIntf::BorderStyle style, const QString color);
|
2016-02-18 21:11:59 +03:00
|
|
|
void editSetting();
|
|
|
|
void setUseGrid(bool value);
|
2016-06-10 18:05:18 +03:00
|
|
|
void previewReport();
|
|
|
|
void printReport();
|
|
|
|
void addPage();
|
|
|
|
void deleteCurrentPage();
|
2017-04-11 11:23:34 +03:00
|
|
|
void slotPagesLoadFinished();
|
2017-04-14 02:43:34 +03:00
|
|
|
void slotDialogDeleted(QString dialogName);
|
2019-06-28 20:12:47 +03:00
|
|
|
void lockSelectedItems();
|
|
|
|
void unlockSelectedItems();
|
|
|
|
void selectOneLevelItems();
|
2017-04-14 02:43:34 +03:00
|
|
|
#ifdef HAVE_QTDESIGNER_INTEGRATION
|
|
|
|
void addNewDialog();
|
|
|
|
#endif
|
2016-02-17 10:11:00 +03:00
|
|
|
private slots:
|
2024-09-04 17:31:16 +03:00
|
|
|
void slotItemSelected(LimeReport::BaseDesignIntf* item);
|
2016-02-17 10:11:00 +03:00
|
|
|
void slotSelectionChanged();
|
|
|
|
void slotDatasourceCollectionLoaded(const QString&);
|
|
|
|
void slotSceneRectChanged(QRectF);
|
2016-06-10 18:05:18 +03:00
|
|
|
void slotCurrentTabChanged(int index);
|
2018-05-08 10:58:43 +03:00
|
|
|
void slotReportLoaded();
|
2019-02-05 21:51:46 +03:00
|
|
|
void slotScriptTextChanged();
|
2019-07-24 03:13:23 +03:00
|
|
|
void slotItemPropertyObjectNameChanged(const QString& oldName, const QString& newName);
|
2017-04-11 11:23:34 +03:00
|
|
|
#ifdef HAVE_QTDESIGNER_INTEGRATION
|
2017-04-14 02:43:34 +03:00
|
|
|
void slotDialogChanged(QString);
|
|
|
|
void slotDialogNameChanged(QString oldName, QString newName);
|
2017-04-11 11:23:34 +03:00
|
|
|
#endif
|
2017-08-19 00:16:55 +03:00
|
|
|
void slotPagePropertyObjectNameChanged(const QString& oldValue, const QString& newValue);
|
|
|
|
void slotTabMoved(int from, int to);
|
2016-02-17 10:11:00 +03:00
|
|
|
signals:
|
|
|
|
void insertModeStarted();
|
2024-09-04 17:31:16 +03:00
|
|
|
void itemInserted(LimeReport::PageDesignIntf*, QPointF, const QString&);
|
2016-02-17 10:11:00 +03:00
|
|
|
void itemInsertCanceled(const QString&);
|
2024-09-04 17:31:16 +03:00
|
|
|
void itemSelected(LimeReport::BaseDesignIntf* item);
|
|
|
|
void itemPropertyChanged(const QString& objectName, const QString& propertyName,
|
|
|
|
const QVariant& oldValue, const QVariant& newValue);
|
2016-02-17 10:11:00 +03:00
|
|
|
void multiItemSelected();
|
|
|
|
void commandHistoryChanged();
|
|
|
|
void cleared();
|
2018-05-31 18:49:57 +03:00
|
|
|
void loadFinished();
|
2016-02-17 10:11:00 +03:00
|
|
|
void activePageChanged();
|
2016-04-21 00:06:08 +03:00
|
|
|
void activePageUpdated(LimeReport::PageDesignIntf*);
|
2016-02-17 10:11:00 +03:00
|
|
|
void bandAdded(LimeReport::PageDesignIntf*, LimeReport::BandDesignIntf*);
|
|
|
|
void bandDeleted(LimeReport::PageDesignIntf*, LimeReport::BandDesignIntf*);
|
|
|
|
void itemAdded(LimeReport::PageDesignIntf*, LimeReport::BaseDesignIntf*);
|
|
|
|
void itemDeleted(LimeReport::PageDesignIntf*, LimeReport::BaseDesignIntf*);
|
2016-06-10 18:05:18 +03:00
|
|
|
void pageAdded(PageDesignIntf* page);
|
|
|
|
void pageDeleted();
|
2024-09-04 17:31:16 +03:00
|
|
|
|
2016-06-10 18:05:18 +03:00
|
|
|
protected:
|
2024-09-04 17:31:16 +03:00
|
|
|
PageView* createPageView(PageDesignIntf* page);
|
2017-04-14 02:43:34 +03:00
|
|
|
#ifdef HAVE_QTDESIGNER_INTEGRATION
|
2024-09-04 17:31:16 +03:00
|
|
|
void createNewDialogTab(const QString& dialogName, const QByteArray& description);
|
2017-04-14 02:43:34 +03:00
|
|
|
#endif
|
2016-02-17 10:11:00 +03:00
|
|
|
private:
|
2024-09-04 17:31:16 +03:00
|
|
|
bool eventFilter(QObject* target, QEvent* event);
|
2017-12-11 16:48:00 +03:00
|
|
|
void prepareReport();
|
2019-05-26 15:15:06 +03:00
|
|
|
void initThemeIfExist(const QString& themeName, const QString& path);
|
2024-09-04 17:31:16 +03:00
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
private:
|
2017-11-24 00:13:47 +03:00
|
|
|
ReportEnginePrivateInterface* m_report;
|
2024-09-04 17:31:16 +03:00
|
|
|
QGraphicsView* m_view;
|
2017-09-20 00:51:17 +03:00
|
|
|
ScriptEditor* m_scriptEditor;
|
2017-08-05 01:38:19 +03:00
|
|
|
TranslationEditor* m_traslationEditor;
|
2017-04-14 02:43:34 +03:00
|
|
|
#ifdef HAVE_QTDESIGNER_INTEGRATION
|
|
|
|
DialogDesignerManager* m_dialogDesignerManager;
|
|
|
|
#endif
|
2024-09-04 17:31:16 +03:00
|
|
|
QMainWindow* m_mainWindow;
|
2021-08-23 08:07:08 +03:00
|
|
|
#if QT_VERSION < 0x050000
|
2017-10-26 12:11:33 +03:00
|
|
|
LimeReportTabWidget* m_tabWidget;
|
2021-08-23 08:07:08 +03:00
|
|
|
#else
|
2017-10-26 12:24:06 +03:00
|
|
|
QTabWidget* m_tabWidget;
|
2017-10-26 12:11:33 +03:00
|
|
|
#endif
|
2016-03-30 23:02:35 +03:00
|
|
|
GraphicsViewZoomer* m_zoomer;
|
2016-02-18 21:11:59 +03:00
|
|
|
QFont m_defaultFont;
|
|
|
|
int m_verticalGridStep;
|
|
|
|
int m_horizontalGridStep;
|
|
|
|
bool m_useGrid;
|
2016-02-21 01:08:54 +03:00
|
|
|
bool m_useMagnet;
|
2017-04-14 02:43:34 +03:00
|
|
|
bool m_dialogChanged;
|
2019-05-26 15:15:06 +03:00
|
|
|
QString m_theme;
|
2019-01-29 23:18:24 +03:00
|
|
|
QSettings* m_settings;
|
2019-05-26 15:15:06 +03:00
|
|
|
QMap<QString, QString> m_themes;
|
|
|
|
QMap<QString, QString> m_localToEng;
|
2019-06-30 22:00:01 +03:00
|
|
|
BaseDesignIntf::UnitType m_defaultUnits;
|
2016-02-17 10:11:00 +03:00
|
|
|
};
|
|
|
|
|
2017-09-13 17:16:54 +03:00
|
|
|
} // namespace LimeReport
|
2016-02-17 10:11:00 +03:00
|
|
|
#endif // LRREPORTDESIGNWIDGET_H
|