2016-02-17 10:11:00 +03:00
|
|
|
/***************************************************************************
|
|
|
|
* 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 <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
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QGraphicsView>
|
|
|
|
#include <QMainWindow>
|
2016-06-10 18:05:18 +03:00
|
|
|
#include <QTextEdit>
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
#include "lrpagedesignintf.h"
|
|
|
|
#include "lrdatadesignintf.h"
|
|
|
|
#include "lrdatasourcemanager.h"
|
|
|
|
#include "lrcollection.h"
|
|
|
|
#include "lrreportengine_p.h"
|
2016-03-30 23:02:35 +03:00
|
|
|
#include "lrgraphicsviewzoom.h"
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2017-10-26 12:11:33 +03:00
|
|
|
#ifdef HAVE_QT4
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
class LimeReportTabWidget: public QTabWidget{
|
2017-10-26 12:32:16 +03:00
|
|
|
Q_OBJECT
|
2017-10-26 12:11:33 +03:00
|
|
|
public:
|
|
|
|
explicit LimeReportTabWidget(QWidget *parent = 0):QTabWidget(parent){}
|
|
|
|
QTabBar* tabBar() const{ return QTabWidget::tabBar();}
|
|
|
|
};
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
#endif
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
namespace LimeReport {
|
|
|
|
|
|
|
|
class ReportEnginePrivate;
|
|
|
|
class DataBrowser;
|
|
|
|
class ReportDesignWindow;
|
|
|
|
|
|
|
|
class ReportDesignWidget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(QObject* datasourcesManager READ dataManager())
|
|
|
|
friend class ReportDesignWindow;
|
|
|
|
public:
|
|
|
|
~ReportDesignWidget();
|
2016-02-18 21:11:59 +03:00
|
|
|
// static ReportDesignWidget* instance(){return m_instance;}
|
2016-02-17 10:11:00 +03:00
|
|
|
void createStartPage();
|
|
|
|
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();
|
|
|
|
void deleteItem(QGraphicsItem *item);
|
|
|
|
PageDesignIntf* activePage();
|
2016-06-10 18:05:18 +03:00
|
|
|
QGraphicsView* activeView();
|
2016-02-17 10:11:00 +03:00
|
|
|
QList<QGraphicsItem *> selectedItems();
|
|
|
|
QStringList datasourcesNames();
|
|
|
|
void scale( qreal sx, qreal sy);
|
|
|
|
// void setDatabrowser(DataBrowser* databrowser);
|
|
|
|
ReportEnginePrivate* report(){return m_report;}
|
|
|
|
QString reportFileName();
|
|
|
|
bool isNeedToSave();
|
2016-02-17 10:39:17 +03:00
|
|
|
bool emitLoadReport();
|
2016-02-18 21:11:59 +03:00
|
|
|
void saveState(QSettings *settings);
|
|
|
|
void loadState(QSettings *settings);
|
|
|
|
void applySettings();
|
|
|
|
void applyUseGrid();
|
|
|
|
bool useGrid(){ return m_useGrid;}
|
2016-02-21 01:08:54 +03:00
|
|
|
bool useMagnet() const;
|
|
|
|
void setUseMagnet(bool useMagnet);
|
2016-02-18 21:11:59 +03:00
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
public slots:
|
|
|
|
void saveToFile(const QString&);
|
|
|
|
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();
|
|
|
|
void brinToFront();
|
|
|
|
void sendToBack();
|
|
|
|
void alignToLeft();
|
|
|
|
void alignToRight();
|
|
|
|
void alignToVCenter();
|
|
|
|
void alignToTop();
|
|
|
|
void alignToBottom();
|
|
|
|
void alignToHCenter();
|
|
|
|
void sameHeight();
|
|
|
|
void sameWidth();
|
|
|
|
void editLayoutMode(bool value);
|
|
|
|
void addHLayout();
|
|
|
|
void setFont(const QFont &font);
|
2016-02-17 10:39:17 +03:00
|
|
|
void setTextAlign(const bool &horizontalAlign, const Qt::AlignmentFlag &alignment);
|
2016-02-17 10:11:00 +03:00
|
|
|
void setBorders(const BaseDesignIntf::BorderLines& borders);
|
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();
|
2016-02-17 10:11:00 +03:00
|
|
|
private slots:
|
|
|
|
void slotItemSelected(LimeReport::BaseDesignIntf *item);
|
|
|
|
void slotSelectionChanged();
|
|
|
|
void slotPagesLoadFinished();
|
|
|
|
void slotDatasourceCollectionLoaded(const QString&);
|
|
|
|
void slotSceneRectChanged(QRectF);
|
2016-06-10 18:05:18 +03:00
|
|
|
void slotCurrentTabChanged(int index);
|
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();
|
|
|
|
void itemInserted(LimeReport::PageDesignIntf*,QPointF,const QString&);
|
|
|
|
void itemInsertCanceled(const QString&);
|
|
|
|
void itemSelected(LimeReport::BaseDesignIntf *item);
|
|
|
|
void itemPropertyChanged(const QString& objectName, const QString& propertyName, const QVariant& oldValue, const QVariant& newValue);
|
|
|
|
void multiItemSelected();
|
|
|
|
void commandHistoryChanged();
|
|
|
|
void cleared();
|
|
|
|
void loaded();
|
|
|
|
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();
|
|
|
|
protected:
|
|
|
|
void createTabs();
|
2016-02-17 10:11:00 +03:00
|
|
|
private:
|
2016-02-17 10:19:50 +03:00
|
|
|
bool eventFilter(QObject *target, QEvent *event);
|
2016-02-17 10:11:00 +03:00
|
|
|
ReportDesignWidget(ReportEnginePrivate* report,QMainWindow *mainWindow,QWidget *parent = 0);
|
|
|
|
private:
|
|
|
|
ReportEnginePrivate* m_report;
|
|
|
|
QGraphicsView *m_view;
|
2016-06-10 18:05:18 +03:00
|
|
|
QTextEdit* m_scriptEditor;
|
2016-02-17 10:11:00 +03:00
|
|
|
QMainWindow *m_mainWindow;
|
2017-10-26 12:11:33 +03:00
|
|
|
#ifdef HAVE_QT5
|
2016-06-10 18:05:18 +03:00
|
|
|
QTabWidget* m_tabWidget;
|
2017-10-26 12:11:33 +03:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_QT4
|
|
|
|
LimeReportTabWidget* m_tabWidget;
|
|
|
|
#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;
|
2016-02-18 21:11:59 +03:00
|
|
|
// static ReportDesignWidget* m_instance;
|
2017-09-21 22:02:13 +03:00
|
|
|
void prepareReport();
|
2016-02-17 10:11:00 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif // LRREPORTDESIGNWIDGET_H
|