mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2024-12-24 12:34:39 +03:00
Report variables have been refactored
This commit is contained in:
parent
127bb45b7d
commit
5455b53404
BIN
limereport/databrowser/images/varToReport.png
Normal file
BIN
limereport/databrowser/images/varToReport.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 644 B |
@ -208,12 +208,15 @@ void DataBrowser::updateDataTree()
|
|||||||
void DataBrowser::updateVariablesTree()
|
void DataBrowser::updateVariablesTree()
|
||||||
{
|
{
|
||||||
ui->variablesTree->clear();
|
ui->variablesTree->clear();
|
||||||
QTreeWidgetItem *userVariables =new QTreeWidgetItem(QStringList(tr("User variables")),DataBrowserTree::Category);
|
QTreeWidgetItem *reportVariables = new QTreeWidgetItem(QStringList(tr("Report variables")),DataBrowserTree::Category);
|
||||||
userVariables->setIcon(0,QIcon(":/report/images/folder"));
|
reportVariables->setIcon(0,QIcon(":/report/images/folder"));
|
||||||
QTreeWidgetItem *systemVariables =new QTreeWidgetItem(QStringList(tr("System variables")),DataBrowserTree::Category);
|
QTreeWidgetItem *systemVariables =new QTreeWidgetItem(QStringList(tr("System variables")),DataBrowserTree::Category);
|
||||||
systemVariables->setIcon(0,QIcon(":/report/images/folder"));
|
systemVariables->setIcon(0,QIcon(":/report/images/folder"));
|
||||||
ui->variablesTree->addTopLevelItem(userVariables);
|
QTreeWidgetItem *externalVariables = new QTreeWidgetItem(QStringList(tr("External variables")),DataBrowserTree::Category);
|
||||||
|
externalVariables->setIcon(0,QIcon(":/report/images/folder"));
|
||||||
|
ui->variablesTree->addTopLevelItem(reportVariables);
|
||||||
ui->variablesTree->addTopLevelItem(systemVariables);
|
ui->variablesTree->addTopLevelItem(systemVariables);
|
||||||
|
ui->variablesTree->addTopLevelItem(externalVariables);
|
||||||
|
|
||||||
foreach(QString variableName,m_report->dataManager()->variableNames()){
|
foreach(QString variableName,m_report->dataManager()->variableNames()){
|
||||||
QStringList values;
|
QStringList values;
|
||||||
@ -227,12 +230,24 @@ void DataBrowser::updateVariablesTree()
|
|||||||
if (m_report->dataManager()->variableIsSystem(variableName)){
|
if (m_report->dataManager()->variableIsSystem(variableName)){
|
||||||
systemVariables->addChild(item);
|
systemVariables->addChild(item);
|
||||||
} else {
|
} else {
|
||||||
userVariables->addChild(item);
|
reportVariables->addChild(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->variablesTree->expandItem(userVariables);
|
foreach(QString variableName,m_report->dataManager()->namesOfUserVariables()){
|
||||||
|
if (!m_report->dataManager()->variableNames().contains(variableName)){
|
||||||
|
QStringList values;
|
||||||
|
values<<variableName+" ["+m_report->dataManager()->variable(variableName).toString()+"]"
|
||||||
|
<<variableName;
|
||||||
|
QTreeWidgetItem *item=new QTreeWidgetItem(values,DataBrowserTree::ExternalVariable);
|
||||||
|
item->setIcon(0,QIcon(":/databrowser/images/value"));
|
||||||
|
externalVariables->addChild(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->variablesTree->expandItem(reportVariables);
|
||||||
ui->variablesTree->expandItem(systemVariables);
|
ui->variablesTree->expandItem(systemVariables);
|
||||||
|
ui->variablesTree->expandItem(externalVariables);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataBrowser::closeAllDataWindows()
|
void DataBrowser::closeAllDataWindows()
|
||||||
@ -333,7 +348,11 @@ QString DataBrowser::getConnectionName()
|
|||||||
|
|
||||||
QString DataBrowser::getVariable()
|
QString DataBrowser::getVariable()
|
||||||
{
|
{
|
||||||
if(ui->variablesTree->currentItem()&&ui->variablesTree->currentItem()->type() == DataBrowserTree::Variable){
|
if(
|
||||||
|
ui->variablesTree->currentItem() &&
|
||||||
|
(ui->variablesTree->currentItem()->type() == DataBrowserTree::Variable ||
|
||||||
|
ui->variablesTree->currentItem()->type() == DataBrowserTree::ExternalVariable)
|
||||||
|
){
|
||||||
return ui->variablesTree->currentItem()->text(1);
|
return ui->variablesTree->currentItem()->text(1);
|
||||||
}
|
}
|
||||||
return QString();
|
return QString();
|
||||||
@ -369,7 +388,7 @@ void DataBrowser::slotDeleteDatasource()
|
|||||||
tr("Do you really want to delete \"%1\" datasource ?").arg(datasourceName),
|
tr("Do you really want to delete \"%1\" datasource ?").arg(datasourceName),
|
||||||
QMessageBox::Ok|QMessageBox::No,
|
QMessageBox::Ok|QMessageBox::No,
|
||||||
QMessageBox::No
|
QMessageBox::No
|
||||||
)==QMessageBox::Ok
|
) == QMessageBox::Ok
|
||||||
){
|
){
|
||||||
removeDatasource(datasourceName);
|
removeDatasource(datasourceName);
|
||||||
}
|
}
|
||||||
@ -390,6 +409,7 @@ void DataBrowser::slotClear()
|
|||||||
ui->dataTree->clear();
|
ui->dataTree->clear();
|
||||||
foreach(QDockWidget* window,m_dataWindows.values()) window->close();
|
foreach(QDockWidget* window,m_dataWindows.values()) window->close();
|
||||||
updateDataTree();
|
updateDataTree();
|
||||||
|
updateVariablesTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataBrowser::initConnections()
|
void DataBrowser::initConnections()
|
||||||
@ -696,16 +716,24 @@ void DataBrowser::on_deleteVariable_clicked()
|
|||||||
void DataBrowser::on_variablesTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
|
void DataBrowser::on_variablesTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
|
||||||
{
|
{
|
||||||
Q_UNUSED(previous)
|
Q_UNUSED(previous)
|
||||||
|
|
||||||
if (current){
|
if (current){
|
||||||
if (m_report->dataManager()->containsVariable(current->text(1))&&
|
if (m_report->dataManager()->containsVariable(current->text(1))){
|
||||||
!m_report->dataManager()->variableIsSystem(current->text(1))
|
if (m_report->dataManager()->variableType(current->text(1)) == VarDesc::Report){
|
||||||
){
|
ui->editVariable->setEnabled(true);
|
||||||
ui->editVariable->setEnabled(true);
|
ui->deleteVariable->setEnabled(true);
|
||||||
ui->deleteVariable->setEnabled(true);
|
} else {
|
||||||
|
ui->editVariable->setEnabled(false);
|
||||||
|
ui->deleteVariable->setEnabled(false);
|
||||||
|
}
|
||||||
|
if (m_report->dataManager()->variableType(current->text(1)) == VarDesc::User){
|
||||||
|
ui->varToReport->setEnabled(true);
|
||||||
|
} else {
|
||||||
|
ui->varToReport->setEnabled(false);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ui->editVariable->setEnabled(false);
|
ui->editVariable->setEnabled(false);
|
||||||
ui->deleteVariable->setEnabled(false);
|
ui->deleteVariable->setEnabled(false);
|
||||||
|
ui->varToReport->setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -717,8 +745,47 @@ void DataBrowser::on_errorMessage_clicked()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DataBrowser::on_varToReport_clicked()
|
||||||
|
{
|
||||||
|
QString varName = getVariable();
|
||||||
|
if (!varName.isEmpty()){
|
||||||
|
m_report->dataManager()->addVariable(varName,m_report->dataManager()->variable(varName), VarDesc::Report);
|
||||||
|
ui->varToReport->setEnabled(false);
|
||||||
|
updateVariablesTree();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataBrowser::on_variablesTree_itemDoubleClicked(QTreeWidgetItem *item, int )
|
||||||
|
{
|
||||||
|
if (item){
|
||||||
|
QString varName = item->text(1);
|
||||||
|
if (
|
||||||
|
!varName.isEmpty() &&
|
||||||
|
(m_report->dataManager()->variableType(varName) == VarDesc::Report)
|
||||||
|
){
|
||||||
|
LRVariableDialog dialog(this);
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
dialog.setWindowModality(Qt::WindowModal);
|
||||||
|
#else
|
||||||
|
dialog.setWindowModality(Qt::ApplicationModal);
|
||||||
|
#endif
|
||||||
|
dialog.setVariableContainer(m_report->dataManager());
|
||||||
|
dialog.setVariableName(varName);
|
||||||
|
connect(&dialog,SIGNAL(signalVariableAccepted(QString)),this,SLOT(slotVariableEditorAccept(QString)));
|
||||||
|
dialog.exec();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace LimeReport
|
} // namespace LimeReport
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,6 +83,9 @@ private slots:
|
|||||||
void on_addVariable_clicked();
|
void on_addVariable_clicked();
|
||||||
void on_variablesTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
void on_variablesTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||||
void on_errorMessage_clicked();
|
void on_errorMessage_clicked();
|
||||||
|
void on_varToReport_clicked();
|
||||||
|
void on_variablesTree_itemDoubleClicked(QTreeWidgetItem *item, int);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString getDatasourceName();
|
QString getDatasourceName();
|
||||||
QString getConnectionName();
|
QString getConnectionName();
|
||||||
|
@ -43,5 +43,6 @@
|
|||||||
<file alias="/images/value_add">images/value_add2.png</file>
|
<file alias="/images/value_add">images/value_add2.png</file>
|
||||||
<file alias="/images/value_edit">images/value_edit2.png</file>
|
<file alias="/images/value_edit">images/value_edit2.png</file>
|
||||||
<file alias="/images/value">images/value1.png</file>
|
<file alias="/images/value">images/value1.png</file>
|
||||||
|
<file alias="/images/varToReport">images/varToReport.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
<enum>QTabWidget::South</enum>
|
<enum>QTabWidget::South</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab">
|
<widget class="QWidget" name="tab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@ -429,6 +429,26 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="varToReport">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Grab variable</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="lrdatabrowser.qrc">
|
||||||
|
<normaloff>:/databrowser/images/varToReport</normaloff>:/databrowser/images/varToReport</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="autoRaise">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer_3">
|
<spacer name="horizontalSpacer_3">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -39,7 +39,7 @@ class DataBrowserTree : public QTreeWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum NodeType{Connection,Table,Row,Category,Variable};
|
enum NodeType{Connection, Table, Row, Category, Variable, ExternalVariable};
|
||||||
explicit DataBrowserTree(QWidget *parent = 0);
|
explicit DataBrowserTree(QWidget *parent = 0);
|
||||||
protected:
|
protected:
|
||||||
QMimeData* mimeData(const QList<QTreeWidgetItem *> items) const;
|
QMimeData* mimeData(const QList<QTreeWidgetItem *> items) const;
|
||||||
|
@ -80,10 +80,10 @@ void LRVariableDialog::accept()
|
|||||||
m_variablesContainer->changeVariable(m_oldVariableName,value());
|
m_variablesContainer->changeVariable(m_oldVariableName,value());
|
||||||
} else {
|
} else {
|
||||||
m_variablesContainer->deleteVariable(m_oldVariableName);
|
m_variablesContainer->deleteVariable(m_oldVariableName);
|
||||||
m_variablesContainer->addVariable(ui->leName->text(),value());
|
m_variablesContainer->addVariable(ui->leName->text(),value(), LimeReport::VarDesc::Report);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_variablesContainer->addVariable(ui->leName->text(),value());
|
m_variablesContainer->addVariable(ui->leName->text(),value(), LimeReport::VarDesc::Report);
|
||||||
}
|
}
|
||||||
emit signalVariableAccepted(ui->leName->text());
|
emit signalVariableAccepted(ui->leName->text());
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
|
@ -563,10 +563,10 @@ bool MasterDetailProxyModel::filterAcceptsRow(int source_row, const QModelIndex
|
|||||||
int MasterDetailProxyModel::fieldIndexByName(QString fieldName) const
|
int MasterDetailProxyModel::fieldIndexByName(QString fieldName) const
|
||||||
{
|
{
|
||||||
for(int i=0;i<sourceModel()->columnCount();++i){
|
for(int i=0;i<sourceModel()->columnCount();++i){
|
||||||
QString fieldName = sourceModel()->headerData(i,Qt::Horizontal,Qt::UserRole).isValid()?
|
QString sourceFieldName = sourceModel()->headerData(i,Qt::Horizontal,Qt::UserRole).isValid()?
|
||||||
sourceModel()->headerData(i,Qt::Horizontal,Qt::UserRole).toString():
|
sourceModel()->headerData(i,Qt::Horizontal,Qt::UserRole).toString():
|
||||||
sourceModel()->headerData(i,Qt::Horizontal).toString();
|
sourceModel()->headerData(i,Qt::Horizontal).toString();
|
||||||
if (fieldName.compare(fieldName,Qt::CaseInsensitive)==0){
|
if (sourceFieldName.compare(fieldName,Qt::CaseInsensitive)==0){
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -322,6 +322,10 @@ QSharedPointer<QAbstractItemModel>DataSourceManager::previewSQL(const QString &c
|
|||||||
}
|
}
|
||||||
|
|
||||||
query.exec();
|
query.exec();
|
||||||
|
while (query.next()){
|
||||||
|
qDebug()<<query.value(0);
|
||||||
|
}
|
||||||
|
|
||||||
model->setQuery(query);
|
model->setQuery(query);
|
||||||
m_lastError = model->lastError().text();
|
m_lastError = model->lastError().text();
|
||||||
if (model->query().isActive())
|
if (model->query().isActive())
|
||||||
@ -705,6 +709,11 @@ bool DataSourceManager::connectConnection(ConnectionDesc *connectionDesc)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DataSourceManager::clearReportVariables()
|
||||||
|
{
|
||||||
|
m_reportVariables.clearUserVariables();
|
||||||
|
}
|
||||||
|
|
||||||
void DataSourceManager::connectAutoConnections()
|
void DataSourceManager::connectAutoConnections()
|
||||||
{
|
{
|
||||||
foreach(ConnectionDesc* conn,m_connections){
|
foreach(ConnectionDesc* conn,m_connections){
|
||||||
@ -918,7 +927,7 @@ int DataSourceManager::elementsCount(const QString &collectionName)
|
|||||||
return m_proxies.count();
|
return m_proxies.count();
|
||||||
}
|
}
|
||||||
if (collectionName=="variables"){
|
if (collectionName=="variables"){
|
||||||
return m_varHolder.userVariablesCount();
|
return m_reportVariables.userVariablesCount();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -938,7 +947,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_varHolder.userVariableAt(index);
|
return m_reportVariables.userVariableAt(index);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -970,8 +979,8 @@ void DataSourceManager::collectionLoadFinished(const QString &collectionName)
|
|||||||
|
|
||||||
if(collectionName.compare("variables",Qt::CaseInsensitive)==0){
|
if(collectionName.compare("variables",Qt::CaseInsensitive)==0){
|
||||||
foreach (VarDesc* item, m_tempVars) {
|
foreach (VarDesc* item, m_tempVars) {
|
||||||
if (!m_varHolder.containsVariable(item->name())){
|
if (!m_reportVariables.containsVariable(item->name())){
|
||||||
m_varHolder.addVariable(item->name(),item->value(),VarDesc::User,FirstPass);
|
m_reportVariables.addVariable(item->name(),item->value(),VarDesc::Report,FirstPass);
|
||||||
}
|
}
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
@ -984,15 +993,20 @@ void DataSourceManager::collectionLoadFinished(const QString &collectionName)
|
|||||||
|
|
||||||
void DataSourceManager::addVariable(const QString &name, const QVariant &value, VarDesc::VarType type, RenderPass pass)
|
void DataSourceManager::addVariable(const QString &name, const QVariant &value, VarDesc::VarType type, RenderPass pass)
|
||||||
{
|
{
|
||||||
m_varHolder.addVariable(name,value,type,pass);
|
if (type == VarDesc::User){
|
||||||
|
m_userVariables.addVariable(name, value, type, pass);
|
||||||
|
} else {
|
||||||
|
m_reportVariables.addVariable(name,value,type,pass);
|
||||||
|
}
|
||||||
if (designTime())
|
if (designTime())
|
||||||
emit datasourcesChanged();
|
emit datasourcesChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataSourceManager::deleteVariable(const QString& name)
|
void DataSourceManager::deleteVariable(const QString& name)
|
||||||
{
|
{
|
||||||
if (m_varHolder.containsVariable(name)&&m_varHolder.variableType(name)==VarDesc::User){
|
m_userVariables.deleteVariable(name);
|
||||||
m_varHolder.deleteVariable(name);
|
if (m_reportVariables.containsVariable(name)&&m_reportVariables.variableType(name)==VarDesc::Report){
|
||||||
|
m_reportVariables.deleteVariable(name);
|
||||||
if (designTime())
|
if (designTime())
|
||||||
emit datasourcesChanged();
|
emit datasourcesChanged();
|
||||||
}
|
}
|
||||||
@ -1000,7 +1014,12 @@ void DataSourceManager::deleteVariable(const QString& name)
|
|||||||
|
|
||||||
void DataSourceManager::changeVariable(const QString& name,const QVariant& value)
|
void DataSourceManager::changeVariable(const QString& name,const QVariant& value)
|
||||||
{
|
{
|
||||||
m_varHolder.changeVariable(name,value);
|
if (m_userVariables.containsVariable(name)){
|
||||||
|
m_userVariables.changeVariable(name,value);
|
||||||
|
}
|
||||||
|
if (m_reportVariables.containsVariable(name)){
|
||||||
|
m_reportVariables.changeVariable(name,value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataSourceManager::setSystemVariable(const QString &name, const QVariant &value, RenderPass pass)
|
void DataSourceManager::setSystemVariable(const QString &name, const QVariant &value, RenderPass pass)
|
||||||
@ -1079,8 +1098,9 @@ void DataSourceManager::clear(ClearMethod method)
|
|||||||
m_queries.clear();
|
m_queries.clear();
|
||||||
m_subqueries.clear();
|
m_subqueries.clear();
|
||||||
m_proxies.clear();
|
m_proxies.clear();
|
||||||
|
// if (method == All)
|
||||||
clearUserVariables();
|
// clearUserVariables();
|
||||||
|
clearReportVariables();
|
||||||
|
|
||||||
emit cleared();
|
emit cleared();
|
||||||
}
|
}
|
||||||
@ -1161,12 +1181,14 @@ bool DataSourceManager::containsField(const QString &fieldName)
|
|||||||
|
|
||||||
bool DataSourceManager::containsVariable(const QString& variableName)
|
bool DataSourceManager::containsVariable(const QString& variableName)
|
||||||
{
|
{
|
||||||
return m_varHolder.containsVariable(variableName);
|
if (m_userVariables.containsVariable(variableName)) return true;
|
||||||
|
return m_reportVariables.containsVariable(variableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataSourceManager::clearUserVariables()
|
void DataSourceManager::clearUserVariables()
|
||||||
{
|
{
|
||||||
m_varHolder.clearUserVariables();
|
m_userVariables.clearUserVariables();
|
||||||
|
m_reportVariables.clearUserVariables();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant DataSourceManager::fieldData(const QString &fieldName)
|
QVariant DataSourceManager::fieldData(const QString &fieldName)
|
||||||
@ -1180,28 +1202,38 @@ QVariant DataSourceManager::fieldData(const QString &fieldName)
|
|||||||
|
|
||||||
QVariant DataSourceManager::variable(const QString &variableName)
|
QVariant DataSourceManager::variable(const QString &variableName)
|
||||||
{
|
{
|
||||||
return m_varHolder.variable(variableName);
|
if (m_userVariables.containsVariable(variableName))
|
||||||
|
return m_userVariables.variable(variableName);
|
||||||
|
return m_reportVariables.variable(variableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderPass DataSourceManager::variablePass(const QString &name)
|
RenderPass DataSourceManager::variablePass(const QString &name)
|
||||||
{
|
{
|
||||||
|
|
||||||
return (m_varHolder.variablePass(name)==FirstPass)?FirstPass:SecondPass;
|
return (m_reportVariables.variablePass(name)==FirstPass)?FirstPass:SecondPass;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DataSourceManager::variableIsSystem(const QString &name)
|
bool DataSourceManager::variableIsSystem(const QString &name)
|
||||||
{
|
{
|
||||||
return (m_varHolder.variableType(name)==VarDesc::System);
|
if (m_reportVariables.containsVariable(name))
|
||||||
|
return (m_reportVariables.variableType(name)==VarDesc::System);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList DataSourceManager::variableNames()
|
QStringList DataSourceManager::variableNames()
|
||||||
{
|
{
|
||||||
return m_varHolder.variableNames();
|
return m_reportVariables.variableNames();
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList DataSourceManager::namesOfUserVariables(){
|
||||||
|
return m_userVariables.variableNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
VarDesc::VarType DataSourceManager::variableType(const QString &name)
|
VarDesc::VarType DataSourceManager::variableType(const QString &name)
|
||||||
{
|
{
|
||||||
return m_varHolder.variableType(name);
|
if (m_reportVariables.containsVariable(name))
|
||||||
|
return m_reportVariables.variableType(name);
|
||||||
|
return VarDesc::User;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataSourceManager::setAllDatasourcesToFirst()
|
void DataSourceManager::setAllDatasourcesToFirst()
|
||||||
|
@ -121,9 +121,12 @@ public:
|
|||||||
void deleteVariable(const QString& name);
|
void deleteVariable(const QString& name);
|
||||||
bool containsVariable(const QString& variableName);
|
bool containsVariable(const QString& variableName);
|
||||||
void clearUserVariables();
|
void clearUserVariables();
|
||||||
|
void addVariable(const QString& name, const QVariant& value, VarDesc::VarType type=VarDesc::User, RenderPass pass=FirstPass);
|
||||||
|
void changeVariable(const QString& name,const QVariant& value);
|
||||||
QVariant variable(const QString& variableName);
|
QVariant variable(const QString& variableName);
|
||||||
RenderPass variablePass(const QString& name);
|
RenderPass variablePass(const QString& name);
|
||||||
QStringList variableNames();
|
QStringList variableNames();
|
||||||
|
QStringList namesOfUserVariables();
|
||||||
VarDesc::VarType variableType(const QString& name);
|
VarDesc::VarType variableType(const QString& name);
|
||||||
bool variableIsSystem(const QString& name);
|
bool variableIsSystem(const QString& name);
|
||||||
QString queryText(const QString& dataSourceName);
|
QString queryText(const QString& dataSourceName);
|
||||||
@ -198,7 +201,7 @@ protected:
|
|||||||
void putSubQueryDesc(SubQueryDesc *subQueryDesc);
|
void putSubQueryDesc(SubQueryDesc *subQueryDesc);
|
||||||
void putProxyDesc(ProxyDesc *proxyDesc);
|
void putProxyDesc(ProxyDesc *proxyDesc);
|
||||||
bool connectConnection(ConnectionDesc* connectionDesc);
|
bool connectConnection(ConnectionDesc* connectionDesc);
|
||||||
|
void clearReportVariables();
|
||||||
QList<QString> childDatasources(const QString& datasourceName);
|
QList<QString> childDatasources(const QString& datasourceName);
|
||||||
void invalidateChildren(const QString& parentDatasourceName);
|
void invalidateChildren(const QString& parentDatasourceName);
|
||||||
//ICollectionContainer
|
//ICollectionContainer
|
||||||
@ -207,8 +210,7 @@ protected:
|
|||||||
virtual QObject *elementAt(const QString& collectionName,int index);
|
virtual QObject *elementAt(const QString& collectionName,int index);
|
||||||
virtual void collectionLoadFinished(const QString& collectionName);
|
virtual void collectionLoadFinished(const QString& collectionName);
|
||||||
|
|
||||||
void addVariable(const QString& name, const QVariant& value, VarDesc::VarType type=VarDesc::User, RenderPass pass=FirstPass);
|
|
||||||
void changeVariable(const QString& name,const QVariant& value);
|
|
||||||
void setSystemVariable(const QString& name, const QVariant& value, RenderPass pass);
|
void setSystemVariable(const QString& name, const QVariant& value, RenderPass pass);
|
||||||
void setLastError(const QString& value);
|
void setLastError(const QString& value);
|
||||||
void invalidateLinkedDatasources(QString datasourceName);
|
void invalidateLinkedDatasources(QString datasourceName);
|
||||||
@ -227,7 +229,8 @@ private:
|
|||||||
|
|
||||||
QMultiMap<QString,GroupFunction*> m_groupFunctions;
|
QMultiMap<QString,GroupFunction*> m_groupFunctions;
|
||||||
GroupFunctionFactory m_groupFunctionFactory;
|
GroupFunctionFactory m_groupFunctionFactory;
|
||||||
AVariablesHolder m_varHolder;
|
VariablesHolder m_reportVariables;
|
||||||
|
VariablesHolder m_userVariables;
|
||||||
DataSourcesMap m_datasources;
|
DataSourcesMap m_datasources;
|
||||||
DataSourceModel m_datasourcesModel;
|
DataSourceModel m_datasourcesModel;
|
||||||
QString m_lastError;
|
QString m_lastError;
|
||||||
|
@ -147,8 +147,8 @@ void ReportRender::renameChildItems(BaseDesignIntf *item){
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReportRender::ReportRender(QObject *parent)
|
ReportRender::ReportRender(QObject *parent)
|
||||||
:QObject(parent), m_renderPageItem(0), m_pageCount(0), m_currentColumn(0),
|
:QObject(parent), m_renderPageItem(0), m_pageCount(0),
|
||||||
m_lastDataBand(0), m_lastRenderedFooter(0)
|
m_lastDataBand(0), m_lastRenderedFooter(0), m_currentColumn(0)
|
||||||
{
|
{
|
||||||
initColumns();
|
initColumns();
|
||||||
}
|
}
|
||||||
|
@ -34,12 +34,12 @@
|
|||||||
|
|
||||||
namespace LimeReport{
|
namespace LimeReport{
|
||||||
|
|
||||||
AVariablesHolder::AVariablesHolder(QObject *parent) :
|
VariablesHolder::VariablesHolder(QObject *parent) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
AVariablesHolder::~AVariablesHolder()
|
VariablesHolder::~VariablesHolder()
|
||||||
{
|
{
|
||||||
QMap<QString,VarDesc*>::iterator it = m_varNames.begin();
|
QMap<QString,VarDesc*>::iterator it = m_varNames.begin();
|
||||||
while(it!=m_varNames.end()){
|
while(it!=m_varNames.end()){
|
||||||
@ -50,7 +50,7 @@ AVariablesHolder::~AVariablesHolder()
|
|||||||
m_userVariables.clear();
|
m_userVariables.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AVariablesHolder::addVariable(const QString& name, const QVariant& value, VarDesc::VarType type, RenderPass pass)
|
void VariablesHolder::addVariable(const QString& name, const QVariant& value, VarDesc::VarType type, RenderPass pass)
|
||||||
{
|
{
|
||||||
if (!m_varNames.contains(name)){
|
if (!m_varNames.contains(name)){
|
||||||
VarDesc* varValue = new VarDesc;
|
VarDesc* varValue = new VarDesc;
|
||||||
@ -66,21 +66,21 @@ void AVariablesHolder::addVariable(const QString& name, const QVariant& value, V
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant AVariablesHolder::variable(const QString &name)
|
QVariant VariablesHolder::variable(const QString &name)
|
||||||
{
|
{
|
||||||
if (m_varNames.contains(name))
|
if (m_varNames.contains(name))
|
||||||
return m_varNames.value(name)->value();
|
return m_varNames.value(name)->value();
|
||||||
else return QVariant();
|
else return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
VarDesc::VarType AVariablesHolder::variableType(const QString &name)
|
VarDesc::VarType VariablesHolder::variableType(const QString &name)
|
||||||
{
|
{
|
||||||
if (m_varNames.contains(name))
|
if (m_varNames.contains(name))
|
||||||
return m_varNames.value(name)->varType();
|
return m_varNames.value(name)->varType();
|
||||||
else throw ReportError(tr("variable with name ")+name+tr(" does not exists !!"));
|
else throw ReportError(tr("variable with name ")+name+tr(" does not exists !!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AVariablesHolder::deleteVariable(const QString &name)
|
void VariablesHolder::deleteVariable(const QString &name)
|
||||||
{
|
{
|
||||||
if (m_varNames.contains(name)) {
|
if (m_varNames.contains(name)) {
|
||||||
m_userVariables.removeOne(m_varNames.value(name));
|
m_userVariables.removeOne(m_varNames.value(name));
|
||||||
@ -89,7 +89,7 @@ void AVariablesHolder::deleteVariable(const QString &name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AVariablesHolder::changeVariable(const QString &name, const QVariant &value)
|
void VariablesHolder::changeVariable(const QString &name, const QVariant &value)
|
||||||
{
|
{
|
||||||
if(m_varNames.contains(name)) {
|
if(m_varNames.contains(name)) {
|
||||||
m_varNames.value(name)->setValue(value);
|
m_varNames.value(name)->setValue(value);
|
||||||
@ -97,11 +97,12 @@ void AVariablesHolder::changeVariable(const QString &name, const QVariant &value
|
|||||||
throw ReportError(tr("variable with name ")+name+tr(" does not exists !!"));
|
throw ReportError(tr("variable with name ")+name+tr(" does not exists !!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AVariablesHolder::clearUserVariables()
|
void VariablesHolder::clearUserVariables()
|
||||||
{
|
{
|
||||||
QMap<QString,VarDesc*>::iterator it = m_varNames.begin();
|
QMap<QString,VarDesc*>::iterator it = m_varNames.begin();
|
||||||
while (it != m_varNames.end()){
|
while (it != m_varNames.end()){
|
||||||
if (it.value()->varType()==VarDesc::User){
|
if (it.value()->varType()==VarDesc::User ||
|
||||||
|
it.value()->varType()==VarDesc::Report){
|
||||||
m_userVariables.removeAll(it.value());
|
m_userVariables.removeAll(it.value());
|
||||||
delete it.value();
|
delete it.value();
|
||||||
it = m_varNames.erase(it);
|
it = m_varNames.erase(it);
|
||||||
@ -113,22 +114,22 @@ void AVariablesHolder::clearUserVariables()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AVariablesHolder::containsVariable(const QString &name)
|
bool VariablesHolder::containsVariable(const QString &name)
|
||||||
{
|
{
|
||||||
return m_varNames.contains(name);
|
return m_varNames.contains(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int AVariablesHolder::userVariablesCount()
|
int VariablesHolder::userVariablesCount()
|
||||||
{
|
{
|
||||||
return m_userVariables.count();
|
return m_userVariables.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
VarDesc *AVariablesHolder::userVariableAt(int index)
|
VarDesc *VariablesHolder::userVariableAt(int index)
|
||||||
{
|
{
|
||||||
return m_userVariables.at(index);
|
return m_userVariables.at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList AVariablesHolder::variableNames()
|
QStringList VariablesHolder::variableNames()
|
||||||
{
|
{
|
||||||
QStringList result;
|
QStringList result;
|
||||||
foreach(QString varName,m_varNames.keys()){
|
foreach(QString varName,m_varNames.keys()){
|
||||||
@ -137,7 +138,7 @@ QStringList AVariablesHolder::variableNames()
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderPass AVariablesHolder::variablePass(const QString &name)
|
RenderPass VariablesHolder::variablePass(const QString &name)
|
||||||
{
|
{
|
||||||
if (m_varNames.contains(name))
|
if (m_varNames.contains(name))
|
||||||
return m_varNames.value(name)->renderPass();
|
return m_varNames.value(name)->renderPass();
|
||||||
|
@ -43,7 +43,7 @@ class VarDesc : public QObject{
|
|||||||
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)
|
||||||
public:
|
public:
|
||||||
enum VarType {System,User};
|
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;}
|
||||||
void setRenderPass(RenderPass value){m_varPass=value;}
|
void setRenderPass(RenderPass value){m_varPass=value;}
|
||||||
@ -74,12 +74,12 @@ public:
|
|||||||
virtual QStringList variableNames()=0;
|
virtual QStringList variableNames()=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AVariablesHolder : public QObject, public IVariablesContainer
|
class VariablesHolder : public QObject, public IVariablesContainer
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit AVariablesHolder(QObject *parent = 0);
|
explicit VariablesHolder(QObject *parent = 0);
|
||||||
~AVariablesHolder();
|
~VariablesHolder();
|
||||||
void addVariable(const QString &name, const QVariant &value, VarDesc::VarType type=VarDesc::User, RenderPass pass=FirstPass);
|
void addVariable(const QString &name, const QVariant &value, VarDesc::VarType type=VarDesc::User, RenderPass pass=FirstPass);
|
||||||
void deleteVariable(const QString &name);
|
void deleteVariable(const QString &name);
|
||||||
void changeVariable(const QString &name, const QVariant &value);
|
void changeVariable(const QString &name, const QVariant &value);
|
||||||
|
Loading…
Reference in New Issue
Block a user