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,19 +1,21 @@
|
||||
#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 <fcntl.h>
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
QApplication::setApplicationVersion(LIMEREPORT_VERSION_STR);
|
||||
@ -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);
|
||||
@ -39,47 +46,48 @@ int main(int argc, char *argv[])
|
||||
|
||||
LimeReport::ReportEngine report;
|
||||
|
||||
if (parser.value(sourceOption).isEmpty()){
|
||||
std::cerr<<"Error! Report file is not specified !! \n";
|
||||
if (parser.value(sourceOption).isEmpty()) {
|
||||
std::cerr << "Error! Report file is not specified !! \n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!report.loadFromFile(parser.value(sourceOption))){
|
||||
std::cerr<<"Error! Report file \""+parser.value(sourceOption).toStdString()+"\" not found \n";
|
||||
if (!report.loadFromFile(parser.value(sourceOption))) {
|
||||
std::cerr << "Error! Report file \"" + parser.value(sourceOption).toStdString()
|
||||
+ "\" not found \n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!parser.values(variablesOption).isEmpty()){
|
||||
foreach(QString var, parser.values(variablesOption)){
|
||||
if (!parser.values(variablesOption).isEmpty()) {
|
||||
foreach (QString var, parser.values(variablesOption)) {
|
||||
QStringList varItem = var.split("=");
|
||||
if (varItem.size() == 2)
|
||||
report.dataManager()->setReportVariable(varItem.at(0),varItem.at(1));
|
||||
report.dataManager()->setReportVariable(varItem.at(0), varItem.at(1));
|
||||
}
|
||||
}
|
||||
|
||||
if (parser.value(destinationOption).isEmpty()){
|
||||
if (parser.value(destinationOption).isEmpty()) {
|
||||
report.printToPDF(QFileInfo(parser.value(sourceOption)).baseName());
|
||||
} else {
|
||||
report.printToPDF(parser.value(destinationOption));
|
||||
}
|
||||
#else
|
||||
std::cerr<<"This demo intended for Qt 5.2 and higher\n";
|
||||
std::cerr << "This demo intended for Qt 5.2 and higher\n";
|
||||
#endif
|
||||
// QUuid uid = QUuid::createUuid();
|
||||
// QString uidStr = uid.toString()+".pdf";
|
||||
// report.printToPDF(uidStr);
|
||||
// QFile in(uidStr);
|
||||
// QFile out;
|
||||
// out.open(stdout, QFile::WriteOnly);
|
||||
// in.open(QIODevice::ReadOnly);
|
||||
//#ifdef _WIN32
|
||||
// _setmode(fileno(stdout),O_BINARY);
|
||||
//#endif
|
||||
// QByteArray buffer = in.readAll();
|
||||
// fwrite(buffer,1,buffer.size(),stdout);
|
||||
// in.close();
|
||||
// in.remove();
|
||||
// QUuid uid = QUuid::createUuid();
|
||||
// QString uidStr = uid.toString()+".pdf";
|
||||
// report.printToPDF(uidStr);
|
||||
// QFile in(uidStr);
|
||||
// QFile out;
|
||||
// out.open(stdout, QFile::WriteOnly);
|
||||
// in.open(QIODevice::ReadOnly);
|
||||
//#ifdef _WIN32
|
||||
// _setmode(fileno(stdout),O_BINARY);
|
||||
//#endif
|
||||
// QByteArray buffer = in.readAll();
|
||||
// fwrite(buffer,1,buffer.size(),stdout);
|
||||
// in.close();
|
||||
// in.remove();
|
||||
|
||||
return 0;
|
||||
//return a.exec();
|
||||
// return a.exec();
|
||||
}
|
||||
|
@ -28,10 +28,10 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
|
@ -29,85 +29,94 @@
|
||||
****************************************************************************/
|
||||
#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"
|
||||
#else
|
||||
# define EASY_BLOCK(...)
|
||||
# define EASY_END_BLOCK
|
||||
# define EASY_PROFILER_ENABLE
|
||||
#define EASY_BLOCK(...)
|
||||
#define EASY_END_BLOCK
|
||||
#define EASY_PROFILER_ENABLE
|
||||
#endif
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
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");
|
||||
if (dbFile.exists()){
|
||||
QFile dbFile(QApplication::applicationDirPath() + "/demo_reports/northwind.db");
|
||||
if (dbFile.exists()) {
|
||||
m_db = QSqlDatabase::addDatabase("QSQLITE");
|
||||
m_db.setDatabaseName(dbFile.fileName());
|
||||
if (m_db.open()){
|
||||
if (m_db.open()) {
|
||||
QSqlQueryModel* customersModel = new QSqlQueryModel();
|
||||
customersModel->setQuery("select * from customers", m_db);
|
||||
report->dataManager()->addModel("external_customers_data",customersModel,true);
|
||||
report->dataManager()->addModel("external_customers_data", customersModel, true);
|
||||
QSqlQueryModel* ordersModel = new QSqlQueryModel();
|
||||
ordersModel->setQuery("Select * from orders",m_db);
|
||||
report->dataManager()->addModel("external_orders_data",ordersModel,true);
|
||||
m_customers = new QSqlQuery("Select * from customers limit 10",m_db);
|
||||
ordersModel->setQuery("Select * from orders", m_db);
|
||||
report->dataManager()->addModel("external_orders_data", ordersModel, true);
|
||||
m_customers = new QSqlQuery("Select * from customers limit 10", m_db);
|
||||
m_customers->first();
|
||||
m_orders = new QSqlQuery(m_db);
|
||||
m_orders->prepare("Select * from orders where CustomerID = :id");
|
||||
int index = m_customers->record().indexOf("CustomerID");
|
||||
m_orders->bindValue(":id",m_customers->value(index));
|
||||
m_orders->bindValue(":id", m_customers->value(index));
|
||||
m_orders->exec();
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
report->dataManager()->addModel("string_list", stringListModel, true);
|
||||
QStringList strList;
|
||||
strList<<"value1"<<"value2";
|
||||
//QScriptValue value = qScriptValueFromSequence(report->scriptManager()->scriptEngine(),strList);
|
||||
//report->scriptManager()->scriptEngine()->globalObject().setProperty("test_list",value);
|
||||
|
||||
|
||||
strList << "value1"
|
||||
<< "value2";
|
||||
// QScriptValue value =
|
||||
// qScriptValueFromSequence(report->scriptManager()->scriptEngine(),strList);
|
||||
// report->scriptManager()->scriptEngine()->globalObject().setProperty("test_list",value);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
@ -122,8 +131,9 @@ void MainWindow::on_pushButton_clicked()
|
||||
EASY_PROFILER_ENABLE;
|
||||
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());
|
||||
if (!ui->leVariableName->text().isEmpty() && !ui->leVariableValue->text().isEmpty()) {
|
||||
report->dataManager()->setReportVariable(ui->leVariableName->text(),
|
||||
ui->leVariableValue->text());
|
||||
}
|
||||
report->setShowProgressDialog(false);
|
||||
report->designReport();
|
||||
@ -135,27 +145,30 @@ 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");
|
||||
report->loadFromFile(fileName);
|
||||
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());
|
||||
if (!ui->leVariableName->text().isEmpty() && !ui->leVariableValue->text().isEmpty()) {
|
||||
report->dataManager()->setReportVariable(ui->leVariableName->text(),
|
||||
ui->leVariableValue->text());
|
||||
}
|
||||
EASY_END_BLOCK;
|
||||
#ifdef BUILD_WITH_EASY_PROFILER
|
||||
profiler::dumpBlocksToFile("test.prof");
|
||||
#endif
|
||||
// QPrinter* printer = new QPrinter;
|
||||
// QPrintDialog dialog(printer);
|
||||
// if (dialog.exec()){
|
||||
// QMap<QString, QPrinter*> printers;
|
||||
// printers.insert("default",printer);
|
||||
// report->printReport(printers);
|
||||
// }
|
||||
// QPrinter* printer = new QPrinter;
|
||||
// QPrintDialog dialog(printer);
|
||||
// if (dialog.exec()){
|
||||
// QMap<QString, QPrinter*> printers;
|
||||
// printers.insert("default",printer);
|
||||
// report->printReport(printers);
|
||||
// }
|
||||
report->setShowProgressDialog(true);
|
||||
report->previewReport();
|
||||
}
|
||||
@ -163,10 +176,10 @@ void MainWindow::on_pushButton_2_clicked()
|
||||
|
||||
void MainWindow::renderStarted()
|
||||
{
|
||||
if (report->isShowProgressDialog()){
|
||||
if (report->isShowProgressDialog()) {
|
||||
m_currentPage = 0;
|
||||
m_progressDialog = new QProgressDialog(tr("Start render"),tr("Cancel"),0,0,this);
|
||||
//m_progressDialog->setWindowModality(Qt::WindowModal);
|
||||
m_progressDialog = new QProgressDialog(tr("Start render"), tr("Cancel"), 0, 0, this);
|
||||
// m_progressDialog->setWindowModality(Qt::WindowModal);
|
||||
connect(m_progressDialog, SIGNAL(canceled()), report, SLOT(cancelRender()));
|
||||
QApplication::processEvents();
|
||||
m_progressDialog->show();
|
||||
@ -175,22 +188,22 @@ void MainWindow::renderStarted()
|
||||
|
||||
void MainWindow::renderPageFinished(int renderedPageCount)
|
||||
{
|
||||
if (m_progressDialog){
|
||||
m_progressDialog->setLabelText(QString::number(renderedPageCount)+tr(" page rendered"));
|
||||
if (m_progressDialog) {
|
||||
m_progressDialog->setLabelText(QString::number(renderedPageCount) + tr(" page rendered"));
|
||||
m_progressDialog->setValue(renderedPageCount);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::renderFinished()
|
||||
{
|
||||
if (m_progressDialog){
|
||||
if (m_progressDialog) {
|
||||
m_progressDialog->close();
|
||||
delete m_progressDialog;
|
||||
}
|
||||
m_progressDialog = 0;
|
||||
}
|
||||
|
||||
void MainWindow::prepareData(QSqlQuery* ds, LimeReport::CallbackInfo info, QVariant &data)
|
||||
void MainWindow::prepareData(QSqlQuery* ds, LimeReport::CallbackInfo info, QVariant& data)
|
||||
{
|
||||
switch (info.dataType) {
|
||||
case LimeReport::CallbackInfo::ColumnCount:
|
||||
@ -210,46 +223,59 @@ 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)
|
||||
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)
|
||||
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 (result){
|
||||
m_orders->bindValue(":id",m_customers->value(m_customers->record().indexOf("CustomerID")));
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::slotGetCallbackChildData(LimeReport::CallbackInfo info, QVariant &data)
|
||||
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)
|
||||
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;
|
||||
@ -257,9 +283,9 @@ void MainWindow::slotOneSlotDS(LimeReport::CallbackInfo info, QVariant &data)
|
||||
case LimeReport::CallbackInfo::ColumnCount:
|
||||
data = columns.size();
|
||||
break;
|
||||
// case LimeReport::CallbackInfo::IsEmpty:
|
||||
// data = false;
|
||||
// break;
|
||||
// case LimeReport::CallbackInfo::IsEmpty:
|
||||
// data = false;
|
||||
// break;
|
||||
case LimeReport::CallbackInfo::ColumnHeaderData: {
|
||||
data = columns.at(info.index);
|
||||
break;
|
||||
@ -268,9 +294,10 @@ void MainWindow::slotOneSlotDS(LimeReport::CallbackInfo info, QVariant &data)
|
||||
if (info.columnName == "Image")
|
||||
data = QImage(":/report//images/logo32");
|
||||
else {
|
||||
data = info.columnName+" "+QString::number(info.index);
|
||||
data = info.columnName + " " + QString::number(info.index);
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -30,22 +30,22 @@
|
||||
#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:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
explicit MainWindow(QWidget* parent = 0);
|
||||
~MainWindow();
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
@ -58,11 +58,13 @@ 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);
|
||||
void prepareData(QSqlQuery* ds, LimeReport::CallbackInfo info, QVariant& data);
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
LimeReport::ReportEngine *report;
|
||||
Ui::MainWindow* ui;
|
||||
LimeReport::ReportEngine* report;
|
||||
QProgressDialog* m_progressDialog;
|
||||
int m_currentPage;
|
||||
QSqlDatabase m_db;
|
||||
@ -73,9 +75,6 @@ private:
|
||||
int m_currentOrderRecord;
|
||||
QSqlQuery* m_customers;
|
||||
QSqlQuery* m_orders;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
@ -1,7 +1,8 @@
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
QApplication a(argc, 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);
|
||||
|
||||
@ -20,20 +19,22 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
m_pageNavigator = new QSpinBox(this);
|
||||
|
||||
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)));
|
||||
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_pageNavigator, SIGNAL(valueChanged(int)), this, SLOT(slotPageNavigatorChanged(int)));
|
||||
ui->groupBox_2->layout()->addWidget(m_preview);
|
||||
buildReportsTree(QApplication::applicationDirPath()+"/demo_reports/", ui->treeWidget);
|
||||
buildReportsTree(QApplication::applicationDirPath() + "/demo_reports/", ui->treeWidget);
|
||||
connect(ui->actionZoomIn, SIGNAL(triggered()), m_preview, SLOT(zoomIn()));
|
||||
connect(ui->actionZoom_Out, SIGNAL(triggered()), m_preview, SLOT(zoomOut()));
|
||||
connect(ui->actionFirst_Page, SIGNAL(triggered()), m_preview, SLOT(firstPage()));
|
||||
connect(ui->actionPrior_Page, SIGNAL(triggered()), m_preview, SLOT(priorPage()));
|
||||
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(m_preview, SIGNAL(scalePercentChanged(int)), this, SLOT(slotScalePercentChanged(int)));
|
||||
// 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)));
|
||||
@ -45,44 +46,40 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
initPercentCombobox();
|
||||
enableUI(false);
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
QDesktopWidget* desktop = QApplication::desktop();
|
||||
|
||||
int screenWidth = desktop->screenGeometry().width();
|
||||
int screenHeight = desktop->screenGeometry().height();
|
||||
#else
|
||||
QScreen *screen = QGuiApplication::primaryScreen();
|
||||
QScreen* screen = QGuiApplication::primaryScreen();
|
||||
|
||||
int screenWidth = screen->geometry().width();
|
||||
int screenHeight = screen->geometry().height();
|
||||
#endif
|
||||
|
||||
int x = screenWidth*0.1;
|
||||
int y = screenHeight*0.1;
|
||||
int x = screenWidth * 0.1;
|
||||
int y = screenHeight * 0.1;
|
||||
|
||||
resize(screenWidth*0.8, screenHeight*0.8);
|
||||
resize(screenWidth * 0.8, screenHeight * 0.8);
|
||||
move(x, y);
|
||||
|
||||
if (ui->treeWidget->topLevelItemCount()>0){
|
||||
if (ui->treeWidget->topLevelItemCount() > 0) {
|
||||
int index = 0;
|
||||
while (index<ui->treeWidget->topLevelItemCount()){
|
||||
if (ui->treeWidget->topLevelItem(index)->childCount()>0)
|
||||
while (index < ui->treeWidget->topLevelItemCount()) {
|
||||
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)
|
||||
{
|
||||
@ -104,21 +101,21 @@ void MainWindow::enableUI(bool value)
|
||||
|
||||
void MainWindow::slotScalePercentChanged(int percent)
|
||||
{
|
||||
//ui->cbScalePercent->setEditText(QString("%1%").arg(percent));
|
||||
// ui->cbScalePercent->setEditText(QString("%1%").arg(percent));
|
||||
m_scalePercent->setEditText(QString("%1%").arg(percent));
|
||||
}
|
||||
|
||||
void MainWindow::scaleComboboxChanged(QString text)
|
||||
{
|
||||
m_preview->setScalePercent(text.remove(text.count()-1,1).toInt());
|
||||
m_preview->setScalePercent(text.remove(text.count() - 1, 1).toInt());
|
||||
}
|
||||
|
||||
void MainWindow::slotPagesSet(int pagesCount)
|
||||
{
|
||||
// ui->sbPageNavigator->setSuffix(tr(" of %1").arg(pagesCount));
|
||||
// ui->sbPageNavigator->setMinimum(1);
|
||||
// ui->sbPageNavigator->setMaximum(pagesCount);
|
||||
// ui->sbPageNavigator->setValue(1);
|
||||
// ui->sbPageNavigator->setSuffix(tr(" of %1").arg(pagesCount));
|
||||
// ui->sbPageNavigator->setMinimum(1);
|
||||
// ui->sbPageNavigator->setMaximum(pagesCount);
|
||||
// ui->sbPageNavigator->setValue(1);
|
||||
|
||||
m_pageNavigator->setSuffix(tr(" of %1").arg(pagesCount));
|
||||
m_pageNavigator->setMinimum(1);
|
||||
@ -127,35 +124,29 @@ 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 )
|
||||
void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem* item, int)
|
||||
{
|
||||
if (!m_report.isBusy()){
|
||||
m_report.loadFromFile(item->data(0,Qt::UserRole).toString());
|
||||
if (!m_report.isBusy()) {
|
||||
m_report.loadFromFile(item->data(0, Qt::UserRole).toString());
|
||||
m_preview->refreshPages();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::initPercentCombobox()
|
||||
{
|
||||
for (int i = 10; i<310; i+=10){
|
||||
// ui->cbScalePercent->addItem(QString("%1%").arg(i));
|
||||
for (int i = 10; i < 310; i += 10) {
|
||||
// ui->cbScalePercent->addItem(QString("%1%").arg(i));
|
||||
m_scalePercent->addItem(QString("%1%").arg(i));
|
||||
}
|
||||
// ui->cbScalePercent->setCurrentIndex(4);
|
||||
// ui->cbScalePercent->setCurrentIndex(4);
|
||||
m_scalePercent->setCurrentIndex(4);
|
||||
}
|
||||
|
||||
//void MainWindow::on_sbPageNavigator_valueChanged(int arg1)
|
||||
// void MainWindow::on_sbPageNavigator_valueChanged(int arg1)
|
||||
//{
|
||||
// m_preview->pageNavigatorChanged(arg1);
|
||||
//}
|
||||
@ -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);
|
||||
explicit MainWindow(QWidget* parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
private:
|
||||
void enableUI(bool value);
|
||||
private slots:
|
||||
@ -28,35 +29,36 @@ private slots:
|
||||
void slotPagesSet(int pagesCount);
|
||||
void slotPageChanged(int page);
|
||||
void slotPageNavigatorChanged(int page);
|
||||
void on_treeWidget_itemClicked(QTreeWidgetItem *item, int);
|
||||
//void on_sbPageNavigator_valueChanged(int arg1);
|
||||
void on_treeWidget_itemClicked(QTreeWidgetItem* item, int);
|
||||
// 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);
|
||||
foreach( QString dir, items){
|
||||
foreach (QString dir, items) {
|
||||
QTreeWidgetItem* listItem = new QTreeWidgetItem(parentItem);
|
||||
listItem->setText(0,dir);
|
||||
listItem->setIcon(0,QIcon(":/images/images/folder.png"));
|
||||
buildReportsTree(reportsDir.path()+"/"+dir, listItem);
|
||||
listItem->setText(0, dir);
|
||||
listItem->setIcon(0, QIcon(":/images/images/folder.png"));
|
||||
buildReportsTree(reportsDir.path() + "/" + dir, listItem);
|
||||
}
|
||||
QStringList nameFilters;
|
||||
nameFilters <<"*.lrxml";
|
||||
nameFilters << "*.lrxml";
|
||||
items = reportsDir.entryList(nameFilters, QDir::Files);
|
||||
foreach( QString file, items){
|
||||
foreach (QString file, items) {
|
||||
QTreeWidgetItem* listItem = new QTreeWidgetItem(parentItem);
|
||||
listItem->setIcon(0,QIcon(":/images/images/report.png"));
|
||||
listItem->setText(0,file);
|
||||
listItem->setData(0,Qt::UserRole,reportsDir.path()+"/"+file);
|
||||
listItem->setIcon(0, QIcon(":/images/images/report.png"));
|
||||
listItem->setText(0, file);
|
||||
listItem->setData(0, Qt::UserRole, reportsDir.path() + "/" + file);
|
||||
}
|
||||
}
|
||||
void initPercentCombobox();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
Ui::MainWindow* ui;
|
||||
LimeReport::ReportEngine m_report;
|
||||
LimeReport::PreviewReportWidget* m_preview;
|
||||
QComboBox* m_scalePercent;
|
||||
|
@ -1,21 +1,19 @@
|
||||
#include "designersettingmanager.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
DesignerSettingManager::DesignerSettingManager(QObject *parent) : QObject(parent)
|
||||
DesignerSettingManager::DesignerSettingManager(QObject* parent): QObject(parent)
|
||||
{
|
||||
m_setting = new QSettings("LimeReport",QCoreApplication::applicationName());
|
||||
m_setting = new QSettings("LimeReport", QCoreApplication::applicationName());
|
||||
}
|
||||
|
||||
DesignerSettingManager::~DesignerSettingManager()
|
||||
{
|
||||
delete m_setting;
|
||||
}
|
||||
DesignerSettingManager::~DesignerSettingManager() { delete m_setting; }
|
||||
|
||||
void DesignerSettingManager::getAvailableLanguages(QList<QLocale::Language>* languages)
|
||||
{
|
||||
languages->append(QLocale::Russian);
|
||||
languages->append(QLocale::English);
|
||||
// languages->append(QLocale::Arabic);
|
||||
// languages->append(QLocale::Arabic);
|
||||
languages->append(QLocale::French);
|
||||
languages->append(QLocale::Chinese);
|
||||
languages->append(QLocale::Spanish);
|
||||
@ -27,8 +25,8 @@ QLocale::Language DesignerSettingManager::getCurrentDefaultLanguage()
|
||||
m_setting->beginGroup("ReportDesigner");
|
||||
QVariant v = m_setting->value("DesignerLanguage");
|
||||
m_setting->endGroup();
|
||||
if (v.isValid()){
|
||||
return static_cast<QLocale::Language>(v.toInt()) ;
|
||||
if (v.isValid()) {
|
||||
return static_cast<QLocale::Language>(v.toInt());
|
||||
} else {
|
||||
return QLocale::system().language();
|
||||
}
|
||||
@ -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,21 +1,21 @@
|
||||
#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);
|
||||
explicit DesignerSettingManager(QObject* parent = 0);
|
||||
~DesignerSettingManager();
|
||||
public slots:
|
||||
void getAvailableLanguages(QList<QLocale::Language>* languages);
|
||||
QLocale::Language getCurrentDefaultLanguage();
|
||||
void currentDefaultLanguageChanged(QLocale::Language language);
|
||||
|
||||
private:
|
||||
QSettings* m_setting;
|
||||
};
|
||||
|
@ -1,10 +1,12 @@
|
||||
#include <QApplication>
|
||||
#include <LimeReport>
|
||||
#include <QTranslator>
|
||||
#include <QDebug>
|
||||
#include "designersettingmanager.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QTranslator>
|
||||
|
||||
#include <LimeReport>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
|
||||
@ -21,29 +23,31 @@ int main(int argc, char *argv[])
|
||||
|
||||
QString designerTranslation = QLocale(manager.getCurrentDefaultLanguage()).name();
|
||||
|
||||
if (limeReportTranslator.load("limereport_"+designerTranslation, translationPath)){
|
||||
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);
|
||||
}
|
||||
|
||||
LimeReport::ReportEngine report;
|
||||
report.setPreviewLayoutDirection(layoutDirection);
|
||||
|
||||
if (a.arguments().count()>1){
|
||||
if (a.arguments().count() > 1) {
|
||||
report.loadFromFile(a.arguments().at(1));
|
||||
}
|
||||
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,18 +2,21 @@
|
||||
#define LRDESIGNERPLUGIN_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
#include <lrdesignerplugininterface.h>
|
||||
|
||||
class ReportDesignerFactoryPlugin : public QObject, public LimeReportDesignerPluginInterface {
|
||||
class ReportDesignerFactoryPlugin: public QObject, public LimeReportDesignerPluginInterface {
|
||||
Q_OBJECT
|
||||
#if QT_VERSION >= 0x050000
|
||||
Q_PLUGIN_METADATA(IID "ru.limereport.DersignerFactoryInterface")
|
||||
#endif
|
||||
Q_INTERFACES( LimeReportDesignerPluginInterface )
|
||||
Q_INTERFACES(LimeReportDesignerPluginInterface)
|
||||
|
||||
public:
|
||||
~ReportDesignerFactoryPlugin();
|
||||
LimeReport::ReportDesignWindowInterface* getDesignerWindow(LimeReport::ReportEnginePrivateInterface* report, QWidget* parent, QSettings* settings);
|
||||
LimeReport::ReportDesignWindowInterface*
|
||||
getDesignerWindow(LimeReport::ReportEnginePrivateInterface* report, QWidget* parent,
|
||||
QSettings* settings);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -3,22 +3,31 @@
|
||||
#include <QObject>
|
||||
namespace LimeReport {
|
||||
|
||||
struct CallbackInfo{
|
||||
enum DataType{IsEmpty, HasNext, ColumnHeaderData, ColumnData, ColumnCount, RowCount};
|
||||
enum ChangePosType{First, Next};
|
||||
struct CallbackInfo {
|
||||
enum DataType {
|
||||
IsEmpty,
|
||||
HasNext,
|
||||
ColumnHeaderData,
|
||||
ColumnData,
|
||||
ColumnCount,
|
||||
RowCount
|
||||
};
|
||||
enum ChangePosType {
|
||||
First,
|
||||
Next
|
||||
};
|
||||
DataType dataType;
|
||||
int index;
|
||||
QString columnName;
|
||||
};
|
||||
|
||||
class ICallbackDatasource :public QObject{
|
||||
class ICallbackDatasource: public QObject {
|
||||
Q_OBJECT
|
||||
signals:
|
||||
void getCallbackData(const LimeReport::CallbackInfo& info, QVariant& data);
|
||||
void changePos(const LimeReport::CallbackInfo::ChangePosType& type, bool& result);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRVIRTUALDATASOURCEINTF
|
||||
|
||||
|
@ -1,14 +1,17 @@
|
||||
#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 ~IDataSource() { }
|
||||
virtual bool next() = 0;
|
||||
virtual bool hasNext() = 0;
|
||||
virtual bool prior() = 0;
|
||||
@ -18,12 +21,16 @@ public:
|
||||
virtual bool eof() = 0;
|
||||
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, 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 int columnCount() = 0;
|
||||
virtual QString columnNameByIndex(int columnIndex) = 0;
|
||||
virtual QVariant headerData(const QString &columnName, const QString &roleName) = 0;
|
||||
virtual QVariant headerData(const QString& columnName, const QString& roleName) = 0;
|
||||
virtual int columnIndexByName(QString name) = 0;
|
||||
virtual bool isInvalid() const = 0;
|
||||
virtual QString lastError() = 0;
|
||||
@ -32,8 +39,9 @@ public:
|
||||
|
||||
class IDataSourceHolder {
|
||||
public:
|
||||
virtual ~IDataSourceHolder(){}
|
||||
virtual IDataSource* dataSource(IDataSource::DatasourceMode mode = IDataSource::RENDER_MODE) = 0;
|
||||
virtual ~IDataSourceHolder() { }
|
||||
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,34 +31,36 @@
|
||||
#define LRDATASOURCEMANAGERINTF_H
|
||||
|
||||
#include "lrcallbackdatasourceintf.h"
|
||||
#include "lrglobal.h"
|
||||
#include "lrdatasourceintf.h"
|
||||
#include "lrglobal.h"
|
||||
|
||||
class QVariant;
|
||||
class QString;
|
||||
class QAbstractItemModel;
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class IDbCredentialsProvider{
|
||||
class IDbCredentialsProvider {
|
||||
public:
|
||||
virtual ~IDbCredentialsProvider(){}
|
||||
virtual ~IDbCredentialsProvider() { }
|
||||
virtual QString getUserName(const QString& connectionName) = 0;
|
||||
virtual QString getPassword(const QString& connectionName) = 0;
|
||||
};
|
||||
|
||||
class IDataSourceManager{
|
||||
class IDataSourceManager {
|
||||
public:
|
||||
virtual ~IDataSourceManager(){}
|
||||
virtual ~IDataSourceManager() { }
|
||||
virtual void setReportVariable(const QString& name, const QVariant& value) = 0;
|
||||
virtual void setDefaultDatabasePath(const QString &defaultDatabasePath) = 0;
|
||||
virtual void setDefaultDatabasePath(const QString& defaultDatabasePath) = 0;
|
||||
virtual void deleteVariable(const QString& name) = 0;
|
||||
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 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 removeModel(const QString& name) = 0;
|
||||
virtual bool containsDatasource(const QString& dataSourceName) = 0;
|
||||
virtual void clearUserVariables()=0;
|
||||
virtual void clearUserVariables() = 0;
|
||||
virtual ICallbackDatasource* createCallbackDatasource(const QString& name) = 0;
|
||||
virtual void registerDbCredentialsProvider(IDbCredentialsProvider* provider) = 0;
|
||||
virtual QStringList variableNames() = 0;
|
||||
@ -69,6 +71,5 @@ public:
|
||||
virtual IDataSourceHolder* dataSourceHolder(const QString& name) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRDATASOURCEMANAGERINTF_H
|
||||
|
||||
|
@ -27,18 +27,21 @@
|
||||
* 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;
|
||||
return className.right(className.length()-startPos);
|
||||
int startPos = className.lastIndexOf("::");
|
||||
if (startPos == -1)
|
||||
startPos = 0;
|
||||
else
|
||||
startPos += 2;
|
||||
return className.right(className.length() - startPos);
|
||||
}
|
||||
|
||||
bool ReportSettings::suppressAbsentFieldsAndVarsWarnings() const
|
||||
@ -46,31 +49,34 @@ bool ReportSettings::suppressAbsentFieldsAndVarsWarnings() const
|
||||
return m_suppressAbsentFieldsAndVarsWarnings;
|
||||
}
|
||||
|
||||
void ReportSettings::setSuppressAbsentFieldsAndVarsWarnings(bool suppressAbsentFieldsAndVarsWarnings)
|
||||
void ReportSettings::setSuppressAbsentFieldsAndVarsWarnings(
|
||||
bool suppressAbsentFieldsAndVarsWarnings)
|
||||
{
|
||||
m_suppressAbsentFieldsAndVarsWarnings = suppressAbsentFieldsAndVarsWarnings;
|
||||
}
|
||||
|
||||
QString escapeSimbols(const QString &value)
|
||||
QString escapeSimbols(const QString& value)
|
||||
{
|
||||
QString result = value;
|
||||
result.replace("\"","\\\"");
|
||||
result.replace('\n',"\\n");
|
||||
result.replace("\"", "\\\"");
|
||||
result.replace('\n', "\\n");
|
||||
return result;
|
||||
}
|
||||
|
||||
QString replaceHTMLSymbols(const QString &value)
|
||||
QString replaceHTMLSymbols(const QString& value)
|
||||
{
|
||||
QString result = value;
|
||||
result.replace("<","<");
|
||||
result.replace(">",">");
|
||||
result.replace("<", "<");
|
||||
result.replace(">", ">");
|
||||
return result;
|
||||
}
|
||||
|
||||
#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,13 +86,14 @@ QVector<QString> normalizeCaptures(const QRegularExpressionMatch ®){
|
||||
return result;
|
||||
}
|
||||
|
||||
bool isColorDark(QColor color){
|
||||
qreal darkness = 1-(0.299*color.red() + 0.587*color.green() + 0.114*color.blue())/255;
|
||||
if(darkness<0.5){
|
||||
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;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
@ -30,23 +30,25 @@
|
||||
#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)
|
||||
# define LIMEREPORT_EXPORT Q_DECL_IMPORT
|
||||
#define LIMEREPORT_EXPORT Q_DECL_EXPORT
|
||||
#elif defined(LIMEREPORT_IMPORTS)
|
||||
#define LIMEREPORT_EXPORT Q_DECL_IMPORT
|
||||
#else
|
||||
# define LIMEREPORT_EXPORT /**/
|
||||
#define LIMEREPORT_EXPORT /**/
|
||||
#endif
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define VARIABLE_IS_NOT_USED __attribute__ ((unused))
|
||||
#define VARIABLE_IS_NOT_USED __attribute__((unused))
|
||||
#else
|
||||
#define VARIABLE_IS_NOT_USED
|
||||
#endif
|
||||
@ -55,12 +57,12 @@ namespace LimeReport {
|
||||
Q_NAMESPACE
|
||||
#endif
|
||||
|
||||
namespace Const{
|
||||
namespace Const {
|
||||
int const DEFAULT_GRID_STEP = 1;
|
||||
int const RESIZE_HANDLE_SIZE = 5;
|
||||
int const SELECTION_PEN_SIZE = 1;
|
||||
int const MINIMUM_ITEM_WIDTH = 2*RESIZE_HANDLE_SIZE;
|
||||
int const MINIMUM_ITEM_HEIGHT = 2*RESIZE_HANDLE_SIZE;
|
||||
int const MINIMUM_ITEM_WIDTH = 2 * RESIZE_HANDLE_SIZE;
|
||||
int const MINIMUM_ITEM_HEIGHT = 2 * RESIZE_HANDLE_SIZE;
|
||||
double const RESIZE_ZONE_OPACITY = 0.5;
|
||||
double const SELECTED_RESIZE_ZONE_OPACITY = 0.6;
|
||||
Qt::GlobalColor const RESIZE_ZONE_COLOR = Qt::green;
|
||||
@ -80,15 +82,21 @@ 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;
|
||||
|
||||
const QString GROUP_FUNCTION_RX = "(%1\\s*"+GROUP_FUNCTION_PARAM_RX+")";
|
||||
const QString GROUP_FUNCTION_RX = "(%1\\s*" + GROUP_FUNCTION_PARAM_RX + ")";
|
||||
const QString GROUP_FUNCTION_NAME_RX = "%1\\s*\\((.*[^\\)])\\)";
|
||||
const int SCENE_MARGIN = 50;
|
||||
const QString FUNCTION_MANAGER_NAME = "LimeReport";
|
||||
@ -100,104 +108,135 @@ namespace Const{
|
||||
const char SCRIPT_SIGN = 'S';
|
||||
const char FIELD_SIGN = 'D';
|
||||
const char VARIABLE_SIGN = 'V';
|
||||
}
|
||||
QString extractClassName(QString className);
|
||||
QString escapeSimbols(const QString& value);
|
||||
QString replaceHTMLSymbols(const QString &value);
|
||||
} // namespace Const
|
||||
QString extractClassName(QString className);
|
||||
QString escapeSimbols(const QString& value);
|
||||
QString replaceHTMLSymbols(const QString& value);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1)
|
||||
QVector<QString> normalizeCaptures(const QRegularExpressionMatch ®);
|
||||
QVector<QString> normalizeCaptures(const QRegularExpressionMatch& reg);
|
||||
#else
|
||||
QVector<QString> normalizeCaptures(const QRegExp ®);
|
||||
QVector<QString> normalizeCaptures(const QRegExp& reg);
|
||||
#endif
|
||||
bool isColorDark(QColor color);
|
||||
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)
|
||||
Q_DECLARE_FLAGS(PreviewHints, PreviewHint)
|
||||
Q_FLAGS(PreviewHints)
|
||||
|
||||
class LIMEREPORT_EXPORT ReportError : public std::runtime_error{
|
||||
public:
|
||||
class LIMEREPORT_EXPORT ReportError: public std::runtime_error {
|
||||
public:
|
||||
ReportError(const QString& message);
|
||||
};
|
||||
};
|
||||
|
||||
class LIMEREPORT_EXPORT ReportSettings{
|
||||
public:
|
||||
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){}
|
||||
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:
|
||||
|
||||
private:
|
||||
bool m_suppressAbsentFieldsAndVarsWarnings;
|
||||
int m_baseItemPadding;
|
||||
};
|
||||
};
|
||||
|
||||
class LIMEREPORT_EXPORT IExternalPainter{
|
||||
public:
|
||||
virtual void paintByExternalPainter(const QString& objectName, QPainter* painter, const QStyleOptionGraphicsItem* options) = 0;
|
||||
class LIMEREPORT_EXPORT IExternalPainter {
|
||||
public:
|
||||
virtual void paintByExternalPainter(const QString& objectName, QPainter* painter,
|
||||
const QStyleOptionGraphicsItem* options)
|
||||
= 0;
|
||||
virtual ~IExternalPainter();
|
||||
};
|
||||
};
|
||||
|
||||
class LIMEREPORT_EXPORT IPainterProxy{
|
||||
public:
|
||||
class LIMEREPORT_EXPORT IPainterProxy {
|
||||
public:
|
||||
virtual void setExternalPainter(IExternalPainter* externalPainter) = 0;
|
||||
virtual ~IPainterProxy();
|
||||
};
|
||||
};
|
||||
|
||||
#if QT_VERSION < 0x050000
|
||||
typedef QStyleOptionViewItemV4 StyleOptionViewItem;
|
||||
typedef QStyleOptionViewItemV4 StyleOptionViewItem;
|
||||
#else
|
||||
typedef QStyleOptionViewItem StyleOptionViewItem;
|
||||
typedef QStyleOptionViewItem StyleOptionViewItem;
|
||||
#endif
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1)
|
||||
QRegularExpression getRegEx(QString expression);
|
||||
QRegularExpression getVariableRegEx();
|
||||
QRegularExpression getFieldRegEx();
|
||||
QRegularExpression getScriptRegEx();
|
||||
QRegularExpression getGroupFunctionRegEx(QString functionName);
|
||||
QRegularExpression getGroupFunctionNameRegEx(QString functionName);
|
||||
QRegularExpression getNamedVariableRegEx(QString variableName);
|
||||
QRegularExpression getRegEx(QString expression);
|
||||
QRegularExpression getVariableRegEx();
|
||||
QRegularExpression getFieldRegEx();
|
||||
QRegularExpression getScriptRegEx();
|
||||
QRegularExpression getGroupFunctionRegEx(QString functionName);
|
||||
QRegularExpression getGroupFunctionNameRegEx(QString functionName);
|
||||
QRegularExpression getNamedVariableRegEx(QString variableName);
|
||||
#endif
|
||||
|
||||
|
||||
class LIMEREPORT_EXPORT Enums
|
||||
{
|
||||
public:
|
||||
enum VariableDataType {Undefined, String, Bool, Int, Real, Date, Time, DateTime};
|
||||
class LIMEREPORT_EXPORT Enums {
|
||||
public:
|
||||
enum VariableDataType {
|
||||
Undefined,
|
||||
String,
|
||||
Bool,
|
||||
Int,
|
||||
Real,
|
||||
Date,
|
||||
Time,
|
||||
DateTime
|
||||
};
|
||||
#if QT_VERSION >= 0x050500
|
||||
Q_ENUM(VariableDataType)
|
||||
#else
|
||||
Q_ENUMS(VariableDataType)
|
||||
#endif
|
||||
private:
|
||||
Enums(){}
|
||||
private:
|
||||
Enums() { }
|
||||
Q_GADGET
|
||||
};
|
||||
};
|
||||
|
||||
typedef Enums::VariableDataType VariableDataType;
|
||||
typedef Enums::VariableDataType VariableDataType;
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
|
@ -2,9 +2,9 @@
|
||||
#define LRPREPAREDPAGESINTF_H
|
||||
#include "lrglobal.h"
|
||||
namespace LimeReport {
|
||||
class LIMEREPORT_EXPORT IPreparedPages{
|
||||
class LIMEREPORT_EXPORT IPreparedPages {
|
||||
public:
|
||||
virtual ~IPreparedPages(){};
|
||||
virtual ~IPreparedPages() {};
|
||||
virtual bool loadFromFile(const QString& fileName) = 0;
|
||||
virtual bool loadFromString(const QString data) = 0;
|
||||
virtual bool loadFromByteArray(QByteArray* data) = 0;
|
||||
@ -13,5 +13,5 @@ public:
|
||||
virtual QByteArray saveToByteArray() = 0;
|
||||
virtual void clear() = 0;
|
||||
};
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
#endif // LRPREPAREDPAGESINTF_H
|
||||
|
@ -1,16 +1,17 @@
|
||||
#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 {
|
||||
class PreviewReportWidget;
|
||||
class PreviewReportWidget;
|
||||
}
|
||||
|
||||
class PreviewReportWidgetPrivate;
|
||||
@ -18,29 +19,30 @@ 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);
|
||||
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);
|
||||
void setScaleType(const ScaleType& scaleType, int percent = 0);
|
||||
void setPreviewPageBackgroundColor(QColor color);
|
||||
QColor previewPageBackgroundColor();
|
||||
QPrinter *defaultPrinter() const;
|
||||
void setDefaultPrinter(QPrinter *defaultPrinter);
|
||||
QPrinter* defaultPrinter() const;
|
||||
void setDefaultPrinter(QPrinter* defaultPrinter);
|
||||
void startInsertTextItem();
|
||||
void activateItemSelectionMode();
|
||||
void deleteSelectedItems();
|
||||
void activateCurrentPage();
|
||||
void resize(ScaleType scaleType, int percent=0);
|
||||
void resize(ScaleType scaleType, int percent = 0);
|
||||
|
||||
public slots:
|
||||
void refreshPages();
|
||||
@ -59,8 +61,9 @@ public slots:
|
||||
void setScalePercent(int percent);
|
||||
void fitWidth();
|
||||
void fitPage();
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *);
|
||||
void resizeEvent(QResizeEvent*);
|
||||
signals:
|
||||
void pageChanged(int page);
|
||||
void scalePercentChanged(int percent);
|
||||
@ -72,20 +75,22 @@ private slots:
|
||||
void reportEngineDestroyed(QObject* object);
|
||||
void slotZoomed(double);
|
||||
void resizeDone();
|
||||
|
||||
private:
|
||||
void initPreview();
|
||||
void setErrorsMesagesVisible(bool visible);
|
||||
void setErrorMessages(const QStringList &value);
|
||||
void setErrorMessages(const QStringList& value);
|
||||
void emitPageSet();
|
||||
|
||||
private:
|
||||
Ui::PreviewReportWidget *ui;
|
||||
Ui::PreviewReportWidget* ui;
|
||||
PreviewReportWidgetPrivate* d_ptr;
|
||||
ScaleType m_scaleType;
|
||||
int m_scalePercent;
|
||||
QTimer m_resizeTimer;
|
||||
QColor m_previewPageBackgroundColor;
|
||||
QPrinter* m_defaultPrinter;
|
||||
void printPages(QPrinter *printer);
|
||||
void printPages(QPrinter* printer);
|
||||
bool m_scaleChanging;
|
||||
};
|
||||
|
||||
|
@ -1,26 +1,28 @@
|
||||
#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"
|
||||
|
||||
namespace LimeReport{
|
||||
#include <QObject>
|
||||
#include <QPrintDialog>
|
||||
#include <QSettings>
|
||||
|
||||
class PrintRange{
|
||||
namespace LimeReport {
|
||||
|
||||
class PrintRange {
|
||||
public:
|
||||
int fromPage() const { return m_fromPage;}
|
||||
int toPage() const { return m_toPage;}
|
||||
QPrintDialog::PrintRange rangeType() const { return m_rangeType;}
|
||||
PrintRange(QAbstractPrintDialog::PrintRange rangeType=QPrintDialog::AllPages, int fromPage=0, int toPage=0);
|
||||
void setRangeType(QAbstractPrintDialog::PrintRange rangeType){ m_rangeType=rangeType;}
|
||||
void setFromPage(int fromPage){ m_fromPage = fromPage;}
|
||||
void setToPage(int toPage){ m_toPage = toPage;}
|
||||
int fromPage() const { return m_fromPage; }
|
||||
int toPage() const { return m_toPage; }
|
||||
QPrintDialog::PrintRange rangeType() const { return m_rangeType; }
|
||||
PrintRange(QAbstractPrintDialog::PrintRange rangeType = QPrintDialog::AllPages,
|
||||
int fromPage = 0, int toPage = 0);
|
||||
void setRangeType(QAbstractPrintDialog::PrintRange rangeType) { m_rangeType = rangeType; }
|
||||
void setFromPage(int fromPage) { m_fromPage = fromPage; }
|
||||
void setToPage(int toPage) { m_toPage = toPage; }
|
||||
|
||||
private:
|
||||
QPrintDialog::PrintRange m_rangeType;
|
||||
int m_fromPage;
|
||||
@ -32,34 +34,36 @@ class PageDesignIntf;
|
||||
class PageItemDesignIntf;
|
||||
class PreviewReportWidget;
|
||||
|
||||
typedef QList< QSharedPointer<PageItemDesignIntf> > ReportPages;
|
||||
typedef QList<QSharedPointer<PageItemDesignIntf>> ReportPages;
|
||||
|
||||
class RenderEnginePrivate;
|
||||
|
||||
class LIMEREPORT_EXPORT RenderEngine: public QObject{
|
||||
class LIMEREPORT_EXPORT RenderEngine: public QObject {
|
||||
Q_OBJECT
|
||||
friend class PreviewReportWidget;
|
||||
|
||||
public:
|
||||
static void setSettings(QSettings *value){m_settings=value;}
|
||||
static void setSettings(QSettings* value) { m_settings = value; }
|
||||
|
||||
public:
|
||||
explicit RenderEngine(QObject *parent = 0);
|
||||
explicit RenderEngine(RenderEnginePrivate* dd, QObject *parent = 0);
|
||||
explicit RenderEngine(QObject* parent = 0);
|
||||
explicit RenderEngine(RenderEnginePrivate* dd, QObject* parent = 0);
|
||||
~RenderEngine();
|
||||
bool printReport(QPrinter *printer=0);
|
||||
bool printPages(ReportPages pages, QPrinter *printer);
|
||||
bool printReport(QPrinter* printer = 0);
|
||||
bool printPages(ReportPages pages, QPrinter* printer);
|
||||
void printToFile(const QString& fileName);
|
||||
PageDesignIntf *createPreviewScene(QObject *parent = 0);
|
||||
PageDesignIntf* createPreviewScene(QObject* parent = 0);
|
||||
bool printToPDF(const QString& fileName);
|
||||
void previewReport(PreviewHints hints = PreviewBarsUserSetting);
|
||||
IDataSourceManager* dataManager();
|
||||
IScriptEngineManager* scriptManager();
|
||||
bool loadFromFile(const QString& fileName, bool autoLoadPreviewOnChange = false);
|
||||
bool loadFromByteArray(QByteArray *data);
|
||||
bool loadFromByteArray(QByteArray* data);
|
||||
bool loadFromString(const QString& data);
|
||||
QString reportFileName();
|
||||
void setReportFileName(const QString& fileName);
|
||||
QString lastError();
|
||||
PreviewReportWidget *createPreviewWidget(QWidget *parent = 0);
|
||||
PreviewReportWidget* createPreviewWidget(QWidget* parent = 0);
|
||||
void setPreviewWindowTitle(const QString& title);
|
||||
void setPreviewWindowIcon(const QIcon& icon);
|
||||
void setResultEditable(bool value);
|
||||
@ -70,7 +74,7 @@ public:
|
||||
bool setReportLanguage(QLocale::Language language);
|
||||
Qt::LayoutDirection previewLayoutDirection();
|
||||
void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection);
|
||||
QSettings* settings(){ return m_settings;}
|
||||
QSettings* settings() { return m_settings; }
|
||||
signals:
|
||||
void renderStarted();
|
||||
void renderFinished();
|
||||
@ -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)
|
||||
};
|
||||
|
@ -6,9 +6,9 @@
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
class ReportDesignWindowInterface: public QMainWindow{
|
||||
class ReportDesignWindowInterface: public QMainWindow {
|
||||
public:
|
||||
ReportDesignWindowInterface(QWidget* parent = 0): QMainWindow(parent){}
|
||||
ReportDesignWindowInterface(QWidget* parent = 0): QMainWindow(parent) { }
|
||||
virtual bool checkNeedToSave() = 0;
|
||||
virtual void showModal() = 0;
|
||||
virtual void showNonModal() = 0;
|
||||
|
@ -31,61 +31,74 @@
|
||||
#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;
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
class PrintRange{
|
||||
class PrintRange {
|
||||
public:
|
||||
int fromPage() const { return m_fromPage;}
|
||||
int toPage() const { return m_toPage;}
|
||||
QPrintDialog::PrintRange rangeType() const { return m_rangeType;}
|
||||
PrintRange(QAbstractPrintDialog::PrintRange rangeType=QPrintDialog::AllPages, int fromPage=0, int toPage=0);
|
||||
void setRangeType(QAbstractPrintDialog::PrintRange rangeType){ m_rangeType=rangeType;}
|
||||
void setFromPage(int fromPage){ m_fromPage = fromPage;}
|
||||
void setToPage(int toPage){ m_toPage = toPage;}
|
||||
int fromPage() const { return m_fromPage; }
|
||||
int toPage() const { return m_toPage; }
|
||||
QPrintDialog::PrintRange rangeType() const { return m_rangeType; }
|
||||
PrintRange(QAbstractPrintDialog::PrintRange rangeType = QPrintDialog::AllPages,
|
||||
int fromPage = 0, int toPage = 0);
|
||||
void setRangeType(QAbstractPrintDialog::PrintRange rangeType) { m_rangeType = rangeType; }
|
||||
void setFromPage(int fromPage) { m_fromPage = fromPage; }
|
||||
void setToPage(int toPage) { m_toPage = toPage; }
|
||||
|
||||
private:
|
||||
QPrintDialog::PrintRange m_rangeType;
|
||||
int m_fromPage;
|
||||
int m_toPage;
|
||||
};
|
||||
|
||||
class LIMEREPORT_EXPORT ItemGeometry{
|
||||
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){}
|
||||
ItemGeometry(): m_x(0), m_y(0), m_width(0), m_height(0), m_type(Millimeters){}
|
||||
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;
|
||||
void setX(const qreal &x);
|
||||
void setX(const qreal& x);
|
||||
|
||||
qreal y() const;
|
||||
void setY(const qreal &y);
|
||||
void setY(const qreal& y);
|
||||
|
||||
qreal width() const;
|
||||
void setWidth(const qreal &width);
|
||||
void setWidth(const qreal& width);
|
||||
|
||||
qreal height() const;
|
||||
void setHeight(const qreal &height);
|
||||
void setHeight(const qreal& height);
|
||||
|
||||
Type type() const;
|
||||
void setType(const Type &type);
|
||||
void setType(const Type& type);
|
||||
|
||||
Qt::Alignment anchor() const;
|
||||
void setAnchor(const Qt::Alignment &anchor);
|
||||
void setAnchor(const Qt::Alignment& anchor);
|
||||
|
||||
private:
|
||||
qreal m_x;
|
||||
@ -96,25 +109,31 @@ private:
|
||||
Qt::Alignment m_anchor;
|
||||
};
|
||||
|
||||
class LIMEREPORT_EXPORT WatermarkSetting{
|
||||
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(): m_font(QFont()), m_opacity(50), m_geometry(ItemGeometry()){}
|
||||
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);
|
||||
void setText(const QString& text);
|
||||
|
||||
QFont font() const;
|
||||
void setFont(const QFont &font);
|
||||
void setFont(const QFont& font);
|
||||
|
||||
int opacity() const;
|
||||
void setOpacity(const int &opacity);
|
||||
void setOpacity(const int& opacity);
|
||||
|
||||
ItemGeometry geometry() const;
|
||||
void setGeometry(const ItemGeometry &geometry);
|
||||
void setGeometry(const ItemGeometry& geometry);
|
||||
|
||||
QColor color() const;
|
||||
void setColor(const QColor &color);
|
||||
void setColor(const QColor& color);
|
||||
|
||||
private:
|
||||
QString m_text;
|
||||
@ -124,14 +143,13 @@ private:
|
||||
QColor m_color;
|
||||
};
|
||||
|
||||
class ItemBuilder{
|
||||
class ItemBuilder {
|
||||
virtual void setProperty(QString name, QVariant value) = 0;
|
||||
virtual QVariant property(QString name) = 0;
|
||||
virtual void setGeometry(ItemGeometry geometry) = 0;
|
||||
virtual ItemGeometry geometry() = 0;
|
||||
};
|
||||
|
||||
|
||||
class DataSourceManager;
|
||||
class ReportEnginePrivate;
|
||||
class PageDesignIntf;
|
||||
@ -140,25 +158,28 @@ class ReportDesignWidget;
|
||||
class PreviewReportWidget;
|
||||
class PreparedPages;
|
||||
|
||||
typedef QList< QSharedPointer<PageItemDesignIntf> > ReportPages;
|
||||
typedef QList<QSharedPointer<PageItemDesignIntf>> ReportPages;
|
||||
|
||||
class LIMEREPORT_EXPORT ReportEngine : public QObject{
|
||||
class LIMEREPORT_EXPORT ReportEngine: public QObject {
|
||||
Q_OBJECT
|
||||
friend class ReportDesignWidget;
|
||||
friend class PreviewReportWidget;
|
||||
friend class TranslationEditor;
|
||||
|
||||
public:
|
||||
static void setSettings(QSettings *value){m_settings=value;}
|
||||
static void setSettings(QSettings* value) { m_settings = value; }
|
||||
|
||||
public:
|
||||
explicit ReportEngine(QObject *parent = 0);
|
||||
explicit ReportEngine(QObject* parent = 0);
|
||||
~ReportEngine();
|
||||
bool printReport(QPrinter *printer=0);
|
||||
bool printReport(QPrinter* printer = 0);
|
||||
bool printReport(QMap<QString, QPrinter*> printers, bool printToAllPrinters = false);
|
||||
bool printPages(ReportPages pages, QPrinter *printer);
|
||||
bool printPages(ReportPages pages, QPrinter* printer);
|
||||
void printToFile(const QString& fileName);
|
||||
QGraphicsScene* createPreviewScene(QObject *parent = 0);
|
||||
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();
|
||||
@ -168,7 +189,7 @@ public:
|
||||
IDataSourceManager* dataManager();
|
||||
IScriptEngineManager* scriptManager();
|
||||
bool loadFromFile(const QString& fileName, bool autoLoadPreviewOnChange = false);
|
||||
bool loadFromByteArray(QByteArray *data);
|
||||
bool loadFromByteArray(QByteArray* data);
|
||||
bool loadFromString(const QString& data);
|
||||
QString reportFileName();
|
||||
void setReportFileName(const QString& fileName);
|
||||
@ -180,7 +201,7 @@ public:
|
||||
bool setDefaultExportDir(const QString& dirName);
|
||||
void setReportName(const QString& name);
|
||||
QString reportName();
|
||||
PreviewReportWidget *createPreviewWidget(QWidget *parent = 0);
|
||||
PreviewReportWidget* createPreviewWidget(QWidget* parent = 0);
|
||||
void setPreviewWindowTitle(const QString& title);
|
||||
void setPreviewWindowIcon(const QIcon& icon);
|
||||
void setPreviewPageBackgroundColor(QColor color);
|
||||
@ -202,7 +223,7 @@ public:
|
||||
QLocale::Language currentDesignerLanguage();
|
||||
ScaleType previewScaleType();
|
||||
int previewScalePercent();
|
||||
void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0);
|
||||
void setPreviewScaleType(const ScaleType& previewScaleType, int percent = 0);
|
||||
void addWatermark(const WatermarkSetting& watermarkSetting);
|
||||
void clearWatermarks();
|
||||
IPreparedPages* preparedPages();
|
||||
@ -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);
|
||||
ReportEnginePrivate* const d_ptr;
|
||||
ReportEngine(ReportEnginePrivate& dd, QObject* parent = 0);
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(ReportEngine)
|
||||
static QSettings* m_settings;
|
||||
|
@ -32,15 +32,15 @@
|
||||
#include "qglobal.h"
|
||||
|
||||
#if QT_VERSION >= 0x050600
|
||||
#ifndef USE_QTSCRIPTENGINE
|
||||
#ifndef USE_QJSENGINE
|
||||
#define USE_QJSENGINE
|
||||
#endif
|
||||
#endif
|
||||
#ifndef USE_QTSCRIPTENGINE
|
||||
#ifndef USE_QJSENGINE
|
||||
#define USE_QJSENGINE
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#ifndef USE_QTSCRIPTENGINE
|
||||
#define USE_QTSCRIPTENGINE
|
||||
#endif
|
||||
#ifndef USE_QTSCRIPTENGINE
|
||||
#define USE_QTSCRIPTENGINE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_QJSENGINE
|
||||
@ -49,38 +49,38 @@
|
||||
#include <QtScript/QScriptEngine>
|
||||
#endif
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
#ifdef USE_QJSENGINE
|
||||
typedef QJSEngine ScriptEngineType;
|
||||
typedef QJSValue ScriptValueType;
|
||||
template <typename T>
|
||||
static inline QJSValue getJSValue(QJSEngine &e, T *p)
|
||||
{
|
||||
typedef QJSEngine ScriptEngineType;
|
||||
typedef QJSValue ScriptValueType;
|
||||
template <typename T> static inline QJSValue getJSValue(QJSEngine& e, T* p)
|
||||
{
|
||||
QJSValue res = e.newQObject(p);
|
||||
QQmlEngine::setObjectOwnership(p, QQmlEngine::CppOwnership);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
#else
|
||||
typedef QScriptEngine ScriptEngineType;
|
||||
typedef QScriptValue ScriptValueType;
|
||||
typedef QScriptEngine ScriptEngineType;
|
||||
typedef QScriptValue ScriptValueType;
|
||||
#endif
|
||||
|
||||
class IScriptEngineManager{
|
||||
class IScriptEngineManager {
|
||||
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;
|
||||
virtual bool addFunction(const QString& name, const QString& script,
|
||||
const QString& category = "", const QString& description = "")
|
||||
= 0;
|
||||
virtual const QString& lastError() const = 0;
|
||||
virtual ScriptValueType moveQObjectToScript(QObject* object, const QString objectName) = 0;
|
||||
virtual ~IScriptEngineManager(){}
|
||||
|
||||
virtual ~IScriptEngineManager() { }
|
||||
};
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRSCRIPTENGINEMANAGERINTF_H
|
||||
|
@ -28,6 +28,7 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrdataband.h"
|
||||
|
||||
#include "lrdesignelementsfactory.h"
|
||||
#include "lrglobal.h"
|
||||
|
||||
@ -35,56 +36,51 @@ const QString xmlTag = "Data";
|
||||
const QString xmlTagHeader = "DataHeader";
|
||||
const QString xmlTagFooter = "DataFooter";
|
||||
|
||||
namespace{
|
||||
namespace {
|
||||
|
||||
LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::DataBand(owner,parent);
|
||||
LimeReport::BaseDesignIntf* createBand(QObject* owner, LimeReport::BaseDesignIntf* parent)
|
||||
{
|
||||
return new LimeReport::DataBand(owner, parent);
|
||||
}
|
||||
LimeReport::BaseDesignIntf * createHeader(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::DataHeaderBand(owner,parent);
|
||||
LimeReport::BaseDesignIntf* createHeader(QObject* owner, LimeReport::BaseDesignIntf* parent)
|
||||
{
|
||||
return new LimeReport::DataHeaderBand(owner, parent);
|
||||
}
|
||||
LimeReport::BaseDesignIntf * createFooter(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::DataFooterBand(owner,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(
|
||||
LimeReport::ItemAttribs(QObject::tr("DataHeader"), LimeReport::Const::bandTAG),
|
||||
createHeader);
|
||||
bool VARIABLE_IS_NOT_USED registredFooter
|
||||
= LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTagFooter,
|
||||
LimeReport::ItemAttribs(QObject::tr("DataFooter"),LimeReport::Const::bandTAG),
|
||||
createFooter
|
||||
);
|
||||
LimeReport::ItemAttribs(QObject::tr("DataFooter"), LimeReport::Const::bandTAG),
|
||||
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)
|
||||
void DataBand::preparePopUpMenu(QMenu& menu)
|
||||
{
|
||||
BandDesignIntf::preparePopUpMenu(menu);
|
||||
|
||||
@ -111,52 +107,49 @@ void DataBand::preparePopUpMenu(QMenu &menu)
|
||||
currAction = menu.addAction(tr("Start new page"));
|
||||
currAction->setCheckable(true);
|
||||
currAction->setChecked(startNewPage());
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void DataBand::processPopUpAction(QAction *action)
|
||||
void DataBand::processPopUpAction(QAction* action)
|
||||
{
|
||||
BandDesignIntf::processPopUpAction(action);
|
||||
if (action->text().compare(tr("Keep footer together")) == 0){
|
||||
setProperty("keepFooterTogether",action->isChecked());
|
||||
if (action->text().compare(tr("Keep footer together")) == 0) {
|
||||
setProperty("keepFooterTogether", action->isChecked());
|
||||
}
|
||||
|
||||
if (action->text().compare(tr("Keep subdetail together")) == 0){
|
||||
setProperty("keepSubdetailTogether",action->isChecked());
|
||||
if (action->text().compare(tr("Keep subdetail together")) == 0) {
|
||||
setProperty("keepSubdetailTogether", action->isChecked());
|
||||
}
|
||||
|
||||
if (action->text().compare(tr("Slice last row")) == 0){
|
||||
setProperty("sliceLastRow",action->isChecked());
|
||||
if (action->text().compare(tr("Slice last row")) == 0) {
|
||||
setProperty("sliceLastRow", action->isChecked());
|
||||
}
|
||||
|
||||
if (action->text().compare(tr("Use alternate background color")) == 0){
|
||||
setProperty("useAlternateBackgroundColor",action->isChecked());
|
||||
if (action->text().compare(tr("Use alternate background color")) == 0) {
|
||||
setProperty("useAlternateBackgroundColor", action->isChecked());
|
||||
}
|
||||
|
||||
if (action->text().compare(tr("Start new page")) == 0){
|
||||
setProperty("startNewPage",action->isChecked());
|
||||
if (action->text().compare(tr("Start new page")) == 0) {
|
||||
setProperty("startNewPage", action->isChecked());
|
||||
}
|
||||
|
||||
if (action->text().compare(tr("Start from new page")) == 0){
|
||||
setProperty("startFromNewPage",action->isChecked());
|
||||
if (action->text().compare(tr("Start from new page")) == 0) {
|
||||
setProperty("startFromNewPage", action->isChecked());
|
||||
}
|
||||
}
|
||||
|
||||
BaseDesignIntf *DataBand::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
BaseDesignIntf* DataBand::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
return new DataBand(owner,parent);
|
||||
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());
|
||||
}
|
||||
|
||||
void DataHeaderBand::preparePopUpMenu(QMenu &menu)
|
||||
void DataHeaderBand::preparePopUpMenu(QMenu& menu)
|
||||
{
|
||||
BandDesignIntf::preparePopUpMenu(menu);
|
||||
QAction* currAction = menu.addAction(tr("Reprint on each page"));
|
||||
@ -172,30 +165,30 @@ void DataHeaderBand::preparePopUpMenu(QMenu &menu)
|
||||
currAction->setChecked(printAlways());
|
||||
}
|
||||
|
||||
void DataHeaderBand::processPopUpAction(QAction *action)
|
||||
void DataHeaderBand::processPopUpAction(QAction* action)
|
||||
{
|
||||
BandDesignIntf::processPopUpAction(action);
|
||||
if (action->text().compare(tr("Reprint on each page")) == 0){
|
||||
setProperty("reprintOnEachPage",action->isChecked());
|
||||
if (action->text().compare(tr("Reprint on each page")) == 0) {
|
||||
setProperty("reprintOnEachPage", action->isChecked());
|
||||
}
|
||||
|
||||
if (action->text().compare(tr("Repeat on each row")) == 0){
|
||||
setProperty("repeatOnEachRow",action->isChecked());
|
||||
if (action->text().compare(tr("Repeat on each row")) == 0) {
|
||||
setProperty("repeatOnEachRow", action->isChecked());
|
||||
}
|
||||
|
||||
if (action->text().compare(tr("Print always")) == 0){
|
||||
setProperty("printAlways",action->isChecked());
|
||||
if (action->text().compare(tr("Print always")) == 0) {
|
||||
setProperty("printAlways", action->isChecked());
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
void DataFooterBand::preparePopUpMenu(QMenu &menu)
|
||||
void DataFooterBand::preparePopUpMenu(QMenu& menu)
|
||||
{
|
||||
BandDesignIntf::preparePopUpMenu(menu);
|
||||
QAction* currAction = menu.addAction(tr("Print always"));
|
||||
@ -203,13 +196,12 @@ void DataFooterBand::preparePopUpMenu(QMenu &menu)
|
||||
currAction->setChecked(printAlways());
|
||||
}
|
||||
|
||||
void DataFooterBand::processPopUpAction(QAction *action)
|
||||
void DataFooterBand::processPopUpAction(QAction* action)
|
||||
{
|
||||
BandDesignIntf::processPopUpAction(action);
|
||||
if (action->text().compare(tr("Print always")) == 0){
|
||||
setProperty("printAlways",action->isChecked());
|
||||
if (action->text().compare(tr("Print always")) == 0) {
|
||||
setProperty("printAlways", action->isChecked());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -32,77 +32,88 @@
|
||||
|
||||
#include "lrbanddesignintf.h"
|
||||
#include "lrbasedesignintf.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace LimeReport{
|
||||
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);
|
||||
DataBand(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
bool isUnique() const;
|
||||
bool isData() const {return true;}
|
||||
bool isData() const { return true; }
|
||||
|
||||
protected:
|
||||
QColor bandColor() const;
|
||||
void preparePopUpMenu(QMenu &menu);
|
||||
void processPopUpAction(QAction *action);
|
||||
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);
|
||||
};
|
||||
|
||||
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:
|
||||
DataHeaderBand(QObject* owner=0, QGraphicsItem* parent=0);
|
||||
bool isUnique() const {return false;}
|
||||
bool isHeader() const {return true;}
|
||||
QColor bandColor() const {return QColor(Qt::darkGreen);}
|
||||
DataHeaderBand(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
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);
|
||||
void preparePopUpMenu(QMenu& menu);
|
||||
void processPopUpAction(QAction* action);
|
||||
|
||||
private:
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0){
|
||||
return new DataHeaderBand(owner,parent);
|
||||
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);}
|
||||
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);
|
||||
void preparePopUpMenu(QMenu& menu);
|
||||
void processPopUpAction(QAction* action);
|
||||
|
||||
private:
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0){
|
||||
return new DataFooterBand(owner,parent);
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0)
|
||||
{
|
||||
return new DataFooterBand(owner, parent);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRDATABAND_H
|
||||
|
@ -28,131 +28,130 @@
|
||||
* 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{
|
||||
namespace {
|
||||
|
||||
LimeReport::BaseDesignIntf* createHeader(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::GroupBandHeader(owner,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
|
||||
);
|
||||
LimeReport::ItemAttribs(QObject::tr("GroupHeader"), LimeReport::Const::bandTAG),
|
||||
createHeader);
|
||||
|
||||
LimeReport::BaseDesignIntf * createFooter(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::GroupBandFooter(owner,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
|
||||
);
|
||||
LimeReport::ItemAttribs(QObject::tr("GroupFooter"), LimeReport::Const::bandTAG),
|
||||
createFooter);
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport{
|
||||
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()
|
||||
// bool GroupBandHeader::tryToKeepTogether()
|
||||
//{
|
||||
// return m_tryToKeepTogether;
|
||||
//}
|
||||
|
||||
BaseDesignIntf *GroupBandHeader::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
BaseDesignIntf* GroupBandHeader::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
return new GroupBandHeader(owner, parent);
|
||||
}
|
||||
|
||||
void GroupBandHeader::startGroup(DataSourceManager* dataManager)
|
||||
{
|
||||
m_groupStarted=true;
|
||||
m_groupStarted = true;
|
||||
|
||||
QString lineVar = QLatin1String("line_")+objectName().toLower();
|
||||
dataManager->setReportVariable(lineVar,1);
|
||||
QString lineVar = QLatin1String("line_") + objectName().toLower();
|
||||
dataManager->setReportVariable(lineVar, 1);
|
||||
|
||||
QString datasourceName = findDataSourceName(parentBand());
|
||||
if (dataManager->containsDatasource(datasourceName)){
|
||||
if (dataManager->containsDatasource(datasourceName)) {
|
||||
IDataSource* ds = dataManager->dataSource(datasourceName);
|
||||
if (ds && ds->columnIndexByName(m_groupFiledName)!=-1)
|
||||
m_groupFieldValue=ds->data(m_groupFiledName);
|
||||
if (ds && ds->columnIndexByName(m_groupFiledName) != -1)
|
||||
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);
|
||||
result=expandScripts(result, dataManager);
|
||||
result=expandDataFields(result, NoEscapeSymbols, dataManager);
|
||||
if (!m_condition.isEmpty()) {
|
||||
result = expandUserVariables(result, FirstPass, NoEscapeSymbols, dataManager);
|
||||
result = expandScripts(result, dataManager);
|
||||
result = expandDataFields(result, NoEscapeSymbols, dataManager);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool GroupBandHeader::isNeedToClose(DataSourceManager* dataManager)
|
||||
{
|
||||
if (!m_groupStarted) return false;
|
||||
if ((m_groupFiledName.isNull() || m_groupFiledName.isEmpty()) && condition().isEmpty()){
|
||||
if (!m_groupStarted)
|
||||
return false;
|
||||
if ((m_groupFiledName.isNull() || m_groupFiledName.isEmpty()) && condition().isEmpty()) {
|
||||
dataManager->putError(tr("Group field not found"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_condition.isEmpty()){
|
||||
if (!m_condition.isEmpty()) {
|
||||
return m_conditionValue != calcCondition(dataManager);
|
||||
} else {
|
||||
QString datasourceName = findDataSourceName(parentBand());
|
||||
if (dataManager->containsDatasource(datasourceName)){
|
||||
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;
|
||||
return ds->data(m_groupFiledName)!=m_groupFieldValue;
|
||||
if (ds) {
|
||||
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 {
|
||||
dataManager->putError(tr("Datasource \"%1\" not found!").arg(datasourceName));
|
||||
@ -164,62 +163,47 @@ bool GroupBandHeader::isNeedToClose(DataSourceManager* dataManager)
|
||||
|
||||
bool GroupBandHeader::isStarted()
|
||||
{
|
||||
return m_groupStarted;//!m_groupFieldValue.isNull();
|
||||
return m_groupStarted; //! m_groupFieldValue.isNull();
|
||||
}
|
||||
|
||||
void GroupBandHeader::closeGroup()
|
||||
{
|
||||
m_groupFieldValue=QVariant();
|
||||
m_conditionValue="";
|
||||
m_groupStarted=false;
|
||||
m_groupFieldValue = QVariant();
|
||||
m_conditionValue = "";
|
||||
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
|
||||
bool GroupBandFooter::isUnique() const { return false; }
|
||||
|
||||
QColor GroupBandFooter::bandColor() const { return QColor(Qt::darkBlue); }
|
||||
|
||||
BaseDesignIntf* GroupBandFooter::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
return false;
|
||||
return new GroupBandFooter(owner, parent);
|
||||
}
|
||||
|
||||
QColor GroupBandFooter::bandColor() const
|
||||
{
|
||||
return QColor(Qt::darkBlue);
|
||||
}
|
||||
|
||||
BaseDesignIntf *GroupBandFooter::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
{
|
||||
return new GroupBandFooter(owner,parent);
|
||||
}
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
@ -33,61 +33,64 @@
|
||||
#include "lrbanddesignintf.h"
|
||||
#include "lrdesignelementsfactory.h"
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class GroupBandHeader : public BandDesignIntf, public IGroupBand{
|
||||
class GroupBandHeader: public BandDesignIntf, public IGroupBand {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString groupFieldName READ groupFieldName WRITE setGroupFieldName)
|
||||
Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable )
|
||||
Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable)
|
||||
Q_PROPERTY(bool keepGroupTogether READ tryToKeepTogether WRITE setTryToKeepTogether)
|
||||
Q_PROPERTY(bool startNewPage READ startNewPage WRITE setStartNewPage)
|
||||
Q_PROPERTY(bool resetPageNumber READ resetPageNumber WRITE setResetPageNumber)
|
||||
Q_PROPERTY(bool reprintOnEachPage READ reprintOnEachPage WRITE setReprintOnEachPage)
|
||||
Q_PROPERTY(QString condition READ condition WRITE setCondition)
|
||||
public:
|
||||
GroupBandHeader(QObject* owner = 0, QGraphicsItem* parent=0);
|
||||
GroupBandHeader(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
virtual bool isUnique() const;
|
||||
QVariant groupFieldValue(){return m_groupFieldValue;}
|
||||
void setGroupFieldValue(QVariant value){m_groupFieldValue=value;}
|
||||
QString groupFieldName(){return m_groupFiledName;}
|
||||
void setGroupFieldName(QString fieldName){m_groupFiledName=fieldName;}
|
||||
QVariant groupFieldValue() { return m_groupFieldValue; }
|
||||
void setGroupFieldValue(QVariant value) { m_groupFieldValue = value; }
|
||||
QString groupFieldName() { return m_groupFiledName; }
|
||||
void setGroupFieldName(QString fieldName) { m_groupFiledName = fieldName; }
|
||||
QColor bandColor() const;
|
||||
bool startNewPage() const;
|
||||
void setStartNewPage(bool startNewPage);
|
||||
bool resetPageNumber() const;
|
||||
void setResetPageNumber(bool resetPageNumber);
|
||||
bool isHeader() const{return true;}
|
||||
bool isGroupHeader() const {return true;}
|
||||
bool isHeader() const { return true; }
|
||||
bool isGroupHeader() const { return true; }
|
||||
QString condition() const;
|
||||
void setCondition(const QString &condition);
|
||||
void setCondition(const QString& condition);
|
||||
|
||||
private:
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
void startGroup(DataSourceManager* dataManager);
|
||||
bool isNeedToClose(DataSourceManager *dataManager);
|
||||
bool isNeedToClose(DataSourceManager* dataManager);
|
||||
bool isStarted();
|
||||
void closeGroup();
|
||||
int index();
|
||||
QString findDataSourceName(BandDesignIntf *parentBand);
|
||||
QString calcCondition(DataSourceManager *dataManager);
|
||||
QString findDataSourceName(BandDesignIntf* parentBand);
|
||||
QString calcCondition(DataSourceManager* dataManager);
|
||||
|
||||
private:
|
||||
QVariant m_groupFieldValue;
|
||||
QString m_groupFiledName;
|
||||
bool m_groupStarted;
|
||||
//bool m_startNewPage;
|
||||
// bool m_startNewPage;
|
||||
bool m_resetPageNumber;
|
||||
QString m_condition;
|
||||
QString m_conditionValue;
|
||||
};
|
||||
|
||||
class GroupBandFooter : public BandDesignIntf{
|
||||
class GroupBandFooter: public BandDesignIntf {
|
||||
Q_OBJECT
|
||||
public:
|
||||
GroupBandFooter(QObject* owner = 0, QGraphicsItem* parent=0);
|
||||
GroupBandFooter(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
virtual bool isUnique() const;
|
||||
QColor bandColor() const;
|
||||
virtual bool isFooter() const{return true;}
|
||||
virtual bool isFooter() const { return true; }
|
||||
|
||||
private:
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -28,46 +28,45 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrpagefooter.h"
|
||||
|
||||
#include "lrdesignelementsfactory.h"
|
||||
#include "lrglobal.h"
|
||||
#include "lrpagedesignintf.h"
|
||||
|
||||
const QString xmlTag ="PageFooter";
|
||||
const QString xmlTag = "PageFooter";
|
||||
|
||||
namespace{
|
||||
LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::PageFooter(owner,parent);
|
||||
namespace {
|
||||
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{
|
||||
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") );
|
||||
setBandTypeText(tr("Page Footer"));
|
||||
setMarkerColor(bandColor());
|
||||
setAutoHeight(false);
|
||||
}
|
||||
|
||||
BaseDesignIntf *PageFooter::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
BaseDesignIntf* PageFooter::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
return new PageFooter(owner,parent);
|
||||
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)
|
||||
void PageFooter::preparePopUpMenu(QMenu& menu)
|
||||
{
|
||||
QAction* action = menu.addAction(tr("Print on first page"));
|
||||
action->setCheckable(true);
|
||||
@ -76,57 +75,44 @@ void PageFooter::preparePopUpMenu(QMenu &menu)
|
||||
action = menu.addAction(tr("Print on last page"));
|
||||
action->setCheckable(true);
|
||||
action->setChecked(printOnLastPage());
|
||||
|
||||
}
|
||||
|
||||
void PageFooter::processPopUpAction(QAction *action)
|
||||
void PageFooter::processPopUpAction(QAction* action)
|
||||
{
|
||||
if (action->text().compare(tr("Print on first page")) == 0){
|
||||
page()->setPropertyToSelectedItems("printOnFirstPage",action->isChecked());
|
||||
if (action->text().compare(tr("Print on first page")) == 0) {
|
||||
page()->setPropertyToSelectedItems("printOnFirstPage", action->isChecked());
|
||||
}
|
||||
if (action->text().compare(tr("Print on last page")) == 0){
|
||||
page()->setPropertyToSelectedItems("printOnLastPage",action->isChecked());
|
||||
if (action->text().compare(tr("Print on last page")) == 0) {
|
||||
page()->setPropertyToSelectedItems("printOnLastPage", action->isChecked());
|
||||
}
|
||||
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)
|
||||
{
|
||||
if (m_printOnFirstPage != printOnFirstPage){
|
||||
if (m_printOnFirstPage != printOnFirstPage) {
|
||||
bool oldValue = m_printOnFirstPage;
|
||||
m_printOnFirstPage = printOnFirstPage;
|
||||
update();
|
||||
notify("printOnFirstPage",oldValue,printOnFirstPage);
|
||||
notify("printOnFirstPage", oldValue, printOnFirstPage);
|
||||
}
|
||||
}
|
||||
|
||||
bool PageFooter::printOnLastPage() const
|
||||
{
|
||||
return m_printOnLastPage;
|
||||
}
|
||||
bool PageFooter::printOnLastPage() const { return m_printOnLastPage; }
|
||||
|
||||
void PageFooter::setPrintOnLastPage(bool printOnLastPage)
|
||||
{
|
||||
if (m_printOnLastPage != printOnLastPage){
|
||||
if (m_printOnLastPage != printOnLastPage) {
|
||||
bool oldValue = m_printOnLastPage;
|
||||
m_printOnLastPage = printOnLastPage;
|
||||
update();
|
||||
notify("printOnLastPage",oldValue,printOnLastPage);
|
||||
notify("printOnLastPage", oldValue, printOnLastPage);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,19 +32,19 @@
|
||||
|
||||
#include "lrbanddesignintf.h"
|
||||
#include "lrbasedesignintf.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace LimeReport{
|
||||
class PageFooter : public BandDesignIntf
|
||||
{
|
||||
namespace LimeReport {
|
||||
class PageFooter: public BandDesignIntf {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool printOnFirstPage READ printOnFirstPage WRITE setPrintOnFirstPage)
|
||||
Q_PROPERTY(bool printOnLastPage READ printOnLastPage WRITE setPrintOnLastPage)
|
||||
Q_PROPERTY(bool removeGap READ removeGap WRITE setRemoveGap)
|
||||
public:
|
||||
PageFooter(QObject* owner = 0, QGraphicsItem* parent=0);
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
|
||||
virtual bool isFooter() const {return true;}
|
||||
PageFooter(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
virtual bool isFooter() const { return true; }
|
||||
bool printOnLastPage() const;
|
||||
void setPrintOnLastPage(bool printOnLastPage);
|
||||
bool printOnFirstPage() const;
|
||||
@ -54,13 +54,14 @@ public:
|
||||
|
||||
protected:
|
||||
QColor bandColor() const;
|
||||
void preparePopUpMenu(QMenu &menu);
|
||||
void processPopUpAction(QAction *action);
|
||||
void preparePopUpMenu(QMenu& menu);
|
||||
void processPopUpAction(QAction* action);
|
||||
|
||||
private:
|
||||
bool m_printOnFirstPage;
|
||||
bool m_printOnLastPage;
|
||||
bool m_removeGap;
|
||||
};
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRPAGEFOOTER_H
|
||||
|
@ -28,64 +28,54 @@
|
||||
* 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";
|
||||
const QString xmlTag = "PageHeader";
|
||||
|
||||
namespace{
|
||||
namespace {
|
||||
|
||||
LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::PageHeader(owner,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{
|
||||
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());
|
||||
}
|
||||
|
||||
BaseDesignIntf *PageHeader::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
BaseDesignIntf* PageHeader::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
return new PageHeader(owner,parent);
|
||||
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,29 +30,31 @@
|
||||
#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)
|
||||
public:
|
||||
PageHeader(QObject* owner = 0, QGraphicsItem* parent=0);
|
||||
PageHeader(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
bool printOnFirstPage() const;
|
||||
void setPrintOnFirstPage(bool printOnFirstPage);
|
||||
bool printOnLastPage() const;
|
||||
void setPrintOnLastPage(bool printOnLastPage);
|
||||
bool isHeader() const{return true;}
|
||||
bool isHeader() const { return true; }
|
||||
|
||||
protected:
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
|
||||
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,44 +28,39 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrreportfooter.h"
|
||||
|
||||
#include "lrdesignelementsfactory.h"
|
||||
#include "lrglobal.h"
|
||||
|
||||
const QString xmlTag ="ReportFooter";
|
||||
const QString xmlTag = "ReportFooter";
|
||||
|
||||
namespace{
|
||||
namespace {
|
||||
|
||||
LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::ReportFooter(owner,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{
|
||||
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());
|
||||
}
|
||||
|
||||
BaseDesignIntf *ReportFooter::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
BaseDesignIntf* ReportFooter::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
return new ReportFooter(owner,parent);
|
||||
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"
|
||||
|
||||
namespace LimeReport{
|
||||
class ReportFooter : public BandDesignIntf
|
||||
{
|
||||
#include <QObject>
|
||||
|
||||
namespace LimeReport {
|
||||
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);
|
||||
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,50 +28,45 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrreportheader.h"
|
||||
|
||||
#include "lrdesignelementsfactory.h"
|
||||
#include "lrglobal.h"
|
||||
|
||||
const QString xmlTag ="ReportHeader";
|
||||
const QString xmlTag = "ReportHeader";
|
||||
|
||||
namespace{
|
||||
LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::ReportHeader(owner,parent);
|
||||
namespace {
|
||||
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());
|
||||
}
|
||||
BaseDesignIntf *ReportHeader::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
BaseDesignIntf* ReportHeader::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
return new ReportHeader(owner,parent);
|
||||
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)
|
||||
{
|
||||
if (m_printBeforePageHeader != printBeforePageHeader){
|
||||
if (m_printBeforePageHeader != printBeforePageHeader) {
|
||||
m_printBeforePageHeader = printBeforePageHeader;
|
||||
notify("printBeforePageHeader",!m_printBeforePageHeader,m_printBeforePageHeader);
|
||||
notify("printBeforePageHeader", !m_printBeforePageHeader, m_printBeforePageHeader);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -30,25 +30,26 @@
|
||||
#ifndef LRREPORTHEADER_H
|
||||
#define LRREPORTHEADER_H
|
||||
|
||||
#include <QObject>
|
||||
#include "lrbanddesignintf.h"
|
||||
#include "lrbasedesignintf.h"
|
||||
|
||||
namespace LimeReport{
|
||||
class ReportHeader : public LimeReport::BandDesignIntf
|
||||
{
|
||||
#include <QObject>
|
||||
|
||||
namespace LimeReport {
|
||||
class ReportHeader: public LimeReport::BandDesignIntf {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable)
|
||||
Q_PROPERTY(bool printBeforePageHeader READ printBeforePageHeader WRITE setPrintBeforePageHeader)
|
||||
public:
|
||||
ReportHeader(QObject* owner = 0, QGraphicsItem *parent=0);
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
|
||||
ReportHeader(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
bool printBeforePageHeader() const;
|
||||
void setPrintBeforePageHeader(bool printBeforePageHeader);
|
||||
bool isHeader() const {return true;}
|
||||
bool isHeader() const { return true; }
|
||||
|
||||
protected:
|
||||
QColor bandColor() const;
|
||||
bool m_printBeforePageHeader;
|
||||
};
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRREPORTHEADER_H
|
||||
|
@ -28,55 +28,56 @@
|
||||
* 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");
|
||||
const QColor BAND_COLOR = Qt::red;
|
||||
|
||||
namespace{
|
||||
namespace {
|
||||
|
||||
LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::SubDetailBand(owner,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){
|
||||
return new LimeReport::SubDetailHeaderBand(owner,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
|
||||
);
|
||||
LimeReport::ItemAttribs(QObject::tr("SubDetailHeader"), LimeReport::Const::bandTAG),
|
||||
createHeader);
|
||||
|
||||
LimeReport::BaseDesignIntf * createFooter(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::SubDetailFooterBand(owner,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
|
||||
);
|
||||
LimeReport::ItemAttribs(QObject::tr("SubDetailFooter"), LimeReport::Const::bandTAG),
|
||||
createFooter);
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
//SubDetailBand
|
||||
// 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);
|
||||
@ -93,62 +94,46 @@ bool SubDetailBand::isHasFooter() const
|
||||
return isConnectedToBand(BandDesignIntf::SubDetailFooter);
|
||||
}
|
||||
|
||||
BaseDesignIntf *SubDetailBand::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
BaseDesignIntf* SubDetailBand::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
return new SubDetailBand(owner,parent);
|
||||
return new SubDetailBand(owner, parent);
|
||||
}
|
||||
|
||||
QColor SubDetailBand::bandColor() const
|
||||
{
|
||||
return BAND_COLOR;
|
||||
}
|
||||
QColor SubDetailBand::bandColor() const { return BAND_COLOR; }
|
||||
|
||||
//SubDetailHeaderBand
|
||||
// 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
|
||||
bool SubDetailHeaderBand::isUnique() const { return false; }
|
||||
|
||||
QColor SubDetailHeaderBand::bandColor() const { return BAND_COLOR; }
|
||||
|
||||
BaseDesignIntf* SubDetailHeaderBand::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
return false;
|
||||
return new SubDetailHeaderBand(owner, parent);
|
||||
}
|
||||
|
||||
QColor SubDetailHeaderBand::bandColor() const
|
||||
{
|
||||
return BAND_COLOR;
|
||||
}
|
||||
// SubDetailFooterBand
|
||||
|
||||
BaseDesignIntf *SubDetailHeaderBand::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
{
|
||||
return new SubDetailHeaderBand(owner,parent);
|
||||
}
|
||||
|
||||
//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
|
||||
bool SubDetailFooterBand::isUnique() const { return false; }
|
||||
|
||||
QColor SubDetailFooterBand::bandColor() const { return BAND_COLOR; }
|
||||
|
||||
BaseDesignIntf* SubDetailFooterBand::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
return false;
|
||||
return new SubDetailFooterBand(owner, parent);
|
||||
}
|
||||
|
||||
QColor SubDetailFooterBand::bandColor() const
|
||||
{
|
||||
return BAND_COLOR;
|
||||
}
|
||||
|
||||
BaseDesignIntf *SubDetailFooterBand::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
{
|
||||
return new SubDetailFooterBand(owner,parent);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
@ -33,64 +33,73 @@
|
||||
#include "lrbanddesignintf.h"
|
||||
#include "lrbasedesignintf.h"
|
||||
|
||||
namespace LimeReport{
|
||||
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;}
|
||||
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);
|
||||
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);
|
||||
SubDetailHeaderBand(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
bool isUnique() const;
|
||||
bool isHeader() const {return true;}
|
||||
int bandNestingLevel(){ return 1;}
|
||||
bool isHeader() const { return true; }
|
||||
int bandNestingLevel() { return 1; }
|
||||
|
||||
protected:
|
||||
QColor bandColor() const;
|
||||
|
||||
private:
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
|
||||
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);
|
||||
SubDetailFooterBand(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
virtual bool isUnique() const;
|
||||
bool isFooter() const{return true;}
|
||||
int bandNestingLevel(){ return 1;}
|
||||
bool isFooter() const { return true; }
|
||||
int bandNestingLevel() { return 1; }
|
||||
|
||||
protected:
|
||||
QColor bandColor() const;
|
||||
|
||||
private:
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRSUBDETAILBAND_H
|
||||
|
@ -1,37 +1,34 @@
|
||||
#include "lrtearoffband.h"
|
||||
|
||||
#include "lrdesignelementsfactory.h"
|
||||
#include "lrglobal.h"
|
||||
|
||||
const QString xmlTag ="TearOffBand";
|
||||
const QString xmlTag = "TearOffBand";
|
||||
|
||||
namespace{
|
||||
LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::TearOffBand(owner,parent);
|
||||
namespace {
|
||||
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{
|
||||
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());
|
||||
}
|
||||
|
||||
BaseDesignIntf *TearOffBand::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
BaseDesignIntf* TearOffBand::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
return new TearOffBand(owner,parent);
|
||||
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,16 +4,16 @@
|
||||
|
||||
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);
|
||||
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;}
|
||||
bool isFooter() const{ return true;}
|
||||
bool isUnique() const { return true; }
|
||||
bool isFooter() const { return true; }
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -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>
|
||||
|
||||
namespace LimeReport{
|
||||
#include <stdexcept>
|
||||
|
||||
template
|
||||
<
|
||||
typename AbstractProduct,
|
||||
typename IdentifierType,
|
||||
typename ProductCreator,
|
||||
typename Attribs
|
||||
>
|
||||
class AttribsAbstractFactory
|
||||
: public Singleton< AttribsAbstractFactory< AbstractProduct,IdentifierType,ProductCreator,Attribs > >
|
||||
{
|
||||
namespace LimeReport {
|
||||
|
||||
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 > >;
|
||||
typedef QMap<IdentifierType, ProductCreator> FactoryMap;
|
||||
typedef QMap<IdentifierType, Attribs> AliasMap;
|
||||
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){
|
||||
if (m_factoryMap.contains(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){
|
||||
if (m_attribsMap.contains(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();}
|
||||
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,74 +30,76 @@
|
||||
#ifndef LRSIMPLEABSTRACTFACTORY_H
|
||||
#define LRSIMPLEABSTRACTFACTORY_H
|
||||
|
||||
#include "lrsingleton.h"
|
||||
#include "lrglobal.h"
|
||||
#include <stdexcept>
|
||||
#include "lrsingleton.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
namespace LimeReport{
|
||||
|
||||
template
|
||||
<
|
||||
typename AbstractProduct,
|
||||
typename IdentifierType,
|
||||
typename ProductCreator
|
||||
>
|
||||
class SimpleAbstractFactory
|
||||
: public Singleton< SimpleAbstractFactory< AbstractProduct,IdentifierType,ProductCreator > >
|
||||
{
|
||||
#include <stdexcept>
|
||||
namespace LimeReport {
|
||||
|
||||
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 > >;
|
||||
typedef QHash<IdentifierType, ProductCreator> FactoryMap;
|
||||
friend class Singleton<SimpleAbstractFactory<AbstractProduct, IdentifierType, ProductCreator>>;
|
||||
|
||||
public:
|
||||
bool registerCreator(const IdentifierType& id, ProductCreator creator){
|
||||
return (m_factoryMap.insert(id,creator).value()==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){
|
||||
if (m_factoryMap.contains(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 {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
const FactoryMap& map(){return m_factoryMap;}
|
||||
int mapElementCount(){return m_factoryMap.count();}
|
||||
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 >{
|
||||
typedef SimpleAbstractFactory< AbstractProduct,IdentifierType,ProductCreator > SimpleFactory;
|
||||
typedef QMap<IdentifierType,Attribs> AliasMap;
|
||||
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);
|
||||
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>>;
|
||||
|
||||
public:
|
||||
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){
|
||||
return SimpleFactory::unregisterCreator(id)&&(m_attribsMap.remove(id)==1);
|
||||
bool unregisterCreator(const IdentifierType& id)
|
||||
{
|
||||
return SimpleFactory::unregisterCreator(id) && (m_attribsMap.remove(id) == 1);
|
||||
}
|
||||
QString attribs(const IdentifierType& id){
|
||||
if (m_attribsMap.contains(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;}
|
||||
const AliasMap& attribsMap() { return m_attribsMap; }
|
||||
|
||||
private:
|
||||
AliasMap m_attribsMap;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif //LRSIMPLEABSTRACTFACTORY_H
|
||||
#endif // LRSIMPLEABSTRACTFACTORY_H
|
||||
|
@ -32,28 +32,27 @@
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
template <typename T>
|
||||
class Singleton
|
||||
{
|
||||
template <typename T> class Singleton {
|
||||
public:
|
||||
static T& instance(){
|
||||
if (0==inst){
|
||||
static T& instance()
|
||||
{
|
||||
if (0 == inst) {
|
||||
inst = new T();
|
||||
::atexit( destroy );
|
||||
} else {};
|
||||
::atexit(destroy);
|
||||
} 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{
|
||||
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;
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
m_changeMode = m_connection != 0;
|
||||
}
|
||||
|
||||
ConnectionDialog::~ConnectionDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
ConnectionDialog::~ConnectionDialog() { delete ui; }
|
||||
|
||||
void ConnectionDialog::init()
|
||||
{
|
||||
@ -59,81 +63,84 @@ 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 (!m_connection){
|
||||
if (ui->cbAutoConnect->isChecked())
|
||||
checkConnection();
|
||||
if (!m_connection) {
|
||||
m_controller->addConnectionDesc(uiToConnection());
|
||||
} else {
|
||||
m_controller->changeConnectionDesc(uiToConnection(m_connection));
|
||||
}
|
||||
close();
|
||||
}
|
||||
catch(LimeReport::ReportError &exception){
|
||||
QMessageBox::critical(this,tr("Error"),exception.what());
|
||||
} catch (LimeReport::ReportError& exception) {
|
||||
QMessageBox::critical(this, tr("Error"), exception.what());
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectionDialog::slotCheckConnection()
|
||||
{
|
||||
try{
|
||||
try {
|
||||
checkConnection();
|
||||
QMessageBox::information(this,tr("Connection"),tr("Connection succsesfully established!"));
|
||||
} catch(LimeReport::ReportError &exception) {
|
||||
QMessageBox::critical(this,tr("Error"),exception.what());
|
||||
QMessageBox::information(this, tr("Connection"),
|
||||
tr("Connection succsesfully established!"));
|
||||
} catch (LimeReport::ReportError& exception) {
|
||||
QMessageBox::critical(this, tr("Error"), exception.what());
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectionDialog::checkFieldsFill()
|
||||
{
|
||||
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! "));
|
||||
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! "));
|
||||
}
|
||||
}
|
||||
|
||||
bool ConnectionDialog::checkConnection()
|
||||
{
|
||||
QScopedPointer<LimeReport::ConnectionDesc> con(uiToConnection());
|
||||
if (!m_controller->checkConnectionDesc(con.data())){
|
||||
if (!m_controller->checkConnectionDesc(con.data())) {
|
||||
throw LimeReport::ReportError(m_controller->lastError());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
ConnectionDesc *ConnectionDialog::uiToConnection(LimeReport::ConnectionDesc* conDesc)
|
||||
ConnectionDesc* ConnectionDialog::uiToConnection(LimeReport::ConnectionDesc* conDesc)
|
||||
{
|
||||
LimeReport::ConnectionDesc* result;
|
||||
if (conDesc)
|
||||
result = conDesc;
|
||||
else
|
||||
result = new LimeReport::ConnectionDesc();
|
||||
result ->setName(ConnectionDesc::connectionNameForReport(ui->leConnectionName->text()));
|
||||
result ->setHost(ui->leServerName->text());
|
||||
result->setName(ConnectionDesc::connectionNameForReport(ui->leConnectionName->text()));
|
||||
result->setHost(ui->leServerName->text());
|
||||
if (!ui->lePort->text().isEmpty())
|
||||
result->setPort(ui->lePort->text());
|
||||
result ->setDriver(ui->cbbDrivers->currentText());
|
||||
result ->setUserName(ui->leUserName->text());
|
||||
result ->setPassword(ui->lePassword->text());
|
||||
result ->setDatabaseName(ui->leDataBase->text());
|
||||
result ->setAutoconnect(ui->cbAutoConnect->isChecked());
|
||||
result->setDriver(ui->cbbDrivers->currentText());
|
||||
result->setUserName(ui->leUserName->text());
|
||||
result->setPassword(ui->lePassword->text());
|
||||
result->setDatabaseName(ui->leDataBase->text());
|
||||
result->setAutoconnect(ui->cbAutoConnect->isChecked());
|
||||
result->setKeepDBCredentials(!ui->cbbKeepCredentials->isChecked());
|
||||
return result ;
|
||||
return result;
|
||||
}
|
||||
|
||||
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());
|
||||
@ -151,7 +158,7 @@ void ConnectionDialog::on_toolButton_clicked()
|
||||
|
||||
void ConnectionDialog::on_cbbUseDefaultConnection_toggled(bool checked)
|
||||
{
|
||||
if (checked){
|
||||
if (checked) {
|
||||
m_savedConnectionName = ui->leConnectionName->text();
|
||||
ui->leConnectionName->setText(tr("defaultConnection"));
|
||||
ui->leConnectionName->setEnabled(false);
|
||||
@ -166,10 +173,3 @@ void ConnectionDialog::on_toolButton_2_toggled(bool checked)
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -30,27 +30,29 @@
|
||||
#ifndef LRCONNECTIONDIALOG_H
|
||||
#define LRCONNECTIONDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "lrdatadesignintf.h"
|
||||
|
||||
namespace LimeReport{
|
||||
#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 showEvent(QShowEvent*);
|
||||
void init();
|
||||
void checkFieldsFill();
|
||||
bool checkConnection();
|
||||
ConnectionDesc* uiToConnection(LimeReport::ConnectionDesc *conDesc = 0);
|
||||
ConnectionDesc* uiToConnection(LimeReport::ConnectionDesc* conDesc = 0);
|
||||
void connectionToUI();
|
||||
signals:
|
||||
void conectionRegistred(LimeReport::ConnectionDesc* connectionDesc);
|
||||
@ -63,7 +65,7 @@ private slots:
|
||||
void on_toolButton_2_toggled(bool checked);
|
||||
|
||||
private:
|
||||
Ui::ConnectionDialog *ui;
|
||||
Ui::ConnectionDialog* ui;
|
||||
ConnectionDesc* m_connection;
|
||||
bool m_changeMode;
|
||||
IConnectionController* m_controller;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -30,27 +30,25 @@
|
||||
#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"
|
||||
|
||||
namespace LimeReport{
|
||||
#include <QDockWidget>
|
||||
#include <QToolButton>
|
||||
#include <QTreeWidget>
|
||||
#include <QWidget>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
namespace Ui {
|
||||
class DataBrowser;
|
||||
}
|
||||
|
||||
class DataBrowser : public QWidget, public IConnectionController
|
||||
{
|
||||
class DataBrowser: public QWidget, public IConnectionController {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
explicit DataBrowser(QWidget *parent = 0);
|
||||
explicit DataBrowser(QWidget* parent = 0);
|
||||
~DataBrowser();
|
||||
QSize sizeHint() const;
|
||||
void setReportEditor(LimeReport::ReportDesignWidget* report);
|
||||
@ -62,7 +60,7 @@ public:
|
||||
void setSettings(QSettings* value, bool owned = false);
|
||||
QSettings* settings();
|
||||
QString lastError() const;
|
||||
void setLastError(const QString &lastError);
|
||||
void setLastError(const QString& lastError);
|
||||
|
||||
private slots:
|
||||
void slotDatasourcesChanged();
|
||||
@ -77,24 +75,27 @@ private slots:
|
||||
void slotDataWindowClosed();
|
||||
void slotChangeConnection();
|
||||
void slotChangeConnectionState();
|
||||
void slotVariableEditorAccept(const QString &variable);
|
||||
void on_dataTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||
void slotVariableEditorAccept(const QString& variable);
|
||||
void on_dataTree_currentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous);
|
||||
void on_editVariable_clicked();
|
||||
void on_deleteVariable_clicked();
|
||||
void on_addVariable_clicked();
|
||||
void on_variablesTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||
void on_variablesTree_currentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous);
|
||||
void on_errorMessage_clicked();
|
||||
void on_varToReport_clicked();
|
||||
void on_variablesTree_itemDoubleClicked(QTreeWidgetItem *item, int);
|
||||
void on_variablesTree_itemDoubleClicked(QTreeWidgetItem* item, int);
|
||||
|
||||
private:
|
||||
enum NameType{NameForUser, NameForReport};
|
||||
enum NameType {
|
||||
NameForUser,
|
||||
NameForReport
|
||||
};
|
||||
QString getDatasourceName();
|
||||
QString getConnectionName(NameType nameType);
|
||||
QString getVariable();
|
||||
bool isClosingWindows() const {return m_closingWindows;}
|
||||
QTreeWidgetItem * findByNameAndType(QString name, int itemType);
|
||||
void fillFields(QTreeWidgetItem *parentItem, LimeReport::IDataSource *dataSource);
|
||||
bool isClosingWindows() const { return m_closingWindows; }
|
||||
QTreeWidgetItem* findByNameAndType(QString name, int itemType);
|
||||
void fillFields(QTreeWidgetItem* parentItem, LimeReport::IDataSource* dataSource);
|
||||
QDockWidget* createDataWindow(QString datasourceName);
|
||||
void closeDataWindow(QString datasourceName);
|
||||
QDockWidget* dataWindow(QString datasourceName);
|
||||
@ -113,16 +114,16 @@ private:
|
||||
void applyChanges(SQLEditResult result);
|
||||
void addDatasource(SQLEditResult result);
|
||||
|
||||
void addConnectionDesc(ConnectionDesc *connection);
|
||||
void changeConnectionDesc(ConnectionDesc *connection);
|
||||
bool checkConnectionDesc(ConnectionDesc *connection);
|
||||
void addConnectionDesc(ConnectionDesc* connection);
|
||||
void changeConnectionDesc(ConnectionDesc* connection);
|
||||
bool checkConnectionDesc(ConnectionDesc* connection);
|
||||
bool containsDefaultConnection();
|
||||
void activateItem(const QString &name, DataBrowserTree::NodeType type);
|
||||
void activateItem(const QString& name, DataBrowserTree::NodeType type);
|
||||
|
||||
private:
|
||||
Ui::DataBrowser* ui;
|
||||
ReportDesignWidget* m_report;
|
||||
QMap<QString,QDockWidget*> m_dataWindows;
|
||||
QMap<QString, QDockWidget*> m_dataWindows;
|
||||
QMainWindow* m_mainWindow;
|
||||
bool m_closingWindows;
|
||||
QSettings* m_settings;
|
||||
@ -130,5 +131,5 @@ private:
|
||||
QString m_lastError;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRDATABROWSER_H
|
||||
|
@ -28,29 +28,30 @@
|
||||
* 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
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QMimeData* DataBrowserTree::mimeData(const QList<QTreeWidgetItem*>& items) const
|
||||
#else
|
||||
QMimeData *DataBrowserTree::mimeData(const QList<QTreeWidgetItem *> items) const
|
||||
QMimeData* DataBrowserTree::mimeData(const QList<QTreeWidgetItem*> items) const
|
||||
#endif
|
||||
{
|
||||
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()+"}");
|
||||
if (items.at(0)->type() == Row) {
|
||||
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)+"}");
|
||||
if (items.at(0)->type() == Variable) {
|
||||
result->setText("variable:$V{" + items.at(0)->text(0) + "}");
|
||||
}
|
||||
if (items.at(0)->type()==ExternalVariable){
|
||||
result->setText("variable:$V{"+items.at(0)->text(0)+"}");
|
||||
if (items.at(0)->type() == ExternalVariable) {
|
||||
result->setText("variable:$V{" + items.at(0)->text(0) + "}");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -32,24 +32,29 @@
|
||||
|
||||
#include <QTreeWidget>
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
|
||||
class DataBrowserTree : public QTreeWidget
|
||||
{
|
||||
class DataBrowserTree: public QTreeWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum NodeType{Connection, Table, Row, Category, Variable, ExternalVariable};
|
||||
explicit DataBrowserTree(QWidget *parent = 0);
|
||||
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;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
virtual QMimeData* mimeData(const QList<QTreeWidgetItem*>& items) const;
|
||||
#else
|
||||
virtual QMimeData *mimeData(const QList<QTreeWidgetItem*> items) const;
|
||||
virtual QMimeData* mimeData(const QList<QTreeWidgetItem*> items) const;
|
||||
#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);
|
||||
}
|
||||
}
|
||||
@ -126,22 +141,24 @@ void SQLEditDialog::accept() {
|
||||
check();
|
||||
emit signalSqlEditingFinished(result);
|
||||
QDialog::accept();
|
||||
} catch (LimeReport::ReportError &exception) {
|
||||
} catch (LimeReport::ReportError& exception) {
|
||||
QMessageBox::critical(this, tr("Error"), exception.what());
|
||||
}
|
||||
}
|
||||
|
||||
void SQLEditDialog::showEvent(QShowEvent *) {
|
||||
void SQLEditDialog::showEvent(QShowEvent*)
|
||||
{
|
||||
ui->lblInfo->setVisible(false);
|
||||
initConnections();
|
||||
readSettings();
|
||||
}
|
||||
|
||||
void SQLEditDialog::closeEvent(QCloseEvent *) { writeSetting(); }
|
||||
void SQLEditDialog::closeEvent(QCloseEvent*) { writeSetting(); }
|
||||
|
||||
void SQLEditDialog::hideEvent(QHideEvent *) { 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);
|
||||
@ -191,11 +214,11 @@ void SQLEditDialog::setDataSources(LimeReport::DataSourceManager *dataSources, Q
|
||||
}
|
||||
if (dataSources->isProxy(datasourceName)) {
|
||||
initProxyMode();
|
||||
LimeReport::ProxyDesc *proxyDesc = dataSources->proxyByName(datasourceName);
|
||||
LimeReport::ProxyDesc* proxyDesc = dataSources->proxyByName(datasourceName);
|
||||
ui->leChild->setText(proxyDesc->child());
|
||||
ui->leMaster->setText(proxyDesc->master());
|
||||
int curIndex = 0;
|
||||
foreach (LimeReport::FieldMapDesc *fields, *proxyDesc->fieldsMap()) {
|
||||
foreach (LimeReport::FieldMapDesc* fields, *proxyDesc->fieldsMap()) {
|
||||
ui->fieldsMap->setRowCount(curIndex + 1);
|
||||
ui->fieldsMap->setItem(curIndex, 0, new QTableWidgetItem(fields->master()));
|
||||
ui->fieldsMap->setItem(curIndex, 1, new QTableWidgetItem(fields->detail()));
|
||||
@ -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,15 +30,17 @@
|
||||
#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"
|
||||
|
||||
namespace LimeReport{
|
||||
#include <QCompleter>
|
||||
#include <QDialog>
|
||||
#include <QSettings>
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
namespace Ui {
|
||||
class SQLEditDialog;
|
||||
@ -46,22 +48,26 @@ 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);
|
||||
void setDataSources(LimeReport::DataSourceManager *dataSources,QString datasourceName="");
|
||||
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();
|
||||
QSettings* settings();
|
||||
void setSettings(QSettings* value, bool owned = false);
|
||||
signals:
|
||||
void signalSqlEditingFinished(SQLEditResult result);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *);
|
||||
void showEvent(QShowEvent*);
|
||||
void closeEvent(QCloseEvent*);
|
||||
void hideEvent(QHideEvent*);
|
||||
void check();
|
||||
@ -80,12 +86,14 @@ private slots:
|
||||
void initCSVMode();
|
||||
void slotPreviewData();
|
||||
void slotHidePreview();
|
||||
|
||||
private:
|
||||
void writeSetting();
|
||||
void readSettings();
|
||||
void hidePreview();
|
||||
|
||||
private:
|
||||
Ui::SQLEditDialog *ui;
|
||||
Ui::SQLEditDialog* ui;
|
||||
LimeReport::DataSourceManager* m_datasources;
|
||||
SQLDialogMode m_dialogMode;
|
||||
QString m_oldDatasourceName;
|
||||
@ -96,8 +104,14 @@ private:
|
||||
QSharedPointer<QAbstractItemModel> m_previewModel;
|
||||
};
|
||||
|
||||
struct SQLEditResult{
|
||||
enum ResultMode{Query, SubQuery, SubProxy, CSVText, Undefined};
|
||||
struct SQLEditResult {
|
||||
enum ResultMode {
|
||||
Query,
|
||||
SubQuery,
|
||||
SubProxy,
|
||||
CSVText,
|
||||
Undefined
|
||||
};
|
||||
QString connectionName;
|
||||
QString datasourceName;
|
||||
QString oldDatasourceName;
|
||||
|
@ -29,13 +29,16 @@
|
||||
****************************************************************************/
|
||||
#include "lrvariabledialog.h"
|
||||
#include "ui_lrvariabledialog.h"
|
||||
|
||||
#include "lrglobal.h"
|
||||
#include "lrvariablesholder.h"
|
||||
#include <stdexcept>
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QMetaEnum>
|
||||
|
||||
LRVariableDialog::LRVariableDialog(QWidget *parent) :
|
||||
#include <stdexcept>
|
||||
|
||||
LRVariableDialog::LRVariableDialog(QWidget* parent):
|
||||
QDialog(parent),
|
||||
ui(new Ui::LRVariableDialog),
|
||||
m_variableName(""),
|
||||
@ -45,43 +48,45 @@ 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){
|
||||
for (int i = 0; i < enumerator.keyCount(); ++i) {
|
||||
ui->cbbType->addItem(enumerator.key(i));
|
||||
}
|
||||
//ui->cbbType->setVisible(false);
|
||||
//ui->lblType->setVisible(false);
|
||||
// ui->cbbType->setVisible(false);
|
||||
// ui->lblType->setVisible(false);
|
||||
}
|
||||
|
||||
LRVariableDialog::~LRVariableDialog()
|
||||
LRVariableDialog::~LRVariableDialog() { delete ui; }
|
||||
|
||||
void LRVariableDialog::setVariableContainer(LimeReport::IVariablesContainer* value)
|
||||
{
|
||||
delete ui;
|
||||
m_variablesContainer = value;
|
||||
}
|
||||
|
||||
void LRVariableDialog::setVariableContainer(LimeReport::IVariablesContainer *value)
|
||||
void LRVariableDialog::setVariableName(const QString& value)
|
||||
{
|
||||
m_variablesContainer=value;
|
||||
m_variableName = value;
|
||||
m_changeMode = true;
|
||||
m_oldVariableName = value;
|
||||
}
|
||||
|
||||
void LRVariableDialog::setVariableName(const QString &value)
|
||||
{
|
||||
m_variableName=value;
|
||||
m_changeMode=true;
|
||||
m_oldVariableName=value;
|
||||
}
|
||||
|
||||
void LRVariableDialog::showEvent(QShowEvent *)
|
||||
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));
|
||||
}
|
||||
@ -89,35 +94,36 @@ void LRVariableDialog::showEvent(QShowEvent *)
|
||||
|
||||
void LRVariableDialog::accept()
|
||||
{
|
||||
try{
|
||||
static int enumIndex = LimeReport::Enums::staticMetaObject.indexOfEnumerator("VariableDataType");
|
||||
try {
|
||||
static int enumIndex
|
||||
= LimeReport::Enums::staticMetaObject.indexOfEnumerator("VariableDataType");
|
||||
QMetaEnum enumerator = LimeReport::Enums::staticMetaObject.enumerator(enumIndex);
|
||||
|
||||
if (m_variablesContainer&&!ui->leName->text().isEmpty()){
|
||||
if (m_changeMode){
|
||||
if (m_oldVariableName==ui->leName->text()){
|
||||
m_variablesContainer->changeVariable(m_oldVariableName,value());
|
||||
if (m_variablesContainer && !ui->leName->text().isEmpty()) {
|
||||
if (m_changeMode) {
|
||||
if (m_oldVariableName == ui->leName->text()) {
|
||||
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();
|
||||
}
|
||||
} catch (LimeReport::ReportError &exception){
|
||||
QMessageBox::critical(this,tr("Attention"),exception.what());
|
||||
} catch (LimeReport::ReportError& exception) {
|
||||
QMessageBox::critical(this, tr("Attention"), exception.what());
|
||||
}
|
||||
}
|
||||
|
||||
QVariant LRVariableDialog::value()
|
||||
{
|
||||
return ui->leValue->toPlainText();
|
||||
}
|
||||
QVariant LRVariableDialog::value() { return ui->leValue->toPlainText(); }
|
||||
|
@ -30,32 +30,35 @@
|
||||
#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:
|
||||
explicit LRVariableDialog(QWidget *parent = 0);
|
||||
explicit LRVariableDialog(QWidget* parent = 0);
|
||||
~LRVariableDialog();
|
||||
void setVariableContainer(LimeReport::IVariablesContainer *value);
|
||||
void setVariableName(const QString &value);
|
||||
void setVariableContainer(LimeReport::IVariablesContainer* value);
|
||||
void setVariableName(const QString& value);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *);
|
||||
void showEvent(QShowEvent*);
|
||||
private slots:
|
||||
void accept();
|
||||
signals:
|
||||
void signalVariableAccepted(const QString &variable);
|
||||
void signalVariableAccepted(const QString& variable);
|
||||
|
||||
private:
|
||||
QVariant value();
|
||||
|
||||
private:
|
||||
Ui::LRVariableDialog *ui;
|
||||
Ui::LRVariableDialog* ui;
|
||||
QString m_variableName;
|
||||
LimeReport::IVariablesContainer* m_variablesContainer;
|
||||
bool m_changeMode;
|
||||
|
@ -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,15 +19,17 @@
|
||||
#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{
|
||||
namespace LimeReport {
|
||||
|
||||
DialogDesignerManager::DialogDesignerManager(QObject *parent) : QObject(parent)
|
||||
DialogDesignerManager::DialogDesignerManager(QObject* parent): QObject(parent)
|
||||
{
|
||||
QDesignerComponents::initializeResources();
|
||||
m_formEditor = QDesignerComponents::createFormEditor(this);
|
||||
@ -43,20 +42,21 @@ 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 ) )
|
||||
{
|
||||
if ( !fep->isInitialized() )
|
||||
fep->initialize( m_formEditor );
|
||||
fep->action()->setCheckable( true );
|
||||
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);
|
||||
fep->action()->setIcon(QIcon(iconPathByName(fep->action()->objectName())));
|
||||
m_modes->addAction(fep->action());
|
||||
}
|
||||
@ -68,54 +68,57 @@ DialogDesignerManager::DialogDesignerManager(QObject *parent) : QObject(parent)
|
||||
m_formEditor->setWidgetBox(m_widgetBox);
|
||||
m_formEditor->setTopLevel(m_widgetBox);
|
||||
m_designerToolWindows.append(m_widgetBox);
|
||||
connect(m_widgetBox, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)) );
|
||||
connect(m_widgetBox, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)));
|
||||
|
||||
m_objectInspector = QDesignerComponents::createObjectInspector(m_formEditor, 0);
|
||||
m_objectInspector->setWindowTitle(tr("Object Inspector"));
|
||||
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"));
|
||||
m_actionEditor->setObjectName("ActionEditor");
|
||||
m_formEditor->setActionEditor(m_actionEditor);
|
||||
m_designerToolWindows.append(m_actionEditor);
|
||||
connect(m_actionEditor, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)) );
|
||||
connect(m_actionEditor, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)));
|
||||
|
||||
#if QT_VERSION < 0x050000
|
||||
m_designerIntegration = new qdesigner_internal::QDesignerIntegration(m_formEditor,this);
|
||||
m_designerIntegration = new qdesigner_internal::QDesignerIntegration(m_formEditor, this);
|
||||
#else
|
||||
m_designerIntegration = new QDesignerIntegration(m_formEditor,this);
|
||||
m_designerIntegration = new QDesignerIntegration(m_formEditor, this);
|
||||
#endif
|
||||
m_formEditor->setIntegration(m_designerIntegration);
|
||||
|
||||
}
|
||||
|
||||
DialogDesignerManager::~DialogDesignerManager()
|
||||
{
|
||||
for (int i = 0; i<m_designerToolWindows.size();++i){
|
||||
for (int i = 0; i < m_designerToolWindows.size(); ++i) {
|
||||
if (m_designerToolWindows[i])
|
||||
delete m_designerToolWindows[i];
|
||||
}
|
||||
@ -124,9 +127,9 @@ DialogDesignerManager::~DialogDesignerManager()
|
||||
delete m_formEditor;
|
||||
}
|
||||
|
||||
void DialogDesignerManager::initToolBar(QToolBar *tb)
|
||||
void DialogDesignerManager::initToolBar(QToolBar* tb)
|
||||
{
|
||||
tb->setIconSize(QSize(16,16));
|
||||
tb->setIconSize(QSize(16, 16));
|
||||
m_formEditor->formWindowManager()->actionCopy()->setIcon(QIcon(":/report/images/copy"));
|
||||
tb->addAction(m_formEditor->formWindowManager()->actionCopy());
|
||||
m_formEditor->formWindowManager()->actionPaste()->setIcon(QIcon(":/report/images/paste"));
|
||||
@ -145,15 +148,17 @@ 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());
|
||||
}
|
||||
|
||||
QWidget *DialogDesignerManager::createFormEditor(const QString &content)
|
||||
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,79 +167,61 @@ 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)
|
||||
QByteArray DialogDesignerManager::getDialogDescription(QWidget* form)
|
||||
{
|
||||
QByteArray result;
|
||||
DialogDesigner* dialogDesigner = dynamic_cast<DialogDesigner*>(form);
|
||||
Q_ASSERT(dialogDesigner != NULL);
|
||||
//SharedTools::WidgetHost* wh = dynamic_cast<SharedTools::WidgetHost*>(form);
|
||||
if (dialogDesigner){
|
||||
// SharedTools::WidgetHost* wh = dynamic_cast<SharedTools::WidgetHost*>(form);
|
||||
if (dialogDesigner) {
|
||||
result = dialogDesigner->dialogContent();
|
||||
//wh->formWindow()->setDirty(false);
|
||||
// wh->formWindow()->setDirty(false);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void DialogDesignerManager::setActiveEditor(QWidget *widget)
|
||||
void DialogDesignerManager::setActiveEditor(QWidget* widget)
|
||||
{
|
||||
SharedTools::WidgetHost* wh = dynamic_cast<SharedTools::WidgetHost*>(widget);
|
||||
if (wh){
|
||||
if (wh) {
|
||||
m_formEditor->formWindowManager()->setActiveFormWindow(wh->formWindow());
|
||||
}
|
||||
}
|
||||
|
||||
void DialogDesignerManager::setDirty(bool value)
|
||||
{
|
||||
foreach(DialogDesigner* dialogDesigner, m_dialogDesigners){
|
||||
foreach (DialogDesigner* dialogDesigner, m_dialogDesigners) {
|
||||
dialogDesigner->setChanged(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)
|
||||
{
|
||||
|
||||
QList<DialogDesigner*>::Iterator it = m_dialogDesigners.begin();
|
||||
while(it!=m_dialogDesigners.end()){
|
||||
if (*it == object){
|
||||
while (it != m_dialogDesigners.end()) {
|
||||
if (*it == object) {
|
||||
it = m_dialogDesigners.erase(it);
|
||||
return;
|
||||
} else {
|
||||
@ -242,22 +229,22 @@ 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];
|
||||
for (int i = 0; i < m_designerToolWindows.size(); ++i) {
|
||||
m_designerToolWindows[i]
|
||||
= m_designerToolWindows[i] == object ? 0 : m_designerToolWindows[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void DialogDesignerManager::slotEditWidgets()
|
||||
{
|
||||
for (int i = 0; i<m_formEditor->formWindowManager()->formWindowCount(); ++i){
|
||||
for (int i = 0; i < m_formEditor->formWindowManager()->formWindowCount(); ++i) {
|
||||
m_formEditor->formWindowManager()->formWindow(i)->editWidgets();
|
||||
}
|
||||
}
|
||||
|
||||
void DialogDesignerManager::slotActiveFormWindowChanged(QDesignerFormWindowInterface *formWindow)
|
||||
void DialogDesignerManager::slotActiveFormWindowChanged(QDesignerFormWindowInterface* formWindow)
|
||||
{
|
||||
if (formWindow){
|
||||
if (formWindow) {
|
||||
m_editWidgetsAction->setEnabled(true);
|
||||
m_editWidgetsAction->trigger();
|
||||
m_editWidgetsAction->setChecked(true);
|
||||
@ -265,7 +252,7 @@ void DialogDesignerManager::slotActiveFormWindowChanged(QDesignerFormWindowInter
|
||||
}
|
||||
}
|
||||
|
||||
QString DialogDesignerManager::iconPathByName(const QString &name)
|
||||
QString DialogDesignerManager::iconPathByName(const QString& name)
|
||||
{
|
||||
if (name.compare("__qt_edit_signals_slots_action") == 0)
|
||||
return ":/images/images/signalslottool.png";
|
||||
@ -276,43 +263,33 @@ 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()));
|
||||
|
||||
m_designerHolder = new SharedTools::WidgetHost(this,wnd);
|
||||
m_designerHolder->setFrameStyle( QFrame::NoFrame | QFrame::Plain );
|
||||
m_designerHolder->setFocusProxy( wnd );
|
||||
m_designerHolder = new SharedTools::WidgetHost(this, wnd);
|
||||
m_designerHolder->setFrameStyle(QFrame::NoFrame | QFrame::Plain);
|
||||
m_designerHolder->setFocusProxy(wnd);
|
||||
|
||||
QVBoxLayout* l = new QVBoxLayout(this);
|
||||
l->addWidget(m_designerHolder);
|
||||
setLayout(l);
|
||||
|
||||
}
|
||||
|
||||
DialogDesigner::~DialogDesigner(){}
|
||||
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()
|
||||
{
|
||||
@ -324,7 +301,7 @@ QByteArray DialogDesigner::dialogContent()
|
||||
void DialogDesigner::undo()
|
||||
{
|
||||
Q_ASSERT(m_formEditor != NULL);
|
||||
if (m_formEditor){
|
||||
if (m_formEditor) {
|
||||
m_formEditor->formWindowManager()->actionUndo()->trigger();
|
||||
}
|
||||
}
|
||||
@ -332,14 +309,14 @@ void DialogDesigner::undo()
|
||||
void DialogDesigner::redo()
|
||||
{
|
||||
Q_ASSERT(m_formEditor != NULL);
|
||||
if (m_formEditor){
|
||||
if (m_formEditor) {
|
||||
m_formEditor->formWindowManager()->actionRedo()->trigger();
|
||||
}
|
||||
}
|
||||
|
||||
void DialogDesigner::slotMainContainerNameChanged(QString newName)
|
||||
{
|
||||
if (m_dialogName.compare(newName) != 0){
|
||||
if (m_dialogName.compare(newName) != 0) {
|
||||
emit dialogNameChanged(m_dialogName, newName);
|
||||
m_dialogName = newName;
|
||||
}
|
||||
@ -348,9 +325,11 @@ void DialogDesigner::slotMainContainerNameChanged(QString newName)
|
||||
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 && m_designerHolder->formWindow()) {
|
||||
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;
|
||||
@ -15,19 +15,20 @@ class QDesignerPropertyEditorInterface;
|
||||
class QDesignerObjectInspectorInterface;
|
||||
class QDesignerFormWindowManagerInterface;
|
||||
|
||||
namespace SharedTools{
|
||||
class WidgetHost;
|
||||
namespace SharedTools {
|
||||
class WidgetHost;
|
||||
}
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class DialogDesigner : public QWidget{
|
||||
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);
|
||||
void setDialogName(const QString& dialogName);
|
||||
bool isChanged();
|
||||
void setChanged(bool value);
|
||||
QByteArray dialogContent();
|
||||
@ -40,17 +41,17 @@ 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);
|
||||
explicit DialogDesignerManager(QObject* parent = 0);
|
||||
~DialogDesignerManager();
|
||||
void initToolBar(QToolBar* tb);
|
||||
QWidget* createFormEditor(const QString& content);
|
||||
@ -69,9 +70,11 @@ signals:
|
||||
private slots:
|
||||
void slotObjectDestroyed(QObject* object);
|
||||
void slotEditWidgets();
|
||||
void slotActiveFormWindowChanged(QDesignerFormWindowInterface *formWindow);
|
||||
void slotActiveFormWindowChanged(QDesignerFormWindowInterface* formWindow);
|
||||
|
||||
private:
|
||||
QString iconPathByName(const QString& name);
|
||||
|
||||
private:
|
||||
QDesignerFormEditorInterface* m_formEditor;
|
||||
QDesignerIntegrationInterface* m_designerIntegration;
|
||||
|
@ -1,32 +1,36 @@
|
||||
#include <QPrinter>
|
||||
|
||||
#include "lrpdfexporter.h"
|
||||
|
||||
#include "lrexportersfactory.h"
|
||||
#include "lrreportengine_p.h"
|
||||
|
||||
namespace{
|
||||
#include <QPrinter>
|
||||
|
||||
LimeReport::ReportExporterInterface* createPDFExporter(LimeReport::ReportEnginePrivate* parent){
|
||||
namespace {
|
||||
|
||||
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{
|
||||
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()){
|
||||
if (!fileName.isEmpty()) {
|
||||
QPrinter printer;
|
||||
printer.setOutputFileName(fileName);
|
||||
printer.setOutputFormat(QPrinter::PdfFormat);
|
||||
if (!pages.isEmpty()){
|
||||
if (!pages.isEmpty()) {
|
||||
m_reportEngine->printPages(pages, &printer);
|
||||
}
|
||||
m_reportEngine->emitPrintedToPDF(fileName);
|
||||
@ -35,4 +39,4 @@ bool PDFExporter::exportPages(ReportPages pages, const QString &fileName, const
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
@ -1,35 +1,28 @@
|
||||
#ifndef LRPDFEXPORTER_H
|
||||
#define LRPDFEXPORTER_H
|
||||
|
||||
#include <QObject>
|
||||
#include "lrexporterintf.h"
|
||||
|
||||
namespace LimeReport{
|
||||
#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);
|
||||
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;
|
||||
};
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRPDFEXPORTER_H
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "lrgridlineschart.h"
|
||||
|
||||
namespace LimeReport {
|
||||
void GridLinesChart::paintChart(QPainter *painter, QRectF chartRect)
|
||||
void GridLinesChart::paintChart(QPainter* painter, QRectF chartRect)
|
||||
{
|
||||
updateMinAndMaxValues();
|
||||
|
||||
@ -10,22 +10,18 @@ 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
|
||||
gridRect.adjust(0, -valuesVMargin, 0 , -valuesVMargin);
|
||||
gridRect.adjust(0, -valuesVMargin, 0, -valuesVMargin);
|
||||
}
|
||||
|
||||
// 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,23 +30,21 @@ 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);
|
||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
const AxisData &yAxisData = this->yAxisData();
|
||||
const AxisData& yAxisData = this->yAxisData();
|
||||
const qreal delta = yAxisData.delta();
|
||||
|
||||
if (m_chartItem->itemMode() == DesignMode){
|
||||
if (m_chartItem->itemMode() == DesignMode) {
|
||||
const qreal hStep = barsRect.width() / valuesCount();
|
||||
const qreal vStep = barsRect.height() / delta;
|
||||
const qreal topShift = (delta - (maxValue() - minValue())) * vStep + barsRect.top();
|
||||
@ -59,7 +53,7 @@ void GridLinesChart::paintSerialLines(QPainter* painter, QRectF barsRect)
|
||||
return;
|
||||
}
|
||||
|
||||
const AxisData &xAxisData = this->xAxisData();
|
||||
const AxisData& xAxisData = this->xAxisData();
|
||||
const qreal hStep = barsRect.width() / (xAxisData.rangeMax() - xAxisData.rangeMin());
|
||||
|
||||
qreal leftMargin = 0;
|
||||
@ -70,8 +64,8 @@ void GridLinesChart::paintSerialLines(QPainter* painter, QRectF barsRect)
|
||||
pen.setWidth(m_chartItem->seriesLineWidth());
|
||||
painter->setPen(pen);
|
||||
|
||||
const QList<qreal> &xAxisValues = series->data()->xAxisValues();
|
||||
const QList<qreal> &values = series->data()->values();
|
||||
const QList<qreal>& xAxisValues = series->data()->xAxisValues();
|
||||
const QList<qreal>& values = series->data()->values();
|
||||
const int xAxisValuesSize = xAxisValues.size();
|
||||
qreal lastXPos = 0;
|
||||
qreal lastYPos = 0;
|
||||
@ -85,16 +79,16 @@ void GridLinesChart::paintSerialLines(QPainter* painter, QRectF barsRect)
|
||||
leftMargin = barsRect.left();
|
||||
lastXPos = calculatePos(xAxisData, xAxisValues.first(), barsRect.width());
|
||||
}
|
||||
for (int i = 0; i < values.count() - 1; ++i ) {
|
||||
for (int i = 0; i < values.count() - 1; ++i) {
|
||||
const qreal startY = lastYPos;
|
||||
const qreal endY = calculatePos(yAxisData, values.at(i+1), barsRect.height());
|
||||
const qreal endY = calculatePos(yAxisData, values.at(i + 1), barsRect.height());
|
||||
// Record last used Y position to only calculate new one
|
||||
lastYPos = endY;
|
||||
|
||||
qreal startX = lastXPos;
|
||||
qreal endX = 0;
|
||||
if (i + 1 < xAxisValuesSize) {
|
||||
endX = calculatePos(xAxisData, xAxisValues.at(i+1), barsRect.width());
|
||||
endX = calculatePos(xAxisData, xAxisValues.at(i + 1), barsRect.width());
|
||||
} else {
|
||||
endX = startX + hStep;
|
||||
}
|
||||
@ -109,4 +103,4 @@ void GridLinesChart::paintSerialLines(QPainter* painter, QRectF barsRect)
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
@ -4,14 +4,14 @@
|
||||
#include "lrlineschart.h"
|
||||
|
||||
namespace LimeReport {
|
||||
class GridLinesChart : public LinesChart{
|
||||
class GridLinesChart: public LinesChart {
|
||||
public:
|
||||
GridLinesChart(ChartItem* chartItem):LinesChart(chartItem){}
|
||||
void paintChart(QPainter *painter, QRectF chartRect);
|
||||
GridLinesChart(ChartItem* chartItem): LinesChart(chartItem) { }
|
||||
void paintChart(QPainter* painter, QRectF chartRect);
|
||||
|
||||
private:
|
||||
void paintSerialLines(QPainter *painter, QRectF barsRect);
|
||||
void paintSerialLines(QPainter* painter, QRectF barsRect);
|
||||
};
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // GRIDLINESCHART_H
|
||||
|
@ -1,52 +1,49 @@
|
||||
#include "lrhorizontalbarchart.h"
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
void HorizontalBarChart::paintChart(QPainter *painter, QRectF chartRect)
|
||||
void HorizontalBarChart::paintChart(QPainter* painter, QRectF chartRect)
|
||||
{
|
||||
updateMinAndMaxValues();
|
||||
|
||||
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)
|
||||
void HorizontalBarChart::paintHorizontalBars(QPainter* painter, QRectF barsRect)
|
||||
{
|
||||
if (seriesCount() == 0) return;
|
||||
if (seriesCount() == 0)
|
||||
return;
|
||||
|
||||
painter->save();
|
||||
painter->setRenderHint(QPainter::Antialiasing,false);
|
||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||
|
||||
const AxisData &yAxisData = this->yAxisData();
|
||||
const AxisData& yAxisData = this->yAxisData();
|
||||
const qreal delta = yAxisData.delta();
|
||||
|
||||
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)){
|
||||
if (!m_chartItem->series().isEmpty() && (m_chartItem->itemMode() != DesignMode)) {
|
||||
qreal curVOffset = barsRect.top();
|
||||
if (m_chartItem->horizontalAxisOnTop()) {
|
||||
curVOffset += verticalOffset;
|
||||
@ -55,8 +52,9 @@ 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));
|
||||
y+=vStep*seriesCount();
|
||||
painter->drawRect(
|
||||
QRectF((-minValue() * hStep) + barsRect.left(), y, value * hStep, vStep));
|
||||
y += vStep * seriesCount();
|
||||
}
|
||||
curVOffset += vStep;
|
||||
}
|
||||
@ -66,15 +64,17 @@ void HorizontalBarChart::paintHorizontalBars(QPainter *painter, QRectF barsRect)
|
||||
curVOffset += verticalOffset;
|
||||
}
|
||||
int curColor = 0;
|
||||
for (int i=0; i<9; ++i){
|
||||
if (curColor==3) curColor=0;
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
if (curColor == 3)
|
||||
curColor = 0;
|
||||
painter->setBrush(color_map[curColor]);
|
||||
painter->drawRect(QRectF(barsRect.left(), curVOffset, designValues()[i]*hStep, vStep));
|
||||
curVOffset+=vStep;
|
||||
painter->drawRect(
|
||||
QRectF(barsRect.left(), curVOffset, designValues()[i] * hStep, vStep));
|
||||
curVOffset += vStep;
|
||||
curColor++;
|
||||
}
|
||||
}
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
@ -3,13 +3,13 @@
|
||||
|
||||
#include "lrchartitem.h"
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class HorizontalBarChart: public AbstractBarChart{
|
||||
class HorizontalBarChart: public AbstractBarChart {
|
||||
public:
|
||||
HorizontalBarChart(ChartItem* chartItem):AbstractBarChart(chartItem){}
|
||||
void paintChart(QPainter *painter, QRectF chartRect);
|
||||
void paintHorizontalBars(QPainter *painter, QRectF barsRect);
|
||||
HorizontalBarChart(ChartItem* chartItem): AbstractBarChart(chartItem) { }
|
||||
void paintChart(QPainter* painter, QRectF chartRect);
|
||||
void paintHorizontalBars(QPainter* painter, QRectF barsRect);
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
void LinesChart::paintChart(QPainter *painter, QRectF chartRect)
|
||||
void LinesChart::paintChart(QPainter* painter, QRectF chartRect)
|
||||
{
|
||||
updateMinAndMaxValues();
|
||||
|
||||
@ -11,64 +11,47 @@ 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){
|
||||
for (int i = 0; i < valuesCount()-1; ++i){
|
||||
QPoint startPoint = QPoint((i+1) * hStep + barsRect.left() - hStep/2,
|
||||
(maxValue() * vStep+topShift) - designValues()[i] * vStep
|
||||
);
|
||||
QPoint endPoint = QPoint((i+2) * hStep + barsRect.left() - hStep/2,
|
||||
(maxValue() * vStep+topShift) - designValues()[i+1] * vStep
|
||||
);
|
||||
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);
|
||||
QPoint endPoint = QPoint((i + 2) * hStep + barsRect.left() - hStep / 2,
|
||||
(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
|
||||
);
|
||||
endPoint = QPoint((i+2) * hStep + barsRect.left() - hStep/2,
|
||||
(maxValue() * vStep+topShift) - designValues()[i+3+1] * vStep
|
||||
);
|
||||
startPoint = QPoint((i + 1) * hStep + barsRect.left() - hStep / 2,
|
||||
(maxValue() * vStep + topShift) - designValues()[i + 3] * vStep);
|
||||
endPoint = QPoint((i + 2) * hStep + barsRect.left() - hStep / 2,
|
||||
(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
|
||||
);
|
||||
endPoint = QPoint((i+2) * hStep + barsRect.left() - hStep/2,
|
||||
(maxValue() * vStep+topShift) - designValues()[i+6+1] * vStep
|
||||
);
|
||||
startPoint = QPoint((i + 1) * hStep + barsRect.left() - hStep / 2,
|
||||
(maxValue() * vStep + topShift) - designValues()[i + 6] * vStep);
|
||||
endPoint = QPoint((i + 2) * hStep + barsRect.left() - hStep / 2,
|
||||
(maxValue() * vStep + topShift) - designValues()[i + 6 + 1] * vStep);
|
||||
drawSegment(painter, startPoint, endPoint, color_map[2]);
|
||||
}
|
||||
}
|
||||
|
||||
qreal LinesChart::calculatePos(const AxisData &data, qreal value, qreal rectSize) const
|
||||
qreal LinesChart::calculatePos(const AxisData& data, qreal value, qreal rectSize) const
|
||||
{
|
||||
if (data.type() == AxisData::XAxis || (data.reverseDirection() && data.rangeMin() >= 0)) {
|
||||
// Not flipping for minimum less than 0 because lower number is at the bottom.
|
||||
@ -78,10 +61,10 @@ qreal LinesChart::calculatePos(const AxisData &data, qreal value, qreal rectSize
|
||||
}
|
||||
}
|
||||
|
||||
void LinesChart::paintSeries(QPainter *painter, SeriesItem *series, QRectF barsRect)
|
||||
void LinesChart::paintSeries(QPainter* painter, SeriesItem* series, QRectF barsRect)
|
||||
{
|
||||
const AxisData &yAxisData = this->yAxisData();
|
||||
const AxisData &xAxisData = this->xAxisData();
|
||||
const AxisData& yAxisData = this->yAxisData();
|
||||
const AxisData& xAxisData = this->xAxisData();
|
||||
|
||||
const qreal xAxisDiff = std::max(1.0, xAxisData.maxValue() - xAxisData.minValue());
|
||||
const qreal hStep = barsRect.width() / xAxisDiff;
|
||||
@ -91,17 +74,17 @@ void LinesChart::paintSeries(QPainter *painter, SeriesItem *series, QRectF barsR
|
||||
pen.setWidth(4);
|
||||
painter->setPen(pen);
|
||||
|
||||
const QList<qreal> &values = series->data()->values();
|
||||
const QList<qreal>& values = series->data()->values();
|
||||
|
||||
qreal lastYValue = 0;
|
||||
qreal lastXValue = barsRect.left() + hStep/2;
|
||||
qreal lastXValue = barsRect.left() + hStep / 2;
|
||||
if (!values.isEmpty()) {
|
||||
// Calculate first point position on plot before loop
|
||||
lastYValue = calculatePos(yAxisData, values.first(), barsRect.height());
|
||||
}
|
||||
for (int i = 0; i < values.count()-1; ++i ){
|
||||
for (int i = 0; i < values.count() - 1; ++i) {
|
||||
const qreal startY = lastYValue;
|
||||
const qreal endY = calculatePos(yAxisData, values.at(i+1), barsRect.height());
|
||||
const qreal endY = calculatePos(yAxisData, values.at(i + 1), barsRect.height());
|
||||
// Record last used Y position to only calculate new one
|
||||
lastYValue = endY;
|
||||
|
||||
@ -118,13 +101,14 @@ 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);
|
||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
if (m_chartItem->itemMode() == DesignMode){
|
||||
const AxisData &yAxisData = this->yAxisData();
|
||||
if (m_chartItem->itemMode() == DesignMode) {
|
||||
const AxisData& yAxisData = this->yAxisData();
|
||||
const qreal delta = yAxisData.delta();
|
||||
const qreal hStep = barsRect.width() / valuesCount();
|
||||
const qreal vStep = barsRect.height() / delta;
|
||||
@ -134,12 +118,11 @@ void LinesChart::paintSerialLines(QPainter* painter, QRectF barsRect)
|
||||
return;
|
||||
}
|
||||
|
||||
for (SeriesItem *series : m_chartItem->series()) {
|
||||
for (SeriesItem* series : m_chartItem->series()) {
|
||||
paintSeries(painter, series, barsRect);
|
||||
}
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
} //namespace LimeReport
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -4,18 +4,20 @@
|
||||
#include "lrchartitem.h"
|
||||
|
||||
namespace LimeReport {
|
||||
class LinesChart: public AbstractBarChart{
|
||||
class LinesChart: public AbstractBarChart {
|
||||
public:
|
||||
LinesChart(ChartItem* chartItem):AbstractBarChart(chartItem){}
|
||||
void paintChart(QPainter *painter, QRectF chartRect);
|
||||
LinesChart(ChartItem* chartItem): AbstractBarChart(chartItem) { }
|
||||
void paintChart(QPainter* painter, QRectF chartRect);
|
||||
|
||||
protected:
|
||||
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);
|
||||
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);
|
||||
void paintSerialLines(QPainter* painter, QRectF barsRect);
|
||||
};
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LINESCHART_H
|
||||
|
@ -1,36 +1,36 @@
|
||||
#include "lrpiechart.h"
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
void PieChart::drawPercent(QPainter *painter, QRectF chartRect, qreal startAngle, qreal angle)
|
||||
void PieChart::drawPercent(QPainter* painter, QRectF chartRect, qreal startAngle, qreal angle)
|
||||
{
|
||||
painter->save();
|
||||
|
||||
QPointF center(chartRect.left()+chartRect.width()/2,chartRect.top()+chartRect.height()/2);
|
||||
qreal percent = angle/3.6;
|
||||
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);
|
||||
qreal radAngle = (angle / 2 + startAngle) * (M_PI / 180);
|
||||
#else
|
||||
qreal radAngle = qDegreesToRadians(angle/2+startAngle);
|
||||
qreal radAngle = qDegreesToRadians(angle / 2 + startAngle);
|
||||
#endif
|
||||
qreal radius = painter->fontMetrics().boundingRect("99,9%").width();
|
||||
qreal border = chartRect.height()*0.02;
|
||||
qreal length = (chartRect.height())/2-(radius/2+border);
|
||||
qreal x,y;
|
||||
x = length*qCos(radAngle);
|
||||
y = length*qSin(radAngle);
|
||||
QPointF endPoint(center.x()+x,center.y()-y);
|
||||
qreal border = chartRect.height() * 0.02;
|
||||
qreal length = (chartRect.height()) / 2 - (radius / 2 + border);
|
||||
qreal x, y;
|
||||
x = length * qCos(radAngle);
|
||||
y = length * qSin(radAngle);
|
||||
QPointF endPoint(center.x() + x, center.y() - y);
|
||||
painter->setPen(Qt::white);
|
||||
QRectF textRect(endPoint.x()-(radius/2),endPoint.y()-(radius/2),radius,radius);
|
||||
QRectF textRect(endPoint.x() - (radius / 2), endPoint.y() - (radius / 2), radius, radius);
|
||||
|
||||
qreal arcLength = 3.14 * length * angle / 180;
|
||||
if (arcLength >= radius)
|
||||
painter->drawText(textRect,Qt::AlignCenter,QString::number(percent,'f',1)+"%");
|
||||
painter->drawText(textRect, Qt::AlignCenter, QString::number(percent, 'f', 1) + "%");
|
||||
painter->restore();
|
||||
|
||||
}
|
||||
|
||||
void PieChart::paintChart(QPainter *painter, QRectF chartRect)
|
||||
void PieChart::paintChart(QPainter* painter, QRectF chartRect)
|
||||
{
|
||||
painter->save();
|
||||
QPen pen(Qt::white);
|
||||
@ -42,10 +42,10 @@ void PieChart::paintChart(QPainter *painter, QRectF chartRect)
|
||||
painter->setBackground(QBrush(Qt::NoBrush));
|
||||
|
||||
QRectF tmpRect = chartRect;
|
||||
if (chartRect.height()>chartRect.width()){
|
||||
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,31 +53,32 @@ 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()){
|
||||
sum+=value;
|
||||
foreach (qreal value, si->data()->values()) {
|
||||
sum += value;
|
||||
}
|
||||
qreal onePercent = sum / 100;
|
||||
qreal currentDegree = 0;
|
||||
for(int i=0; i<si->data()->values().count(); ++i){
|
||||
for (int i = 0; i < si->data()->values().count(); ++i) {
|
||||
qreal value = si->data()->values().at(i);
|
||||
qreal sectorDegree = (value/onePercent)*3.6;
|
||||
qreal sectorDegree = (value / onePercent) * 3.6;
|
||||
painter->setBrush(si->data()->colors().at(i));
|
||||
painter->drawPie(chartRect,currentDegree*16,sectorDegree*16);
|
||||
painter->drawPie(chartRect, currentDegree * 16, sectorDegree * 16);
|
||||
drawPercent(painter, chartRect, currentDegree, sectorDegree);
|
||||
currentDegree += sectorDegree;
|
||||
}
|
||||
} else if (m_chartItem->itemMode() == DesignMode){
|
||||
} else if (m_chartItem->itemMode() == DesignMode) {
|
||||
painter->setBrush(color_map[0]);
|
||||
painter->drawPie(chartRect,0,260*16);
|
||||
painter->drawPie(chartRect, 0, 260 * 16);
|
||||
drawPercent(painter, chartRect, 0, 260);
|
||||
painter->setBrush(color_map[1]);
|
||||
painter->drawPie(chartRect,260*16,40*16);
|
||||
painter->drawPie(chartRect, 260 * 16, 40 * 16);
|
||||
drawPercent(painter, chartRect, 260, 40);
|
||||
painter->setBrush(color_map[2]);
|
||||
painter->drawPie(chartRect,300*16,60*16);
|
||||
painter->drawPie(chartRect, 300 * 16, 60 * 16);
|
||||
drawPercent(painter, chartRect, 300, 60);
|
||||
}
|
||||
|
||||
@ -89,83 +90,77 @@ void PieChart::paintChart(QPainter *painter, QRectF chartRect)
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
void PieChart::paintChartLegend(QPainter *painter, QRectF legendRect)
|
||||
void PieChart::paintChartLegend(QPainter* painter, QRectF legendRect)
|
||||
{
|
||||
prepareLegendToPaint(legendRect, painter);
|
||||
|
||||
int indicatorSize = painter->fontMetrics().height()/2;
|
||||
painter->setRenderHint(QPainter::Antialiasing,false);
|
||||
int indicatorSize = painter->fontMetrics().height() / 2;
|
||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||
|
||||
if (m_chartItem->drawLegendBorder())
|
||||
painter->drawRect(legendRect);
|
||||
|
||||
painter->setRenderHint(QPainter::Antialiasing,true);
|
||||
QRectF indicatorsRect = legendRect.adjusted(painter->fontMetrics().height()/2,painter->fontMetrics().height()/2,0,0);
|
||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||
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){
|
||||
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){
|
||||
} else if (m_chartItem->itemMode() == DesignMode) {
|
||||
qreal cw = 0;
|
||||
for (int i=0;i<m_designLabels.size();++i){
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
QSizeF PieChart::calcChartLegendSize(const QFont &font, qreal)
|
||||
QSizeF PieChart::calcChartLegendSize(const QFont& font, qreal)
|
||||
{
|
||||
QFontMetrics fm(font);
|
||||
|
||||
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()){
|
||||
foreach (QString label, si->data()->labels()) {
|
||||
cw += fm.height();
|
||||
if (maxWidth<fm.boundingRect(label).width())
|
||||
maxWidth = fm.boundingRect(label).width()+10;
|
||||
if (maxWidth < fm.boundingRect(label).width())
|
||||
maxWidth = fm.boundingRect(label).width() + 10;
|
||||
}
|
||||
} else {
|
||||
foreach(QString label, m_designLabels){
|
||||
foreach (QString label, m_designLabels) {
|
||||
cw += fm.height();
|
||||
if (maxWidth<fm.boundingRect(label).width())
|
||||
maxWidth = fm.boundingRect(label).width()+10;
|
||||
if (maxWidth < fm.boundingRect(label).width())
|
||||
maxWidth = fm.boundingRect(label).width() + 10;
|
||||
}
|
||||
}
|
||||
cw += fm.height();
|
||||
return QSizeF(maxWidth+fm.height()*2,cw);
|
||||
return QSizeF(maxWidth + fm.height() * 2, cw);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
@ -3,16 +3,17 @@
|
||||
|
||||
#include "lrchartitem.h"
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class PieChart : public AbstractChart{
|
||||
class PieChart: public AbstractChart {
|
||||
public:
|
||||
PieChart(ChartItem* chartItem):AbstractChart(chartItem){}
|
||||
QSizeF calcChartLegendSize(const QFont &font, qreal maxWidth = 0);
|
||||
void paintChart(QPainter *painter, QRectF chartRect);
|
||||
void paintChartLegend(QPainter *painter, QRectF legendRect);
|
||||
PieChart(ChartItem* chartItem): AbstractChart(chartItem) { }
|
||||
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);
|
||||
void drawPercent(QPainter* painter, QRectF chartRect, qreal startAngle, qreal angle);
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include "lrverticalbarchart.h"
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
void VerticalBarChart::paintChart(QPainter *painter, QRectF chartRect)
|
||||
void VerticalBarChart::paintChart(QPainter* painter, QRectF chartRect)
|
||||
{
|
||||
updateMinAndMaxValues();
|
||||
|
||||
@ -11,74 +11,61 @@ 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)
|
||||
void VerticalBarChart::paintVerticalBars(QPainter* painter, QRectF barsRect)
|
||||
{
|
||||
|
||||
if (valuesCount() == 0) return;
|
||||
if (valuesCount() == 0)
|
||||
return;
|
||||
|
||||
const AxisData &yAxisData = this->yAxisData();
|
||||
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++;
|
||||
foreach (SeriesItem* series, m_chartItem->series()) {
|
||||
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);
|
||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||
|
||||
qreal vStep = barsRect.height() / delta;
|
||||
qreal hStep = (barsRect.width() / valuesCount()) / (barSeriesCount == 0 ? 1 : barSeriesCount);
|
||||
qreal topShift = (delta - (maxValue() - minValue())) * vStep + barsRect.top();
|
||||
|
||||
if (!m_chartItem->series().isEmpty() && (m_chartItem->itemMode() != DesignMode)){
|
||||
if (!m_chartItem->series().isEmpty() && (m_chartItem->itemMode() != DesignMode)) {
|
||||
int curSeries = 0;
|
||||
foreach (SeriesItem* series, m_chartItem->series()) {
|
||||
if (series->preferredType() == SeriesItem::Bar){
|
||||
if (series->preferredType() == SeriesItem::Bar) {
|
||||
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++;
|
||||
@ -87,10 +74,12 @@ void VerticalBarChart::paintVerticalBars(QPainter *painter, QRectF barsRect)
|
||||
} else {
|
||||
qreal curHOffset = barsRect.left();
|
||||
int curColor = 0;
|
||||
for (int i = 0; i < 9; ++i){
|
||||
if (curColor == 3) curColor = 0;
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
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,13 +89,14 @@ 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);
|
||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||
|
||||
for (SeriesItem *series : m_chartItem->series()) {
|
||||
if (series->preferredType() == SeriesItem::Line){
|
||||
for (SeriesItem* series : m_chartItem->series()) {
|
||||
if (series->preferredType() == SeriesItem::Line) {
|
||||
paintSeries(painter, series, barsRect);
|
||||
}
|
||||
}
|
||||
|
@ -3,17 +3,17 @@
|
||||
|
||||
#include "lrlineschart.h"
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class VerticalBarChart: public LinesChart{
|
||||
class VerticalBarChart: public LinesChart {
|
||||
public:
|
||||
VerticalBarChart(ChartItem* chartItem):LinesChart(chartItem){}
|
||||
void paintChart(QPainter *painter, QRectF chartRect);
|
||||
// void paintVerticalGrid(QPainter *painter, QRectF gridRect);
|
||||
void paintVerticalBars(QPainter *painter, QRectF barsRect);
|
||||
void paintSerialLines(QPainter *painter, QRectF barsRect);
|
||||
VerticalBarChart(ChartItem* chartItem): LinesChart(chartItem) { }
|
||||
void paintChart(QPainter* painter, QRectF chartRect);
|
||||
// void paintVerticalGrid(QPainter *painter, QRectF gridRect);
|
||||
void paintVerticalBars(QPainter* painter, QRectF barsRect);
|
||||
void paintSerialLines(QPainter* painter, QRectF barsRect);
|
||||
};
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // VERTICALBARCHART_H
|
||||
|
@ -29,10 +29,11 @@
|
||||
****************************************************************************/
|
||||
#include "lrfonteditorwidget.h"
|
||||
|
||||
namespace LimeReport{
|
||||
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();
|
||||
}
|
||||
@ -40,91 +41,107 @@ FontEditorWidget::FontEditorWidget(const QString& title, QWidget* parent)
|
||||
void FontEditorWidget::setItemEvent(BaseDesignIntf* item)
|
||||
{
|
||||
|
||||
QVariant font=item->property("font");
|
||||
if (font.isValid()){
|
||||
QVariant font = item->property("font");
|
||||
if (font.isValid()) {
|
||||
updateValues(font.value<QFont>());
|
||||
setEnabled(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void FontEditorWidget::initEditor()
|
||||
{
|
||||
setIconSize(QSize(24,24));
|
||||
setIconSize(QSize(24, 24));
|
||||
setAllowedAreas(Qt::TopToolBarArea);
|
||||
setFloatable(false);
|
||||
|
||||
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);
|
||||
|
||||
addSeparator();
|
||||
setEnabled(false);
|
||||
|
||||
m_fontBold = new QAction(tr("Font bold"),this);
|
||||
m_fontBold = new QAction(tr("Font bold"), this);
|
||||
m_fontBold->setIcon(QIcon(":/report/images/textBold"));
|
||||
m_fontBold->setCheckable(true);
|
||||
connect(m_fontBold,SIGNAL(toggled(bool)),this,SLOT(slotFontAttribsChanged(bool)));
|
||||
connect(m_fontBold, SIGNAL(toggled(bool)), this, SLOT(slotFontAttribsChanged(bool)));
|
||||
addAction(m_fontBold);
|
||||
|
||||
m_fontItalic = new QAction(tr("Font Italic"),this);
|
||||
m_fontItalic = new QAction(tr("Font Italic"), this);
|
||||
m_fontItalic->setIcon(QIcon(":/report/images/textItalic"));
|
||||
m_fontItalic->setCheckable(true);
|
||||
connect(m_fontItalic,SIGNAL(toggled(bool)),this,SLOT(slotFontAttribsChanged(bool)));
|
||||
connect(m_fontItalic, SIGNAL(toggled(bool)), this, SLOT(slotFontAttribsChanged(bool)));
|
||||
addAction(m_fontItalic);
|
||||
|
||||
m_fontUnderline = new QAction(tr("Font Underline"),this);
|
||||
m_fontUnderline = new QAction(tr("Font Underline"), this);
|
||||
m_fontUnderline->setIcon(QIcon(":/report/images/textUnderline"));
|
||||
m_fontUnderline->setCheckable(true);
|
||||
connect(m_fontUnderline,SIGNAL(toggled(bool)),this,SLOT(slotFontAttribsChanged(bool)));
|
||||
connect(m_fontUnderline, SIGNAL(toggled(bool)), this, SLOT(slotFontAttribsChanged(bool)));
|
||||
addAction(m_fontUnderline);
|
||||
|
||||
}
|
||||
|
||||
void FontEditorWidget::updateValues(const QFont& font)
|
||||
{
|
||||
m_ignoreSlots=true;
|
||||
m_ignoreSlots = true;
|
||||
m_fontNameEditor->setCurrentFont(font);
|
||||
m_fontSizeEditor->setEditText(QString::number(font.pointSize()));
|
||||
m_fontBold->setChecked(font.bold());
|
||||
m_fontItalic->setChecked(font.italic());
|
||||
m_fontUnderline->setChecked(font.underline());
|
||||
m_ignoreSlots=false;
|
||||
}
|
||||
|
||||
bool FontEditorWidget::ignoreSlots() const
|
||||
{
|
||||
return m_ignoreSlots;
|
||||
m_ignoreSlots = false;
|
||||
}
|
||||
|
||||
bool FontEditorWidget::ignoreSlots() const { return m_ignoreSlots; }
|
||||
|
||||
void FontEditorWidget::slotFontChanged(const QFont& /*font*/)
|
||||
{
|
||||
//if (page()) page()->setFont(font);
|
||||
// if (page()) page()->setFont(font);
|
||||
}
|
||||
|
||||
void FontEditorWidget::slotFontSizeChanged(const QString &value)
|
||||
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,16 +149,16 @@ 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)
|
||||
if (item()&&(item()->objectName()==objectName)&&(property=="font")){
|
||||
if (item() && (item()->objectName() == objectName) && (property == "font")) {
|
||||
updateValues(item()->property("font").value<QFont>());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FontEditorWidgetForPage::slotFontChanged(const QFont& font)
|
||||
{
|
||||
if (!ignoreSlots())
|
||||
@ -150,7 +167,7 @@ void FontEditorWidgetForPage::slotFontChanged(const QFont& font)
|
||||
|
||||
void FontEditorWidgetForPage::slotFontSizeChanged(const QString& value)
|
||||
{
|
||||
if (!ignoreSlots()){
|
||||
if (!ignoreSlots()) {
|
||||
FontEditorWidget::slotFontSizeChanged(value);
|
||||
m_page->setFont(resFont());
|
||||
}
|
||||
@ -158,7 +175,7 @@ void FontEditorWidgetForPage::slotFontSizeChanged(const QString& value)
|
||||
|
||||
void FontEditorWidgetForPage::slotFontAttribsChanged(bool value)
|
||||
{
|
||||
if (!ignoreSlots()){
|
||||
if (!ignoreSlots()) {
|
||||
FontEditorWidget::slotFontAttribsChanged(value);
|
||||
m_page->setFont(resFont());
|
||||
}
|
||||
@ -167,18 +184,19 @@ 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)
|
||||
{
|
||||
if (!ignoreSlots()){
|
||||
if (!ignoreSlots()) {
|
||||
FontEditorWidget::slotFontSizeChanged(value);
|
||||
m_reportEditor->setFont(resFont());
|
||||
}
|
||||
@ -186,7 +204,7 @@ void FontEditorWidgetForDesigner::slotFontSizeChanged(const QString& value)
|
||||
|
||||
void FontEditorWidgetForDesigner::slotFontAttribsChanged(bool value)
|
||||
{
|
||||
if (!ignoreSlots()){
|
||||
if (!ignoreSlots()) {
|
||||
FontEditorWidget::slotFontAttribsChanged(value);
|
||||
m_reportEditor->setFont(resFont());
|
||||
}
|
||||
@ -194,5 +212,4 @@ void FontEditorWidgetForDesigner::slotFontAttribsChanged(bool value)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
} //namespace LimeReport
|
||||
} // 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"
|
||||
@ -41,27 +41,30 @@
|
||||
|
||||
#include "lritemeditorwidget.h"
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class FontEditorWidget :public ItemEditorWidget{
|
||||
class FontEditorWidget: public ItemEditorWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FontEditorWidget(const QString &title, QWidget *parent = 0);
|
||||
explicit FontEditorWidget(const QString& title, QWidget* parent = 0);
|
||||
bool ignoreSlots() const;
|
||||
|
||||
protected:
|
||||
void setItemEvent(BaseDesignIntf *item);
|
||||
QFontComboBox* fontNameEditor(){return m_fontNameEditor;}
|
||||
void setItemEvent(BaseDesignIntf* item);
|
||||
QFontComboBox* fontNameEditor() { return m_fontNameEditor; }
|
||||
void initEditor();
|
||||
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);
|
||||
protected:
|
||||
QFont resFont(){return m_resFont;}
|
||||
private:
|
||||
void slotPropertyChanged(const QString& objectName, const QString& property,
|
||||
const QVariant& oldValue, const QVariant& newValue);
|
||||
|
||||
void updateValues(const QFont &font);
|
||||
protected:
|
||||
QFont resFont() { return m_resFont; }
|
||||
|
||||
private:
|
||||
void updateValues(const QFont& font);
|
||||
|
||||
QFontComboBox* m_fontNameEditor;
|
||||
QComboBox* m_fontSizeEditor;
|
||||
@ -73,28 +76,37 @@ private:
|
||||
|
||||
bool m_ignoreSlots;
|
||||
QFont m_resFont;
|
||||
|
||||
};
|
||||
|
||||
class FontEditorWidgetForPage : public FontEditorWidget{
|
||||
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;
|
||||
};
|
||||
|
||||
#ifdef HAVE_REPORT_DESIGNER
|
||||
class FontEditorWidgetForDesigner : public FontEditorWidget{
|
||||
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,11 +114,12 @@ protected slots:
|
||||
virtual void slotFontChanged(const QFont& font);
|
||||
virtual void slotFontSizeChanged(const QString& value);
|
||||
virtual void slotFontAttribsChanged(bool value);
|
||||
|
||||
private:
|
||||
ReportDesignWidget* m_reportEditor;
|
||||
};
|
||||
#endif
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRFONTEDITORWIDGET_H
|
||||
|
@ -29,22 +29,24 @@
|
||||
****************************************************************************/
|
||||
#include "lritemeditorwidget.h"
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
void ItemEditorWidget::setItem(BaseDesignIntf* item)
|
||||
{
|
||||
if (m_item!=item){
|
||||
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)));
|
||||
if (m_item != item) {
|
||||
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)));
|
||||
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)
|
||||
@ -53,19 +55,16 @@ void ItemEditorWidget::properyChangedEvent(const QString& propertName, const QVa
|
||||
|
||||
void ItemEditorWidget::slotItemDestroyed(QObject* item)
|
||||
{
|
||||
if (item==m_item) {
|
||||
if (item == m_item) {
|
||||
m_item = 0;
|
||||
setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
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){}
|
||||
void setItem(BaseDesignIntf *item);
|
||||
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);
|
||||
BaseDesignIntf* item(){return m_item;}
|
||||
virtual void setItemEvent(BaseDesignIntf*) { }
|
||||
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;
|
||||
};
|
||||
|
@ -29,143 +29,174 @@
|
||||
****************************************************************************/
|
||||
#include "lritemsaligneditorwidget.h"
|
||||
|
||||
namespace LimeReport{
|
||||
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()
|
||||
{
|
||||
m_bringToFront = new QAction(tr("Bring to top"),this);
|
||||
m_bringToFront = new QAction(tr("Bring to top"), this);
|
||||
m_bringToFront->setIcon(QIcon(":/report/images/bringToTop"));
|
||||
connect(m_bringToFront,SIGNAL(triggered()),this,SLOT(slotBringToFront()));
|
||||
connect(m_bringToFront, SIGNAL(triggered()), this, SLOT(slotBringToFront()));
|
||||
addAction(m_bringToFront);
|
||||
|
||||
m_sendToBack = new QAction(tr("Send to back"),this);
|
||||
m_sendToBack = new QAction(tr("Send to back"), this);
|
||||
m_sendToBack->setIcon(QIcon(":/report/images/sendToBack"));
|
||||
connect(m_sendToBack,SIGNAL(triggered()),this,SLOT(slotSendToBack()));
|
||||
connect(m_sendToBack, SIGNAL(triggered()), this, SLOT(slotSendToBack()));
|
||||
addAction(m_sendToBack);
|
||||
|
||||
m_alignToLeft = new QAction(tr("Align to left"),this);
|
||||
m_alignToLeft = new QAction(tr("Align to left"), this);
|
||||
m_alignToLeft->setIcon(QIcon(":/report/images/alignToLeft"));
|
||||
connect(m_alignToLeft,SIGNAL(triggered()),this,SLOT(slotAlignToLeft()));
|
||||
connect(m_alignToLeft, SIGNAL(triggered()), this, SLOT(slotAlignToLeft()));
|
||||
addAction(m_alignToLeft);
|
||||
|
||||
m_alignToRight = new QAction(tr("Align to right"),this);
|
||||
m_alignToRight = new QAction(tr("Align to right"), this);
|
||||
m_alignToRight->setIcon(QIcon(":/report/images/alignToRight"));
|
||||
connect(m_alignToRight,SIGNAL(triggered()),this,SLOT(slotAlignToRight()));
|
||||
connect(m_alignToRight, SIGNAL(triggered()), this, SLOT(slotAlignToRight()));
|
||||
addAction(m_alignToRight);
|
||||
|
||||
m_alignToVCenter = new QAction(tr("Align to vertical center"),this);
|
||||
m_alignToVCenter = new QAction(tr("Align to vertical center"), this);
|
||||
m_alignToVCenter->setIcon(QIcon(":/report/images/alignToVCenter"));
|
||||
connect(m_alignToVCenter,SIGNAL(triggered()),this,SLOT(slotAlignToVCenter()));
|
||||
connect(m_alignToVCenter, SIGNAL(triggered()), this, SLOT(slotAlignToVCenter()));
|
||||
addAction(m_alignToVCenter);
|
||||
|
||||
m_alignToTop = new QAction(tr("Align to top"),this);
|
||||
m_alignToTop = new QAction(tr("Align to top"), this);
|
||||
m_alignToTop->setIcon(QIcon(":/report/images/alignToTop"));
|
||||
connect(m_alignToTop,SIGNAL(triggered()),this,SLOT(slotAlignToTop()));
|
||||
connect(m_alignToTop, SIGNAL(triggered()), this, SLOT(slotAlignToTop()));
|
||||
addAction(m_alignToTop);
|
||||
|
||||
m_alignToBottom = new QAction(tr("Align to bottom"),this);
|
||||
m_alignToBottom = new QAction(tr("Align to bottom"), this);
|
||||
m_alignToBottom->setIcon(QIcon(":/report/images/alignToBottom"));
|
||||
connect(m_alignToBottom,SIGNAL(triggered()),this,SLOT(slotAlignToBottom()));
|
||||
connect(m_alignToBottom, SIGNAL(triggered()), this, SLOT(slotAlignToBottom()));
|
||||
addAction(m_alignToBottom);
|
||||
|
||||
m_alignToHCenter = new QAction(tr("Align to horizontal center"),this);
|
||||
m_alignToHCenter = new QAction(tr("Align to horizontal center"), this);
|
||||
m_alignToHCenter->setIcon(QIcon(":/report/images/alignToHCenter"));
|
||||
connect(m_alignToHCenter,SIGNAL(triggered()),this,SLOT(slotAlignToHCenter()));
|
||||
connect(m_alignToHCenter, SIGNAL(triggered()), this, SLOT(slotAlignToHCenter()));
|
||||
addAction(m_alignToHCenter);
|
||||
|
||||
m_sameHeight = new QAction(tr("Set same height"),this);
|
||||
m_sameHeight = new QAction(tr("Set same height"), this);
|
||||
m_sameHeight->setIcon(QIcon(":/report/images/sameHeight"));
|
||||
connect(m_sameHeight,SIGNAL(triggered()),this,SLOT(slotSameHeight()));
|
||||
connect(m_sameHeight, SIGNAL(triggered()), this, SLOT(slotSameHeight()));
|
||||
addAction(m_sameHeight);
|
||||
|
||||
m_sameWidth = new QAction(tr("Set same width"),this);
|
||||
m_sameWidth = new QAction(tr("Set same width"), this);
|
||||
m_sameWidth->setIcon(QIcon(":/report/images/sameWidth"));
|
||||
connect(m_sameWidth,SIGNAL(triggered()),this,SLOT(slotSameWidth()));
|
||||
connect(m_sameWidth, SIGNAL(triggered()), this, SLOT(slotSameWidth()));
|
||||
addAction(m_sameWidth);
|
||||
}
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
@ -31,19 +31,21 @@
|
||||
#define LRITEMSALIGNEDITORWIDGET_H
|
||||
|
||||
#include "lrreportdesignwidget.h"
|
||||
#include <QToolBar>
|
||||
|
||||
#include <QAction>
|
||||
#include <QToolBar>
|
||||
|
||||
namespace LimeReport{
|
||||
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, QWidget *parent = 0);
|
||||
explicit ItemsAlignmentEditorWidget(PageDesignIntf* page, const QString &title, QWidget *parent = 0);
|
||||
explicit ItemsAlignmentEditorWidget(PageDesignIntf* page, 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, QWidget* parent = 0);
|
||||
private slots:
|
||||
void slotBringToFront();
|
||||
void slotSendToBack();
|
||||
@ -55,6 +57,7 @@ private slots:
|
||||
void slotAlignToHCenter();
|
||||
void slotSameHeight();
|
||||
void slotSameWidth();
|
||||
|
||||
private:
|
||||
void initEditor();
|
||||
ReportDesignWidget* m_reportEditor;
|
||||
@ -72,6 +75,6 @@ private:
|
||||
QAction* m_sameWidth;
|
||||
};
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRITEMSALIGNEDITORWIDGET_H
|
||||
|
@ -28,57 +28,56 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lritemsborderseditorwidget.h"
|
||||
#include <QAction>
|
||||
|
||||
#include "lrbordereditor.h"
|
||||
namespace LimeReport{
|
||||
|
||||
#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;
|
||||
}
|
||||
QVariant borders=item->property("borders");
|
||||
if (borders.isValid()){
|
||||
QVariant borders = item->property("borders");
|
||||
if (borders.isValid()) {
|
||||
updateValues((BaseDesignIntf::BorderLines)borders.toInt());
|
||||
setEnabled(true);
|
||||
}
|
||||
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"){
|
||||
if (property == "borders") {
|
||||
m_changing = true;
|
||||
updateValues((BaseDesignIntf::BorderLines)newValue.toInt());
|
||||
m_changing = false;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void ItemsBordersEditorWidget::buttonClicked(bool){}
|
||||
void ItemsBordersEditorWidget::buttonClicked(bool) { }
|
||||
|
||||
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());
|
||||
@ -89,49 +88,48 @@ void ItemsBordersEditorWidget::editBorderClicked()
|
||||
void ItemsBordersEditorWidget::initEditor()
|
||||
{
|
||||
|
||||
m_topLine = new QAction(tr("Top line"),this);
|
||||
m_topLine = new QAction(tr("Top line"), this);
|
||||
m_topLine->setIcon(QIcon(":/report/images/topLine"));
|
||||
m_topLine->setCheckable(true);
|
||||
connect(m_topLine,SIGNAL(toggled(bool)),this,SLOT(buttonClicked(bool)));
|
||||
connect(m_topLine, SIGNAL(toggled(bool)), this, SLOT(buttonClicked(bool)));
|
||||
addAction(m_topLine);
|
||||
|
||||
m_bottomLine = new QAction(tr("Bottom line"),this);
|
||||
m_bottomLine = new QAction(tr("Bottom line"), this);
|
||||
m_bottomLine->setIcon(QIcon(":/report/images/bottomLine"));
|
||||
m_bottomLine->setCheckable(true);
|
||||
connect(m_bottomLine,SIGNAL(toggled(bool)),this,SLOT(buttonClicked(bool)));
|
||||
connect(m_bottomLine, SIGNAL(toggled(bool)), this, SLOT(buttonClicked(bool)));
|
||||
addAction(m_bottomLine);
|
||||
|
||||
m_leftLine = new QAction(tr("Left line"),this);
|
||||
m_leftLine = new QAction(tr("Left line"), this);
|
||||
m_leftLine->setIcon(QIcon(":/report/images/leftLine"));
|
||||
m_leftLine->setCheckable(true);
|
||||
connect(m_leftLine,SIGNAL(toggled(bool)),this,SLOT(buttonClicked(bool)));
|
||||
connect(m_leftLine, SIGNAL(toggled(bool)), this, SLOT(buttonClicked(bool)));
|
||||
addAction(m_leftLine);
|
||||
|
||||
m_rightLine = new QAction(tr("Right line"),this);
|
||||
m_rightLine = new QAction(tr("Right line"), this);
|
||||
m_rightLine->setIcon(QIcon(":/report/images/rightLine"));
|
||||
m_rightLine->setCheckable(true);
|
||||
connect(m_rightLine,SIGNAL(toggled(bool)),this,SLOT(buttonClicked(bool)));
|
||||
connect(m_rightLine, SIGNAL(toggled(bool)), this, SLOT(buttonClicked(bool)));
|
||||
addAction(m_rightLine);
|
||||
|
||||
addSeparator();
|
||||
|
||||
m_noLines = new QAction(tr("No borders"),this);
|
||||
m_noLines = new QAction(tr("No borders"), this);
|
||||
m_noLines->setIcon(QIcon(":/report/images/noLines"));
|
||||
connect(m_noLines,SIGNAL(triggered()),this,SLOT(noBordesClicked()));
|
||||
connect(m_noLines, SIGNAL(triggered()), this, SLOT(noBordesClicked()));
|
||||
addAction(m_noLines);
|
||||
|
||||
m_allLines = new QAction(tr("All borders"),this);
|
||||
m_allLines = new QAction(tr("All borders"), this);
|
||||
m_allLines->setIcon(QIcon(":/report/images/allLines"));
|
||||
connect(m_allLines,SIGNAL(triggered()),this,SLOT(allBordesClicked()));
|
||||
connect(m_allLines, SIGNAL(triggered()), this, SLOT(allBordesClicked()));
|
||||
addAction(m_allLines);
|
||||
addSeparator();
|
||||
m_BorderEditor = new QAction(tr("Edit border"),this);
|
||||
m_BorderEditor = new QAction(tr("Edit border"), this);
|
||||
m_BorderEditor->setIcon(QIcon(":/report/images/borderEditor"));
|
||||
connect(m_BorderEditor,SIGNAL(triggered()),this,SLOT(editBorderClicked()));
|
||||
connect(m_BorderEditor, SIGNAL(triggered()), this, SLOT(editBorderClicked()));
|
||||
addAction(m_BorderEditor);
|
||||
|
||||
setEnabled(false);
|
||||
|
||||
}
|
||||
|
||||
void ItemsBordersEditorWidget::updateValues(BaseDesignIntf::BorderLines borders)
|
||||
@ -147,17 +145,14 @@ void ItemsBordersEditorWidget::updateValues(BaseDesignIntf::BorderLines borders)
|
||||
BaseDesignIntf::BorderLines ItemsBordersEditorWidget::createBorders()
|
||||
{
|
||||
int borders = 0;
|
||||
borders += (m_topLine->isChecked()) ? BaseDesignIntf::TopLine:0;
|
||||
borders += (m_bottomLine->isChecked()) ? BaseDesignIntf::BottomLine:0;
|
||||
borders += (m_leftLine->isChecked()) ? BaseDesignIntf::LeftLine:0;
|
||||
borders += (m_rightLine->isChecked()) ? BaseDesignIntf::RightLine:0;
|
||||
borders += (m_topLine->isChecked()) ? BaseDesignIntf::TopLine : 0;
|
||||
borders += (m_bottomLine->isChecked()) ? BaseDesignIntf::BottomLine : 0;
|
||||
borders += (m_leftLine->isChecked()) ? BaseDesignIntf::LeftLine : 0;
|
||||
borders += (m_rightLine->isChecked()) ? BaseDesignIntf::RightLine : 0;
|
||||
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,16 +177,14 @@ 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
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
@ -30,18 +30,21 @@
|
||||
#ifndef LRITEMSBORDERSEDITORWIDGET_H
|
||||
#define LRITEMSBORDERSEDITORWIDGET_H
|
||||
|
||||
#include <QToolBar>
|
||||
#include "lrreportdesignwidget.h"
|
||||
#include "lritemeditorwidget.h"
|
||||
#include "lrreportdesignwidget.h"
|
||||
|
||||
namespace LimeReport{
|
||||
#include <QToolBar>
|
||||
|
||||
class ItemsBordersEditorWidget : public ItemEditorWidget
|
||||
{
|
||||
namespace LimeReport {
|
||||
|
||||
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 setItemEvent(BaseDesignIntf* item);
|
||||
void properyChangedEvent(const QString& property, const QVariant& oldValue,
|
||||
const QVariant& newValue);
|
||||
BaseDesignIntf::BorderLines createBorders();
|
||||
BaseDesignIntf *m_item;
|
||||
BaseDesignIntf* m_item;
|
||||
|
||||
private:
|
||||
void initEditor();
|
||||
void updateValues(BaseDesignIntf::BorderLines borders);
|
||||
@ -67,26 +73,29 @@ private:
|
||||
QAction* m_BorderEditor;
|
||||
bool m_changing;
|
||||
int m_borders;
|
||||
|
||||
};
|
||||
|
||||
#ifdef HAVE_REPORT_DESIGNER
|
||||
class ItemsBordersEditorWidgetForDesigner : public ItemsBordersEditorWidget{
|
||||
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
|
||||
|
||||
}//namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRITEMSBORDERSEDITORWIDGET_H
|
||||
|
@ -29,17 +29,19 @@
|
||||
****************************************************************************/
|
||||
#include "lrtextalignmenteditorwidget.h"
|
||||
|
||||
namespace LimeReport{
|
||||
TextAlignmentEditorWidget::TextAlignmentEditorWidget(const QString& title, QWidget* parent)
|
||||
:ItemEditorWidget(title, parent), m_textAttibutesIsChanging(false), m_flag(0)
|
||||
namespace LimeReport {
|
||||
TextAlignmentEditorWidget::TextAlignmentEditorWidget(const QString& title, QWidget* parent):
|
||||
ItemEditorWidget(title, parent),
|
||||
m_textAttibutesIsChanging(false),
|
||||
m_flag(0)
|
||||
{
|
||||
initEditor();
|
||||
}
|
||||
|
||||
void TextAlignmentEditorWidget::setItemEvent(BaseDesignIntf *item)
|
||||
void TextAlignmentEditorWidget::setItemEvent(BaseDesignIntf* item)
|
||||
{
|
||||
QVariant align=item->property("alignment");
|
||||
if (align.isValid()){
|
||||
QVariant align = item->property("alignment");
|
||||
if (align.isValid()) {
|
||||
updateValues(Qt::Alignment(align.value<int>()));
|
||||
setEnabled(true);
|
||||
}
|
||||
@ -47,178 +49,197 @@ void TextAlignmentEditorWidget::setItemEvent(BaseDesignIntf *item)
|
||||
|
||||
void TextAlignmentEditorWidget::initEditor()
|
||||
{
|
||||
m_textAliginLeft = new QAction(tr("Text align left"),this);
|
||||
m_textAliginLeft = new QAction(tr("Text align left"), this);
|
||||
m_textAliginLeft->setIcon(QIcon(":/report/images/textAlignHLeft"));
|
||||
m_textAliginLeft->setCheckable(true);
|
||||
connect(m_textAliginLeft,SIGNAL(toggled(bool)),this,SLOT(slotTextHAttribsChanged(bool)));
|
||||
connect(m_textAliginLeft, SIGNAL(toggled(bool)), this, SLOT(slotTextHAttribsChanged(bool)));
|
||||
addAction(m_textAliginLeft);
|
||||
|
||||
m_textAliginHCenter = new QAction(tr("Text align center"),this);
|
||||
m_textAliginHCenter = new QAction(tr("Text align center"), this);
|
||||
m_textAliginHCenter->setIcon(QIcon(":/report/images/textAlignHCenter"));
|
||||
m_textAliginHCenter->setCheckable(true);
|
||||
connect(m_textAliginHCenter,SIGNAL(toggled(bool)),this,SLOT(slotTextHAttribsChanged(bool)));
|
||||
connect(m_textAliginHCenter, SIGNAL(toggled(bool)), this, SLOT(slotTextHAttribsChanged(bool)));
|
||||
addAction(m_textAliginHCenter);
|
||||
|
||||
m_textAliginRight = new QAction(tr("Text align right"),this);
|
||||
m_textAliginRight = new QAction(tr("Text align right"), this);
|
||||
m_textAliginRight->setIcon(QIcon(":/report/images/textAlignHRight"));
|
||||
m_textAliginRight->setCheckable(true);
|
||||
connect(m_textAliginRight,SIGNAL(toggled(bool)),this,SLOT(slotTextHAttribsChanged(bool)));
|
||||
connect(m_textAliginRight, SIGNAL(toggled(bool)), this, SLOT(slotTextHAttribsChanged(bool)));
|
||||
addAction(m_textAliginRight);
|
||||
|
||||
m_textAliginJustify = new QAction(tr("Text align justify"),this);
|
||||
m_textAliginJustify = new QAction(tr("Text align justify"), this);
|
||||
m_textAliginJustify->setIcon(QIcon(":/report/images/textAlignHJustify"));
|
||||
m_textAliginJustify->setCheckable(true);
|
||||
connect(m_textAliginJustify,SIGNAL(toggled(bool)),this,SLOT(slotTextHAttribsChanged(bool)));
|
||||
connect(m_textAliginJustify, SIGNAL(toggled(bool)), this, SLOT(slotTextHAttribsChanged(bool)));
|
||||
addAction(m_textAliginJustify);
|
||||
|
||||
addSeparator();
|
||||
|
||||
m_textAliginTop = new QAction(tr("Text align top"),this);
|
||||
m_textAliginTop = new QAction(tr("Text align top"), this);
|
||||
m_textAliginTop->setIcon(QIcon(":/report/images/textAlignVTop"));
|
||||
m_textAliginTop->setCheckable(true);
|
||||
connect(m_textAliginTop,SIGNAL(toggled(bool)),this,SLOT(slotTextVAttribsChanged(bool)));
|
||||
connect(m_textAliginTop, SIGNAL(toggled(bool)), this, SLOT(slotTextVAttribsChanged(bool)));
|
||||
addAction(m_textAliginTop);
|
||||
|
||||
m_textAliginVCenter = new QAction(tr("Text align center"),this);
|
||||
m_textAliginVCenter = new QAction(tr("Text align center"), this);
|
||||
m_textAliginVCenter->setIcon(QIcon(":/report/images/textAlignVCenter"));
|
||||
m_textAliginVCenter->setCheckable(true);
|
||||
connect(m_textAliginVCenter,SIGNAL(toggled(bool)),this,SLOT(slotTextVAttribsChanged(bool)));
|
||||
connect(m_textAliginVCenter, SIGNAL(toggled(bool)), this, SLOT(slotTextVAttribsChanged(bool)));
|
||||
addAction(m_textAliginVCenter);
|
||||
|
||||
m_textAliginBottom = new QAction(tr("Text align bottom"),this);
|
||||
m_textAliginBottom = new QAction(tr("Text align bottom"), this);
|
||||
m_textAliginBottom->setIcon(QIcon(":/report/images/textAlignVBottom"));
|
||||
m_textAliginBottom->setCheckable(true);
|
||||
connect(m_textAliginBottom,SIGNAL(toggled(bool)),this,SLOT(slotTextVAttribsChanged(bool)));
|
||||
connect(m_textAliginBottom, SIGNAL(toggled(bool)), this, SLOT(slotTextVAttribsChanged(bool)));
|
||||
addAction(m_textAliginBottom);
|
||||
setEnabled(false);
|
||||
}
|
||||
|
||||
void TextAlignmentEditorWidget::updateValues(const Qt::Alignment &align)
|
||||
void TextAlignmentEditorWidget::updateValues(const Qt::Alignment& align)
|
||||
{
|
||||
m_textAttibutesIsChanging=true;
|
||||
m_textAliginLeft->setChecked((align & Qt::AlignLeft)==Qt::AlignLeft);
|
||||
m_textAliginRight->setChecked((align & Qt::AlignRight)==Qt::AlignRight);
|
||||
m_textAliginHCenter->setChecked((align & Qt::AlignHCenter)==Qt::AlignHCenter);
|
||||
m_textAliginJustify->setChecked((align & Qt::AlignJustify)==Qt::AlignJustify);
|
||||
m_textAliginTop->setChecked((align & Qt::AlignTop)==Qt::AlignTop);
|
||||
m_textAliginVCenter->setChecked((align & Qt::AlignVCenter)==Qt::AlignVCenter);
|
||||
m_textAliginBottom->setChecked((align & Qt::AlignBottom)==Qt::AlignBottom);
|
||||
m_textAttibutesIsChanging=false;
|
||||
m_textAttibutesIsChanging = true;
|
||||
m_textAliginLeft->setChecked((align & Qt::AlignLeft) == Qt::AlignLeft);
|
||||
m_textAliginRight->setChecked((align & Qt::AlignRight) == Qt::AlignRight);
|
||||
m_textAliginHCenter->setChecked((align & Qt::AlignHCenter) == Qt::AlignHCenter);
|
||||
m_textAliginJustify->setChecked((align & Qt::AlignJustify) == Qt::AlignJustify);
|
||||
m_textAliginTop->setChecked((align & Qt::AlignTop) == Qt::AlignTop);
|
||||
m_textAliginVCenter->setChecked((align & Qt::AlignVCenter) == Qt::AlignVCenter);
|
||||
m_textAliginBottom->setChecked((align & Qt::AlignBottom) == Qt::AlignBottom);
|
||||
m_textAttibutesIsChanging = false;
|
||||
}
|
||||
|
||||
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);
|
||||
m_textAliginHCenter->setChecked(sender()==m_textAliginHCenter);
|
||||
m_textAliginRight->setChecked(sender()==m_textAliginRight);
|
||||
m_textAliginJustify->setChecked(sender()==m_textAliginJustify);
|
||||
m_textAliginLeft->setChecked(sender() == m_textAliginLeft);
|
||||
m_textAliginHCenter->setChecked(sender() == m_textAliginHCenter);
|
||||
m_textAliginRight->setChecked(sender() == m_textAliginRight);
|
||||
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);
|
||||
m_textAliginVCenter->setChecked(sender()==m_textAliginVCenter);
|
||||
m_textAliginBottom->setChecked(sender()==m_textAliginBottom);
|
||||
m_textAliginTop->setChecked(sender() == m_textAliginTop);
|
||||
m_textAliginVCenter->setChecked(sender() == m_textAliginVCenter);
|
||||
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)
|
||||
|
||||
if (item()&&(item()->objectName()==objectName)&&(property=="alignment")){
|
||||
if (item() && (item()->objectName() == objectName) && (property == "alignment")) {
|
||||
updateValues(Qt::Alignment(item()->property("alignment").value<int>()));
|
||||
}
|
||||
}
|
||||
|
||||
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_page->changeSelectedGrpoupTextAlignPropperty(true, Qt::AlignmentFlag(flag()));
|
||||
m_textAttibutesIsChanging = false;
|
||||
}
|
||||
|
||||
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_page->changeSelectedGrpoupTextAlignPropperty(false, Qt::AlignmentFlag(flag()));
|
||||
m_textAttibutesIsChanging = false;
|
||||
}
|
||||
|
||||
#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_reportEditor->setTextAlign(true, Qt::AlignmentFlag(flag()));
|
||||
m_textAttibutesIsChanging = false;
|
||||
}
|
||||
|
||||
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_reportEditor->setTextAlign(false, Qt::AlignmentFlag(flag()));
|
||||
m_textAttibutesIsChanging = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
@ -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{
|
||||
namespace LimeReport {
|
||||
|
||||
class TextAlignmentEditorWidget:public ItemEditorWidget
|
||||
{
|
||||
class TextAlignmentEditorWidget: public ItemEditorWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TextAlignmentEditorWidget(const QString &title, QWidget *parent = 0);
|
||||
explicit TextAlignmentEditorWidget(const QString& title, QWidget* parent = 0);
|
||||
int flag() const;
|
||||
|
||||
protected:
|
||||
void setItemEvent(BaseDesignIntf *item);
|
||||
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;
|
||||
@ -65,36 +69,49 @@ private:
|
||||
int m_flag;
|
||||
};
|
||||
|
||||
class TextAlignmentEditorWidgetForPage: public TextAlignmentEditorWidget{
|
||||
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;
|
||||
};
|
||||
|
||||
#ifdef HAVE_REPORT_DESIGNER
|
||||
class TextAlignmentEditorWidgetForDesigner: public TextAlignmentEditorWidget{
|
||||
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;
|
||||
};
|
||||
#endif
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRTEXTALIGNMENTEDITORWIDGET_H
|
||||
|
@ -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);
|
||||
@ -58,13 +48,13 @@ void AbstractLayout::addChild(BaseDesignIntf* item, bool updateSize)
|
||||
|
||||
connectToLayout(item);
|
||||
|
||||
if (updateSize){
|
||||
if (updateSize) {
|
||||
relocateChildren();
|
||||
updateLayoutSize();
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractLayout::removeChild(BaseDesignIntf *item)
|
||||
void AbstractLayout::removeChild(BaseDesignIntf* item)
|
||||
{
|
||||
if (!item) {
|
||||
return;
|
||||
@ -75,8 +65,9 @@ void AbstractLayout::removeChild(BaseDesignIntf *item)
|
||||
|
||||
void AbstractLayout::restoreChild(BaseDesignIntf* item)
|
||||
{
|
||||
if (m_children.contains(item)) return;
|
||||
m_isRelocating=true;
|
||||
if (m_children.contains(item))
|
||||
return;
|
||||
m_isRelocating = true;
|
||||
|
||||
insertItemInLayout(item);
|
||||
|
||||
@ -88,7 +79,7 @@ void AbstractLayout::restoreChild(BaseDesignIntf* item)
|
||||
item->setParentItem(this);
|
||||
|
||||
updateLayoutSize();
|
||||
m_isRelocating=false;
|
||||
m_isRelocating = false;
|
||||
}
|
||||
|
||||
bool AbstractLayout::isEmpty() const
|
||||
@ -97,54 +88,49 @@ 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;
|
||||
}
|
||||
return (isEmpty && allItemsIsText);
|
||||
}
|
||||
|
||||
void AbstractLayout::paintChild(BaseDesignIntf *child, QPointF parentPos, QPainter *painter)
|
||||
void AbstractLayout::paintChild(BaseDesignIntf* child, QPointF parentPos, QPainter* painter)
|
||||
{
|
||||
if (!child->childBaseItems().isEmpty()){
|
||||
if (!child->childBaseItems().isEmpty()) {
|
||||
foreach (BaseDesignIntf* item, child->childBaseItems()) {
|
||||
paintChild(item, child->pos(),painter);
|
||||
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()){
|
||||
if (isSelected()) {
|
||||
painter->save();
|
||||
painter->setPen(Qt::red);
|
||||
foreach( BaseDesignIntf* item, m_children){
|
||||
paintChild(item, QPointF(0,0), painter);
|
||||
foreach (BaseDesignIntf* item, m_children) {
|
||||
paintChild(item, QPointF(0, 0), painter);
|
||||
}
|
||||
painter->restore();
|
||||
}
|
||||
LayoutDesignIntf::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
int AbstractLayout::childrenCount()
|
||||
{
|
||||
return m_children.size();
|
||||
}
|
||||
int AbstractLayout::childrenCount() { return m_children.size(); }
|
||||
|
||||
void AbstractLayout::beforeDelete()
|
||||
{
|
||||
#ifdef HAVE_QT5
|
||||
foreach (QObject *item, children()) {
|
||||
foreach (QObject* item, children()) {
|
||||
#else
|
||||
foreach (QObject *item, QObject::children()) {
|
||||
foreach (QObject* item, QObject::children()) {
|
||||
#endif
|
||||
BaseDesignIntf *bi = dynamic_cast<BaseDesignIntf*>(item);
|
||||
BaseDesignIntf* bi = dynamic_cast<BaseDesignIntf*>(item);
|
||||
if (bi) {
|
||||
bi->disconnect(this);
|
||||
bi->setParentItem(parentItem());
|
||||
@ -158,16 +144,13 @@ 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)
|
||||
{
|
||||
layoutMarker()->setHeight(newRect.height());
|
||||
relocateChildren();
|
||||
if (!isRelocating()){
|
||||
if (!isRelocating()) {
|
||||
divideSpace();
|
||||
}
|
||||
}
|
||||
@ -175,7 +158,7 @@ void AbstractLayout::geometryChangedEvent(QRectF newRect, QRectF)
|
||||
void AbstractLayout::initMode(BaseDesignIntf::ItemMode mode)
|
||||
{
|
||||
BaseDesignIntf::initMode(mode);
|
||||
if ((mode==PreviewMode)||(mode==PrintMode)){
|
||||
if ((mode == PreviewMode) || (mode == PrintMode)) {
|
||||
layoutMarker()->setVisible(false);
|
||||
} else {
|
||||
layoutMarker()->setVisible(true);
|
||||
@ -185,22 +168,22 @@ void AbstractLayout::initMode(BaseDesignIntf::ItemMode mode)
|
||||
void AbstractLayout::setBorderLinesFlags(BaseDesignIntf::BorderLines flags)
|
||||
{
|
||||
BaseDesignIntf::setBorderLinesFlags(flags);
|
||||
if (flags!=0)
|
||||
if (flags != 0)
|
||||
relocateChildren();
|
||||
}
|
||||
|
||||
void AbstractLayout::collectionLoadFinished(const QString& collectionName)
|
||||
{
|
||||
ItemDesignIntf::collectionLoadFinished(collectionName);
|
||||
if (collectionName.compare("children",Qt::CaseInsensitive)==0){
|
||||
if (collectionName.compare("children", Qt::CaseInsensitive) == 0) {
|
||||
#ifdef HAVE_QT5
|
||||
foreach(QObject* obj, children()){
|
||||
foreach (QObject* obj, children()) {
|
||||
#else
|
||||
foreach(QObject* obj,QObject::children()){
|
||||
foreach (QObject* obj, QObject::children()) {
|
||||
#endif
|
||||
BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(obj);
|
||||
if (item) {
|
||||
addChild(item,false);
|
||||
addChild(item, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -220,9 +203,9 @@ bool AbstractLayout::isNeedUpdateSize(RenderPass pass) const
|
||||
|
||||
QVariant AbstractLayout::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant& value)
|
||||
{
|
||||
if (change == QGraphicsItem::ItemSelectedHasChanged){
|
||||
if (change == QGraphicsItem::ItemSelectedHasChanged) {
|
||||
setIsRelocating(true);
|
||||
foreach(BaseDesignIntf* item, layoutsChildren()){
|
||||
foreach (BaseDesignIntf* item, layoutsChildren()) {
|
||||
item->setVisible(!value.toBool());
|
||||
}
|
||||
setIsRelocating(false);
|
||||
@ -234,7 +217,7 @@ void AbstractLayout::updateItemSize(DataSourceManager* dataManager, RenderPass p
|
||||
{
|
||||
setIsRelocating(true);
|
||||
ItemDesignIntf::updateItemSize(dataManager, pass, maxHeight);
|
||||
foreach(QGraphicsItem *child, childItems()){
|
||||
foreach (QGraphicsItem* child, childItems()) {
|
||||
BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(child);
|
||||
if (item && item->isNeedUpdateSize(pass))
|
||||
item->updateItemSize(dataManager, pass, maxHeight);
|
||||
@ -245,8 +228,9 @@ void AbstractLayout::updateItemSize(DataSourceManager* dataManager, RenderPass p
|
||||
BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight);
|
||||
}
|
||||
|
||||
void AbstractLayout::rebuildChildrenIfNeeded(){
|
||||
if (layoutsChildren().count() < childItems().size()-1){
|
||||
void AbstractLayout::rebuildChildrenIfNeeded()
|
||||
{
|
||||
if (layoutsChildren().count() < childItems().size() - 1) {
|
||||
layoutsChildren().clear();
|
||||
foreach (BaseDesignIntf* childItem, childBaseItems()) {
|
||||
layoutsChildren().append(childItem);
|
||||
@ -255,89 +239,75 @@ void AbstractLayout::rebuildChildrenIfNeeded(){
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractLayout::connectToLayout(BaseDesignIntf *item)
|
||||
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)
|
||||
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)
|
||||
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];}
|
||||
for (int i = 0; i < layoutsChildren().count(); ++i) {
|
||||
if (layoutsChildren()[i] == item && layoutsChildren().size() > i + 1) {
|
||||
return layoutsChildren()[i + 1];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
BaseDesignIntf *AbstractLayout::findPrior(BaseDesignIntf *item)
|
||||
BaseDesignIntf* AbstractLayout::findPrior(BaseDesignIntf* item)
|
||||
{
|
||||
rebuildChildrenIfNeeded();
|
||||
for (int i=0; i<layoutsChildren().count();++i){
|
||||
if (layoutsChildren()[i]==item && i!=0){ return layoutsChildren()[i-1];}
|
||||
for (int i = 0; i < layoutsChildren().count(); ++i) {
|
||||
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){
|
||||
for (int i = 0; i < layoutsChildren().length(); ++i) {
|
||||
BaseDesignIntf* child = layoutsChildren()[i];
|
||||
if (child->pos() == item->pos()){
|
||||
if (child->pos() == item->pos()) {
|
||||
layoutsChildren().insert(i, item);
|
||||
inserted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!inserted) layoutsChildren().append(item);
|
||||
if (!inserted)
|
||||
layoutsChildren().append(item);
|
||||
}
|
||||
|
||||
void AbstractLayout::slotOnChildDestroy(QObject* child)
|
||||
{
|
||||
m_children.removeAll(static_cast<BaseDesignIntf*>(child));
|
||||
if (m_children.count() < 2 && !static_cast<LayoutDesignIntf*>(child)){
|
||||
if (m_children.count() < 2 && !static_cast<LayoutDesignIntf*>(child)) {
|
||||
beforeDelete();
|
||||
} else {
|
||||
relocateChildren();
|
||||
@ -345,19 +315,20 @@ 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){
|
||||
if (!m_isRelocating && !isLoading()) {
|
||||
if (m_layoutType == Layout) {
|
||||
relocateChildren();
|
||||
updateLayoutSize();
|
||||
} else {
|
||||
m_isRelocating = true;
|
||||
qreal delta = newGeometry.width()-oldGeometry.width();
|
||||
qreal delta = newGeometry.width() - oldGeometry.width();
|
||||
BaseDesignIntf* resizingItem = findNext(dynamic_cast<BaseDesignIntf*>(item));
|
||||
if (resizingItem) {
|
||||
resizingItem->setWidth(resizingItem->width()-delta);
|
||||
resizingItem->setPos(resizingItem->pos().x()+delta,resizingItem->pos().y());
|
||||
resizingItem->setWidth(resizingItem->width() - delta);
|
||||
resizingItem->setPos(resizingItem->pos().x() + delta, resizingItem->pos().y());
|
||||
}
|
||||
updateLayoutSize();
|
||||
m_isRelocating = false;
|
||||
@ -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);
|
||||
}
|
||||
@ -373,28 +345,25 @@ void AbstractLayout::slotOnChildItemAlignChanged(BaseDesignIntf* item, const Ite
|
||||
void AbstractLayout::slotOnChildVisibleHasChanged(BaseDesignIntf*)
|
||||
{
|
||||
relocateChildren();
|
||||
if (m_layoutType == Table && !m_isRelocating){
|
||||
if (m_layoutType == Table && !m_isRelocating) {
|
||||
divideSpace();
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractLayout::slotOnChildSelectionHasChanged(BaseDesignIntf* item, bool value)
|
||||
{
|
||||
item->setZValue(value ? item->zValue()+1 : item->zValue()-1);
|
||||
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)
|
||||
{
|
||||
if (m_layoutSpacing != layoutSpacing){
|
||||
if (m_layoutSpacing != layoutSpacing) {
|
||||
int oldValue = m_layoutSpacing;
|
||||
m_layoutSpacing = layoutSpacing;
|
||||
if (!isLoading()){
|
||||
int delta = (m_layoutSpacing - oldValue) * (m_children.count()-1);
|
||||
if (!isLoading()) {
|
||||
int delta = (m_layoutSpacing - oldValue) * (m_children.count() - 1);
|
||||
notify("layoutSpacing", oldValue, m_layoutSpacing);
|
||||
setWidth(width() + delta);
|
||||
}
|
||||
@ -402,16 +371,13 @@ void AbstractLayout::setLayoutSpacing(int layoutSpacing)
|
||||
}
|
||||
}
|
||||
|
||||
bool AbstractLayout::hideEmptyItems() const
|
||||
{
|
||||
return m_hideEmptyItems;
|
||||
}
|
||||
bool AbstractLayout::hideEmptyItems() const { return m_hideEmptyItems; }
|
||||
|
||||
void AbstractLayout::setHideEmptyItems(bool hideEmptyItems)
|
||||
{
|
||||
m_hideEmptyItems = hideEmptyItems;
|
||||
|
||||
if (m_hideEmptyItems != hideEmptyItems){
|
||||
if (m_hideEmptyItems != hideEmptyItems) {
|
||||
m_hideEmptyItems = hideEmptyItems;
|
||||
notify("hideEmptyItems", !m_hideEmptyItems, m_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,22 +3,25 @@
|
||||
|
||||
#include "lritemdesignintf.h"
|
||||
#include "lrlayoutmarker.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
namespace LimeReport{
|
||||
class AbstractLayout: public LayoutDesignIntf
|
||||
{
|
||||
namespace LimeReport {
|
||||
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
|
||||
Q_ENUMS(LayoutType)
|
||||
#endif
|
||||
AbstractLayout(QString xmlTag, QObject *owner = 0, QGraphicsItem *parent = 0);
|
||||
AbstractLayout(QString xmlTag, QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
~AbstractLayout();
|
||||
QList<BaseDesignIntf*>& layoutsChildren();
|
||||
LayoutMarker* layoutMarker() const;
|
||||
@ -27,9 +30,9 @@ public:
|
||||
LayoutType layoutType() const;
|
||||
void setLayoutType(const LayoutType& layoutType);
|
||||
|
||||
void addChild(BaseDesignIntf *item,bool updateSize=true);
|
||||
void removeChild(BaseDesignIntf *item);
|
||||
void restoreChild(BaseDesignIntf *item);
|
||||
void addChild(BaseDesignIntf* item, bool updateSize = true);
|
||||
void removeChild(BaseDesignIntf* item);
|
||||
void restoreChild(BaseDesignIntf* item);
|
||||
bool isEmpty() const;
|
||||
void paintChild(BaseDesignIntf* child, QPointF parentPos, QPainter* painter);
|
||||
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
|
||||
@ -40,39 +43,42 @@ public:
|
||||
int childrenCount();
|
||||
int layoutSpacing() const;
|
||||
void setLayoutSpacing(int layoutSpacing);
|
||||
qreal layoutSpacingMM(){ return m_layoutSpacing * Const::mmFACTOR;}
|
||||
qreal layoutSpacingMM() { return m_layoutSpacing * Const::mmFACTOR; }
|
||||
|
||||
protected:
|
||||
void beforeDelete();
|
||||
void childAddedEvent(BaseDesignIntf *child);
|
||||
void childAddedEvent(BaseDesignIntf* child);
|
||||
void geometryChangedEvent(QRectF newRect, QRectF);
|
||||
void initMode(ItemMode mode);
|
||||
void setBorderLinesFlags(BorderLines flags);
|
||||
void collectionLoadFinished(const QString &collectionName);
|
||||
void collectionLoadFinished(const QString& collectionName);
|
||||
void objectLoadFinished();
|
||||
bool isNeedUpdateSize(RenderPass pass) const;
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant& value);
|
||||
void updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight);
|
||||
void rebuildChildrenIfNeeded();
|
||||
void connectToLayout(BaseDesignIntf* item);
|
||||
void disconnectFromLayout(BaseDesignIntf* item);
|
||||
virtual void insertItemInLayout(BaseDesignIntf* item);
|
||||
|
||||
private:
|
||||
virtual void sortChildren() = 0;
|
||||
virtual void divideSpace() = 0;
|
||||
virtual void updateLayoutSize() = 0;
|
||||
virtual void relocateChildren() = 0;
|
||||
virtual BaseDesignIntf* findNext(BaseDesignIntf *item);
|
||||
virtual BaseDesignIntf* findPrior(BaseDesignIntf *item);
|
||||
virtual BaseDesignIntf* findNext(BaseDesignIntf* item);
|
||||
virtual BaseDesignIntf* findPrior(BaseDesignIntf* item);
|
||||
virtual void placeItemInLayout(BaseDesignIntf* item) = 0;
|
||||
|
||||
private slots:
|
||||
void slotOnChildDestroy(QObject *child);
|
||||
void slotOnChildGeometryChanged(QObject*item, QRectF newGeometry, QRectF oldGeometry);
|
||||
void slotOnChildDestroy(QObject* child);
|
||||
void slotOnChildGeometryChanged(QObject* item, QRectF newGeometry, QRectF oldGeometry);
|
||||
void slotOnChildItemAlignChanged(BaseDesignIntf* item, const ItemAlign&, const ItemAlign&);
|
||||
void slotOnChildVisibleHasChanged(BaseDesignIntf*);
|
||||
void slotOnChildSelectionHasChanged(BaseDesignIntf* item, bool value);
|
||||
|
||||
private:
|
||||
QList<BaseDesignIntf *> m_children;
|
||||
QList<BaseDesignIntf*> m_children;
|
||||
bool m_isRelocating;
|
||||
LayoutMarker* m_layoutMarker;
|
||||
LayoutType m_layoutType;
|
||||
|
@ -28,54 +28,63 @@
|
||||
* 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);
|
||||
}
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("alignment","LimeReport::TextItem"),
|
||||
QObject::tr("alignment"),
|
||||
createAlignItem
|
||||
);
|
||||
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);
|
||||
}
|
||||
|
||||
namespace LimeReport{
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("alignment", "LimeReport::TextItem"), QObject::tr("alignment"),
|
||||
createAlignItem);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
QString AlignmentPropItem::associateValue(int value, const AlignMap* map) const
|
||||
{
|
||||
QString result;
|
||||
QMap<QString,Qt::Alignment>::const_iterator it = map->constBegin();
|
||||
for(;it!= map->constEnd();++it){
|
||||
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);
|
||||
m_horizMap.insert(tr("Right"),Qt::AlignRight);
|
||||
m_horizMap.insert(tr("Center"),Qt::AlignHCenter);
|
||||
m_horizMap.insert(tr("Justify"),Qt::AlignJustify);
|
||||
m_horizMap.insert(tr("Left"), Qt::AlignLeft);
|
||||
m_horizMap.insert(tr("Right"), Qt::AlignRight);
|
||||
m_horizMap.insert(tr("Center"), Qt::AlignHCenter);
|
||||
m_horizMap.insert(tr("Justify"), Qt::AlignJustify);
|
||||
|
||||
m_vertMap.insert(tr("Top"),Qt::AlignTop);
|
||||
m_vertMap.insert(tr("Center"),Qt::AlignVCenter);
|
||||
m_vertMap.insert(tr("Botom"),Qt::AlignBottom);
|
||||
m_vertMap.insert(tr("Top"), Qt::AlignTop);
|
||||
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,62 +103,67 @@ 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())
|
||||
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);
|
||||
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);
|
||||
model->setData(index, align);
|
||||
}
|
||||
|
||||
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();
|
||||
flags = flags ^ it.value();
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
QWidget *AlignmentItemEditor::createProperyEditor(QWidget *parent) const
|
||||
QWidget* AlignmentItemEditor::createProperyEditor(QWidget* parent) const
|
||||
{
|
||||
ComboBoxEditor *editor = new ComboBoxEditor(parent);
|
||||
ComboBoxEditor* editor = new ComboBoxEditor(parent);
|
||||
QStringList enumValues;
|
||||
enumValues<<m_acceptableValues.keys();
|
||||
enumValues << m_acceptableValues.keys();
|
||||
editor->addItems(enumValues);
|
||||
return editor;
|
||||
}
|
||||
|
||||
void AlignmentItemEditor::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
void AlignmentItemEditor::setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const
|
||||
{
|
||||
ComboBoxEditor *editor=qobject_cast<ComboBoxEditor *>(propertyEditor);
|
||||
ComboBoxEditor* editor = qobject_cast<ComboBoxEditor*>(propertyEditor);
|
||||
editor->setTextValue(m_acceptableValues.key(Qt::Alignment(propertyValue().toInt())));
|
||||
}
|
||||
|
||||
@ -160,10 +174,11 @@ QString AlignmentItemEditor::displayValue() const
|
||||
|
||||
void AlignmentItemEditor::setPropertyValue(QVariant value)
|
||||
{
|
||||
QVector<int> _accpepttableValueList= extractAcceptableValue(value.toInt());
|
||||
if(_accpepttableValueList.isEmpty()) return;
|
||||
QVector<int> _accpepttableValueList = extractAcceptableValue(value.toInt());
|
||||
if (_accpepttableValueList.isEmpty())
|
||||
return;
|
||||
|
||||
ObjectPropItem::setPropertyValue(_accpepttableValueList[0]);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
@ -33,48 +33,51 @@
|
||||
#include "lrobjectpropitem.h"
|
||||
#include "objectinspector/propertyItems/lrenumpropitem.h"
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
typedef QMap<QString,Qt::Alignment> AlignMap;
|
||||
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(): 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);
|
||||
QString displayValue() const;
|
||||
void setPropertyValue(QVariant value);
|
||||
|
||||
private:
|
||||
AlignMap m_vertMap;
|
||||
AlignMap m_horizMap;
|
||||
AlignmentItemEditor* m_horizEditor;
|
||||
AlignmentItemEditor* m_vertEditor;
|
||||
QString associateValue(int value, const AlignMap *map) const;
|
||||
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);
|
||||
void setModelData(QWidget * propertyEditor, QAbstractItemModel * model, const QModelIndex & index);
|
||||
void setPropertyEditorData(QWidget * propertyEditor, const QModelIndex &) const;
|
||||
QWidget* createProperyEditor(QWidget *parent) const;
|
||||
AlignmentItemEditor(): ObjectPropItem() { }
|
||||
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;}
|
||||
AlignMap acceptableValues() const { return m_acceptableValues; }
|
||||
|
||||
private:
|
||||
AlignMap m_acceptableValues;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRALIGNPROPITEM_H
|
||||
|
@ -28,44 +28,59 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrbarcodeitem.h"
|
||||
#include "lrdesignelementsfactory.h"
|
||||
#include "qzint.h"
|
||||
#include "lrglobal.h"
|
||||
|
||||
namespace{
|
||||
#include "lrdesignelementsfactory.h"
|
||||
#include "lrglobal.h"
|
||||
#include "qzint.h"
|
||||
|
||||
namespace {
|
||||
|
||||
const QString xmlTag = "BarcodeItem";
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
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()
|
||||
{}
|
||||
|
||||
BaseDesignIntf *BarcodeItem::createSameTypeItem(QObject *owner, QGraphicsItem *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);
|
||||
|
||||
} // 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)
|
||||
{
|
||||
return new BarcodeItem(owner,parent);
|
||||
}
|
||||
|
||||
void BarcodeItem::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
BarcodeItem::~BarcodeItem() { }
|
||||
|
||||
BaseDesignIntf* BarcodeItem::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
return new BarcodeItem(owner, parent);
|
||||
}
|
||||
|
||||
void BarcodeItem::paint(QPainter* ppainter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||
{
|
||||
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;
|
||||
|
||||
@ -86,45 +102,42 @@ void BarcodeItem::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *opti
|
||||
bcRect = rect();
|
||||
break;
|
||||
case Angle90:
|
||||
ppainter->translate(width(),0);
|
||||
ppainter->translate(width(), 0);
|
||||
ppainter->rotate(90);
|
||||
bcRect = QRectF(0,0,height(),width());
|
||||
bcRect = QRectF(0, 0, height(), width());
|
||||
break;
|
||||
case Angle180:
|
||||
bcRect = rect();
|
||||
ppainter->translate(width(),height());
|
||||
ppainter->translate(width(), height());
|
||||
ppainter->rotate(180);
|
||||
break;
|
||||
case Angle270:
|
||||
ppainter->translate(0,height());
|
||||
ppainter->translate(0, height());
|
||||
ppainter->rotate(270);
|
||||
bcRect = QRectF(0,0,height(),width());
|
||||
bcRect = QRectF(0, 0, height(), width());
|
||||
break;
|
||||
}
|
||||
|
||||
bc.render(*ppainter,bcRect);
|
||||
bc.render(*ppainter, bcRect);
|
||||
ppainter->restore();
|
||||
ItemDesignIntf::paint(ppainter,option,widget);
|
||||
ItemDesignIntf::paint(ppainter, option, widget);
|
||||
}
|
||||
|
||||
void BarcodeItem::setContent(const QString &content)
|
||||
void BarcodeItem::setContent(const QString& content)
|
||||
{
|
||||
if (m_content!=content){
|
||||
if (m_content != content) {
|
||||
QString oldValue = m_content;
|
||||
m_content=content;
|
||||
m_content = content;
|
||||
update();
|
||||
notify("content",oldValue,m_content);
|
||||
notify("content", oldValue, m_content);
|
||||
}
|
||||
}
|
||||
|
||||
QString BarcodeItem::datasource() const
|
||||
{
|
||||
return m_datasource;
|
||||
}
|
||||
QString BarcodeItem::datasource() const { return m_datasource; }
|
||||
|
||||
void BarcodeItem::setDatasource(const QString &datasource)
|
||||
void BarcodeItem::setDatasource(const QString& datasource)
|
||||
{
|
||||
if (m_datasource != datasource){
|
||||
if (m_datasource != datasource) {
|
||||
QString oldValue = m_datasource;
|
||||
m_datasource = datasource;
|
||||
update();
|
||||
@ -132,14 +145,11 @@ 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)
|
||||
void BarcodeItem::setField(const QString& field)
|
||||
{
|
||||
if (m_field != field){
|
||||
if (m_field != field) {
|
||||
QString oldValue = m_field;
|
||||
m_field = field;
|
||||
update();
|
||||
@ -149,189 +159,162 @@ void BarcodeItem::setField(const QString &field)
|
||||
|
||||
void BarcodeItem::setBarcodeType(BarcodeItem::BarcodeType value)
|
||||
{
|
||||
if (m_barcodeType!=value){
|
||||
if (m_barcodeType != value) {
|
||||
BarcodeType oldValue = m_barcodeType;
|
||||
m_barcodeType = value;
|
||||
update();
|
||||
notify("barcodeType",oldValue,value);
|
||||
notify("barcodeType", oldValue, value);
|
||||
}
|
||||
}
|
||||
|
||||
void BarcodeItem::setDesignTestValue(QString value)
|
||||
{
|
||||
if (m_designTestValue!=value){
|
||||
if (m_designTestValue != value) {
|
||||
QString oldValue = m_designTestValue;
|
||||
m_designTestValue=value;
|
||||
m_designTestValue = value;
|
||||
update();
|
||||
notify("testValue",oldValue,value);
|
||||
notify("testValue", oldValue, value);
|
||||
}
|
||||
}
|
||||
|
||||
void BarcodeItem::setForegroundColor(QColor value)
|
||||
{
|
||||
if (m_foregroundColor != value){
|
||||
if (m_foregroundColor != value) {
|
||||
QColor oldValue = m_foregroundColor;
|
||||
m_foregroundColor=value;
|
||||
m_foregroundColor = value;
|
||||
update();
|
||||
notify("foregroundColor",oldValue,value);
|
||||
notify("foregroundColor", oldValue, value);
|
||||
}
|
||||
}
|
||||
|
||||
void BarcodeItem::setBackgroundColor(QColor value)
|
||||
{
|
||||
if (m_backgroundColor != value){
|
||||
if (m_backgroundColor != value) {
|
||||
QColor oldValue = m_backgroundColor;
|
||||
m_backgroundColor=value;
|
||||
m_backgroundColor = value;
|
||||
update();
|
||||
notify("backgroundColor",oldValue,value);
|
||||
notify("backgroundColor", oldValue, value);
|
||||
}
|
||||
}
|
||||
|
||||
void BarcodeItem::setWhitespace(int value)
|
||||
{
|
||||
if (m_whitespace != value){
|
||||
if (m_whitespace != value) {
|
||||
int oldValue = m_whitespace;
|
||||
m_whitespace = value;
|
||||
update();
|
||||
notify("whitespace",oldValue,value);
|
||||
notify("whitespace", oldValue, value);
|
||||
}
|
||||
}
|
||||
|
||||
BarcodeItem::AngleType BarcodeItem::angle() const
|
||||
{
|
||||
return m_angle;
|
||||
}
|
||||
BarcodeItem::AngleType BarcodeItem::angle() const { return m_angle; }
|
||||
|
||||
void BarcodeItem::setAngle(const AngleType &angle)
|
||||
void BarcodeItem::setAngle(const AngleType& angle)
|
||||
{
|
||||
if (m_angle!=angle){
|
||||
if (m_angle != angle) {
|
||||
AngleType oldValue = m_angle;
|
||||
m_angle = angle;
|
||||
if (!isLoading()){
|
||||
if (!isLoading()) {
|
||||
update();
|
||||
notify("angle",oldValue,angle);
|
||||
notify("angle", oldValue, angle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int BarcodeItem::barcodeWidth() const
|
||||
{
|
||||
return m_barcodeWidth;
|
||||
}
|
||||
int BarcodeItem::barcodeWidth() const { return m_barcodeWidth; }
|
||||
|
||||
void BarcodeItem::setBarcodeWidth(int barcodeWidth)
|
||||
{
|
||||
if (m_barcodeWidth != barcodeWidth){
|
||||
if (m_barcodeWidth != barcodeWidth) {
|
||||
int oldValue = m_barcodeWidth;
|
||||
m_barcodeWidth = barcodeWidth;
|
||||
if (!isLoading()){
|
||||
if (!isLoading()) {
|
||||
update();
|
||||
notify("barcodeWidth",oldValue,m_barcodeWidth);
|
||||
notify("barcodeWidth", oldValue, m_barcodeWidth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int BarcodeItem::securityLevel() const
|
||||
{
|
||||
return m_securityLevel;
|
||||
}
|
||||
int BarcodeItem::securityLevel() const { return m_securityLevel; }
|
||||
|
||||
void BarcodeItem::setSecurityLevel(int securityLevel)
|
||||
{
|
||||
if (m_securityLevel != securityLevel){
|
||||
if (m_securityLevel != securityLevel) {
|
||||
int oldValue = m_securityLevel;
|
||||
m_securityLevel = securityLevel;
|
||||
if (!isLoading()){
|
||||
if (!isLoading()) {
|
||||
update();
|
||||
notify("securityLevel",oldValue,m_securityLevel);
|
||||
notify("securityLevel", oldValue, m_securityLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int BarcodeItem::pdf417CodeWords() const
|
||||
{
|
||||
return m_pdf417CodeWords;
|
||||
}
|
||||
int BarcodeItem::pdf417CodeWords() const { return m_pdf417CodeWords; }
|
||||
|
||||
void BarcodeItem::setPdf417CodeWords(int pdf417CodeWords)
|
||||
{
|
||||
if (m_pdf417CodeWords != pdf417CodeWords){
|
||||
if (m_pdf417CodeWords != pdf417CodeWords) {
|
||||
int oldValue = m_pdf417CodeWords;
|
||||
m_pdf417CodeWords = pdf417CodeWords;
|
||||
if (!isLoading()){
|
||||
if (!isLoading()) {
|
||||
update();
|
||||
notify("pdf417CodeWords",oldValue,m_pdf417CodeWords);
|
||||
notify("pdf417CodeWords", oldValue, m_pdf417CodeWords);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BarcodeItem::InputMode BarcodeItem::inputMode() const
|
||||
{
|
||||
return m_inputMode;
|
||||
}
|
||||
BarcodeItem::InputMode BarcodeItem::inputMode() const { return m_inputMode; }
|
||||
|
||||
void BarcodeItem::setInputMode(const InputMode &inputMode)
|
||||
void BarcodeItem::setInputMode(const InputMode& inputMode)
|
||||
{
|
||||
if (m_inputMode != inputMode){
|
||||
if (m_inputMode != inputMode) {
|
||||
InputMode oldValue = m_inputMode;
|
||||
m_inputMode = inputMode;
|
||||
if (!isLoading()){
|
||||
if (!isLoading()) {
|
||||
update();
|
||||
notify("inputMode",oldValue,inputMode);
|
||||
notify("inputMode", oldValue, inputMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool BarcodeItem::hideText() const
|
||||
{
|
||||
return m_hideText;
|
||||
}
|
||||
bool BarcodeItem::hideText() const { return m_hideText; }
|
||||
|
||||
void BarcodeItem::setHideText(bool hideText)
|
||||
{
|
||||
if (m_hideText != hideText){
|
||||
if (m_hideText != hideText) {
|
||||
m_hideText = hideText;
|
||||
if (!isLoading()){
|
||||
if (!isLoading()) {
|
||||
update();
|
||||
notify("hideText", !m_hideText, m_hideText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int BarcodeItem::option3() const
|
||||
{
|
||||
return m_option3;
|
||||
}
|
||||
int BarcodeItem::option3() const { return m_option3; }
|
||||
|
||||
void BarcodeItem::setOption3(int option3)
|
||||
{
|
||||
if (m_option3 != option3){
|
||||
if (m_option3 != option3) {
|
||||
int oldValue = m_option3;
|
||||
m_option3 = option3;
|
||||
if(!isLoading()){
|
||||
if (!isLoading()) {
|
||||
update();
|
||||
notify("option3", oldValue, m_option3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool BarcodeItem::hideIfEmpty() const
|
||||
{
|
||||
return m_hideIfEmpty;
|
||||
}
|
||||
bool BarcodeItem::hideIfEmpty() const { return m_hideIfEmpty; }
|
||||
|
||||
void BarcodeItem::setHideIfEmpty(bool hideIfEmpty)
|
||||
{
|
||||
if (m_hideIfEmpty != hideIfEmpty){
|
||||
if (m_hideIfEmpty != hideIfEmpty) {
|
||||
m_hideIfEmpty = hideIfEmpty;
|
||||
notify("hideIfEmpty",!m_hideIfEmpty, m_hideIfEmpty);
|
||||
notify("hideIfEmpty", !m_hideIfEmpty, m_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;
|
||||
@ -363,7 +341,7 @@ void BarcodeItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch(pass){
|
||||
switch (pass) {
|
||||
case FirstPass:
|
||||
expandContent(content(), 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,11 +30,12 @@
|
||||
#ifndef LRBARCODEITEM_H
|
||||
#define LRBARCODEITEM_H
|
||||
#include "lritemdesignintf.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class BarcodeItem : public LimeReport::ContentItemDesignIntf {
|
||||
class BarcodeItem: public LimeReport::ContentItemDesignIntf {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString content READ content WRITE setContent)
|
||||
Q_PROPERTY(BarcodeType barcodeType READ barcodeType WRITE setBarcodeType)
|
||||
@ -54,98 +55,102 @@ class BarcodeItem : public LimeReport::ContentItemDesignIntf {
|
||||
Q_PROPERTY(bool hideIfEmpty READ hideIfEmpty WRITE setHideIfEmpty)
|
||||
public:
|
||||
enum BarcodeType {
|
||||
CODE11 =1,
|
||||
C25MATRIX =2,
|
||||
C25INTER =3,
|
||||
C25IATA =4,
|
||||
C25LOGIC =6,
|
||||
C25IND =7,
|
||||
CODE39 =8,
|
||||
EXCODE39 =9,
|
||||
EANX =13,
|
||||
EANX_CHK =14,
|
||||
EAN128 =16,
|
||||
CODABAR =18,
|
||||
CODE128 =20,
|
||||
DPLEIT =21,
|
||||
DPIDENT =22,
|
||||
CODE16K =23,
|
||||
CODE93 =25,
|
||||
FLAT =28,
|
||||
RSS14 =29,
|
||||
RSS_LTD =30,
|
||||
RSS_EXP =31,
|
||||
TELEPEN =32,
|
||||
UPCA =34,
|
||||
UPCE =37,
|
||||
POSTNET =40,
|
||||
MSI_PLESSEY =47,
|
||||
FIM =49,
|
||||
LOGMARS =50,
|
||||
PHARMA =51,
|
||||
PZN =52,
|
||||
PHARMA_TWO =53,
|
||||
PDF417 =55,
|
||||
PDF417TRUNC =56,
|
||||
MAXICODE =57,
|
||||
QRCODE =58,
|
||||
CODE128B =60,
|
||||
AUSPOST =63,
|
||||
AUSREPLY =66,
|
||||
AUSROUTE =67,
|
||||
AUSREDIRECT =68,
|
||||
ISBNX =69,
|
||||
RM4SCC =70,
|
||||
DATAMATRIX =71,
|
||||
ITF14 =72,
|
||||
CODABLOCKF =74,
|
||||
NVE18 =75,
|
||||
KOREAPOST =77,
|
||||
RSS14STACK =79,
|
||||
RSS14STACK_OMNI =80,
|
||||
RSS_EXPSTACK =81,
|
||||
PLANET =82,
|
||||
MICROPDF417 =84,
|
||||
ONECODE =85,
|
||||
PLESSEY =86,
|
||||
KIX =90,
|
||||
AZTEC =92,
|
||||
DAFT =93,
|
||||
ITALYPOST =94,
|
||||
DPD =96,
|
||||
MICROQR =97,
|
||||
HIBC_128 =98,
|
||||
HIBC_39 =99,
|
||||
HIBC_DM =102,
|
||||
HIBC_QR =104,
|
||||
HIBC_PDF =106,
|
||||
HIBC_MICPDF =108,
|
||||
HIBC_BLOCKF =110,
|
||||
HIBC_AZTEC =112,
|
||||
DOTCODE =115,
|
||||
HANXIN =116,
|
||||
TELEPEN_NUM =128,
|
||||
CODE32 =129,
|
||||
// EANX_CC =130,
|
||||
// EAN128_CC =131,
|
||||
// RSS14_CC =132,
|
||||
// RSS_LTD_CC =133,
|
||||
// RSS_EXP_CC =134,
|
||||
// UPCA_CC =135,
|
||||
// UPCE_CC =136,
|
||||
// RSS14STACK_CC =137,
|
||||
// RSS14_OMNI_CC =138,
|
||||
// RSS_EXPSTACK_CC =139,
|
||||
CHANNEL =140,
|
||||
CODEONE =141,
|
||||
GRIDMATRIX =142,
|
||||
UPNQR =143
|
||||
|
||||
CODE11 = 1,
|
||||
C25MATRIX = 2,
|
||||
C25INTER = 3,
|
||||
C25IATA = 4,
|
||||
C25LOGIC = 6,
|
||||
C25IND = 7,
|
||||
CODE39 = 8,
|
||||
EXCODE39 = 9,
|
||||
EANX = 13,
|
||||
EANX_CHK = 14,
|
||||
EAN128 = 16,
|
||||
CODABAR = 18,
|
||||
CODE128 = 20,
|
||||
DPLEIT = 21,
|
||||
DPIDENT = 22,
|
||||
CODE16K = 23,
|
||||
CODE93 = 25,
|
||||
FLAT = 28,
|
||||
RSS14 = 29,
|
||||
RSS_LTD = 30,
|
||||
RSS_EXP = 31,
|
||||
TELEPEN = 32,
|
||||
UPCA = 34,
|
||||
UPCE = 37,
|
||||
POSTNET = 40,
|
||||
MSI_PLESSEY = 47,
|
||||
FIM = 49,
|
||||
LOGMARS = 50,
|
||||
PHARMA = 51,
|
||||
PZN = 52,
|
||||
PHARMA_TWO = 53,
|
||||
PDF417 = 55,
|
||||
PDF417TRUNC = 56,
|
||||
MAXICODE = 57,
|
||||
QRCODE = 58,
|
||||
CODE128B = 60,
|
||||
AUSPOST = 63,
|
||||
AUSREPLY = 66,
|
||||
AUSROUTE = 67,
|
||||
AUSREDIRECT = 68,
|
||||
ISBNX = 69,
|
||||
RM4SCC = 70,
|
||||
DATAMATRIX = 71,
|
||||
ITF14 = 72,
|
||||
CODABLOCKF = 74,
|
||||
NVE18 = 75,
|
||||
KOREAPOST = 77,
|
||||
RSS14STACK = 79,
|
||||
RSS14STACK_OMNI = 80,
|
||||
RSS_EXPSTACK = 81,
|
||||
PLANET = 82,
|
||||
MICROPDF417 = 84,
|
||||
ONECODE = 85,
|
||||
PLESSEY = 86,
|
||||
KIX = 90,
|
||||
AZTEC = 92,
|
||||
DAFT = 93,
|
||||
ITALYPOST = 94,
|
||||
DPD = 96,
|
||||
MICROQR = 97,
|
||||
HIBC_128 = 98,
|
||||
HIBC_39 = 99,
|
||||
HIBC_DM = 102,
|
||||
HIBC_QR = 104,
|
||||
HIBC_PDF = 106,
|
||||
HIBC_MICPDF = 108,
|
||||
HIBC_BLOCKF = 110,
|
||||
HIBC_AZTEC = 112,
|
||||
DOTCODE = 115,
|
||||
HANXIN = 116,
|
||||
TELEPEN_NUM = 128,
|
||||
CODE32 = 129,
|
||||
// EANX_CC =130,
|
||||
// EAN128_CC =131,
|
||||
// RSS14_CC =132,
|
||||
// RSS_LTD_CC =133,
|
||||
// RSS_EXP_CC =134,
|
||||
// UPCA_CC =135,
|
||||
// UPCE_CC =136,
|
||||
// RSS14STACK_CC =137,
|
||||
// RSS14_OMNI_CC =138,
|
||||
// RSS_EXPSTACK_CC =139,
|
||||
CHANNEL = 140,
|
||||
CODEONE = 141,
|
||||
GRIDMATRIX = 142,
|
||||
UPNQR = 143
|
||||
};
|
||||
|
||||
enum AngleType{Angle0,Angle90,Angle180,Angle270};
|
||||
enum AngleType {
|
||||
Angle0,
|
||||
Angle90,
|
||||
Angle180,
|
||||
Angle270
|
||||
};
|
||||
|
||||
enum InputMode{
|
||||
enum InputMode {
|
||||
DATA_INPUT_MODE = 0,
|
||||
UNICODE_INPUT_MODE = 1,
|
||||
GS1_INPUT_MODE = 2,
|
||||
@ -161,30 +166,30 @@ public:
|
||||
Q_ENUMS(AngleType)
|
||||
Q_ENUMS(InputMode)
|
||||
#endif
|
||||
BarcodeItem(QObject *owner, QGraphicsItem *parent);
|
||||
BarcodeItem(QObject* owner, QGraphicsItem* parent);
|
||||
~BarcodeItem();
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject *owner, QGraphicsItem *parent);
|
||||
virtual void paint(QPainter *ppainter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
virtual void updateItemSize(DataSourceManager *dataManager, RenderPass pass, int maxHeight);
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner, QGraphicsItem* parent);
|
||||
virtual void paint(QPainter* ppainter, const QStyleOptionGraphicsItem* option, QWidget* widget);
|
||||
virtual void updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight);
|
||||
virtual bool isNeedUpdateSize(RenderPass pass) const;
|
||||
void setContent(const QString& content);
|
||||
QString content() const {return m_content;}
|
||||
QString content() const { return m_content; }
|
||||
void setBarcodeType(BarcodeType value);
|
||||
BarcodeType barcodeType(){return m_barcodeType;}
|
||||
BarcodeType barcodeType() { return m_barcodeType; }
|
||||
QString datasource() const;
|
||||
void setDatasource(const QString &datasource);
|
||||
void setDatasource(const QString& datasource);
|
||||
QString field() const;
|
||||
void setField(const QString &field);
|
||||
void setField(const QString& field);
|
||||
void setDesignTestValue(QString value);
|
||||
QString designTestValue(){return m_designTestValue;}
|
||||
QColor foregroundColor(){return m_foregroundColor;}
|
||||
QString designTestValue() { return m_designTestValue; }
|
||||
QColor foregroundColor() { return m_foregroundColor; }
|
||||
void setForegroundColor(QColor value);
|
||||
QColor backgroundColor(){return m_backgroundColor;}
|
||||
QColor backgroundColor() { return m_backgroundColor; }
|
||||
void setBackgroundColor(QColor value);
|
||||
int whitespace(){return m_whitespace;}
|
||||
int whitespace() { return m_whitespace; }
|
||||
void setWhitespace(int value);
|
||||
AngleType angle() const;
|
||||
void setAngle(const AngleType &angle);
|
||||
void setAngle(const AngleType& angle);
|
||||
int barcodeWidth() const;
|
||||
void setBarcodeWidth(int barcodeWidth);
|
||||
int securityLevel() const;
|
||||
@ -192,7 +197,7 @@ public:
|
||||
int pdf417CodeWords() const;
|
||||
void setPdf417CodeWords(int pdf417CodeWords);
|
||||
InputMode inputMode() const;
|
||||
void setInputMode(const InputMode &inputMode);
|
||||
void setInputMode(const InputMode& inputMode);
|
||||
bool hideText() const;
|
||||
void setHideText(bool hideText);
|
||||
int option3() const;
|
||||
@ -202,7 +207,7 @@ public:
|
||||
bool isEmpty() const;
|
||||
|
||||
private:
|
||||
void expandContent(QString data, DataSourceManager *dataManager, RenderPass pass);
|
||||
void expandContent(QString data, DataSourceManager* dataManager, RenderPass pass);
|
||||
|
||||
private:
|
||||
QString m_content;
|
||||
@ -223,5 +228,5 @@ private:
|
||||
bool m_hideIfEmpty;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRBARCODEITEM_H
|
||||
|
@ -1,34 +1,39 @@
|
||||
#include "lrbordereditor.h"
|
||||
#include "ui_lrbordereditor.h"
|
||||
#include <QColorDialog>
|
||||
|
||||
#include "lrbasedesignintf.h"
|
||||
|
||||
namespace LimeReport{
|
||||
#include <QColorDialog>
|
||||
|
||||
BorderEditor::BorderEditor(QWidget *parent) :
|
||||
namespace LimeReport {
|
||||
|
||||
BorderEditor::BorderEditor(QWidget* parent):
|
||||
QDialog(parent),
|
||||
ui(new Ui::BorderEditor),
|
||||
m_borderStyle(1),
|
||||
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)
|
||||
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());
|
||||
@ -39,7 +44,7 @@ void BorderEditor::loadItem(LimeReport::BaseDesignIntf *item)
|
||||
ui->listWidget->setCurrentRow((Qt::PenStyle)item->borderStyle());
|
||||
ui->comboBox->setCurrentText(QString::number(item->borderLineSize()));
|
||||
m_borderWidth = ui->comboBox->currentText().toDouble();
|
||||
m_borderStyle =ui->listWidget->currentRow();
|
||||
m_borderStyle = ui->listWidget->currentRow();
|
||||
ui->colorIndicator->setStyleSheet(QString("background-color:%1;").arg(m_borderColor));
|
||||
}
|
||||
|
||||
@ -50,28 +55,19 @@ LimeReport::BaseDesignIntf::BorderLines BorderEditor::borderSides()
|
||||
borders += (ui->bottomLine->isChecked()) ? LimeReport::BaseDesignIntf::BottomLine : 0;
|
||||
borders += (ui->leftLine->isChecked()) ? LimeReport::BaseDesignIntf::LeftLine : 0;
|
||||
borders += (ui->rightLine->isChecked()) ? LimeReport::BaseDesignIntf::RightLine : 0;
|
||||
return (LimeReport::BaseDesignIntf::BorderLines) borders;
|
||||
return (LimeReport::BaseDesignIntf::BorderLines)borders;
|
||||
}
|
||||
|
||||
LimeReport::BaseDesignIntf::BorderStyle BorderEditor::borderStyle()
|
||||
{
|
||||
return (LimeReport::BaseDesignIntf::BorderStyle) m_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)
|
||||
{
|
||||
@ -81,7 +77,7 @@ void BorderEditor::on_listWidget_currentRowChanged(int currentRow)
|
||||
ui->borderFrame->setPen(pen);
|
||||
}
|
||||
|
||||
void BorderEditor::on_comboBox_currentTextChanged(const QString &arg1)
|
||||
void BorderEditor::on_comboBox_currentTextChanged(const QString& arg1)
|
||||
{
|
||||
QPen pen = ui->borderFrame->pen();
|
||||
pen.setWidthF(arg1.toDouble());
|
||||
@ -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,23 +1,22 @@
|
||||
#ifndef LRBORDEREDITOR_H
|
||||
#define LRBORDEREDITOR_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "lrbasedesignintf.h"
|
||||
|
||||
namespace LimeReport{
|
||||
#include <QDialog>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
namespace Ui {
|
||||
class BorderEditor;
|
||||
}
|
||||
|
||||
|
||||
class LIMEREPORT_EXPORT BorderEditor : public QDialog
|
||||
{
|
||||
class LIMEREPORT_EXPORT BorderEditor: public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BorderEditor(QWidget *parent = nullptr);
|
||||
void loadItem(LimeReport::BaseDesignIntf *item);
|
||||
explicit BorderEditor(QWidget* parent = nullptr);
|
||||
void loadItem(LimeReport::BaseDesignIntf* item);
|
||||
LimeReport::BaseDesignIntf::BorderLines borderSides();
|
||||
LimeReport::BaseDesignIntf::BorderStyle borderStyle();
|
||||
QString borderColor();
|
||||
@ -26,7 +25,7 @@ public:
|
||||
|
||||
private slots:
|
||||
void on_listWidget_currentRowChanged(int currentRow);
|
||||
void on_comboBox_currentTextChanged(const QString &arg1);
|
||||
void on_comboBox_currentTextChanged(const QString& arg1);
|
||||
void on_noLines_clicked();
|
||||
void on_topLine_clicked(bool checked);
|
||||
void on_bottomLine_clicked(bool checked);
|
||||
@ -37,8 +36,8 @@ private slots:
|
||||
void on_selectColor_clicked();
|
||||
|
||||
private:
|
||||
Ui::BorderEditor *ui;
|
||||
LimeReport::BaseDesignIntf *m_item;
|
||||
Ui::BorderEditor* ui;
|
||||
LimeReport::BaseDesignIntf* m_item;
|
||||
QString m_borderColor;
|
||||
int m_borderStyle;
|
||||
double m_borderWidth;
|
||||
|
@ -1,57 +1,56 @@
|
||||
#include "lrborderframeeditor.h"
|
||||
#include "ui_lrborderframeeditor.h"
|
||||
#include <QPainter>
|
||||
#include <QGraphicsLineItem>
|
||||
#include <QDebug>
|
||||
#include <QMouseEvent>
|
||||
|
||||
#include "lrbasedesignintf.h"
|
||||
#include "lrbordereditor.h"
|
||||
|
||||
namespace LimeReport{
|
||||
#include <QDebug>
|
||||
#include <QGraphicsLineItem>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
|
||||
BorderFrameEditor::BorderFrameEditor(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::BorderFrameEditor)
|
||||
namespace LimeReport {
|
||||
|
||||
BorderFrameEditor::BorderFrameEditor(QWidget* parent):
|
||||
QWidget(parent),
|
||||
ui(new Ui::BorderFrameEditor)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
scene = new QGraphicsScene(ui->graphicsView);
|
||||
|
||||
QRect vRect = rect();
|
||||
|
||||
//Draw corder lines
|
||||
//topLeft
|
||||
// Draw corder lines
|
||||
// topLeft
|
||||
scene->addLine(10, 5, 10, 10, QPen(Qt::gray));
|
||||
scene->addLine(5, 10, 10, 10, QPen(Qt::gray));
|
||||
//bottomLeft
|
||||
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));
|
||||
//topRight
|
||||
// bottomLeft
|
||||
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));
|
||||
// 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));
|
||||
scene->setSceneRect(vRect);
|
||||
ui->graphicsView->setScene(scene);
|
||||
QGraphicsSimpleTextItem * io = new QGraphicsSimpleTextItem();
|
||||
QGraphicsSimpleTextItem* io = new QGraphicsSimpleTextItem();
|
||||
io->setAcceptedMouseButtons(Qt::LeftButton);
|
||||
io->setPos(scene->sceneRect().center());
|
||||
io->setText(tr("Text"));
|
||||
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()
|
||||
{
|
||||
@ -78,34 +74,33 @@ void BorderFrameEditor::setAllLines()
|
||||
|
||||
void BorderFrameEditor::unSetAllLines()
|
||||
{
|
||||
if (topLine){
|
||||
if (topLine) {
|
||||
scene->removeItem(topLine);
|
||||
topLine = NULL;
|
||||
}
|
||||
if (leftLine){
|
||||
if (leftLine) {
|
||||
scene->removeItem(leftLine);
|
||||
leftLine = NULL;
|
||||
}
|
||||
if (bottomLine){
|
||||
if (bottomLine) {
|
||||
scene->removeItem(bottomLine);
|
||||
bottomLine = NULL;
|
||||
}
|
||||
if (rightLine){
|
||||
if (rightLine) {
|
||||
scene->removeItem(rightLine);
|
||||
rightLine = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void BorderFrameEditor::mousePressEvent(QMouseEvent *event)
|
||||
void BorderFrameEditor::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
if (event->x() >= 10 && event->y() <30)
|
||||
if (event->x() >= 10 && event->y() < 30)
|
||||
emit borderSideClicked(BaseDesignIntf::BorderSide::TopLine, !topLine);
|
||||
|
||||
if ((event->x() >= 10 && event->x() < 30) && (event->y() > 10))
|
||||
emit borderSideClicked(BaseDesignIntf::BorderSide::LeftLine, !leftLine);
|
||||
|
||||
if (event->x() >= 10 && (event->y() >80 && event->y() < rect().bottom()))
|
||||
if (event->x() >= 10 && (event->y() > 80 && event->y() < rect().bottom()))
|
||||
emit borderSideClicked(BaseDesignIntf::BorderSide::BottomLine, !bottomLine);
|
||||
|
||||
if ((event->x() >= 130 && event->x() < rect().width()) && event->y() > 10)
|
||||
@ -115,67 +110,80 @@ void BorderFrameEditor::mousePressEvent(QMouseEvent *event)
|
||||
void BorderFrameEditor::slotBorderSideClicked(BaseDesignIntf::BorderSide side, bool show)
|
||||
{
|
||||
|
||||
switch(side){
|
||||
switch (side) {
|
||||
|
||||
case BaseDesignIntf::BorderSide::TopLine:
|
||||
if (show){
|
||||
if (!topLine) topLine = createSideLine(side);
|
||||
if (show) {
|
||||
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 (show) {
|
||||
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 (show) {
|
||||
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 (show) {
|
||||
if (!rightLine)
|
||||
rightLine = createSideLine(side);
|
||||
} else {
|
||||
if(rightLine) scene->removeItem(rightLine);
|
||||
if (rightLine)
|
||||
scene->removeItem(rightLine);
|
||||
rightLine = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
updateBorders();
|
||||
}
|
||||
|
||||
QGraphicsLineItem *BorderFrameEditor::createSideLine(LimeReport::BaseDesignIntf::BorderSide side)
|
||||
QGraphicsLineItem* BorderFrameEditor::createSideLine(LimeReport::BaseDesignIntf::BorderSide side)
|
||||
{
|
||||
switch(side){
|
||||
switch (side) {
|
||||
case BaseDesignIntf::BorderSide::TopLine:
|
||||
return scene->addLine(QLineF(10, 10, rect().width() - 10, 10), m_pen);
|
||||
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
|
||||
} // namespace LimeReport
|
||||
|
@ -1,46 +1,44 @@
|
||||
#ifndef WIDGET
|
||||
#define WIDGET
|
||||
|
||||
#include <QWidget>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsLineItem>
|
||||
#include "lrbasedesignintf.h"
|
||||
namespace LimeReport{
|
||||
|
||||
namespace Ui { class BorderFrameEditor; }
|
||||
#include <QGraphicsLineItem>
|
||||
#include <QGraphicsScene>
|
||||
#include <QWidget>
|
||||
namespace LimeReport {
|
||||
|
||||
class BorderFrameEditor : public QWidget
|
||||
{
|
||||
namespace Ui {
|
||||
class BorderFrameEditor;
|
||||
}
|
||||
|
||||
class BorderFrameEditor: public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
BorderFrameEditor(QWidget *parent = nullptr);
|
||||
BorderFrameEditor(QWidget* parent = nullptr);
|
||||
~BorderFrameEditor();
|
||||
void setPen(QPen pen);
|
||||
QPen pen();
|
||||
void setAllLines();
|
||||
void unSetAllLines();
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
signals:
|
||||
void borderSideClicked(LimeReport::BaseDesignIntf::BorderSide side, bool show);
|
||||
private slots:
|
||||
void slotBorderSideClicked(LimeReport::BaseDesignIntf::BorderSide side, bool show);
|
||||
|
||||
private:
|
||||
QGraphicsLineItem *createSideLine(LimeReport::BaseDesignIntf::BorderSide side);
|
||||
QGraphicsLineItem* createSideLine(LimeReport::BaseDesignIntf::BorderSide side);
|
||||
void updateBorders();
|
||||
|
||||
private:
|
||||
Ui::BorderFrameEditor *ui;
|
||||
QGraphicsScene *scene;
|
||||
QGraphicsLineItem *topLine = NULL
|
||||
,*bottomLine = NULL
|
||||
,*leftLine = NULL
|
||||
,*rightLine = NULL;
|
||||
Ui::BorderFrameEditor* ui;
|
||||
QGraphicsScene* scene;
|
||||
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();
|
||||
@ -24,16 +28,17 @@ ChartAxisEditor::~ChartAxisEditor()
|
||||
|
||||
QSettings* ChartAxisEditor::settings()
|
||||
{
|
||||
if (m_settings){
|
||||
if (m_settings) {
|
||||
return m_settings;
|
||||
}
|
||||
m_settings = new QSettings("LimeReport",QCoreApplication::applicationName());
|
||||
m_settings = new QSettings("LimeReport", QCoreApplication::applicationName());
|
||||
return m_settings;
|
||||
}
|
||||
|
||||
void ChartAxisEditor::readSetting()
|
||||
{
|
||||
if (settings() == 0) return;
|
||||
if (settings() == 0)
|
||||
return;
|
||||
|
||||
settings()->beginGroup("ChartAxisEditor");
|
||||
QVariant v = settings()->value("Geometry");
|
||||
@ -50,7 +55,7 @@ void ChartAxisEditor::writeSetting()
|
||||
return;
|
||||
}
|
||||
settings()->beginGroup("ChartAxisEditor");
|
||||
settings()->setValue("Geometry",saveGeometry());
|
||||
settings()->setValue("Geometry", saveGeometry());
|
||||
settings()->endGroup();
|
||||
}
|
||||
|
||||
@ -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,22 +1,22 @@
|
||||
#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:
|
||||
public:
|
||||
ChartAxisEditor(LimeReport::ChartItem* item, LimeReport::PageDesignIntf* page, bool isXAxis,
|
||||
QSettings* settings=0, QWidget *parent = 0);
|
||||
QSettings* settings = 0, QWidget* parent = 0);
|
||||
~ChartAxisEditor();
|
||||
|
||||
QSettings *settings();
|
||||
QSettings* settings();
|
||||
private slots:
|
||||
void on_minimumCheckBox_stateChanged(int arg1);
|
||||
void on_maximumCheckBox_stateChanged(int arg1);
|
||||
@ -31,7 +31,7 @@ private:
|
||||
void writeSetting();
|
||||
void init();
|
||||
|
||||
Ui::ChartAxisEditor *ui;
|
||||
Ui::ChartAxisEditor* ui;
|
||||
LimeReport::ChartItem* m_chartItem;
|
||||
LimeReport::PageDesignIntf* m_page;
|
||||
QSettings* m_settings;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,32 +1,39 @@
|
||||
#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{
|
||||
namespace LimeReport {
|
||||
|
||||
QColor generateColor();
|
||||
extern QColor color_map[39];
|
||||
|
||||
class IDataSource;
|
||||
|
||||
class SeriesItemData : public QObject{
|
||||
class SeriesItemData: public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QList<qreal>& values(){ return m_values;}
|
||||
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(); }
|
||||
QList<qreal>& values() { return m_values; }
|
||||
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();
|
||||
}
|
||||
|
||||
private:
|
||||
QList<qreal> m_values, m_xAxisValues;
|
||||
QList<QString> m_labels;
|
||||
QList<QColor> m_colors;
|
||||
};
|
||||
|
||||
class SeriesItem : public QObject{
|
||||
class SeriesItem: public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
Q_PROPERTY(QString valuesColumn READ valuesColumn WRITE setValuesColumn)
|
||||
@ -35,29 +42,33 @@ 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
|
||||
Q_ENUMS(SeriesItemPreferredType)
|
||||
#endif
|
||||
SeriesItem(QObject* parent = 0) : QObject(parent), m_preferredType(Bar){}
|
||||
SeriesItem(QObject* parent = 0): QObject(parent), m_preferredType(Bar) { }
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
void setName(const QString& name);
|
||||
QString valuesColumn() const;
|
||||
void setValuesColumn(const QString &valuesColumn);
|
||||
void setValuesColumn(const QString& valuesColumn);
|
||||
QString labelsColumn() const;
|
||||
void setLabelsColumn(const QString &labelsColumn);
|
||||
void setLabelsColumn(const QString& labelsColumn);
|
||||
QString xAxisColumn() const;
|
||||
void setXAxisColumn(const QString &xAxisColumn);
|
||||
void setXAxisColumn(const QString& xAxisColumn);
|
||||
SeriesItem* clone();
|
||||
void fillSeriesData(IDataSource* dataSource);
|
||||
SeriesItemData* data(){ return &m_data;}
|
||||
SeriesItemData* data() { return &m_data; }
|
||||
QColor color() const;
|
||||
void setColor(const QColor &color);
|
||||
void setColor(const QColor& color);
|
||||
SeriesItemPreferredType preferredType() const;
|
||||
void setPreferredType(const SeriesItemPreferredType& preferredType);
|
||||
bool isEmpty(){ return m_data.values().isEmpty();}
|
||||
bool isEmpty() { return m_data.values().isEmpty(); }
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
QString m_valuesColumn;
|
||||
@ -73,17 +84,20 @@ class ChartItem;
|
||||
class AbstractChart {
|
||||
public:
|
||||
AbstractChart(ChartItem* chartItem);
|
||||
virtual ~AbstractChart(){}
|
||||
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 ~AbstractChart() { }
|
||||
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);
|
||||
|
||||
QFont titleFont();
|
||||
void setTitleFont(const QFont &value);
|
||||
void setTitleFont(const QFont& value);
|
||||
|
||||
protected:
|
||||
QVector<qreal> legendColumnWidths() const;
|
||||
virtual void prepareLegendToPaint(QRectF& legendRect, QPainter *painter);
|
||||
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
|
||||
@ -93,57 +107,60 @@ protected:
|
||||
QVector<qreal> m_legendColumnWidths;
|
||||
};
|
||||
|
||||
class AbstractSeriesChart: public AbstractChart{
|
||||
class AbstractSeriesChart: public AbstractChart {
|
||||
public:
|
||||
AbstractSeriesChart(ChartItem* chartItem);
|
||||
|
||||
protected:
|
||||
AxisData &xAxisData() const;
|
||||
AxisData &yAxisData() const;
|
||||
AxisData& xAxisData() const;
|
||||
AxisData& yAxisData() const;
|
||||
qreal maxValue();
|
||||
qreal minValue();
|
||||
void updateMinAndMaxValues();
|
||||
int valuesCount();
|
||||
int seriesCount();
|
||||
bool verticalLabels(QPainter* painter, QRectF labelsRect);
|
||||
QSizeF calcChartLegendSize(const QFont &font, qreal maxWidth);
|
||||
qreal* designValues(){ return m_designValues;}
|
||||
QSizeF calcChartLegendSize(const QFont& font, qreal maxWidth);
|
||||
qreal* designValues() { return m_designValues; }
|
||||
virtual qreal hPadding(QRectF chartRect);
|
||||
virtual qreal vPadding(QRectF chartRect);
|
||||
virtual void paintHorizontalLabels(QPainter *painter, QRectF labelsRect);
|
||||
virtual void paintVerticalLabels(QPainter *painter, QRectF labelsRect);
|
||||
virtual void paintHorizontalGrid(QPainter *painter, QRectF gridRect);
|
||||
virtual void paintGrid(QPainter *painter, QRectF gridRect);
|
||||
virtual void paintVerticalGrid(QPainter *painter, QRectF gridRect);
|
||||
virtual void drawSegment(QPainter *painter, QPoint startPoint, QPoint endPoint, QColor color);
|
||||
virtual qreal valuesHMargin(QPainter *painter);
|
||||
virtual qreal valuesVMargin(QPainter *painter);
|
||||
virtual void paintHorizontalLabels(QPainter* painter, QRectF labelsRect);
|
||||
virtual void paintVerticalLabels(QPainter* painter, QRectF labelsRect);
|
||||
virtual void paintHorizontalGrid(QPainter* painter, QRectF gridRect);
|
||||
virtual void paintGrid(QPainter* painter, QRectF gridRect);
|
||||
virtual void paintVerticalGrid(QPainter* painter, QRectF gridRect);
|
||||
virtual void drawSegment(QPainter* painter, QPoint startPoint, QPoint endPoint, QColor color);
|
||||
virtual qreal valuesHMargin(QPainter* painter);
|
||||
virtual qreal valuesVMargin(QPainter* painter);
|
||||
virtual QFont adaptLabelsFont(QRectF rect, QFont font);
|
||||
virtual QFont adaptFont(qreal width, QFont font, const AxisData &axisData);
|
||||
virtual QString axisLabel(int i, const AxisData &axisData);
|
||||
virtual QFont adaptFont(qreal width, QFont font, const AxisData& axisData);
|
||||
virtual QString axisLabel(int i, const AxisData& axisData);
|
||||
|
||||
private:
|
||||
bool calculateLegendColumnWidths(qreal indicatorWidth, qreal maxWidth, const QFontMetrics &fm);
|
||||
bool calculateLegendSingleColumnWidth(qreal ¤tRowWidth, int ¤tColumn, int &maxColumnCount,
|
||||
const qreal itemWidth, const qreal maxRowWidth);
|
||||
qreal m_designValues [9];
|
||||
bool calculateLegendColumnWidths(qreal indicatorWidth, qreal maxWidth, const QFontMetrics& fm);
|
||||
bool calculateLegendSingleColumnWidth(qreal& currentRowWidth, int& currentColumn,
|
||||
int& maxColumnCount, const qreal itemWidth,
|
||||
const qreal maxRowWidth);
|
||||
qreal m_designValues[9];
|
||||
};
|
||||
|
||||
class AbstractBarChart: public AbstractSeriesChart{
|
||||
class AbstractBarChart: public AbstractSeriesChart {
|
||||
public:
|
||||
AbstractBarChart(ChartItem* chartItem):AbstractSeriesChart(chartItem){}
|
||||
void paintChartLegend(QPainter *painter, QRectF legendRect);
|
||||
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)
|
||||
@ -160,23 +177,42 @@ class ChartItem : public LimeReport::ItemDesignIntf
|
||||
Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont)
|
||||
Q_PROPERTY(QFont font READ font WRITE setCharItemFont)
|
||||
|
||||
//linesChart
|
||||
// linesChart
|
||||
Q_PROPERTY(bool drawPoints READ drawPoints WRITE setDrawPoints)
|
||||
Q_PROPERTY(int seriesLineWidth READ seriesLineWidth WRITE setSeriesLineWidth)
|
||||
Q_PROPERTY(bool horizontalAxisOnTop READ horizontalAxisOnTop WRITE setHorizontalAxisOnTop)
|
||||
|
||||
//gridChart
|
||||
// gridChart
|
||||
Q_FLAGS(GridChartLines)
|
||||
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,
|
||||
@ -200,48 +236,48 @@ public:
|
||||
|
||||
ChartItem(QObject* owner, QGraphicsItem* parent);
|
||||
~ChartItem();
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
|
||||
|
||||
QObject* xAxisSettings();
|
||||
void setYAxisSettings(QObject *axis);
|
||||
void setYAxisSettings(QObject* axis);
|
||||
QObject* yAxisSettings();
|
||||
void setXAxisSettings(QObject *axis);
|
||||
void setXAxisSettings(QObject* axis);
|
||||
|
||||
AxisData *xAxisData();
|
||||
AxisData *yAxisData();
|
||||
AxisData* xAxisData();
|
||||
AxisData* yAxisData();
|
||||
|
||||
void showAxisEditorDialog(bool isXAxis);
|
||||
|
||||
QList<SeriesItem *> &series();
|
||||
void setSeries(const QList<SeriesItem *> &series);
|
||||
QList<SeriesItem*>& series();
|
||||
void setSeries(const QList<SeriesItem*>& series);
|
||||
bool isSeriesExists(const QString& name);
|
||||
|
||||
QString datasource() const;
|
||||
void setDatasource(const QString &datasource);
|
||||
void setDatasource(const QString& datasource);
|
||||
|
||||
QString chartTitle() const;
|
||||
void setChartTitle(const QString &chartTitle);
|
||||
void setChartTitle(const QString& chartTitle);
|
||||
|
||||
bool drawLegendBorder() const;
|
||||
void setDrawLegendBorder(bool drawLegendBorder);
|
||||
|
||||
LegendAlign legendAlign() const;
|
||||
void setLegendAlign(const LegendAlign &legendAlign);
|
||||
void setLegendAlign(const LegendAlign& legendAlign);
|
||||
|
||||
LegendStyle legendStyle() const;
|
||||
void setLegendStyle(const LegendStyle &legendStyle);
|
||||
void setLegendStyle(const LegendStyle& legendStyle);
|
||||
|
||||
TitleAlign titleAlign() const;
|
||||
void setTitleAlign(const TitleAlign &titleAlign);
|
||||
void setTitleAlign(const TitleAlign& titleAlign);
|
||||
|
||||
ChartType chartType() const;
|
||||
void setChartType(const ChartType &chartType);
|
||||
void setChartType(const ChartType& chartType);
|
||||
|
||||
QString labelsField() const;
|
||||
void setLabelsField(const QString &labelsField);
|
||||
void setLabelsField(const QString& labelsField);
|
||||
|
||||
QList<QString> labels() const;
|
||||
void setLabels(const QList<QString> &labels);
|
||||
void setLabels(const QList<QString>& labels);
|
||||
QWidget* defaultEditor();
|
||||
|
||||
bool showLegend() const;
|
||||
@ -254,7 +290,7 @@ public:
|
||||
void setSeriesLineWidth(int newSeriesLineWidth);
|
||||
|
||||
QString xAxisField() const;
|
||||
void setXAxisField(const QString &xAxisField);
|
||||
void setXAxisField(const QString& xAxisField);
|
||||
|
||||
bool horizontalAxisOnTop() const;
|
||||
void setHorizontalAxisOnTop(bool horizontalAxisOnTop);
|
||||
@ -266,20 +302,21 @@ public:
|
||||
void setTitleFont(QFont value);
|
||||
void setCharItemFont(QFont value);
|
||||
|
||||
QSettings *settings();
|
||||
QSettings* settings();
|
||||
|
||||
protected:
|
||||
void paintChartTitle(QPainter* painter, QRectF titleRect);
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject *owner, QGraphicsItem *parent);
|
||||
//ICollectionContainer
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner, QGraphicsItem* parent);
|
||||
// ICollectionContainer
|
||||
QObject* createElement(const QString& collectionName, const QString& elementType);
|
||||
int elementsCount(const QString& collectionName);
|
||||
QObject* elementAt(const QString& collectionName,int index);
|
||||
void collectionLoadFinished(const QString& collectionName){Q_UNUSED(collectionName)}
|
||||
void updateItemSize(DataSourceManager *dataManager, RenderPass, int);
|
||||
QObject* elementAt(const QString& collectionName, int index);
|
||||
void collectionLoadFinished(const QString& collectionName) { Q_UNUSED(collectionName) }
|
||||
void updateItemSize(DataSourceManager* dataManager, RenderPass, int);
|
||||
void fillLabels(IDataSource* dataSource);
|
||||
bool isNeedUpdateSize(RenderPass pass) const;
|
||||
void setSeries(ACollectionProperty series){Q_UNUSED(series)}
|
||||
void setSeries(ACollectionProperty series) { Q_UNUSED(series) }
|
||||
|
||||
private:
|
||||
QList<SeriesItem*> m_series;
|
||||
QString m_datasource;
|
||||
@ -302,5 +339,5 @@ private:
|
||||
LegendStyle m_legendStyle;
|
||||
AxisData *m_xAxisData, *m_yAxisData;
|
||||
};
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
#endif // LRCHARTITEM_H
|
||||
|
@ -1,21 +1,29 @@
|
||||
#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();
|
||||
colorLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_colorButton = new QToolButton();
|
||||
m_colorButton->setText("...");
|
||||
m_colorButton->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
|
||||
m_colorButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
m_colorIndicator = new ColorIndicator();
|
||||
m_colorIndicator->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
|
||||
m_colorIndicator->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
ui->colorWidget->setLayout(colorLayout);
|
||||
colorLayout->addWidget(m_colorIndicator);
|
||||
colorLayout->addWidget(m_colorButton);
|
||||
@ -38,10 +46,10 @@ ChartItemEditor::~ChartItemEditor()
|
||||
|
||||
QSettings* ChartItemEditor::settings()
|
||||
{
|
||||
if (m_settings){
|
||||
if (m_settings) {
|
||||
return m_settings;
|
||||
} else {
|
||||
m_settings = new QSettings("LimeReport",QCoreApplication::applicationName());
|
||||
m_settings = new QSettings("LimeReport", QCoreApplication::applicationName());
|
||||
m_ownedSettings = true;
|
||||
return m_settings;
|
||||
}
|
||||
@ -49,17 +57,18 @@ QSettings* ChartItemEditor::settings()
|
||||
|
||||
void ChartItemEditor::readSetting()
|
||||
{
|
||||
if (settings()==0) return;
|
||||
if (settings() == 0)
|
||||
return;
|
||||
|
||||
m_isReadingSetting = true;
|
||||
|
||||
settings()->beginGroup("ChartItemEditor");
|
||||
QVariant v = settings()->value("Geometry");
|
||||
if (v.isValid()){
|
||||
if (v.isValid()) {
|
||||
restoreGeometry(v.toByteArray());
|
||||
}
|
||||
v = settings()->value("State");
|
||||
if (v.isValid()){
|
||||
if (v.isValid()) {
|
||||
ui->splitter->restoreState(v.toByteArray());
|
||||
}
|
||||
|
||||
@ -70,10 +79,10 @@ void ChartItemEditor::readSetting()
|
||||
|
||||
void ChartItemEditor::writeSetting()
|
||||
{
|
||||
if (settings()!=0){
|
||||
if (settings() != 0) {
|
||||
settings()->beginGroup("ChartItemEditor");
|
||||
settings()->setValue("Geometry",saveGeometry());
|
||||
settings()->setValue("State",ui->splitter->saveState());
|
||||
settings()->setValue("Geometry", saveGeometry());
|
||||
settings()->setValue("State", ui->splitter->saveState());
|
||||
settings()->endGroup();
|
||||
}
|
||||
}
|
||||
@ -82,9 +91,9 @@ void ChartItemEditor::rebuildTable()
|
||||
{
|
||||
ui->tableWidget->clearContents();
|
||||
ui->tableWidget->setRowCount(m_charItem->series().count());
|
||||
for( int i=0;i<m_charItem->series().count();++i){
|
||||
for (int i = 0; i < m_charItem->series().count(); ++i) {
|
||||
QTableWidgetItem* newRow = new QTableWidgetItem(m_charItem->series().at(i)->name());
|
||||
ui->tableWidget->setItem(i,0,newRow);
|
||||
ui->tableWidget->setItem(i, 0, newRow);
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,38 +104,41 @@ void ChartItemEditor::init()
|
||||
ui->tableWidget->setColumnCount(1);
|
||||
ui->tableWidget->setRowCount(m_charItem->series().count());
|
||||
ui->tableWidget->horizontalHeader()->setStretchLastSection(true);
|
||||
ui->tableWidget->setHorizontalHeaderItem(0,new QTableWidgetItem(tr("Series name")));
|
||||
ui->tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Series name")));
|
||||
|
||||
rebuildTable();
|
||||
|
||||
if (!m_charItem->datasource().isEmpty()){
|
||||
if (m_page && m_page->datasourceManager()){
|
||||
LimeReport::IDataSource* ds = m_page->datasourceManager()->dataSource(m_charItem->datasource());
|
||||
if (ds){
|
||||
for (int i=0;i<ds->columnCount();++i){
|
||||
if (!m_charItem->datasource().isEmpty()) {
|
||||
if (m_page && m_page->datasourceManager()) {
|
||||
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));
|
||||
ui->labelsFieldComboBox->addItem(ds->columnNameByIndex(i));
|
||||
ui->xAxisFieldComboBox->addItem(ds->columnNameByIndex(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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){
|
||||
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());
|
||||
#endif
|
||||
if (!m_charItem->series().isEmpty()){
|
||||
if (!m_charItem->series().isEmpty()) {
|
||||
enableSeriesEditor();
|
||||
ui->tableWidget->selectRow(0);
|
||||
} else {
|
||||
@ -160,30 +172,30 @@ void ChartItemEditor::disableSeriesEditor()
|
||||
ui->seriesTypeComboBox->setDisabled(true);
|
||||
}
|
||||
|
||||
LimeReport::SeriesItem *ChartItemEditor::currentSeries()
|
||||
LimeReport::SeriesItem* ChartItemEditor::currentSeries()
|
||||
{
|
||||
int curRow = ui->tableWidget->currentRow();
|
||||
if ((curRow>-1) && !m_charItem->series().isEmpty() && m_charItem->series().count()>curRow){
|
||||
if ((curRow > -1) && !m_charItem->series().isEmpty() && m_charItem->series().count() > curRow) {
|
||||
return m_charItem->series().at(curRow);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ChartItemEditor::resizeEvent(QResizeEvent *)
|
||||
void ChartItemEditor::resizeEvent(QResizeEvent*)
|
||||
{
|
||||
#ifdef Q_OS_UNIX
|
||||
writeSetting();
|
||||
#endif
|
||||
}
|
||||
|
||||
void ChartItemEditor::moveEvent(QMoveEvent *)
|
||||
void ChartItemEditor::moveEvent(QMoveEvent*)
|
||||
{
|
||||
#ifdef Q_OS_UNIX
|
||||
writeSetting();
|
||||
#endif
|
||||
}
|
||||
|
||||
void ChartItemEditor::on_splitter_splitterMoved(int , int )
|
||||
void ChartItemEditor::on_splitter_splitterMoved(int, int)
|
||||
{
|
||||
#ifdef Q_OS_UNIX
|
||||
writeSetting();
|
||||
@ -200,15 +212,19 @@ void ChartItemEditor::slotAddSeries()
|
||||
{
|
||||
LimeReport::SeriesItem* series = new LimeReport::SeriesItem();
|
||||
int curSeriesNumber = m_charItem->series().count();
|
||||
while (m_charItem->isSeriesExists("Series"+QString::number(curSeriesNumber))) curSeriesNumber++;
|
||||
series->setName("Series"+QString::number(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->selectRow(m_charItem->series().count()-1);
|
||||
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("");
|
||||
#else
|
||||
@ -219,10 +235,10 @@ void ChartItemEditor::slotAddSeries()
|
||||
void ChartItemEditor::slotDeleteSeries()
|
||||
{
|
||||
QList<LimeReport::SeriesItem*> itemsToRemove;
|
||||
foreach(QModelIndex index,ui->tableWidget->selectionModel()->selectedRows()){
|
||||
foreach (QModelIndex index, ui->tableWidget->selectionModel()->selectedRows()) {
|
||||
itemsToRemove.append(m_charItem->series().at(index.row()));
|
||||
};
|
||||
foreach (LimeReport::SeriesItem* series, itemsToRemove){
|
||||
foreach (LimeReport::SeriesItem* series, itemsToRemove) {
|
||||
m_charItem->series().removeOne(series);
|
||||
delete series;
|
||||
}
|
||||
@ -232,19 +248,23 @@ 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());
|
||||
if (ui->tableWidget->selectionModel()->hasSelection()) {
|
||||
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
|
||||
@ -252,22 +272,22 @@ void ChartItemEditor::on_tableWidget_itemSelectionChanged()
|
||||
}
|
||||
}
|
||||
|
||||
void ChartItemEditor::on_seriesNameLineEdit_textChanged(const QString &arg1)
|
||||
void ChartItemEditor::on_seriesNameLineEdit_textChanged(const QString& arg1)
|
||||
{
|
||||
if (currentSeries()){
|
||||
if (currentSeries()) {
|
||||
currentSeries()->setName(arg1);
|
||||
ui->tableWidget->currentItem()->setText(arg1);
|
||||
}
|
||||
}
|
||||
|
||||
void ChartItemEditor::on_valuesFieldComboBox_currentTextChanged(const QString &arg1)
|
||||
void ChartItemEditor::on_valuesFieldComboBox_currentTextChanged(const QString& arg1)
|
||||
{
|
||||
if (currentSeries()){
|
||||
if (currentSeries()) {
|
||||
currentSeries()->setValuesColumn(arg1);
|
||||
}
|
||||
}
|
||||
|
||||
void ChartItemEditor::on_labelsFieldComboBox_currentTextChanged(const QString &arg1)
|
||||
void ChartItemEditor::on_labelsFieldComboBox_currentTextChanged(const QString& arg1)
|
||||
{
|
||||
if (!m_initing)
|
||||
m_charItem->setLabelsField(arg1);
|
||||
@ -276,27 +296,30 @@ void ChartItemEditor::on_labelsFieldComboBox_currentTextChanged(const QString &a
|
||||
void ChartItemEditor::slotChangeSeriesColor()
|
||||
{
|
||||
QColorDialog colorDialog;
|
||||
if (colorDialog.exec()){
|
||||
if (colorDialog.exec()) {
|
||||
currentSeries()->setColor(colorDialog.selectedColor());
|
||||
m_colorIndicator->setColor(colorDialog.selectedColor());
|
||||
}
|
||||
}
|
||||
|
||||
void ChartItemEditor::on_seriesTypeComboBox_currentIndexChanged(const QString &arg1)
|
||||
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())));
|
||||
if (currentSeries()) {
|
||||
currentSeries()->setPreferredType(
|
||||
static_cast<LimeReport::SeriesItem::SeriesItemPreferredType>(
|
||||
enumerator.keysToValue(arg1.toLatin1())));
|
||||
}
|
||||
}
|
||||
|
||||
void ChartItemEditor::on_xAxisFieldComboBox_currentTextChanged(const QString &arg1)
|
||||
void ChartItemEditor::on_xAxisFieldComboBox_currentTextChanged(const QString& arg1)
|
||||
{
|
||||
if (!m_initing)
|
||||
m_charItem->setXAxisField(arg1);
|
||||
}
|
||||
void ChartItemEditor::on_tableWidget_itemChanged(QTableWidgetItem *item)
|
||||
void ChartItemEditor::on_tableWidget_itemChanged(QTableWidgetItem* item)
|
||||
{
|
||||
if (ui->seriesNameLineEdit->hasFocus())
|
||||
return;
|
||||
|
@ -1,30 +1,31 @@
|
||||
#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);
|
||||
QSettings* settings = 0, QWidget* parent = 0);
|
||||
~ChartItemEditor();
|
||||
|
||||
public:
|
||||
QSettings *settings();
|
||||
QSettings* settings();
|
||||
void rebuildTable();
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *);
|
||||
void moveEvent(QMoveEvent *);
|
||||
void resizeEvent(QResizeEvent*);
|
||||
void moveEvent(QMoveEvent*);
|
||||
|
||||
signals:
|
||||
void editingFinished();
|
||||
@ -35,13 +36,13 @@ private slots:
|
||||
void slotAddSeries();
|
||||
void slotDeleteSeries();
|
||||
void on_tableWidget_itemSelectionChanged();
|
||||
void on_seriesNameLineEdit_textChanged(const QString &arg1);
|
||||
void on_valuesFieldComboBox_currentTextChanged(const QString &arg1);
|
||||
void on_labelsFieldComboBox_currentTextChanged(const QString &arg1);
|
||||
void on_seriesNameLineEdit_textChanged(const QString& arg1);
|
||||
void on_valuesFieldComboBox_currentTextChanged(const QString& arg1);
|
||||
void on_labelsFieldComboBox_currentTextChanged(const QString& arg1);
|
||||
void slotChangeSeriesColor();
|
||||
void on_seriesTypeComboBox_currentIndexChanged(const QString &arg1);
|
||||
void on_xAxisFieldComboBox_currentTextChanged(const QString &arg1);
|
||||
void on_tableWidget_itemChanged(QTableWidgetItem *item);
|
||||
void on_seriesTypeComboBox_currentIndexChanged(const QString& arg1);
|
||||
void on_xAxisFieldComboBox_currentTextChanged(const QString& arg1);
|
||||
void on_tableWidget_itemChanged(QTableWidgetItem* item);
|
||||
|
||||
private:
|
||||
void readSetting();
|
||||
@ -50,8 +51,9 @@ private:
|
||||
void enableSeriesEditor();
|
||||
void disableSeriesEditor();
|
||||
LimeReport::SeriesItem* currentSeries();
|
||||
|
||||
private:
|
||||
Ui::ChartItemEditor *ui;
|
||||
Ui::ChartItemEditor* ui;
|
||||
LimeReport::ChartItem* m_charItem;
|
||||
LimeReport::PageDesignIntf* m_page;
|
||||
QSettings* m_settings;
|
||||
|
@ -5,16 +5,15 @@
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
class IEditableImageItem{
|
||||
class IEditableImageItem {
|
||||
public:
|
||||
virtual QByteArray imageAsByteArray() const = 0;
|
||||
virtual void setImageAsByteArray(QByteArray image) = 0;
|
||||
virtual QString resourcePath() const = 0;
|
||||
virtual void setResourcePath(const QString &value) = 0;
|
||||
virtual void setResourcePath(const QString& value) = 0;
|
||||
virtual QString fileFilter() const = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LREDITABLEIMAGEITEMINTF_H
|
||||
|
@ -28,101 +28,105 @@
|
||||
* 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";
|
||||
|
||||
namespace {
|
||||
|
||||
LimeReport::BaseDesignIntf *createHLayout(QObject *owner, LimeReport::BaseDesignIntf *parent)
|
||||
LimeReport::BaseDesignIntf* createHLayout(QObject* owner, LimeReport::BaseDesignIntf* parent)
|
||||
{
|
||||
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){
|
||||
return c1->pos().x()<c2->pos().x();
|
||||
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)
|
||||
BaseDesignIntf* HorizontalLayout::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
return new LimeReport::HorizontalLayout(owner, parent);
|
||||
}
|
||||
|
||||
bool HorizontalLayout::canBeSplitted(int height) const
|
||||
{
|
||||
foreach(QGraphicsItem* qgItem,childItems()){
|
||||
BaseDesignIntf* item=dynamic_cast<BaseDesignIntf*>(qgItem);
|
||||
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)
|
||||
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()){
|
||||
foreach (BaseDesignIntf* item, childBaseItems()) {
|
||||
|
||||
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();
|
||||
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();
|
||||
} else {
|
||||
item->cloneEmpty(sliceHeight,upperPart,upperPart);
|
||||
item->setPos(item->pos().x(),item->pos().y()+((height+1)-item->geometry().top()));
|
||||
item->cloneEmpty(sliceHeight, upperPart, upperPart);
|
||||
item->setPos(item->pos().x(),
|
||||
item->pos().y() + ((height + 1) - item->geometry().top()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach(BaseDesignIntf* item, upperPart->childBaseItems()){
|
||||
item->setHeight((maxHeight<height)?maxHeight:height);
|
||||
foreach (BaseDesignIntf* item, upperPart->childBaseItems()) {
|
||||
item->setHeight((maxHeight < height) ? maxHeight : height);
|
||||
}
|
||||
upperPart->setHeight(height);
|
||||
|
||||
return upperPart;
|
||||
}
|
||||
|
||||
BaseDesignIntf *HorizontalLayout::cloneBottomPart(int height, QObject *owner, QGraphicsItem *parent)
|
||||
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)){
|
||||
BaseDesignIntf* tmpItem=item->cloneBottomPart(height,bottomPart,bottomPart);
|
||||
tmpItem->setPos(tmpItem->pos().x(),0);
|
||||
if (maxHeight<tmpItem->height())
|
||||
foreach (BaseDesignIntf* item, childBaseItems()) {
|
||||
if ((item->geometry().top() < height) && (item->geometry().bottom() > height)) {
|
||||
BaseDesignIntf* tmpItem = item->cloneBottomPart(height, bottomPart, bottomPart);
|
||||
tmpItem->setPos(tmpItem->pos().x(), 0);
|
||||
if (maxHeight < tmpItem->height())
|
||||
maxHeight = tmpItem->height();
|
||||
}
|
||||
}
|
||||
|
||||
if (!bottomPart->isEmpty()){
|
||||
if (!bottomPart->isEmpty()) {
|
||||
foreach (BaseDesignIntf* item, bottomPart->childBaseItems()) {
|
||||
item->setHeight(maxHeight);
|
||||
}
|
||||
@ -131,7 +135,7 @@ BaseDesignIntf *HorizontalLayout::cloneBottomPart(int height, QObject *owner, QG
|
||||
return bottomPart;
|
||||
}
|
||||
|
||||
void HorizontalLayout::setItemAlign(const BaseDesignIntf::ItemAlign &itemAlign)
|
||||
void HorizontalLayout::setItemAlign(const BaseDesignIntf::ItemAlign& itemAlign)
|
||||
{
|
||||
if (itemAlign == ParentWidthItemAlign)
|
||||
setLayoutType(Table);
|
||||
@ -140,29 +144,32 @@ void HorizontalLayout::setItemAlign(const BaseDesignIntf::ItemAlign &itemAlign)
|
||||
|
||||
void HorizontalLayout::sortChildren()
|
||||
{
|
||||
std::sort(layoutsChildren().begin(),layoutsChildren().end(),horizontalLessThen);
|
||||
std::sort(layoutsChildren().begin(), layoutsChildren().end(), horizontalLessThen);
|
||||
}
|
||||
|
||||
void HorizontalLayout::updateLayoutSize()
|
||||
{
|
||||
int spaceBorder = (borderLines() != 0) ? borderLineSize() : 0;
|
||||
qreal w = spaceBorder*2;
|
||||
qreal w = spaceBorder * 2;
|
||||
qreal h = 0;
|
||||
int visibleItemCount = 0;
|
||||
foreach(BaseDesignIntf* item, layoutsChildren()){
|
||||
if (item->isEmpty() && hideEmptyItems()) item->setVisible(false);
|
||||
if (item->isVisible()){
|
||||
if (h<item->height()) h=item->height();
|
||||
w+=item->width();
|
||||
foreach (BaseDesignIntf* item, layoutsChildren()) {
|
||||
if (item->isEmpty() && hideEmptyItems())
|
||||
item->setVisible(false);
|
||||
if (item->isVisible()) {
|
||||
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{
|
||||
setWidth(w + layoutSpacingMM() * (visibleItemCount - 1));
|
||||
else {
|
||||
relocateChildren();
|
||||
if (!isRelocating()){
|
||||
if (!isRelocating()) {
|
||||
divideSpace();
|
||||
}
|
||||
}
|
||||
@ -172,7 +179,7 @@ void HorizontalLayout::relocateChildren()
|
||||
{
|
||||
int spaceBorder = (borderLines() != 0) ? borderLineSize() : 0;
|
||||
QList<BaseDesignIntf*> newChildren;
|
||||
if (layoutsChildren().count() < childItems().size()-1){
|
||||
if (layoutsChildren().count() < childItems().size() - 1) {
|
||||
auto oldChildren = layoutsChildren();
|
||||
layoutsChildren().clear();
|
||||
foreach (BaseDesignIntf* item, childBaseItems()) {
|
||||
@ -182,14 +189,14 @@ void HorizontalLayout::relocateChildren()
|
||||
layoutsChildren().append(item);
|
||||
}
|
||||
}
|
||||
std::sort(layoutsChildren().begin(),layoutsChildren().end(),horizontalLessThen);
|
||||
std::sort(layoutsChildren().begin(), layoutsChildren().end(), horizontalLessThen);
|
||||
qreal curX = spaceBorder;
|
||||
setIsRelocating(true);
|
||||
foreach (BaseDesignIntf* item, layoutsChildren()) {
|
||||
if (item->isVisible() || itemMode() == DesignMode){
|
||||
item->setPos(curX,spaceBorder);
|
||||
if (item->isVisible() || itemMode() == DesignMode) {
|
||||
item->setPos(curX, spaceBorder);
|
||||
curX += item->width() + layoutSpacingMM();
|
||||
item->setHeight(height()-(spaceBorder * 2));
|
||||
item->setHeight(height() - (spaceBorder * 2));
|
||||
}
|
||||
}
|
||||
setIsRelocating(false);
|
||||
@ -199,32 +206,36 @@ void HorizontalLayout::relocateChildren()
|
||||
}
|
||||
}
|
||||
|
||||
void HorizontalLayout::divideSpace(){
|
||||
void HorizontalLayout::divideSpace()
|
||||
{
|
||||
setIsRelocating(true);
|
||||
qreal itemsSumSize = 0;
|
||||
int visibleItemsCount = 0;
|
||||
int spaceBorder = (borderLines() != 0) ? borderLineSize() : 0;
|
||||
|
||||
foreach(BaseDesignIntf* item, layoutsChildren()){
|
||||
if (item->isVisible() || itemMode() == DesignMode ){
|
||||
foreach (BaseDesignIntf* item, layoutsChildren()) {
|
||||
if (item->isVisible() || itemMode() == DesignMode) {
|
||||
itemsSumSize += item->width();
|
||||
visibleItemsCount++;
|
||||
}
|
||||
}
|
||||
|
||||
itemsSumSize += layoutSpacingMM() * (visibleItemsCount-1);
|
||||
itemsSumSize += layoutSpacingMM() * (visibleItemsCount - 1);
|
||||
|
||||
if (itemMode() == DesignMode && !layoutsChildren().isEmpty()){
|
||||
qreal delta = (width() - (itemsSumSize+spaceBorder*2));
|
||||
layoutsChildren().last()->setWidth(layoutsChildren().last()->width()+delta);
|
||||
if (itemMode() == DesignMode && !layoutsChildren().isEmpty()) {
|
||||
qreal delta = (width() - (itemsSumSize + spaceBorder * 2));
|
||||
layoutsChildren().last()->setWidth(layoutsChildren().last()->width() + delta);
|
||||
} else {
|
||||
qreal delta = (width() - (itemsSumSize+spaceBorder*2)) / (visibleItemsCount!=0 ? visibleItemsCount : 1);
|
||||
for (int i=0; i<layoutsChildren().size(); ++i){
|
||||
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]->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());
|
||||
}
|
||||
}
|
||||
setIsRelocating(false);
|
||||
|
@ -29,34 +29,32 @@
|
||||
****************************************************************************/
|
||||
#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:
|
||||
friend class LayoutMarker;
|
||||
friend class BaseDesignIntf;
|
||||
|
||||
HorizontalLayout(QObject *owner = 0, QGraphicsItem *parent = 0);
|
||||
HorizontalLayout(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
~HorizontalLayout();
|
||||
BaseDesignIntf *createSameTypeItem(QObject *owner = 0, QGraphicsItem *parent = 0);
|
||||
bool isSplittable() const { return true;}
|
||||
bool canContainChildren() const { return true;}
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
bool isSplittable() const { return true; }
|
||||
bool canContainChildren() const { return true; }
|
||||
|
||||
protected:
|
||||
void updateLayoutSize();
|
||||
void relocateChildren();
|
||||
bool canBeSplitted(int height) const;
|
||||
BaseDesignIntf* cloneUpperPart(int height, QObject* owner=0, QGraphicsItem* parent=0);
|
||||
BaseDesignIntf* cloneBottomPart(int height, QObject *owner=0, QGraphicsItem *parent=0);
|
||||
void setItemAlign(const ItemAlign &itemAlign);
|
||||
BaseDesignIntf* cloneUpperPart(int height, QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
BaseDesignIntf* cloneBottomPart(int height, QObject* owner = 0, QGraphicsItem* parent = 0);
|
||||
void setItemAlign(const ItemAlign& itemAlign);
|
||||
|
||||
private:
|
||||
void sortChildren();
|
||||
@ -64,5 +62,5 @@ private:
|
||||
void placeItemInLayout(BaseDesignIntf* item);
|
||||
};
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
#endif // LRHORIZONTALLAYOUT_H
|
||||
|
@ -28,45 +28,54 @@
|
||||
* 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{
|
||||
namespace {
|
||||
|
||||
const QString xmlTag = "ImageItem";
|
||||
|
||||
LimeReport::BaseDesignIntf * createImageItem(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::ImageItem(owner,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)
|
||||
{
|
||||
}
|
||||
|
||||
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){}
|
||||
|
||||
BaseDesignIntf *ImageItem::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
BaseDesignIntf* ImageItem::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
ImageItem* result = new ImageItem(owner,parent);
|
||||
ImageItem* result = new ImageItem(owner, parent);
|
||||
result->setExternalPainter(m_externalPainter);
|
||||
return result;
|
||||
}
|
||||
|
||||
void ImageItem::loadPictureFromVariant(QVariant& data){
|
||||
//TODO: Migrate to QMetaType
|
||||
if (data.isValid()){
|
||||
void ImageItem::loadPictureFromVariant(QVariant& data)
|
||||
{
|
||||
// TODO: Migrate to QMetaType
|
||||
if (data.isValid()) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (data.typeId() == QMetaType::QImage){
|
||||
if (data.typeId() == QMetaType::QImage) {
|
||||
#else
|
||||
if (data.type() == QVariant::Image){
|
||||
if (data.type() == QVariant::Image) {
|
||||
#endif
|
||||
m_picture = data.value<QImage>();
|
||||
} else {
|
||||
@ -83,35 +92,34 @@ void ImageItem::loadPictureFromVariant(QVariant& data){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ImageItem::preparePopUpMenu(QMenu &menu)
|
||||
void ImageItem::preparePopUpMenu(QMenu& menu)
|
||||
{
|
||||
QAction* editAction = menu.addAction(QIcon(":/report/images/edit_pecil2.png"),tr("Edit"));
|
||||
menu.insertAction(menu.actions().at(0),editAction);
|
||||
QAction* editAction = menu.addAction(QIcon(":/report/images/edit_pecil2.png"), tr("Edit"));
|
||||
menu.insertAction(menu.actions().at(0), editAction);
|
||||
menu.insertSeparator(menu.actions().at(1));
|
||||
|
||||
menu.addSeparator();
|
||||
QAction* action = menu.addAction(tr("Watermark"));
|
||||
action->setCheckable(true);
|
||||
action->setChecked(isWatermark());
|
||||
|
||||
}
|
||||
|
||||
void ImageItem::processPopUpAction(QAction *action)
|
||||
void ImageItem::processPopUpAction(QAction* action)
|
||||
{
|
||||
if (action->text().compare(tr("Watermark")) == 0){
|
||||
page()->setPropertyToSelectedItems("watermark",action->isChecked());
|
||||
if (action->text().compare(tr("Watermark")) == 0) {
|
||||
page()->setPropertyToSelectedItems("watermark", action->isChecked());
|
||||
}
|
||||
if (action->text().compare(tr("Edit")) == 0){
|
||||
if (action->text().compare(tr("Edit")) == 0) {
|
||||
this->showEditorDialog();
|
||||
}
|
||||
ItemDesignIntf::processPopUpAction(action);
|
||||
}
|
||||
|
||||
QImage getFileByResourcePath(QString resourcePath) {
|
||||
QImage getFileByResourcePath(QString resourcePath)
|
||||
{
|
||||
QFileInfo resourceFile(resourcePath);
|
||||
if (resourceFile.exists())
|
||||
return QImage(resourcePath);
|
||||
@ -125,21 +133,18 @@ 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)
|
||||
{
|
||||
if (m_useExternalPainter != value){
|
||||
if (m_useExternalPainter != value) {
|
||||
m_useExternalPainter = value;
|
||||
notify("useExternalPainter",!value, value);
|
||||
notify("useExternalPainter", !value, value);
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
QWidget *ImageItem::defaultEditor()
|
||||
QWidget* ImageItem::defaultEditor()
|
||||
{
|
||||
ImageItemEditor* editor = new ImageItemEditor(this);
|
||||
editor->setAttribute(Qt::WA_DeleteOnClose);
|
||||
@ -151,7 +156,7 @@ QByteArray ImageItem::imageAsByteArray() const
|
||||
QByteArray result;
|
||||
QBuffer buffer(&result);
|
||||
buffer.open(QIODevice::WriteOnly);
|
||||
m_picture.save(&buffer,"PNG");
|
||||
m_picture.save(&buffer, "PNG");
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -165,63 +170,59 @@ 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)
|
||||
{
|
||||
|
||||
if (m_picture.isNull()){
|
||||
if (!m_datasource.isEmpty() && !m_field.isEmpty()){
|
||||
if (m_picture.isNull()) {
|
||||
if (!m_datasource.isEmpty() && !m_field.isEmpty()) {
|
||||
IDataSource* ds = dataManager->dataSource(m_datasource);
|
||||
if (ds) {
|
||||
QVariant data = ds->data(m_field);
|
||||
loadPictureFromVariant(data);
|
||||
}
|
||||
} else if (!m_resourcePath.isEmpty()){
|
||||
m_resourcePath = expandUserVariables(m_resourcePath, pass, NoEscapeSymbols, dataManager);
|
||||
} else if (!m_resourcePath.isEmpty()) {
|
||||
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()){
|
||||
//TODO: Migrate to QMetaType
|
||||
} else if (!m_variable.isEmpty()) {
|
||||
// TODO: Migrate to QMetaType
|
||||
QVariant data = dataManager->variable(m_variable);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (data.typeId() == QMetaType::QString){
|
||||
if (data.typeId() == QMetaType::QString) {
|
||||
#else
|
||||
if (data.type() == QVariant::String){
|
||||
if (data.type() == QVariant::String) {
|
||||
#endif
|
||||
m_picture = QImage(data.toString());
|
||||
} else {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (data.typeId() == QMetaType::QImage){
|
||||
if (data.typeId() == QMetaType::QImage) {
|
||||
#else
|
||||
if (data.type() == QVariant::Image){
|
||||
if (data.type() == QVariant::Image) {
|
||||
#endif
|
||||
loadPictureFromVariant(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (m_autoSize){
|
||||
if (m_autoSize) {
|
||||
setWidth(m_picture.width());
|
||||
setHeight(m_picture.height());
|
||||
}
|
||||
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;
|
||||
@ -230,65 +231,53 @@ qreal ImageItem::minHeight() const{
|
||||
|
||||
void ImageItem::setVariable(const QString& content)
|
||||
{
|
||||
if (m_variable!=content){
|
||||
if (m_variable != content) {
|
||||
QString oldValue = m_variable;
|
||||
m_variable=content;
|
||||
m_variable = content;
|
||||
update();
|
||||
notify("variable", oldValue, m_variable);
|
||||
}
|
||||
}
|
||||
|
||||
bool ImageItem::center() const
|
||||
{
|
||||
return m_center;
|
||||
}
|
||||
bool ImageItem::center() const { return m_center; }
|
||||
|
||||
void ImageItem::setCenter(bool center)
|
||||
{
|
||||
if (m_center != center){
|
||||
if (m_center != center) {
|
||||
m_center = center;
|
||||
update();
|
||||
notify("center",!center,center);
|
||||
notify("center", !center, center);
|
||||
}
|
||||
}
|
||||
|
||||
bool ImageItem::keepAspectRatio() const
|
||||
{
|
||||
return m_keepAspectRatio;
|
||||
}
|
||||
bool ImageItem::keepAspectRatio() const { return m_keepAspectRatio; }
|
||||
|
||||
void ImageItem::setKeepAspectRatio(bool keepAspectRatio)
|
||||
{
|
||||
if (m_keepAspectRatio != keepAspectRatio){
|
||||
if (m_keepAspectRatio != keepAspectRatio) {
|
||||
m_keepAspectRatio = keepAspectRatio;
|
||||
update();
|
||||
notify("keepAspectRatio",!keepAspectRatio,keepAspectRatio);
|
||||
notify("keepAspectRatio", !keepAspectRatio, keepAspectRatio);
|
||||
}
|
||||
}
|
||||
|
||||
bool ImageItem::scale() const
|
||||
{
|
||||
return m_scale;
|
||||
}
|
||||
bool ImageItem::scale() const { return m_scale; }
|
||||
|
||||
void ImageItem::setScale(bool scale)
|
||||
{
|
||||
if (m_scale != scale){
|
||||
if (m_scale != scale) {
|
||||
m_scale = scale;
|
||||
update();
|
||||
notify("scale",!scale,scale);
|
||||
notify("scale", !scale, scale);
|
||||
}
|
||||
}
|
||||
bool ImageItem::autoSize() const
|
||||
{
|
||||
return m_autoSize;
|
||||
}
|
||||
bool ImageItem::autoSize() const { return m_autoSize; }
|
||||
|
||||
void ImageItem::setAutoSize(bool autoSize)
|
||||
{
|
||||
if (m_autoSize != autoSize){
|
||||
if (m_autoSize != autoSize) {
|
||||
m_autoSize = autoSize;
|
||||
if (m_autoSize && !m_picture.isNull()){
|
||||
if (m_autoSize && !m_picture.isNull()) {
|
||||
setWidth(drawImage().width());
|
||||
setHeight(drawImage().height());
|
||||
setPossibleResizeDirectionFlags(Fixed);
|
||||
@ -296,52 +285,49 @@ void ImageItem::setAutoSize(bool autoSize)
|
||||
setPossibleResizeDirectionFlags(AllDirections);
|
||||
}
|
||||
update();
|
||||
notify("autoSize",!autoSize,autoSize);
|
||||
notify("autoSize", !autoSize, autoSize);
|
||||
}
|
||||
}
|
||||
|
||||
QString ImageItem::field() const
|
||||
{
|
||||
return m_field;
|
||||
}
|
||||
QString ImageItem::field() const { return m_field; }
|
||||
|
||||
void ImageItem::setField(const QString &field)
|
||||
void ImageItem::setField(const QString& field)
|
||||
{
|
||||
if (m_field != field){
|
||||
if (m_field != field) {
|
||||
QString oldValue = m_field;
|
||||
m_field = field;
|
||||
update();
|
||||
notify("field",oldValue,field);
|
||||
notify("field", oldValue, field);
|
||||
}
|
||||
}
|
||||
|
||||
QString ImageItem::datasource() const
|
||||
{
|
||||
return m_datasource;
|
||||
}
|
||||
QString ImageItem::datasource() const { return m_datasource; }
|
||||
|
||||
void ImageItem::setDatasource(const QString &datasource)
|
||||
void ImageItem::setDatasource(const QString& datasource)
|
||||
{
|
||||
if (m_datasource != datasource){
|
||||
if (m_datasource != datasource) {
|
||||
QString oldValue = m_datasource;
|
||||
m_datasource = datasource;
|
||||
update();
|
||||
notify("datasource",oldValue,datasource);
|
||||
notify("datasource", oldValue, datasource);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ImageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
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);
|
||||
if (m_scale && !drawImage().isNull()) {
|
||||
img = drawImage().scaled(rect().width(), rect().height(),
|
||||
keepAspectRatio() ? Qt::KeepAspectRatio : Qt::IgnoreAspectRatio,
|
||||
Qt::SmoothTransformation);
|
||||
} else {
|
||||
img = drawImage();
|
||||
}
|
||||
@ -349,73 +335,75 @@ void ImageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
qreal shiftHeight = rect().height() - img.height();
|
||||
qreal shiftWidth = rect().width() - img.width();
|
||||
|
||||
if (m_center){
|
||||
if (shiftHeight<0 || shiftWidth<0){
|
||||
if (m_center) {
|
||||
if (shiftHeight < 0 || shiftWidth < 0) {
|
||||
qreal cutX = 0;
|
||||
qreal cutY = 0;
|
||||
qreal cutWidth = img.width();
|
||||
qreal cutHeigth = img.height();
|
||||
|
||||
if (shiftWidth > 0){
|
||||
point.setX(point.x()+shiftWidth/2);
|
||||
if (shiftWidth > 0) {
|
||||
point.setX(point.x() + shiftWidth / 2);
|
||||
} else {
|
||||
cutX = fabs(shiftWidth/2);
|
||||
cutX = fabs(shiftWidth / 2);
|
||||
cutWidth += shiftWidth;
|
||||
}
|
||||
|
||||
if (shiftHeight > 0){
|
||||
point.setY(point.y()+shiftHeight/2);
|
||||
if (shiftHeight > 0) {
|
||||
point.setY(point.y() + shiftHeight / 2);
|
||||
} else {
|
||||
cutY = fabs(shiftHeight/2);
|
||||
cutY = fabs(shiftHeight / 2);
|
||||
cutHeigth += shiftHeight;
|
||||
}
|
||||
|
||||
img = img.copy(cutX,cutY,cutWidth,cutHeigth);
|
||||
img = img.copy(cutX, cutY, cutWidth, cutHeigth);
|
||||
} else {
|
||||
point.setX(point.x()+shiftWidth/2);
|
||||
point.setY(point.y()+shiftHeight/2);
|
||||
point.setX(point.x() + shiftWidth / 2);
|
||||
point.setY(point.y() + shiftHeight / 2);
|
||||
}
|
||||
}
|
||||
|
||||
if (img.isNull() && itemMode() == DesignMode){
|
||||
if (img.isNull() && itemMode() == DesignMode) {
|
||||
QString text;
|
||||
painter->setFont(transformToSceneFont(QFont("Arial",10)));
|
||||
painter->setFont(transformToSceneFont(QFont("Arial", 10)));
|
||||
painter->setPen(Qt::black);
|
||||
if (!datasource().isEmpty() && !field().isEmpty())
|
||||
text = datasource()+"."+field();
|
||||
else if (m_useExternalPainter) text = tr("Ext."); else text = tr("Image");
|
||||
painter->drawText(rect().adjusted(4,4,-4,-4), Qt::AlignCenter, text );
|
||||
text = datasource() + "." + field();
|
||||
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)
|
||||
m_externalPainter->paintByExternalPainter(this->patternName(), painter, option);
|
||||
else
|
||||
painter->drawImage(point,img);
|
||||
painter->drawImage(point, img);
|
||||
}
|
||||
|
||||
ItemDesignIntf::paint(painter,option,widget);
|
||||
ItemDesignIntf::paint(painter, option, widget);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
void ImageItem::setImage(QImage value)
|
||||
{
|
||||
if (m_picture != value){
|
||||
if (m_picture != value) {
|
||||
QImage oldValue = m_picture;
|
||||
m_picture = value;
|
||||
if (m_autoSize){
|
||||
if (m_autoSize) {
|
||||
setWidth(m_picture.width());
|
||||
setHeight(m_picture.height());
|
||||
}
|
||||
update();
|
||||
notify("image",oldValue,value);
|
||||
notify("image", oldValue, value);
|
||||
}
|
||||
}
|
||||
|
||||
QImage ImageItem::image() const{
|
||||
return m_picture;
|
||||
}
|
||||
QImage ImageItem::image() const { return m_picture; }
|
||||
|
||||
void ImageItem::setResourcePath(const QString &value){
|
||||
if (m_resourcePath != value){
|
||||
void ImageItem::setResourcePath(const QString& value)
|
||||
{
|
||||
if (m_resourcePath != value) {
|
||||
QString oldValue = m_resourcePath;
|
||||
m_resourcePath = value;
|
||||
update();
|
||||
@ -423,24 +411,18 @@ 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)
|
||||
{
|
||||
if (m_format!=format){
|
||||
if (m_format != format) {
|
||||
Format oldValue = m_format;
|
||||
m_format=format;
|
||||
m_format = format;
|
||||
update();
|
||||
notify("format",oldValue,format);
|
||||
notify("format", oldValue, 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{
|
||||
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)
|
||||
@ -64,16 +64,16 @@ public:
|
||||
Q_ENUMS(Format)
|
||||
#endif
|
||||
|
||||
ImageItem(QObject *owner, QGraphicsItem *parent);
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
ImageItem(QObject* owner, QGraphicsItem* parent);
|
||||
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
|
||||
void setImage(QImage value);
|
||||
QImage image() const;
|
||||
void setResourcePath(const QString &value);
|
||||
void setResourcePath(const QString& value);
|
||||
QString resourcePath() const;
|
||||
QString datasource() const;
|
||||
void setDatasource(const QString &datasource);
|
||||
void setDatasource(const QString& datasource);
|
||||
QString field() const;
|
||||
void setField(const QString &field);
|
||||
void setField(const QString& field);
|
||||
|
||||
bool autoSize() const;
|
||||
void setAutoSize(bool autoSize);
|
||||
@ -87,10 +87,13 @@ public:
|
||||
void setFormat(Format format);
|
||||
qreal minHeight() const;
|
||||
|
||||
QString variable(){ return m_variable;}
|
||||
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,15 +103,17 @@ 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);
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner, QGraphicsItem* parent);
|
||||
void updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight);
|
||||
bool isNeedUpdateSize(RenderPass) const;
|
||||
bool drawDesignBorders() const {return m_picture.isNull();}
|
||||
bool drawDesignBorders() const { return m_picture.isNull(); }
|
||||
void loadPictureFromVariant(QVariant& data);
|
||||
void preparePopUpMenu(QMenu &menu);
|
||||
void processPopUpAction(QAction *action);
|
||||
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:
|
||||
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) :
|
||||
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,15 +17,12 @@ ImageItemEditor::ImageItemEditor(LimeReport::IEditableImageItem *item, QWidget *
|
||||
updateImage();
|
||||
}
|
||||
|
||||
ImageItemEditor::~ImageItemEditor()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
ImageItemEditor::~ImageItemEditor() { delete ui; }
|
||||
|
||||
void ImageItemEditor::updateImage()
|
||||
{
|
||||
QPixmap image;
|
||||
if (m_image.isEmpty() && !ui->resourcePath->text().isEmpty()){
|
||||
if (m_image.isEmpty() && !ui->resourcePath->text().isEmpty()) {
|
||||
image.load(ui->resourcePath->text());
|
||||
} else {
|
||||
image.loadFromData(m_image);
|
||||
@ -33,9 +32,10 @@ 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)){
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
m_image = file.readAll();
|
||||
}
|
||||
updateImage();
|
||||
@ -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()
|
||||
{
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user