mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-23 16:22:58 +03:00
Define code style and format all source file using clang-format-14
except those placed in 3rdparty directories.
This commit is contained in:
parent
c5b9ac265d
commit
0fca7169d3
41
.clang-format
Normal file
41
.clang-format
Normal file
@ -0,0 +1,41 @@
|
||||
---
|
||||
BasedOnStyle: WebKit
|
||||
Language: Cpp
|
||||
AlignAfterOpenBracket: Align
|
||||
AllowShortEnumsOnASingleLine: false
|
||||
BreakInheritanceList: AfterColon
|
||||
BreakConstructorInitializers: AfterColon
|
||||
SpaceBeforeCtorInitializerColon: false
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
AllowAllConstructorInitializersOnNextLine: false
|
||||
SpaceBeforeInheritanceColon: false
|
||||
PointerAlignment: Left
|
||||
ReflowComments: true
|
||||
FixNamespaceComments: true
|
||||
SortIncludes: true
|
||||
SortUsingDeclarations: true
|
||||
IncludeBlocks: Regroup
|
||||
# regular expressions are matched against the filename of an include (including the <> or “”) in order:
|
||||
# topmost: main header file (the one that has the same name as .cpp-file) and ui_XXX.h, if exists
|
||||
# second group: local header files (i.e. "something.h")
|
||||
# third group: external header files (i.e. <smth/other.h>)
|
||||
# fourth group: Qt toolkit headers (actually, anything that starts with a 'Q')
|
||||
# last group: all other external header files
|
||||
# headers in all groups are sorted by name
|
||||
IncludeCategories:
|
||||
- Regex: '"ui_.*'
|
||||
Priority: 0
|
||||
- Regex: '^".*'
|
||||
Priority: 1
|
||||
- Regex: '^<Qt.*'
|
||||
Priority: 3
|
||||
- Regex: '^<.*/.*\.h>'
|
||||
Priority: 2
|
||||
- Regex: '^<Q.*'
|
||||
Priority: 3
|
||||
- Regex: '^<.*'
|
||||
Priority: 4
|
||||
ColumnLimit: 100
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
||||
MaxEmptyLinesToKeep: 1
|
13
.github/workflows/cmake.yml
vendored
13
.github/workflows/cmake.yml
vendored
@ -11,9 +11,19 @@ env:
|
||||
BUILD_TYPE: Release
|
||||
|
||||
jobs:
|
||||
check-code-style:
|
||||
runs-on: ubuntu-22.04
|
||||
name: "Check code style"
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Perform check
|
||||
run: ./tools/check_code_style.sh
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-${{ matrix.ubuntu_version }}
|
||||
name: Ubuntu-${{ matrix.ubuntu_version }}-Qt-${{ matrix.qt_version }}-static-${{ matrix.static }}
|
||||
needs: check-code-style
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@ -55,6 +65,7 @@ jobs:
|
||||
MSVC:
|
||||
name: windows-${{ matrix.win_version }}-Qt-${{ matrix.qt_version }}-static-${{ matrix.static }}
|
||||
runs-on: windows-${{ matrix.win_version }}
|
||||
needs: check-code-style
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@ -96,6 +107,7 @@ jobs:
|
||||
MinGW-w64:
|
||||
runs-on: windows-2022
|
||||
name: msys2-${{ matrix.msystem }}-Qt-${{ matrix.qt_version }}-static-${{ matrix.static }}
|
||||
needs: check-code-style
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@ -165,6 +177,7 @@ jobs:
|
||||
macos:
|
||||
runs-on: macos-${{ matrix.macos_version }}
|
||||
name: macos-${{ matrix.macos_version }}-Qt-${{ matrix.qt_version }}-static-${{ matrix.static }}
|
||||
needs: check-code-style
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
|
@ -1,16 +1,18 @@
|
||||
#include "../limereport/version.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QUuid>
|
||||
#include <LimeReport>
|
||||
#include <iostream>
|
||||
#include <QCommandLineParser>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QCommandLineParser>
|
||||
#include "../limereport/version.h"
|
||||
#include <QUuid>
|
||||
|
||||
#include <LimeReport>
|
||||
#include <iostream>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
@ -23,15 +25,20 @@ int main(int argc, char *argv[])
|
||||
QCommandLineParser parser;
|
||||
parser.addHelpOption();
|
||||
parser.addVersionOption();
|
||||
QCommandLineOption sourceOption(QStringList() << "s" << "source",
|
||||
QCommandLineOption sourceOption(
|
||||
QStringList() << "s"
|
||||
<< "source",
|
||||
QCoreApplication::translate("main", "Limereport pattern file name"),
|
||||
QCoreApplication::translate("main", "source"));
|
||||
parser.addOption(sourceOption);
|
||||
QCommandLineOption destinationOption(QStringList() << "d" << "destination",
|
||||
QCommandLineOption destinationOption(QStringList() << "d"
|
||||
<< "destination",
|
||||
QCoreApplication::translate("main", "Output file name"),
|
||||
QCoreApplication::translate("main", "destination"));
|
||||
parser.addOption(destinationOption);
|
||||
QCommandLineOption variablesOption(QStringList() << "p" << "param",
|
||||
QCommandLineOption variablesOption(
|
||||
QStringList() << "p"
|
||||
<< "param",
|
||||
QCoreApplication::translate("main", "Report parameter (can be more than one)"),
|
||||
QCoreApplication::translate("main", "param_name=param_value"));
|
||||
parser.addOption(variablesOption);
|
||||
@ -45,7 +52,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
if (!report.loadFromFile(parser.value(sourceOption))) {
|
||||
std::cerr<<"Error! Report file \""+parser.value(sourceOption).toStdString()+"\" not found \n";
|
||||
std::cerr << "Error! Report file \"" + parser.value(sourceOption).toStdString()
|
||||
+ "\" not found \n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -28,8 +28,8 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "mainwindow.h"
|
||||
#include <QApplication>
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
@ -29,15 +29,17 @@
|
||||
****************************************************************************/
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QPrinter>
|
||||
#include <QStringListModel>
|
||||
#include <QtSql/QSqlQuery>
|
||||
#include <QtSql/QSqlRecord>
|
||||
#include <LimeReport>
|
||||
|
||||
#include <LRCallbackDS>
|
||||
#include <QDebug>
|
||||
#include <QStringListModel>
|
||||
#include <QPrinter>
|
||||
#include <LimeReport>
|
||||
|
||||
#ifdef BUILD_WITH_EASY_PROFILER
|
||||
#include "easy/profiler.h"
|
||||
@ -49,14 +51,16 @@
|
||||
|
||||
MainWindow::MainWindow(QWidget* parent):
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow), m_progressDialog(0), m_customers(0), m_orders(0)
|
||||
ui(new Ui::MainWindow),
|
||||
m_progressDialog(0),
|
||||
m_customers(0),
|
||||
m_orders(0)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
report = new LimeReport::ReportEngine(this);
|
||||
|
||||
connect(report, SIGNAL(renderStarted()), this, SLOT(renderStarted()));
|
||||
connect(report, SIGNAL(renderPageFinished(int)),
|
||||
this, SLOT(renderPageFinished(int)));
|
||||
connect(report, SIGNAL(renderPageFinished(int)), this, SLOT(renderPageFinished(int)));
|
||||
connect(report, SIGNAL(renderFinished()), this, SLOT(renderFinished()));
|
||||
|
||||
QFile dbFile(QApplication::applicationDirPath() + "/demo_reports/northwind.db");
|
||||
@ -80,34 +84,39 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
}
|
||||
}
|
||||
|
||||
LimeReport::ICallbackDatasource * callbackDatasource = report->dataManager()->createCallbackDatasource("master");
|
||||
connect(callbackDatasource, SIGNAL(getCallbackData(LimeReport::CallbackInfo,QVariant&)),
|
||||
this, SLOT(slotGetCallbackData(LimeReport::CallbackInfo,QVariant&)));
|
||||
connect(callbackDatasource, SIGNAL(changePos(const LimeReport::CallbackInfo::ChangePosType&,bool&)),
|
||||
this, SLOT(slotChangePos(const LimeReport::CallbackInfo::ChangePosType&,bool&)));
|
||||
LimeReport::ICallbackDatasource* callbackDatasource
|
||||
= report->dataManager()->createCallbackDatasource("master");
|
||||
connect(callbackDatasource, SIGNAL(getCallbackData(LimeReport::CallbackInfo, QVariant&)), this,
|
||||
SLOT(slotGetCallbackData(LimeReport::CallbackInfo, QVariant&)));
|
||||
connect(callbackDatasource,
|
||||
SIGNAL(changePos(const LimeReport::CallbackInfo::ChangePosType&, bool&)), this,
|
||||
SLOT(slotChangePos(const LimeReport::CallbackInfo::ChangePosType&, bool&)));
|
||||
|
||||
callbackDatasource = report->dataManager()->createCallbackDatasource("detail");
|
||||
connect(callbackDatasource, SIGNAL(getCallbackData(LimeReport::CallbackInfo,QVariant&)),
|
||||
this, SLOT(slotGetCallbackChildData(LimeReport::CallbackInfo,QVariant&)));
|
||||
connect(callbackDatasource, SIGNAL(changePos(const LimeReport::CallbackInfo::ChangePosType&,bool&)),
|
||||
this, SLOT(slotChangeChildPos(const LimeReport::CallbackInfo::ChangePosType&,bool&)));
|
||||
connect(callbackDatasource, SIGNAL(getCallbackData(LimeReport::CallbackInfo, QVariant&)), this,
|
||||
SLOT(slotGetCallbackChildData(LimeReport::CallbackInfo, QVariant&)));
|
||||
connect(callbackDatasource,
|
||||
SIGNAL(changePos(const LimeReport::CallbackInfo::ChangePosType&, bool&)), this,
|
||||
SLOT(slotChangeChildPos(const LimeReport::CallbackInfo::ChangePosType&, bool&)));
|
||||
|
||||
callbackDatasource = report->dataManager()->createCallbackDatasource("oneSlotDS");
|
||||
connect(callbackDatasource, SIGNAL(getCallbackData(LimeReport::CallbackInfo,QVariant&)),
|
||||
this, SLOT(slotOneSlotDS(LimeReport::CallbackInfo,QVariant&)));
|
||||
connect(callbackDatasource, SIGNAL(getCallbackData(LimeReport::CallbackInfo, QVariant&)), this,
|
||||
SLOT(slotOneSlotDS(LimeReport::CallbackInfo, QVariant&)));
|
||||
|
||||
QStringList simpleData;
|
||||
simpleData << "value1" << "value2" << "value3";
|
||||
simpleData << "value1"
|
||||
<< "value2"
|
||||
<< "value3";
|
||||
QStringListModel* stringListModel = new QStringListModel();
|
||||
stringListModel->setStringList(simpleData);
|
||||
|
||||
report->dataManager()->addModel("string_list", stringListModel, true);
|
||||
QStringList strList;
|
||||
strList<<"value1"<<"value2";
|
||||
//QScriptValue value = qScriptValueFromSequence(report->scriptManager()->scriptEngine(),strList);
|
||||
strList << "value1"
|
||||
<< "value2";
|
||||
// QScriptValue value =
|
||||
// qScriptValueFromSequence(report->scriptManager()->scriptEngine(),strList);
|
||||
// report->scriptManager()->scriptEngine()->globalObject().setProperty("test_list",value);
|
||||
|
||||
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
@ -123,7 +132,8 @@ void MainWindow::on_pushButton_clicked()
|
||||
EASY_BLOCK("design report");
|
||||
report->dataManager()->clearUserVariables();
|
||||
if (!ui->leVariableName->text().isEmpty() && !ui->leVariableValue->text().isEmpty()) {
|
||||
report->dataManager()->setReportVariable(ui->leVariableName->text(), ui->leVariableValue->text());
|
||||
report->dataManager()->setReportVariable(ui->leVariableName->text(),
|
||||
ui->leVariableValue->text());
|
||||
}
|
||||
report->setShowProgressDialog(false);
|
||||
report->designReport();
|
||||
@ -135,7 +145,9 @@ void MainWindow::on_pushButton_clicked()
|
||||
|
||||
void MainWindow::on_pushButton_2_clicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this,"Select report file",QApplication::applicationDirPath()+"/demo_reports/","*.lrxml");
|
||||
QString fileName = QFileDialog::getOpenFileName(
|
||||
this, "Select report file", QApplication::applicationDirPath() + "/demo_reports/",
|
||||
"*.lrxml");
|
||||
if (!fileName.isEmpty()) {
|
||||
EASY_PROFILER_ENABLE;
|
||||
EASY_BLOCK("Load file");
|
||||
@ -143,7 +155,8 @@ void MainWindow::on_pushButton_2_clicked()
|
||||
EASY_END_BLOCK;
|
||||
EASY_BLOCK("Set report variable");
|
||||
if (!ui->leVariableName->text().isEmpty() && !ui->leVariableValue->text().isEmpty()) {
|
||||
report->dataManager()->setReportVariable(ui->leVariableName->text(), ui->leVariableValue->text());
|
||||
report->dataManager()->setReportVariable(ui->leVariableName->text(),
|
||||
ui->leVariableValue->text());
|
||||
}
|
||||
EASY_END_BLOCK;
|
||||
#ifdef BUILD_WITH_EASY_PROFILER
|
||||
@ -210,22 +223,28 @@ void MainWindow::prepareData(QSqlQuery* ds, LimeReport::CallbackInfo info, QVari
|
||||
case LimeReport::CallbackInfo::ColumnData:
|
||||
data = ds->value(ds->record().indexOf(info.columnName));
|
||||
break;
|
||||
default: break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::slotGetCallbackData(LimeReport::CallbackInfo info, QVariant& data)
|
||||
{
|
||||
if (!m_customers) return;
|
||||
if (!m_customers)
|
||||
return;
|
||||
prepareData(m_customers, info, data);
|
||||
}
|
||||
|
||||
void MainWindow::slotChangePos(const LimeReport::CallbackInfo::ChangePosType& type, bool& result)
|
||||
{
|
||||
QSqlQuery* ds = m_customers;
|
||||
if (!ds) return;
|
||||
if (type == LimeReport::CallbackInfo::First) {result = ds->first();}
|
||||
else {result = ds->next();}
|
||||
if (!ds)
|
||||
return;
|
||||
if (type == LimeReport::CallbackInfo::First) {
|
||||
result = ds->first();
|
||||
} else {
|
||||
result = ds->next();
|
||||
}
|
||||
if (result) {
|
||||
m_orders->bindValue(":id", m_customers->value(m_customers->record().indexOf("CustomerID")));
|
||||
m_orders->exec();
|
||||
@ -234,22 +253,29 @@ void MainWindow::slotChangePos(const LimeReport::CallbackInfo::ChangePosType &ty
|
||||
|
||||
void MainWindow::slotGetCallbackChildData(LimeReport::CallbackInfo info, QVariant& data)
|
||||
{
|
||||
if (!m_orders) return ;
|
||||
if (!m_orders)
|
||||
return;
|
||||
prepareData(m_orders, info, data);
|
||||
}
|
||||
|
||||
void MainWindow::slotChangeChildPos(const LimeReport::CallbackInfo::ChangePosType &type, bool &result)
|
||||
void MainWindow::slotChangeChildPos(const LimeReport::CallbackInfo::ChangePosType& type,
|
||||
bool& result)
|
||||
{
|
||||
QSqlQuery* ds = m_orders;
|
||||
if (!ds) return;
|
||||
if (type == LimeReport::CallbackInfo::First) result = ds->first();
|
||||
else result = ds->next();
|
||||
if (!ds)
|
||||
return;
|
||||
if (type == LimeReport::CallbackInfo::First)
|
||||
result = ds->first();
|
||||
else
|
||||
result = ds->next();
|
||||
}
|
||||
|
||||
void MainWindow::slotOneSlotDS(LimeReport::CallbackInfo info, QVariant& data)
|
||||
{
|
||||
QStringList columns;
|
||||
columns << "Name" << "Value" << "Image";
|
||||
columns << "Name"
|
||||
<< "Value"
|
||||
<< "Image";
|
||||
switch (info.dataType) {
|
||||
case LimeReport::CallbackInfo::RowCount:
|
||||
data = 4;
|
||||
@ -271,6 +297,7 @@ void MainWindow::slotOneSlotDS(LimeReport::CallbackInfo info, QVariant &data)
|
||||
data = info.columnName + " " + QString::number(info.index);
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -30,18 +30,18 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include "lrreportengine.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QProgressDialog>
|
||||
#include <QtSql/QSqlDatabase>
|
||||
#include <QtSql/QSqlQueryModel>
|
||||
#include "lrreportengine.h"
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
class MainWindow: public QMainWindow {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@ -58,8 +58,10 @@ private slots:
|
||||
void slotGetCallbackChildData(LimeReport::CallbackInfo info, QVariant& data);
|
||||
void slotChangeChildPos(const LimeReport::CallbackInfo::ChangePosType& type, bool& result);
|
||||
void slotOneSlotDS(LimeReport::CallbackInfo info, QVariant& data);
|
||||
|
||||
private:
|
||||
void prepareData(QSqlQuery* ds, LimeReport::CallbackInfo info, QVariant& data);
|
||||
|
||||
private:
|
||||
Ui::MainWindow* ui;
|
||||
LimeReport::ReportEngine* report;
|
||||
@ -73,9 +75,6 @@ private:
|
||||
int m_currentOrderRecord;
|
||||
QSqlQuery* m_customers;
|
||||
QSqlQuery* m_orders;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
|
@ -1,17 +1,16 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include <QSqlDatabase>
|
||||
#include <QDir>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QSqlDatabase>
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
|
||||
#include <QDesktopWidget>
|
||||
#else
|
||||
#include <QScreen>
|
||||
#endif
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
MainWindow::MainWindow(QWidget* parent): QMainWindow(parent), ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@ -22,7 +21,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
m_pageNavigator->setPrefix(tr("Page :"));
|
||||
ui->toolBar->insertWidget(ui->actionZoom_Out, m_scalePercent);
|
||||
ui->toolBar->insertWidget(ui->actionNext_Page, m_pageNavigator);
|
||||
connect(m_scalePercent, SIGNAL(currentIndexChanged(QString)), this, SLOT(scaleComboboxChanged(QString)));
|
||||
connect(m_scalePercent, SIGNAL(currentIndexChanged(QString)), this,
|
||||
SLOT(scaleComboboxChanged(QString)));
|
||||
connect(m_pageNavigator, SIGNAL(valueChanged(int)), this, SLOT(slotPageNavigatorChanged(int)));
|
||||
ui->groupBox_2->layout()->addWidget(m_preview);
|
||||
buildReportsTree(QApplication::applicationDirPath() + "/demo_reports/", ui->treeWidget);
|
||||
@ -33,7 +33,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
connect(ui->actionNext_Page, SIGNAL(triggered()), m_preview, SLOT(nextPage()));
|
||||
connect(ui->actionLast_Page, SIGNAL(triggered()), m_preview, SLOT(lastPage()));
|
||||
connect(m_preview, SIGNAL(scalePercentChanged(int)), this, SLOT(slotScalePercentChanged(int)));
|
||||
//connect(ui->cbScalePercent, SIGNAL(currentIndexChanged(QString)), this, SLOT(scaleComboboxChanged(QString)));
|
||||
// connect(ui->cbScalePercent, SIGNAL(currentIndexChanged(QString)), this,
|
||||
// SLOT(scaleComboboxChanged(QString)));
|
||||
connect(ui->actionFit_Width, SIGNAL(triggered()), m_preview, SLOT(fitWidth()));
|
||||
connect(ui->actionFit_Page, SIGNAL(triggered()), m_preview, SLOT(fitPage()));
|
||||
connect(m_preview, SIGNAL(pagesSet(int)), this, SLOT(slotPagesSet(int)));
|
||||
@ -68,21 +69,17 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
if (ui->treeWidget->topLevelItem(index)->childCount() > 0)
|
||||
++index;
|
||||
else {
|
||||
m_report.loadFromFile(ui->treeWidget->topLevelItem(index)->data(0,Qt::UserRole).toString());
|
||||
m_report.loadFromFile(
|
||||
ui->treeWidget->topLevelItem(index)->data(0, Qt::UserRole).toString());
|
||||
ui->treeWidget->setCurrentItem(ui->treeWidget->topLevelItem(index));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
m_preview->refreshPages();
|
||||
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
MainWindow::~MainWindow() { delete ui; }
|
||||
|
||||
void MainWindow::enableUI(bool value)
|
||||
{
|
||||
@ -127,15 +124,9 @@ void MainWindow::slotPagesSet(int pagesCount)
|
||||
enableUI(true);
|
||||
}
|
||||
|
||||
void MainWindow::slotPageChanged(int page)
|
||||
{
|
||||
m_pageNavigator->setValue(page);
|
||||
}
|
||||
void MainWindow::slotPageChanged(int page) { m_pageNavigator->setValue(page); }
|
||||
|
||||
void MainWindow::slotPageNavigatorChanged(int page)
|
||||
{
|
||||
m_preview->pageNavigatorChanged(page);
|
||||
}
|
||||
void MainWindow::slotPageNavigatorChanged(int page) { m_preview->pageNavigatorChanged(page); }
|
||||
|
||||
void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem* item, int)
|
||||
{
|
||||
@ -166,7 +157,4 @@ void MainWindow::slotDesignReport()
|
||||
m_preview->refreshPages();
|
||||
}
|
||||
|
||||
void MainWindow::slotOneToOne()
|
||||
{
|
||||
m_preview->setScalePercent(100);
|
||||
}
|
||||
void MainWindow::slotOneToOne() { m_preview->setScalePercent(100); }
|
||||
|
@ -1,25 +1,26 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <LimeReport>
|
||||
#include <QTreeWidget>
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
#include <QComboBox>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QMainWindow>
|
||||
#include <QSpinBox>
|
||||
#include <QTreeWidget>
|
||||
|
||||
#include <LimeReport>
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
class MainWindow: public QMainWindow {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget* parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
private:
|
||||
void enableUI(bool value);
|
||||
private slots:
|
||||
@ -32,9 +33,9 @@ private slots:
|
||||
// void on_sbPageNavigator_valueChanged(int arg1);
|
||||
void slotDesignReport();
|
||||
void slotOneToOne();
|
||||
|
||||
private:
|
||||
template< typename T >
|
||||
void buildReportsTree(const QString &path, T* parentItem)
|
||||
template <typename T> void buildReportsTree(const QString& path, T* parentItem)
|
||||
{
|
||||
QDir reportsDir(path);
|
||||
QStringList items = reportsDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
@ -55,6 +56,7 @@ private:
|
||||
}
|
||||
}
|
||||
void initPercentCombobox();
|
||||
|
||||
private:
|
||||
Ui::MainWindow* ui;
|
||||
LimeReport::ReportEngine m_report;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "designersettingmanager.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
DesignerSettingManager::DesignerSettingManager(QObject* parent): QObject(parent)
|
||||
@ -6,10 +7,7 @@ DesignerSettingManager::DesignerSettingManager(QObject *parent) : QObject(parent
|
||||
m_setting = new QSettings("LimeReport", QCoreApplication::applicationName());
|
||||
}
|
||||
|
||||
DesignerSettingManager::~DesignerSettingManager()
|
||||
{
|
||||
delete m_setting;
|
||||
}
|
||||
DesignerSettingManager::~DesignerSettingManager() { delete m_setting; }
|
||||
|
||||
void DesignerSettingManager::getAvailableLanguages(QList<QLocale::Language>* languages)
|
||||
{
|
||||
@ -36,7 +34,8 @@ QLocale::Language DesignerSettingManager::getCurrentDefaultLanguage()
|
||||
|
||||
void DesignerSettingManager::currentDefaultLanguageChanged(QLocale::Language language)
|
||||
{
|
||||
QMessageBox::information(0, tr("Warning") , tr("The language will change after the application is restarted"));
|
||||
QMessageBox::information(0, tr("Warning"),
|
||||
tr("The language will change after the application is restarted"));
|
||||
m_setting->beginGroup("ReportDesigner");
|
||||
m_setting->setValue("DesignerLanguage", (int)language);
|
||||
m_setting->endGroup();
|
||||
|
@ -1,13 +1,12 @@
|
||||
#ifndef DESIGNERSETTINGMANAGER_H
|
||||
#define DESIGNERSETTINGMANAGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QLocale>
|
||||
#include <QApplication>
|
||||
#include <QLocale>
|
||||
#include <QObject>
|
||||
#include <QSettings>
|
||||
|
||||
class DesignerSettingManager : public QObject
|
||||
{
|
||||
class DesignerSettingManager: public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DesignerSettingManager(QObject* parent = 0);
|
||||
@ -16,6 +15,7 @@ public slots:
|
||||
void getAvailableLanguages(QList<QLocale::Language>* languages);
|
||||
QLocale::Language getCurrentDefaultLanguage();
|
||||
void currentDefaultLanguageChanged(QLocale::Language language);
|
||||
|
||||
private:
|
||||
QSettings* m_setting;
|
||||
};
|
||||
|
@ -1,9 +1,11 @@
|
||||
#include <QApplication>
|
||||
#include <LimeReport>
|
||||
#include <QTranslator>
|
||||
#include <QDebug>
|
||||
#include "designersettingmanager.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QTranslator>
|
||||
|
||||
#include <LimeReport>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
@ -23,13 +25,15 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (limeReportTranslator.load("limereport_" + designerTranslation, translationPath)) {
|
||||
static_cast<void>(qtBaseTranslator.load("qtbase_" + designerTranslation, translationPath));
|
||||
static_cast<void>(qtDesignerTranslator.load("designer_"+designerTranslation,translationPath));
|
||||
static_cast<void>(
|
||||
qtDesignerTranslator.load("designer_" + designerTranslation, translationPath));
|
||||
|
||||
a.installTranslator(&qtBaseTranslator);
|
||||
a.installTranslator(&qtDesignerTranslator);
|
||||
a.installTranslator(&limeReportTranslator);
|
||||
|
||||
Qt::LayoutDirection layoutDirection = QLocale(manager.getCurrentDefaultLanguage()).textDirection();
|
||||
Qt::LayoutDirection layoutDirection
|
||||
= QLocale(manager.getCurrentDefaultLanguage()).textDirection();
|
||||
a.setLayoutDirection(layoutDirection);
|
||||
}
|
||||
|
||||
@ -42,8 +46,8 @@ int main(int argc, char *argv[])
|
||||
QObject::connect(&report, SIGNAL(getAvailableDesignerLanguages(QList<QLocale::Language>*)),
|
||||
&manager, SLOT(getAvailableLanguages(QList<QLocale::Language>*)));
|
||||
|
||||
QObject::connect(&report, SIGNAL(getCurrentDefaultDesignerLanguage()),
|
||||
&manager, SLOT(getCurrentDefaultLanguage()));
|
||||
QObject::connect(&report, SIGNAL(getCurrentDefaultDesignerLanguage()), &manager,
|
||||
SLOT(getCurrentDefaultLanguage()));
|
||||
|
||||
QObject::connect(&report, SIGNAL(currentDefaultDesignerLanguageChanged(QLocale::Language)),
|
||||
&manager, SLOT(currentDefaultLanguageChanged(QLocale::Language)));
|
||||
@ -52,4 +56,3 @@ int main(int argc, char *argv[])
|
||||
report.designReport();
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,14 @@
|
||||
#include "lrdesignerplugin.h"
|
||||
|
||||
#include <QRect>
|
||||
#include "lrreportdesignwindow.h"
|
||||
|
||||
ReportDesignerFactoryPlugin::~ReportDesignerFactoryPlugin() {
|
||||
}
|
||||
#include <QRect>
|
||||
|
||||
LimeReport::ReportDesignWindowInterface* ReportDesignerFactoryPlugin::getDesignerWindow(LimeReport::ReportEnginePrivateInterface* report, QWidget* parent, QSettings* settings)
|
||||
ReportDesignerFactoryPlugin::~ReportDesignerFactoryPlugin() { }
|
||||
|
||||
LimeReport::ReportDesignWindowInterface*
|
||||
ReportDesignerFactoryPlugin::getDesignerWindow(LimeReport::ReportEnginePrivateInterface* report,
|
||||
QWidget* parent, QSettings* settings)
|
||||
{
|
||||
return new LimeReport::ReportDesignWindow(report, parent, settings);
|
||||
}
|
||||
@ -14,4 +16,3 @@ LimeReport::ReportDesignWindowInterface* ReportDesignerFactoryPlugin::getDesigne
|
||||
#if QT_VERSION < 0x050000
|
||||
Q_EXPORT_PLUGIN2(LimeReportPluginInterface, ReportDesignerFactoryPlugin)
|
||||
#endif
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define LRDESIGNERPLUGIN_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
#include <lrdesignerplugininterface.h>
|
||||
|
||||
class ReportDesignerFactoryPlugin: public QObject, public LimeReportDesignerPluginInterface {
|
||||
@ -13,7 +14,9 @@ class ReportDesignerFactoryPlugin : public QObject, public LimeReportDesignerPlu
|
||||
|
||||
public:
|
||||
~ReportDesignerFactoryPlugin();
|
||||
LimeReport::ReportDesignWindowInterface* getDesignerWindow(LimeReport::ReportEnginePrivateInterface* report, QWidget* parent, QSettings* settings);
|
||||
LimeReport::ReportDesignWindowInterface*
|
||||
getDesignerWindow(LimeReport::ReportEnginePrivateInterface* report, QWidget* parent,
|
||||
QSettings* settings);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -4,8 +4,18 @@
|
||||
namespace LimeReport {
|
||||
|
||||
struct CallbackInfo {
|
||||
enum DataType{IsEmpty, HasNext, ColumnHeaderData, ColumnData, ColumnCount, RowCount};
|
||||
enum ChangePosType{First, Next};
|
||||
enum DataType {
|
||||
IsEmpty,
|
||||
HasNext,
|
||||
ColumnHeaderData,
|
||||
ColumnData,
|
||||
ColumnCount,
|
||||
RowCount
|
||||
};
|
||||
enum ChangePosType {
|
||||
First,
|
||||
Next
|
||||
};
|
||||
DataType dataType;
|
||||
int index;
|
||||
QString columnName;
|
||||
@ -18,7 +28,6 @@ signals:
|
||||
void changePos(const LimeReport::CallbackInfo::ChangePosType& type, bool& result);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRVIRTUALDATASOURCEINTF
|
||||
|
||||
|
@ -1,12 +1,15 @@
|
||||
#ifndef LRDATASOURCEINTF_H
|
||||
#define LRDATASOURCEINTF_H
|
||||
#include <QSharedPointer>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QSharedPointer>
|
||||
namespace LimeReport {
|
||||
|
||||
class IDataSource {
|
||||
public:
|
||||
enum DatasourceMode{DESIGN_MODE,RENDER_MODE};
|
||||
enum DatasourceMode {
|
||||
DESIGN_MODE,
|
||||
RENDER_MODE
|
||||
};
|
||||
typedef QSharedPointer<IDataSource> Ptr;
|
||||
virtual ~IDataSource() { }
|
||||
virtual bool next() = 0;
|
||||
@ -19,8 +22,12 @@ public:
|
||||
virtual QVariant data(const QString& columnName) = 0;
|
||||
virtual QVariant dataByRowIndex(const QString& columnName, int rowIndex) = 0;
|
||||
virtual QVariant dataByRowIndex(const QString& columnName, int rowIndex, int roleName) = 0;
|
||||
virtual QVariant dataByRowIndex(const QString &columnName, int rowIndex, const QString &roleName) = 0;
|
||||
virtual QVariant dataByKeyField(const QString& columnName, const QString& keyColumnName, QVariant keyData) = 0;
|
||||
virtual QVariant dataByRowIndex(const QString& columnName, int rowIndex,
|
||||
const QString& roleName)
|
||||
= 0;
|
||||
virtual QVariant dataByKeyField(const QString& columnName, const QString& keyColumnName,
|
||||
QVariant keyData)
|
||||
= 0;
|
||||
virtual int columnCount() = 0;
|
||||
virtual QString columnNameByIndex(int columnIndex) = 0;
|
||||
virtual QVariant headerData(const QString& columnName, const QString& roleName) = 0;
|
||||
@ -33,7 +40,8 @@ public:
|
||||
class IDataSourceHolder {
|
||||
public:
|
||||
virtual ~IDataSourceHolder() { }
|
||||
virtual IDataSource* dataSource(IDataSource::DatasourceMode mode = IDataSource::RENDER_MODE) = 0;
|
||||
virtual IDataSource* dataSource(IDataSource::DatasourceMode mode = IDataSource::RENDER_MODE)
|
||||
= 0;
|
||||
virtual QString lastError() const = 0;
|
||||
virtual bool isInvalid() const = 0;
|
||||
virtual bool isOwned() const = 0;
|
||||
@ -47,5 +55,3 @@ public:
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRDATASOURCEINTF_H
|
||||
|
||||
|
||||
|
@ -31,8 +31,8 @@
|
||||
#define LRDATASOURCEMANAGERINTF_H
|
||||
|
||||
#include "lrcallbackdatasourceintf.h"
|
||||
#include "lrglobal.h"
|
||||
#include "lrdatasourceintf.h"
|
||||
#include "lrglobal.h"
|
||||
|
||||
class QVariant;
|
||||
class QString;
|
||||
@ -55,7 +55,9 @@ public:
|
||||
virtual bool containsVariable(const QString& variableName) = 0;
|
||||
virtual QVariant variable(const QString& variableName) = 0;
|
||||
virtual bool addModel(const QString& name, QAbstractItemModel* model, bool owned) = 0;
|
||||
virtual void addCSV(const QString& name, const QString& csvText, const QString& separator, bool firstRowIsHeader) = 0;
|
||||
virtual void addCSV(const QString& name, const QString& csvText, const QString& separator,
|
||||
bool firstRowIsHeader)
|
||||
= 0;
|
||||
virtual void removeModel(const QString& name) = 0;
|
||||
virtual bool containsDatasource(const QString& dataSourceName) = 0;
|
||||
virtual void clearUserVariables() = 0;
|
||||
@ -69,6 +71,5 @@ public:
|
||||
virtual IDataSourceHolder* dataSourceHolder(const QString& name) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRDATASOURCEMANAGERINTF_H
|
||||
|
||||
|
@ -27,17 +27,20 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
#include "lrglobal.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QString>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
QString extractClassName(QString className)
|
||||
{
|
||||
int startPos = className.lastIndexOf("::");
|
||||
if(startPos==-1) startPos=0;
|
||||
else startPos+=2;
|
||||
if (startPos == -1)
|
||||
startPos = 0;
|
||||
else
|
||||
startPos += 2;
|
||||
return className.right(className.length() - startPos);
|
||||
}
|
||||
|
||||
@ -46,7 +49,8 @@ bool ReportSettings::suppressAbsentFieldsAndVarsWarnings() const
|
||||
return m_suppressAbsentFieldsAndVarsWarnings;
|
||||
}
|
||||
|
||||
void ReportSettings::setSuppressAbsentFieldsAndVarsWarnings(bool suppressAbsentFieldsAndVarsWarnings)
|
||||
void ReportSettings::setSuppressAbsentFieldsAndVarsWarnings(
|
||||
bool suppressAbsentFieldsAndVarsWarnings)
|
||||
{
|
||||
m_suppressAbsentFieldsAndVarsWarnings = suppressAbsentFieldsAndVarsWarnings;
|
||||
}
|
||||
@ -68,9 +72,11 @@ QString replaceHTMLSymbols(const QString &value)
|
||||
}
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
|
||||
QVector<QString> normalizeCaptures(const QRegExp& reg){
|
||||
QVector<QString> normalizeCaptures(const QRegExp& reg)
|
||||
{
|
||||
#else
|
||||
QVector<QString> normalizeCaptures(const QRegularExpressionMatch ®){
|
||||
QVector<QString> normalizeCaptures(const QRegularExpressionMatch& reg)
|
||||
{
|
||||
#endif
|
||||
QVector<QString> result;
|
||||
foreach (QString cap, reg.capturedTexts()) {
|
||||
@ -80,7 +86,8 @@ QVector<QString> normalizeCaptures(const QRegularExpressionMatch ®){
|
||||
return result;
|
||||
}
|
||||
|
||||
bool isColorDark(QColor color){
|
||||
bool isColorDark(QColor color)
|
||||
{
|
||||
qreal darkness = 1 - (0.299 * color.red() + 0.587 * color.green() + 0.114 * color.blue()) / 255;
|
||||
if (darkness < 0.5) {
|
||||
return false;
|
||||
|
@ -30,11 +30,13 @@
|
||||
#ifndef LRGLOBAL_H
|
||||
#define LRGLOBAL_H
|
||||
#include "qglobal.h"
|
||||
#include <stdexcept>
|
||||
|
||||
#include <QString>
|
||||
#include <QStyleOptionViewItem>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#if defined(LIMEREPORT_EXPORTS)
|
||||
#define LIMEREPORT_EXPORT Q_DECL_EXPORT
|
||||
#elif defined(LIMEREPORT_IMPORTS)
|
||||
@ -80,10 +82,16 @@ namespace Const{
|
||||
const qreal BAND_NAME_TEXT_OPACITY = 0.6;
|
||||
const qreal SELECTION_OPACITY = 0.3;
|
||||
const QString FIELD_RX = "\\$D\\s*\\{\\s*([^{}]*)\\s*\\}";
|
||||
const QString VARIABLE_RX = "\\$V\\s*\\{\\s*(?:([^\\{\\},]*)|(?:([^\\{\\}]*)\\s*,\\s*([^\\{\\}]*)))\\s*\\}";
|
||||
const QString NAMED_VARIABLE_RX = "\\$V\\s*\\{\\s*(?:(%1)|(?:(%1)\\s*,\\s*([^\\{\\}]*)))\\s*\\}";
|
||||
const QString VARIABLE_RX = "\\$V\\s*\\{\\s*(?:([^\\{\\},]*)|(?:([^\\{\\}]*)\\s*,\\s*([^\\{"
|
||||
"\\}]*)))\\s*\\}";
|
||||
const QString NAMED_VARIABLE_RX
|
||||
= "\\$V\\s*\\{\\s*(?:(%1)|(?:(%1)\\s*,\\s*([^\\{\\}]*)))\\s*\\}";
|
||||
const QString SCRIPT_RX = "\\$S\\s*\\{(.*)\\}";
|
||||
const QString GROUP_FUNCTION_PARAM_RX = "\\(\\s*((?:(?:\\\")|(?:))(?:(?:\\$(?:(?:D\\{\\s*\\w*..*\\})|(?:V\\{\\s*\\w*\\s*\\})|(?:S\\{.+\\})))|(?:\\w*))(?:(?:\\\")|(?:)))(?:(?:\\s*,\\s*(?:\\\"(\\w*)\\\"))|(?:))(?:(?:\\s*,\\s*(?:(\\w*)))|(?:))\\)";
|
||||
const QString GROUP_FUNCTION_PARAM_RX
|
||||
= "\\(\\s*((?:(?:\\\")|(?:))(?:(?:\\$(?:(?:D\\{\\s*\\w*..*\\})|"
|
||||
"(?:V\\{\\s*\\w*\\s*\\})|(?:S\\{.+\\})))|(?:\\w*))(?:(?:\\\")"
|
||||
"|(?:)))(?:(?:\\s*,\\s*(?:\\\"(\\w*)\\\"))|(?:))(?:(?:\\s*,"
|
||||
"\\s*(?:(\\w*)))|(?:))\\)";
|
||||
const int DATASOURCE_INDEX = 3;
|
||||
const int VALUE_INDEX = 2;
|
||||
const int EXPRESSION_ARGUMENT_INDEX = 1;
|
||||
@ -100,7 +108,7 @@ namespace Const{
|
||||
const char SCRIPT_SIGN = 'S';
|
||||
const char FIELD_SIGN = 'D';
|
||||
const char VARIABLE_SIGN = 'V';
|
||||
}
|
||||
} // namespace Const
|
||||
QString extractClassName(QString className);
|
||||
QString escapeSimbols(const QString& value);
|
||||
QString replaceHTMLSymbols(const QString& value);
|
||||
@ -111,16 +119,33 @@ namespace Const{
|
||||
#endif
|
||||
bool isColorDark(QColor color);
|
||||
|
||||
enum ExpandType {EscapeSymbols, NoEscapeSymbols, ReplaceHTMLSymbols};
|
||||
enum RenderPass {FirstPass = 1, SecondPass = 2};
|
||||
enum ArrangeType {AsNeeded, Force};
|
||||
enum ScaleType {FitWidth, FitPage, OneToOne, Percents};
|
||||
enum PreviewHint{ShowAllPreviewBars = 0,
|
||||
enum ExpandType {
|
||||
EscapeSymbols,
|
||||
NoEscapeSymbols,
|
||||
ReplaceHTMLSymbols
|
||||
};
|
||||
enum RenderPass {
|
||||
FirstPass = 1,
|
||||
SecondPass = 2
|
||||
};
|
||||
enum ArrangeType {
|
||||
AsNeeded,
|
||||
Force
|
||||
};
|
||||
enum ScaleType {
|
||||
FitWidth,
|
||||
FitPage,
|
||||
OneToOne,
|
||||
Percents
|
||||
};
|
||||
enum PreviewHint {
|
||||
ShowAllPreviewBars = 0,
|
||||
HidePreviewToolBar = 1,
|
||||
HidePreviewMenuBar = 2,
|
||||
HidePreviewStatusBar = 4,
|
||||
HideAllPreviewBar = 7,
|
||||
PreviewBarsUserSetting = 8};
|
||||
PreviewBarsUserSetting = 8
|
||||
};
|
||||
|
||||
Q_DECLARE_FLAGS(PreviewHints, PreviewHint)
|
||||
Q_FLAGS(PreviewHints)
|
||||
@ -133,23 +158,28 @@ namespace Const{
|
||||
class LIMEREPORT_EXPORT ReportSettings {
|
||||
public:
|
||||
#ifdef DEFAULT_ITEM_PADDING
|
||||
ReportSettings():m_suppressAbsentFieldsAndVarsWarnings(false), m_baseItemPadding(DEFAULT_ITEM_PADDING){}
|
||||
ReportSettings():
|
||||
m_suppressAbsentFieldsAndVarsWarnings(false),
|
||||
m_baseItemPadding(DEFAULT_ITEM_PADDING)
|
||||
{
|
||||
}
|
||||
#else
|
||||
ReportSettings(): m_suppressAbsentFieldsAndVarsWarnings(false), m_baseItemPadding(0) { }
|
||||
#endif
|
||||
void setDefaultValues(){
|
||||
void setDefaultValues()
|
||||
{
|
||||
m_suppressAbsentFieldsAndVarsWarnings = false;
|
||||
#ifdef DEFAULT_ITEM_PADDING
|
||||
m_baseItemPadding = DEFAULT_ITEM_PADDING;
|
||||
#else
|
||||
m_baseItemPadding = 0;
|
||||
#endif
|
||||
|
||||
}
|
||||
bool suppressAbsentFieldsAndVarsWarnings() const;
|
||||
void setSuppressAbsentFieldsAndVarsWarnings(bool suppressAbsentFieldsAndVarsWarnings);
|
||||
int baseItemPadding() const;
|
||||
void setBaseItemPadding(int newBaseTextItemPadding);
|
||||
|
||||
private:
|
||||
bool m_suppressAbsentFieldsAndVarsWarnings;
|
||||
int m_baseItemPadding;
|
||||
@ -157,7 +187,9 @@ namespace Const{
|
||||
|
||||
class LIMEREPORT_EXPORT IExternalPainter {
|
||||
public:
|
||||
virtual void paintByExternalPainter(const QString& objectName, QPainter* painter, const QStyleOptionGraphicsItem* options) = 0;
|
||||
virtual void paintByExternalPainter(const QString& objectName, QPainter* painter,
|
||||
const QStyleOptionGraphicsItem* options)
|
||||
= 0;
|
||||
virtual ~IExternalPainter();
|
||||
};
|
||||
|
||||
@ -182,11 +214,18 @@ namespace Const{
|
||||
QRegularExpression getNamedVariableRegEx(QString variableName);
|
||||
#endif
|
||||
|
||||
|
||||
class LIMEREPORT_EXPORT Enums
|
||||
{
|
||||
class LIMEREPORT_EXPORT Enums {
|
||||
public:
|
||||
enum VariableDataType {Undefined, String, Bool, Int, Real, Date, Time, DateTime};
|
||||
enum VariableDataType {
|
||||
Undefined,
|
||||
String,
|
||||
Bool,
|
||||
Int,
|
||||
Real,
|
||||
Date,
|
||||
Time,
|
||||
DateTime
|
||||
};
|
||||
#if QT_VERSION >= 0x050500
|
||||
Q_ENUM(VariableDataType)
|
||||
#else
|
||||
|
@ -1,12 +1,13 @@
|
||||
#ifndef LRPREVIEWREPORTWIDGET_H
|
||||
#define LRPREVIEWREPORTWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTimer>
|
||||
#include <QPrinter>
|
||||
#include "lrglobal.h"
|
||||
#include "lrpreparedpagesintf.h"
|
||||
|
||||
#include <QPrinter>
|
||||
#include <QTimer>
|
||||
#include <QWidget>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
namespace Ui {
|
||||
@ -18,17 +19,18 @@ class ReportEnginePrivate;
|
||||
class ReportEngine;
|
||||
class PageDesignIntf;
|
||||
|
||||
class LIMEREPORT_EXPORT PreviewReportWidget : public QWidget
|
||||
{
|
||||
class LIMEREPORT_EXPORT PreviewReportWidget: public QWidget {
|
||||
Q_OBJECT
|
||||
friend class ReportEnginePrivate;
|
||||
friend class PreviewReportWindow;
|
||||
friend class PreviewReportWidgetPrivate;
|
||||
|
||||
public:
|
||||
explicit PreviewReportWidget(ReportEngine* report, QWidget* parent = 0);
|
||||
~PreviewReportWidget();
|
||||
QList<QString> aviableExporters();
|
||||
bool exportReport(QString exporterName, const QMap<QString, QVariant>& params = QMap<QString, QVariant>());
|
||||
bool exportReport(QString exporterName,
|
||||
const QMap<QString, QVariant>& params = QMap<QString, QVariant>());
|
||||
ScaleType scaleType() const;
|
||||
int scalePercent() const;
|
||||
void setScaleType(const ScaleType& scaleType, int percent = 0);
|
||||
@ -59,6 +61,7 @@ public slots:
|
||||
void setScalePercent(int percent);
|
||||
void fitWidth();
|
||||
void fitPage();
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent*);
|
||||
signals:
|
||||
@ -72,11 +75,13 @@ private slots:
|
||||
void reportEngineDestroyed(QObject* object);
|
||||
void slotZoomed(double);
|
||||
void resizeDone();
|
||||
|
||||
private:
|
||||
void initPreview();
|
||||
void setErrorsMesagesVisible(bool visible);
|
||||
void setErrorMessages(const QStringList& value);
|
||||
void emitPageSet();
|
||||
|
||||
private:
|
||||
Ui::PreviewReportWidget* ui;
|
||||
PreviewReportWidgetPrivate* d_ptr;
|
||||
|
@ -1,14 +1,14 @@
|
||||
#ifndef LRRENDERENGINE_H
|
||||
#define LRRENDERENGINE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QSettings>
|
||||
#include <QPrintDialog>
|
||||
|
||||
#include "lrglobal.h"
|
||||
#include "lrdatasourcemanagerintf.h"
|
||||
#include "lrscriptenginemanagerintf.h"
|
||||
#include "lrglobal.h"
|
||||
#include "lrpreviewreportwidget.h"
|
||||
#include "lrscriptenginemanagerintf.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QPrintDialog>
|
||||
#include <QSettings>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
@ -17,10 +17,12 @@ 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);
|
||||
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;
|
||||
@ -39,8 +41,10 @@ class RenderEnginePrivate;
|
||||
class LIMEREPORT_EXPORT RenderEngine: public QObject {
|
||||
Q_OBJECT
|
||||
friend class PreviewReportWidget;
|
||||
|
||||
public:
|
||||
static void setSettings(QSettings* value) { m_settings = value; }
|
||||
|
||||
public:
|
||||
explicit RenderEngine(QObject* parent = 0);
|
||||
explicit RenderEngine(RenderEnginePrivate* dd, QObject* parent = 0);
|
||||
@ -78,11 +82,14 @@ signals:
|
||||
void onLoad(bool& loaded);
|
||||
public slots:
|
||||
void cancelRender();
|
||||
|
||||
protected:
|
||||
QObject* d_ptr;
|
||||
|
||||
private:
|
||||
static QSettings* m_settings;
|
||||
void init();
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(RenderEngine)
|
||||
};
|
||||
|
@ -31,16 +31,16 @@
|
||||
#define LRREPORTDESIGNINTF_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QSettings>
|
||||
#include <QPrintDialog>
|
||||
#include <QSettings>
|
||||
//#include <QJSEngine>
|
||||
|
||||
#include "lrglobal.h"
|
||||
#include "lrdatasourcemanagerintf.h"
|
||||
#include "lrscriptenginemanagerintf.h"
|
||||
#include "lrglobal.h"
|
||||
#include "lrpreparedpagesintf.h"
|
||||
#include "lrpreviewreportwidget.h"
|
||||
#include "lrreportdesignwindowintrerface.h"
|
||||
#include "lrpreparedpagesintf.h"
|
||||
#include "lrscriptenginemanagerintf.h"
|
||||
|
||||
class QPrinter;
|
||||
class QGraphicsScene;
|
||||
@ -52,10 +52,12 @@ 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);
|
||||
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;
|
||||
@ -64,9 +66,20 @@ private:
|
||||
|
||||
class LIMEREPORT_EXPORT ItemGeometry {
|
||||
public:
|
||||
enum Type{Millimeters, Pixels};
|
||||
ItemGeometry(qreal x, qreal y, qreal width, qreal height, Qt::Alignment anchor, Type type = Millimeters)
|
||||
:m_x(x), m_y(y), m_width(width), m_height(height), m_type(type), m_anchor(anchor){}
|
||||
enum Type {
|
||||
Millimeters,
|
||||
Pixels
|
||||
};
|
||||
ItemGeometry(qreal x, qreal y, qreal width, qreal height, Qt::Alignment anchor,
|
||||
Type type = Millimeters):
|
||||
m_x(x),
|
||||
m_y(y),
|
||||
m_width(width),
|
||||
m_height(height),
|
||||
m_type(type),
|
||||
m_anchor(anchor)
|
||||
{
|
||||
}
|
||||
ItemGeometry(): m_x(0), m_y(0), m_width(0), m_height(0), m_type(Millimeters) { }
|
||||
|
||||
qreal x() const;
|
||||
@ -98,8 +111,14 @@ private:
|
||||
|
||||
class LIMEREPORT_EXPORT WatermarkSetting {
|
||||
public:
|
||||
WatermarkSetting(const QString& text, const ItemGeometry& geometry, const QFont& font)
|
||||
: m_text(text), m_font(font), m_opacity(50), m_geometry(geometry), m_color(QColor(Qt::black)){}
|
||||
WatermarkSetting(const QString& text, const ItemGeometry& geometry, const QFont& font):
|
||||
m_text(text),
|
||||
m_font(font),
|
||||
m_opacity(50),
|
||||
m_geometry(geometry),
|
||||
m_color(QColor(Qt::black))
|
||||
{
|
||||
}
|
||||
WatermarkSetting(): m_font(QFont()), m_opacity(50), m_geometry(ItemGeometry()) { }
|
||||
QString text() const;
|
||||
void setText(const QString& text);
|
||||
@ -131,7 +150,6 @@ class ItemBuilder{
|
||||
virtual ItemGeometry geometry() = 0;
|
||||
};
|
||||
|
||||
|
||||
class DataSourceManager;
|
||||
class ReportEnginePrivate;
|
||||
class PageDesignIntf;
|
||||
@ -147,8 +165,10 @@ class LIMEREPORT_EXPORT ReportEngine : public QObject{
|
||||
friend class ReportDesignWidget;
|
||||
friend class PreviewReportWidget;
|
||||
friend class TranslationEditor;
|
||||
|
||||
public:
|
||||
static void setSettings(QSettings* value) { m_settings = value; }
|
||||
|
||||
public:
|
||||
explicit ReportEngine(QObject* parent = 0);
|
||||
~ReportEngine();
|
||||
@ -158,7 +178,8 @@ public:
|
||||
void printToFile(const QString& fileName);
|
||||
QGraphicsScene* createPreviewScene(QObject* parent = 0);
|
||||
bool printToPDF(const QString& fileName);
|
||||
bool exportReport(QString exporterName, const QString &fileName = "", const QMap<QString, QVariant>& params = QMap<QString, QVariant>());
|
||||
bool exportReport(QString exporterName, const QString& fileName = "",
|
||||
const QMap<QString, QVariant>& params = QMap<QString, QVariant>());
|
||||
void previewReport(PreviewHints hints = PreviewBarsUserSetting);
|
||||
void previewReport(QPrinter* printer, PreviewHints hints = PreviewBarsUserSetting);
|
||||
void designReport();
|
||||
@ -234,14 +255,17 @@ signals:
|
||||
void currentDefaultDesignerLanguageChanged(QLocale::Language);
|
||||
QLocale::Language getCurrentDefaultDesignerLanguage();
|
||||
|
||||
void externalPaint(const QString& objectName, QPainter* painter, const QStyleOptionGraphicsItem*);
|
||||
void externalPaint(const QString& objectName, QPainter* painter,
|
||||
const QStyleOptionGraphicsItem*);
|
||||
|
||||
public slots:
|
||||
void cancelRender();
|
||||
void cancelPrinting();
|
||||
|
||||
protected:
|
||||
ReportEnginePrivate* const d_ptr;
|
||||
ReportEngine(ReportEnginePrivate& dd, QObject* parent = 0);
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(ReportEngine)
|
||||
static QSettings* m_settings;
|
||||
|
@ -54,8 +54,7 @@ namespace LimeReport{
|
||||
#ifdef USE_QJSENGINE
|
||||
typedef QJSEngine ScriptEngineType;
|
||||
typedef QJSValue ScriptValueType;
|
||||
template <typename T>
|
||||
static inline QJSValue getJSValue(QJSEngine &e, T *p)
|
||||
template <typename T> static inline QJSValue getJSValue(QJSEngine& e, T* p)
|
||||
{
|
||||
QJSValue res = e.newQObject(p);
|
||||
QQmlEngine::setObjectOwnership(p, QQmlEngine::CppOwnership);
|
||||
@ -71,14 +70,15 @@ public:
|
||||
virtual ScriptEngineType* scriptEngine() = 0;
|
||||
#ifdef USE_QTSCRIPTENGINE
|
||||
virtual bool addFunction(const QString& name, ScriptEngineType::FunctionSignature function,
|
||||
const QString& category="", const QString& description="") = 0;
|
||||
const QString& category = "", const QString& description = "")
|
||||
= 0;
|
||||
#endif
|
||||
virtual bool addFunction(const QString& name, const QString& script,
|
||||
const QString &category="", const QString &description="") = 0;
|
||||
const QString& category = "", const QString& description = "")
|
||||
= 0;
|
||||
virtual const QString& lastError() const = 0;
|
||||
virtual ScriptValueType moveQObjectToScript(QObject* object, const QString objectName) = 0;
|
||||
virtual ~IScriptEngineManager() { }
|
||||
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -28,6 +28,7 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrdataband.h"
|
||||
|
||||
#include "lrdesignelementsfactory.h"
|
||||
#include "lrglobal.h"
|
||||
|
||||
@ -37,52 +38,47 @@ const QString xmlTagFooter = "DataFooter";
|
||||
|
||||
namespace {
|
||||
|
||||
LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
LimeReport::BaseDesignIntf* createBand(QObject* owner, LimeReport::BaseDesignIntf* parent)
|
||||
{
|
||||
return new LimeReport::DataBand(owner, parent);
|
||||
}
|
||||
LimeReport::BaseDesignIntf * createHeader(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
LimeReport::BaseDesignIntf* createHeader(QObject* owner, LimeReport::BaseDesignIntf* parent)
|
||||
{
|
||||
return new LimeReport::DataHeaderBand(owner, parent);
|
||||
}
|
||||
LimeReport::BaseDesignIntf * createFooter(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
LimeReport::BaseDesignIntf* createFooter(QObject* owner, LimeReport::BaseDesignIntf* parent)
|
||||
{
|
||||
return new LimeReport::DataFooterBand(owner, parent);
|
||||
}
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag,
|
||||
LimeReport::ItemAttribs(QObject::tr("Data"),LimeReport::Const::bandTAG),
|
||||
createBand
|
||||
);
|
||||
bool VARIABLE_IS_NOT_USED registredHeader = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag, LimeReport::ItemAttribs(QObject::tr("Data"), LimeReport::Const::bandTAG), createBand);
|
||||
bool VARIABLE_IS_NOT_USED registredHeader
|
||||
= LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTagHeader,
|
||||
LimeReport::ItemAttribs(QObject::tr("DataHeader"), LimeReport::Const::bandTAG),
|
||||
createHeader
|
||||
);
|
||||
bool VARIABLE_IS_NOT_USED registredFooter = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
createHeader);
|
||||
bool VARIABLE_IS_NOT_USED registredFooter
|
||||
= LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTagFooter,
|
||||
LimeReport::ItemAttribs(QObject::tr("DataFooter"), LimeReport::Const::bandTAG),
|
||||
createFooter
|
||||
);
|
||||
createFooter);
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
DataBand::DataBand(QObject *owner, QGraphicsItem *parent)
|
||||
: DataBandDesignIntf(LimeReport::BandDesignIntf::Data,xmlTag,owner,parent) {
|
||||
DataBand::DataBand(QObject* owner, QGraphicsItem* parent):
|
||||
DataBandDesignIntf(LimeReport::BandDesignIntf::Data, xmlTag, owner, parent)
|
||||
{
|
||||
setBandTypeText(tr("Data"));
|
||||
setFixedPos(false);
|
||||
setMarkerColor(bandColor());
|
||||
}
|
||||
|
||||
bool DataBand::isUnique() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool DataBand::isUnique() const { return false; }
|
||||
|
||||
QColor DataBand::bandColor() const
|
||||
{
|
||||
return QColor(Qt::darkGreen);
|
||||
}
|
||||
QColor DataBand::bandColor() const { return QColor(Qt::darkGreen); }
|
||||
|
||||
void DataBand::preparePopUpMenu(QMenu& menu)
|
||||
{
|
||||
@ -111,9 +107,6 @@ void DataBand::preparePopUpMenu(QMenu &menu)
|
||||
currAction = menu.addAction(tr("Start new page"));
|
||||
currAction->setCheckable(true);
|
||||
currAction->setChecked(startNewPage());
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void DataBand::processPopUpAction(QAction* action)
|
||||
@ -149,8 +142,8 @@ BaseDesignIntf *DataBand::createSameTypeItem(QObject *owner, QGraphicsItem *pare
|
||||
return new DataBand(owner, parent);
|
||||
}
|
||||
|
||||
DataHeaderBand::DataHeaderBand(QObject *owner, QGraphicsItem *parent)
|
||||
:BandDesignIntf(BandDesignIntf::DataHeader,xmlTagHeader,owner,parent)
|
||||
DataHeaderBand::DataHeaderBand(QObject* owner, QGraphicsItem* parent):
|
||||
BandDesignIntf(BandDesignIntf::DataHeader, xmlTagHeader, owner, parent)
|
||||
{
|
||||
setBandTypeText(tr("DataHeader"));
|
||||
setMarkerColor(bandColor());
|
||||
@ -188,8 +181,8 @@ void DataHeaderBand::processPopUpAction(QAction *action)
|
||||
}
|
||||
}
|
||||
|
||||
DataFooterBand::DataFooterBand(QObject *owner, QGraphicsItem *parent)
|
||||
:BandDesignIntf(BandDesignIntf::DataFooter,xmlTagFooter,owner,parent)
|
||||
DataFooterBand::DataFooterBand(QObject* owner, QGraphicsItem* parent):
|
||||
BandDesignIntf(BandDesignIntf::DataFooter, xmlTagFooter, owner, parent)
|
||||
{
|
||||
setBandTypeText(tr("DataFooter"));
|
||||
setMarkerColor(bandColor());
|
||||
@ -211,5 +204,4 @@ void DataFooterBand::processPopUpAction(QAction *action)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -32,41 +32,46 @@
|
||||
|
||||
#include "lrbanddesignintf.h"
|
||||
#include "lrbasedesignintf.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
class DataBand : public DataBandDesignIntf
|
||||
{
|
||||
class DataBand: public DataBandDesignIntf {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool keepSubdetailTogether READ tryToKeepTogether WRITE setTryToKeepTogether)
|
||||
Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable)
|
||||
Q_PROPERTY(bool keepFooterTogether READ keepFooterTogether WRITE setKeepFooterTogether)
|
||||
Q_PROPERTY(bool sliceLastRow READ sliceLastRow WRITE setSliceLastRow)
|
||||
Q_PROPERTY(int columnsCount READ columnsCount WRITE setColumnsCount)
|
||||
Q_PROPERTY(BandColumnsLayoutType columnsFillDirection READ columnsFillDirection WRITE setColumnsFillDirection)
|
||||
Q_PROPERTY(BandColumnsLayoutType columnsFillDirection READ columnsFillDirection WRITE
|
||||
setColumnsFillDirection)
|
||||
Q_PROPERTY(bool startNewPage READ startNewPage WRITE setStartNewPage)
|
||||
Q_PROPERTY(bool startFromNewPage READ startFromNewPage WRITE setStartFromNewPage)
|
||||
Q_PROPERTY(QColor alternateBackgroundColor READ alternateBackgroundColor WRITE setAlternateBackgroundColor)
|
||||
Q_PROPERTY(bool useAlternateBackgroundColor READ useAlternateBackgroundColor WRITE setUseAlternateBackgroundColor)
|
||||
Q_PROPERTY(QColor alternateBackgroundColor READ alternateBackgroundColor WRITE
|
||||
setAlternateBackgroundColor)
|
||||
Q_PROPERTY(bool useAlternateBackgroundColor READ useAlternateBackgroundColor WRITE
|
||||
setUseAlternateBackgroundColor)
|
||||
public:
|
||||
DataBand(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
bool isUnique() const;
|
||||
bool isData() const { return true; }
|
||||
|
||||
protected:
|
||||
QColor bandColor() const;
|
||||
void preparePopUpMenu(QMenu& menu);
|
||||
void processPopUpAction(QAction* action);
|
||||
|
||||
private:
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
};
|
||||
|
||||
class DataHeaderBand : public BandDesignIntf
|
||||
{
|
||||
class DataHeaderBand: public BandDesignIntf {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool reprintOnEachPage READ reprintOnEachPage WRITE setReprintOnEachPage)
|
||||
Q_PROPERTY(int columnsCount READ columnsCount WRITE setColumnsCount)
|
||||
Q_PROPERTY(BandColumnsLayoutType columnsFillDirection READ columnsFillDirection WRITE setColumnsFillDirection)
|
||||
Q_PROPERTY(BandColumnsLayoutType columnsFillDirection READ columnsFillDirection WRITE
|
||||
setColumnsFillDirection)
|
||||
Q_PROPERTY(bool printAlways READ printAlways WRITE setPrintAlways)
|
||||
Q_PROPERTY(bool repeatOnEachRow READ repeatOnEachRow WRITE setRepeatOnEachRow)
|
||||
public:
|
||||
@ -74,35 +79,41 @@ public:
|
||||
bool isUnique() const { return false; }
|
||||
bool isHeader() const { return true; }
|
||||
QColor bandColor() const { return QColor(Qt::darkGreen); }
|
||||
|
||||
protected:
|
||||
void preparePopUpMenu(QMenu& menu);
|
||||
void processPopUpAction(QAction* action);
|
||||
|
||||
private:
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0){
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0)
|
||||
{
|
||||
return new DataHeaderBand(owner, parent);
|
||||
}
|
||||
};
|
||||
|
||||
class DataFooterBand : public BandDesignIntf
|
||||
{
|
||||
class DataFooterBand: public BandDesignIntf {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int columnsCount READ columnsCount WRITE setColumnsCount)
|
||||
Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable)
|
||||
Q_PROPERTY(BandColumnsLayoutType columnsFillDirection READ columnsFillDirection WRITE setColumnsFillDirection)
|
||||
Q_PROPERTY(BandColumnsLayoutType columnsFillDirection READ columnsFillDirection WRITE
|
||||
setColumnsFillDirection)
|
||||
Q_PROPERTY(bool printAlways READ printAlways WRITE setPrintAlways)
|
||||
public:
|
||||
DataFooterBand(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
bool isUnique() const { return false; }
|
||||
bool isFooter() const { return true; }
|
||||
QColor bandColor() const { return QColor(Qt::darkGreen); }
|
||||
|
||||
protected:
|
||||
void preparePopUpMenu(QMenu& menu);
|
||||
void processPopUpAction(QAction* action);
|
||||
|
||||
private:
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0){
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0)
|
||||
{
|
||||
return new DataFooterBand(owner, parent);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRDATABAND_H
|
||||
|
@ -28,51 +28,53 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrgroupbands.h"
|
||||
#include "lrglobal.h"
|
||||
|
||||
#include "lrdatasourcemanager.h"
|
||||
#include "lrglobal.h"
|
||||
|
||||
const QString xmlTagHeader = QLatin1String("GroupHeader");
|
||||
const QString xmlTagFooter = QLatin1String("GroupFooter");
|
||||
|
||||
namespace {
|
||||
|
||||
LimeReport::BaseDesignIntf* createHeader(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
LimeReport::BaseDesignIntf* createHeader(QObject* owner, LimeReport::BaseDesignIntf* parent)
|
||||
{
|
||||
return new LimeReport::GroupBandHeader(owner, parent);
|
||||
}
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registredHeader = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
bool VARIABLE_IS_NOT_USED registredHeader
|
||||
= LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTagHeader,
|
||||
LimeReport::ItemAttribs(QObject::tr("GroupHeader"), LimeReport::Const::bandTAG),
|
||||
createHeader
|
||||
);
|
||||
createHeader);
|
||||
|
||||
LimeReport::BaseDesignIntf * createFooter(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
LimeReport::BaseDesignIntf* createFooter(QObject* owner, LimeReport::BaseDesignIntf* parent)
|
||||
{
|
||||
return new LimeReport::GroupBandFooter(owner, parent);
|
||||
}
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registredFooter = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
bool VARIABLE_IS_NOT_USED registredFooter
|
||||
= LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTagFooter,
|
||||
LimeReport::ItemAttribs(QObject::tr("GroupFooter"), LimeReport::Const::bandTAG),
|
||||
createFooter
|
||||
);
|
||||
createFooter);
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
GroupBandHeader::GroupBandHeader(QObject *owner, QGraphicsItem *parent)
|
||||
: BandDesignIntf(BandDesignIntf::GroupHeader, xmlTagHeader, owner,parent),
|
||||
m_groupFiledName(""), m_groupStarted(false), m_resetPageNumber(false)
|
||||
GroupBandHeader::GroupBandHeader(QObject* owner, QGraphicsItem* parent):
|
||||
BandDesignIntf(BandDesignIntf::GroupHeader, xmlTagHeader, owner, parent),
|
||||
m_groupFiledName(""),
|
||||
m_groupStarted(false),
|
||||
m_resetPageNumber(false)
|
||||
{
|
||||
setBandTypeText(tr("GroupHeader"));
|
||||
setFixedPos(false);
|
||||
setMarkerColor(bandColor());
|
||||
}
|
||||
|
||||
bool GroupBandHeader::isUnique() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool GroupBandHeader::isUnique() const { return false; }
|
||||
|
||||
// bool GroupBandHeader::tryToKeepTogether()
|
||||
//{
|
||||
@ -98,34 +100,28 @@ void GroupBandHeader::startGroup(DataSourceManager* dataManager)
|
||||
m_groupFieldValue = ds->data(m_groupFiledName);
|
||||
}
|
||||
|
||||
if (!m_condition.isEmpty()) m_conditionValue = calcCondition(dataManager);
|
||||
if (!m_condition.isEmpty())
|
||||
m_conditionValue = calcCondition(dataManager);
|
||||
}
|
||||
|
||||
QColor GroupBandHeader::bandColor() const
|
||||
QColor GroupBandHeader::bandColor() const { return QColor(Qt::darkBlue); }
|
||||
|
||||
QString GroupBandHeader::findDataSourceName(BandDesignIntf* parentBand)
|
||||
{
|
||||
return QColor(Qt::darkBlue);
|
||||
}
|
||||
|
||||
QString GroupBandHeader::findDataSourceName(BandDesignIntf* parentBand){
|
||||
if (!parentBand) return "";
|
||||
if (!parentBand)
|
||||
return "";
|
||||
if (!parentBand->datasourceName().isEmpty())
|
||||
return parentBand->datasourceName();
|
||||
else
|
||||
return findDataSourceName(parentBand->parentBand());
|
||||
|
||||
}
|
||||
|
||||
QString GroupBandHeader::condition() const
|
||||
QString GroupBandHeader::condition() const { return m_condition; }
|
||||
|
||||
void GroupBandHeader::setCondition(const QString& condition) { m_condition = condition; }
|
||||
|
||||
QString GroupBandHeader::calcCondition(DataSourceManager* dataManager)
|
||||
{
|
||||
return m_condition;
|
||||
}
|
||||
|
||||
void GroupBandHeader::setCondition(const QString &condition)
|
||||
{
|
||||
m_condition = condition;
|
||||
}
|
||||
|
||||
QString GroupBandHeader::calcCondition(DataSourceManager* dataManager){
|
||||
QString result = m_condition;
|
||||
if (!m_condition.isEmpty()) {
|
||||
result = expandUserVariables(result, FirstPass, NoEscapeSymbols, dataManager);
|
||||
@ -137,7 +133,8 @@ QString GroupBandHeader::calcCondition(DataSourceManager* dataManager){
|
||||
|
||||
bool GroupBandHeader::isNeedToClose(DataSourceManager* dataManager)
|
||||
{
|
||||
if (!m_groupStarted) return false;
|
||||
if (!m_groupStarted)
|
||||
return false;
|
||||
if ((m_groupFiledName.isNull() || m_groupFiledName.isEmpty()) && condition().isEmpty()) {
|
||||
dataManager->putError(tr("Group field not found"));
|
||||
return false;
|
||||
@ -150,8 +147,10 @@ bool GroupBandHeader::isNeedToClose(DataSourceManager* dataManager)
|
||||
if (dataManager->containsDatasource(datasourceName)) {
|
||||
IDataSource* ds = dataManager->dataSource(datasourceName);
|
||||
if (ds) {
|
||||
if (ds->data(m_groupFiledName).isNull() && m_groupFieldValue.isNull()) return false;
|
||||
if (!ds->data(m_groupFiledName).isValid()) return false;
|
||||
if (ds->data(m_groupFiledName).isNull() && m_groupFieldValue.isNull())
|
||||
return false;
|
||||
if (!ds->data(m_groupFiledName).isValid())
|
||||
return false;
|
||||
return ds->data(m_groupFiledName) != m_groupFieldValue;
|
||||
}
|
||||
} else {
|
||||
@ -174,48 +173,33 @@ void GroupBandHeader::closeGroup()
|
||||
m_groupStarted = false;
|
||||
}
|
||||
|
||||
int GroupBandHeader::index()
|
||||
{
|
||||
return bandIndex();
|
||||
}
|
||||
int GroupBandHeader::index() { return bandIndex(); }
|
||||
|
||||
bool GroupBandHeader::startNewPage() const
|
||||
{
|
||||
return BandDesignIntf::startNewPage();
|
||||
}
|
||||
bool GroupBandHeader::startNewPage() const { return BandDesignIntf::startNewPage(); }
|
||||
|
||||
void GroupBandHeader::setStartNewPage(bool startNewPage)
|
||||
{
|
||||
BandDesignIntf::setStartNewPage(startNewPage);
|
||||
}
|
||||
|
||||
bool GroupBandHeader::resetPageNumber() const
|
||||
{
|
||||
return m_resetPageNumber;
|
||||
}
|
||||
bool GroupBandHeader::resetPageNumber() const { return m_resetPageNumber; }
|
||||
|
||||
void GroupBandHeader::setResetPageNumber(bool resetPageNumber)
|
||||
{
|
||||
m_resetPageNumber = resetPageNumber;
|
||||
}
|
||||
|
||||
GroupBandFooter::GroupBandFooter(QObject *owner, QGraphicsItem *parent)
|
||||
:BandDesignIntf(BandDesignIntf::GroupFooter, xmlTagFooter, owner,parent)
|
||||
GroupBandFooter::GroupBandFooter(QObject* owner, QGraphicsItem* parent):
|
||||
BandDesignIntf(BandDesignIntf::GroupFooter, xmlTagFooter, owner, parent)
|
||||
{
|
||||
setBandTypeText(tr("GroupFooter"));
|
||||
setFixedPos(false);
|
||||
setMarkerColor(bandColor());
|
||||
}
|
||||
|
||||
bool GroupBandFooter::isUnique() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool GroupBandFooter::isUnique() const { return false; }
|
||||
|
||||
QColor GroupBandFooter::bandColor() const
|
||||
{
|
||||
return QColor(Qt::darkBlue);
|
||||
}
|
||||
QColor GroupBandFooter::bandColor() const { return QColor(Qt::darkBlue); }
|
||||
|
||||
BaseDesignIntf* GroupBandFooter::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
|
@ -60,6 +60,7 @@ public:
|
||||
bool isGroupHeader() const { return true; }
|
||||
QString condition() const;
|
||||
void setCondition(const QString& condition);
|
||||
|
||||
private:
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
void startGroup(DataSourceManager* dataManager);
|
||||
@ -69,6 +70,7 @@ private:
|
||||
int index();
|
||||
QString findDataSourceName(BandDesignIntf* parentBand);
|
||||
QString calcCondition(DataSourceManager* dataManager);
|
||||
|
||||
private:
|
||||
QVariant m_groupFieldValue;
|
||||
QString m_groupFiledName;
|
||||
@ -86,6 +88,7 @@ public:
|
||||
virtual bool isUnique() const;
|
||||
QColor bandColor() const;
|
||||
virtual bool isFooter() const { return true; }
|
||||
|
||||
private:
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
};
|
||||
|
@ -28,6 +28,7 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrpagefooter.h"
|
||||
|
||||
#include "lrdesignelementsfactory.h"
|
||||
#include "lrglobal.h"
|
||||
#include "lrpagedesignintf.h"
|
||||
@ -35,22 +36,23 @@
|
||||
const QString xmlTag = "PageFooter";
|
||||
|
||||
namespace {
|
||||
LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
LimeReport::BaseDesignIntf* createBand(QObject* owner, LimeReport::BaseDesignIntf* parent)
|
||||
{
|
||||
return new LimeReport::PageFooter(owner, parent);
|
||||
}
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag,
|
||||
LimeReport::ItemAttribs(QObject::tr("Page Footer"),LimeReport::Const::bandTAG),
|
||||
createBand
|
||||
);
|
||||
}
|
||||
xmlTag, LimeReport::ItemAttribs(QObject::tr("Page Footer"), LimeReport::Const::bandTAG),
|
||||
createBand);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
PageFooter::PageFooter(QObject *owner, QGraphicsItem *parent)
|
||||
: BandDesignIntf(LimeReport::BandDesignIntf::PageFooter,xmlTag,owner,parent),
|
||||
m_printOnFirstPage(true), m_printOnLastPage(true), m_removeGap(false)
|
||||
PageFooter::PageFooter(QObject* owner, QGraphicsItem* parent):
|
||||
BandDesignIntf(LimeReport::BandDesignIntf::PageFooter, xmlTag, owner, parent),
|
||||
m_printOnFirstPage(true),
|
||||
m_printOnLastPage(true),
|
||||
m_removeGap(false)
|
||||
{
|
||||
setBandTypeText(tr("Page Footer"));
|
||||
setMarkerColor(bandColor());
|
||||
@ -62,10 +64,7 @@ BaseDesignIntf *PageFooter::createSameTypeItem(QObject *owner, QGraphicsItem *pa
|
||||
return new PageFooter(owner, parent);
|
||||
}
|
||||
|
||||
QColor PageFooter::bandColor() const
|
||||
{
|
||||
return QColor(246,120,12);
|
||||
}
|
||||
QColor PageFooter::bandColor() const { return QColor(246, 120, 12); }
|
||||
|
||||
void PageFooter::preparePopUpMenu(QMenu& menu)
|
||||
{
|
||||
@ -76,7 +75,6 @@ void PageFooter::preparePopUpMenu(QMenu &menu)
|
||||
action = menu.addAction(tr("Print on last page"));
|
||||
action->setCheckable(true);
|
||||
action->setChecked(printOnLastPage());
|
||||
|
||||
}
|
||||
|
||||
void PageFooter::processPopUpAction(QAction* action)
|
||||
@ -90,20 +88,11 @@ void PageFooter::processPopUpAction(QAction *action)
|
||||
BandDesignIntf::processPopUpAction(action);
|
||||
}
|
||||
|
||||
bool PageFooter::removeGap() const
|
||||
{
|
||||
return m_removeGap;
|
||||
}
|
||||
bool PageFooter::removeGap() const { return m_removeGap; }
|
||||
|
||||
void PageFooter::setRemoveGap(bool removeGap)
|
||||
{
|
||||
m_removeGap = removeGap;
|
||||
}
|
||||
void PageFooter::setRemoveGap(bool removeGap) { m_removeGap = removeGap; }
|
||||
|
||||
bool PageFooter::printOnFirstPage() const
|
||||
{
|
||||
return m_printOnFirstPage;
|
||||
}
|
||||
bool PageFooter::printOnFirstPage() const { return m_printOnFirstPage; }
|
||||
|
||||
void PageFooter::setPrintOnFirstPage(bool printOnFirstPage)
|
||||
{
|
||||
@ -115,10 +104,7 @@ void PageFooter::setPrintOnFirstPage(bool printOnFirstPage)
|
||||
}
|
||||
}
|
||||
|
||||
bool PageFooter::printOnLastPage() const
|
||||
{
|
||||
return m_printOnLastPage;
|
||||
}
|
||||
bool PageFooter::printOnLastPage() const { return m_printOnLastPage; }
|
||||
|
||||
void PageFooter::setPrintOnLastPage(bool printOnLastPage)
|
||||
{
|
||||
|
@ -32,11 +32,11 @@
|
||||
|
||||
#include "lrbanddesignintf.h"
|
||||
#include "lrbasedesignintf.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace LimeReport {
|
||||
class PageFooter : public BandDesignIntf
|
||||
{
|
||||
class PageFooter: public BandDesignIntf {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool printOnFirstPage READ printOnFirstPage WRITE setPrintOnFirstPage)
|
||||
Q_PROPERTY(bool printOnLastPage READ printOnLastPage WRITE setPrintOnLastPage)
|
||||
@ -56,11 +56,12 @@ protected:
|
||||
QColor bandColor() const;
|
||||
void preparePopUpMenu(QMenu& menu);
|
||||
void processPopUpAction(QAction* action);
|
||||
|
||||
private:
|
||||
bool m_printOnFirstPage;
|
||||
bool m_printOnLastPage;
|
||||
bool m_removeGap;
|
||||
};
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRPAGEFOOTER_H
|
||||
|
@ -28,32 +28,34 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrpageheader.h"
|
||||
#include "lrdesignelementsfactory.h"
|
||||
|
||||
#include "lrbanddesignintf.h"
|
||||
#include "lrbasedesignintf.h"
|
||||
#include "lrpageitemdesignintf.h"
|
||||
#include "lrdesignelementsfactory.h"
|
||||
#include "lrglobal.h"
|
||||
#include "lrpageitemdesignintf.h"
|
||||
|
||||
const QString xmlTag = "PageHeader";
|
||||
|
||||
namespace {
|
||||
|
||||
LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
LimeReport::BaseDesignIntf* createBand(QObject* owner, LimeReport::BaseDesignIntf* parent)
|
||||
{
|
||||
return new LimeReport::PageHeader(owner, parent);
|
||||
}
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag,
|
||||
LimeReport::ItemAttribs(QObject::tr("Page Header"),LimeReport::Const::bandTAG),
|
||||
createBand
|
||||
);
|
||||
}
|
||||
xmlTag, LimeReport::ItemAttribs(QObject::tr("Page Header"), LimeReport::Const::bandTAG),
|
||||
createBand);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
PageHeader::PageHeader(QObject* owner, QGraphicsItem *parent)
|
||||
: BandDesignIntf(LimeReport::BandDesignIntf::PageHeader,xmlTag,owner,parent),
|
||||
m_printOnFirstPage(true), m_printOnLastPage(true) {
|
||||
PageHeader::PageHeader(QObject* owner, QGraphicsItem* parent):
|
||||
BandDesignIntf(LimeReport::BandDesignIntf::PageHeader, xmlTag, owner, parent),
|
||||
m_printOnFirstPage(true),
|
||||
m_printOnLastPage(true)
|
||||
{
|
||||
setBandTypeText(tr("Page Header"));
|
||||
setMarkerColor(bandColor());
|
||||
}
|
||||
@ -63,29 +65,17 @@ BaseDesignIntf *PageHeader::createSameTypeItem(QObject *owner, QGraphicsItem *pa
|
||||
return new PageHeader(owner, parent);
|
||||
}
|
||||
|
||||
QColor PageHeader::bandColor() const
|
||||
{
|
||||
return QColor(246,120,12);
|
||||
}
|
||||
QColor PageHeader::bandColor() const { return QColor(246, 120, 12); }
|
||||
|
||||
bool PageHeader::printOnLastPage() const
|
||||
{
|
||||
return m_printOnLastPage;
|
||||
}
|
||||
bool PageHeader::printOnLastPage() const { return m_printOnLastPage; }
|
||||
|
||||
void PageHeader::setPrintOnLastPage(bool printOnLastPage)
|
||||
{
|
||||
m_printOnLastPage = printOnLastPage;
|
||||
}
|
||||
void PageHeader::setPrintOnLastPage(bool printOnLastPage) { m_printOnLastPage = printOnLastPage; }
|
||||
|
||||
bool PageHeader::printOnFirstPage() const
|
||||
{
|
||||
return m_printOnFirstPage;
|
||||
}
|
||||
bool PageHeader::printOnFirstPage() const { return m_printOnFirstPage; }
|
||||
|
||||
void PageHeader::setPrintOnFirstPage(bool printOnFirstPage)
|
||||
{
|
||||
m_printOnFirstPage = printOnFirstPage;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
@ -30,13 +30,13 @@
|
||||
#ifndef LRPAGEHEADER_H
|
||||
#define LRPAGEHEADER_H
|
||||
|
||||
#include <QObject>
|
||||
#include "lrbanddesignintf.h"
|
||||
#include "lrbasedesignintf.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace LimeReport {
|
||||
class PageHeader : public LimeReport::BandDesignIntf
|
||||
{
|
||||
class PageHeader: public LimeReport::BandDesignIntf {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool printOnFirstPage READ printOnFirstPage WRITE setPrintOnFirstPage)
|
||||
Q_PROPERTY(bool printOnLastPage READ printOnLastPage WRITE setPrintOnLastPage)
|
||||
@ -47,12 +47,14 @@ public:
|
||||
bool printOnLastPage() const;
|
||||
void setPrintOnLastPage(bool printOnLastPage);
|
||||
bool isHeader() const { return true; }
|
||||
|
||||
protected:
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
QColor bandColor() const;
|
||||
|
||||
private:
|
||||
bool m_printOnFirstPage;
|
||||
bool m_printOnLastPage;
|
||||
};
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRPAGEHEADER_H
|
||||
|
@ -28,6 +28,7 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrreportfooter.h"
|
||||
|
||||
#include "lrdesignelementsfactory.h"
|
||||
#include "lrglobal.h"
|
||||
|
||||
@ -35,20 +36,20 @@ const QString xmlTag ="ReportFooter";
|
||||
|
||||
namespace {
|
||||
|
||||
LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
LimeReport::BaseDesignIntf* createBand(QObject* owner, LimeReport::BaseDesignIntf* parent)
|
||||
{
|
||||
return new LimeReport::ReportFooter(owner, parent);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag,
|
||||
LimeReport::ItemAttribs(QObject::tr("Report Footer"),LimeReport::Const::bandTAG),
|
||||
createBand
|
||||
);
|
||||
}
|
||||
xmlTag, LimeReport::ItemAttribs(QObject::tr("Report Footer"), LimeReport::Const::bandTAG),
|
||||
createBand);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
ReportFooter::ReportFooter(QObject *owner, QGraphicsItem *parent)
|
||||
: BandDesignIntf(LimeReport::BandDesignIntf::ReportFooter,xmlTag,owner,parent) {
|
||||
ReportFooter::ReportFooter(QObject* owner, QGraphicsItem* parent):
|
||||
BandDesignIntf(LimeReport::BandDesignIntf::ReportFooter, xmlTag, owner, parent)
|
||||
{
|
||||
setBandTypeText(tr("Report Footer"));
|
||||
setMarkerColor(bandColor());
|
||||
}
|
||||
@ -58,14 +59,8 @@ BaseDesignIntf *ReportFooter::createSameTypeItem(QObject *owner, QGraphicsItem *
|
||||
return new ReportFooter(owner, parent);
|
||||
}
|
||||
|
||||
QColor ReportFooter::bandColor() const
|
||||
{
|
||||
return QColor(152,69,167);
|
||||
}
|
||||
QColor ReportFooter::bandColor() const { return QColor(152, 69, 167); }
|
||||
|
||||
bool ReportFooter::isFooter() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool ReportFooter::isFooter() const { return true; }
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
@ -30,22 +30,23 @@
|
||||
#ifndef LRREPORTFOOTER_H
|
||||
#define LRREPORTFOOTER_H
|
||||
|
||||
#include <QObject>
|
||||
#include "lrbanddesignintf.h"
|
||||
#include "lrbasedesignintf.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace LimeReport {
|
||||
class ReportFooter : public BandDesignIntf
|
||||
{
|
||||
class ReportFooter: public BandDesignIntf {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int maxScalePercent READ maxScalePercent WRITE setMaxScalePercent)
|
||||
Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable)
|
||||
public:
|
||||
ReportFooter(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
|
||||
protected:
|
||||
QColor bandColor() const;
|
||||
bool isFooter() const;
|
||||
};
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRREPORTFOOTER_H
|
||||
|
@ -28,25 +28,27 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrreportheader.h"
|
||||
|
||||
#include "lrdesignelementsfactory.h"
|
||||
#include "lrglobal.h"
|
||||
|
||||
const QString xmlTag = "ReportHeader";
|
||||
|
||||
namespace {
|
||||
LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
LimeReport::BaseDesignIntf* createBand(QObject* owner, LimeReport::BaseDesignIntf* parent)
|
||||
{
|
||||
return new LimeReport::ReportHeader(owner, parent);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag,
|
||||
LimeReport::ItemAttribs(QObject::tr("Report Header"),LimeReport::Const::bandTAG),
|
||||
createBand
|
||||
);
|
||||
}
|
||||
xmlTag, LimeReport::ItemAttribs(QObject::tr("Report Header"), LimeReport::Const::bandTAG),
|
||||
createBand);
|
||||
} // namespace
|
||||
namespace LimeReport {
|
||||
|
||||
ReportHeader::ReportHeader(QObject *owner, QGraphicsItem *parent)
|
||||
: BandDesignIntf(LimeReport::BandDesignIntf::ReportHeader,xmlTag,owner,parent), m_printBeforePageHeader(false) {
|
||||
ReportHeader::ReportHeader(QObject* owner, QGraphicsItem* parent):
|
||||
BandDesignIntf(LimeReport::BandDesignIntf::ReportHeader, xmlTag, owner, parent),
|
||||
m_printBeforePageHeader(false)
|
||||
{
|
||||
setBandTypeText(tr("Report Header"));
|
||||
setMarkerColor(bandColor());
|
||||
}
|
||||
@ -55,15 +57,9 @@ BaseDesignIntf *ReportHeader::createSameTypeItem(QObject *owner, QGraphicsItem *
|
||||
return new ReportHeader(owner, parent);
|
||||
}
|
||||
|
||||
QColor ReportHeader::bandColor() const
|
||||
{
|
||||
return QColor(152,69,167);
|
||||
}
|
||||
QColor ReportHeader::bandColor() const { return QColor(152, 69, 167); }
|
||||
|
||||
bool ReportHeader::printBeforePageHeader() const
|
||||
{
|
||||
return m_printBeforePageHeader;
|
||||
}
|
||||
bool ReportHeader::printBeforePageHeader() const { return m_printBeforePageHeader; }
|
||||
|
||||
void ReportHeader::setPrintBeforePageHeader(bool printBeforePageHeader)
|
||||
{
|
||||
@ -73,5 +69,4 @@ void ReportHeader::setPrintBeforePageHeader(bool printBeforePageHeader)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -30,13 +30,13 @@
|
||||
#ifndef LRREPORTHEADER_H
|
||||
#define LRREPORTHEADER_H
|
||||
|
||||
#include <QObject>
|
||||
#include "lrbanddesignintf.h"
|
||||
#include "lrbasedesignintf.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace LimeReport {
|
||||
class ReportHeader : public LimeReport::BandDesignIntf
|
||||
{
|
||||
class ReportHeader: public LimeReport::BandDesignIntf {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable)
|
||||
Q_PROPERTY(bool printBeforePageHeader READ printBeforePageHeader WRITE setPrintBeforePageHeader)
|
||||
@ -46,9 +46,10 @@ public:
|
||||
bool printBeforePageHeader() const;
|
||||
void setPrintBeforePageHeader(bool printBeforePageHeader);
|
||||
bool isHeader() const { return true; }
|
||||
|
||||
protected:
|
||||
QColor bandColor() const;
|
||||
bool m_printBeforePageHeader;
|
||||
};
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRREPORTHEADER_H
|
||||
|
@ -28,10 +28,10 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrsubdetailband.h"
|
||||
|
||||
#include "lrdesignelementsfactory.h"
|
||||
#include "lrglobal.h"
|
||||
|
||||
|
||||
const QString xmlTagBand = QLatin1String("SubDetail");
|
||||
const QString xmlTagHeader = QLatin1String("SubDetailHeader");
|
||||
const QString xmlTagFooter = QLatin1String("SubDetailFooter");
|
||||
@ -39,35 +39,36 @@ const QColor BAND_COLOR = Qt::red;
|
||||
|
||||
namespace {
|
||||
|
||||
LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
LimeReport::BaseDesignIntf* createBand(QObject* owner, LimeReport::BaseDesignIntf* parent)
|
||||
{
|
||||
return new LimeReport::SubDetailBand(owner, parent);
|
||||
}
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTagBand,
|
||||
LimeReport::ItemAttribs(QObject::tr("SubDetail"),LimeReport::Const::bandTAG),
|
||||
createBand
|
||||
);
|
||||
xmlTagBand, LimeReport::ItemAttribs(QObject::tr("SubDetail"), LimeReport::Const::bandTAG),
|
||||
createBand);
|
||||
|
||||
LimeReport::BaseDesignIntf * createHeader(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
LimeReport::BaseDesignIntf* createHeader(QObject* owner, LimeReport::BaseDesignIntf* parent)
|
||||
{
|
||||
return new LimeReport::SubDetailHeaderBand(owner, parent);
|
||||
}
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registredHeader = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
bool VARIABLE_IS_NOT_USED registredHeader
|
||||
= LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTagHeader,
|
||||
LimeReport::ItemAttribs(QObject::tr("SubDetailHeader"), LimeReport::Const::bandTAG),
|
||||
createHeader
|
||||
);
|
||||
createHeader);
|
||||
|
||||
LimeReport::BaseDesignIntf * createFooter(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
LimeReport::BaseDesignIntf* createFooter(QObject* owner, LimeReport::BaseDesignIntf* parent)
|
||||
{
|
||||
return new LimeReport::SubDetailFooterBand(owner, parent);
|
||||
}
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registredFooter = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
bool VARIABLE_IS_NOT_USED registredFooter
|
||||
= LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTagFooter,
|
||||
LimeReport::ItemAttribs(QObject::tr("SubDetailFooter"), LimeReport::Const::bandTAG),
|
||||
createFooter
|
||||
);
|
||||
createFooter);
|
||||
|
||||
} // namespace
|
||||
|
||||
@ -75,8 +76,8 @@ namespace LimeReport{
|
||||
|
||||
// SubDetailBand
|
||||
|
||||
SubDetailBand::SubDetailBand(QObject *owner, QGraphicsItem *parent)
|
||||
: DataBandDesignIntf(BandDesignIntf::SubDetailBand, xmlTagBand, owner,parent)
|
||||
SubDetailBand::SubDetailBand(QObject* owner, QGraphicsItem* parent):
|
||||
DataBandDesignIntf(BandDesignIntf::SubDetailBand, xmlTagBand, owner, parent)
|
||||
{
|
||||
setBandTypeText(tr("SubDetail"));
|
||||
setFixedPos(false);
|
||||
@ -98,29 +99,20 @@ BaseDesignIntf *SubDetailBand::createSameTypeItem(QObject *owner, QGraphicsItem
|
||||
return new SubDetailBand(owner, parent);
|
||||
}
|
||||
|
||||
QColor SubDetailBand::bandColor() const
|
||||
{
|
||||
return BAND_COLOR;
|
||||
}
|
||||
QColor SubDetailBand::bandColor() const { return BAND_COLOR; }
|
||||
|
||||
// SubDetailHeaderBand
|
||||
|
||||
SubDetailHeaderBand::SubDetailHeaderBand(QObject *owner, QGraphicsItem *parent)
|
||||
:BandDesignIntf(BandDesignIntf::SubDetailHeader,xmlTagHeader,owner,parent)
|
||||
SubDetailHeaderBand::SubDetailHeaderBand(QObject* owner, QGraphicsItem* parent):
|
||||
BandDesignIntf(BandDesignIntf::SubDetailHeader, xmlTagHeader, owner, parent)
|
||||
{
|
||||
setBandTypeText(tr("SubDetailHeader"));
|
||||
setMarkerColor(bandColor());
|
||||
}
|
||||
|
||||
bool SubDetailHeaderBand::isUnique() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool SubDetailHeaderBand::isUnique() const { return false; }
|
||||
|
||||
QColor SubDetailHeaderBand::bandColor() const
|
||||
{
|
||||
return BAND_COLOR;
|
||||
}
|
||||
QColor SubDetailHeaderBand::bandColor() const { return BAND_COLOR; }
|
||||
|
||||
BaseDesignIntf* SubDetailHeaderBand::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
@ -129,26 +121,19 @@ BaseDesignIntf *SubDetailHeaderBand::createSameTypeItem(QObject *owner, QGraphic
|
||||
|
||||
// SubDetailFooterBand
|
||||
|
||||
SubDetailFooterBand::SubDetailFooterBand(QObject *owner, QGraphicsItem *parent)
|
||||
: BandDesignIntf(BandDesignIntf::SubDetailFooter,xmlTagFooter,owner,parent)
|
||||
SubDetailFooterBand::SubDetailFooterBand(QObject* owner, QGraphicsItem* parent):
|
||||
BandDesignIntf(BandDesignIntf::SubDetailFooter, xmlTagFooter, owner, parent)
|
||||
{
|
||||
setMarkerColor(bandColor());
|
||||
}
|
||||
|
||||
bool SubDetailFooterBand::isUnique() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool SubDetailFooterBand::isUnique() const { return false; }
|
||||
|
||||
QColor SubDetailFooterBand::bandColor() const
|
||||
{
|
||||
return BAND_COLOR;
|
||||
}
|
||||
QColor SubDetailFooterBand::bandColor() const { return BAND_COLOR; }
|
||||
|
||||
BaseDesignIntf* SubDetailFooterBand::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
return new SubDetailFooterBand(owner, parent);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
@ -35,62 +35,71 @@
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
class SubDetailBand : public DataBandDesignIntf
|
||||
{
|
||||
class SubDetailBand: public DataBandDesignIntf {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable)
|
||||
Q_PROPERTY(int columnsCount READ columnsCount WRITE setColumnsCount)
|
||||
Q_PROPERTY(BandColumnsLayoutType columnsFillDirection READ columnsFillDirection WRITE setColumnsFillDirection)
|
||||
Q_PROPERTY(BandColumnsLayoutType columnsFillDirection READ columnsFillDirection WRITE
|
||||
setColumnsFillDirection)
|
||||
Q_PROPERTY(bool keepFooterTogether READ keepFooterTogether WRITE setKeepFooterTogether)
|
||||
Q_PROPERTY(QColor alternateBackgroundColor READ alternateBackgroundColor WRITE setAlternateBackgroundColor)
|
||||
Q_PROPERTY(bool useAlternateBackgroundColor READ useAlternateBackgroundColor WRITE setUseAlternateBackgroundColor)
|
||||
Q_PROPERTY(QColor alternateBackgroundColor READ alternateBackgroundColor WRITE
|
||||
setAlternateBackgroundColor)
|
||||
Q_PROPERTY(bool useAlternateBackgroundColor READ useAlternateBackgroundColor WRITE
|
||||
setUseAlternateBackgroundColor)
|
||||
public:
|
||||
SubDetailBand(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
bool isUnique() const { return false; }
|
||||
int bandNestingLevel() { return 1; }
|
||||
bool isHasHeader() const;
|
||||
bool isHasFooter() const;
|
||||
|
||||
private:
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
|
||||
protected:
|
||||
virtual QColor bandColor() const;
|
||||
};
|
||||
|
||||
class SubDetailHeaderBand : public BandDesignIntf
|
||||
{
|
||||
class SubDetailHeaderBand: public BandDesignIntf {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int columnsCount READ columnsCount WRITE setColumnsCount)
|
||||
Q_PROPERTY(BandColumnsLayoutType columnsFillDirection READ columnsFillDirection WRITE setColumnsFillDirection)
|
||||
Q_PROPERTY(BandColumnsLayoutType columnsFillDirection READ columnsFillDirection WRITE
|
||||
setColumnsFillDirection)
|
||||
Q_PROPERTY(bool printAlways READ printAlways WRITE setPrintAlways)
|
||||
public:
|
||||
SubDetailHeaderBand(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
bool isUnique() const;
|
||||
bool isHeader() const { return true; }
|
||||
int bandNestingLevel() { return 1; }
|
||||
|
||||
protected:
|
||||
QColor bandColor() const;
|
||||
|
||||
private:
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
};
|
||||
|
||||
class SubDetailFooterBand : public BandDesignIntf
|
||||
{
|
||||
class SubDetailFooterBand: public BandDesignIntf {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int columnsCount READ columnsCount WRITE setColumnsCount)
|
||||
Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable)
|
||||
Q_PROPERTY(BandColumnsLayoutType columnsFillDirection READ columnsFillDirection WRITE setColumnsFillDirection)
|
||||
Q_PROPERTY(BandColumnsLayoutType columnsFillDirection READ columnsFillDirection WRITE
|
||||
setColumnsFillDirection)
|
||||
Q_PROPERTY(bool printAlways READ printAlways WRITE setPrintAlways)
|
||||
public:
|
||||
SubDetailFooterBand(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
virtual bool isUnique() const;
|
||||
bool isFooter() const { return true; }
|
||||
int bandNestingLevel() { return 1; }
|
||||
|
||||
protected:
|
||||
QColor bandColor() const;
|
||||
|
||||
private:
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRSUBDETAILBAND_H
|
||||
|
@ -1,24 +1,24 @@
|
||||
#include "lrtearoffband.h"
|
||||
|
||||
#include "lrdesignelementsfactory.h"
|
||||
#include "lrglobal.h"
|
||||
|
||||
const QString xmlTag = "TearOffBand";
|
||||
|
||||
namespace {
|
||||
LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
LimeReport::BaseDesignIntf* createBand(QObject* owner, LimeReport::BaseDesignIntf* parent)
|
||||
{
|
||||
return new LimeReport::TearOffBand(owner, parent);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag,
|
||||
LimeReport::ItemAttribs(QObject::tr("Tear-off Band"),LimeReport::Const::bandTAG),
|
||||
createBand
|
||||
);
|
||||
}
|
||||
xmlTag, LimeReport::ItemAttribs(QObject::tr("Tear-off Band"), LimeReport::Const::bandTAG),
|
||||
createBand);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
TearOffBand::TearOffBand(QObject *owner, QGraphicsItem *parent)
|
||||
:BandDesignIntf(LimeReport::BandDesignIntf::TearOffBand,xmlTag,owner,parent)
|
||||
TearOffBand::TearOffBand(QObject* owner, QGraphicsItem* parent):
|
||||
BandDesignIntf(LimeReport::BandDesignIntf::TearOffBand, xmlTag, owner, parent)
|
||||
{
|
||||
setBandTypeText(tr("Tear-off Band"));
|
||||
setMarkerColor(bandColor());
|
||||
@ -29,9 +29,6 @@ BaseDesignIntf *TearOffBand::createSameTypeItem(QObject *owner, QGraphicsItem *p
|
||||
return new TearOffBand(owner, parent);
|
||||
}
|
||||
|
||||
QColor TearOffBand::bandColor() const
|
||||
{
|
||||
return QColor(200,200,200);
|
||||
}
|
||||
QColor TearOffBand::bandColor() const { return QColor(200, 200, 200); }
|
||||
|
||||
} // namedpace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
@ -4,12 +4,12 @@
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
class TearOffBand : public BandDesignIntf
|
||||
{
|
||||
class TearOffBand: public BandDesignIntf {
|
||||
Q_OBJECT
|
||||
public:
|
||||
TearOffBand(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
|
||||
protected:
|
||||
QColor bandColor() const;
|
||||
bool isUnique() const { return true; }
|
||||
|
@ -30,54 +30,61 @@
|
||||
#ifndef LRATTRIBABSTRACTFACTORY_H
|
||||
#define LRATTRIBABSTRACTFACTORY_H
|
||||
|
||||
#include "lrsingleton.h"
|
||||
#include "lrglobal.h"
|
||||
#include <stdexcept>
|
||||
#include "lrsingleton.h"
|
||||
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
template
|
||||
<
|
||||
typename AbstractProduct,
|
||||
typename IdentifierType,
|
||||
typename ProductCreator,
|
||||
typename Attribs
|
||||
>
|
||||
class AttribsAbstractFactory
|
||||
: public Singleton< AttribsAbstractFactory< AbstractProduct,IdentifierType,ProductCreator,Attribs > >
|
||||
{
|
||||
template <typename AbstractProduct, typename IdentifierType, typename ProductCreator,
|
||||
typename Attribs>
|
||||
class AttribsAbstractFactory:
|
||||
public Singleton<
|
||||
AttribsAbstractFactory<AbstractProduct, IdentifierType, ProductCreator, Attribs>> {
|
||||
private:
|
||||
typedef QMap<IdentifierType, ProductCreator> FactoryMap;
|
||||
typedef QMap<IdentifierType, Attribs> AliasMap;
|
||||
friend class Singleton< AttribsAbstractFactory< AbstractProduct,IdentifierType,ProductCreator,Attribs > >;
|
||||
friend class Singleton<
|
||||
AttribsAbstractFactory<AbstractProduct, IdentifierType, ProductCreator, Attribs>>;
|
||||
|
||||
public:
|
||||
bool registerCreator(const IdentifierType& id, Attribs attribs, ProductCreator creator){
|
||||
if (m_factoryMap.contains(id)) return true;
|
||||
return (m_factoryMap.insert(id,creator).value() == creator) &&
|
||||
(m_attribsMap.insert(id,attribs).value() == attribs);
|
||||
bool registerCreator(const IdentifierType& id, Attribs attribs, ProductCreator creator)
|
||||
{
|
||||
if (m_factoryMap.contains(id))
|
||||
return true;
|
||||
return (m_factoryMap.insert(id, creator).value() == creator)
|
||||
&& (m_attribsMap.insert(id, attribs).value() == attribs);
|
||||
}
|
||||
bool unregisterCreator(const IdentifierType& id){
|
||||
bool unregisterCreator(const IdentifierType& id)
|
||||
{
|
||||
return (m_factoryMap.remove(id) == 1) && (m_attribsMap.remove(id) == 1);
|
||||
}
|
||||
ProductCreator objectCreator(const IdentifierType& id){
|
||||
ProductCreator objectCreator(const IdentifierType& id)
|
||||
{
|
||||
if (m_factoryMap.contains(id)) {
|
||||
return m_factoryMap[id];
|
||||
} else return 0;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
QString attribs(const IdentifierType& id){
|
||||
QString attribs(const IdentifierType& id)
|
||||
{
|
||||
if (m_attribsMap.contains(id)) {
|
||||
return m_attribsMap.value(id);
|
||||
} else return "";
|
||||
} else
|
||||
return "";
|
||||
}
|
||||
const FactoryMap& map() { return m_factoryMap; }
|
||||
const AliasMap& attribsMap() { return m_attribsMap; }
|
||||
int mapElementCount() { return m_factoryMap.count(); }
|
||||
|
||||
private:
|
||||
FactoryMap m_factoryMap;
|
||||
AliasMap m_attribsMap;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRATTRIBABSTRACTFACTORY_H
|
||||
|
@ -30,34 +30,31 @@
|
||||
#ifndef LRSIMPLEABSTRACTFACTORY_H
|
||||
#define LRSIMPLEABSTRACTFACTORY_H
|
||||
|
||||
#include "lrsingleton.h"
|
||||
#include "lrglobal.h"
|
||||
#include <stdexcept>
|
||||
#include "lrsingleton.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
|
||||
#include <stdexcept>
|
||||
namespace LimeReport {
|
||||
|
||||
template
|
||||
<
|
||||
typename AbstractProduct,
|
||||
typename IdentifierType,
|
||||
typename ProductCreator
|
||||
>
|
||||
class SimpleAbstractFactory
|
||||
: public Singleton< SimpleAbstractFactory< AbstractProduct,IdentifierType,ProductCreator > >
|
||||
{
|
||||
template <typename AbstractProduct, typename IdentifierType, typename ProductCreator>
|
||||
class SimpleAbstractFactory:
|
||||
public Singleton<SimpleAbstractFactory<AbstractProduct, IdentifierType, ProductCreator>> {
|
||||
private:
|
||||
typedef QHash<IdentifierType, ProductCreator> FactoryMap;
|
||||
friend class Singleton<SimpleAbstractFactory<AbstractProduct, IdentifierType, ProductCreator>>;
|
||||
|
||||
public:
|
||||
bool registerCreator(const IdentifierType& id, ProductCreator creator){
|
||||
bool registerCreator(const IdentifierType& id, ProductCreator creator)
|
||||
{
|
||||
return (m_factoryMap.insert(id, creator).value() == creator);
|
||||
}
|
||||
bool unregisterCreator(const IdentifierType& id){
|
||||
return (m_factoryMap.remove(id)==1);
|
||||
}
|
||||
ProductCreator objectCreator(const IdentifierType& id){
|
||||
bool unregisterCreator(const IdentifierType& id) { return (m_factoryMap.remove(id) == 1); }
|
||||
ProductCreator objectCreator(const IdentifierType& id)
|
||||
{
|
||||
if (m_factoryMap.contains(id)) {
|
||||
return m_factoryMap[id];
|
||||
} else {
|
||||
@ -66,38 +63,43 @@ public:
|
||||
}
|
||||
const FactoryMap& map() { return m_factoryMap; }
|
||||
int mapElementCount() { return m_factoryMap.count(); }
|
||||
|
||||
private:
|
||||
FactoryMap m_factoryMap;
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename AbstractProduct,
|
||||
typename IdentifierType,
|
||||
typename ProductCreator,
|
||||
typename Attribs
|
||||
>
|
||||
class AttribAbstractFactory : public SimpleAbstractFactory< AbstractProduct,IdentifierType,ProductCreator >{
|
||||
template <typename AbstractProduct, typename IdentifierType, typename ProductCreator,
|
||||
typename Attribs>
|
||||
class AttribAbstractFactory:
|
||||
public SimpleAbstractFactory<AbstractProduct, IdentifierType, ProductCreator> {
|
||||
typedef SimpleAbstractFactory<AbstractProduct, IdentifierType, ProductCreator> SimpleFactory;
|
||||
typedef QMap<IdentifierType, Attribs> AliasMap;
|
||||
friend class Singleton<AttribAbstractFactory< AbstractProduct,IdentifierType,ProductCreator,Attribs > >;
|
||||
friend class Singleton<
|
||||
AttribAbstractFactory<AbstractProduct, IdentifierType, ProductCreator, Attribs>>;
|
||||
|
||||
public:
|
||||
bool registerCreator(const IdentifierType &id, Attribs attribs, ProductCreator creator){
|
||||
return SimpleFactory::registerCreator(id,creator) && (m_attribsMap.insert(id,attribs).value()==attribs);
|
||||
bool registerCreator(const IdentifierType& id, Attribs attribs, ProductCreator creator)
|
||||
{
|
||||
return SimpleFactory::registerCreator(id, creator)
|
||||
&& (m_attribsMap.insert(id, attribs).value() == attribs);
|
||||
}
|
||||
bool unregisterCreator(const IdentifierType &id){
|
||||
bool unregisterCreator(const IdentifierType& id)
|
||||
{
|
||||
return SimpleFactory::unregisterCreator(id) && (m_attribsMap.remove(id) == 1);
|
||||
}
|
||||
QString attribs(const IdentifierType& id){
|
||||
QString attribs(const IdentifierType& id)
|
||||
{
|
||||
if (m_attribsMap.contains(id)) {
|
||||
return m_attribsMap.value(id);
|
||||
} else return "";
|
||||
} else
|
||||
return "";
|
||||
}
|
||||
const AliasMap& attribsMap() { return m_attribsMap; }
|
||||
|
||||
private:
|
||||
AliasMap m_attribsMap;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRSIMPLEABSTRACTFACTORY_H
|
||||
|
@ -34,26 +34,25 @@
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
template <typename T>
|
||||
class Singleton
|
||||
{
|
||||
template <typename T> class Singleton {
|
||||
public:
|
||||
static T& instance(){
|
||||
static T& instance()
|
||||
{
|
||||
if (0 == inst) {
|
||||
inst = new T();
|
||||
::atexit(destroy);
|
||||
} else {};
|
||||
} else {
|
||||
};
|
||||
return *inst;
|
||||
}
|
||||
|
||||
private:
|
||||
static T* inst;
|
||||
|
||||
private:
|
||||
static void destroy() {
|
||||
delete inst;
|
||||
}
|
||||
static void destroy() { delete inst; }
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
T* Singleton< T >::inst =0;
|
||||
}
|
||||
template <typename T> T* Singleton<T>::inst = 0;
|
||||
} // namespace LimeReport
|
||||
#endif // LRSINGLETON_H
|
||||
|
@ -29,29 +29,33 @@
|
||||
****************************************************************************/
|
||||
#include "lrconnectiondialog.h"
|
||||
#include "ui_lrconnectiondialog.h"
|
||||
|
||||
#include "lrglobal.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QSqlDatabase>
|
||||
#include <QSqlError>
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <QFileDialog>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
ConnectionDialog::ConnectionDialog(LimeReport::IConnectionController *conControl, LimeReport::ConnectionDesc* connectionDesc, QWidget *parent) :
|
||||
ConnectionDialog::ConnectionDialog(LimeReport::IConnectionController* conControl,
|
||||
LimeReport::ConnectionDesc* connectionDesc, QWidget* parent):
|
||||
QDialog(parent),
|
||||
ui(new Ui::ConnectionDialog), m_connection(connectionDesc), m_controller(conControl), m_savedConnectionName("")
|
||||
ui(new Ui::ConnectionDialog),
|
||||
m_connection(connectionDesc),
|
||||
m_controller(conControl),
|
||||
m_savedConnectionName("")
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
m_changeMode = m_connection != 0;
|
||||
}
|
||||
|
||||
ConnectionDialog::~ConnectionDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
ConnectionDialog::~ConnectionDialog() { delete ui; }
|
||||
|
||||
void ConnectionDialog::init()
|
||||
{
|
||||
@ -59,24 +63,21 @@ void ConnectionDialog::init()
|
||||
ui->cbbUseDefaultConnection->setEnabled(!m_controller->containsDefaultConnection());
|
||||
}
|
||||
|
||||
void ConnectionDialog::showEvent(QShowEvent *)
|
||||
{
|
||||
connectionToUI();
|
||||
}
|
||||
void ConnectionDialog::showEvent(QShowEvent*) { connectionToUI(); }
|
||||
|
||||
void ConnectionDialog::slotAccept()
|
||||
{
|
||||
try {
|
||||
checkFieldsFill();
|
||||
if (ui->cbAutoConnect->isChecked()) checkConnection();
|
||||
if (ui->cbAutoConnect->isChecked())
|
||||
checkConnection();
|
||||
if (!m_connection) {
|
||||
m_controller->addConnectionDesc(uiToConnection());
|
||||
} else {
|
||||
m_controller->changeConnectionDesc(uiToConnection(m_connection));
|
||||
}
|
||||
close();
|
||||
}
|
||||
catch(LimeReport::ReportError &exception){
|
||||
} catch (LimeReport::ReportError& exception) {
|
||||
QMessageBox::critical(this, tr("Error"), exception.what());
|
||||
}
|
||||
}
|
||||
@ -85,7 +86,8 @@ void ConnectionDialog::slotCheckConnection()
|
||||
{
|
||||
try {
|
||||
checkConnection();
|
||||
QMessageBox::information(this,tr("Connection"),tr("Connection succsesfully established!"));
|
||||
QMessageBox::information(this, tr("Connection"),
|
||||
tr("Connection succsesfully established!"));
|
||||
} catch (LimeReport::ReportError& exception) {
|
||||
QMessageBox::critical(this, tr("Error"), exception.what());
|
||||
}
|
||||
@ -93,9 +95,12 @@ void ConnectionDialog::slotCheckConnection()
|
||||
|
||||
void ConnectionDialog::checkFieldsFill()
|
||||
{
|
||||
if (ui->leConnectionName->text().isEmpty()){throw LimeReport::ReportError(tr("Connection Name is empty"));}
|
||||
if (ui->leConnectionName->text().isEmpty()) {
|
||||
throw LimeReport::ReportError(tr("Connection Name is empty"));
|
||||
}
|
||||
if (!m_changeMode && QSqlDatabase::connectionNames().contains(ui->leConnectionName->text())) {
|
||||
throw LimeReport::ReportError(tr("Connection with name ")+ui->leConnectionName->text()+tr(" already exists! "));
|
||||
throw LimeReport::ReportError(tr("Connection with name ") + ui->leConnectionName->text()
|
||||
+ tr(" already exists! "));
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,9 +136,11 @@ ConnectionDesc *ConnectionDialog::uiToConnection(LimeReport::ConnectionDesc* con
|
||||
void ConnectionDialog::connectionToUI()
|
||||
{
|
||||
init();
|
||||
if (!m_connection) return;
|
||||
if (!m_connection)
|
||||
return;
|
||||
ui->leConnectionName->setText(ConnectionDesc::connectionNameForUser(m_connection->name()));
|
||||
ui->cbbUseDefaultConnection->setChecked(m_connection->name().compare(QSqlDatabase::defaultConnection) == 0);
|
||||
ui->cbbUseDefaultConnection->setChecked(
|
||||
m_connection->name().compare(QSqlDatabase::defaultConnection) == 0);
|
||||
ui->leDataBase->setText(m_connection->databaseName());
|
||||
ui->leServerName->setText(m_connection->host());
|
||||
ui->leUserName->setText(m_connection->userName());
|
||||
@ -166,10 +173,3 @@ void ConnectionDialog::on_toolButton_2_toggled(bool checked)
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -30,21 +30,23 @@
|
||||
#ifndef LRCONNECTIONDIALOG_H
|
||||
#define LRCONNECTIONDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "lrdatadesignintf.h"
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
namespace Ui {
|
||||
class ConnectionDialog;
|
||||
}
|
||||
|
||||
class ConnectionDialog : public QDialog
|
||||
{
|
||||
class ConnectionDialog: public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ConnectionDialog(LimeReport::IConnectionController* conControl, LimeReport::ConnectionDesc* connectionDesc=0, QWidget *parent = 0);
|
||||
explicit ConnectionDialog(LimeReport::IConnectionController* conControl,
|
||||
LimeReport::ConnectionDesc* connectionDesc = 0, QWidget* parent = 0);
|
||||
~ConnectionDialog();
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent*);
|
||||
void init();
|
||||
|
@ -27,31 +27,36 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
#include <QtSql/QSqlDatabase>
|
||||
#include <QtSql/QSqlQuery>
|
||||
#include <QtSql/QSqlQueryModel>
|
||||
#include <QtSql/QSqlError>
|
||||
#include <QFileInfo>
|
||||
#include <QTableView>
|
||||
#include <QDockWidget>
|
||||
#include <QMainWindow>
|
||||
#include "ui_lrdatabrowser.h"
|
||||
|
||||
#include "lrdatabrowser.h"
|
||||
#include "lrsqleditdialog.h"
|
||||
#include "lrconnectiondialog.h"
|
||||
#include "lrdatabrowser.h"
|
||||
#include "lrreportengine_p.h"
|
||||
#include "lrsqleditdialog.h"
|
||||
#include "lrvariabledialog.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDockWidget>
|
||||
#include <QFileInfo>
|
||||
#include <QHBoxLayout>
|
||||
#include <QMainWindow>
|
||||
#include <QMessageBox>
|
||||
#include <QTableView>
|
||||
#include <QVBoxLayout>
|
||||
#include <QtSql/QSqlDatabase>
|
||||
#include <QtSql/QSqlError>
|
||||
#include <QtSql/QSqlQuery>
|
||||
#include <QtSql/QSqlQueryModel>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
DataBrowser::DataBrowser(QWidget* parent):
|
||||
QWidget(parent),
|
||||
ui(new Ui::DataBrowser), m_report(0), m_closingWindows(false), m_settings(0), m_ownedSettings(false)
|
||||
ui(new Ui::DataBrowser),
|
||||
m_report(0),
|
||||
m_closingWindows(false),
|
||||
m_settings(0),
|
||||
m_ownedSettings(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->addConnection, SIGNAL(clicked()), this, SLOT(slotAddConnection()));
|
||||
@ -76,10 +81,7 @@ DataBrowser::~DataBrowser()
|
||||
if (m_settings && m_ownedSettings)
|
||||
delete m_settings;
|
||||
}
|
||||
QSize DataBrowser::sizeHint() const
|
||||
{
|
||||
return QSize(100,200);
|
||||
}
|
||||
QSize DataBrowser::sizeHint() const { return QSize(100, 200); }
|
||||
|
||||
void DataBrowser::slotAddConnection()
|
||||
{
|
||||
@ -108,15 +110,11 @@ void DataBrowser::slotSQLEditingFinished(SQLEditResult result)
|
||||
void DataBrowser::slotDeleteConnection()
|
||||
{
|
||||
if (!getConnectionName(NameForUser).isEmpty()) {
|
||||
if (
|
||||
QMessageBox::critical(
|
||||
this,
|
||||
tr("Attention"),
|
||||
tr("Do you really want to delete \"%1\" connection?").arg(getConnectionName(NameForUser)),
|
||||
QMessageBox::Ok|QMessageBox::No,
|
||||
QMessageBox::No
|
||||
) == QMessageBox::Ok
|
||||
){
|
||||
if (QMessageBox::critical(this, tr("Attention"),
|
||||
tr("Do you really want to delete \"%1\" connection?")
|
||||
.arg(getConnectionName(NameForUser)),
|
||||
QMessageBox::Ok | QMessageBox::No, QMessageBox::No)
|
||||
== QMessageBox::Ok) {
|
||||
m_report->dataManager()->removeConnection(getConnectionName(NameForReport));
|
||||
updateDataTree();
|
||||
}
|
||||
@ -125,7 +123,8 @@ void DataBrowser::slotDeleteConnection()
|
||||
|
||||
void DataBrowser::slotAddDataSource()
|
||||
{
|
||||
SQLEditDialog *sqlEdit = new SQLEditDialog(this,m_report->dataManager(),SQLEditDialog::AddMode);
|
||||
SQLEditDialog* sqlEdit
|
||||
= new SQLEditDialog(this, m_report->dataManager(), SQLEditDialog::AddMode);
|
||||
sqlEdit->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
#ifdef Q_OS_MAC
|
||||
sqlEdit->setWindowModality(Qt::WindowModal);
|
||||
@ -135,7 +134,8 @@ void DataBrowser::slotAddDataSource()
|
||||
sqlEdit->setSettings(settings());
|
||||
sqlEdit->setDataSources(m_report->dataManager());
|
||||
sqlEdit->setDefaultConnection(getConnectionName(NameForReport));
|
||||
connect(sqlEdit,SIGNAL(signalSqlEditingFinished(SQLEditResult)),this,SLOT(slotSQLEditingFinished(SQLEditResult)));
|
||||
connect(sqlEdit, SIGNAL(signalSqlEditingFinished(SQLEditResult)), this,
|
||||
SLOT(slotSQLEditingFinished(SQLEditResult)));
|
||||
sqlEdit->exec();
|
||||
}
|
||||
|
||||
@ -153,14 +153,16 @@ void DataBrowser::updateDataTree()
|
||||
|
||||
foreach (QString dataSourceName, m_report->datasourcesNames()) {
|
||||
|
||||
QTreeWidgetItem *item=new QTreeWidgetItem(QStringList(dataSourceName),DataBrowserTree::Table);
|
||||
QTreeWidgetItem *parentItem = findByNameAndType(
|
||||
ConnectionDesc::connectionNameForUser(m_report->dataManager()->connectionName(dataSourceName)),
|
||||
DataBrowserTree::Connection
|
||||
);
|
||||
QTreeWidgetItem* item
|
||||
= new QTreeWidgetItem(QStringList(dataSourceName), DataBrowserTree::Table);
|
||||
QTreeWidgetItem* parentItem
|
||||
= findByNameAndType(ConnectionDesc::connectionNameForUser(
|
||||
m_report->dataManager()->connectionName(dataSourceName)),
|
||||
DataBrowserTree::Connection);
|
||||
if (parentItem) {
|
||||
parentItem->addChild(item);
|
||||
if (!parentItem->isExpanded()) ui->dataTree->expandItem(parentItem);
|
||||
if (!parentItem->isExpanded())
|
||||
ui->dataTree->expandItem(parentItem);
|
||||
} else {
|
||||
ui->dataTree->addTopLevelItem(item);
|
||||
}
|
||||
@ -174,7 +176,8 @@ void DataBrowser::updateDataTree()
|
||||
else
|
||||
item->setIcon(0, QIcon(":/databrowser/images/table_error"));
|
||||
|
||||
} else item->setIcon(0,QIcon(":/databrowser/images/table_error"));
|
||||
} else
|
||||
item->setIcon(0, QIcon(":/databrowser/images/table_error"));
|
||||
|
||||
} catch (ReportError& /*exception*/) {
|
||||
item->setIcon(0, QIcon(":/databrowser/images/table_error"));
|
||||
@ -192,11 +195,14 @@ void DataBrowser::updateDataTree()
|
||||
void DataBrowser::updateVariablesTree()
|
||||
{
|
||||
ui->variablesTree->clear();
|
||||
QTreeWidgetItem *reportVariables = new QTreeWidgetItem(QStringList(tr("Report variables")),DataBrowserTree::Category);
|
||||
QTreeWidgetItem* reportVariables
|
||||
= new QTreeWidgetItem(QStringList(tr("Report variables")), DataBrowserTree::Category);
|
||||
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"));
|
||||
QTreeWidgetItem *externalVariables = new QTreeWidgetItem(QStringList(tr("External variables")),DataBrowserTree::Category);
|
||||
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);
|
||||
@ -204,10 +210,10 @@ void DataBrowser::updateVariablesTree()
|
||||
|
||||
foreach (QString variableName, m_report->dataManager()->variableNames()) {
|
||||
QStringList values;
|
||||
values<<variableName+((m_report->dataManager()->variableIsSystem(variableName))?
|
||||
"":
|
||||
" ["+m_report->dataManager()->variable(variableName).toString()+"]"
|
||||
)
|
||||
values << variableName
|
||||
+ ((m_report->dataManager()->variableIsSystem(variableName))
|
||||
? ""
|
||||
: " [" + m_report->dataManager()->variable(variableName).toString() + "]")
|
||||
<< variableName;
|
||||
QTreeWidgetItem* item = new QTreeWidgetItem(values, DataBrowserTree::Variable);
|
||||
item->setIcon(0, QIcon(":/databrowser/images/value"));
|
||||
@ -221,7 +227,8 @@ void DataBrowser::updateVariablesTree()
|
||||
foreach (QString variableName, m_report->dataManager()->userVariableNames()) {
|
||||
if (!m_report->dataManager()->variableNames().contains(variableName)) {
|
||||
QStringList values;
|
||||
values<<variableName+" ["+m_report->dataManager()->variable(variableName).toString()+"]"
|
||||
values << variableName + " ["
|
||||
+ m_report->dataManager()->variable(variableName).toString() + "]"
|
||||
<< variableName;
|
||||
QTreeWidgetItem* item = new QTreeWidgetItem(values, DataBrowserTree::ExternalVariable);
|
||||
item->setIcon(0, QIcon(":/databrowser/images/value"));
|
||||
@ -248,7 +255,8 @@ void DataBrowser::closeAllDataWindows()
|
||||
|
||||
void DataBrowser::setSettings(QSettings* value, bool owned)
|
||||
{
|
||||
if (m_settings && m_ownedSettings) delete m_settings;
|
||||
if (m_settings && m_ownedSettings)
|
||||
delete m_settings;
|
||||
m_settings = value;
|
||||
m_ownedSettings = owned;
|
||||
}
|
||||
@ -264,16 +272,15 @@ QSettings *DataBrowser::settings()
|
||||
}
|
||||
}
|
||||
|
||||
void DataBrowser::slotDatasourcesChanged()
|
||||
{
|
||||
updateDataTree();
|
||||
}
|
||||
void DataBrowser::slotDatasourcesChanged() { updateDataTree(); }
|
||||
|
||||
void DataBrowser::fillFields(QTreeWidgetItem* parentItem, LimeReport::IDataSource* dataSource)
|
||||
{
|
||||
if (!dataSource) return;
|
||||
if (!dataSource)
|
||||
return;
|
||||
for (int i = 0; i < dataSource->columnCount(); i++) {
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(QStringList(dataSource->columnNameByIndex(i)),DataBrowserTree::Row);
|
||||
QTreeWidgetItem* item = new QTreeWidgetItem(QStringList(dataSource->columnNameByIndex(i)),
|
||||
DataBrowserTree::Row);
|
||||
item->setIcon(0, QIcon(":/databrowser/images/field"));
|
||||
parentItem->addChild(item);
|
||||
}
|
||||
@ -282,11 +289,15 @@ void DataBrowser::fillFields(QTreeWidgetItem *parentItem, LimeReport::IDataSourc
|
||||
|
||||
QTreeWidgetItem* DataBrowser::findByNameAndType(QString name, int itemType)
|
||||
{
|
||||
if (name.isEmpty()) return 0;
|
||||
QList<QTreeWidgetItem *>items = ui->dataTree->findItems(name,Qt::MatchContains | Qt::MatchRecursive);
|
||||
if (name.isEmpty())
|
||||
return 0;
|
||||
QList<QTreeWidgetItem*> items
|
||||
= ui->dataTree->findItems(name, Qt::MatchContains | Qt::MatchRecursive);
|
||||
if (!items.isEmpty()) {
|
||||
for (int i = 0; i < items.count(); i++) {
|
||||
if ( (items.at(i)->type()==itemType)/* && (items.at(0)->text(0)==name)*/){ return items.at(i);}
|
||||
if ((items.at(i)->type() == itemType) /* && (items.at(0)->text(0)==name)*/) {
|
||||
return items.at(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@ -303,13 +314,16 @@ void DataBrowser::slotViewDatasource()
|
||||
QString DataBrowser::getDatasourceName()
|
||||
{
|
||||
if (ui->dataTree->currentItem()) {
|
||||
if (ui->dataTree->currentItem()->type() == DataBrowserTree::Table) return ui->dataTree->currentItem()->text(0);
|
||||
if (ui->dataTree->currentItem()->type() == DataBrowserTree::Row) return ui->dataTree->currentItem()->parent()->text(0);
|
||||
if (ui->dataTree->currentItem()->type() == DataBrowserTree::Table)
|
||||
return ui->dataTree->currentItem()->text(0);
|
||||
if (ui->dataTree->currentItem()->type() == DataBrowserTree::Row)
|
||||
return ui->dataTree->currentItem()->parent()->text(0);
|
||||
};
|
||||
return QString();
|
||||
}
|
||||
|
||||
QTreeWidgetItem* findConnectionItem(QTreeWidgetItem* item){
|
||||
QTreeWidgetItem* findConnectionItem(QTreeWidgetItem* item)
|
||||
{
|
||||
if (item->type() == DataBrowserTree::Connection) {
|
||||
return item;
|
||||
} else {
|
||||
@ -331,19 +345,17 @@ QString DataBrowser::getConnectionName(NameType nameType)
|
||||
case NameForReport:
|
||||
return ConnectionDesc::connectionNameForReport(ci->text(0));
|
||||
}
|
||||
}
|
||||
else return QString();
|
||||
} else
|
||||
return QString();
|
||||
};
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString DataBrowser::getVariable()
|
||||
{
|
||||
if(
|
||||
ui->variablesTree->currentItem() &&
|
||||
(ui->variablesTree->currentItem()->type() == DataBrowserTree::Variable ||
|
||||
ui->variablesTree->currentItem()->type() == DataBrowserTree::ExternalVariable)
|
||||
){
|
||||
if (ui->variablesTree->currentItem()
|
||||
&& (ui->variablesTree->currentItem()->type() == DataBrowserTree::Variable
|
||||
|| ui->variablesTree->currentItem()->type() == DataBrowserTree::ExternalVariable)) {
|
||||
return ui->variablesTree->currentItem()->text(1);
|
||||
}
|
||||
return QString();
|
||||
@ -353,7 +365,8 @@ void DataBrowser::slotEditDatasource()
|
||||
{
|
||||
if (!getDatasourceName().isEmpty()) {
|
||||
closeDataWindow(getDatasourceName());
|
||||
SQLEditDialog *sqlEdit = new SQLEditDialog(this,m_report->dataManager(),SQLEditDialog::EditMode);
|
||||
SQLEditDialog* sqlEdit
|
||||
= new SQLEditDialog(this, m_report->dataManager(), SQLEditDialog::EditMode);
|
||||
sqlEdit->setAttribute(Qt::WA_DeleteOnClose);
|
||||
#ifdef Q_OS_MAC
|
||||
sqlEdit->setWindowModality(Qt::WindowModal);
|
||||
@ -362,7 +375,8 @@ void DataBrowser::slotEditDatasource()
|
||||
#endif
|
||||
sqlEdit->setSettings(settings());
|
||||
sqlEdit->setDataSources(m_report->dataManager(), getDatasourceName());
|
||||
connect(sqlEdit,SIGNAL(signalSqlEditingFinished(SQLEditResult)),this,SLOT(slotSQLEditingFinished(SQLEditResult)));
|
||||
connect(sqlEdit, SIGNAL(signalSqlEditingFinished(SQLEditResult)), this,
|
||||
SLOT(slotSQLEditingFinished(SQLEditResult)));
|
||||
sqlEdit->exec();
|
||||
}
|
||||
}
|
||||
@ -372,15 +386,11 @@ void DataBrowser::slotDeleteDatasource()
|
||||
QString datasourceName = getDatasourceName();
|
||||
QTreeWidgetItem* item = findByNameAndType(datasourceName, DataBrowserTree::Table);
|
||||
if (item) {
|
||||
if (
|
||||
QMessageBox::critical(
|
||||
this,
|
||||
tr("Attention"),
|
||||
if (QMessageBox::critical(
|
||||
this, tr("Attention"),
|
||||
tr("Do you really want to delete \"%1\" datasource?").arg(datasourceName),
|
||||
QMessageBox::Ok|QMessageBox::No,
|
||||
QMessageBox::No
|
||||
) == QMessageBox::Ok
|
||||
){
|
||||
QMessageBox::Ok | QMessageBox::No, QMessageBox::No)
|
||||
== QMessageBox::Ok) {
|
||||
removeDatasource(datasourceName);
|
||||
}
|
||||
}
|
||||
@ -390,7 +400,8 @@ void DataBrowser::setReportEditor(LimeReport::ReportDesignWidget *report)
|
||||
{
|
||||
m_report = report;
|
||||
connect(m_report, SIGNAL(cleared()), this, SLOT(slotClear()));
|
||||
connect(m_report->dataManager(), SIGNAL(datasourcesChanged()), this, SLOT(slotDatasourcesChanged()));
|
||||
connect(m_report->dataManager(), SIGNAL(datasourcesChanged()), this,
|
||||
SLOT(slotDatasourcesChanged()));
|
||||
updateDataTree();
|
||||
updateVariablesTree();
|
||||
}
|
||||
@ -398,7 +409,8 @@ void DataBrowser::setReportEditor(LimeReport::ReportDesignWidget *report)
|
||||
void DataBrowser::slotClear()
|
||||
{
|
||||
ui->dataTree->clear();
|
||||
foreach(QDockWidget* window,m_dataWindows.values()) window->close();
|
||||
foreach (QDockWidget* window, m_dataWindows.values())
|
||||
window->close();
|
||||
updateDataTree();
|
||||
updateVariablesTree();
|
||||
}
|
||||
@ -417,12 +429,10 @@ void DataBrowser::initConnections()
|
||||
std::sort(connections.begin(), connections.end());
|
||||
foreach (QString connectionName, connections) {
|
||||
QTreeWidgetItem* item = new QTreeWidgetItem(
|
||||
ui->dataTree,
|
||||
QStringList(ConnectionDesc::connectionNameForUser(connectionName)),
|
||||
DataBrowserTree::Connection
|
||||
);
|
||||
if (!m_report->dataManager()->connectionNames().contains(ConnectionDesc::connectionNameForReport(connectionName), Qt::CaseInsensitive))
|
||||
{
|
||||
ui->dataTree, QStringList(ConnectionDesc::connectionNameForUser(connectionName)),
|
||||
DataBrowserTree::Connection);
|
||||
if (!m_report->dataManager()->connectionNames().contains(
|
||||
ConnectionDesc::connectionNameForReport(connectionName), Qt::CaseInsensitive)) {
|
||||
item->setIcon(0, QIcon(":/databrowser/images/database_connected"));
|
||||
} else {
|
||||
if (m_report->dataManager()->isConnectionConnected(connectionName))
|
||||
@ -433,7 +443,6 @@ void DataBrowser::initConnections()
|
||||
items.append(item);
|
||||
}
|
||||
|
||||
|
||||
// foreach (QString connectionName, connections) {
|
||||
// QTreeWidgetItem *item=new QTreeWidgetItem(
|
||||
// ui->dataTree,
|
||||
@ -470,7 +479,8 @@ QDockWidget *DataBrowser::createDataWindow(QString datasourceName)
|
||||
|
||||
try {
|
||||
IDataSourceHolder* holder = m_report->dataManager()->dataSourceHolder(datasourceName);
|
||||
if (holder) holder->update();
|
||||
if (holder)
|
||||
holder->update();
|
||||
IDataSource* datasource = m_report->dataManager()->dataSource(datasourceName);
|
||||
if (datasource) {
|
||||
tableView->setModel(datasource->model());
|
||||
@ -497,17 +507,16 @@ QDockWidget *DataBrowser::dataWindow(QString datasourceName)
|
||||
{
|
||||
if (m_dataWindows.contains(datasourceName)) {
|
||||
return m_dataWindows.value(datasourceName);
|
||||
} else return createDataWindow(datasourceName);
|
||||
} else
|
||||
return createDataWindow(datasourceName);
|
||||
}
|
||||
|
||||
void DataBrowser::setMainWindow(QMainWindow *mainWindow)
|
||||
{
|
||||
m_mainWindow=mainWindow;
|
||||
}
|
||||
void DataBrowser::setMainWindow(QMainWindow* mainWindow) { m_mainWindow = mainWindow; }
|
||||
|
||||
void DataBrowser::slotDataWindowClosed()
|
||||
{
|
||||
if (isClosingWindows()) return;
|
||||
if (isClosingWindows())
|
||||
return;
|
||||
for (int i = 0; i < m_dataWindows.count(); i++) {
|
||||
if (m_dataWindows.values().at(i) == sender()) {
|
||||
m_dataWindows.remove(m_dataWindows.keys().at(i));
|
||||
@ -519,10 +528,8 @@ void DataBrowser::slotChangeConnection()
|
||||
{
|
||||
if (!getConnectionName(NameForUser).isEmpty()) {
|
||||
ConnectionDialog* connectionEdit = new ConnectionDialog(
|
||||
this,
|
||||
m_report->dataManager()->connectionByName(getConnectionName(NameForReport)),
|
||||
this
|
||||
);
|
||||
this, m_report->dataManager()->connectionByName(getConnectionName(NameForReport)),
|
||||
this);
|
||||
connectionEdit->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
#ifdef Q_OS_MAC
|
||||
connectionEdit->setWindowModality(Qt::WindowModal);
|
||||
@ -558,7 +565,8 @@ void DataBrowser::slotChangeConnectionState()
|
||||
void DataBrowser::slotVariableEditorAccept(const QString& variable)
|
||||
{
|
||||
updateVariablesTree();
|
||||
QList<QTreeWidgetItem*> items = ui->variablesTree->findItems(variable, Qt::MatchContains | Qt::MatchRecursive);
|
||||
QList<QTreeWidgetItem*> items
|
||||
= ui->variablesTree->findItems(variable, Qt::MatchContains | Qt::MatchRecursive);
|
||||
if (!items.isEmpty()) {
|
||||
ui->variablesTree->setCurrentItem(items.at(0));
|
||||
}
|
||||
@ -607,7 +615,8 @@ void DataBrowser::changeQuery(SQLEditResult result)
|
||||
void DataBrowser::addSubQuery(SQLEditResult result)
|
||||
{
|
||||
try {
|
||||
m_report->dataManager()->addSubQuery(result.datasourceName, result.sql, result.connectionName, result.masterDatasource);
|
||||
m_report->dataManager()->addSubQuery(result.datasourceName, result.sql,
|
||||
result.connectionName, result.masterDatasource);
|
||||
} catch (ReportError& exception) {
|
||||
qDebug() << exception.what();
|
||||
}
|
||||
@ -626,7 +635,8 @@ void DataBrowser::changeSubQuery(SQLEditResult result)
|
||||
void DataBrowser::addProxy(SQLEditResult result)
|
||||
{
|
||||
try {
|
||||
m_report->dataManager()->addProxy(result.datasourceName,result.masterDatasource,result.childDataSource,result.fieldMap);
|
||||
m_report->dataManager()->addProxy(result.datasourceName, result.masterDatasource,
|
||||
result.childDataSource, result.fieldMap);
|
||||
} catch (ReportError& exception) {
|
||||
qDebug() << exception.what();
|
||||
}
|
||||
@ -645,12 +655,8 @@ void DataBrowser::changeProxy(SQLEditResult result)
|
||||
void DataBrowser::addCSV(SQLEditResult result)
|
||||
{
|
||||
try {
|
||||
m_report->dataManager()->addCSV(
|
||||
result.datasourceName,
|
||||
result.csv,
|
||||
result.separator,
|
||||
result.firstRowIsHeader
|
||||
);
|
||||
m_report->dataManager()->addCSV(result.datasourceName, result.csv, result.separator,
|
||||
result.firstRowIsHeader);
|
||||
} catch (ReportError& exception) {
|
||||
qDebug() << exception.what();
|
||||
}
|
||||
@ -668,14 +674,17 @@ void DataBrowser::changeCSV(SQLEditResult result)
|
||||
|
||||
SQLEditResult::ResultMode DataBrowser::currentDatasourceType(const QString& datasourceName)
|
||||
{
|
||||
if (m_report->dataManager()->isQuery(datasourceName)) return SQLEditResult::Query;
|
||||
if (m_report->dataManager()->isSubQuery(datasourceName)) return SQLEditResult::SubQuery;
|
||||
if (m_report->dataManager()->isProxy(datasourceName)) return SQLEditResult::SubProxy;
|
||||
if (m_report->dataManager()->isCSV(datasourceName)) return SQLEditResult::CSVText;
|
||||
if (m_report->dataManager()->isQuery(datasourceName))
|
||||
return SQLEditResult::Query;
|
||||
if (m_report->dataManager()->isSubQuery(datasourceName))
|
||||
return SQLEditResult::SubQuery;
|
||||
if (m_report->dataManager()->isProxy(datasourceName))
|
||||
return SQLEditResult::SubProxy;
|
||||
if (m_report->dataManager()->isCSV(datasourceName))
|
||||
return SQLEditResult::CSVText;
|
||||
return SQLEditResult::Undefined;
|
||||
}
|
||||
|
||||
|
||||
void DataBrowser::applyChanges(SQLEditResult result)
|
||||
{
|
||||
if (result.resultMode == currentDatasourceType(result.oldDatasourceName)) {
|
||||
@ -692,7 +701,8 @@ void DataBrowser::applyChanges(SQLEditResult result)
|
||||
case SQLEditResult::CSVText:
|
||||
changeCSV(result);
|
||||
break;
|
||||
default: break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
removeDatasource(result.oldDatasourceName);
|
||||
@ -722,7 +732,8 @@ void DataBrowser::addDatasource(SQLEditResult result)
|
||||
activateItem(result.datasourceName, DataBrowserTree::Table);
|
||||
}
|
||||
|
||||
void DataBrowser::activateItem(const QString& name, DataBrowserTree::NodeType type){
|
||||
void DataBrowser::activateItem(const QString& name, DataBrowserTree::NodeType type)
|
||||
{
|
||||
QTreeWidgetItem* item = findByNameAndType(name, type);
|
||||
if (item)
|
||||
item->treeWidget()->setCurrentItem(item);
|
||||
@ -737,7 +748,8 @@ void DataBrowser::addConnectionDesc(ConnectionDesc *connection)
|
||||
|
||||
void DataBrowser::changeConnectionDesc(ConnectionDesc* connection)
|
||||
{
|
||||
if (connection->autoconnect()) m_report->dataManager()->connectConnection(connection->name());
|
||||
if (connection->autoconnect())
|
||||
m_report->dataManager()->connectConnection(connection->name());
|
||||
updateDataTree();
|
||||
activateItem(connection->name(), DataBrowserTree::Connection);
|
||||
}
|
||||
@ -745,33 +757,31 @@ void DataBrowser::changeConnectionDesc(ConnectionDesc *connection)
|
||||
bool DataBrowser::checkConnectionDesc(ConnectionDesc* connection)
|
||||
{
|
||||
bool result = m_report->dataManager()->checkConnectionDesc(connection);
|
||||
if (!result) setLastError(m_report->dataManager()->lastError());
|
||||
if (!result)
|
||||
setLastError(m_report->dataManager()->lastError());
|
||||
return result;
|
||||
}
|
||||
|
||||
bool DataBrowser::containsDefaultConnection()
|
||||
{
|
||||
bool result = m_report->dataManager()->connectionByName(QSqlDatabase::defaultConnection) ||
|
||||
QSqlDatabase::contains(QSqlDatabase::defaultConnection);
|
||||
bool result = m_report->dataManager()->connectionByName(QSqlDatabase::defaultConnection)
|
||||
|| QSqlDatabase::contains(QSqlDatabase::defaultConnection);
|
||||
return result;
|
||||
}
|
||||
|
||||
QString DataBrowser::lastError() const
|
||||
{
|
||||
return m_lastError;
|
||||
}
|
||||
QString DataBrowser::lastError() const { return m_lastError; }
|
||||
|
||||
void DataBrowser::setLastError(const QString &lastError)
|
||||
{
|
||||
m_lastError = lastError;
|
||||
}
|
||||
void DataBrowser::setLastError(const QString& lastError) { m_lastError = lastError; }
|
||||
|
||||
void DataBrowser::on_dataTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
|
||||
void DataBrowser::on_dataTree_currentItemChanged(QTreeWidgetItem* current,
|
||||
QTreeWidgetItem* previous)
|
||||
{
|
||||
Q_UNUSED(previous)
|
||||
if (current && (current->type() == DataBrowserTree::Connection)) {
|
||||
bool internalConnection = m_report->dataManager()->connectionByName(ConnectionDesc::connectionNameForReport(current->text(0)));
|
||||
if (m_report->dataManager()->isConnectionConnected(ConnectionDesc::connectionNameForReport(current->text(0)))){
|
||||
bool internalConnection = m_report->dataManager()->connectionByName(
|
||||
ConnectionDesc::connectionNameForReport(current->text(0)));
|
||||
if (m_report->dataManager()->isConnectionConnected(
|
||||
ConnectionDesc::connectionNameForReport(current->text(0)))) {
|
||||
ui->pbConnect->setIcon(QIcon(":/databrowser/images/plug-connect.png"));
|
||||
} else {
|
||||
ui->pbConnect->setIcon(QIcon(":/databrowser/images/plug-disconnect.png"));
|
||||
@ -794,7 +804,9 @@ void DataBrowser::on_dataTree_currentItemChanged(QTreeWidgetItem *current, QTree
|
||||
ui->deleteDataSource->setEnabled(holder->isRemovable());
|
||||
if (!holder->lastError().isEmpty()) {
|
||||
ui->errorMessage->setEnabled(true);
|
||||
} else {ui->errorMessage->setEnabled(false);}
|
||||
} else {
|
||||
ui->errorMessage->setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -808,15 +820,14 @@ void LimeReport::DataBrowser::on_addVariable_clicked()
|
||||
dialog.setWindowModality(Qt::ApplicationModal);
|
||||
#endif
|
||||
dialog.setVariableContainer(m_report->dataManager());
|
||||
connect(&dialog,SIGNAL(signalVariableAccepted(QString)),this,SLOT(slotVariableEditorAccept(QString)));
|
||||
connect(&dialog, SIGNAL(signalVariableAccepted(QString)), this,
|
||||
SLOT(slotVariableEditorAccept(QString)));
|
||||
dialog.exec();
|
||||
|
||||
}
|
||||
|
||||
void DataBrowser::on_editVariable_clicked()
|
||||
{
|
||||
if (!getVariable().isEmpty())
|
||||
{
|
||||
if (!getVariable().isEmpty()) {
|
||||
LRVariableDialog dialog(this);
|
||||
#ifdef Q_OS_MAC
|
||||
dialog.setWindowModality(Qt::WindowModal);
|
||||
@ -826,7 +837,8 @@ void DataBrowser::on_editVariable_clicked()
|
||||
dialog.setVariableContainer(m_report->dataManager());
|
||||
QString varName = getVariable();
|
||||
dialog.setVariableName(varName);
|
||||
connect(&dialog,SIGNAL(signalVariableAccepted(QString)),this,SLOT(slotVariableEditorAccept(QString)));
|
||||
connect(&dialog, SIGNAL(signalVariableAccepted(QString)), this,
|
||||
SLOT(slotVariableEditorAccept(QString)));
|
||||
dialog.exec();
|
||||
}
|
||||
}
|
||||
@ -835,16 +847,19 @@ void DataBrowser::on_deleteVariable_clicked()
|
||||
{
|
||||
QString varName = getVariable();
|
||||
if (!varName.isEmpty()) {
|
||||
if (QMessageBox::critical(this,tr("Attention"),QString(tr("Do you really want to delete variable \"%1\"?")).arg(varName),
|
||||
QMessageBox::Ok|QMessageBox::Cancel, QMessageBox::Cancel
|
||||
)==QMessageBox::Ok){
|
||||
if (QMessageBox::critical(
|
||||
this, tr("Attention"),
|
||||
QString(tr("Do you really want to delete variable \"%1\"?")).arg(varName),
|
||||
QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel)
|
||||
== QMessageBox::Ok) {
|
||||
m_report->dataManager()->deleteVariable(varName);
|
||||
updateVariablesTree();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DataBrowser::on_variablesTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
|
||||
void DataBrowser::on_variablesTree_currentItemChanged(QTreeWidgetItem* current,
|
||||
QTreeWidgetItem* previous)
|
||||
{
|
||||
Q_UNUSED(previous)
|
||||
if (current) {
|
||||
@ -871,8 +886,11 @@ void DataBrowser::on_variablesTree_currentItemChanged(QTreeWidgetItem *current,
|
||||
|
||||
void DataBrowser::on_errorMessage_clicked()
|
||||
{
|
||||
if(!getDatasourceName().isEmpty()&&m_report->dataManager()->dataSourceHolder(getDatasourceName())){
|
||||
QMessageBox::critical(this,tr("Error"),m_report->dataManager()->dataSourceHolder(getDatasourceName())->lastError());
|
||||
if (!getDatasourceName().isEmpty()
|
||||
&& m_report->dataManager()->dataSourceHolder(getDatasourceName())) {
|
||||
QMessageBox::critical(
|
||||
this, tr("Error"),
|
||||
m_report->dataManager()->dataSourceHolder(getDatasourceName())->lastError());
|
||||
}
|
||||
}
|
||||
|
||||
@ -880,21 +898,19 @@ void DataBrowser::on_varToReport_clicked()
|
||||
{
|
||||
QString varName = getVariable();
|
||||
if (!varName.isEmpty()) {
|
||||
m_report->dataManager()->addVariable(varName,m_report->dataManager()->variable(varName), VarDesc::Report);
|
||||
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)
|
||||
){
|
||||
if (!varName.isEmpty()
|
||||
&& (m_report->dataManager()->variableType(varName) == VarDesc::Report)) {
|
||||
LRVariableDialog dialog(this);
|
||||
#ifdef Q_OS_MAC
|
||||
dialog.setWindowModality(Qt::WindowModal);
|
||||
@ -903,7 +919,8 @@ void DataBrowser::on_variablesTree_itemDoubleClicked(QTreeWidgetItem *item, int
|
||||
#endif
|
||||
dialog.setVariableContainer(m_report->dataManager());
|
||||
dialog.setVariableName(varName);
|
||||
connect(&dialog,SIGNAL(signalVariableAccepted(QString)),this,SLOT(slotVariableEditorAccept(QString)));
|
||||
connect(&dialog, SIGNAL(signalVariableAccepted(QString)), this,
|
||||
SLOT(slotVariableEditorAccept(QString)));
|
||||
dialog.exec();
|
||||
}
|
||||
}
|
||||
|
@ -30,14 +30,14 @@
|
||||
#ifndef LRDATABROWSER_H
|
||||
#define LRDATABROWSER_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTreeWidget>
|
||||
#include <QToolButton>
|
||||
#include <QDockWidget>
|
||||
|
||||
#include "lrdatabrowsertree.h"
|
||||
#include "lrreportdesignwidget.h"
|
||||
#include "lrsqleditdialog.h"
|
||||
#include "lrdatabrowsertree.h"
|
||||
|
||||
#include <QDockWidget>
|
||||
#include <QToolButton>
|
||||
#include <QTreeWidget>
|
||||
#include <QWidget>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
@ -45,11 +45,9 @@ namespace Ui {
|
||||
class DataBrowser;
|
||||
}
|
||||
|
||||
class DataBrowser : public QWidget, public IConnectionController
|
||||
{
|
||||
class DataBrowser: public QWidget, public IConnectionController {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
explicit DataBrowser(QWidget* parent = 0);
|
||||
~DataBrowser();
|
||||
QSize sizeHint() const;
|
||||
@ -88,7 +86,10 @@ private slots:
|
||||
void on_variablesTree_itemDoubleClicked(QTreeWidgetItem* item, int);
|
||||
|
||||
private:
|
||||
enum NameType{NameForUser, NameForReport};
|
||||
enum NameType {
|
||||
NameForUser,
|
||||
NameForReport
|
||||
};
|
||||
QString getDatasourceName();
|
||||
QString getConnectionName(NameType nameType);
|
||||
QString getVariable();
|
||||
@ -130,5 +131,5 @@ private:
|
||||
QString m_lastError;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRDATABROWSER_H
|
||||
|
@ -28,13 +28,13 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrdatabrowsertree.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMimeData>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
DataBrowserTree::DataBrowserTree(QWidget *parent) :
|
||||
QTreeWidget(parent){}
|
||||
DataBrowserTree::DataBrowserTree(QWidget* parent): QTreeWidget(parent) { }
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QMimeData* DataBrowserTree::mimeData(const QList<QTreeWidgetItem*>& items) const
|
||||
@ -44,7 +44,8 @@ QMimeData *DataBrowserTree::mimeData(const QList<QTreeWidgetItem *> items) const
|
||||
{
|
||||
QMimeData* result = QTreeWidget::mimeData(items);
|
||||
if (items.at(0)->type() == Row) {
|
||||
result->setText("field:$D{"+items.at(0)->parent()->text(0)+"."+items.at(0)->data(0,Qt::DisplayRole).toString()+"}");
|
||||
result->setText("field:$D{" + items.at(0)->parent()->text(0) + "."
|
||||
+ items.at(0)->data(0, Qt::DisplayRole).toString() + "}");
|
||||
}
|
||||
if (items.at(0)->type() == Variable) {
|
||||
result->setText("variable:$V{" + items.at(0)->text(0) + "}");
|
||||
|
@ -34,13 +34,19 @@
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
|
||||
class DataBrowserTree : public QTreeWidget
|
||||
{
|
||||
class DataBrowserTree: public QTreeWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum NodeType{Connection, Table, Row, Category, Variable, ExternalVariable};
|
||||
enum NodeType {
|
||||
Connection,
|
||||
Table,
|
||||
Row,
|
||||
Category,
|
||||
Variable,
|
||||
ExternalVariable
|
||||
};
|
||||
explicit DataBrowserTree(QWidget* parent = 0);
|
||||
|
||||
protected:
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
virtual QMimeData* mimeData(const QList<QTreeWidgetItem*>& items) const;
|
||||
@ -49,7 +55,6 @@ protected:
|
||||
#endif
|
||||
|
||||
public slots:
|
||||
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -28,18 +28,26 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrsqleditdialog.h"
|
||||
#include "lrreportengine_p.h"
|
||||
#include "ui_lrsqleditdialog.h"
|
||||
|
||||
#include "lrreportengine_p.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
#include <QSqlDatabase>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
SQLEditDialog::SQLEditDialog(QWidget *parent, LimeReport::DataSourceManager *dataSources, SQLDialogMode dialogMode)
|
||||
: QDialog(parent), ui(new Ui::SQLEditDialog), m_datasources(dataSources), m_dialogMode(dialogMode),
|
||||
m_oldDatasourceName(""), m_settings(0), m_ownedSettings(false) {
|
||||
SQLEditDialog::SQLEditDialog(QWidget* parent, LimeReport::DataSourceManager* dataSources,
|
||||
SQLDialogMode dialogMode):
|
||||
QDialog(parent),
|
||||
ui(new Ui::SQLEditDialog),
|
||||
m_datasources(dataSources),
|
||||
m_dialogMode(dialogMode),
|
||||
m_oldDatasourceName(""),
|
||||
m_settings(0),
|
||||
m_ownedSettings(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
m_masterDatasources = new QCompleter(this);
|
||||
ui->leMaster->setCompleter(m_masterDatasources);
|
||||
@ -62,13 +70,15 @@ SQLEditDialog::SQLEditDialog(QWidget *parent, LimeReport::DataSourceManager *dat
|
||||
connect(ui->pbHidePreview, SIGNAL(pressed()), this, SLOT(slotHidePreview()));
|
||||
}
|
||||
|
||||
SQLEditDialog::~SQLEditDialog() {
|
||||
SQLEditDialog::~SQLEditDialog()
|
||||
{
|
||||
delete ui;
|
||||
if (m_settings && m_ownedSettings)
|
||||
delete m_settings;
|
||||
}
|
||||
|
||||
QSettings *SQLEditDialog::settings() {
|
||||
QSettings* SQLEditDialog::settings()
|
||||
{
|
||||
if (m_settings) {
|
||||
return m_settings;
|
||||
} else {
|
||||
@ -78,14 +88,16 @@ QSettings *SQLEditDialog::settings() {
|
||||
}
|
||||
}
|
||||
|
||||
void SQLEditDialog::setSettings(QSettings *value, bool owned) {
|
||||
void SQLEditDialog::setSettings(QSettings* value, bool owned)
|
||||
{
|
||||
if (m_settings && m_ownedSettings)
|
||||
delete m_settings;
|
||||
m_settings = value;
|
||||
m_ownedSettings = owned;
|
||||
}
|
||||
|
||||
void SQLEditDialog::accept() {
|
||||
void SQLEditDialog::accept()
|
||||
{
|
||||
SQLEditResult result;
|
||||
|
||||
if (ui->tabWidget->currentIndex() == 1) {
|
||||
@ -99,7 +111,8 @@ void SQLEditDialog::accept() {
|
||||
result.resultMode = SQLEditResult::SubProxy;
|
||||
}
|
||||
|
||||
result.connectionName = ConnectionDesc::connectionNameForReport(ui->cbbConnection->currentText());
|
||||
result.connectionName
|
||||
= ConnectionDesc::connectionNameForReport(ui->cbbConnection->currentText());
|
||||
result.datasourceName = ui->leDatasourceName->text();
|
||||
result.sql = ui->sqlText->toPlainText();
|
||||
result.csv = ui->csvText->toPlainText();
|
||||
@ -114,10 +127,12 @@ void SQLEditDialog::accept() {
|
||||
if (ui->fieldsMap->rowCount() > 0) {
|
||||
for (int i = 0; i < ui->fieldsMap->rowCount(); ++i) {
|
||||
LimeReport::FieldsCorrelation fieldsCorrelation;
|
||||
fieldsCorrelation.master =
|
||||
ui->fieldsMap->item(i, 0) ? ui->fieldsMap->item(i, 0)->data(Qt::DisplayRole).toString() : "";
|
||||
fieldsCorrelation.detail =
|
||||
ui->fieldsMap->item(i, 1) ? ui->fieldsMap->item(i, 1)->data(Qt::DisplayRole).toString() : "";
|
||||
fieldsCorrelation.master = ui->fieldsMap->item(i, 0)
|
||||
? ui->fieldsMap->item(i, 0)->data(Qt::DisplayRole).toString()
|
||||
: "";
|
||||
fieldsCorrelation.detail = ui->fieldsMap->item(i, 1)
|
||||
? ui->fieldsMap->item(i, 1)->data(Qt::DisplayRole).toString()
|
||||
: "";
|
||||
result.fieldMap.append(fieldsCorrelation);
|
||||
}
|
||||
}
|
||||
@ -131,7 +146,8 @@ void SQLEditDialog::accept() {
|
||||
}
|
||||
}
|
||||
|
||||
void SQLEditDialog::showEvent(QShowEvent *) {
|
||||
void SQLEditDialog::showEvent(QShowEvent*)
|
||||
{
|
||||
ui->lblInfo->setVisible(false);
|
||||
initConnections();
|
||||
readSettings();
|
||||
@ -141,7 +157,8 @@ void SQLEditDialog::closeEvent(QCloseEvent *) { writeSetting(); }
|
||||
|
||||
void SQLEditDialog::hideEvent(QHideEvent*) { writeSetting(); }
|
||||
|
||||
void SQLEditDialog::check() {
|
||||
void SQLEditDialog::check()
|
||||
{
|
||||
if (ui->leDatasourceName->text().isEmpty())
|
||||
throw LimeReport::ReportError(tr("Datasource Name is empty!"));
|
||||
if (ui->sqlText->toPlainText().isEmpty() && (!ui->rbProxy))
|
||||
@ -149,20 +166,23 @@ void SQLEditDialog::check() {
|
||||
if (m_dialogMode == AddMode) {
|
||||
if (m_datasources->containsDatasource(ui->leDatasourceName->text())) {
|
||||
throw LimeReport::ReportError(
|
||||
QString(tr("Datasource with name: \"%1\" already exists!")).arg(ui->leDatasourceName->text()));
|
||||
QString(tr("Datasource with name: \"%1\" already exists!"))
|
||||
.arg(ui->leDatasourceName->text()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SQLEditDialog::initConnections() {
|
||||
void SQLEditDialog::initConnections()
|
||||
{
|
||||
foreach (QString connectionName, QSqlDatabase::connectionNames()) {
|
||||
ui->cbbConnection->addItem(QIcon(":/databrowser/images/plug-connect.png"),
|
||||
ConnectionDesc::connectionNameForUser(connectionName));
|
||||
}
|
||||
|
||||
foreach (QString connectionName, m_datasources->connectionNames()) {
|
||||
connectionName =
|
||||
(connectionName.compare(QSqlDatabase::defaultConnection) == 0) ? tr("defaultConnection") : connectionName;
|
||||
connectionName = (connectionName.compare(QSqlDatabase::defaultConnection) == 0)
|
||||
? tr("defaultConnection")
|
||||
: connectionName;
|
||||
if (ui->cbbConnection->findText(connectionName, Qt::MatchExactly) == -1)
|
||||
ui->cbbConnection->addItem(QIcon(":/databrowser/images/plug-disconnect.png"),
|
||||
ConnectionDesc::connectionNameForUser(connectionName));
|
||||
@ -170,12 +190,15 @@ void SQLEditDialog::initConnections() {
|
||||
|
||||
ui->cbbConnection->setCurrentIndex(ui->cbbConnection->findText(m_defaultConnection));
|
||||
if (!m_oldDatasourceName.isEmpty()) {
|
||||
ui->cbbConnection->setCurrentIndex(ui->cbbConnection->findText(
|
||||
ConnectionDesc::connectionNameForUser(m_datasources->connectionName(m_oldDatasourceName))));
|
||||
ui->cbbConnection->setCurrentIndex(
|
||||
ui->cbbConnection->findText(ConnectionDesc::connectionNameForUser(
|
||||
m_datasources->connectionName(m_oldDatasourceName))));
|
||||
}
|
||||
}
|
||||
|
||||
void SQLEditDialog::setDataSources(LimeReport::DataSourceManager *dataSources, QString datasourceName) {
|
||||
void SQLEditDialog::setDataSources(LimeReport::DataSourceManager* dataSources,
|
||||
QString datasourceName)
|
||||
{
|
||||
m_datasources = dataSources;
|
||||
if (!datasourceName.isEmpty()) {
|
||||
ui->cbSubdetail->setEnabled(true);
|
||||
@ -205,24 +228,27 @@ void SQLEditDialog::setDataSources(LimeReport::DataSourceManager *dataSources, Q
|
||||
if (dataSources->isCSV(datasourceName)) {
|
||||
ui->csvText->setPlainText(dataSources->csvByName(datasourceName)->csvText());
|
||||
ui->leSeparator->setText(dataSources->csvByName(datasourceName)->separator());
|
||||
ui->cbUseFirstRowAsHeader->setChecked(dataSources->csvByName(datasourceName)->firstRowIsHeader());
|
||||
ui->cbUseFirstRowAsHeader->setChecked(
|
||||
dataSources->csvByName(datasourceName)->firstRowIsHeader());
|
||||
initCSVMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SQLEditDialog::setDefaultConnection(QString defaultConnection) {
|
||||
void SQLEditDialog::setDefaultConnection(QString defaultConnection)
|
||||
{
|
||||
m_defaultConnection = ConnectionDesc::connectionNameForUser(defaultConnection);
|
||||
}
|
||||
|
||||
void SQLEditDialog::slotDataSourceNameEditing() {
|
||||
void SQLEditDialog::slotDataSourceNameEditing()
|
||||
{
|
||||
if (m_dialogMode == AddMode) {
|
||||
QPalette palette = ui->leDatasourceName->palette();
|
||||
if (m_datasources->containsDatasource(ui->leDatasourceName->text())) {
|
||||
palette.setColor(QPalette::Text, Qt::red);
|
||||
ui->leDatasourceName->setPalette(palette);
|
||||
ui->lblInfo->setText(
|
||||
QString(tr("Datasource with name %1 already exist")).arg(ui->leDatasourceName->text()));
|
||||
ui->lblInfo->setText(QString(tr("Datasource with name %1 already exist"))
|
||||
.arg(ui->leDatasourceName->text()));
|
||||
ui->lblInfo->setVisible(true);
|
||||
} else {
|
||||
palette.setColor(QPalette::Text, QApplication::palette().text().color());
|
||||
@ -232,9 +258,11 @@ void SQLEditDialog::slotDataSourceNameEditing() {
|
||||
}
|
||||
}
|
||||
|
||||
void SQLEditDialog::on_cbSubdetail_clicked(bool checked) {
|
||||
void SQLEditDialog::on_cbSubdetail_clicked(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
m_masterDatasources->setModel(new QStringListModel(m_datasources->dataSourceNames(), m_datasources));
|
||||
m_masterDatasources->setModel(
|
||||
new QStringListModel(m_datasources->dataSourceNames(), m_datasources));
|
||||
}
|
||||
ui->leMaster->setEnabled(checked);
|
||||
ui->rbProxy->setEnabled(checked);
|
||||
@ -247,19 +275,25 @@ void SQLEditDialog::on_cbSubdetail_clicked(bool checked) {
|
||||
initQueryMode();
|
||||
}
|
||||
|
||||
void SQLEditDialog::on_rbProxy_clicked(bool checked) {
|
||||
void SQLEditDialog::on_rbProxy_clicked(bool checked)
|
||||
{
|
||||
if (checked)
|
||||
initProxyMode();
|
||||
}
|
||||
|
||||
void SQLEditDialog::on_rbSubQuery_clicked(bool checked) {
|
||||
void SQLEditDialog::on_rbSubQuery_clicked(bool checked)
|
||||
{
|
||||
if (checked)
|
||||
initSubQueryMode();
|
||||
}
|
||||
|
||||
void SQLEditDialog::on_pbAddField_clicked() { ui->fieldsMap->setRowCount(ui->fieldsMap->rowCount() + 1); }
|
||||
void SQLEditDialog::on_pbAddField_clicked()
|
||||
{
|
||||
ui->fieldsMap->setRowCount(ui->fieldsMap->rowCount() + 1);
|
||||
}
|
||||
|
||||
void SQLEditDialog::initQueryMode() {
|
||||
void SQLEditDialog::initQueryMode()
|
||||
{
|
||||
ui->gbSQL->setVisible(true);
|
||||
ui->gbFieldsMap->setVisible(false);
|
||||
ui->pnlChildDatasource->setVisible(false);
|
||||
@ -272,7 +306,8 @@ void SQLEditDialog::initQueryMode() {
|
||||
ui->tabWidget->addTab(ui->csvTab, tr("CSV"));
|
||||
}
|
||||
|
||||
void SQLEditDialog::initSubQueryMode() {
|
||||
void SQLEditDialog::initSubQueryMode()
|
||||
{
|
||||
ui->gbSQL->setVisible(true);
|
||||
ui->gbFieldsMap->setVisible(false);
|
||||
ui->pnlChildDatasource->setVisible(false);
|
||||
@ -286,7 +321,8 @@ void SQLEditDialog::initSubQueryMode() {
|
||||
ui->tabWidget->removeTab(1);
|
||||
}
|
||||
|
||||
void SQLEditDialog::initProxyMode() {
|
||||
void SQLEditDialog::initProxyMode()
|
||||
{
|
||||
ui->gbSQL->setVisible(false);
|
||||
ui->gbFieldsMap->setVisible(true);
|
||||
ui->pnlChildDatasource->setVisible(true);
|
||||
@ -303,13 +339,14 @@ void SQLEditDialog::initProxyMode() {
|
||||
|
||||
void SQLEditDialog::initCSVMode() { ui->tabWidget->setCurrentWidget(ui->csvTab); }
|
||||
|
||||
void SQLEditDialog::slotPreviewData() {
|
||||
void SQLEditDialog::slotPreviewData()
|
||||
{
|
||||
if (ui->cbbConnection->currentText().isEmpty()) {
|
||||
QMessageBox::critical(this, tr("Attention"), tr("Connection is not specified"));
|
||||
return;
|
||||
}
|
||||
m_previewModel =
|
||||
m_datasources->previewSQL(ConnectionDesc::connectionNameForReport(ui->cbbConnection->currentText()),
|
||||
m_previewModel = m_datasources->previewSQL(
|
||||
ConnectionDesc::connectionNameForReport(ui->cbbConnection->currentText()),
|
||||
ui->sqlText->toPlainText(), ui->leMaster->text());
|
||||
if (m_previewModel) {
|
||||
ui->tvPreview->setModel(m_previewModel.data());
|
||||
@ -325,7 +362,8 @@ void SQLEditDialog::slotPreviewData() {
|
||||
|
||||
void SQLEditDialog::slotHidePreview() { hidePreview(); }
|
||||
|
||||
void SQLEditDialog::writeSetting() {
|
||||
void SQLEditDialog::writeSetting()
|
||||
{
|
||||
if (settings() != 0) {
|
||||
settings()->beginGroup("SQLEditor");
|
||||
settings()->setValue("Geometry", saveGeometry());
|
||||
@ -333,7 +371,8 @@ void SQLEditDialog::writeSetting() {
|
||||
}
|
||||
}
|
||||
|
||||
void SQLEditDialog::readSettings() {
|
||||
void SQLEditDialog::readSettings()
|
||||
{
|
||||
if (settings() == 0)
|
||||
return;
|
||||
settings()->beginGroup("SQLEditor");
|
||||
@ -344,12 +383,16 @@ void SQLEditDialog::readSettings() {
|
||||
settings()->endGroup();
|
||||
}
|
||||
|
||||
void SQLEditDialog::hidePreview() {
|
||||
void SQLEditDialog::hidePreview()
|
||||
{
|
||||
ui->gbDataPreview->setVisible(false);
|
||||
ui->pbPreview->setText(tr("Preview"));
|
||||
ui->pbHidePreview->setVisible(false);
|
||||
}
|
||||
|
||||
void SQLEditDialog::on_pbDelField_clicked() { ui->fieldsMap->removeRow(ui->fieldsMap->currentRow()); }
|
||||
void SQLEditDialog::on_pbDelField_clicked()
|
||||
{
|
||||
ui->fieldsMap->removeRow(ui->fieldsMap->currentRow());
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -30,13 +30,15 @@
|
||||
#ifndef LRSQLEDITDIALOG_H
|
||||
#define LRSQLEDITDIALOG_H
|
||||
|
||||
#include <stdexcept>
|
||||
#include <QDialog>
|
||||
#include <QCompleter>
|
||||
#include <QSettings>
|
||||
#include "lrreportengine_p.h"
|
||||
#include "lrdatasourcemanager.h"
|
||||
#include "lrdatadesignintf.h"
|
||||
#include "lrdatasourcemanager.h"
|
||||
#include "lrreportengine_p.h"
|
||||
|
||||
#include <QCompleter>
|
||||
#include <QDialog>
|
||||
#include <QSettings>
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
@ -46,13 +48,16 @@ namespace Ui {
|
||||
|
||||
struct SQLEditResult;
|
||||
|
||||
class SQLEditDialog : public QDialog
|
||||
{
|
||||
class SQLEditDialog: public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum SQLDialogMode {AddMode,EditMode};
|
||||
explicit SQLEditDialog(QWidget *parent, LimeReport::DataSourceManager* dataSources,SQLDialogMode dialogMode);
|
||||
enum SQLDialogMode {
|
||||
AddMode,
|
||||
EditMode
|
||||
};
|
||||
explicit SQLEditDialog(QWidget* parent, LimeReport::DataSourceManager* dataSources,
|
||||
SQLDialogMode dialogMode);
|
||||
void setDataSources(LimeReport::DataSourceManager* dataSources, QString datasourceName = "");
|
||||
void setDefaultConnection(QString defaultConnection);
|
||||
~SQLEditDialog();
|
||||
@ -60,6 +65,7 @@ public:
|
||||
void setSettings(QSettings* value, bool owned = false);
|
||||
signals:
|
||||
void signalSqlEditingFinished(SQLEditResult result);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent*);
|
||||
void closeEvent(QCloseEvent*);
|
||||
@ -80,10 +86,12 @@ private slots:
|
||||
void initCSVMode();
|
||||
void slotPreviewData();
|
||||
void slotHidePreview();
|
||||
|
||||
private:
|
||||
void writeSetting();
|
||||
void readSettings();
|
||||
void hidePreview();
|
||||
|
||||
private:
|
||||
Ui::SQLEditDialog* ui;
|
||||
LimeReport::DataSourceManager* m_datasources;
|
||||
@ -97,7 +105,13 @@ private:
|
||||
};
|
||||
|
||||
struct SQLEditResult {
|
||||
enum ResultMode{Query, SubQuery, SubProxy, CSVText, Undefined};
|
||||
enum ResultMode {
|
||||
Query,
|
||||
SubQuery,
|
||||
SubProxy,
|
||||
CSVText,
|
||||
Undefined
|
||||
};
|
||||
QString connectionName;
|
||||
QString datasourceName;
|
||||
QString oldDatasourceName;
|
||||
|
@ -29,12 +29,15 @@
|
||||
****************************************************************************/
|
||||
#include "lrvariabledialog.h"
|
||||
#include "ui_lrvariabledialog.h"
|
||||
|
||||
#include "lrglobal.h"
|
||||
#include "lrvariablesholder.h"
|
||||
#include <stdexcept>
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QMetaEnum>
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
LRVariableDialog::LRVariableDialog(QWidget* parent):
|
||||
QDialog(parent),
|
||||
ui(new Ui::LRVariableDialog),
|
||||
@ -45,7 +48,8 @@ LRVariableDialog::LRVariableDialog(QWidget *parent) :
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
static int enumIndex = LimeReport::Enums::staticMetaObject.indexOfEnumerator("VariableDataType");
|
||||
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));
|
||||
@ -54,10 +58,7 @@ LRVariableDialog::LRVariableDialog(QWidget *parent) :
|
||||
// ui->lblType->setVisible(false);
|
||||
}
|
||||
|
||||
LRVariableDialog::~LRVariableDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
LRVariableDialog::~LRVariableDialog() { delete ui; }
|
||||
|
||||
void LRVariableDialog::setVariableContainer(LimeReport::IVariablesContainer* value)
|
||||
{
|
||||
@ -74,14 +75,18 @@ void LRVariableDialog::setVariableName(const QString &value)
|
||||
void LRVariableDialog::showEvent(QShowEvent*)
|
||||
{
|
||||
ui->leName->setText(m_variableName);
|
||||
static int enumIndex = LimeReport::Enums::staticMetaObject.indexOfEnumerator("VariableDataType");
|
||||
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->setPlainText(m_variablesContainer->variable(m_variableName).toString());
|
||||
#if QT_VERSION < 0x050000
|
||||
ui->cbbType->setCurrentIndex(ui->cbbType->findText(enumerator.valueToKey(m_variablesContainer->variableDataType(m_variableName))));
|
||||
ui->cbbType->setCurrentIndex(ui->cbbType->findText(
|
||||
enumerator.valueToKey(m_variablesContainer->variableDataType(m_variableName))));
|
||||
#else
|
||||
ui->cbbType->setCurrentText(enumerator.valueToKey(m_variablesContainer->variableDataType(m_variableName)));
|
||||
ui->cbbType->setCurrentText(
|
||||
enumerator.valueToKey(m_variablesContainer->variableDataType(m_variableName)));
|
||||
#endif
|
||||
ui->cbbMandatory->setChecked(m_variablesContainer->variableIsMandatory(m_variableName));
|
||||
}
|
||||
@ -90,7 +95,8 @@ void LRVariableDialog::showEvent(QShowEvent *)
|
||||
void LRVariableDialog::accept()
|
||||
{
|
||||
try {
|
||||
static int enumIndex = LimeReport::Enums::staticMetaObject.indexOfEnumerator("VariableDataType");
|
||||
static int enumIndex
|
||||
= LimeReport::Enums::staticMetaObject.indexOfEnumerator("VariableDataType");
|
||||
QMetaEnum enumerator = LimeReport::Enums::staticMetaObject.enumerator(enumIndex);
|
||||
|
||||
if (m_variablesContainer && !ui->leName->text().isEmpty()) {
|
||||
@ -99,16 +105,19 @@ void LRVariableDialog::accept()
|
||||
m_variablesContainer->changeVariable(m_oldVariableName, value());
|
||||
} else {
|
||||
m_variablesContainer->deleteVariable(m_oldVariableName);
|
||||
m_variablesContainer->addVariable(ui->leName->text(),value(), LimeReport::VarDesc::Report);
|
||||
m_variablesContainer->addVariable(ui->leName->text(), value(),
|
||||
LimeReport::VarDesc::Report);
|
||||
}
|
||||
} 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->setVarableMandatory(ui->leName->text(),
|
||||
ui->cbbMandatory->isChecked());
|
||||
m_variablesContainer->setVariableDataType(
|
||||
ui->leName->text(),
|
||||
LimeReport::VariableDataType(enumerator.keysToValue(ui->cbbType->currentText().toLatin1()))
|
||||
);
|
||||
LimeReport::VariableDataType(
|
||||
enumerator.keysToValue(ui->cbbType->currentText().toLatin1())));
|
||||
emit signalVariableAccepted(ui->leName->text());
|
||||
QDialog::accept();
|
||||
}
|
||||
@ -117,7 +126,4 @@ void LRVariableDialog::accept()
|
||||
}
|
||||
}
|
||||
|
||||
QVariant LRVariableDialog::value()
|
||||
{
|
||||
return ui->leValue->toPlainText();
|
||||
}
|
||||
QVariant LRVariableDialog::value() { return ui->leValue->toPlainText(); }
|
||||
|
@ -30,15 +30,15 @@
|
||||
#ifndef LRVARIABLEDIALOG_H
|
||||
#define LRVARIABLEDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "lrvariablesholder.h"
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class LRVariableDialog;
|
||||
}
|
||||
|
||||
class LRVariableDialog : public QDialog
|
||||
{
|
||||
class LRVariableDialog: public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@ -46,14 +46,17 @@ public:
|
||||
~LRVariableDialog();
|
||||
void setVariableContainer(LimeReport::IVariablesContainer* value);
|
||||
void setVariableName(const QString& value);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent*);
|
||||
private slots:
|
||||
void accept();
|
||||
signals:
|
||||
void signalVariableAccepted(const QString& variable);
|
||||
|
||||
private:
|
||||
QVariant value();
|
||||
|
||||
private:
|
||||
Ui::LRVariableDialog* ui;
|
||||
QString m_variableName;
|
||||
|
@ -1,20 +1,17 @@
|
||||
#include "lrdialogdesigner.h"
|
||||
|
||||
#include <QPluginLoader>
|
||||
|
||||
#include <QDesignerComponents>
|
||||
#include <QDesignerFormEditorInterface>
|
||||
#include <QDesignerFormWindowInterface>
|
||||
#include <QDesignerFormWindowManagerInterface>
|
||||
#include <QDesignerFormEditorPluginInterface>
|
||||
|
||||
#include <QDesignerWidgetBoxInterface>
|
||||
#include <QDesignerActionEditorInterface>
|
||||
#include <QDesignerPropertyEditorInterface>
|
||||
#include <QDesignerObjectInspectorInterface>
|
||||
#include <QDesignerFormEditorInterface>
|
||||
#include <QAction>
|
||||
#include <QDebug>
|
||||
#include <QDesignerActionEditorInterface>
|
||||
#include <QDesignerComponents>
|
||||
#include <QDesignerFormEditorInterface>
|
||||
#include <QDesignerFormEditorPluginInterface>
|
||||
#include <QDesignerFormWindowInterface>
|
||||
#include <QDesignerFormWindowManagerInterface>
|
||||
#include <QDesignerObjectInspectorInterface>
|
||||
#include <QDesignerPropertyEditorInterface>
|
||||
#include <QDesignerWidgetBoxInterface>
|
||||
#include <QPluginLoader>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#if HAVE_QT5
|
||||
@ -22,10 +19,12 @@
|
||||
#endif
|
||||
#if HAVE_QT4
|
||||
#include "qdesigner_integration_p.h"
|
||||
|
||||
#include <QtDesigner/QDesignerIntegrationInterface>
|
||||
#endif
|
||||
#include "pluginmanager_p.h"
|
||||
#include "widgethost.h"
|
||||
|
||||
#include <abstractobjectinspector.h>
|
||||
|
||||
namespace LimeReport {
|
||||
@ -43,17 +42,18 @@ DialogDesignerManager::DialogDesignerManager(QObject *parent) : QObject(parent)
|
||||
m_editWidgetsAction->setCheckable(true);
|
||||
m_editWidgetsAction->setChecked(true);
|
||||
connect(m_editWidgetsAction, SIGNAL(triggered()), this, SLOT(slotEditWidgets()));
|
||||
connect(m_formEditor->formWindowManager(), SIGNAL(activeFormWindowChanged(QDesignerFormWindowInterface*)),
|
||||
this, SLOT(slotActiveFormWindowChanged(QDesignerFormWindowInterface*)) );
|
||||
connect(m_formEditor->formWindowManager(),
|
||||
SIGNAL(activeFormWindowChanged(QDesignerFormWindowInterface*)), this,
|
||||
SLOT(slotActiveFormWindowChanged(QDesignerFormWindowInterface*)));
|
||||
|
||||
m_modes = new QActionGroup(this);
|
||||
m_modes->setExclusive(true);
|
||||
m_modes->addAction(m_editWidgetsAction);
|
||||
|
||||
foreach ( QObject* o, QPluginLoader::staticInstances() << m_formEditor->pluginManager()->instances() )
|
||||
{
|
||||
if ( QDesignerFormEditorPluginInterface* fep = qobject_cast<QDesignerFormEditorPluginInterface*>( o ) )
|
||||
{
|
||||
foreach (QObject* o,
|
||||
QPluginLoader::staticInstances() << m_formEditor->pluginManager()->instances()) {
|
||||
if (QDesignerFormEditorPluginInterface* fep
|
||||
= qobject_cast<QDesignerFormEditorPluginInterface*>(o)) {
|
||||
if (!fep->isInitialized())
|
||||
fep->initialize(m_formEditor);
|
||||
fep->action()->setCheckable(true);
|
||||
@ -75,27 +75,31 @@ DialogDesignerManager::DialogDesignerManager(QObject *parent) : QObject(parent)
|
||||
m_objectInspector->setObjectName(QLatin1String("ObjectInspector"));
|
||||
m_formEditor->setObjectInspector(m_objectInspector);
|
||||
m_designerToolWindows.append(m_objectInspector);
|
||||
connect(m_objectInspector, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)) );
|
||||
connect(m_objectInspector, SIGNAL(destroyed(QObject*)), this,
|
||||
SLOT(slotObjectDestroyed(QObject*)));
|
||||
|
||||
m_propertyEditor = QDesignerComponents::createPropertyEditor(m_formEditor, 0);
|
||||
m_propertyEditor->setWindowTitle(tr("Property Editor"));
|
||||
m_propertyEditor->setObjectName(QLatin1String("PropertyEditor"));
|
||||
m_formEditor->setPropertyEditor(m_propertyEditor);
|
||||
m_designerToolWindows.append(m_propertyEditor);
|
||||
connect(m_propertyEditor, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)) );
|
||||
connect(m_propertyEditor, SIGNAL(destroyed(QObject*)), this,
|
||||
SLOT(slotObjectDestroyed(QObject*)));
|
||||
|
||||
m_signalSlotEditor = QDesignerComponents::createSignalSlotEditor(m_formEditor, 0);
|
||||
m_signalSlotEditor->setWindowTitle(tr("Signals && Slots Editor"));
|
||||
m_signalSlotEditor->setObjectName(QLatin1String("SignalsAndSlotsEditor"));
|
||||
|
||||
m_designerToolWindows.append(m_signalSlotEditor);
|
||||
connect(m_signalSlotEditor, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)) );
|
||||
connect(m_signalSlotEditor, SIGNAL(destroyed(QObject*)), this,
|
||||
SLOT(slotObjectDestroyed(QObject*)));
|
||||
|
||||
m_resourcesEditor = QDesignerComponents::createResourceEditor(m_formEditor, 0);
|
||||
m_resourcesEditor->setWindowTitle(tr("Resource Editor"));
|
||||
m_resourcesEditor->setObjectName(QLatin1String("ResourceEditor"));
|
||||
m_designerToolWindows.append(m_resourcesEditor);
|
||||
connect(m_resourcesEditor, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)) );
|
||||
connect(m_resourcesEditor, SIGNAL(destroyed(QObject*)), this,
|
||||
SLOT(slotObjectDestroyed(QObject*)));
|
||||
|
||||
m_actionEditor = QDesignerComponents::createActionEditor(m_formEditor, 0);
|
||||
m_actionEditor->setWindowTitle(tr("Action Editor"));
|
||||
@ -110,7 +114,6 @@ DialogDesignerManager::DialogDesignerManager(QObject *parent) : QObject(parent)
|
||||
m_designerIntegration = new QDesignerIntegration(m_formEditor, this);
|
||||
#endif
|
||||
m_formEditor->setIntegration(m_designerIntegration);
|
||||
|
||||
}
|
||||
|
||||
DialogDesignerManager::~DialogDesignerManager()
|
||||
@ -145,7 +148,8 @@ void DialogDesignerManager::initToolBar(QToolBar *tb)
|
||||
tb->addAction(m_formEditor->formWindowManager()->actionSplitHorizontal());
|
||||
tb->addAction(m_formEditor->formWindowManager()->actionSplitVertical());
|
||||
tb->addAction(m_formEditor->formWindowManager()->actionGridLayout());
|
||||
m_formEditor->formWindowManager()->actionFormLayout()->setIcon(QIcon(":/images/images/editform.png"));
|
||||
m_formEditor->formWindowManager()->actionFormLayout()->setIcon(
|
||||
QIcon(":/images/images/editform.png"));
|
||||
tb->addAction(m_formEditor->formWindowManager()->actionFormLayout());
|
||||
tb->addAction(m_formEditor->formWindowManager()->actionBreakLayout());
|
||||
tb->addAction(m_formEditor->formWindowManager()->actionAdjustSize());
|
||||
@ -153,7 +157,8 @@ void DialogDesignerManager::initToolBar(QToolBar *tb)
|
||||
|
||||
QWidget* DialogDesignerManager::createFormEditor(const QString& content)
|
||||
{
|
||||
QDesignerFormWindowInterface* wnd = m_formEditor->formWindowManager()->createFormWindow(0, Qt::Window);
|
||||
QDesignerFormWindowInterface* wnd
|
||||
= m_formEditor->formWindowManager()->createFormWindow(0, Qt::Window);
|
||||
wnd->setContents(content);
|
||||
m_formEditor->formWindowManager()->setActiveFormWindow(wnd);
|
||||
m_formEditor->objectInspector()->setFormWindow(wnd);
|
||||
@ -162,13 +167,13 @@ QWidget *DialogDesignerManager::createFormEditor(const QString &content)
|
||||
DialogDesigner* dialogDesigner = new DialogDesigner(wnd, m_formEditor);
|
||||
|
||||
connect(dialogDesigner, SIGNAL(dialogChanged(QString)), this, SIGNAL(dialogChanged(QString)));
|
||||
connect(dialogDesigner, SIGNAL(dialogNameChanged(QString,QString)), this, SIGNAL(dialogNameChanged(QString,QString)));
|
||||
connect(dialogDesigner, SIGNAL(dialogNameChanged(QString, QString)), this,
|
||||
SIGNAL(dialogNameChanged(QString, QString)));
|
||||
connect(dialogDesigner, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)));
|
||||
|
||||
m_dialogDesigners.append(dialogDesigner);
|
||||
|
||||
return dialogDesigner;
|
||||
|
||||
}
|
||||
|
||||
QByteArray DialogDesignerManager::getDialogDescription(QWidget* form)
|
||||
@ -199,35 +204,17 @@ void DialogDesignerManager::setDirty(bool value)
|
||||
}
|
||||
}
|
||||
|
||||
QWidget* DialogDesignerManager::widgetBox() const
|
||||
{
|
||||
return m_widgetBox;
|
||||
}
|
||||
QWidget* DialogDesignerManager::widgetBox() const { return m_widgetBox; }
|
||||
|
||||
QWidget* DialogDesignerManager::actionEditor() const
|
||||
{
|
||||
return m_actionEditor;
|
||||
}
|
||||
QWidget* DialogDesignerManager::actionEditor() const { return m_actionEditor; }
|
||||
|
||||
QWidget* DialogDesignerManager::propertyEditor() const
|
||||
{
|
||||
return m_propertyEditor;
|
||||
}
|
||||
QWidget* DialogDesignerManager::propertyEditor() const { return m_propertyEditor; }
|
||||
|
||||
QWidget* DialogDesignerManager::objectInspector() const
|
||||
{
|
||||
return m_objectInspector;
|
||||
}
|
||||
QWidget* DialogDesignerManager::objectInspector() const { return m_objectInspector; }
|
||||
|
||||
QWidget *DialogDesignerManager::signalSlotEditor() const
|
||||
{
|
||||
return m_signalSlotEditor;
|
||||
}
|
||||
QWidget* DialogDesignerManager::signalSlotEditor() const { return m_signalSlotEditor; }
|
||||
|
||||
QWidget *DialogDesignerManager::resourcesEditor() const
|
||||
{
|
||||
return m_resourcesEditor;
|
||||
}
|
||||
QWidget* DialogDesignerManager::resourcesEditor() const { return m_resourcesEditor; }
|
||||
|
||||
void DialogDesignerManager::slotObjectDestroyed(QObject* object)
|
||||
{
|
||||
@ -243,9 +230,9 @@ void DialogDesignerManager::slotObjectDestroyed(QObject* object)
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_designerToolWindows.size(); ++i) {
|
||||
m_designerToolWindows[i] = m_designerToolWindows[i] == object ? 0 : m_designerToolWindows[i];
|
||||
m_designerToolWindows[i]
|
||||
= m_designerToolWindows[i] == object ? 0 : m_designerToolWindows[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void DialogDesignerManager::slotEditWidgets()
|
||||
@ -276,8 +263,11 @@ QString DialogDesignerManager::iconPathByName(const QString &name)
|
||||
return "";
|
||||
}
|
||||
|
||||
DialogDesigner::DialogDesigner(QDesignerFormWindowInterface* wnd, QDesignerFormEditorInterface* formEditor, QWidget *parent, Qt::WindowFlags flags)
|
||||
:QWidget(parent, flags), m_formEditor(formEditor)
|
||||
DialogDesigner::DialogDesigner(QDesignerFormWindowInterface* wnd,
|
||||
QDesignerFormEditorInterface* formEditor, QWidget* parent,
|
||||
Qt::WindowFlags flags):
|
||||
QWidget(parent, flags),
|
||||
m_formEditor(formEditor)
|
||||
{
|
||||
m_dialogName = wnd->mainContainer()->objectName();
|
||||
connect(wnd, SIGNAL(changed()), this, SLOT(slotDialogChanged()));
|
||||
@ -289,30 +279,17 @@ DialogDesigner::DialogDesigner(QDesignerFormWindowInterface* wnd, QDesignerFormE
|
||||
QVBoxLayout* l = new QVBoxLayout(this);
|
||||
l->addWidget(m_designerHolder);
|
||||
setLayout(l);
|
||||
|
||||
}
|
||||
|
||||
DialogDesigner::~DialogDesigner() { }
|
||||
|
||||
QString DialogDesigner::dialogName() const
|
||||
{
|
||||
return m_dialogName;
|
||||
}
|
||||
QString DialogDesigner::dialogName() const { return m_dialogName; }
|
||||
|
||||
void DialogDesigner::setDialogName(const QString &dialogName)
|
||||
{
|
||||
m_dialogName = dialogName;
|
||||
}
|
||||
void DialogDesigner::setDialogName(const QString& dialogName) { m_dialogName = dialogName; }
|
||||
|
||||
bool DialogDesigner::isChanged()
|
||||
{
|
||||
return m_designerHolder->formWindow()->isDirty();
|
||||
}
|
||||
bool DialogDesigner::isChanged() { return m_designerHolder->formWindow()->isDirty(); }
|
||||
|
||||
void DialogDesigner::setChanged(bool value)
|
||||
{
|
||||
m_designerHolder->formWindow()->setDirty(value);
|
||||
}
|
||||
void DialogDesigner::setChanged(bool value) { m_designerHolder->formWindow()->setDirty(value); }
|
||||
|
||||
QByteArray DialogDesigner::dialogContent()
|
||||
{
|
||||
@ -349,8 +326,10 @@ void DialogDesigner::slotDialogChanged()
|
||||
{
|
||||
Q_ASSERT(m_designerHolder != NULL);
|
||||
if (m_designerHolder && m_designerHolder->formWindow()) {
|
||||
if ( m_designerHolder->formWindow()->mainContainer()->objectName().compare(m_dialogName) !=0 ){
|
||||
emit dialogNameChanged(m_dialogName, m_designerHolder->formWindow()->mainContainer()->objectName());
|
||||
if (m_designerHolder->formWindow()->mainContainer()->objectName().compare(m_dialogName)
|
||||
!= 0) {
|
||||
emit dialogNameChanged(m_dialogName,
|
||||
m_designerHolder->formWindow()->mainContainer()->objectName());
|
||||
m_dialogName = m_designerHolder->formWindow()->mainContainer()->objectName();
|
||||
}
|
||||
emit dialogChanged(m_dialogName);
|
||||
@ -358,4 +337,4 @@ void DialogDesigner::slotDialogChanged()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
@ -1,10 +1,10 @@
|
||||
#ifndef DIALOGDESIGNER_H
|
||||
#define DIALOGDESIGNER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QVector>
|
||||
#include <QToolBar>
|
||||
#include <QActionGroup>
|
||||
#include <QObject>
|
||||
#include <QToolBar>
|
||||
#include <QVector>
|
||||
|
||||
class QDesignerFormEditorInterface;
|
||||
class QDesignerFormWindowInterface;
|
||||
@ -24,7 +24,8 @@ namespace LimeReport{
|
||||
class DialogDesigner: public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DialogDesigner(QDesignerFormWindowInterface *wnd, QDesignerFormEditorInterface* formEditor, QWidget *parent = NULL, Qt::WindowFlags flags = Qt::WindowFlags());
|
||||
DialogDesigner(QDesignerFormWindowInterface* wnd, QDesignerFormEditorInterface* formEditor,
|
||||
QWidget* parent = NULL, Qt::WindowFlags flags = Qt::WindowFlags());
|
||||
~DialogDesigner();
|
||||
QString dialogName() const;
|
||||
void setDialogName(const QString& dialogName);
|
||||
@ -40,14 +41,14 @@ signals:
|
||||
private slots:
|
||||
void slotMainContainerNameChanged(QString newName);
|
||||
void slotDialogChanged();
|
||||
|
||||
private:
|
||||
QString m_dialogName;
|
||||
SharedTools::WidgetHost* m_designerHolder;
|
||||
QDesignerFormEditorInterface* m_formEditor;
|
||||
};
|
||||
|
||||
class DialogDesignerManager : public QObject
|
||||
{
|
||||
class DialogDesignerManager: public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DialogDesignerManager(QObject* parent = 0);
|
||||
@ -70,8 +71,10 @@ private slots:
|
||||
void slotObjectDestroyed(QObject* object);
|
||||
void slotEditWidgets();
|
||||
void slotActiveFormWindowChanged(QDesignerFormWindowInterface* formWindow);
|
||||
|
||||
private:
|
||||
QString iconPathByName(const QString& name);
|
||||
|
||||
private:
|
||||
QDesignerFormEditorInterface* m_formEditor;
|
||||
QDesignerIntegrationInterface* m_designerIntegration;
|
||||
|
@ -1,25 +1,29 @@
|
||||
#include <QPrinter>
|
||||
|
||||
#include "lrpdfexporter.h"
|
||||
|
||||
#include "lrexportersfactory.h"
|
||||
#include "lrreportengine_p.h"
|
||||
|
||||
#include <QPrinter>
|
||||
|
||||
namespace {
|
||||
|
||||
LimeReport::ReportExporterInterface* createPDFExporter(LimeReport::ReportEnginePrivate* parent){
|
||||
LimeReport::ReportExporterInterface* createPDFExporter(LimeReport::ReportEnginePrivate* parent)
|
||||
{
|
||||
return new LimeReport::PDFExporter(parent);
|
||||
}
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::ExportersFactory::instance().registerCreator("PDF", LimeReport::ExporterAttribs(QObject::tr("Export to PDF"), "PDFExporter"), createPDFExporter);
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::ExportersFactory::instance().registerCreator(
|
||||
"PDF", LimeReport::ExporterAttribs(QObject::tr("Export to PDF"), "PDFExporter"),
|
||||
createPDFExporter);
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
PDFExporter::PDFExporter(ReportEnginePrivate *parent) : QObject(parent), m_reportEngine(parent)
|
||||
{}
|
||||
PDFExporter::PDFExporter(ReportEnginePrivate* parent): QObject(parent), m_reportEngine(parent) { }
|
||||
|
||||
bool PDFExporter::exportPages(ReportPages pages, const QString &fileName, const QMap<QString, QVariant> ¶ms)
|
||||
bool PDFExporter::exportPages(ReportPages pages, const QString& fileName,
|
||||
const QMap<QString, QVariant>& params)
|
||||
{
|
||||
Q_UNUSED(params);
|
||||
if (!fileName.isEmpty()) {
|
||||
@ -35,4 +39,4 @@ bool PDFExporter::exportPages(ReportPages pages, const QString &fileName, const
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
@ -1,31 +1,24 @@
|
||||
#ifndef LRPDFEXPORTER_H
|
||||
#define LRPDFEXPORTER_H
|
||||
|
||||
#include <QObject>
|
||||
#include "lrexporterintf.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace LimeReport {
|
||||
class ReportEnginePrivate;
|
||||
|
||||
class PDFExporter : public QObject, public ReportExporterInterface
|
||||
{
|
||||
class PDFExporter: public QObject, public ReportExporterInterface {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PDFExporter(ReportEnginePrivate* parent = NULL);
|
||||
// ReportExporterInterface interface
|
||||
bool exportPages(ReportPages pages, const QString &fileName, const QMap<QString, QVariant> ¶ms);
|
||||
QString exporterName()
|
||||
{
|
||||
return "PDF";
|
||||
}
|
||||
QString exporterFileExt()
|
||||
{
|
||||
return "pdf";
|
||||
}
|
||||
QString hint()
|
||||
{
|
||||
return tr("Export to PDF");
|
||||
}
|
||||
bool exportPages(ReportPages pages, const QString& fileName,
|
||||
const QMap<QString, QVariant>& params);
|
||||
QString exporterName() { return "PDF"; }
|
||||
QString exporterFileExt() { return "pdf"; }
|
||||
QString hint() { return tr("Export to PDF"); }
|
||||
|
||||
private:
|
||||
ReportEnginePrivate* m_reportEngine;
|
||||
};
|
||||
|
@ -10,12 +10,8 @@ void GridLinesChart::paintChart(QPainter *painter, QRectF chartRect)
|
||||
|
||||
const qreal valuesVMargin = this->valuesVMargin(painter);
|
||||
|
||||
QRectF gridRect = chartRect.adjusted(
|
||||
hPadding,
|
||||
vPadding + valuesVMargin * 2,
|
||||
-hPadding * 3,
|
||||
-vPadding * 3
|
||||
);
|
||||
QRectF gridRect
|
||||
= chartRect.adjusted(hPadding, vPadding + valuesVMargin * 2, -hPadding * 3, -vPadding * 3);
|
||||
|
||||
if (!m_chartItem->horizontalAxisOnTop()) {
|
||||
// If horizontal axis is on the bottom, move grid a little up
|
||||
@ -23,9 +19,9 @@ void GridLinesChart::paintChart(QPainter *painter, QRectF chartRect)
|
||||
}
|
||||
|
||||
// Adapt font for horizontal axis
|
||||
painter->setFont(adaptFont((gridRect.width() - this->valuesHMargin(painter)) / xAxisData().segmentCount() * 0.8,
|
||||
painter->font(),
|
||||
xAxisData()));
|
||||
painter->setFont(adaptFont((gridRect.width() - this->valuesHMargin(painter))
|
||||
/ xAxisData().segmentCount() * 0.8,
|
||||
painter->font(), xAxisData()));
|
||||
|
||||
const qreal valuesHMargin = this->valuesHMargin(painter);
|
||||
|
||||
@ -34,15 +30,13 @@ void GridLinesChart::paintChart(QPainter *painter, QRectF chartRect)
|
||||
|
||||
paintGrid(painter, gridRect);
|
||||
|
||||
paintSerialLines(
|
||||
painter,
|
||||
gridRect.adjusted(hPadding + valuesHMargin, 0, 0, 0)
|
||||
);
|
||||
paintSerialLines(painter, gridRect.adjusted(hPadding + valuesHMargin, 0, 0, 0));
|
||||
}
|
||||
|
||||
void GridLinesChart::paintSerialLines(QPainter* painter, QRectF barsRect)
|
||||
{
|
||||
if (valuesCount() == 0) return;
|
||||
if (valuesCount() == 0)
|
||||
return;
|
||||
|
||||
painter->save();
|
||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||
@ -109,4 +103,4 @@ void GridLinesChart::paintSerialLines(QPainter* painter, QRectF barsRect)
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
@ -12,6 +12,6 @@ public:
|
||||
private:
|
||||
void paintSerialLines(QPainter* painter, QRectF barsRect);
|
||||
};
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // GRIDLINESCHART_H
|
||||
|
@ -8,33 +8,28 @@ void HorizontalBarChart::paintChart(QPainter *painter, QRectF chartRect)
|
||||
|
||||
const qreal valuesVMargin = this->valuesVMargin(painter);
|
||||
|
||||
QRectF calcRect = verticalLabelsRect(painter, chartRect.adjusted(
|
||||
hPadding(chartRect),
|
||||
vPadding(chartRect) * 2,
|
||||
-(chartRect.width() * 0.9),
|
||||
-(vPadding(chartRect) * 2 + valuesVMargin)
|
||||
));
|
||||
QRectF calcRect = verticalLabelsRect(
|
||||
painter,
|
||||
chartRect.adjusted(hPadding(chartRect), vPadding(chartRect) * 2, -(chartRect.width() * 0.9),
|
||||
-(vPadding(chartRect) * 2 + valuesVMargin)));
|
||||
|
||||
qreal barsShift = calcRect.width();
|
||||
|
||||
paintHorizontalGrid(painter, chartRect.adjusted(
|
||||
hPadding(chartRect) + barsShift,
|
||||
vPadding(chartRect),
|
||||
-(hPadding(chartRect)),
|
||||
-vPadding(chartRect)));
|
||||
paintHorizontalGrid(painter,
|
||||
chartRect.adjusted(hPadding(chartRect) + barsShift, vPadding(chartRect),
|
||||
-(hPadding(chartRect)), -vPadding(chartRect)));
|
||||
|
||||
paintHorizontalBars(painter, chartRect.adjusted(
|
||||
hPadding(chartRect) + barsShift,
|
||||
vPadding(chartRect) * 2,
|
||||
-(hPadding(chartRect)),
|
||||
-(vPadding(chartRect) * 2) ));
|
||||
paintHorizontalBars(painter,
|
||||
chartRect.adjusted(hPadding(chartRect) + barsShift, vPadding(chartRect) * 2,
|
||||
-(hPadding(chartRect)), -(vPadding(chartRect) * 2)));
|
||||
|
||||
paintVerticalLabels(painter, calcRect);
|
||||
}
|
||||
|
||||
void HorizontalBarChart::paintHorizontalBars(QPainter* painter, QRectF barsRect)
|
||||
{
|
||||
if (seriesCount() == 0) return;
|
||||
if (seriesCount() == 0)
|
||||
return;
|
||||
|
||||
painter->save();
|
||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||
@ -44,7 +39,9 @@ void HorizontalBarChart::paintHorizontalBars(QPainter *painter, QRectF barsRect)
|
||||
|
||||
const qreal verticalOffset = painter->fontMetrics().height();
|
||||
qreal vStep = (barsRect.height() - verticalOffset) / valuesCount() / seriesCount();
|
||||
qreal hStep = (barsRect.width()-painter->fontMetrics().boundingRect(QString::number(maxValue())).width()) / delta;
|
||||
qreal hStep = (barsRect.width()
|
||||
- painter->fontMetrics().boundingRect(QString::number(maxValue())).width())
|
||||
/ delta;
|
||||
|
||||
if (!m_chartItem->series().isEmpty() && (m_chartItem->itemMode() != DesignMode)) {
|
||||
qreal curVOffset = barsRect.top();
|
||||
@ -55,7 +52,8 @@ void HorizontalBarChart::paintHorizontalBars(QPainter *painter, QRectF barsRect)
|
||||
painter->setBrush(series->color());
|
||||
qreal y = curVOffset;
|
||||
foreach (qreal value, series->data()->values()) {
|
||||
painter->drawRect(QRectF((-minValue()*hStep)+barsRect.left(), y, value*hStep, vStep));
|
||||
painter->drawRect(
|
||||
QRectF((-minValue() * hStep) + barsRect.left(), y, value * hStep, vStep));
|
||||
y += vStep * seriesCount();
|
||||
}
|
||||
curVOffset += vStep;
|
||||
@ -67,9 +65,11 @@ void HorizontalBarChart::paintHorizontalBars(QPainter *painter, QRectF barsRect)
|
||||
}
|
||||
int curColor = 0;
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
if (curColor==3) curColor=0;
|
||||
if (curColor == 3)
|
||||
curColor = 0;
|
||||
painter->setBrush(color_map[curColor]);
|
||||
painter->drawRect(QRectF(barsRect.left(), curVOffset, designValues()[i]*hStep, vStep));
|
||||
painter->drawRect(
|
||||
QRectF(barsRect.left(), curVOffset, designValues()[i] * hStep, vStep));
|
||||
curVOffset += vStep;
|
||||
curColor++;
|
||||
}
|
||||
@ -77,4 +77,4 @@ void HorizontalBarChart::paintHorizontalBars(QPainter *painter, QRectF barsRect)
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
@ -11,59 +11,42 @@ void LinesChart::paintChart(QPainter *painter, QRectF chartRect)
|
||||
|
||||
QRectF calcRect = horizontalLabelsRect(
|
||||
painter,
|
||||
chartRect.adjusted(
|
||||
hPadding(chartRect) * 2 + valuesHMargin,
|
||||
chartRect.height() - (painter->fontMetrics().height() + vPadding(chartRect)*2),
|
||||
-(hPadding(chartRect) * 2),
|
||||
-vPadding(chartRect)
|
||||
)
|
||||
);
|
||||
chartRect.adjusted(hPadding(chartRect) * 2 + valuesHMargin,
|
||||
chartRect.height()
|
||||
- (painter->fontMetrics().height() + vPadding(chartRect) * 2),
|
||||
-(hPadding(chartRect) * 2), -vPadding(chartRect)));
|
||||
qreal barsShift = calcRect.height();
|
||||
paintVerticalGrid(
|
||||
painter,
|
||||
chartRect.adjusted(
|
||||
hPadding(chartRect),
|
||||
vPadding(chartRect) + valuesVMargin,
|
||||
-hPadding(chartRect),
|
||||
-(vPadding(chartRect) + barsShift)
|
||||
)
|
||||
);
|
||||
paintSerialLines(
|
||||
painter,
|
||||
chartRect.adjusted(
|
||||
hPadding(chartRect) * 2 + valuesHMargin,
|
||||
paintVerticalGrid(painter,
|
||||
chartRect.adjusted(hPadding(chartRect), vPadding(chartRect) + valuesVMargin,
|
||||
-hPadding(chartRect), -(vPadding(chartRect) + barsShift)));
|
||||
paintSerialLines(painter,
|
||||
chartRect.adjusted(hPadding(chartRect) * 2 + valuesHMargin,
|
||||
vPadding(chartRect) + valuesVMargin,
|
||||
-(hPadding(chartRect) * 2),
|
||||
-(vPadding(chartRect)+barsShift)
|
||||
)
|
||||
);
|
||||
-(vPadding(chartRect) + barsShift)));
|
||||
paintHorizontalLabels(painter, calcRect);
|
||||
}
|
||||
|
||||
void LinesChart::drawDesignMode(QPainter* painter, qreal hStep, qreal vStep, qreal topShift, QRectF barsRect){
|
||||
void LinesChart::drawDesignMode(QPainter* painter, qreal hStep, qreal vStep, qreal topShift,
|
||||
QRectF barsRect)
|
||||
{
|
||||
for (int i = 0; i < valuesCount() - 1; ++i) {
|
||||
QPoint startPoint = QPoint((i + 1) * hStep + barsRect.left() - hStep / 2,
|
||||
(maxValue() * vStep+topShift) - designValues()[i] * vStep
|
||||
);
|
||||
(maxValue() * vStep + topShift) - designValues()[i] * vStep);
|
||||
QPoint endPoint = QPoint((i + 2) * hStep + barsRect.left() - hStep / 2,
|
||||
(maxValue() * vStep+topShift) - designValues()[i+1] * vStep
|
||||
);
|
||||
(maxValue() * vStep + topShift) - designValues()[i + 1] * vStep);
|
||||
drawSegment(painter, startPoint, endPoint, color_map[0]);
|
||||
|
||||
startPoint = QPoint((i + 1) * hStep + barsRect.left() - hStep / 2,
|
||||
(maxValue() * vStep+topShift) - designValues()[i+3] * vStep
|
||||
);
|
||||
(maxValue() * vStep + topShift) - designValues()[i + 3] * vStep);
|
||||
endPoint = QPoint((i + 2) * hStep + barsRect.left() - hStep / 2,
|
||||
(maxValue() * vStep+topShift) - designValues()[i+3+1] * vStep
|
||||
);
|
||||
(maxValue() * vStep + topShift) - designValues()[i + 3 + 1] * vStep);
|
||||
drawSegment(painter, startPoint, endPoint, color_map[1]);
|
||||
|
||||
startPoint = QPoint((i + 1) * hStep + barsRect.left() - hStep / 2,
|
||||
(maxValue() * vStep+topShift) - designValues()[i+6] * vStep
|
||||
);
|
||||
(maxValue() * vStep + topShift) - designValues()[i + 6] * vStep);
|
||||
endPoint = QPoint((i + 2) * hStep + barsRect.left() - hStep / 2,
|
||||
(maxValue() * vStep+topShift) - designValues()[i+6+1] * vStep
|
||||
);
|
||||
(maxValue() * vStep + topShift) - designValues()[i + 6 + 1] * vStep);
|
||||
drawSegment(painter, startPoint, endPoint, color_map[2]);
|
||||
}
|
||||
}
|
||||
@ -118,7 +101,8 @@ void LinesChart::paintSeries(QPainter *painter, SeriesItem *series, QRectF barsR
|
||||
|
||||
void LinesChart::paintSerialLines(QPainter* painter, QRectF barsRect)
|
||||
{
|
||||
if (valuesCount() == 0) return;
|
||||
if (valuesCount() == 0)
|
||||
return;
|
||||
|
||||
painter->save();
|
||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||
@ -142,4 +126,3 @@ void LinesChart::paintSerialLines(QPainter* painter, QRectF barsRect)
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
|
@ -8,14 +8,16 @@ class LinesChart: public AbstractBarChart{
|
||||
public:
|
||||
LinesChart(ChartItem* chartItem): AbstractBarChart(chartItem) { }
|
||||
void paintChart(QPainter* painter, QRectF chartRect);
|
||||
|
||||
protected:
|
||||
void drawDesignMode(QPainter *painter, qreal hStep, qreal vStep, qreal topShift, QRectF barsRect);
|
||||
void drawDesignMode(QPainter* painter, qreal hStep, qreal vStep, qreal topShift,
|
||||
QRectF barsRect);
|
||||
qreal calculatePos(const AxisData& data, qreal value, qreal rectSize) const;
|
||||
void paintSeries(QPainter* painter, SeriesItem* series, QRectF barsRect);
|
||||
|
||||
private:
|
||||
void paintSerialLines(QPainter* painter, QRectF barsRect);
|
||||
};
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LINESCHART_H
|
||||
|
@ -6,7 +6,8 @@ void PieChart::drawPercent(QPainter *painter, QRectF chartRect, qreal startAngle
|
||||
{
|
||||
painter->save();
|
||||
|
||||
QPointF center(chartRect.left()+chartRect.width()/2,chartRect.top()+chartRect.height()/2);
|
||||
QPointF center(chartRect.left() + chartRect.width() / 2,
|
||||
chartRect.top() + chartRect.height() / 2);
|
||||
qreal percent = angle / 3.6;
|
||||
#if QT_VERSION < 0x050000
|
||||
qreal radAngle = (angle / 2 + startAngle) * (M_PI / 180);
|
||||
@ -27,7 +28,6 @@ void PieChart::drawPercent(QPainter *painter, QRectF chartRect, qreal startAngle
|
||||
if (arcLength >= radius)
|
||||
painter->drawText(textRect, Qt::AlignCenter, QString::number(percent, 'f', 1) + "%");
|
||||
painter->restore();
|
||||
|
||||
}
|
||||
|
||||
void PieChart::paintChart(QPainter* painter, QRectF chartRect)
|
||||
@ -44,8 +44,8 @@ void PieChart::paintChart(QPainter *painter, QRectF chartRect)
|
||||
QRectF tmpRect = chartRect;
|
||||
if (chartRect.height() > chartRect.width()) {
|
||||
tmpRect.setHeight(chartRect.width());
|
||||
tmpRect.adjust(0,(chartRect.bottom()-tmpRect.bottom())/2,
|
||||
0,(chartRect.bottom()-tmpRect.bottom())/2);
|
||||
tmpRect.adjust(0, (chartRect.bottom() - tmpRect.bottom()) / 2, 0,
|
||||
(chartRect.bottom() - tmpRect.bottom()) / 2);
|
||||
} else {
|
||||
tmpRect.setWidth(chartRect.height());
|
||||
}
|
||||
@ -53,7 +53,8 @@ void PieChart::paintChart(QPainter *painter, QRectF chartRect)
|
||||
chartRect = tmpRect;
|
||||
painter->drawRect(chartRect);
|
||||
|
||||
if (!m_chartItem->series().isEmpty()&&!m_chartItem->series().at(0)->data()->values().isEmpty()){
|
||||
if (!m_chartItem->series().isEmpty()
|
||||
&& !m_chartItem->series().at(0)->data()->values().isEmpty()) {
|
||||
SeriesItem* si = m_chartItem->series().at(0);
|
||||
qreal sum = 0;
|
||||
foreach (qreal value, si->data()->values()) {
|
||||
@ -100,25 +101,23 @@ void PieChart::paintChartLegend(QPainter *painter, QRectF legendRect)
|
||||
painter->drawRect(legendRect);
|
||||
|
||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||
QRectF indicatorsRect = legendRect.adjusted(painter->fontMetrics().height()/2,painter->fontMetrics().height()/2,0,0);
|
||||
QRectF indicatorsRect = legendRect.adjusted(painter->fontMetrics().height() / 2,
|
||||
painter->fontMetrics().height() / 2, 0, 0);
|
||||
|
||||
if (!m_chartItem->series().isEmpty() && !m_chartItem->series().at(0)->data()->labels().isEmpty()){
|
||||
if (!m_chartItem->series().isEmpty()
|
||||
&& !m_chartItem->series().at(0)->data()->labels().isEmpty()) {
|
||||
qreal cw = 0;
|
||||
SeriesItem* si = m_chartItem->series().at(0);
|
||||
for (int i = 0; i < si->data()->labels().count(); ++i) {
|
||||
QString label = si->data()->labels().at(i);
|
||||
painter->setPen(Qt::black);
|
||||
painter->drawText(indicatorsRect.adjusted(indicatorSize+indicatorSize/2,cw,0,0),label);
|
||||
painter->drawText(indicatorsRect.adjusted(indicatorSize + indicatorSize / 2, cw, 0, 0),
|
||||
label);
|
||||
painter->setPen(si->data()->colors().at(i));
|
||||
painter->setBrush(si->data()->colors().at(i));
|
||||
painter->drawEllipse(
|
||||
indicatorsRect.adjusted(
|
||||
0,
|
||||
cw+indicatorSize/2,
|
||||
-(indicatorsRect.width()-indicatorSize),
|
||||
-(indicatorsRect.height()-(cw+indicatorSize+indicatorSize/2))
|
||||
)
|
||||
);
|
||||
painter->drawEllipse(indicatorsRect.adjusted(
|
||||
0, cw + indicatorSize / 2, -(indicatorsRect.width() - indicatorSize),
|
||||
-(indicatorsRect.height() - (cw + indicatorSize + indicatorSize / 2))));
|
||||
cw += painter->fontMetrics().height();
|
||||
}
|
||||
} else if (m_chartItem->itemMode() == DesignMode) {
|
||||
@ -126,20 +125,15 @@ void PieChart::paintChartLegend(QPainter *painter, QRectF legendRect)
|
||||
for (int i = 0; i < m_designLabels.size(); ++i) {
|
||||
QString label = m_designLabels.at(i);
|
||||
painter->setPen(Qt::black);
|
||||
painter->drawText(indicatorsRect.adjusted(indicatorSize+indicatorSize/2,cw,0,0),label);
|
||||
painter->drawText(indicatorsRect.adjusted(indicatorSize + indicatorSize / 2, cw, 0, 0),
|
||||
label);
|
||||
painter->setBrush(color_map[i]);
|
||||
painter->setPen(color_map[i]);
|
||||
painter->drawEllipse(
|
||||
indicatorsRect.adjusted(
|
||||
0,
|
||||
cw+indicatorSize/2,
|
||||
-(indicatorsRect.width()-indicatorSize),
|
||||
-(indicatorsRect.height()-(cw+indicatorSize+indicatorSize/2))
|
||||
)
|
||||
);
|
||||
painter->drawEllipse(indicatorsRect.adjusted(
|
||||
0, cw + indicatorSize / 2, -(indicatorsRect.width() - indicatorSize),
|
||||
-(indicatorsRect.height() - (cw + indicatorSize + indicatorSize / 2))));
|
||||
cw += painter->fontMetrics().height();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -150,7 +144,8 @@ QSizeF PieChart::calcChartLegendSize(const QFont &font, qreal)
|
||||
qreal cw = 0;
|
||||
qreal maxWidth = 0;
|
||||
|
||||
if (!m_chartItem->series().isEmpty() && !m_chartItem->series().at(0)->data()->labels().isEmpty()){
|
||||
if (!m_chartItem->series().isEmpty()
|
||||
&& !m_chartItem->series().at(0)->data()->labels().isEmpty()) {
|
||||
SeriesItem* si = m_chartItem->series().at(0);
|
||||
foreach (QString label, si->data()->labels()) {
|
||||
cw += fm.height();
|
||||
@ -168,4 +163,4 @@ QSizeF PieChart::calcChartLegendSize(const QFont &font, qreal)
|
||||
return QSizeF(maxWidth + fm.height() * 2, cw);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
@ -11,6 +11,7 @@ public:
|
||||
QSizeF calcChartLegendSize(const QFont& font, qreal maxWidth = 0);
|
||||
void paintChart(QPainter* painter, QRectF chartRect);
|
||||
void paintChartLegend(QPainter* painter, QRectF legendRect);
|
||||
|
||||
protected:
|
||||
void drawPercent(QPainter* painter, QRectF chartRect, qreal startAngle, qreal angle);
|
||||
};
|
||||
|
@ -11,59 +11,45 @@ void VerticalBarChart::paintChart(QPainter *painter, QRectF chartRect)
|
||||
|
||||
QRectF calcRect = horizontalLabelsRect(
|
||||
painter,
|
||||
chartRect.adjusted(
|
||||
hPadding(chartRect) * 2 + valuesHMargin,
|
||||
chartRect.height() - (painter->fontMetrics().height() + vPadding(chartRect) * 2),
|
||||
-(hPadding(chartRect) * 2),
|
||||
-vPadding(chartRect)
|
||||
)
|
||||
);
|
||||
chartRect.adjusted(hPadding(chartRect) * 2 + valuesHMargin,
|
||||
chartRect.height()
|
||||
- (painter->fontMetrics().height() + vPadding(chartRect) * 2),
|
||||
-(hPadding(chartRect) * 2), -vPadding(chartRect)));
|
||||
qreal barsShift = calcRect.height();
|
||||
paintVerticalGrid(
|
||||
painter,
|
||||
chartRect.adjusted(
|
||||
hPadding(chartRect),
|
||||
vPadding(chartRect) + valuesVMargin,
|
||||
-hPadding(chartRect),
|
||||
-(vPadding(chartRect) + barsShift)
|
||||
)
|
||||
);
|
||||
paintVerticalBars(
|
||||
painter,
|
||||
chartRect.adjusted(
|
||||
hPadding(chartRect) * 2 + valuesHMargin,
|
||||
paintVerticalGrid(painter,
|
||||
chartRect.adjusted(hPadding(chartRect), vPadding(chartRect) + valuesVMargin,
|
||||
-hPadding(chartRect), -(vPadding(chartRect) + barsShift)));
|
||||
paintVerticalBars(painter,
|
||||
chartRect.adjusted(hPadding(chartRect) * 2 + valuesHMargin,
|
||||
vPadding(chartRect) + valuesVMargin,
|
||||
-hPadding(chartRect) * 2,
|
||||
-(vPadding(chartRect) + barsShift)
|
||||
)
|
||||
);
|
||||
paintSerialLines(
|
||||
painter,
|
||||
chartRect.adjusted(
|
||||
hPadding(chartRect) * 2 + valuesHMargin,
|
||||
-(vPadding(chartRect) + barsShift)));
|
||||
paintSerialLines(painter,
|
||||
chartRect.adjusted(hPadding(chartRect) * 2 + valuesHMargin,
|
||||
vPadding(chartRect) + valuesVMargin,
|
||||
-hPadding(chartRect) * 2,
|
||||
-(vPadding(chartRect) + barsShift)
|
||||
)
|
||||
);
|
||||
-(vPadding(chartRect) + barsShift)));
|
||||
paintHorizontalLabels(painter, calcRect);
|
||||
}
|
||||
|
||||
void VerticalBarChart::paintVerticalBars(QPainter* painter, QRectF barsRect)
|
||||
{
|
||||
|
||||
if (valuesCount() == 0) return;
|
||||
if (valuesCount() == 0)
|
||||
return;
|
||||
|
||||
const AxisData& yAxisData = this->yAxisData();
|
||||
const qreal delta = yAxisData.delta();
|
||||
|
||||
int barSeriesCount = 0;
|
||||
foreach (SeriesItem* series, m_chartItem->series()) {
|
||||
if (series->preferredType() == SeriesItem::Bar) barSeriesCount++;
|
||||
if (series->preferredType() == SeriesItem::Bar)
|
||||
barSeriesCount++;
|
||||
}
|
||||
|
||||
barSeriesCount = (m_chartItem->itemMode() == DesignMode) ? seriesCount() : barSeriesCount;
|
||||
if (barSeriesCount < 1) return;
|
||||
if (barSeriesCount < 1)
|
||||
return;
|
||||
painter->save();
|
||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||
|
||||
@ -78,7 +64,8 @@ void VerticalBarChart::paintVerticalBars(QPainter *painter, QRectF barsRect)
|
||||
qreal curHOffset = curSeries * hStep + barsRect.left();
|
||||
painter->setBrush(series->color());
|
||||
foreach (qreal value, series->data()->values()) {
|
||||
painter->drawRect(QRectF(curHOffset, maxValue() * vStep + topShift, hStep, -value * vStep));
|
||||
painter->drawRect(
|
||||
QRectF(curHOffset, maxValue() * vStep + topShift, hStep, -value * vStep));
|
||||
curHOffset += hStep * barSeriesCount;
|
||||
}
|
||||
curSeries++;
|
||||
@ -88,9 +75,11 @@ void VerticalBarChart::paintVerticalBars(QPainter *painter, QRectF barsRect)
|
||||
qreal curHOffset = barsRect.left();
|
||||
int curColor = 0;
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
if (curColor == 3) curColor = 0;
|
||||
if (curColor == 3)
|
||||
curColor = 0;
|
||||
painter->setBrush(color_map[curColor]);
|
||||
painter->drawRect(QRectF(curHOffset, maxValue() * vStep + barsRect.top(), hStep, -designValues()[i] * vStep));
|
||||
painter->drawRect(QRectF(curHOffset, maxValue() * vStep + barsRect.top(), hStep,
|
||||
-designValues()[i] * vStep));
|
||||
curHOffset += hStep;
|
||||
curColor++;
|
||||
}
|
||||
@ -100,7 +89,8 @@ void VerticalBarChart::paintVerticalBars(QPainter *painter, QRectF barsRect)
|
||||
|
||||
void VerticalBarChart::paintSerialLines(QPainter* painter, QRectF barsRect)
|
||||
{
|
||||
if (valuesCount() == 0 || m_chartItem->series().isEmpty() ) return;
|
||||
if (valuesCount() == 0 || m_chartItem->series().isEmpty())
|
||||
return;
|
||||
|
||||
painter->save();
|
||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||
|
@ -31,8 +31,9 @@
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
FontEditorWidget::FontEditorWidget(const QString& title, QWidget* parent)
|
||||
:ItemEditorWidget(title, parent), m_ignoreSlots(false)
|
||||
FontEditorWidget::FontEditorWidget(const QString& title, QWidget* parent):
|
||||
ItemEditorWidget(title, parent),
|
||||
m_ignoreSlots(false)
|
||||
{
|
||||
initEditor();
|
||||
}
|
||||
@ -45,7 +46,6 @@ void FontEditorWidget::setItemEvent(BaseDesignIntf* item)
|
||||
updateValues(font.value<QFont>());
|
||||
setEnabled(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void FontEditorWidget::initEditor()
|
||||
@ -56,17 +56,37 @@ void FontEditorWidget::initEditor()
|
||||
|
||||
m_fontNameEditor = new QFontComboBox(this);
|
||||
m_fontNameEditor->setFontFilters(QFontComboBox::AllFonts);
|
||||
connect(m_fontNameEditor,SIGNAL(currentFontChanged(QFont)),this,SLOT(slotFontChanged(QFont)));
|
||||
connect(m_fontNameEditor, SIGNAL(currentFontChanged(QFont)), this,
|
||||
SLOT(slotFontChanged(QFont)));
|
||||
addWidget(m_fontNameEditor);
|
||||
|
||||
m_fontSizeModel.setStringList(QStringList()<<"6"<<"7"<<"8"<<"9"<<"10"<<"11"<<"12"<<"14"<<"16"<<"18"<<"20"<<"24"<<"28"<<"30"<<"36"<<"48"<<"64"<<"72");
|
||||
m_fontSizeModel.setStringList(QStringList() << "6"
|
||||
<< "7"
|
||||
<< "8"
|
||||
<< "9"
|
||||
<< "10"
|
||||
<< "11"
|
||||
<< "12"
|
||||
<< "14"
|
||||
<< "16"
|
||||
<< "18"
|
||||
<< "20"
|
||||
<< "24"
|
||||
<< "28"
|
||||
<< "30"
|
||||
<< "36"
|
||||
<< "48"
|
||||
<< "64"
|
||||
<< "72");
|
||||
m_fontSizeEditor = new QComboBox(this);
|
||||
m_fontSizeEditor->setModel(&m_fontSizeModel);
|
||||
m_fontSizeEditor->setEditable(true);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
connect(m_fontSizeEditor,SIGNAL(currentTextChanged(QString)),this,SLOT(slotFontSizeChanged(QString)));
|
||||
connect(m_fontSizeEditor, SIGNAL(currentTextChanged(QString)), this,
|
||||
SLOT(slotFontSizeChanged(QString)));
|
||||
#else
|
||||
connect(m_fontSizeEditor,SIGNAL(currentIndexChanged(QString)),this,SLOT(slotFontSizeChanged(QString)));
|
||||
connect(m_fontSizeEditor, SIGNAL(currentIndexChanged(QString)), this,
|
||||
SLOT(slotFontSizeChanged(QString)));
|
||||
#endif
|
||||
addWidget(m_fontSizeEditor);
|
||||
|
||||
@ -90,7 +110,6 @@ void FontEditorWidget::initEditor()
|
||||
m_fontUnderline->setCheckable(true);
|
||||
connect(m_fontUnderline, SIGNAL(toggled(bool)), this, SLOT(slotFontAttribsChanged(bool)));
|
||||
addAction(m_fontUnderline);
|
||||
|
||||
}
|
||||
|
||||
void FontEditorWidget::updateValues(const QFont& font)
|
||||
@ -104,11 +123,7 @@ void FontEditorWidget::updateValues(const QFont& font)
|
||||
m_ignoreSlots = false;
|
||||
}
|
||||
|
||||
bool FontEditorWidget::ignoreSlots() const
|
||||
{
|
||||
return m_ignoreSlots;
|
||||
}
|
||||
|
||||
bool FontEditorWidget::ignoreSlots() const { return m_ignoreSlots; }
|
||||
|
||||
void FontEditorWidget::slotFontChanged(const QFont& /*font*/)
|
||||
{
|
||||
@ -117,14 +132,16 @@ void FontEditorWidget::slotFontChanged(const QFont& /*font*/)
|
||||
|
||||
void FontEditorWidget::slotFontSizeChanged(const QString& value)
|
||||
{
|
||||
if (m_ignoreSlots) return;
|
||||
if (m_ignoreSlots)
|
||||
return;
|
||||
m_resFont = fontNameEditor()->currentFont();
|
||||
m_resFont.setPointSize(value.toInt());
|
||||
}
|
||||
|
||||
void FontEditorWidget::slotFontAttribsChanged(bool)
|
||||
{
|
||||
if (m_ignoreSlots) return;
|
||||
if (m_ignoreSlots)
|
||||
return;
|
||||
m_resFont = m_fontNameEditor->currentFont();
|
||||
m_resFont.setPointSize(m_fontSizeEditor->currentText().toInt());
|
||||
m_resFont.setBold(m_fontBold->isChecked());
|
||||
@ -132,7 +149,8 @@ void FontEditorWidget::slotFontAttribsChanged(bool)
|
||||
m_resFont.setUnderline(m_fontUnderline->isChecked());
|
||||
}
|
||||
|
||||
void FontEditorWidget::slotPropertyChanged(const QString &objectName, const QString &property, const QVariant& oldValue, const QVariant& newValue)
|
||||
void FontEditorWidget::slotPropertyChanged(const QString& objectName, const QString& property,
|
||||
const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
Q_UNUSED(oldValue)
|
||||
Q_UNUSED(newValue)
|
||||
@ -141,7 +159,6 @@ void FontEditorWidget::slotPropertyChanged(const QString &objectName, const QStr
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FontEditorWidgetForPage::slotFontChanged(const QFont& font)
|
||||
{
|
||||
if (!ignoreSlots())
|
||||
@ -167,13 +184,14 @@ void FontEditorWidgetForPage::slotFontAttribsChanged(bool value)
|
||||
#ifdef HAVE_REPORT_DESIGNER
|
||||
void FontEditorWidgetForDesigner::initEditor()
|
||||
{
|
||||
connect(m_reportEditor,SIGNAL(itemPropertyChanged(QString,QString,QVariant,QVariant)),
|
||||
this,SLOT(slotPropertyChanged(QString,QString,QVariant,QVariant)));
|
||||
connect(m_reportEditor, SIGNAL(itemPropertyChanged(QString, QString, QVariant, QVariant)), this,
|
||||
SLOT(slotPropertyChanged(QString, QString, QVariant, QVariant)));
|
||||
}
|
||||
|
||||
void FontEditorWidgetForDesigner::slotFontChanged(const QFont& font)
|
||||
{
|
||||
if (!ignoreSlots()) m_reportEditor->setFont(font);
|
||||
if (!ignoreSlots())
|
||||
m_reportEditor->setFont(font);
|
||||
}
|
||||
|
||||
void FontEditorWidgetForDesigner::slotFontSizeChanged(const QString& value)
|
||||
@ -194,5 +212,4 @@ void FontEditorWidgetForDesigner::slotFontAttribsChanged(bool value)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -30,10 +30,10 @@
|
||||
#ifndef LRFONTEDITORWIDGET_H
|
||||
#define LRFONTEDITORWIDGET_H
|
||||
|
||||
#include <QToolBar>
|
||||
#include <QAction>
|
||||
#include <QFontComboBox>
|
||||
#include <QStringListModel>
|
||||
#include <QAction>
|
||||
#include <QToolBar>
|
||||
|
||||
#ifdef HAVE_REPORT_DESIGNER
|
||||
#include "lrreportdesignwidget.h"
|
||||
@ -48,6 +48,7 @@ class FontEditorWidget :public ItemEditorWidget{
|
||||
public:
|
||||
explicit FontEditorWidget(const QString& title, QWidget* parent = 0);
|
||||
bool ignoreSlots() const;
|
||||
|
||||
protected:
|
||||
void setItemEvent(BaseDesignIntf* item);
|
||||
QFontComboBox* fontNameEditor() { return m_fontNameEditor; }
|
||||
@ -56,11 +57,13 @@ protected slots:
|
||||
virtual void slotFontChanged(const QFont&);
|
||||
virtual void slotFontSizeChanged(const QString& value);
|
||||
virtual void slotFontAttribsChanged(bool);
|
||||
void slotPropertyChanged(const QString& objectName, const QString& property, const QVariant &oldValue, const QVariant &newValue);
|
||||
void slotPropertyChanged(const QString& objectName, const QString& property,
|
||||
const QVariant& oldValue, const QVariant& newValue);
|
||||
|
||||
protected:
|
||||
QFont resFont() { return m_resFont; }
|
||||
private:
|
||||
|
||||
private:
|
||||
void updateValues(const QFont& font);
|
||||
|
||||
QFontComboBox* m_fontNameEditor;
|
||||
@ -73,18 +76,22 @@ private:
|
||||
|
||||
bool m_ignoreSlots;
|
||||
QFont m_resFont;
|
||||
|
||||
};
|
||||
|
||||
class FontEditorWidgetForPage: public FontEditorWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FontEditorWidgetForPage(PageDesignIntf* page, const QString &title, QWidget *parent = 0)
|
||||
: FontEditorWidget(title, parent), m_page(page){}
|
||||
explicit FontEditorWidgetForPage(PageDesignIntf* page, const QString& title,
|
||||
QWidget* parent = 0):
|
||||
FontEditorWidget(title, parent),
|
||||
m_page(page)
|
||||
{
|
||||
}
|
||||
protected slots:
|
||||
virtual void slotFontChanged(const QFont& font);
|
||||
virtual void slotFontSizeChanged(const QString& value);
|
||||
virtual void slotFontAttribsChanged(bool value);
|
||||
|
||||
private:
|
||||
PageDesignIntf* m_page;
|
||||
};
|
||||
@ -93,8 +100,13 @@ private:
|
||||
class FontEditorWidgetForDesigner: public FontEditorWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FontEditorWidgetForDesigner(ReportDesignWidget* reportEditor, const QString &title, QWidget *parent = 0)
|
||||
: FontEditorWidget(title, parent), m_reportEditor(reportEditor){initEditor();}
|
||||
explicit FontEditorWidgetForDesigner(ReportDesignWidget* reportEditor, const QString& title,
|
||||
QWidget* parent = 0):
|
||||
FontEditorWidget(title, parent),
|
||||
m_reportEditor(reportEditor)
|
||||
{
|
||||
initEditor();
|
||||
}
|
||||
|
||||
protected:
|
||||
void initEditor();
|
||||
@ -102,6 +114,7 @@ protected slots:
|
||||
virtual void slotFontChanged(const QFont& font);
|
||||
virtual void slotFontSizeChanged(const QString& value);
|
||||
virtual void slotFontAttribsChanged(bool value);
|
||||
|
||||
private:
|
||||
ReportDesignWidget* m_reportEditor;
|
||||
};
|
||||
|
@ -34,17 +34,19 @@ namespace LimeReport{
|
||||
void ItemEditorWidget::setItem(BaseDesignIntf* item)
|
||||
{
|
||||
if (m_item != item) {
|
||||
if (m_item) m_item->disconnect(this);
|
||||
if (m_item)
|
||||
m_item->disconnect(this);
|
||||
m_item = item;
|
||||
connect(m_item, SIGNAL(destroyed(QObject*)), this, SLOT(slotItemDestroyed(QObject*)));
|
||||
connect(m_item,SIGNAL(propertyChanged(QString,QVariant,QVariant)),
|
||||
this,SLOT(slotPropertyChanged(QString,QVariant,QVariant)));
|
||||
connect(m_item, SIGNAL(propertyChanged(QString, QVariant, QVariant)), this,
|
||||
SLOT(slotPropertyChanged(QString, QVariant, QVariant)));
|
||||
setEnabled(false);
|
||||
setItemEvent(item);
|
||||
}
|
||||
}
|
||||
|
||||
void ItemEditorWidget::properyChangedEvent(const QString& propertName, const QVariant& oldValue, const QVariant& newValue)
|
||||
void ItemEditorWidget::properyChangedEvent(const QString& propertName, const QVariant& oldValue,
|
||||
const QVariant& newValue)
|
||||
{
|
||||
Q_UNUSED(propertName)
|
||||
Q_UNUSED(oldValue)
|
||||
@ -59,13 +61,10 @@ void ItemEditorWidget::slotItemDestroyed(QObject* item)
|
||||
}
|
||||
}
|
||||
|
||||
void ItemEditorWidget::slotPropertyChanged(const QString& propertName, const QVariant& oldValue, const QVariant& newValue)
|
||||
void ItemEditorWidget::slotPropertyChanged(const QString& propertName, const QVariant& oldValue,
|
||||
const QVariant& newValue)
|
||||
{
|
||||
properyChangedEvent(propertName, oldValue, newValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -39,20 +39,26 @@
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
class ItemEditorWidget : public QToolBar
|
||||
{
|
||||
class ItemEditorWidget: public QToolBar {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ItemEditorWidget(const QString &title, QWidget *parent = 0)
|
||||
: QToolBar(title, parent), m_item(0){}
|
||||
explicit ItemEditorWidget(const QString& title, QWidget* parent = 0):
|
||||
QToolBar(title, parent),
|
||||
m_item(0)
|
||||
{
|
||||
}
|
||||
void setItem(BaseDesignIntf* item);
|
||||
|
||||
protected:
|
||||
virtual void setItemEvent(BaseDesignIntf*) { }
|
||||
virtual void properyChangedEvent(const QString& propertName, const QVariant& oldValue, const QVariant& newValue);
|
||||
virtual void properyChangedEvent(const QString& propertName, const QVariant& oldValue,
|
||||
const QVariant& newValue);
|
||||
BaseDesignIntf* item() { return m_item; }
|
||||
private slots:
|
||||
void slotItemDestroyed(QObject* item);
|
||||
void slotPropertyChanged(const QString& propertName, const QVariant& oldValue, const QVariant& newValue);
|
||||
void slotPropertyChanged(const QString& propertName, const QVariant& oldValue,
|
||||
const QVariant& newValue);
|
||||
|
||||
private:
|
||||
BaseDesignIntf* m_item;
|
||||
};
|
||||
|
@ -31,88 +31,119 @@
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
ItemsAlignmentEditorWidget::ItemsAlignmentEditorWidget(LimeReport::ReportDesignWidget* reportEditor, const QString& title, QWidget* parent)
|
||||
:QToolBar(title,parent), m_reportEditor(reportEditor), m_page(0)
|
||||
ItemsAlignmentEditorWidget::ItemsAlignmentEditorWidget(LimeReport::ReportDesignWidget* reportEditor,
|
||||
const QString& title, QWidget* parent):
|
||||
QToolBar(title, parent),
|
||||
m_reportEditor(reportEditor),
|
||||
m_page(0)
|
||||
{
|
||||
initEditor();
|
||||
}
|
||||
|
||||
ItemsAlignmentEditorWidget::ItemsAlignmentEditorWidget(ReportDesignWidget* reportEditor, QWidget* parent)
|
||||
:QToolBar(parent), m_reportEditor(reportEditor), m_page(0)
|
||||
ItemsAlignmentEditorWidget::ItemsAlignmentEditorWidget(ReportDesignWidget* reportEditor,
|
||||
QWidget* parent):
|
||||
QToolBar(parent),
|
||||
m_reportEditor(reportEditor),
|
||||
m_page(0)
|
||||
{
|
||||
initEditor();
|
||||
}
|
||||
|
||||
ItemsAlignmentEditorWidget::ItemsAlignmentEditorWidget(PageDesignIntf* page, const QString& title, QWidget* parent)
|
||||
:QToolBar(title,parent), m_reportEditor(0), m_page(page)
|
||||
ItemsAlignmentEditorWidget::ItemsAlignmentEditorWidget(PageDesignIntf* page, const QString& title,
|
||||
QWidget* parent):
|
||||
QToolBar(title, parent),
|
||||
m_reportEditor(0),
|
||||
m_page(page)
|
||||
{
|
||||
initEditor();
|
||||
}
|
||||
|
||||
ItemsAlignmentEditorWidget::ItemsAlignmentEditorWidget(PageDesignIntf* page, QWidget* parent)
|
||||
:QToolBar(parent), m_reportEditor(0), m_page(page)
|
||||
ItemsAlignmentEditorWidget::ItemsAlignmentEditorWidget(PageDesignIntf* page, QWidget* parent):
|
||||
QToolBar(parent),
|
||||
m_reportEditor(0),
|
||||
m_page(page)
|
||||
{
|
||||
initEditor();
|
||||
}
|
||||
|
||||
void ItemsAlignmentEditorWidget::slotBringToFront()
|
||||
{
|
||||
if (m_reportEditor) m_reportEditor->bringToFront();
|
||||
if (m_page) m_page->bringToFront();
|
||||
if (m_reportEditor)
|
||||
m_reportEditor->bringToFront();
|
||||
if (m_page)
|
||||
m_page->bringToFront();
|
||||
}
|
||||
|
||||
void ItemsAlignmentEditorWidget::slotSendToBack()
|
||||
{
|
||||
if (m_reportEditor) m_reportEditor->sendToBack();
|
||||
if (m_page) m_page->sendToBack();
|
||||
if (m_reportEditor)
|
||||
m_reportEditor->sendToBack();
|
||||
if (m_page)
|
||||
m_page->sendToBack();
|
||||
}
|
||||
|
||||
void ItemsAlignmentEditorWidget::slotAlignToLeft()
|
||||
{
|
||||
if (m_reportEditor) m_reportEditor->alignToLeft();
|
||||
if (m_page) m_page->alignToLeft();
|
||||
if (m_reportEditor)
|
||||
m_reportEditor->alignToLeft();
|
||||
if (m_page)
|
||||
m_page->alignToLeft();
|
||||
}
|
||||
|
||||
void ItemsAlignmentEditorWidget::slotAlignToRight()
|
||||
{
|
||||
if (m_reportEditor) m_reportEditor->alignToRight();
|
||||
if (m_page) m_page->alignToRigth();
|
||||
if (m_reportEditor)
|
||||
m_reportEditor->alignToRight();
|
||||
if (m_page)
|
||||
m_page->alignToRigth();
|
||||
}
|
||||
|
||||
void ItemsAlignmentEditorWidget::slotAlignToVCenter()
|
||||
{
|
||||
if (m_reportEditor) m_reportEditor->alignToVCenter();
|
||||
if (m_page) m_page->alignToVCenter();
|
||||
if (m_reportEditor)
|
||||
m_reportEditor->alignToVCenter();
|
||||
if (m_page)
|
||||
m_page->alignToVCenter();
|
||||
}
|
||||
|
||||
void ItemsAlignmentEditorWidget::slotAlignToTop()
|
||||
{
|
||||
if (m_reportEditor) m_reportEditor->alignToTop();
|
||||
if (m_page) m_page->alignToTop();
|
||||
if (m_reportEditor)
|
||||
m_reportEditor->alignToTop();
|
||||
if (m_page)
|
||||
m_page->alignToTop();
|
||||
}
|
||||
|
||||
void ItemsAlignmentEditorWidget::slotAlignToBottom()
|
||||
{
|
||||
if (m_reportEditor) m_reportEditor->alignToBottom();
|
||||
if (m_page) m_page->alignToBottom();
|
||||
if (m_reportEditor)
|
||||
m_reportEditor->alignToBottom();
|
||||
if (m_page)
|
||||
m_page->alignToBottom();
|
||||
}
|
||||
|
||||
void ItemsAlignmentEditorWidget::slotAlignToHCenter()
|
||||
{
|
||||
if (m_reportEditor) m_reportEditor->alignToHCenter();
|
||||
if (m_page) m_page->alignToHCenter();
|
||||
if (m_reportEditor)
|
||||
m_reportEditor->alignToHCenter();
|
||||
if (m_page)
|
||||
m_page->alignToHCenter();
|
||||
}
|
||||
|
||||
void ItemsAlignmentEditorWidget::slotSameHeight()
|
||||
{
|
||||
if (m_reportEditor) m_reportEditor->sameHeight();
|
||||
if (m_page) m_page->sameHeight();
|
||||
if (m_reportEditor)
|
||||
m_reportEditor->sameHeight();
|
||||
if (m_page)
|
||||
m_page->sameHeight();
|
||||
}
|
||||
|
||||
void ItemsAlignmentEditorWidget::slotSameWidth()
|
||||
{
|
||||
if (m_reportEditor) m_reportEditor->sameWidth();
|
||||
if (m_page) m_page->sameWidth();
|
||||
if (m_reportEditor)
|
||||
m_reportEditor->sameWidth();
|
||||
if (m_page)
|
||||
m_page->sameWidth();
|
||||
}
|
||||
|
||||
void ItemsAlignmentEditorWidget::initEditor()
|
||||
|
@ -31,18 +31,20 @@
|
||||
#define LRITEMSALIGNEDITORWIDGET_H
|
||||
|
||||
#include "lrreportdesignwidget.h"
|
||||
#include <QToolBar>
|
||||
|
||||
#include <QAction>
|
||||
#include <QToolBar>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
class ItemsAlignmentEditorWidget : public QToolBar
|
||||
{
|
||||
class ItemsAlignmentEditorWidget: public QToolBar {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ItemsAlignmentEditorWidget(ReportDesignWidget* reportEditor, const QString &title, QWidget *parent = 0);
|
||||
explicit ItemsAlignmentEditorWidget(ReportDesignWidget* reportEditor, const QString& title,
|
||||
QWidget* parent = 0);
|
||||
explicit ItemsAlignmentEditorWidget(ReportDesignWidget* reportEditor, QWidget* parent = 0);
|
||||
explicit ItemsAlignmentEditorWidget(PageDesignIntf* page, const QString &title, QWidget *parent = 0);
|
||||
explicit ItemsAlignmentEditorWidget(PageDesignIntf* page, const QString& title,
|
||||
QWidget* parent = 0);
|
||||
explicit ItemsAlignmentEditorWidget(PageDesignIntf* page, QWidget* parent = 0);
|
||||
private slots:
|
||||
void slotBringToFront();
|
||||
@ -55,6 +57,7 @@ private slots:
|
||||
void slotAlignToHCenter();
|
||||
void slotSameHeight();
|
||||
void slotSameWidth();
|
||||
|
||||
private:
|
||||
void initEditor();
|
||||
ReportDesignWidget* m_reportEditor;
|
||||
|
@ -28,14 +28,15 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lritemsborderseditorwidget.h"
|
||||
#include <QAction>
|
||||
|
||||
#include "lrbordereditor.h"
|
||||
|
||||
#include <QAction>
|
||||
namespace LimeReport {
|
||||
|
||||
void ItemsBordersEditorWidget::setItemEvent(BaseDesignIntf* item)
|
||||
{
|
||||
if(QString(item->metaObject()->className()) == "LimeReport::ShapeItem")
|
||||
{
|
||||
if (QString(item->metaObject()->className()) == "LimeReport::ShapeItem") {
|
||||
setDisabled(true);
|
||||
return;
|
||||
}
|
||||
@ -47,7 +48,9 @@ void ItemsBordersEditorWidget::setItemEvent(BaseDesignIntf* item)
|
||||
m_item = item;
|
||||
}
|
||||
|
||||
void ItemsBordersEditorWidget::properyChangedEvent(const QString& property, const QVariant& oldValue, const QVariant& newValue)
|
||||
void ItemsBordersEditorWidget::properyChangedEvent(const QString& property,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue)
|
||||
{
|
||||
Q_UNUSED(oldValue)
|
||||
if (property == "borders") {
|
||||
@ -57,17 +60,12 @@ void ItemsBordersEditorWidget::properyChangedEvent(const QString& property, cons
|
||||
}
|
||||
}
|
||||
|
||||
void ItemsBordersEditorWidget::noBordesClicked()
|
||||
{
|
||||
updateValues({});
|
||||
}
|
||||
void ItemsBordersEditorWidget::noBordesClicked() { updateValues({}); }
|
||||
|
||||
void ItemsBordersEditorWidget::allBordesClicked()
|
||||
{
|
||||
int borders = BaseDesignIntf::LeftLine |
|
||||
BaseDesignIntf::RightLine |
|
||||
BaseDesignIntf::TopLine |
|
||||
BaseDesignIntf::BottomLine;
|
||||
int borders = BaseDesignIntf::LeftLine | BaseDesignIntf::RightLine | BaseDesignIntf::TopLine
|
||||
| BaseDesignIntf::BottomLine;
|
||||
|
||||
updateValues((BaseDesignIntf::BorderLines)borders);
|
||||
}
|
||||
@ -78,7 +76,8 @@ void ItemsBordersEditorWidget::editBorderClicked()
|
||||
{
|
||||
BorderEditor be;
|
||||
be.loadItem(m_item);
|
||||
if ( be.exec() == QDialog::Rejected ) return;
|
||||
if (be.exec() == QDialog::Rejected)
|
||||
return;
|
||||
updateValues(be.borderSides());
|
||||
m_item->setBorderLinesFlags(be.borderSides());
|
||||
m_item->setBorderLineSize(be.borderWidth());
|
||||
@ -131,7 +130,6 @@ void ItemsBordersEditorWidget::initEditor()
|
||||
addAction(m_BorderEditor);
|
||||
|
||||
setEnabled(false);
|
||||
|
||||
}
|
||||
|
||||
void ItemsBordersEditorWidget::updateValues(BaseDesignIntf::BorderLines borders)
|
||||
@ -154,10 +152,7 @@ BaseDesignIntf::BorderLines ItemsBordersEditorWidget::createBorders()
|
||||
return (BaseDesignIntf::BorderLines)borders;
|
||||
}
|
||||
|
||||
bool ItemsBordersEditorWidget::changing() const
|
||||
{
|
||||
return m_changing;
|
||||
}
|
||||
bool ItemsBordersEditorWidget::changing() const { return m_changing; }
|
||||
|
||||
#ifdef HAVE_REPORT_DESIGNER
|
||||
void ItemsBordersEditorWidgetForDesigner::buttonClicked(bool)
|
||||
@ -182,14 +177,12 @@ void ItemsBordersEditorWidgetForDesigner::editBorderClicked()
|
||||
{
|
||||
BorderEditor be;
|
||||
be.loadItem(m_item);
|
||||
if ( be.exec() == QDialog::Rejected ) return;
|
||||
if (be.exec() == QDialog::Rejected)
|
||||
return;
|
||||
|
||||
m_reportEditor->setBordersExt(
|
||||
be.borderSides(),
|
||||
be.borderWidth(),
|
||||
m_reportEditor->setBordersExt(be.borderSides(), be.borderWidth(),
|
||||
(LimeReport::BaseDesignIntf::BorderStyle)be.borderStyle(),
|
||||
be.borderColor()
|
||||
);
|
||||
be.borderColor());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -30,18 +30,21 @@
|
||||
#ifndef LRITEMSBORDERSEDITORWIDGET_H
|
||||
#define LRITEMSBORDERSEDITORWIDGET_H
|
||||
|
||||
#include <QToolBar>
|
||||
#include "lrreportdesignwidget.h"
|
||||
#include "lritemeditorwidget.h"
|
||||
#include "lrreportdesignwidget.h"
|
||||
|
||||
#include <QToolBar>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
class ItemsBordersEditorWidget : public ItemEditorWidget
|
||||
{
|
||||
class ItemsBordersEditorWidget: public ItemEditorWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ItemsBordersEditorWidget(const QString &title, QWidget *parent = 0)
|
||||
: ItemEditorWidget(title, parent), m_changing(false), m_borders(0){
|
||||
explicit ItemsBordersEditorWidget(const QString& title, QWidget* parent = 0):
|
||||
ItemEditorWidget(title, parent),
|
||||
m_changing(false),
|
||||
m_borders(0)
|
||||
{
|
||||
initEditor();
|
||||
}
|
||||
bool changing() const;
|
||||
@ -50,11 +53,14 @@ protected slots:
|
||||
virtual void allBordesClicked();
|
||||
virtual void buttonClicked(bool);
|
||||
virtual void editBorderClicked();
|
||||
|
||||
protected:
|
||||
void setItemEvent(BaseDesignIntf* item);
|
||||
void properyChangedEvent(const QString &property, const QVariant &oldValue, const QVariant &newValue);
|
||||
void properyChangedEvent(const QString& property, const QVariant& oldValue,
|
||||
const QVariant& newValue);
|
||||
BaseDesignIntf::BorderLines createBorders();
|
||||
BaseDesignIntf* m_item;
|
||||
|
||||
private:
|
||||
void initEditor();
|
||||
void updateValues(BaseDesignIntf::BorderLines borders);
|
||||
@ -67,23 +73,26 @@ private:
|
||||
QAction* m_BorderEditor;
|
||||
bool m_changing;
|
||||
int m_borders;
|
||||
|
||||
};
|
||||
|
||||
#ifdef HAVE_REPORT_DESIGNER
|
||||
class ItemsBordersEditorWidgetForDesigner: public ItemsBordersEditorWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ItemsBordersEditorWidgetForDesigner(ReportDesignWidget* reportEditor, const QString &title="", QWidget *parent = 0)
|
||||
: ItemsBordersEditorWidget(title,parent), m_reportEditor(reportEditor){}
|
||||
explicit ItemsBordersEditorWidgetForDesigner(ReportDesignWidget* reportEditor,
|
||||
const QString& title = "", QWidget* parent = 0):
|
||||
ItemsBordersEditorWidget(title, parent),
|
||||
m_reportEditor(reportEditor)
|
||||
{
|
||||
}
|
||||
protected slots:
|
||||
void buttonClicked(bool);
|
||||
void noBordesClicked();
|
||||
void allBordesClicked();
|
||||
void editBorderClicked();
|
||||
|
||||
private:
|
||||
ReportDesignWidget* m_reportEditor;
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -30,8 +30,10 @@
|
||||
#include "lrtextalignmenteditorwidget.h"
|
||||
|
||||
namespace LimeReport {
|
||||
TextAlignmentEditorWidget::TextAlignmentEditorWidget(const QString& title, QWidget* parent)
|
||||
:ItemEditorWidget(title, parent), m_textAttibutesIsChanging(false), m_flag(0)
|
||||
TextAlignmentEditorWidget::TextAlignmentEditorWidget(const QString& title, QWidget* parent):
|
||||
ItemEditorWidget(title, parent),
|
||||
m_textAttibutesIsChanging(false),
|
||||
m_flag(0)
|
||||
{
|
||||
initEditor();
|
||||
}
|
||||
@ -109,19 +111,27 @@ void TextAlignmentEditorWidget::updateValues(const Qt::Alignment &align)
|
||||
Qt::Alignment TextAlignmentEditorWidget::createAlignment()
|
||||
{
|
||||
Qt::Alignment align = Qt::Alignment();
|
||||
if (m_textAliginLeft->isChecked()) align |= Qt::AlignLeft;
|
||||
if (m_textAliginHCenter->isChecked()) align |= Qt::AlignHCenter;
|
||||
if (m_textAliginRight->isChecked()) align |= Qt::AlignRight;
|
||||
if (m_textAliginJustify->isChecked()) align |= Qt::AlignJustify;
|
||||
if (m_textAliginTop->isChecked()) align |= Qt::AlignTop;
|
||||
if (m_textAliginVCenter->isChecked()) align |= Qt::AlignVCenter;
|
||||
if (m_textAliginBottom->isChecked()) align |= Qt::AlignBottom;
|
||||
if (m_textAliginLeft->isChecked())
|
||||
align |= Qt::AlignLeft;
|
||||
if (m_textAliginHCenter->isChecked())
|
||||
align |= Qt::AlignHCenter;
|
||||
if (m_textAliginRight->isChecked())
|
||||
align |= Qt::AlignRight;
|
||||
if (m_textAliginJustify->isChecked())
|
||||
align |= Qt::AlignJustify;
|
||||
if (m_textAliginTop->isChecked())
|
||||
align |= Qt::AlignTop;
|
||||
if (m_textAliginVCenter->isChecked())
|
||||
align |= Qt::AlignVCenter;
|
||||
if (m_textAliginBottom->isChecked())
|
||||
align |= Qt::AlignBottom;
|
||||
return align;
|
||||
}
|
||||
|
||||
void TextAlignmentEditorWidget::slotTextHAttribsChanged(bool)
|
||||
{
|
||||
if (m_textAttibutesIsChanging) return;
|
||||
if (m_textAttibutesIsChanging)
|
||||
return;
|
||||
m_textAttibutesIsChanging = true;
|
||||
|
||||
m_textAliginLeft->setChecked(sender() == m_textAliginLeft);
|
||||
@ -130,16 +140,21 @@ void TextAlignmentEditorWidget::slotTextHAttribsChanged(bool)
|
||||
m_textAliginJustify->setChecked(sender() == m_textAliginJustify);
|
||||
|
||||
m_flag = 0;
|
||||
if (sender()==m_textAliginLeft) m_flag |= Qt::AlignLeft;
|
||||
if (sender()==m_textAliginHCenter) m_flag |= Qt::AlignHCenter;
|
||||
if (sender()==m_textAliginRight) m_flag |= Qt::AlignRight;
|
||||
if (sender()==m_textAliginJustify) m_flag |= Qt::AlignJustify;
|
||||
if (sender() == m_textAliginLeft)
|
||||
m_flag |= Qt::AlignLeft;
|
||||
if (sender() == m_textAliginHCenter)
|
||||
m_flag |= Qt::AlignHCenter;
|
||||
if (sender() == m_textAliginRight)
|
||||
m_flag |= Qt::AlignRight;
|
||||
if (sender() == m_textAliginJustify)
|
||||
m_flag |= Qt::AlignJustify;
|
||||
m_textAttibutesIsChanging = false;
|
||||
}
|
||||
|
||||
void TextAlignmentEditorWidget::slotTextVAttribsChanged(bool)
|
||||
{
|
||||
if (m_textAttibutesIsChanging) return;
|
||||
if (m_textAttibutesIsChanging)
|
||||
return;
|
||||
m_textAttibutesIsChanging = true;
|
||||
|
||||
m_textAliginTop->setChecked(sender() == m_textAliginTop);
|
||||
@ -147,13 +162,19 @@ void TextAlignmentEditorWidget::slotTextVAttribsChanged(bool)
|
||||
m_textAliginBottom->setChecked(sender() == m_textAliginBottom);
|
||||
|
||||
m_flag = 0;
|
||||
if (sender()==m_textAliginTop) m_flag |= Qt::AlignTop;
|
||||
if (sender()==m_textAliginVCenter) m_flag |= Qt::AlignVCenter;
|
||||
if (sender()==m_textAliginBottom) m_flag |= Qt::AlignBottom;
|
||||
if (sender() == m_textAliginTop)
|
||||
m_flag |= Qt::AlignTop;
|
||||
if (sender() == m_textAliginVCenter)
|
||||
m_flag |= Qt::AlignVCenter;
|
||||
if (sender() == m_textAliginBottom)
|
||||
m_flag |= Qt::AlignBottom;
|
||||
m_textAttibutesIsChanging = false;
|
||||
}
|
||||
|
||||
void TextAlignmentEditorWidget::slotPropertyChanged(const QString &objectName, const QString &property, const QVariant &oldValue, const QVariant &newValue)
|
||||
void TextAlignmentEditorWidget::slotPropertyChanged(const QString& objectName,
|
||||
const QString& property,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue)
|
||||
{
|
||||
Q_UNUSED(oldValue)
|
||||
Q_UNUSED(newValue)
|
||||
@ -163,23 +184,21 @@ void TextAlignmentEditorWidget::slotPropertyChanged(const QString &objectName, c
|
||||
}
|
||||
}
|
||||
|
||||
int TextAlignmentEditorWidget::flag() const
|
||||
{
|
||||
return m_flag;
|
||||
}
|
||||
int TextAlignmentEditorWidget::flag() const { return m_flag; }
|
||||
|
||||
void TextAlignmentEditorWidgetForPage::initEditor()
|
||||
{
|
||||
TextAlignmentEditorWidget::initEditor();
|
||||
connect(m_page,SIGNAL(itemPropertyChanged(QString,QString,QVariant,QVariant)),
|
||||
this,SLOT(slotPropertyChanged(QString,QString,QVariant,QVariant)));
|
||||
connect(m_page, SIGNAL(itemPropertyChanged(QString, QString, QVariant, QVariant)), this,
|
||||
SLOT(slotPropertyChanged(QString, QString, QVariant, QVariant)));
|
||||
}
|
||||
|
||||
void TextAlignmentEditorWidgetForPage::slotTextHAttribsChanged(bool value)
|
||||
{
|
||||
|
||||
TextAlignmentEditorWidget::slotTextHAttribsChanged(value);
|
||||
if (m_textAttibutesIsChanging) return;
|
||||
if (m_textAttibutesIsChanging)
|
||||
return;
|
||||
m_textAttibutesIsChanging = true;
|
||||
m_page->changeSelectedGrpoupTextAlignPropperty(true, Qt::AlignmentFlag(flag()));
|
||||
m_textAttibutesIsChanging = false;
|
||||
@ -188,7 +207,8 @@ void TextAlignmentEditorWidgetForPage::slotTextHAttribsChanged(bool value)
|
||||
void TextAlignmentEditorWidgetForPage::slotTextVAttribsChanged(bool value)
|
||||
{
|
||||
TextAlignmentEditorWidget::slotTextVAttribsChanged(value);
|
||||
if (m_textAttibutesIsChanging) return;
|
||||
if (m_textAttibutesIsChanging)
|
||||
return;
|
||||
m_textAttibutesIsChanging = true;
|
||||
m_page->changeSelectedGrpoupTextAlignPropperty(false, Qt::AlignmentFlag(flag()));
|
||||
m_textAttibutesIsChanging = false;
|
||||
@ -197,15 +217,15 @@ void TextAlignmentEditorWidgetForPage::slotTextVAttribsChanged(bool value)
|
||||
#ifdef HAVE_REPORT_DESIGNER
|
||||
void TextAlignmentEditorWidgetForDesigner::initEditor()
|
||||
{
|
||||
connect(m_reportEditor,SIGNAL(itemPropertyChanged(QString,QString,QVariant,QVariant)),
|
||||
this,SLOT(slotPropertyChanged(QString,QString,QVariant,QVariant)));
|
||||
|
||||
connect(m_reportEditor, SIGNAL(itemPropertyChanged(QString, QString, QVariant, QVariant)), this,
|
||||
SLOT(slotPropertyChanged(QString, QString, QVariant, QVariant)));
|
||||
}
|
||||
|
||||
void TextAlignmentEditorWidgetForDesigner::slotTextHAttribsChanged(bool value)
|
||||
{
|
||||
TextAlignmentEditorWidget::slotTextHAttribsChanged(value);
|
||||
if (m_textAttibutesIsChanging) return;
|
||||
if (m_textAttibutesIsChanging)
|
||||
return;
|
||||
m_textAttibutesIsChanging = true;
|
||||
m_reportEditor->setTextAlign(true, Qt::AlignmentFlag(flag()));
|
||||
m_textAttibutesIsChanging = false;
|
||||
@ -214,7 +234,8 @@ void TextAlignmentEditorWidgetForDesigner::slotTextHAttribsChanged(bool value)
|
||||
void TextAlignmentEditorWidgetForDesigner::slotTextVAttribsChanged(bool value)
|
||||
{
|
||||
TextAlignmentEditorWidget::slotTextVAttribsChanged(value);
|
||||
if (m_textAttibutesIsChanging) return;
|
||||
if (m_textAttibutesIsChanging)
|
||||
return;
|
||||
m_textAttibutesIsChanging = true;
|
||||
m_reportEditor->setTextAlign(false, Qt::AlignmentFlag(flag()));
|
||||
m_textAttibutesIsChanging = false;
|
||||
|
@ -30,30 +30,34 @@
|
||||
#ifndef LRTEXTALIGNMENTEDITORWIDGET_H
|
||||
#define LRTEXTALIGNMENTEDITORWIDGET_H
|
||||
|
||||
#include "lrreportdesignwidget.h"
|
||||
#include "lritemeditorwidget.h"
|
||||
#include <QToolBar>
|
||||
#include "lrreportdesignwidget.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QToolBar>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
class TextAlignmentEditorWidget:public ItemEditorWidget
|
||||
{
|
||||
class TextAlignmentEditorWidget: public ItemEditorWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TextAlignmentEditorWidget(const QString& title, QWidget* parent = 0);
|
||||
int flag() const;
|
||||
|
||||
protected:
|
||||
void setItemEvent(BaseDesignIntf* item);
|
||||
void initEditor();
|
||||
bool m_textAttibutesIsChanging;
|
||||
|
||||
private:
|
||||
void updateValues(const Qt::Alignment& align);
|
||||
Qt::Alignment createAlignment();
|
||||
protected slots:
|
||||
virtual void slotTextHAttribsChanged(bool);
|
||||
virtual void slotTextVAttribsChanged(bool);
|
||||
virtual void slotPropertyChanged(const QString& objectName, const QString& property, const QVariant &oldValue, const QVariant &newValue);
|
||||
virtual void slotPropertyChanged(const QString& objectName, const QString& property,
|
||||
const QVariant& oldValue, const QVariant& newValue);
|
||||
|
||||
private:
|
||||
QAction* m_textAliginLeft;
|
||||
QAction* m_textAliginRight;
|
||||
@ -68,13 +72,19 @@ private:
|
||||
class TextAlignmentEditorWidgetForPage: public TextAlignmentEditorWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
TextAlignmentEditorWidgetForPage(PageDesignIntf* page, const QString &title, QWidget *parent = 0)
|
||||
:TextAlignmentEditorWidget(title, parent), m_page(page){}
|
||||
TextAlignmentEditorWidgetForPage(PageDesignIntf* page, const QString& title,
|
||||
QWidget* parent = 0):
|
||||
TextAlignmentEditorWidget(title, parent),
|
||||
m_page(page)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
void initEditor();
|
||||
protected slots:
|
||||
void slotTextHAttribsChanged(bool value);
|
||||
void slotTextVAttribsChanged(bool value);
|
||||
|
||||
private:
|
||||
PageDesignIntf* m_page;
|
||||
};
|
||||
@ -83,13 +93,20 @@ private:
|
||||
class TextAlignmentEditorWidgetForDesigner: public TextAlignmentEditorWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
TextAlignmentEditorWidgetForDesigner(ReportDesignWidget* reportEditor, const QString &title, QWidget *parent = 0)
|
||||
:TextAlignmentEditorWidget(title, parent), m_reportEditor(reportEditor){initEditor();}
|
||||
TextAlignmentEditorWidgetForDesigner(ReportDesignWidget* reportEditor, const QString& title,
|
||||
QWidget* parent = 0):
|
||||
TextAlignmentEditorWidget(title, parent),
|
||||
m_reportEditor(reportEditor)
|
||||
{
|
||||
initEditor();
|
||||
}
|
||||
|
||||
protected:
|
||||
void initEditor();
|
||||
protected slots:
|
||||
void slotTextHAttribsChanged(bool value);
|
||||
void slotTextVAttribsChanged(bool value);
|
||||
|
||||
private:
|
||||
ReportDesignWidget* m_reportEditor;
|
||||
};
|
||||
|
@ -2,9 +2,12 @@
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
AbstractLayout::AbstractLayout(QString xmlTag, QObject* owner, QGraphicsItem* parent)
|
||||
: LayoutDesignIntf(xmlTag, owner, parent), m_isRelocating(false), m_layoutType(Layout),
|
||||
m_hideEmptyItems(false), m_layoutSpacing(0)
|
||||
AbstractLayout::AbstractLayout(QString xmlTag, QObject* owner, QGraphicsItem* parent):
|
||||
LayoutDesignIntf(xmlTag, owner, parent),
|
||||
m_isRelocating(false),
|
||||
m_layoutType(Layout),
|
||||
m_hideEmptyItems(false),
|
||||
m_layoutSpacing(0)
|
||||
{
|
||||
setPossibleResizeDirectionFlags(AllDirections);
|
||||
m_layoutMarker = new LayoutMarker(this);
|
||||
@ -17,38 +20,25 @@ AbstractLayout::AbstractLayout(QString xmlTag, QObject* owner, QGraphicsItem* pa
|
||||
AbstractLayout::~AbstractLayout()
|
||||
{
|
||||
if (m_layoutMarker) {
|
||||
delete m_layoutMarker; m_layoutMarker=0;
|
||||
delete m_layoutMarker;
|
||||
m_layoutMarker = 0;
|
||||
}
|
||||
}
|
||||
|
||||
QList<BaseDesignIntf*>& AbstractLayout::layoutsChildren()
|
||||
{
|
||||
return m_children;
|
||||
}
|
||||
QList<BaseDesignIntf*>& AbstractLayout::layoutsChildren() { return m_children; }
|
||||
|
||||
bool AbstractLayout::isRelocating() const
|
||||
{
|
||||
return m_isRelocating;
|
||||
}
|
||||
bool AbstractLayout::isRelocating() const { return m_isRelocating; }
|
||||
|
||||
void AbstractLayout::setIsRelocating(bool isRelocating)
|
||||
{
|
||||
m_isRelocating = isRelocating;
|
||||
}
|
||||
void AbstractLayout::setIsRelocating(bool isRelocating) { m_isRelocating = isRelocating; }
|
||||
|
||||
AbstractLayout::LayoutType AbstractLayout::layoutType() const
|
||||
{
|
||||
return m_layoutType;
|
||||
}
|
||||
AbstractLayout::LayoutType AbstractLayout::layoutType() const { return m_layoutType; }
|
||||
|
||||
void AbstractLayout::setLayoutType(const LayoutType& layoutType)
|
||||
{
|
||||
m_layoutType = layoutType;
|
||||
}
|
||||
void AbstractLayout::setLayoutType(const LayoutType& layoutType) { m_layoutType = layoutType; }
|
||||
|
||||
void AbstractLayout::addChild(BaseDesignIntf* item, bool updateSize)
|
||||
{
|
||||
if (updateSize) placeItemInLayout(item);
|
||||
if (updateSize)
|
||||
placeItemInLayout(item);
|
||||
|
||||
m_children.append(item);
|
||||
item->setParentItem(this);
|
||||
@ -75,7 +65,8 @@ void AbstractLayout::removeChild(BaseDesignIntf *item)
|
||||
|
||||
void AbstractLayout::restoreChild(BaseDesignIntf* item)
|
||||
{
|
||||
if (m_children.contains(item)) return;
|
||||
if (m_children.contains(item))
|
||||
return;
|
||||
m_isRelocating = true;
|
||||
|
||||
insertItemInLayout(item);
|
||||
@ -97,7 +88,8 @@ bool AbstractLayout::isEmpty() const
|
||||
bool allItemsIsText = true;
|
||||
foreach (QGraphicsItem* qgItem, childItems()) {
|
||||
ContentItemDesignIntf* item = dynamic_cast<ContentItemDesignIntf*>(qgItem);
|
||||
if (item && !item->content().isEmpty()) isEmpty = false;
|
||||
if (item && !item->content().isEmpty())
|
||||
isEmpty = false;
|
||||
if (!item && dynamic_cast<BaseDesignIntf*>(qgItem))
|
||||
allItemsIsText = false;
|
||||
}
|
||||
@ -111,15 +103,12 @@ void AbstractLayout::paintChild(BaseDesignIntf *child, QPointF parentPos, QPaint
|
||||
paintChild(item, child->pos(), painter);
|
||||
}
|
||||
}
|
||||
painter->drawRect(
|
||||
QRectF(parentPos.x()+child->pos().x(), parentPos.y()+child->pos().y(),
|
||||
child->rect().bottomRight().rx(),
|
||||
child->rect().bottomRight().ry()
|
||||
)
|
||||
);
|
||||
painter->drawRect(QRectF(parentPos.x() + child->pos().x(), parentPos.y() + child->pos().y(),
|
||||
child->rect().bottomRight().rx(), child->rect().bottomRight().ry()));
|
||||
}
|
||||
|
||||
void AbstractLayout::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||
void AbstractLayout::paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
|
||||
QWidget* widget)
|
||||
{
|
||||
if (isSelected()) {
|
||||
painter->save();
|
||||
@ -132,10 +121,7 @@ void AbstractLayout::paint(QPainter* painter, const QStyleOptionGraphicsItem* op
|
||||
LayoutDesignIntf::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
int AbstractLayout::childrenCount()
|
||||
{
|
||||
return m_children.size();
|
||||
}
|
||||
int AbstractLayout::childrenCount() { return m_children.size(); }
|
||||
|
||||
void AbstractLayout::beforeDelete()
|
||||
{
|
||||
@ -158,10 +144,7 @@ void AbstractLayout::beforeDelete()
|
||||
m_children.clear();
|
||||
}
|
||||
|
||||
void AbstractLayout::childAddedEvent(BaseDesignIntf* child)
|
||||
{
|
||||
addChild(child,false);
|
||||
}
|
||||
void AbstractLayout::childAddedEvent(BaseDesignIntf* child) { addChild(child, false); }
|
||||
|
||||
void AbstractLayout::geometryChangedEvent(QRectF newRect, QRectF)
|
||||
{
|
||||
@ -245,7 +228,8 @@ void AbstractLayout::updateItemSize(DataSourceManager* dataManager, RenderPass p
|
||||
BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight);
|
||||
}
|
||||
|
||||
void AbstractLayout::rebuildChildrenIfNeeded(){
|
||||
void AbstractLayout::rebuildChildrenIfNeeded()
|
||||
{
|
||||
if (layoutsChildren().count() < childItems().size() - 1) {
|
||||
layoutsChildren().clear();
|
||||
foreach (BaseDesignIntf* childItem, childBaseItems()) {
|
||||
@ -257,57 +241,39 @@ void AbstractLayout::rebuildChildrenIfNeeded(){
|
||||
|
||||
void AbstractLayout::connectToLayout(BaseDesignIntf* item)
|
||||
{
|
||||
connect(
|
||||
item, SIGNAL(destroyed(QObject*)),
|
||||
this, SLOT(slotOnChildDestroy(QObject*))
|
||||
);
|
||||
connect(
|
||||
item,SIGNAL(geometryChanged(QObject*,QRectF,QRectF)),
|
||||
this,SLOT(slotOnChildGeometryChanged(QObject*,QRectF,QRectF))
|
||||
);
|
||||
connect(
|
||||
item, SIGNAL(itemVisibleHasChanged(BaseDesignIntf*)),
|
||||
this, SLOT(slotOnChildVisibleHasChanged(BaseDesignIntf*))
|
||||
);
|
||||
connect(
|
||||
item, SIGNAL(itemSelectedHasBeenChanged(BaseDesignIntf*,bool)),
|
||||
this, SLOT(slotOnChildSelectionHasChanged(BaseDesignIntf*,bool))
|
||||
);
|
||||
connect(
|
||||
item, SIGNAL(itemAlignChanged(BaseDesignIntf*, const ItemAlign&, const ItemAlign&)),
|
||||
this, SLOT(slotOnChildItemAlignChanged(BaseDesignIntf*,const ItemAlign&,const ItemAlign&))
|
||||
);
|
||||
connect(item, SIGNAL(destroyed(QObject*)), this, SLOT(slotOnChildDestroy(QObject*)));
|
||||
connect(item, SIGNAL(geometryChanged(QObject*, QRectF, QRectF)), this,
|
||||
SLOT(slotOnChildGeometryChanged(QObject*, QRectF, QRectF)));
|
||||
connect(item, SIGNAL(itemVisibleHasChanged(BaseDesignIntf*)), this,
|
||||
SLOT(slotOnChildVisibleHasChanged(BaseDesignIntf*)));
|
||||
connect(item, SIGNAL(itemSelectedHasBeenChanged(BaseDesignIntf*, bool)), this,
|
||||
SLOT(slotOnChildSelectionHasChanged(BaseDesignIntf*, bool)));
|
||||
connect(item, SIGNAL(itemAlignChanged(BaseDesignIntf*, const ItemAlign&, const ItemAlign&)),
|
||||
this,
|
||||
SLOT(slotOnChildItemAlignChanged(BaseDesignIntf*, const ItemAlign&, const ItemAlign&)));
|
||||
}
|
||||
|
||||
void AbstractLayout::disconnectFromLayout(BaseDesignIntf* item)
|
||||
{
|
||||
disconnect(item, SIGNAL(destroyed(QObject*)), this, SLOT(slotOnChildDestroy(QObject*)));
|
||||
disconnect(item, SIGNAL(geometryChanged(QObject*, QRectF, QRectF)), this,
|
||||
SLOT(slotOnChildGeometryChanged(QObject*, QRectF, QRectF)));
|
||||
disconnect(item, SIGNAL(itemVisibleHasChanged(BaseDesignIntf*)), this,
|
||||
SLOT(slotOnChildVisibleHasChanged(BaseDesignIntf*)));
|
||||
disconnect(item, SIGNAL(itemSelectedHasBeenChanged(BaseDesignIntf*, bool)), this,
|
||||
SLOT(slotOnChildSelectionHasChanged(BaseDesignIntf*, bool)));
|
||||
disconnect(
|
||||
item, SIGNAL(destroyed(QObject*)),
|
||||
this, SLOT(slotOnChildDestroy(QObject*))
|
||||
);
|
||||
disconnect(
|
||||
item,SIGNAL(geometryChanged(QObject*,QRectF,QRectF)),
|
||||
this,SLOT(slotOnChildGeometryChanged(QObject*,QRectF,QRectF))
|
||||
);
|
||||
disconnect(
|
||||
item, SIGNAL(itemVisibleHasChanged(BaseDesignIntf*)),
|
||||
this, SLOT(slotOnChildVisibleHasChanged(BaseDesignIntf*))
|
||||
);
|
||||
disconnect(
|
||||
item, SIGNAL(itemSelectedHasBeenChanged(BaseDesignIntf*,bool)),
|
||||
this, SLOT(slotOnChildSelectionHasChanged(BaseDesignIntf*,bool))
|
||||
);
|
||||
disconnect(
|
||||
item, SIGNAL(itemAlignChanged(BaseDesignIntf*, const ItemAlign&, const ItemAlign&)),
|
||||
this, SLOT(slotOnChildItemAlignChanged(BaseDesignIntf*,const ItemAlign&,const ItemAlign&))
|
||||
);
|
||||
item, SIGNAL(itemAlignChanged(BaseDesignIntf*, const ItemAlign&, const ItemAlign&)), this,
|
||||
SLOT(slotOnChildItemAlignChanged(BaseDesignIntf*, const ItemAlign&, const ItemAlign&)));
|
||||
}
|
||||
|
||||
BaseDesignIntf* AbstractLayout::findNext(BaseDesignIntf* item)
|
||||
{
|
||||
rebuildChildrenIfNeeded();
|
||||
for (int i = 0; i < layoutsChildren().count(); ++i) {
|
||||
if (layoutsChildren()[i]==item && layoutsChildren().size()>i+1){ return layoutsChildren()[i+1];}
|
||||
if (layoutsChildren()[i] == item && layoutsChildren().size() > i + 1) {
|
||||
return layoutsChildren()[i + 1];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -316,12 +282,15 @@ BaseDesignIntf *AbstractLayout::findPrior(BaseDesignIntf *item)
|
||||
{
|
||||
rebuildChildrenIfNeeded();
|
||||
for (int i = 0; i < layoutsChildren().count(); ++i) {
|
||||
if (layoutsChildren()[i]==item && i!=0){ return layoutsChildren()[i-1];}
|
||||
if (layoutsChildren()[i] == item && i != 0) {
|
||||
return layoutsChildren()[i - 1];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void AbstractLayout::insertItemInLayout(BaseDesignIntf *item){
|
||||
void AbstractLayout::insertItemInLayout(BaseDesignIntf* item)
|
||||
{
|
||||
bool inserted = false;
|
||||
for (int i = 0; i < layoutsChildren().length(); ++i) {
|
||||
BaseDesignIntf* child = layoutsChildren()[i];
|
||||
@ -331,7 +300,8 @@ void AbstractLayout::insertItemInLayout(BaseDesignIntf *item){
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!inserted) layoutsChildren().append(item);
|
||||
if (!inserted)
|
||||
layoutsChildren().append(item);
|
||||
}
|
||||
|
||||
void AbstractLayout::slotOnChildDestroy(QObject* child)
|
||||
@ -345,7 +315,8 @@ void AbstractLayout::slotOnChildDestroy(QObject* child)
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractLayout::slotOnChildGeometryChanged(QObject* item, QRectF newGeometry, QRectF oldGeometry)
|
||||
void AbstractLayout::slotOnChildGeometryChanged(QObject* item, QRectF newGeometry,
|
||||
QRectF oldGeometry)
|
||||
{
|
||||
if (!m_isRelocating && !isLoading()) {
|
||||
if (m_layoutType == Layout) {
|
||||
@ -365,7 +336,8 @@ void AbstractLayout::slotOnChildGeometryChanged(QObject* item, QRectF newGeometr
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractLayout::slotOnChildItemAlignChanged(BaseDesignIntf* item, const ItemAlign&, const ItemAlign&)
|
||||
void AbstractLayout::slotOnChildItemAlignChanged(BaseDesignIntf* item, const ItemAlign&,
|
||||
const ItemAlign&)
|
||||
{
|
||||
item->setPossibleResizeDirectionFlags(ResizeBottom | ResizeRight);
|
||||
}
|
||||
@ -383,10 +355,7 @@ void AbstractLayout::slotOnChildSelectionHasChanged(BaseDesignIntf* item, bool v
|
||||
item->setZValue(value ? item->zValue() + 1 : item->zValue() - 1);
|
||||
}
|
||||
|
||||
int AbstractLayout::layoutSpacing() const
|
||||
{
|
||||
return m_layoutSpacing;
|
||||
}
|
||||
int AbstractLayout::layoutSpacing() const { return m_layoutSpacing; }
|
||||
|
||||
void AbstractLayout::setLayoutSpacing(int layoutSpacing)
|
||||
{
|
||||
@ -402,10 +371,7 @@ void AbstractLayout::setLayoutSpacing(int layoutSpacing)
|
||||
}
|
||||
}
|
||||
|
||||
bool AbstractLayout::hideEmptyItems() const
|
||||
{
|
||||
return m_hideEmptyItems;
|
||||
}
|
||||
bool AbstractLayout::hideEmptyItems() const { return m_hideEmptyItems; }
|
||||
|
||||
void AbstractLayout::setHideEmptyItems(bool hideEmptyItems)
|
||||
{
|
||||
@ -420,13 +386,11 @@ void AbstractLayout::setHideEmptyItems(bool hideEmptyItems)
|
||||
QObject* AbstractLayout::at(int index)
|
||||
{
|
||||
rebuildChildrenIfNeeded();
|
||||
if (layoutsChildren().size() > index) return layoutsChildren()[index];
|
||||
if (layoutsChildren().size() > index)
|
||||
return layoutsChildren()[index];
|
||||
return 0;
|
||||
}
|
||||
|
||||
LayoutMarker* AbstractLayout::layoutMarker() const
|
||||
{
|
||||
return m_layoutMarker;
|
||||
}
|
||||
LayoutMarker* AbstractLayout::layoutMarker() const { return m_layoutMarker; }
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -3,16 +3,19 @@
|
||||
|
||||
#include "lritemdesignintf.h"
|
||||
#include "lrlayoutmarker.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
namespace LimeReport {
|
||||
class AbstractLayout: public LayoutDesignIntf
|
||||
{
|
||||
class AbstractLayout: public LayoutDesignIntf {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool hideEmptyItems READ hideEmptyItems WRITE setHideEmptyItems)
|
||||
Q_PROPERTY(int layoutSpacing READ layoutSpacing WRITE setLayoutSpacing)
|
||||
public:
|
||||
enum LayoutType{Layout,Table};
|
||||
enum LayoutType {
|
||||
Layout,
|
||||
Table
|
||||
};
|
||||
#if QT_VERSION >= 0x050500
|
||||
Q_ENUM(LayoutType)
|
||||
#else
|
||||
@ -41,6 +44,7 @@ public:
|
||||
int layoutSpacing() const;
|
||||
void setLayoutSpacing(int layoutSpacing);
|
||||
qreal layoutSpacingMM() { return m_layoutSpacing * Const::mmFACTOR; }
|
||||
|
||||
protected:
|
||||
void beforeDelete();
|
||||
void childAddedEvent(BaseDesignIntf* child);
|
||||
@ -56,6 +60,7 @@ protected:
|
||||
void connectToLayout(BaseDesignIntf* item);
|
||||
void disconnectFromLayout(BaseDesignIntf* item);
|
||||
virtual void insertItemInLayout(BaseDesignIntf* item);
|
||||
|
||||
private:
|
||||
virtual void sortChildren() = 0;
|
||||
virtual void divideSpace() = 0;
|
||||
@ -71,6 +76,7 @@ private slots:
|
||||
void slotOnChildItemAlignChanged(BaseDesignIntf* item, const ItemAlign&, const ItemAlign&);
|
||||
void slotOnChildVisibleHasChanged(BaseDesignIntf*);
|
||||
void slotOnChildSelectionHasChanged(BaseDesignIntf* item, bool value);
|
||||
|
||||
private:
|
||||
QList<BaseDesignIntf*> m_children;
|
||||
bool m_isRelocating;
|
||||
|
@ -28,23 +28,26 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lralignpropitem.h"
|
||||
#include "objectinspector/propertyItems/lrenumpropitem.h"
|
||||
#include "objectinspector/editors/lrcomboboxeditor.h"
|
||||
|
||||
#include "lrtextitem.h"
|
||||
#include "objectinspector/editors/lrcomboboxeditor.h"
|
||||
#include "objectinspector/propertyItems/lrenumpropitem.h"
|
||||
|
||||
namespace {
|
||||
LimeReport::ObjectPropItem * createAlignItem(
|
||||
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly
|
||||
){
|
||||
return new LimeReport::AlignmentPropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
LimeReport::ObjectPropItem* createAlignItem(QObject* object,
|
||||
LimeReport::ObjectPropItem::ObjectsList* objects,
|
||||
const QString& name, const QString& displayName,
|
||||
const QVariant& data,
|
||||
LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::AlignmentPropItem(object, objects, name, displayName, data, parent,
|
||||
readonly);
|
||||
}
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("alignment","LimeReport::TextItem"),
|
||||
QObject::tr("alignment"),
|
||||
createAlignItem
|
||||
);
|
||||
}
|
||||
LimeReport::APropIdent("alignment", "LimeReport::TextItem"), QObject::tr("alignment"),
|
||||
createAlignItem);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
@ -54,15 +57,19 @@ QString AlignmentPropItem::associateValue(int value, const AlignMap* map) const
|
||||
QMap<QString, Qt::Alignment>::const_iterator it = map->constBegin();
|
||||
for (; it != map->constEnd(); ++it) {
|
||||
if ((value & it.value())) {
|
||||
if (result.isEmpty()) result+=it.key();
|
||||
else result=result+" | "+it.key();
|
||||
if (result.isEmpty())
|
||||
result += it.key();
|
||||
else
|
||||
result = result + " | " + it.key();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
AlignmentPropItem::AlignmentPropItem(QObject *object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value, ObjectPropItem *parent, bool readonly)
|
||||
:ObjectPropItem(object, objects, name,displayName,value,parent,readonly)
|
||||
AlignmentPropItem::AlignmentPropItem(QObject* object, ObjectsList* objects, const QString& name,
|
||||
const QString& displayName, const QVariant& value,
|
||||
ObjectPropItem* parent, bool readonly):
|
||||
ObjectPropItem(object, objects, name, displayName, value, parent, readonly)
|
||||
{
|
||||
|
||||
m_horizMap.insert(tr("Left"), Qt::AlignLeft);
|
||||
@ -74,8 +81,10 @@ AlignmentPropItem::AlignmentPropItem(QObject *object, ObjectsList* objects, cons
|
||||
m_vertMap.insert(tr("Center"), Qt::AlignVCenter);
|
||||
m_vertMap.insert(tr("Botom"), Qt::AlignBottom);
|
||||
|
||||
m_horizEditor = new AlignmentItemEditor(object, objects, name,tr("horizontal"),value.toInt(),this,false,m_horizMap);
|
||||
m_vertEditor = new AlignmentItemEditor(object, objects, name,tr("vertical"), value.toInt(),this,false,m_vertMap);
|
||||
m_horizEditor = new AlignmentItemEditor(object, objects, name, tr("horizontal"), value.toInt(),
|
||||
this, false, m_horizMap);
|
||||
m_vertEditor = new AlignmentItemEditor(object, objects, name, tr("vertical"), value.toInt(),
|
||||
this, false, m_vertMap);
|
||||
|
||||
this->appendItem(m_horizEditor);
|
||||
this->appendItem(m_vertEditor);
|
||||
@ -83,8 +92,8 @@ AlignmentPropItem::AlignmentPropItem(QObject *object, ObjectsList* objects, cons
|
||||
|
||||
QString AlignmentPropItem::displayValue() const
|
||||
{
|
||||
return associateValue(propertyValue().toInt(),&m_horizMap)+" | "+
|
||||
associateValue(propertyValue().toInt(),&m_vertMap);
|
||||
return associateValue(propertyValue().toInt(), &m_horizMap) + " | "
|
||||
+ associateValue(propertyValue().toInt(), &m_vertMap);
|
||||
}
|
||||
|
||||
void AlignmentPropItem::setPropertyValue(QVariant value)
|
||||
@ -94,23 +103,30 @@ void AlignmentPropItem::setPropertyValue(QVariant value)
|
||||
ObjectPropItem::setPropertyValue(value);
|
||||
}
|
||||
|
||||
AlignmentItemEditor::AlignmentItemEditor(QObject *object, ObjectsList* objects, const QString &name, const QString &displayName, const QVariant &value, ObjectPropItem *parent,
|
||||
bool readonly, AlignMap acceptableValues)
|
||||
:ObjectPropItem(object, objects, name, displayName, value, parent, readonly),m_acceptableValues(acceptableValues)
|
||||
AlignmentItemEditor::AlignmentItemEditor(QObject* object, ObjectsList* objects, const QString& name,
|
||||
const QString& displayName, const QVariant& value,
|
||||
ObjectPropItem* parent, bool readonly,
|
||||
AlignMap acceptableValues):
|
||||
ObjectPropItem(object, objects, name, displayName, value, parent, readonly),
|
||||
m_acceptableValues(acceptableValues)
|
||||
{
|
||||
if (!extractAcceptableValue(value.toInt()).isEmpty())
|
||||
setPropertyValue(extractAcceptableValue(value.toInt())[0]);
|
||||
else setPropertyValue(0);
|
||||
else
|
||||
setPropertyValue(0);
|
||||
}
|
||||
|
||||
void AlignmentItemEditor::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
void AlignmentItemEditor::setModelData(QWidget* propertyEditor, QAbstractItemModel* model,
|
||||
const QModelIndex& index)
|
||||
{
|
||||
int flags = object()->property(propertyName().toLatin1()).toInt();
|
||||
int align = m_acceptableValues.value(qobject_cast<ComboBoxEditor*>(propertyEditor)->text());
|
||||
flags = clearAcceptableValues(flags) | align;
|
||||
object()->setProperty(propertyName().toLatin1(), flags);
|
||||
if (objects())
|
||||
foreach(QObject* item,*objects()){item->setProperty(propertyName().toLatin1(),flags);}
|
||||
foreach (QObject* item, *objects()) {
|
||||
item->setProperty(propertyName().toLatin1(), flags);
|
||||
}
|
||||
parent()->setPropertyValue(flags);
|
||||
model->setData(index, align);
|
||||
}
|
||||
@ -119,19 +135,17 @@ QVector<int> AlignmentItemEditor::extractAcceptableValue(int flags)
|
||||
{
|
||||
QVector<int> result;
|
||||
AlignMap::const_iterator it = m_acceptableValues.constBegin();
|
||||
for (;it != m_acceptableValues.constEnd();++it)
|
||||
{
|
||||
if (flags & it.value()) result<<it.value();
|
||||
for (; it != m_acceptableValues.constEnd(); ++it) {
|
||||
if (flags & it.value())
|
||||
result << it.value();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int AlignmentItemEditor::clearAcceptableValues(int flags)
|
||||
{
|
||||
AlignMap::const_iterator it = m_acceptableValues.constBegin();
|
||||
for (;it != m_acceptableValues.constEnd();++it)
|
||||
{
|
||||
for (; it != m_acceptableValues.constEnd(); ++it) {
|
||||
if (flags & it.value())
|
||||
flags = flags ^ it.value();
|
||||
}
|
||||
@ -161,9 +175,10 @@ QString AlignmentItemEditor::displayValue() const
|
||||
void AlignmentItemEditor::setPropertyValue(QVariant value)
|
||||
{
|
||||
QVector<int> _accpepttableValueList = extractAcceptableValue(value.toInt());
|
||||
if(_accpepttableValueList.isEmpty()) return;
|
||||
if (_accpepttableValueList.isEmpty())
|
||||
return;
|
||||
|
||||
ObjectPropItem::setPropertyValue(_accpepttableValueList[0]);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
@ -39,14 +39,16 @@ typedef QMap<QString,Qt::Alignment> AlignMap;
|
||||
|
||||
class AlignmentItemEditor;
|
||||
|
||||
class AlignmentPropItem : public ObjectPropItem
|
||||
{
|
||||
class AlignmentPropItem: public ObjectPropItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
AlignmentPropItem(): ObjectPropItem(), m_horizEditor(NULL), m_vertEditor(NULL) { }
|
||||
AlignmentPropItem(QObject *object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value, ObjectPropItem* parent, bool readonly=true);
|
||||
AlignmentPropItem(QObject* object, ObjectsList* objects, const QString& name,
|
||||
const QString& displayName, const QVariant& value, ObjectPropItem* parent,
|
||||
bool readonly = true);
|
||||
QString displayValue() const;
|
||||
void setPropertyValue(QVariant value);
|
||||
|
||||
private:
|
||||
AlignMap m_vertMap;
|
||||
AlignMap m_horizMap;
|
||||
@ -55,26 +57,27 @@ private:
|
||||
QString associateValue(int value, const AlignMap* map) const;
|
||||
};
|
||||
|
||||
class AlignmentItemEditor : public ObjectPropItem
|
||||
{
|
||||
class AlignmentItemEditor: public ObjectPropItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
AlignmentItemEditor(): ObjectPropItem() { }
|
||||
AlignmentItemEditor(QObject* object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value, ObjectPropItem* parent, bool readonly,
|
||||
AlignMap acceptableValues);
|
||||
AlignmentItemEditor(QObject* object, ObjectsList* objects, const QString& name,
|
||||
const QString& displayName, const QVariant& value, ObjectPropItem* parent,
|
||||
bool readonly, AlignMap acceptableValues);
|
||||
void setModelData(QWidget* propertyEditor, QAbstractItemModel* model, const QModelIndex& index);
|
||||
void setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const;
|
||||
QWidget* createProperyEditor(QWidget* parent) const;
|
||||
QString displayValue() const;
|
||||
void setPropertyValue(QVariant value);
|
||||
|
||||
protected:
|
||||
QVector<int> extractAcceptableValue(int flags);
|
||||
int clearAcceptableValues(int flags);
|
||||
AlignMap acceptableValues() const { return m_acceptableValues; }
|
||||
|
||||
private:
|
||||
AlignMap m_acceptableValues;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRALIGNPROPITEM_H
|
||||
|
@ -28,32 +28,45 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrbarcodeitem.h"
|
||||
|
||||
#include "lrdesignelementsfactory.h"
|
||||
#include "qzint.h"
|
||||
#include "lrglobal.h"
|
||||
#include "qzint.h"
|
||||
|
||||
namespace {
|
||||
|
||||
const QString xmlTag = "BarcodeItem";
|
||||
|
||||
LimeReport::BaseDesignIntf * createBarcodeItem(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
LimeReport::BaseDesignIntf* createBarcodeItem(QObject* owner, LimeReport::BaseDesignIntf* parent)
|
||||
{
|
||||
return new LimeReport::BarcodeItem(owner, parent);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(xmlTag, LimeReport::ItemAttribs(QObject::tr("Barcode Item"),"Item"), createBarcodeItem);
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag, LimeReport::ItemAttribs(QObject::tr("Barcode Item"), "Item"), createBarcodeItem);
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
BarcodeItem::BarcodeItem(QObject* owner,QGraphicsItem* parent)
|
||||
: ContentItemDesignIntf(xmlTag,owner,parent),m_designTestValue("1"), m_barcodeType(CODE128),
|
||||
m_foregroundColor(Qt::black), m_backgroundColor(Qt::white), m_whitespace(10), m_angle(Angle0),
|
||||
m_barcodeWidth(0), m_securityLevel(0), m_pdf417CodeWords(928), m_inputMode(UNICODE_INPUT_MODE),
|
||||
m_hideText(false), m_option3(0), m_hideIfEmpty(false)
|
||||
{}
|
||||
BarcodeItem::BarcodeItem(QObject* owner, QGraphicsItem* parent):
|
||||
ContentItemDesignIntf(xmlTag, owner, parent),
|
||||
m_designTestValue("1"),
|
||||
m_barcodeType(CODE128),
|
||||
m_foregroundColor(Qt::black),
|
||||
m_backgroundColor(Qt::white),
|
||||
m_whitespace(10),
|
||||
m_angle(Angle0),
|
||||
m_barcodeWidth(0),
|
||||
m_securityLevel(0),
|
||||
m_pdf417CodeWords(928),
|
||||
m_inputMode(UNICODE_INPUT_MODE),
|
||||
m_hideText(false),
|
||||
m_option3(0),
|
||||
m_hideIfEmpty(false)
|
||||
{
|
||||
}
|
||||
|
||||
BarcodeItem::~BarcodeItem()
|
||||
{}
|
||||
BarcodeItem::~BarcodeItem() { }
|
||||
|
||||
BaseDesignIntf* BarcodeItem::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
@ -64,8 +77,10 @@ void BarcodeItem::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *opti
|
||||
{
|
||||
ppainter->save();
|
||||
Zint::QZint bc;
|
||||
if (itemMode() & DesignMode) bc.setText(m_designTestValue);
|
||||
else bc.setText(m_content);
|
||||
if (itemMode() & DesignMode)
|
||||
bc.setText(m_designTestValue);
|
||||
else
|
||||
bc.setText(m_content);
|
||||
bc.setInputMode(m_inputMode);
|
||||
bc.setSymbol(m_barcodeType);
|
||||
bc.setWhitespace(m_whitespace);
|
||||
@ -77,7 +92,8 @@ void BarcodeItem::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *opti
|
||||
bc.setHideText(m_hideText);
|
||||
bc.setOption3(m_option3);
|
||||
|
||||
if (isSelected()) ppainter->setOpacity(Const::SELECTION_OPACITY);
|
||||
if (isSelected())
|
||||
ppainter->setOpacity(Const::SELECTION_OPACITY);
|
||||
|
||||
QRectF bcRect;
|
||||
|
||||
@ -117,10 +133,7 @@ void BarcodeItem::setContent(const QString &content)
|
||||
}
|
||||
}
|
||||
|
||||
QString BarcodeItem::datasource() const
|
||||
{
|
||||
return m_datasource;
|
||||
}
|
||||
QString BarcodeItem::datasource() const { return m_datasource; }
|
||||
|
||||
void BarcodeItem::setDatasource(const QString& datasource)
|
||||
{
|
||||
@ -132,10 +145,7 @@ void BarcodeItem::setDatasource(const QString &datasource)
|
||||
}
|
||||
}
|
||||
|
||||
QString BarcodeItem::field() const
|
||||
{
|
||||
return m_field;
|
||||
}
|
||||
QString BarcodeItem::field() const { return m_field; }
|
||||
|
||||
void BarcodeItem::setField(const QString& field)
|
||||
{
|
||||
@ -197,10 +207,7 @@ void BarcodeItem::setWhitespace(int value)
|
||||
}
|
||||
}
|
||||
|
||||
BarcodeItem::AngleType BarcodeItem::angle() const
|
||||
{
|
||||
return m_angle;
|
||||
}
|
||||
BarcodeItem::AngleType BarcodeItem::angle() const { return m_angle; }
|
||||
|
||||
void BarcodeItem::setAngle(const AngleType& angle)
|
||||
{
|
||||
@ -214,10 +221,7 @@ void BarcodeItem::setAngle(const AngleType &angle)
|
||||
}
|
||||
}
|
||||
|
||||
int BarcodeItem::barcodeWidth() const
|
||||
{
|
||||
return m_barcodeWidth;
|
||||
}
|
||||
int BarcodeItem::barcodeWidth() const { return m_barcodeWidth; }
|
||||
|
||||
void BarcodeItem::setBarcodeWidth(int barcodeWidth)
|
||||
{
|
||||
@ -231,10 +235,7 @@ void BarcodeItem::setBarcodeWidth(int barcodeWidth)
|
||||
}
|
||||
}
|
||||
|
||||
int BarcodeItem::securityLevel() const
|
||||
{
|
||||
return m_securityLevel;
|
||||
}
|
||||
int BarcodeItem::securityLevel() const { return m_securityLevel; }
|
||||
|
||||
void BarcodeItem::setSecurityLevel(int securityLevel)
|
||||
{
|
||||
@ -248,10 +249,7 @@ void BarcodeItem::setSecurityLevel(int securityLevel)
|
||||
}
|
||||
}
|
||||
|
||||
int BarcodeItem::pdf417CodeWords() const
|
||||
{
|
||||
return m_pdf417CodeWords;
|
||||
}
|
||||
int BarcodeItem::pdf417CodeWords() const { return m_pdf417CodeWords; }
|
||||
|
||||
void BarcodeItem::setPdf417CodeWords(int pdf417CodeWords)
|
||||
{
|
||||
@ -265,10 +263,7 @@ void BarcodeItem::setPdf417CodeWords(int pdf417CodeWords)
|
||||
}
|
||||
}
|
||||
|
||||
BarcodeItem::InputMode BarcodeItem::inputMode() const
|
||||
{
|
||||
return m_inputMode;
|
||||
}
|
||||
BarcodeItem::InputMode BarcodeItem::inputMode() const { return m_inputMode; }
|
||||
|
||||
void BarcodeItem::setInputMode(const InputMode& inputMode)
|
||||
{
|
||||
@ -282,10 +277,7 @@ void BarcodeItem::setInputMode(const InputMode &inputMode)
|
||||
}
|
||||
}
|
||||
|
||||
bool BarcodeItem::hideText() const
|
||||
{
|
||||
return m_hideText;
|
||||
}
|
||||
bool BarcodeItem::hideText() const { return m_hideText; }
|
||||
|
||||
void BarcodeItem::setHideText(bool hideText)
|
||||
{
|
||||
@ -298,10 +290,7 @@ void BarcodeItem::setHideText(bool hideText)
|
||||
}
|
||||
}
|
||||
|
||||
int BarcodeItem::option3() const
|
||||
{
|
||||
return m_option3;
|
||||
}
|
||||
int BarcodeItem::option3() const { return m_option3; }
|
||||
|
||||
void BarcodeItem::setOption3(int option3)
|
||||
{
|
||||
@ -315,10 +304,7 @@ void BarcodeItem::setOption3(int option3)
|
||||
}
|
||||
}
|
||||
|
||||
bool BarcodeItem::hideIfEmpty() const
|
||||
{
|
||||
return m_hideIfEmpty;
|
||||
}
|
||||
bool BarcodeItem::hideIfEmpty() const { return m_hideIfEmpty; }
|
||||
|
||||
void BarcodeItem::setHideIfEmpty(bool hideIfEmpty)
|
||||
{
|
||||
@ -328,10 +314,7 @@ void BarcodeItem::setHideIfEmpty(bool hideIfEmpty)
|
||||
}
|
||||
}
|
||||
|
||||
bool BarcodeItem::isEmpty() const
|
||||
{
|
||||
return m_content.isEmpty();
|
||||
}
|
||||
bool BarcodeItem::isEmpty() const { return m_content.isEmpty(); }
|
||||
|
||||
void BarcodeItem::expandContent(QString data, DataSourceManager* dataManager, RenderPass pass)
|
||||
{
|
||||
@ -342,18 +325,13 @@ void BarcodeItem::expandContent(QString data, DataSourceManager* dataManager, Re
|
||||
|
||||
void BarcodeItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight)
|
||||
{
|
||||
if (content().isEmpty())
|
||||
{
|
||||
if (!m_datasource.isEmpty() && !m_field.isEmpty())
|
||||
{
|
||||
if (content().isEmpty()) {
|
||||
if (!m_datasource.isEmpty() && !m_field.isEmpty()) {
|
||||
IDataSource* ds = dataManager->dataSource(m_datasource);
|
||||
if (ds)
|
||||
{
|
||||
if (ds) {
|
||||
QVariant data = ds->data(m_field);
|
||||
if (data.isValid())
|
||||
{
|
||||
switch(pass)
|
||||
{
|
||||
if (data.isValid()) {
|
||||
switch (pass) {
|
||||
case FirstPass:
|
||||
expandContent(data.toString(), dataManager, pass);
|
||||
break;
|
||||
@ -371,10 +349,13 @@ void BarcodeItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass
|
||||
}
|
||||
}
|
||||
BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight);
|
||||
if (isEmpty() && hideIfEmpty()) setVisible(false);
|
||||
if (isEmpty() && hideIfEmpty())
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
bool BarcodeItem::isNeedUpdateSize(RenderPass pass) const
|
||||
{return (pass==FirstPass)?true:false;}
|
||||
|
||||
{
|
||||
return (pass == FirstPass) ? true : false;
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -30,6 +30,7 @@
|
||||
#ifndef LRBARCODEITEM_H
|
||||
#define LRBARCODEITEM_H
|
||||
#include "lritemdesignintf.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
namespace LimeReport {
|
||||
@ -140,10 +141,14 @@ public:
|
||||
CODEONE = 141,
|
||||
GRIDMATRIX = 142,
|
||||
UPNQR = 143
|
||||
|
||||
};
|
||||
|
||||
enum AngleType{Angle0,Angle90,Angle180,Angle270};
|
||||
enum AngleType {
|
||||
Angle0,
|
||||
Angle90,
|
||||
Angle180,
|
||||
Angle270
|
||||
};
|
||||
|
||||
enum InputMode {
|
||||
DATA_INPUT_MODE = 0,
|
||||
@ -223,5 +228,5 @@ private:
|
||||
bool m_hideIfEmpty;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRBARCODEITEM_H
|
||||
|
@ -1,8 +1,10 @@
|
||||
#include "lrbordereditor.h"
|
||||
#include "ui_lrbordereditor.h"
|
||||
#include <QColorDialog>
|
||||
|
||||
#include "lrbasedesignintf.h"
|
||||
|
||||
#include <QColorDialog>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
BorderEditor::BorderEditor(QWidget* parent):
|
||||
@ -12,23 +14,26 @@ BorderEditor::BorderEditor(QWidget *parent) :
|
||||
m_borderWidth(1)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(
|
||||
ui->borderFrame, SIGNAL(borderSideClicked(LimeReport::BaseDesignIntf::BorderSide, bool)),
|
||||
this, SLOT(checkToolButtons(LimeReport::BaseDesignIntf::BorderSide, bool))
|
||||
);
|
||||
connect(ui->borderFrame,
|
||||
SIGNAL(borderSideClicked(LimeReport::BaseDesignIntf::BorderSide, bool)), this,
|
||||
SLOT(checkToolButtons(LimeReport::BaseDesignIntf::BorderSide, bool)));
|
||||
}
|
||||
|
||||
void BorderEditor::loadItem(LimeReport::BaseDesignIntf* item)
|
||||
{
|
||||
m_item = item;
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine,
|
||||
item->borderLines() & LimeReport::BaseDesignIntf::TopLine);
|
||||
item->borderLines()
|
||||
& LimeReport::BaseDesignIntf::TopLine);
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::LeftLine,
|
||||
item->borderLines() & LimeReport::BaseDesignIntf::LeftLine);
|
||||
item->borderLines()
|
||||
& LimeReport::BaseDesignIntf::LeftLine);
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::RightLine,
|
||||
item->borderLines() & LimeReport::BaseDesignIntf::RightLine);
|
||||
item->borderLines()
|
||||
& LimeReport::BaseDesignIntf::RightLine);
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::BottomLine,
|
||||
item->borderLines() & LimeReport::BaseDesignIntf::BottomLine);
|
||||
item->borderLines()
|
||||
& LimeReport::BaseDesignIntf::BottomLine);
|
||||
|
||||
QPen pen;
|
||||
pen.setWidthF(item->borderLineSize());
|
||||
@ -58,20 +63,11 @@ LimeReport::BaseDesignIntf::BorderStyle BorderEditor::borderStyle()
|
||||
return (LimeReport::BaseDesignIntf::BorderStyle)m_borderStyle;
|
||||
}
|
||||
|
||||
QString BorderEditor::borderColor()
|
||||
{
|
||||
return m_borderColor;
|
||||
}
|
||||
QString BorderEditor::borderColor() { return m_borderColor; }
|
||||
|
||||
double BorderEditor::borderWidth()
|
||||
{
|
||||
return m_borderWidth;
|
||||
}
|
||||
double BorderEditor::borderWidth() { return m_borderWidth; }
|
||||
|
||||
BorderEditor::~BorderEditor()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
BorderEditor::~BorderEditor() { delete ui; }
|
||||
|
||||
void BorderEditor::on_listWidget_currentRowChanged(int currentRow)
|
||||
{
|
||||
@ -91,8 +87,7 @@ void BorderEditor::on_comboBox_currentTextChanged(const QString &arg1)
|
||||
|
||||
void BorderEditor::checkToolButtons(LimeReport::BaseDesignIntf::BorderSide side, bool check)
|
||||
{
|
||||
switch(side)
|
||||
{
|
||||
switch (side) {
|
||||
case BaseDesignIntf::BorderSide::TopLine:
|
||||
ui->topLine->setChecked(check);
|
||||
break;
|
||||
@ -108,44 +103,53 @@ void BorderEditor::checkToolButtons(LimeReport::BaseDesignIntf::BorderSide side,
|
||||
}
|
||||
}
|
||||
|
||||
void BorderEditor::on_topLine_clicked(bool checked){
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine, checked);
|
||||
void BorderEditor::on_topLine_clicked(bool checked)
|
||||
{
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine,
|
||||
checked);
|
||||
}
|
||||
|
||||
void BorderEditor::on_bottomLine_clicked(bool checked){
|
||||
void BorderEditor::on_bottomLine_clicked(bool checked)
|
||||
{
|
||||
emit ui->borderFrame->borderSideClicked(BaseDesignIntf::BorderSide::BottomLine, checked);
|
||||
}
|
||||
|
||||
void BorderEditor::on_leftLine_clicked(bool checked){
|
||||
void BorderEditor::on_leftLine_clicked(bool checked)
|
||||
{
|
||||
emit ui->borderFrame->borderSideClicked(BaseDesignIntf::BorderSide::LeftLine, checked);
|
||||
}
|
||||
|
||||
void BorderEditor::on_rightLine_clicked(bool checked){
|
||||
void BorderEditor::on_rightLine_clicked(bool checked)
|
||||
{
|
||||
emit ui->borderFrame->borderSideClicked(BaseDesignIntf::BorderSide::RightLine, checked);
|
||||
}
|
||||
|
||||
|
||||
void BorderEditor::on_allLines_clicked()
|
||||
{
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine, true);
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::BottomLine, true);
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::BottomLine,
|
||||
true);
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::LeftLine, true);
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::RightLine, true);
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::RightLine,
|
||||
true);
|
||||
}
|
||||
|
||||
void BorderEditor::on_noLines_clicked()
|
||||
{
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine, false);
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::BottomLine, false);
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::LeftLine, false);
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::RightLine, false);
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::BottomLine,
|
||||
false);
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::LeftLine,
|
||||
false);
|
||||
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::RightLine,
|
||||
false);
|
||||
}
|
||||
|
||||
|
||||
void BorderEditor::on_selectColor_clicked()
|
||||
{
|
||||
QColorDialog cd(this);
|
||||
if(cd.exec() == QDialog::Rejected) return;
|
||||
if (cd.exec() == QDialog::Rejected)
|
||||
return;
|
||||
QPen pen = ui->borderFrame->pen();
|
||||
pen.setColor(cd.selectedColor().name());
|
||||
m_borderColor = pen.color().name();
|
||||
|
@ -1,18 +1,17 @@
|
||||
#ifndef LRBORDEREDITOR_H
|
||||
#define LRBORDEREDITOR_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "lrbasedesignintf.h"
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
namespace Ui {
|
||||
class BorderEditor;
|
||||
}
|
||||
|
||||
|
||||
class LIMEREPORT_EXPORT BorderEditor : public QDialog
|
||||
{
|
||||
class LIMEREPORT_EXPORT BorderEditor: public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
@ -1,17 +1,19 @@
|
||||
#include "lrborderframeeditor.h"
|
||||
#include "ui_lrborderframeeditor.h"
|
||||
#include <QPainter>
|
||||
#include <QGraphicsLineItem>
|
||||
#include <QDebug>
|
||||
#include <QMouseEvent>
|
||||
|
||||
#include "lrbasedesignintf.h"
|
||||
#include "lrbordereditor.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QGraphicsLineItem>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
BorderFrameEditor::BorderFrameEditor(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::BorderFrameEditor)
|
||||
BorderFrameEditor::BorderFrameEditor(QWidget* parent):
|
||||
QWidget(parent),
|
||||
ui(new Ui::BorderFrameEditor)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
scene = new QGraphicsScene(ui->graphicsView);
|
||||
@ -26,8 +28,10 @@ BorderFrameEditor::BorderFrameEditor(QWidget *parent)
|
||||
scene->addLine(10, vRect.bottom() - 5, 10, vRect.bottom() - 10, QPen(Qt::gray));
|
||||
scene->addLine(5, vRect.bottom() - 10, 10, vRect.bottom() - 10, QPen(Qt::gray));
|
||||
// bottomRight
|
||||
scene->addLine(vRect.right() - 10, vRect.bottom() - 5, vRect.right()- 10, vRect.bottom() - 10, QPen(Qt::gray));
|
||||
scene->addLine(vRect.right() - 5, vRect.bottom() - 10, vRect.right() - 10, vRect.bottom() - 10, QPen(Qt::gray));
|
||||
scene->addLine(vRect.right() - 10, vRect.bottom() - 5, vRect.right() - 10, vRect.bottom() - 10,
|
||||
QPen(Qt::gray));
|
||||
scene->addLine(vRect.right() - 5, vRect.bottom() - 10, vRect.right() - 10, vRect.bottom() - 10,
|
||||
QPen(Qt::gray));
|
||||
// topRight
|
||||
scene->addLine(vRect.width() - 10, 5, vRect.width() - 10, 10, QPen(Qt::gray));
|
||||
scene->addLine(vRect.width() - 5, 10, vRect.width() - 10, 10, QPen(Qt::gray));
|
||||
@ -40,18 +44,13 @@ BorderFrameEditor::BorderFrameEditor(QWidget *parent)
|
||||
scene->addItem(io);
|
||||
|
||||
QRectF bR = io->sceneBoundingRect();
|
||||
io->setPos( scene->sceneRect().center().x() - bR.width()/2, scene->sceneRect().center().y() - bR.height()/2 );
|
||||
connect(
|
||||
this, SIGNAL(borderSideClicked(LimeReport::BaseDesignIntf::BorderSide, bool)),
|
||||
this, SLOT(slotBorderSideClicked(LimeReport::BaseDesignIntf::BorderSide, bool))
|
||||
);
|
||||
|
||||
io->setPos(scene->sceneRect().center().x() - bR.width() / 2,
|
||||
scene->sceneRect().center().y() - bR.height() / 2);
|
||||
connect(this, SIGNAL(borderSideClicked(LimeReport::BaseDesignIntf::BorderSide, bool)), this,
|
||||
SLOT(slotBorderSideClicked(LimeReport::BaseDesignIntf::BorderSide, bool)));
|
||||
}
|
||||
|
||||
BorderFrameEditor::~BorderFrameEditor()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
BorderFrameEditor::~BorderFrameEditor() { delete ui; }
|
||||
|
||||
void BorderFrameEditor::setPen(QPen pen)
|
||||
{
|
||||
@ -59,10 +58,7 @@ void BorderFrameEditor::setPen(QPen pen)
|
||||
updateBorders();
|
||||
}
|
||||
|
||||
QPen BorderFrameEditor::pen()
|
||||
{
|
||||
return m_pen;
|
||||
}
|
||||
QPen BorderFrameEditor::pen() { return m_pen; }
|
||||
|
||||
void BorderFrameEditor::setAllLines()
|
||||
{
|
||||
@ -94,7 +90,6 @@ void BorderFrameEditor::unSetAllLines()
|
||||
scene->removeItem(rightLine);
|
||||
rightLine = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void BorderFrameEditor::mousePressEvent(QMouseEvent* event)
|
||||
@ -119,39 +114,46 @@ void BorderFrameEditor::slotBorderSideClicked(BaseDesignIntf::BorderSide side, b
|
||||
|
||||
case BaseDesignIntf::BorderSide::TopLine:
|
||||
if (show) {
|
||||
if (!topLine) topLine = createSideLine(side);
|
||||
if (!topLine)
|
||||
topLine = createSideLine(side);
|
||||
} else {
|
||||
if (topLine) scene->removeItem(topLine);
|
||||
if (topLine)
|
||||
scene->removeItem(topLine);
|
||||
topLine = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case BaseDesignIntf::LeftLine:
|
||||
if (show) {
|
||||
if (!leftLine) leftLine = createSideLine(side);
|
||||
if (!leftLine)
|
||||
leftLine = createSideLine(side);
|
||||
} else {
|
||||
if (leftLine) scene->removeItem(leftLine);
|
||||
if (leftLine)
|
||||
scene->removeItem(leftLine);
|
||||
leftLine = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case BaseDesignIntf::BottomLine:
|
||||
if (show) {
|
||||
if (!bottomLine) bottomLine = createSideLine(side);
|
||||
if (!bottomLine)
|
||||
bottomLine = createSideLine(side);
|
||||
} else {
|
||||
if (bottomLine) scene->removeItem(bottomLine);
|
||||
if (bottomLine)
|
||||
scene->removeItem(bottomLine);
|
||||
bottomLine = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case BaseDesignIntf::RightLine:
|
||||
if (show) {
|
||||
if (!rightLine) rightLine = createSideLine(side);
|
||||
if (!rightLine)
|
||||
rightLine = createSideLine(side);
|
||||
} else {
|
||||
if(rightLine) scene->removeItem(rightLine);
|
||||
if (rightLine)
|
||||
scene->removeItem(rightLine);
|
||||
rightLine = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
updateBorders();
|
||||
}
|
||||
@ -164,18 +166,24 @@ QGraphicsLineItem *BorderFrameEditor::createSideLine(LimeReport::BaseDesignIntf:
|
||||
case BaseDesignIntf::BorderSide::LeftLine:
|
||||
return scene->addLine(QLineF(10, 10, 10, rect().height() - 10), m_pen);
|
||||
case BaseDesignIntf::BorderSide::RightLine:
|
||||
return scene->addLine(QLineF(rect().width() - 10, 10 ,rect().width() - 10, rect().height() - 10), m_pen);
|
||||
return scene->addLine(
|
||||
QLineF(rect().width() - 10, 10, rect().width() - 10, rect().height() - 10), m_pen);
|
||||
case BaseDesignIntf::BorderSide::BottomLine:
|
||||
return scene->addLine(QLineF(10, rect().bottom() - 10, rect().width() - 10, rect().bottom() - 10), m_pen);
|
||||
return scene->addLine(
|
||||
QLineF(10, rect().bottom() - 10, rect().width() - 10, rect().bottom() - 10), m_pen);
|
||||
}
|
||||
}
|
||||
|
||||
void BorderFrameEditor::updateBorders()
|
||||
{
|
||||
if (topLine) topLine->setPen(m_pen);
|
||||
if (leftLine) leftLine->setPen(m_pen);
|
||||
if (bottomLine) bottomLine->setPen(m_pen);
|
||||
if (rightLine) rightLine->setPen(m_pen);
|
||||
if (topLine)
|
||||
topLine->setPen(m_pen);
|
||||
if (leftLine)
|
||||
leftLine->setPen(m_pen);
|
||||
if (bottomLine)
|
||||
bottomLine->setPen(m_pen);
|
||||
if (rightLine)
|
||||
rightLine->setPen(m_pen);
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -1,16 +1,18 @@
|
||||
#ifndef WIDGET
|
||||
#define WIDGET
|
||||
|
||||
#include <QWidget>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsLineItem>
|
||||
#include "lrbasedesignintf.h"
|
||||
|
||||
#include <QGraphicsLineItem>
|
||||
#include <QGraphicsScene>
|
||||
#include <QWidget>
|
||||
namespace LimeReport {
|
||||
|
||||
namespace Ui { class BorderFrameEditor; }
|
||||
namespace Ui {
|
||||
class BorderFrameEditor;
|
||||
}
|
||||
|
||||
class BorderFrameEditor : public QWidget
|
||||
{
|
||||
class BorderFrameEditor: public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@ -20,6 +22,7 @@ public:
|
||||
QPen pen();
|
||||
void setAllLines();
|
||||
void unSetAllLines();
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
signals:
|
||||
@ -30,17 +33,12 @@ private slots:
|
||||
private:
|
||||
QGraphicsLineItem* createSideLine(LimeReport::BaseDesignIntf::BorderSide side);
|
||||
void updateBorders();
|
||||
|
||||
private:
|
||||
Ui::BorderFrameEditor* ui;
|
||||
QGraphicsScene* scene;
|
||||
QGraphicsLineItem *topLine = NULL
|
||||
,*bottomLine = NULL
|
||||
,*leftLine = NULL
|
||||
,*rightLine = NULL;
|
||||
QGraphicsLineItem *topLine = NULL, *bottomLine = NULL, *leftLine = NULL, *rightLine = NULL;
|
||||
QPen m_pen;
|
||||
|
||||
|
||||
|
||||
};
|
||||
} // namespace LimeReport
|
||||
#endif // WIDGET
|
||||
|
@ -1,13 +1,17 @@
|
||||
#include "lrchartaxiseditor.h"
|
||||
|
||||
#include "ui_lrchartaxiseditor.h"
|
||||
#include "lraxisdata.h"
|
||||
|
||||
#include "lraxisdata.h"
|
||||
#include "lrbasedesignintf.h"
|
||||
|
||||
ChartAxisEditor::ChartAxisEditor(LimeReport::ChartItem *item, LimeReport::PageDesignIntf *page, bool isXAxis, QSettings *settings, QWidget *parent):
|
||||
QWidget(parent), ui(new Ui::ChartAxisEditor), m_chartItem(item), m_page(page),
|
||||
m_settings(settings), m_isXAxis(isXAxis)
|
||||
ChartAxisEditor::ChartAxisEditor(LimeReport::ChartItem* item, LimeReport::PageDesignIntf* page,
|
||||
bool isXAxis, QSettings* settings, QWidget* parent):
|
||||
QWidget(parent),
|
||||
ui(new Ui::ChartAxisEditor),
|
||||
m_chartItem(item),
|
||||
m_page(page),
|
||||
m_settings(settings),
|
||||
m_isXAxis(isXAxis)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
readSetting();
|
||||
@ -33,7 +37,8 @@ QSettings* ChartAxisEditor::settings()
|
||||
|
||||
void ChartAxisEditor::readSetting()
|
||||
{
|
||||
if (settings() == 0) return;
|
||||
if (settings() == 0)
|
||||
return;
|
||||
|
||||
settings()->beginGroup("ChartAxisEditor");
|
||||
QVariant v = settings()->value("Geometry");
|
||||
@ -59,7 +64,8 @@ void ChartAxisEditor::init()
|
||||
ui->gbAxis->setTitle(m_isXAxis ? QObject::tr("X Axis") : QObject::tr("Y Axis"));
|
||||
ui->direction_checkbox->setVisible(!m_isXAxis);
|
||||
|
||||
LimeReport::AxisData *axisData = m_isXAxis ? m_chartItem->xAxisData() : m_chartItem->yAxisData();
|
||||
LimeReport::AxisData* axisData
|
||||
= m_isXAxis ? m_chartItem->xAxisData() : m_chartItem->yAxisData();
|
||||
|
||||
ui->minimumSpinBox->setValue(axisData->manualMinimum());
|
||||
ui->maximumSpinBox->setValue(axisData->manualMaximum());
|
||||
@ -96,7 +102,8 @@ void ChartAxisEditor::on_stepCheckBox_stateChanged(int arg1)
|
||||
|
||||
void ChartAxisEditor::on_pushButtonOk_clicked()
|
||||
{
|
||||
LimeReport::AxisData *axisData = m_isXAxis ? m_chartItem->xAxisData() : m_chartItem->yAxisData();
|
||||
LimeReport::AxisData* axisData
|
||||
= m_isXAxis ? m_chartItem->xAxisData() : m_chartItem->yAxisData();
|
||||
if (!m_isXAxis) {
|
||||
axisData->setReverseDirection(ui->direction_checkbox->isChecked());
|
||||
}
|
||||
@ -135,8 +142,4 @@ void ChartAxisEditor::on_enableScaleCalculation_checkbox_stateChanged(int arg1)
|
||||
ui->stepCheckBox->setEnabled(isEnabled);
|
||||
}
|
||||
|
||||
void ChartAxisEditor::on_cancelButton_clicked()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void ChartAxisEditor::on_cancelButton_clicked() { close(); }
|
||||
|
@ -1,15 +1,15 @@
|
||||
#ifndef CHARTAXISEDITOR_H
|
||||
#define CHARTAXISEDITOR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "lrchartitem.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class ChartAxisEditor;
|
||||
}
|
||||
|
||||
class ChartAxisEditor : public QWidget
|
||||
{
|
||||
class ChartAxisEditor: public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ChartAxisEditor(LimeReport::ChartItem* item, LimeReport::PageDesignIntf* page, bool isXAxis,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,9 @@
|
||||
#ifndef LRCHARTITEM_H
|
||||
#define LRCHARTITEM_H
|
||||
#include "lritemdesignintf.h"
|
||||
#include "lrglobal.h"
|
||||
#include "lraxisdata.h"
|
||||
#include "lrglobal.h"
|
||||
#include "lritemdesignintf.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
namespace LimeReport {
|
||||
@ -19,7 +20,13 @@ public:
|
||||
QList<qreal>& xAxisValues() { return m_xAxisValues; }
|
||||
QList<QString>& labels() { return m_labels; }
|
||||
QList<QColor>& colors() { return m_colors; }
|
||||
void clear(){ m_values.clear(); m_labels.clear(); m_colors.clear(); }
|
||||
void clear()
|
||||
{
|
||||
m_values.clear();
|
||||
m_labels.clear();
|
||||
m_colors.clear();
|
||||
}
|
||||
|
||||
private:
|
||||
QList<qreal> m_values, m_xAxisValues;
|
||||
QList<QString> m_labels;
|
||||
@ -35,7 +42,10 @@ class SeriesItem : public QObject{
|
||||
Q_PROPERTY(QColor color READ color WRITE setColor)
|
||||
Q_PROPERTY(SeriesItemPreferredType preferredType READ preferredType WRITE setPreferredType)
|
||||
public:
|
||||
enum SeriesItemPreferredType {Bar, Line};
|
||||
enum SeriesItemPreferredType {
|
||||
Bar,
|
||||
Line
|
||||
};
|
||||
#if QT_VERSION >= 0x050500
|
||||
Q_ENUM(SeriesItemPreferredType)
|
||||
#else
|
||||
@ -58,6 +68,7 @@ public:
|
||||
SeriesItemPreferredType preferredType() const;
|
||||
void setPreferredType(const SeriesItemPreferredType& preferredType);
|
||||
bool isEmpty() { return m_data.values().isEmpty(); }
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
QString m_valuesColumn;
|
||||
@ -77,13 +88,16 @@ public:
|
||||
virtual void paintChart(QPainter* painter, QRectF rect) = 0;
|
||||
virtual void paintChartLegend(QPainter* painter, QRectF legendRect) = 0;
|
||||
virtual QSizeF calcChartLegendSize(const QFont& font, qreal maxWidth = 0) = 0;
|
||||
virtual QRectF calcChartLegendRect(const QFont& font, const QRectF& parentRect, bool takeAllRect, qreal borderMargin, qreal titleOffset);
|
||||
virtual QRectF calcChartLegendRect(const QFont& font, const QRectF& parentRect,
|
||||
bool takeAllRect, qreal borderMargin, qreal titleOffset);
|
||||
|
||||
QFont titleFont();
|
||||
void setTitleFont(const QFont& value);
|
||||
|
||||
protected:
|
||||
QVector<qreal> legendColumnWidths() const;
|
||||
virtual void prepareLegendToPaint(QRectF& legendRect, QPainter* painter);
|
||||
|
||||
protected:
|
||||
// Title font must be placed here instead of CharItem, becuase
|
||||
// it would cause crash when creating CharItem object on embedded
|
||||
@ -96,6 +110,7 @@ protected:
|
||||
class AbstractSeriesChart: public AbstractChart {
|
||||
public:
|
||||
AbstractSeriesChart(ChartItem* chartItem);
|
||||
|
||||
protected:
|
||||
AxisData& xAxisData() const;
|
||||
AxisData& yAxisData() const;
|
||||
@ -123,8 +138,9 @@ protected:
|
||||
|
||||
private:
|
||||
bool calculateLegendColumnWidths(qreal indicatorWidth, qreal maxWidth, const QFontMetrics& fm);
|
||||
bool calculateLegendSingleColumnWidth(qreal ¤tRowWidth, int ¤tColumn, int &maxColumnCount,
|
||||
const qreal itemWidth, const qreal maxRowWidth);
|
||||
bool calculateLegendSingleColumnWidth(qreal& currentRowWidth, int& currentColumn,
|
||||
int& maxColumnCount, const qreal itemWidth,
|
||||
const qreal maxRowWidth);
|
||||
qreal m_designValues[9];
|
||||
};
|
||||
|
||||
@ -132,18 +148,19 @@ class AbstractBarChart: public AbstractSeriesChart{
|
||||
public:
|
||||
AbstractBarChart(ChartItem* chartItem): AbstractSeriesChart(chartItem) { }
|
||||
void paintChartLegend(QPainter* painter, QRectF legendRect);
|
||||
|
||||
protected:
|
||||
QRectF verticalLabelsRect(QPainter* painter, QRectF horizontalLabelsRect);
|
||||
virtual QRectF horizontalLabelsRect(QPainter* painter, QRectF horizontalLabelsRect);
|
||||
|
||||
private:
|
||||
void drawVerticalLegendItem(QPainter *painter, int i, const QString &text,
|
||||
int indicatorSize, const QRectF &indicatorsRect, const QColor &indicatorColor);
|
||||
void drawHorizontalLegendItem(QPainter *painter, int i, const QString &text,
|
||||
int indicatorSize, const QRectF &indicatorsRect, const QColor &indicatorColor);
|
||||
void drawVerticalLegendItem(QPainter* painter, int i, const QString& text, int indicatorSize,
|
||||
const QRectF& indicatorsRect, const QColor& indicatorColor);
|
||||
void drawHorizontalLegendItem(QPainter* painter, int i, const QString& text, int indicatorSize,
|
||||
const QRectF& indicatorsRect, const QColor& indicatorColor);
|
||||
};
|
||||
|
||||
class ChartItem : public LimeReport::ItemDesignIntf
|
||||
{
|
||||
class ChartItem: public LimeReport::ItemDesignIntf {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QObject* xAxisSettings READ xAxisSettings WRITE setXAxisSettings)
|
||||
Q_PROPERTY(QObject* yAxisSettings READ yAxisSettings WRITE setYAxisSettings)
|
||||
@ -170,13 +187,32 @@ class ChartItem : public LimeReport::ItemDesignIntf
|
||||
Q_PROPERTY(QString xAxisField READ xAxisField WRITE setXAxisField)
|
||||
Q_PROPERTY(GridChartLines gridChartLines READ gridChartLines WRITE setGridChartLines)
|
||||
friend class AbstractChart;
|
||||
public:
|
||||
|
||||
enum LegendAlign{LegendAlignRightTop,LegendAlignRightCenter,LegendAlignRightBottom,
|
||||
LegendAlignBottomLeft,LegendAlignBottomCenter,LegendAlignBottomRight};
|
||||
enum LegendStyle{LegendPoints, LegendLines};
|
||||
enum TitleAlign{TitleAlignLeft, TitleAlignCenter, TitleAlignRight};
|
||||
enum ChartType{Pie, VerticalBar, HorizontalBar, Lines, GridLines};
|
||||
public:
|
||||
enum LegendAlign {
|
||||
LegendAlignRightTop,
|
||||
LegendAlignRightCenter,
|
||||
LegendAlignRightBottom,
|
||||
LegendAlignBottomLeft,
|
||||
LegendAlignBottomCenter,
|
||||
LegendAlignBottomRight
|
||||
};
|
||||
enum LegendStyle {
|
||||
LegendPoints,
|
||||
LegendLines
|
||||
};
|
||||
enum TitleAlign {
|
||||
TitleAlignLeft,
|
||||
TitleAlignCenter,
|
||||
TitleAlignRight
|
||||
};
|
||||
enum ChartType {
|
||||
Pie,
|
||||
VerticalBar,
|
||||
HorizontalBar,
|
||||
Lines,
|
||||
GridLines
|
||||
};
|
||||
enum LineType {
|
||||
NoLine = 0,
|
||||
HorizontalLine = 1,
|
||||
@ -280,6 +316,7 @@ protected:
|
||||
void fillLabels(IDataSource* dataSource);
|
||||
bool isNeedUpdateSize(RenderPass pass) const;
|
||||
void setSeries(ACollectionProperty series) { Q_UNUSED(series) }
|
||||
|
||||
private:
|
||||
QList<SeriesItem*> m_series;
|
||||
QString m_datasource;
|
||||
|
@ -1,12 +1,20 @@
|
||||
#include "lrchartitemeditor.h"
|
||||
#include "ui_lrchartitemeditor.h"
|
||||
|
||||
#include "lrchartitem.h"
|
||||
#include "lrpagedesignintf.h"
|
||||
|
||||
#include <QColorDialog>
|
||||
|
||||
ChartItemEditor::ChartItemEditor(LimeReport::ChartItem *item, LimeReport::PageDesignIntf *page, QSettings *settings, QWidget *parent):
|
||||
QWidget(parent), ui(new Ui::ChartItemEditor), m_charItem(item), m_page(page),
|
||||
m_settings(settings), m_ownedSettings(false), m_isReadingSetting(false)
|
||||
ChartItemEditor::ChartItemEditor(LimeReport::ChartItem* item, LimeReport::PageDesignIntf* page,
|
||||
QSettings* settings, QWidget* parent):
|
||||
QWidget(parent),
|
||||
ui(new Ui::ChartItemEditor),
|
||||
m_charItem(item),
|
||||
m_page(page),
|
||||
m_settings(settings),
|
||||
m_ownedSettings(false),
|
||||
m_isReadingSetting(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QHBoxLayout* colorLayout = new QHBoxLayout();
|
||||
@ -49,7 +57,8 @@ QSettings* ChartItemEditor::settings()
|
||||
|
||||
void ChartItemEditor::readSetting()
|
||||
{
|
||||
if (settings()==0) return;
|
||||
if (settings() == 0)
|
||||
return;
|
||||
|
||||
m_isReadingSetting = true;
|
||||
|
||||
@ -101,7 +110,8 @@ void ChartItemEditor::init()
|
||||
|
||||
if (!m_charItem->datasource().isEmpty()) {
|
||||
if (m_page && m_page->datasourceManager()) {
|
||||
LimeReport::IDataSource* ds = m_page->datasourceManager()->dataSource(m_charItem->datasource());
|
||||
LimeReport::IDataSource* ds
|
||||
= m_page->datasourceManager()->dataSource(m_charItem->datasource());
|
||||
if (ds) {
|
||||
for (int i = 0; i < ds->columnCount(); ++i) {
|
||||
ui->valuesFieldComboBox->addItem(ds->columnNameByIndex(i));
|
||||
@ -110,18 +120,20 @@ void ChartItemEditor::init()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static int enumIndex = LimeReport::SeriesItem::staticMetaObject.indexOfEnumerator("SeriesItemPreferredType");
|
||||
static int enumIndex
|
||||
= LimeReport::SeriesItem::staticMetaObject.indexOfEnumerator("SeriesItemPreferredType");
|
||||
QMetaEnum enumerator = LimeReport::SeriesItem::staticMetaObject.enumerator(enumIndex);
|
||||
for (int i = 0; i < enumerator.keyCount(); ++i) {
|
||||
ui->seriesTypeComboBox->addItem(enumerator.key(i));
|
||||
}
|
||||
|
||||
#if QT_VERSION < 0x050000
|
||||
ui->labelsFieldComboBox->setCurrentIndex(ui->labelsFieldComboBox->findText( m_charItem->labelsField()));
|
||||
ui->xAxisFieldComboBox->setCurrentIndex(ui->xAxisFieldComboBox->findText( m_charItem->xAxisField()));
|
||||
ui->labelsFieldComboBox->setCurrentIndex(
|
||||
ui->labelsFieldComboBox->findText(m_charItem->labelsField()));
|
||||
ui->xAxisFieldComboBox->setCurrentIndex(
|
||||
ui->xAxisFieldComboBox->findText(m_charItem->xAxisField()));
|
||||
#else
|
||||
ui->labelsFieldComboBox->setCurrentText(m_charItem->labelsField());
|
||||
ui->xAxisFieldComboBox->setCurrentText(m_charItem->xAxisField());
|
||||
@ -200,14 +212,18 @@ void ChartItemEditor::slotAddSeries()
|
||||
{
|
||||
LimeReport::SeriesItem* series = new LimeReport::SeriesItem();
|
||||
int curSeriesNumber = m_charItem->series().count();
|
||||
while (m_charItem->isSeriesExists("Series"+QString::number(curSeriesNumber))) curSeriesNumber++;
|
||||
while (m_charItem->isSeriesExists("Series" + QString::number(curSeriesNumber)))
|
||||
curSeriesNumber++;
|
||||
series->setName("Series" + QString::number(curSeriesNumber));
|
||||
series->setValuesColumn("");
|
||||
series->setLabelsColumn("");
|
||||
series->setColor((m_charItem->series().count()<32)?LimeReport::color_map[m_charItem->series().count()]:LimeReport::generateColor());
|
||||
series->setColor((m_charItem->series().count() < 32)
|
||||
? LimeReport::color_map[m_charItem->series().count()]
|
||||
: LimeReport::generateColor());
|
||||
m_charItem->series().append(series);
|
||||
ui->tableWidget->setRowCount(m_charItem->series().count());
|
||||
ui->tableWidget->setItem(m_charItem->series().count()-1, 0, new QTableWidgetItem(series->name()));
|
||||
ui->tableWidget->setItem(m_charItem->series().count() - 1, 0,
|
||||
new QTableWidgetItem(series->name()));
|
||||
ui->tableWidget->selectRow(m_charItem->series().count() - 1);
|
||||
#if QT_VERSION < 0x050000
|
||||
ui->valuesFieldComboBox->setEditText("");
|
||||
@ -233,18 +249,22 @@ void ChartItemEditor::slotDeleteSeries()
|
||||
void ChartItemEditor::on_tableWidget_itemSelectionChanged()
|
||||
{
|
||||
if (ui->tableWidget->selectionModel()->hasSelection()) {
|
||||
LimeReport::SeriesItem* series = m_charItem->series().at(ui->tableWidget->selectionModel()->currentIndex().row());
|
||||
LimeReport::SeriesItem* series
|
||||
= m_charItem->series().at(ui->tableWidget->selectionModel()->currentIndex().row());
|
||||
ui->seriesNameLineEdit->setText(series->name());
|
||||
#if QT_VERSION < 0x050000
|
||||
ui->valuesFieldComboBox->setCurrentIndex(ui->valuesFieldComboBox->findText(series->valuesColumn()));
|
||||
ui->valuesFieldComboBox->setCurrentIndex(
|
||||
ui->valuesFieldComboBox->findText(series->valuesColumn()));
|
||||
#else
|
||||
ui->valuesFieldComboBox->setCurrentText(series->valuesColumn());
|
||||
#endif
|
||||
m_colorIndicator->setColor(series->color());
|
||||
static int enumIndex = LimeReport::SeriesItem::staticMetaObject.indexOfEnumerator("SeriesItemPreferredType");
|
||||
static int enumIndex
|
||||
= LimeReport::SeriesItem::staticMetaObject.indexOfEnumerator("SeriesItemPreferredType");
|
||||
QMetaEnum enumerator = LimeReport::SeriesItem::staticMetaObject.enumerator(enumIndex);
|
||||
#if QT_VERSION < 0x050000
|
||||
ui->seriesTypeComboBox->setCurrentIndex(ui->seriesTypeComboBox->findText(enumerator.valueToKey(series->preferredType())));
|
||||
ui->seriesTypeComboBox->setCurrentIndex(
|
||||
ui->seriesTypeComboBox->findText(enumerator.valueToKey(series->preferredType())));
|
||||
#else
|
||||
ui->seriesTypeComboBox->setCurrentText(enumerator.valueToKey(series->preferredType()));
|
||||
#endif
|
||||
@ -284,10 +304,13 @@ void ChartItemEditor::slotChangeSeriesColor()
|
||||
|
||||
void ChartItemEditor::on_seriesTypeComboBox_currentIndexChanged(const QString& arg1)
|
||||
{
|
||||
static int enumIndex = LimeReport::SeriesItem::staticMetaObject.indexOfEnumerator("SeriesItemPreferredType");
|
||||
static int enumIndex
|
||||
= LimeReport::SeriesItem::staticMetaObject.indexOfEnumerator("SeriesItemPreferredType");
|
||||
QMetaEnum enumerator = LimeReport::SeriesItem::staticMetaObject.enumerator(enumIndex);
|
||||
if (currentSeries()) {
|
||||
currentSeries()->setPreferredType(static_cast<LimeReport::SeriesItem::SeriesItemPreferredType>(enumerator.keysToValue(arg1.toLatin1())));
|
||||
currentSeries()->setPreferredType(
|
||||
static_cast<LimeReport::SeriesItem::SeriesItemPreferredType>(
|
||||
enumerator.keysToValue(arg1.toLatin1())));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,23 +1,24 @@
|
||||
#ifndef CHARITEMEDITOR_H
|
||||
#define CHARITEMEDITOR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "lrchartitem.h"
|
||||
#include "lrcolorindicator.h"
|
||||
|
||||
#include <QTableWidgetItem>
|
||||
#include <QToolButton>
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class ChartItemEditor;
|
||||
}
|
||||
|
||||
class ChartItemEditor : public QWidget
|
||||
{
|
||||
class ChartItemEditor: public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ChartItemEditor(LimeReport::ChartItem* item, LimeReport::PageDesignIntf* page,
|
||||
QSettings* settings = 0, QWidget* parent = 0);
|
||||
~ChartItemEditor();
|
||||
|
||||
public:
|
||||
QSettings* settings();
|
||||
void rebuildTable();
|
||||
@ -50,6 +51,7 @@ private:
|
||||
void enableSeriesEditor();
|
||||
void disableSeriesEditor();
|
||||
LimeReport::SeriesItem* currentSeries();
|
||||
|
||||
private:
|
||||
Ui::ChartItemEditor* ui;
|
||||
LimeReport::ChartItem* m_charItem;
|
||||
|
@ -14,7 +14,6 @@ public:
|
||||
virtual QString fileFilter() const = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LREDITABLEIMAGEITEMINTF_H
|
||||
|
@ -28,14 +28,14 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrhorizontallayout.h"
|
||||
|
||||
#include "lrbasedesignintf.h"
|
||||
#include "lrdesignelementsfactory.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QObject>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
|
||||
#include "lrbasedesignintf.h"
|
||||
#include <QObject>
|
||||
|
||||
const QString xmlTag = "HLayout";
|
||||
|
||||
@ -46,25 +46,23 @@ LimeReport::BaseDesignIntf *createHLayout(QObject *owner, LimeReport::BaseDesign
|
||||
return new LimeReport::HorizontalLayout(owner, parent);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag,
|
||||
LimeReport::ItemAttribs(QObject::tr("HLayout"), LimeReport::Const::bandTAG),
|
||||
createHLayout
|
||||
);
|
||||
}
|
||||
|
||||
xmlTag, LimeReport::ItemAttribs(QObject::tr("HLayout"), LimeReport::Const::bandTAG),
|
||||
createHLayout);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
bool horizontalLessThen(BaseDesignIntf *c1, BaseDesignIntf* c2){
|
||||
bool horizontalLessThen(BaseDesignIntf* c1, BaseDesignIntf* c2)
|
||||
{
|
||||
return c1->pos().x() < c2->pos().x();
|
||||
}
|
||||
|
||||
HorizontalLayout::HorizontalLayout(QObject *owner, QGraphicsItem *parent)
|
||||
: AbstractLayout(xmlTag, owner, parent)
|
||||
{}
|
||||
HorizontalLayout::HorizontalLayout(QObject* owner, QGraphicsItem* parent):
|
||||
AbstractLayout(xmlTag, owner, parent)
|
||||
{
|
||||
}
|
||||
|
||||
HorizontalLayout::~HorizontalLayout()
|
||||
{}
|
||||
HorizontalLayout::~HorizontalLayout() { }
|
||||
|
||||
BaseDesignIntf* HorizontalLayout::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
@ -76,14 +74,16 @@ bool HorizontalLayout::canBeSplitted(int height) const
|
||||
foreach (QGraphicsItem* qgItem, childItems()) {
|
||||
BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(qgItem);
|
||||
if (item)
|
||||
if (!item->canBeSplitted(height - item->pos().y())) return false;
|
||||
if (!item->canBeSplitted(height - item->pos().y()))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
BaseDesignIntf* HorizontalLayout::cloneUpperPart(int height, QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
HorizontalLayout* upperPart = dynamic_cast<HorizontalLayout*>(createSameTypeItem(owner,parent));
|
||||
HorizontalLayout* upperPart
|
||||
= dynamic_cast<HorizontalLayout*>(createSameTypeItem(owner, parent));
|
||||
upperPart->initFromItem(this);
|
||||
qreal maxHeight = 0;
|
||||
foreach (BaseDesignIntf* item, childBaseItems()) {
|
||||
@ -91,11 +91,14 @@ BaseDesignIntf *HorizontalLayout::cloneUpperPart(int height, QObject *owner, QGr
|
||||
if ((item->geometry().top() < height) && (item->geometry().bottom() > height)) {
|
||||
int sliceHeight = height - item->geometry().top();
|
||||
if (item->canBeSplitted(sliceHeight)) {
|
||||
BaseDesignIntf* slicedPart = item->cloneUpperPart(sliceHeight,upperPart,upperPart);
|
||||
if (maxHeight<slicedPart->height()) maxHeight = slicedPart->height();
|
||||
BaseDesignIntf* slicedPart
|
||||
= item->cloneUpperPart(sliceHeight, upperPart, upperPart);
|
||||
if (maxHeight < slicedPart->height())
|
||||
maxHeight = slicedPart->height();
|
||||
} else {
|
||||
item->cloneEmpty(sliceHeight, upperPart, upperPart);
|
||||
item->setPos(item->pos().x(),item->pos().y()+((height+1)-item->geometry().top()));
|
||||
item->setPos(item->pos().x(),
|
||||
item->pos().y() + ((height + 1) - item->geometry().top()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -111,7 +114,8 @@ BaseDesignIntf *HorizontalLayout::cloneUpperPart(int height, QObject *owner, QGr
|
||||
BaseDesignIntf* HorizontalLayout::cloneBottomPart(int height, QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
qreal maxHeight = 0;
|
||||
HorizontalLayout* bottomPart = dynamic_cast<HorizontalLayout*>(createSameTypeItem(owner,parent));
|
||||
HorizontalLayout* bottomPart
|
||||
= dynamic_cast<HorizontalLayout*>(createSameTypeItem(owner, parent));
|
||||
bottomPart->initFromItem(this);
|
||||
foreach (BaseDesignIntf* item, childBaseItems()) {
|
||||
if ((item->geometry().top() < height) && (item->geometry().bottom() > height)) {
|
||||
@ -150,14 +154,17 @@ void HorizontalLayout::updateLayoutSize()
|
||||
qreal h = 0;
|
||||
int visibleItemCount = 0;
|
||||
foreach (BaseDesignIntf* item, layoutsChildren()) {
|
||||
if (item->isEmpty() && hideEmptyItems()) item->setVisible(false);
|
||||
if (item->isEmpty() && hideEmptyItems())
|
||||
item->setVisible(false);
|
||||
if (item->isVisible()) {
|
||||
if (h<item->height()) h=item->height();
|
||||
if (h < item->height())
|
||||
h = item->height();
|
||||
w += item->width();
|
||||
visibleItemCount++;
|
||||
}
|
||||
}
|
||||
if (h>0) setHeight(h+spaceBorder*2);
|
||||
if (h > 0)
|
||||
setHeight(h + spaceBorder * 2);
|
||||
if (layoutType() == Layout)
|
||||
setWidth(w + layoutSpacingMM() * (visibleItemCount - 1));
|
||||
else {
|
||||
@ -199,7 +206,8 @@ void HorizontalLayout::relocateChildren()
|
||||
}
|
||||
}
|
||||
|
||||
void HorizontalLayout::divideSpace(){
|
||||
void HorizontalLayout::divideSpace()
|
||||
{
|
||||
setIsRelocating(true);
|
||||
qreal itemsSumSize = 0;
|
||||
int visibleItemsCount = 0;
|
||||
@ -218,13 +226,16 @@ void HorizontalLayout::divideSpace(){
|
||||
qreal delta = (width() - (itemsSumSize + spaceBorder * 2));
|
||||
layoutsChildren().last()->setWidth(layoutsChildren().last()->width() + delta);
|
||||
} else {
|
||||
qreal delta = (width() - (itemsSumSize+spaceBorder*2)) / (visibleItemsCount!=0 ? visibleItemsCount : 1);
|
||||
qreal delta = (width() - (itemsSumSize + spaceBorder * 2))
|
||||
/ (visibleItemsCount != 0 ? visibleItemsCount : 1);
|
||||
for (int i = 0; i < layoutsChildren().size(); ++i) {
|
||||
if (layoutsChildren()[i]->isVisible() || itemMode() == DesignMode)
|
||||
layoutsChildren()[i]->setWidth(layoutsChildren()[i]->width() + delta);
|
||||
if ((i + 1) < layoutsChildren().size())
|
||||
if (layoutsChildren()[i + 1]->isVisible() || itemMode() == DesignMode)
|
||||
layoutsChildren()[i+1]->setPos(layoutsChildren()[i+1]->pos().x()+delta*(i+1),layoutsChildren()[i+1]->pos().y());
|
||||
layoutsChildren()[i + 1]->setPos(layoutsChildren()[i + 1]->pos().x()
|
||||
+ delta * (i + 1),
|
||||
layoutsChildren()[i + 1]->pos().y());
|
||||
}
|
||||
}
|
||||
setIsRelocating(false);
|
||||
|
@ -29,15 +29,13 @@
|
||||
****************************************************************************/
|
||||
#ifndef LRHORIZONTALLAYOUT_H
|
||||
#define LRHORIZONTALLAYOUT_H
|
||||
#include "lrabstractlayout.h"
|
||||
#include "lritemdesignintf.h"
|
||||
#include "lrlayoutmarker.h"
|
||||
#include "lrabstractlayout.h"
|
||||
|
||||
namespace LimeReport
|
||||
{
|
||||
namespace LimeReport {
|
||||
|
||||
class HorizontalLayout : public AbstractLayout
|
||||
{
|
||||
class HorizontalLayout: public AbstractLayout {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(LayoutType layoutType READ layoutType WRITE setLayoutType)
|
||||
public:
|
||||
|
@ -28,30 +28,38 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrimageitem.h"
|
||||
|
||||
#include "lrdatasourcemanager.h"
|
||||
#include "lrdesignelementsfactory.h"
|
||||
#include "lrglobal.h"
|
||||
#include "lrdatasourcemanager.h"
|
||||
#include "lrpagedesignintf.h"
|
||||
#include "lrimageitemeditor.h"
|
||||
#include "lrpagedesignintf.h"
|
||||
|
||||
namespace {
|
||||
|
||||
const QString xmlTag = "ImageItem";
|
||||
|
||||
LimeReport::BaseDesignIntf * createImageItem(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
LimeReport::BaseDesignIntf* createImageItem(QObject* owner, LimeReport::BaseDesignIntf* parent)
|
||||
{
|
||||
return new LimeReport::ImageItem(owner, parent);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag, LimeReport::ItemAttribs(QObject::tr("Image Item"),"Item"), createImageItem
|
||||
);
|
||||
}
|
||||
xmlTag, LimeReport::ItemAttribs(QObject::tr("Image Item"), "Item"), createImageItem);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
ImageItem::ImageItem(QObject* owner,QGraphicsItem* parent)
|
||||
:ItemDesignIntf(xmlTag,owner,parent), m_useExternalPainter(false), m_externalPainter(0),
|
||||
m_autoSize(false), m_scale(true),
|
||||
m_keepAspectRatio(true), m_center(true), m_format(Binary){}
|
||||
ImageItem::ImageItem(QObject* owner, QGraphicsItem* parent):
|
||||
ItemDesignIntf(xmlTag, owner, parent),
|
||||
m_useExternalPainter(false),
|
||||
m_externalPainter(0),
|
||||
m_autoSize(false),
|
||||
m_scale(true),
|
||||
m_keepAspectRatio(true),
|
||||
m_center(true),
|
||||
m_format(Binary)
|
||||
{
|
||||
}
|
||||
|
||||
BaseDesignIntf* ImageItem::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
@ -60,7 +68,8 @@ BaseDesignIntf *ImageItem::createSameTypeItem(QObject *owner, QGraphicsItem *par
|
||||
return result;
|
||||
}
|
||||
|
||||
void ImageItem::loadPictureFromVariant(QVariant& data){
|
||||
void ImageItem::loadPictureFromVariant(QVariant& data)
|
||||
{
|
||||
// TODO: Migrate to QMetaType
|
||||
if (data.isValid()) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
@ -83,7 +92,6 @@ void ImageItem::loadPictureFromVariant(QVariant& data){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,7 +105,6 @@ void ImageItem::preparePopUpMenu(QMenu &menu)
|
||||
QAction* action = menu.addAction(tr("Watermark"));
|
||||
action->setCheckable(true);
|
||||
action->setChecked(isWatermark());
|
||||
|
||||
}
|
||||
|
||||
void ImageItem::processPopUpAction(QAction* action)
|
||||
@ -111,7 +118,8 @@ void ImageItem::processPopUpAction(QAction *action)
|
||||
ItemDesignIntf::processPopUpAction(action);
|
||||
}
|
||||
|
||||
QImage getFileByResourcePath(QString resourcePath) {
|
||||
QImage getFileByResourcePath(QString resourcePath)
|
||||
{
|
||||
QFileInfo resourceFile(resourcePath);
|
||||
if (resourceFile.exists())
|
||||
return QImage(resourcePath);
|
||||
@ -125,10 +133,7 @@ QImage ImageItem::drawImage() const
|
||||
return image();
|
||||
}
|
||||
|
||||
bool ImageItem::useExternalPainter() const
|
||||
{
|
||||
return m_useExternalPainter;
|
||||
}
|
||||
bool ImageItem::useExternalPainter() const { return m_useExternalPainter; }
|
||||
|
||||
void ImageItem::setUseExternalPainter(bool value)
|
||||
{
|
||||
@ -165,7 +170,8 @@ void ImageItem::setImageAsByteArray(QByteArray image)
|
||||
|
||||
QString ImageItem::fileFilter() const
|
||||
{
|
||||
return tr("Images (*.gif *.icns *.ico *.jpeg *.tga *.tiff *.wbmp *.webp *.png *.jpg *.bmp);;All(*.*)");
|
||||
return tr("Images (*.gif *.icns *.ico *.jpeg *.tga *.tiff *.wbmp *.webp *.png *.jpg "
|
||||
"*.bmp);;All(*.*)");
|
||||
}
|
||||
|
||||
void ImageItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight)
|
||||
@ -179,7 +185,8 @@ void ImageItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass,
|
||||
loadPictureFromVariant(data);
|
||||
}
|
||||
} else if (!m_resourcePath.isEmpty()) {
|
||||
m_resourcePath = expandUserVariables(m_resourcePath, pass, NoEscapeSymbols, dataManager);
|
||||
m_resourcePath
|
||||
= expandUserVariables(m_resourcePath, pass, NoEscapeSymbols, dataManager);
|
||||
m_resourcePath = expandDataFields(m_resourcePath, NoEscapeSymbols, dataManager);
|
||||
m_picture = QImage(m_resourcePath);
|
||||
} else if (!m_variable.isEmpty()) {
|
||||
@ -209,19 +216,13 @@ void ImageItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass,
|
||||
BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight);
|
||||
}
|
||||
|
||||
bool ImageItem::isNeedUpdateSize(RenderPass) const
|
||||
{
|
||||
return m_picture.isNull() || m_autoSize;
|
||||
}
|
||||
bool ImageItem::isNeedUpdateSize(RenderPass) const { return m_picture.isNull() || m_autoSize; }
|
||||
|
||||
QString ImageItem::resourcePath() const
|
||||
{
|
||||
return m_resourcePath;
|
||||
}
|
||||
QString ImageItem::resourcePath() const { return m_resourcePath; }
|
||||
|
||||
qreal ImageItem::minHeight() const{
|
||||
if (!m_picture.isNull() && autoSize())
|
||||
qreal ImageItem::minHeight() const
|
||||
{
|
||||
if (!m_picture.isNull() && autoSize()) {
|
||||
return m_picture.height();
|
||||
} else {
|
||||
return 0;
|
||||
@ -238,10 +239,7 @@ void ImageItem::setVariable(const QString& content)
|
||||
}
|
||||
}
|
||||
|
||||
bool ImageItem::center() const
|
||||
{
|
||||
return m_center;
|
||||
}
|
||||
bool ImageItem::center() const { return m_center; }
|
||||
|
||||
void ImageItem::setCenter(bool center)
|
||||
{
|
||||
@ -252,10 +250,7 @@ void ImageItem::setCenter(bool center)
|
||||
}
|
||||
}
|
||||
|
||||
bool ImageItem::keepAspectRatio() const
|
||||
{
|
||||
return m_keepAspectRatio;
|
||||
}
|
||||
bool ImageItem::keepAspectRatio() const { return m_keepAspectRatio; }
|
||||
|
||||
void ImageItem::setKeepAspectRatio(bool keepAspectRatio)
|
||||
{
|
||||
@ -266,10 +261,7 @@ void ImageItem::setKeepAspectRatio(bool keepAspectRatio)
|
||||
}
|
||||
}
|
||||
|
||||
bool ImageItem::scale() const
|
||||
{
|
||||
return m_scale;
|
||||
}
|
||||
bool ImageItem::scale() const { return m_scale; }
|
||||
|
||||
void ImageItem::setScale(bool scale)
|
||||
{
|
||||
@ -279,10 +271,7 @@ void ImageItem::setScale(bool scale)
|
||||
notify("scale", !scale, scale);
|
||||
}
|
||||
}
|
||||
bool ImageItem::autoSize() const
|
||||
{
|
||||
return m_autoSize;
|
||||
}
|
||||
bool ImageItem::autoSize() const { return m_autoSize; }
|
||||
|
||||
void ImageItem::setAutoSize(bool autoSize)
|
||||
{
|
||||
@ -300,10 +289,7 @@ void ImageItem::setAutoSize(bool autoSize)
|
||||
}
|
||||
}
|
||||
|
||||
QString ImageItem::field() const
|
||||
{
|
||||
return m_field;
|
||||
}
|
||||
QString ImageItem::field() const { return m_field; }
|
||||
|
||||
void ImageItem::setField(const QString& field)
|
||||
{
|
||||
@ -315,10 +301,7 @@ void ImageItem::setField(const QString &field)
|
||||
}
|
||||
}
|
||||
|
||||
QString ImageItem::datasource() const
|
||||
{
|
||||
return m_datasource;
|
||||
}
|
||||
QString ImageItem::datasource() const { return m_datasource; }
|
||||
|
||||
void ImageItem::setDatasource(const QString& datasource)
|
||||
{
|
||||
@ -330,18 +313,21 @@ void ImageItem::setDatasource(const QString &datasource)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ImageItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||
{
|
||||
painter->save();
|
||||
if (isSelected()) painter->setOpacity(Const::SELECTION_OPACITY);
|
||||
else painter->setOpacity(qreal(opacity())/100);
|
||||
if (isSelected())
|
||||
painter->setOpacity(Const::SELECTION_OPACITY);
|
||||
else
|
||||
painter->setOpacity(qreal(opacity()) / 100);
|
||||
|
||||
QPointF point = rect().topLeft();
|
||||
QImage img;
|
||||
|
||||
if (m_scale && !drawImage().isNull()) {
|
||||
img = drawImage().scaled(rect().width(), rect().height(), keepAspectRatio() ? Qt::KeepAspectRatio : Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
img = drawImage().scaled(rect().width(), rect().height(),
|
||||
keepAspectRatio() ? Qt::KeepAspectRatio : Qt::IgnoreAspectRatio,
|
||||
Qt::SmoothTransformation);
|
||||
} else {
|
||||
img = drawImage();
|
||||
}
|
||||
@ -383,7 +369,10 @@ void ImageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
painter->setPen(Qt::black);
|
||||
if (!datasource().isEmpty() && !field().isEmpty())
|
||||
text = datasource() + "." + field();
|
||||
else if (m_useExternalPainter) text = tr("Ext."); else text = tr("Image");
|
||||
else if (m_useExternalPainter)
|
||||
text = tr("Ext.");
|
||||
else
|
||||
text = tr("Image");
|
||||
painter->drawText(rect().adjusted(4, 4, -4, -4), Qt::AlignCenter, text);
|
||||
} else {
|
||||
if (m_externalPainter && m_useExternalPainter)
|
||||
@ -410,11 +399,10 @@ void ImageItem::setImage(QImage value)
|
||||
}
|
||||
}
|
||||
|
||||
QImage ImageItem::image() const{
|
||||
return m_picture;
|
||||
}
|
||||
QImage ImageItem::image() const { return m_picture; }
|
||||
|
||||
void ImageItem::setResourcePath(const QString &value){
|
||||
void ImageItem::setResourcePath(const QString& value)
|
||||
{
|
||||
if (m_resourcePath != value) {
|
||||
QString oldValue = m_resourcePath;
|
||||
m_resourcePath = value;
|
||||
@ -423,10 +411,7 @@ void ImageItem::setResourcePath(const QString &value){
|
||||
}
|
||||
}
|
||||
|
||||
ImageItem::Format ImageItem::format() const
|
||||
{
|
||||
return m_format;
|
||||
}
|
||||
ImageItem::Format ImageItem::format() const { return m_format; }
|
||||
|
||||
void ImageItem::setFormat(Format format)
|
||||
{
|
||||
@ -438,9 +423,6 @@ void ImageItem::setFormat(Format format)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
bool LimeReport::ImageItem::isEmpty() const
|
||||
{
|
||||
return drawImage().isNull();
|
||||
}
|
||||
bool LimeReport::ImageItem::isEmpty() const { return drawImage().isNull(); }
|
||||
|
@ -29,14 +29,14 @@
|
||||
****************************************************************************/
|
||||
#ifndef LRIMAGEITEM_H
|
||||
#define LRIMAGEITEM_H
|
||||
#include "lritemdesignintf.h"
|
||||
#include "lreditableimageitemintf.h"
|
||||
#include "lritemdesignintf.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
class ImageItem : public ItemDesignIntf, public IPainterProxy, public IEditableImageItem
|
||||
{
|
||||
class ImageItem: public ItemDesignIntf, public IPainterProxy, public IEditableImageItem {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QImage image READ image WRITE setImage)
|
||||
Q_PROPERTY(int opacity READ opacity WRITE setOpacity)
|
||||
@ -90,7 +90,10 @@ public:
|
||||
QString variable() { return m_variable; }
|
||||
void setVariable(const QString& variable);
|
||||
|
||||
void setExternalPainter(IExternalPainter* externalPainter){ m_externalPainter = externalPainter;}
|
||||
void setExternalPainter(IExternalPainter* externalPainter)
|
||||
{
|
||||
m_externalPainter = externalPainter;
|
||||
}
|
||||
|
||||
bool useExternalPainter() const;
|
||||
void setUseExternalPainter(bool value);
|
||||
@ -100,6 +103,7 @@ public:
|
||||
QByteArray imageAsByteArray() const;
|
||||
void setImageAsByteArray(QByteArray image);
|
||||
QString fileFilter() const;
|
||||
|
||||
protected:
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner, QGraphicsItem* parent);
|
||||
void updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight);
|
||||
@ -109,6 +113,7 @@ protected:
|
||||
void preparePopUpMenu(QMenu& menu);
|
||||
void processPopUpAction(QAction* action);
|
||||
QImage drawImage() const;
|
||||
|
||||
private:
|
||||
QImage m_picture;
|
||||
bool m_useExternalPainter;
|
||||
@ -123,11 +128,10 @@ private:
|
||||
Format m_format;
|
||||
QString m_variable;
|
||||
|
||||
|
||||
// BaseDesignIntf interface
|
||||
public:
|
||||
bool isEmpty() const override;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRIMAGEITEM_H
|
||||
|
@ -1,13 +1,15 @@
|
||||
#include "lrimageitemeditor.h"
|
||||
#include "ui_lrimageitemeditor.h"
|
||||
|
||||
#include "lrimageitem.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
|
||||
ImageItemEditor::ImageItemEditor(LimeReport::IEditableImageItem* item, QWidget* parent):
|
||||
QWidget(parent),
|
||||
ui(new Ui::ImageItemEditor), m_item(item)
|
||||
ui(new Ui::ImageItemEditor),
|
||||
m_item(item)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
m_image = item->imageAsByteArray();
|
||||
@ -15,10 +17,7 @@ ImageItemEditor::ImageItemEditor(LimeReport::IEditableImageItem *item, QWidget *
|
||||
updateImage();
|
||||
}
|
||||
|
||||
ImageItemEditor::~ImageItemEditor()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
ImageItemEditor::~ImageItemEditor() { delete ui; }
|
||||
|
||||
void ImageItemEditor::updateImage()
|
||||
{
|
||||
@ -33,7 +32,8 @@ void ImageItemEditor::updateImage()
|
||||
|
||||
void ImageItemEditor::on_tbLoadImage_clicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Select image file"), "", m_item->fileFilter());
|
||||
QString fileName
|
||||
= QFileDialog::getOpenFileName(this, tr("Select image file"), "", m_item->fileFilter());
|
||||
QFile file(fileName);
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
m_image = file.readAll();
|
||||
@ -55,10 +55,7 @@ void ImageItemEditor::on_buttonBox_accepted()
|
||||
this->close();
|
||||
}
|
||||
|
||||
void ImageItemEditor::on_buttonBox_rejected()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
void ImageItemEditor::on_buttonBox_rejected() { this->close(); }
|
||||
|
||||
void ImageItemEditor::on_toolButton_clicked()
|
||||
{
|
||||
|
@ -1,9 +1,10 @@
|
||||
#ifndef LRIMAGEITEMEDITOR_H
|
||||
#define LRIMAGEITEMEDITOR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "lreditableimageitemintf.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class ImageItemEditor;
|
||||
}
|
||||
@ -12,15 +13,16 @@ namespace LimeReport {
|
||||
class ImageItem;
|
||||
}
|
||||
|
||||
class ImageItemEditor : public QWidget
|
||||
{
|
||||
class ImageItemEditor: public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ImageItemEditor(LimeReport::IEditableImageItem* item, QWidget* parent = NULL);
|
||||
~ImageItemEditor();
|
||||
|
||||
private:
|
||||
void updateImage();
|
||||
|
||||
private:
|
||||
Ui::ImageItemEditor* ui;
|
||||
LimeReport::IEditableImageItem* m_item;
|
||||
|
@ -1,11 +1,16 @@
|
||||
#include "lrlayoutmarker.h"
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
LayoutMarker::LayoutMarker(BaseDesignIntf* layout, QGraphicsItem *parent)
|
||||
:QGraphicsItem(parent), m_rect(0,0,30,30), m_color(Qt::red), m_layout(layout){
|
||||
LayoutMarker::LayoutMarker(BaseDesignIntf* layout, QGraphicsItem* parent):
|
||||
QGraphicsItem(parent),
|
||||
m_rect(0, 0, 30, 30),
|
||||
m_color(Qt::red),
|
||||
m_layout(layout)
|
||||
{
|
||||
setFlag(QGraphicsItem::ItemIsMovable);
|
||||
}
|
||||
|
||||
@ -16,7 +21,8 @@ void LayoutMarker::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QW
|
||||
painter->fillRect(boundingRect(), m_color);
|
||||
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
qreal size = (boundingRect().width()<boundingRect().height()) ? boundingRect().width() : boundingRect().height();
|
||||
qreal size = (boundingRect().width() < boundingRect().height()) ? boundingRect().width()
|
||||
: boundingRect().height();
|
||||
|
||||
if (m_layout->isSelected()) {
|
||||
painter->setOpacity(1);
|
||||
@ -65,5 +71,4 @@ void LayoutMarker::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -1,9 +1,10 @@
|
||||
#ifndef LRLAYOUTMARKER_H
|
||||
#define LRLAYOUTMARKER_H
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include "lrbanddesignintf.h"
|
||||
|
||||
#include <QGraphicsItem>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
class LayoutMarker: public QGraphicsItem {
|
||||
@ -16,8 +17,10 @@ public:
|
||||
void setColor(QColor color);
|
||||
qreal width() { return m_rect.width(); }
|
||||
qreal height() { return m_rect.height(); }
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent* event);
|
||||
|
||||
private:
|
||||
QRectF m_rect;
|
||||
QColor m_color;
|
||||
|
@ -1,9 +1,11 @@
|
||||
#include "lrpageeditor.h"
|
||||
#include "ui_lrpageeditor.h"
|
||||
|
||||
#include "lrpagedesignintf.h"
|
||||
#include "lrpageitemdesignintf.h"
|
||||
#include <QPushButton>
|
||||
|
||||
#include <QPageSize>
|
||||
#include <QPushButton>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
@ -14,7 +16,9 @@ PageEditor::PageEditor(QWidget *parent, LimeReport::PageItemDesignIntf *page) :
|
||||
ui->setupUi(this);
|
||||
m_page = page;
|
||||
// Paper
|
||||
QMetaEnum pageSizes = page->metaObject()->property(page->metaObject()->indexOfProperty("pageSize")).enumerator();
|
||||
QMetaEnum pageSizes = page->metaObject()
|
||||
->property(page->metaObject()->indexOfProperty("pageSize"))
|
||||
.enumerator();
|
||||
|
||||
for (int i = 0; i < pageSizes.keyCount(); i++) {
|
||||
ui->format->addItem(pageSizes.key(i));
|
||||
@ -23,7 +27,8 @@ PageEditor::PageEditor(QWidget *parent, LimeReport::PageItemDesignIntf *page) :
|
||||
ui->width->setValue(m_page->width() / m_page->unitFactor());
|
||||
ui->height->setValue(m_page->height() / m_page->unitFactor());
|
||||
ui->portrait->setChecked(m_page->pageOrientation() == LimeReport::PageItemDesignIntf::Portrait);
|
||||
ui->landscape->setChecked(m_page->pageOrientation() == LimeReport::PageItemDesignIntf::Landscape);
|
||||
ui->landscape->setChecked(m_page->pageOrientation()
|
||||
== LimeReport::PageItemDesignIntf::Landscape);
|
||||
// Margins
|
||||
ui->marginTop->setValue(m_page->topMargin());
|
||||
ui->marginRight->setValue(m_page->rightMargin());
|
||||
@ -37,17 +42,17 @@ PageEditor::PageEditor(QWidget *parent, LimeReport::PageItemDesignIntf *page) :
|
||||
ui->fullPage->setChecked(m_page->fullPage());
|
||||
}
|
||||
|
||||
PageEditor::~PageEditor()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
PageEditor::~PageEditor() { delete ui; }
|
||||
|
||||
void PageEditor::applyChanges()
|
||||
{
|
||||
m_page->setPageSize(static_cast<LimeReport::PageItemDesignIntf::PageSize>(ui->format->currentIndex()));
|
||||
m_page->setPageSize(
|
||||
static_cast<LimeReport::PageItemDesignIntf::PageSize>(ui->format->currentIndex()));
|
||||
m_page->setWidth(ui->width->value() * LimeReport::Const::mmFACTOR);
|
||||
m_page->setHeight(ui->height->value() * LimeReport::Const::mmFACTOR);
|
||||
m_page->setPageOrientation(ui->portrait->isChecked()? LimeReport::PageItemDesignIntf::Portrait : LimeReport::PageItemDesignIntf::Landscape);
|
||||
m_page->setPageOrientation(ui->portrait->isChecked()
|
||||
? LimeReport::PageItemDesignIntf::Portrait
|
||||
: LimeReport::PageItemDesignIntf::Landscape);
|
||||
m_page->setTopMargin(ui->marginTop->value());
|
||||
m_page->setBottomMargin(ui->marginBottom->value());
|
||||
m_page->setRightMargin(ui->marginRight->value());
|
||||
@ -65,7 +70,8 @@ QSizeF PageEditor::getRectByPageSize(const LimeReport::PageItemDesignIntf::PageS
|
||||
QPrinter printer;
|
||||
printer.setOutputFormat(QPrinter::PdfFormat);
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
|
||||
printer.setOrientation(ui->portrait->isChecked() ? QPrinter::Portrait : QPrinter::Landscape);
|
||||
printer.setOrientation(ui->portrait->isChecked() ? QPrinter::Portrait
|
||||
: QPrinter::Landscape);
|
||||
printer.setPaperSize((QPrinter::PageSize)size);
|
||||
return QSizeF(printer.paperSize(QPrinter::Millimeter).width() * m_page->unitFactor(),
|
||||
printer.paperSize(QPrinter::Millimeter).height() * m_page->unitFactor());
|
||||
@ -73,8 +79,10 @@ QSizeF PageEditor::getRectByPageSize(const LimeReport::PageItemDesignIntf::PageS
|
||||
#else
|
||||
printer.setPageOrientation((QPageLayout::Orientation)m_page->pageOrientation());
|
||||
printer.setPageSize(QPageSize((QPageSize::PageSizeId)size));
|
||||
return QSizeF(printer.pageLayout().pageSize().size(QPageSize::Millimeter).width() * m_page->unitFactor(),
|
||||
printer.pageLayout().pageSize().size(QPageSize::Millimeter).height() * m_page->unitFactor());
|
||||
return QSizeF(printer.pageLayout().pageSize().size(QPageSize::Millimeter).width()
|
||||
* m_page->unitFactor(),
|
||||
printer.pageLayout().pageSize().size(QPageSize::Millimeter).height()
|
||||
* m_page->unitFactor());
|
||||
#endif
|
||||
} else {
|
||||
return QSizeF(m_page->getItemWidth(), m_page->getItemHeight());
|
||||
@ -84,16 +92,14 @@ QSizeF PageEditor::getRectByPageSize(const LimeReport::PageItemDesignIntf::PageS
|
||||
void PageEditor::on_format_currentIndexChanged(int index)
|
||||
{
|
||||
QPageSize ps = *new QPageSize();
|
||||
if(ui->format->currentText() != "Custom")
|
||||
{
|
||||
QSizeF pageSize = getRectByPageSize(static_cast<LimeReport::PageItemDesignIntf::PageSize>(index));
|
||||
if (ui->format->currentText() != "Custom") {
|
||||
QSizeF pageSize
|
||||
= getRectByPageSize(static_cast<LimeReport::PageItemDesignIntf::PageSize>(index));
|
||||
ui->width->setValue(pageSize.width() / m_page->unitFactor());
|
||||
ui->height->setValue(pageSize.height() / m_page->unitFactor());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void PageEditor::on_buttonBox_clicked(QAbstractButton* button)
|
||||
{
|
||||
switch (ui->buttonBox->buttonRole(button)) {
|
||||
@ -104,7 +110,6 @@ void PageEditor::on_buttonBox_clicked(QAbstractButton *button)
|
||||
applyChanges();
|
||||
accept();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace LimeReport
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user