mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2024-12-24 12:34:39 +03:00
New functionality has been added to the report's variables
This commit is contained in:
parent
0ab92681b0
commit
af589e31ba
@ -31,6 +31,7 @@
|
|||||||
#define LRDATASOURCEMANAGERINTF_H
|
#define LRDATASOURCEMANAGERINTF_H
|
||||||
|
|
||||||
#include "lrcallbackdatasourceintf.h"
|
#include "lrcallbackdatasourceintf.h"
|
||||||
|
#include "lrglobal.h"
|
||||||
|
|
||||||
class QVariant;
|
class QVariant;
|
||||||
class QString;
|
class QString;
|
||||||
@ -56,6 +57,11 @@ public:
|
|||||||
virtual void clearUserVariables()=0;
|
virtual void clearUserVariables()=0;
|
||||||
virtual ICallbackDatasource* createCallbackDatasource(const QString& name) = 0;
|
virtual ICallbackDatasource* createCallbackDatasource(const QString& name) = 0;
|
||||||
virtual void registerDbCredentialsProvider(IDbCredentialsProvider* provider) = 0;
|
virtual void registerDbCredentialsProvider(IDbCredentialsProvider* provider) = 0;
|
||||||
|
|
||||||
|
virtual QStringList variableNames() = 0;
|
||||||
|
virtual bool variableIsMandatory(const QString& name) = 0;
|
||||||
|
virtual VariableDataType variableDataType(const QString& name) = 0;
|
||||||
|
virtual bool variableIsSystem(const QString& name) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -157,6 +157,17 @@ namespace Const{
|
|||||||
typedef QScriptValue ScriptValueType;
|
typedef QScriptValue ScriptValueType;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
class Enums
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum VariableDataType {Undefined, String, Bool, Int, Real, Date, Time, DateTime};
|
||||||
|
Q_ENUM(VariableDataType)
|
||||||
|
private:
|
||||||
|
Enums(){}
|
||||||
|
Q_GADGET
|
||||||
|
};
|
||||||
|
typedef Enums::VariableDataType VariableDataType;
|
||||||
|
|
||||||
} // namespace LimeReport
|
} // namespace LimeReport
|
||||||
|
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(LimeReport::PreviewHints)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(LimeReport::PreviewHints)
|
||||||
|
@ -237,7 +237,7 @@ void DataBrowser::updateVariablesTree()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(QString variableName,m_report->dataManager()->namesOfUserVariables()){
|
foreach(QString variableName,m_report->dataManager()->userVariableNames()){
|
||||||
if (!m_report->dataManager()->variableNames().contains(variableName)){
|
if (!m_report->dataManager()->variableNames().contains(variableName)){
|
||||||
QStringList values;
|
QStringList values;
|
||||||
values<<variableName+" ["+m_report->dataManager()->variable(variableName).toString()+"]"
|
values<<variableName+" ["+m_report->dataManager()->variable(variableName).toString()+"]"
|
||||||
|
@ -30,8 +30,10 @@
|
|||||||
#include "lrvariabledialog.h"
|
#include "lrvariabledialog.h"
|
||||||
#include "ui_lrvariabledialog.h"
|
#include "ui_lrvariabledialog.h"
|
||||||
#include "lrglobal.h"
|
#include "lrglobal.h"
|
||||||
|
#include "lrvariablesholder.h"
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QMetaEnum>
|
||||||
|
|
||||||
LRVariableDialog::LRVariableDialog(QWidget *parent) :
|
LRVariableDialog::LRVariableDialog(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
@ -42,8 +44,14 @@ LRVariableDialog::LRVariableDialog(QWidget *parent) :
|
|||||||
m_oldVariableName("")
|
m_oldVariableName("")
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->cbbType->setVisible(false);
|
|
||||||
ui->lblType->setVisible(false);
|
static int enumIndex = LimeReport::Enums::staticMetaObject.indexOfEnumerator("VariableDataType");
|
||||||
|
QMetaEnum enumerator = LimeReport::Enums::staticMetaObject.enumerator(enumIndex);
|
||||||
|
for (int i = 0; i<enumerator.keyCount(); ++i){
|
||||||
|
ui->cbbType->addItem(enumerator.key(i));
|
||||||
|
}
|
||||||
|
//ui->cbbType->setVisible(false);
|
||||||
|
//ui->lblType->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
LRVariableDialog::~LRVariableDialog()
|
LRVariableDialog::~LRVariableDialog()
|
||||||
@ -66,14 +74,21 @@ void LRVariableDialog::setVariableName(const QString &value)
|
|||||||
void LRVariableDialog::showEvent(QShowEvent *)
|
void LRVariableDialog::showEvent(QShowEvent *)
|
||||||
{
|
{
|
||||||
ui->leName->setText(m_variableName);
|
ui->leName->setText(m_variableName);
|
||||||
|
static int enumIndex = LimeReport::Enums::staticMetaObject.indexOfEnumerator("VariableDataType");
|
||||||
|
QMetaEnum enumerator = LimeReport::Enums::staticMetaObject.enumerator(enumIndex);
|
||||||
if (!m_variableName.isEmpty()&&m_variablesContainer&&m_variablesContainer->containsVariable(m_variableName)){
|
if (!m_variableName.isEmpty()&&m_variablesContainer&&m_variablesContainer->containsVariable(m_variableName)){
|
||||||
ui->leValue->setText(m_variablesContainer->variable(m_variableName).toString());
|
ui->leValue->setText(m_variablesContainer->variable(m_variableName).toString());
|
||||||
|
ui->cbbType->setCurrentText(enumerator.valueToKey(m_variablesContainer->variableDataType(m_variableName)));
|
||||||
|
ui->cbbMandatory->setChecked(m_variablesContainer->variableIsMandatory(m_variableName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LRVariableDialog::accept()
|
void LRVariableDialog::accept()
|
||||||
{
|
{
|
||||||
try{
|
try{
|
||||||
|
static int enumIndex = LimeReport::Enums::staticMetaObject.indexOfEnumerator("VariableDataType");
|
||||||
|
QMetaEnum enumerator = LimeReport::Enums::staticMetaObject.enumerator(enumIndex);
|
||||||
|
|
||||||
if (m_variablesContainer&&!ui->leName->text().isEmpty()){
|
if (m_variablesContainer&&!ui->leName->text().isEmpty()){
|
||||||
if (m_changeMode){
|
if (m_changeMode){
|
||||||
if (m_oldVariableName==ui->leName->text()){
|
if (m_oldVariableName==ui->leName->text()){
|
||||||
@ -85,6 +100,11 @@ void LRVariableDialog::accept()
|
|||||||
} else {
|
} else {
|
||||||
m_variablesContainer->addVariable(ui->leName->text(),value(), LimeReport::VarDesc::Report);
|
m_variablesContainer->addVariable(ui->leName->text(),value(), LimeReport::VarDesc::Report);
|
||||||
}
|
}
|
||||||
|
m_variablesContainer->setVarableMandatory(ui->leName->text(),ui->cbbMandatory->isChecked());
|
||||||
|
m_variablesContainer->setVariableDataType(
|
||||||
|
ui->leName->text(),
|
||||||
|
LimeReport::VariableDataType(enumerator.keysToValue(ui->cbbType->currentText().toLatin1()))
|
||||||
|
);
|
||||||
emit signalVariableAccepted(ui->leName->text());
|
emit signalVariableAccepted(ui->leName->text());
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>218</width>
|
<width>328</width>
|
||||||
<height>126</height>
|
<height>173</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -18,35 +18,8 @@
|
|||||||
<normaloff>:/databrowser/images/value</normaloff>:/databrowser/images/value</iconset>
|
<normaloff>:/databrowser/images/value</normaloff>:/databrowser/images/value</iconset>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<property name="spacing">
|
|
||||||
<number>2</number>
|
|
||||||
</property>
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>4</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>4</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>4</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>4</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
<item>
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<property name="horizontalSpacing">
|
|
||||||
<number>7</number>
|
|
||||||
</property>
|
|
||||||
<property name="verticalSpacing">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>4</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>8</number>
|
|
||||||
</property>
|
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="lblName">
|
<widget class="QLabel" name="lblName">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -67,9 +40,6 @@
|
|||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="leValue"/>
|
<widget class="QLineEdit" name="leValue"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="QComboBox" name="cbbType"/>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="lblType">
|
<widget class="QLabel" name="lblType">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -77,8 +47,31 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QComboBox" name="cbbType"/>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="cbbMandatory">
|
||||||
|
<property name="text">
|
||||||
|
<string>Mandatory</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -211,7 +211,7 @@ void DataSourceModel::updateModel()
|
|||||||
}
|
}
|
||||||
|
|
||||||
vars = m_rootNode->addChild(tr("External variables"),DataNode::Variables,QIcon(":/report/images/folder"));
|
vars = m_rootNode->addChild(tr("External variables"),DataNode::Variables,QIcon(":/report/images/folder"));
|
||||||
foreach (QString name, m_dataManager->namesOfUserVariables()){
|
foreach (QString name, m_dataManager->userVariableNames()){
|
||||||
vars->addChild(name,DataNode::Variable,QIcon(":/report/images/value"));
|
vars->addChild(name,DataNode::Variable,QIcon(":/report/images/value"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1072,7 +1072,7 @@ int DataSourceManager::elementsCount(const QString &collectionName)
|
|||||||
return m_proxies.count();
|
return m_proxies.count();
|
||||||
}
|
}
|
||||||
if (collectionName=="variables"){
|
if (collectionName=="variables"){
|
||||||
return m_reportVariables.userVariablesCount();
|
return m_reportVariables.variablesCount();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1092,7 +1092,7 @@ QObject* DataSourceManager::elementAt(const QString &collectionName, int index)
|
|||||||
return m_proxies.at(index);
|
return m_proxies.at(index);
|
||||||
}
|
}
|
||||||
if (collectionName=="variables"){
|
if (collectionName=="variables"){
|
||||||
return m_reportVariables.userVariableAt(index);
|
return m_reportVariables.variableAt(index);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1160,6 +1160,8 @@ void DataSourceManager::collectionLoadFinished(const QString &collectionName)
|
|||||||
foreach (VarDesc* item, m_tempVars) {
|
foreach (VarDesc* item, m_tempVars) {
|
||||||
if (!m_reportVariables.containsVariable(item->name())){
|
if (!m_reportVariables.containsVariable(item->name())){
|
||||||
m_reportVariables.addVariable(item->name(),item->value(),VarDesc::Report,FirstPass);
|
m_reportVariables.addVariable(item->name(),item->value(),VarDesc::Report,FirstPass);
|
||||||
|
VarDesc* currentVar = m_reportVariables.variableByName(item->name());
|
||||||
|
currentVar->initFrom(item);
|
||||||
}
|
}
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
@ -1454,6 +1456,19 @@ bool DataSourceManager::variableIsSystem(const QString &name)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DataSourceManager::variableIsMandatory(const QString& name)
|
||||||
|
{
|
||||||
|
if (m_reportVariables.containsVariable(name))
|
||||||
|
return m_reportVariables.variableByName(name)->isMandatory();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataSourceManager::setVarableMandatory(const QString& name, bool value)
|
||||||
|
{
|
||||||
|
if (m_reportVariables.containsVariable(name))
|
||||||
|
m_reportVariables.variableByName(name)->setMandatory(value);
|
||||||
|
}
|
||||||
|
|
||||||
QStringList DataSourceManager::variableNames()
|
QStringList DataSourceManager::variableNames()
|
||||||
{
|
{
|
||||||
return m_reportVariables.variableNames();
|
return m_reportVariables.variableNames();
|
||||||
@ -1470,7 +1485,7 @@ QStringList DataSourceManager::variableNamesByRenderPass(RenderPass pass)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList DataSourceManager::namesOfUserVariables(){
|
QStringList DataSourceManager::userVariableNames(){
|
||||||
return m_userVariables.variableNames();
|
return m_userVariables.variableNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1481,6 +1496,19 @@ VarDesc::VarType DataSourceManager::variableType(const QString &name)
|
|||||||
return VarDesc::User;
|
return VarDesc::User;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VariableDataType DataSourceManager::variableDataType(const QString& name)
|
||||||
|
{
|
||||||
|
if (m_reportVariables.containsVariable(name))
|
||||||
|
return m_reportVariables.variableByName(name)->dataType();
|
||||||
|
return VariableDataType::Undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataSourceManager::setVariableDataType(const QString& name, VariableDataType value)
|
||||||
|
{
|
||||||
|
if (m_reportVariables.containsVariable(name))
|
||||||
|
m_reportVariables.variableByName(name)->setDataType(value);
|
||||||
|
}
|
||||||
|
|
||||||
void DataSourceManager::setAllDatasourcesToFirst()
|
void DataSourceManager::setAllDatasourcesToFirst()
|
||||||
{
|
{
|
||||||
foreach(IDataSourceHolder* ds,m_datasources.values()) {
|
foreach(IDataSourceHolder* ds,m_datasources.values()) {
|
||||||
|
@ -127,9 +127,13 @@ public:
|
|||||||
RenderPass variablePass(const QString& name);
|
RenderPass variablePass(const QString& name);
|
||||||
QStringList variableNames();
|
QStringList variableNames();
|
||||||
QStringList variableNamesByRenderPass(RenderPass pass);
|
QStringList variableNamesByRenderPass(RenderPass pass);
|
||||||
QStringList namesOfUserVariables();
|
QStringList userVariableNames();
|
||||||
VarDesc::VarType variableType(const QString& name);
|
VarDesc::VarType variableType(const QString& name);
|
||||||
|
VariableDataType variableDataType(const QString& name);
|
||||||
|
void setVariableDataType(const QString &name, VariableDataType value);
|
||||||
bool variableIsSystem(const QString& name);
|
bool variableIsSystem(const QString& name);
|
||||||
|
bool variableIsMandatory(const QString& name);
|
||||||
|
void setVarableMandatory(const QString &name, bool value);
|
||||||
QString queryText(const QString& dataSourceName);
|
QString queryText(const QString& dataSourceName);
|
||||||
QString connectionName(const QString& dataSourceName);
|
QString connectionName(const QString& dataSourceName);
|
||||||
void removeDatasource(const QString& name);
|
void removeDatasource(const QString& name);
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#define LRDATASOURCEMANAGERINTF_H
|
#define LRDATASOURCEMANAGERINTF_H
|
||||||
|
|
||||||
#include "lrcallbackdatasourceintf.h"
|
#include "lrcallbackdatasourceintf.h"
|
||||||
|
#include "lrglobal.h"
|
||||||
|
|
||||||
class QVariant;
|
class QVariant;
|
||||||
class QString;
|
class QString;
|
||||||
@ -56,6 +57,11 @@ public:
|
|||||||
virtual void clearUserVariables()=0;
|
virtual void clearUserVariables()=0;
|
||||||
virtual ICallbackDatasource* createCallbackDatasource(const QString& name) = 0;
|
virtual ICallbackDatasource* createCallbackDatasource(const QString& name) = 0;
|
||||||
virtual void registerDbCredentialsProvider(IDbCredentialsProvider* provider) = 0;
|
virtual void registerDbCredentialsProvider(IDbCredentialsProvider* provider) = 0;
|
||||||
|
|
||||||
|
virtual QStringList variableNames() = 0;
|
||||||
|
virtual bool variableIsMandatory(const QString& name) = 0;
|
||||||
|
virtual VariableDataType variableDataType(const QString& name) = 0;
|
||||||
|
virtual bool variableIsSystem(const QString& name) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -157,6 +157,17 @@ namespace Const{
|
|||||||
typedef QScriptValue ScriptValueType;
|
typedef QScriptValue ScriptValueType;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
class Enums
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum VariableDataType {Undefined, String, Bool, Int, Real, Date, Time, DateTime};
|
||||||
|
Q_ENUM(VariableDataType)
|
||||||
|
private:
|
||||||
|
Enums(){}
|
||||||
|
Q_GADGET
|
||||||
|
};
|
||||||
|
typedef Enums::VariableDataType VariableDataType;
|
||||||
|
|
||||||
} // namespace LimeReport
|
} // namespace LimeReport
|
||||||
|
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(LimeReport::PreviewHints)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(LimeReport::PreviewHints)
|
||||||
|
@ -122,16 +122,50 @@ bool VariablesHolder::containsVariable(const QString &name)
|
|||||||
return m_varNames.contains(name);
|
return m_varNames.contains(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int VariablesHolder::userVariablesCount()
|
int VariablesHolder::variablesCount()
|
||||||
{
|
{
|
||||||
return m_userVariables.count();
|
return m_userVariables.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
VarDesc *VariablesHolder::userVariableAt(int index)
|
VarDesc* VariablesHolder::variableByName(const QString& name)
|
||||||
|
{
|
||||||
|
if (m_varNames.contains(name))
|
||||||
|
return m_varNames.value(name);
|
||||||
|
else return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
VarDesc *VariablesHolder::variableAt(int index)
|
||||||
{
|
{
|
||||||
return m_userVariables.at(index);
|
return m_userVariables.at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool VariablesHolder::variableIsMandatory(const QString& name)
|
||||||
|
{
|
||||||
|
if (m_varNames.contains(name))
|
||||||
|
return m_varNames.value(name)->isMandatory();
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VariablesHolder::setVarableMandatory(const QString& name, bool value)
|
||||||
|
{
|
||||||
|
if (m_varNames.contains(name))
|
||||||
|
m_varNames.value(name)->setMandatory(value);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
VariableDataType VariablesHolder::variableDataType(const QString& name)
|
||||||
|
{
|
||||||
|
if (m_varNames.contains(name))
|
||||||
|
return m_varNames.value(name)->dataType();
|
||||||
|
else return Enums::Undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VariablesHolder::setVariableDataType(const QString& name, VariableDataType value)
|
||||||
|
{
|
||||||
|
if (m_varNames.contains(name))
|
||||||
|
m_varNames.value(name)->setDataType(value);
|
||||||
|
}
|
||||||
|
|
||||||
QStringList VariablesHolder::variableNames()
|
QStringList VariablesHolder::variableNames()
|
||||||
{
|
{
|
||||||
QStringList result;
|
QStringList result;
|
||||||
@ -148,4 +182,40 @@ RenderPass VariablesHolder::variablePass(const QString &name)
|
|||||||
else throw ReportError(tr("variable with name ")+name+tr(" does not exists!"));
|
else throw ReportError(tr("variable with name ")+name+tr(" does not exists!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool VarDesc::isMandatory() const
|
||||||
|
{
|
||||||
|
return m_mandatory;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VarDesc::setMandatory(bool mandatory)
|
||||||
|
{
|
||||||
|
m_mandatory = mandatory;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VarDesc::initFrom(VarDesc* value)
|
||||||
|
{
|
||||||
|
m_mandatory = value->isMandatory();
|
||||||
|
m_dataType = value->dataType();
|
||||||
|
}
|
||||||
|
|
||||||
|
VariableDataType VarDesc::dataType() const
|
||||||
|
{
|
||||||
|
return m_dataType;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VarDesc::setDataType(const VariableDataType& dataType)
|
||||||
|
{
|
||||||
|
m_dataType = dataType;
|
||||||
|
}
|
||||||
|
|
||||||
|
int VarDesc::readDataTypeProperty() const
|
||||||
|
{
|
||||||
|
return static_cast<int>(m_dataType);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VarDesc::setDataTypeProperty(int value)
|
||||||
|
{
|
||||||
|
m_dataType = static_cast<VariableDataType>(value);
|
||||||
|
}
|
||||||
|
|
||||||
}// namespace LimeReport
|
}// namespace LimeReport
|
||||||
|
@ -42,7 +42,10 @@ class VarDesc : public QObject{
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString name READ name WRITE setName)
|
Q_PROPERTY(QString name READ name WRITE setName)
|
||||||
Q_PROPERTY(QVariant value READ value WRITE setValue)
|
Q_PROPERTY(QVariant value READ value WRITE setValue)
|
||||||
|
Q_PROPERTY(bool isMandatory READ isMandatory WRITE setMandatory)
|
||||||
|
Q_PROPERTY(int dataType READ readDataTypeProperty WRITE setDataTypeProperty)
|
||||||
public:
|
public:
|
||||||
|
VarDesc() : m_dataType(VariableDataType::Undefined), m_mandatory(false){}
|
||||||
enum VarType {System, User, Report};
|
enum VarType {System, User, Report};
|
||||||
void setVarType(VarType value){m_varType=value;}
|
void setVarType(VarType value){m_varType=value;}
|
||||||
VarType varType(){return m_varType;}
|
VarType varType(){return m_varType;}
|
||||||
@ -52,26 +55,39 @@ public:
|
|||||||
QString name(){return m_name;}
|
QString name(){return m_name;}
|
||||||
void setValue(QVariant value){m_value=value;}
|
void setValue(QVariant value){m_value=value;}
|
||||||
QVariant value(){return m_value;}
|
QVariant value(){return m_value;}
|
||||||
|
VariableDataType dataType() const;
|
||||||
|
void setDataType(const VariableDataType& dataType);
|
||||||
|
int readDataTypeProperty() const;
|
||||||
|
void setDataTypeProperty(int value);
|
||||||
|
bool isMandatory() const;
|
||||||
|
void setMandatory(bool isMandatory);
|
||||||
|
void initFrom(VarDesc* value);
|
||||||
private:
|
private:
|
||||||
VarType m_varType;
|
VarType m_varType;
|
||||||
RenderPass m_varPass;
|
RenderPass m_varPass;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
QVariant m_value;
|
QVariant m_value;
|
||||||
|
VariableDataType m_dataType;
|
||||||
|
bool m_mandatory;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IVariablesContainer
|
class IVariablesContainer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~IVariablesContainer(){}
|
virtual ~IVariablesContainer(){}
|
||||||
virtual void addVariable(const QString &name, const QVariant &value, VarDesc::VarType type=VarDesc::User, RenderPass pass=FirstPass)=0;
|
virtual void addVariable(const QString& name, const QVariant &value, VarDesc::VarType type=VarDesc::User, RenderPass pass=FirstPass) = 0;
|
||||||
virtual void deleteVariable(const QString &name)=0;
|
virtual void deleteVariable(const QString& name) = 0;
|
||||||
virtual void changeVariable(const QString &name, const QVariant &value)=0;
|
virtual void changeVariable(const QString& name, const QVariant &value) = 0;
|
||||||
virtual void clearUserVariables()=0;
|
virtual void clearUserVariables() = 0;
|
||||||
virtual QVariant variable(const QString &name)=0;
|
virtual QVariant variable(const QString& name) = 0;
|
||||||
virtual VarDesc::VarType variableType(const QString &name)=0;
|
virtual VarDesc::VarType variableType(const QString& name) = 0;
|
||||||
virtual RenderPass variablePass(const QString &name)=0;
|
virtual RenderPass variablePass(const QString& name) = 0;
|
||||||
virtual bool containsVariable(const QString &name)=0;
|
virtual bool containsVariable(const QString& name) = 0;
|
||||||
virtual QStringList variableNames()=0;
|
virtual QStringList variableNames() = 0;
|
||||||
|
virtual bool variableIsMandatory(const QString& name) = 0;
|
||||||
|
virtual void setVarableMandatory(const QString& name, bool value) = 0;
|
||||||
|
virtual VariableDataType variableDataType(const QString& name) = 0;
|
||||||
|
virtual void setVariableDataType(const QString& name, VariableDataType value) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class VariablesHolder : public QObject, public IVariablesContainer
|
class VariablesHolder : public QObject, public IVariablesContainer
|
||||||
@ -85,12 +101,17 @@ public:
|
|||||||
void changeVariable(const QString &name, const QVariant &value);
|
void changeVariable(const QString &name, const QVariant &value);
|
||||||
void clearUserVariables();
|
void clearUserVariables();
|
||||||
QVariant variable(const QString &name);
|
QVariant variable(const QString &name);
|
||||||
VarDesc::VarType variableType(const QString &name);
|
VarDesc::VarType variableType(const QString& name);
|
||||||
RenderPass variablePass(const QString &name);
|
RenderPass variablePass(const QString &name);
|
||||||
bool containsVariable(const QString &name);
|
bool containsVariable(const QString &name);
|
||||||
QStringList variableNames();
|
QStringList variableNames();
|
||||||
int userVariablesCount();
|
int variablesCount();
|
||||||
VarDesc* userVariableAt(int index);
|
VarDesc* variableByName(const QString& name);
|
||||||
|
VarDesc* variableAt(int index);
|
||||||
|
bool variableIsMandatory(const QString& name);
|
||||||
|
void setVarableMandatory(const QString &name, bool value);
|
||||||
|
VariableDataType variableDataType(const QString& name);
|
||||||
|
void setVariableDataType(const QString &name, VariableDataType value);
|
||||||
signals:
|
signals:
|
||||||
void variableHasBeenAdded(const QString& variableName);
|
void variableHasBeenAdded(const QString& variableName);
|
||||||
void variableHasBeenChanged(const QString& variableName);
|
void variableHasBeenChanged(const QString& variableName);
|
||||||
|
Loading…
Reference in New Issue
Block a user