mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2025-09-23 16:49:07 +03:00
1.0.1.7
This commit is contained in:
24
include/lrcallbackdatasourceintf.h
Normal file
24
include/lrcallbackdatasourceintf.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef LRVIRTUALDATASOURCEINTF
|
||||
#define LRVIRTUALDATASOURCEINTF
|
||||
#include <QObject>
|
||||
namespace LimeReport {
|
||||
|
||||
struct CallbackInfo{
|
||||
enum DataType{IsEmpty, HasNext, ColumnHeaderData, ColumnData};
|
||||
enum ChangePosType{First, Next};
|
||||
DataType dataType;
|
||||
int index;
|
||||
QString columnName;
|
||||
};
|
||||
|
||||
class ICallbackDatasource :public QObject{
|
||||
Q_OBJECT
|
||||
signals:
|
||||
void getCallbackData(const LimeReport::CallbackInfo& info, QVariant& data);
|
||||
void changePos(const LimeReport::CallbackInfo::ChangePosType& type, bool& result);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // LRVIRTUALDATASOURCEINTF
|
||||
|
54
include/lrdatasourcemanagerintf.h
Normal file
54
include/lrdatasourcemanagerintf.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/***************************************************************************
|
||||
* 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 LRDATASOURCEMANAGERINTF_H
|
||||
#define LRDATASOURCEMANAGERINTF_H
|
||||
|
||||
#include "lrcallbackdatasourceintf.h"
|
||||
|
||||
class QVariant;
|
||||
class QString;
|
||||
class QAbstractItemModel;
|
||||
namespace LimeReport{
|
||||
|
||||
class IDataSourceManager{
|
||||
public:
|
||||
virtual void setReportVariable(const QString& name, const QVariant& value)=0;
|
||||
virtual void deleteVariable(const QString& name)=0;
|
||||
virtual bool containsVariable(const QString& variableName)=0;
|
||||
virtual QVariant variable(const QString& variableName)=0;
|
||||
virtual void addModel(const QString& name, QAbstractItemModel *model, bool owned)=0;
|
||||
virtual bool containsDatasource(const QString& dataSourceName)=0;
|
||||
virtual void clearUserVariables()=0;
|
||||
virtual ICallbackDatasource* createCallbackDatasouce(const QString& name) = 0;
|
||||
virtual void addCallbackDatasource(ICallbackDatasource* datasource, const QString& name) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // LRDATASOURCEMANAGERINTF_H
|
40
include/lrglobal.cpp
Normal file
40
include/lrglobal.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
/***************************************************************************
|
||||
* 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. *
|
||||
****************************************************************************/
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
#include "lrglobal.h"
|
||||
|
||||
QString LimeReport::extractClassName(QString className)
|
||||
{
|
||||
int startPos=className.lastIndexOf("::");
|
||||
if(startPos==-1) startPos=0;
|
||||
else startPos+=2;
|
||||
return className.right(className.length()-startPos);
|
||||
}
|
76
include/lrglobal.h
Normal file
76
include/lrglobal.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/***************************************************************************
|
||||
* 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 GLOBAL_H
|
||||
#define GLOBAL_H
|
||||
#include "qglobal.h"
|
||||
#include <stdexcept>
|
||||
#include <QString>
|
||||
|
||||
#if defined(LIMEREPORT_EXPORTS)
|
||||
# define LIMEREPORT_EXPORT Q_DECL_EXPORT
|
||||
#elif defined (LIMEREPORT_IMPORTS)
|
||||
# define LIMEREPORT_EXPORT Q_DECL_IMPORT
|
||||
#else
|
||||
# define LIMEREPORT_EXPORT /**/
|
||||
#endif
|
||||
|
||||
namespace LimeReport {
|
||||
const qreal fontFACTOR = 3.5;
|
||||
const int mmFACTOR = 10;
|
||||
const int itemPaleteIconSize = 24;
|
||||
const qreal minSpaceBorder = 10;
|
||||
QString extractClassName(QString className);
|
||||
const QString bandTAG = "band";
|
||||
const qreal BAND_MARKER_OPACITY = 1;
|
||||
const qreal LAYOUT_MARKER_OPACITY = 0.3;
|
||||
const qreal BAND_NAME_AREA_OPACITY = 0.3;
|
||||
const qreal BAND_NAME_TEXT_OPACITY = 0.6;
|
||||
const qreal SELECTION_OPACITY = 0.3;
|
||||
enum RenderPass {FirstPass, SecondPass};
|
||||
enum ArrangeType {AsNeeded, Force};
|
||||
const QString FIELD_RX = "\\$D\\s*\\{\\s*([^\\s{}]*)\\s*\\}";
|
||||
const QString VARIABLE_RX = "\\$V\\s*\\{\\s*([^\\s{}]*)\\s*\\}";
|
||||
const QString SCRIPT_RX = "\\$S\\s*\\{(.*)\\}";
|
||||
const QString GROUP_FUNCTION_PARAM_RX = "\\(\\s*(((?:\\\"?\\$D\\s*\\{\\s*)|(?:\\\"?\\$V\\s*\\{\\s*)|(?:\\\"))(\\w+\\.?\\w+)((?:\\\")|(?:\\s*\\}\\\"?\\s*)))\\s*,\\s*\\\"(\\w+)\\\"\\s*\\)";
|
||||
const int DATASOURCE_INDEX = 6;
|
||||
const int VALUE_INDEX = 2;
|
||||
const QString GROUP_FUNCTION_RX = "(%1\\s*"+GROUP_FUNCTION_PARAM_RX+")";
|
||||
const QString GROUP_FUNCTION_NAME_RX = "%1\\s*\\((.*[^\\)])\\)";
|
||||
const int SCENE_MARGIN = 50;
|
||||
class ReportError : public std::runtime_error{
|
||||
public:
|
||||
ReportError(const QString& message):std::runtime_error(message.toStdString()){}
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
|
||||
|
||||
#endif // GLOBAL_H
|
105
include/lrreportengine.h
Normal file
105
include/lrreportengine.h
Normal file
@@ -0,0 +1,105 @@
|
||||
/***************************************************************************
|
||||
* 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 LRREPORTDESIGNINTF_H
|
||||
#define LRREPORTDESIGNINTF_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QSettings>
|
||||
#include <QPrintDialog>
|
||||
|
||||
#include "lrglobal.h"
|
||||
#include "lrdatasourcemanagerintf.h"
|
||||
#include "lrscriptenginemanagerintf.h"
|
||||
//#include "lrreportrender.h"
|
||||
|
||||
class QPrinter;
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
|
||||
class PrintRange{
|
||||
public:
|
||||
int fromPage() const { return m_fromPage;}
|
||||
int toPage() const { return m_toPage;}
|
||||
QPrintDialog::PrintRange rangeType() const { return m_rangeType;}
|
||||
PrintRange(QAbstractPrintDialog::PrintRange rangeType=QPrintDialog::AllPages, int fromPage=0, int toPage=0);
|
||||
void setRangeType(QAbstractPrintDialog::PrintRange rangeType){ m_rangeType=rangeType;}
|
||||
void setFromPage(int fromPage){ m_fromPage = fromPage;}
|
||||
void setToPage(int toPage){ m_toPage = toPage;}
|
||||
private:
|
||||
QPrintDialog::PrintRange m_rangeType;
|
||||
int m_fromPage;
|
||||
int m_toPage;
|
||||
};
|
||||
|
||||
class DataSourceManager;
|
||||
class ReportEnginePrivate;
|
||||
//class PageDesignIntf;
|
||||
|
||||
class LIMEREPORT_EXPORT ReportEngine : public QObject{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static void setSettings(QSettings *value){m_settings=value;}
|
||||
public:
|
||||
explicit ReportEngine(QObject *parent = 0);
|
||||
~ReportEngine();
|
||||
bool printReport(QPrinter *printer=0);
|
||||
//void printReport(ReportPages pages, QPrinter &printer);
|
||||
void printToFile(const QString& fileName);
|
||||
//PageDesignIntf *createPreviewScene(QObject *parent = 0);
|
||||
void previewReport();
|
||||
void designReport();
|
||||
void setShowProgressDialog(bool value);
|
||||
IDataSourceManager* dataManager();
|
||||
IScriptEngineManager* scriptManager();
|
||||
|
||||
bool loadFromFile(const QString& fileName);
|
||||
bool loadFromByteArray(QByteArray *data);
|
||||
QString reportFileName();
|
||||
bool saveToFile();
|
||||
bool saveToFile(const QString& fileName);
|
||||
QString lastError();
|
||||
signals:
|
||||
void renderStarted();
|
||||
void renderFinished();
|
||||
void renderPageFinished(int renderedPageCount);
|
||||
public slots:
|
||||
void cancelRender();
|
||||
protected:
|
||||
ReportEnginePrivate * const d_ptr;
|
||||
ReportEngine(ReportEnginePrivate &dd, QObject * parent=0);
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(ReportEngine)
|
||||
static QSettings* m_settings;
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRREPORTDESIGNINTF_H
|
49
include/lrscriptenginemanagerintf.h
Normal file
49
include/lrscriptenginemanagerintf.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/***************************************************************************
|
||||
* 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 LRSCRIPTENGINEMANAGERINTF_H
|
||||
#define LRSCRIPTENGINEMANAGERINTF_H
|
||||
|
||||
#include <QScriptEngine>
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
class IScriptEngineManager{
|
||||
public:
|
||||
virtual QScriptEngine* scriptEngine() = 0;
|
||||
virtual QScriptValue addFunction(const QString& name, QScriptEngine::FunctionSignature function,
|
||||
const QString& category="", const QString& description="") = 0;
|
||||
virtual QScriptValue addFunction(const QString &name, const QString& script,
|
||||
const QString &category="", const QString &description="") = 0;
|
||||
virtual const QString& lastError() const = 0;
|
||||
virtual ~IScriptEngineManager(){}
|
||||
};
|
||||
|
||||
} //namespace LimeReport
|
||||
#endif // LRSCRIPTENGINEMANAGERINTF_H
|
Reference in New Issue
Block a user