0
0
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:
Андрей Лухнов 2024-09-04 17:31:16 +03:00
parent c5b9ac265d
commit 0fca7169d3
285 changed files with 19120 additions and 17875 deletions

41
.clang-format Normal file
View 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

View File

@ -11,9 +11,19 @@ env:
BUILD_TYPE: Release BUILD_TYPE: Release
jobs: 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: build:
runs-on: ubuntu-${{ matrix.ubuntu_version }} runs-on: ubuntu-${{ matrix.ubuntu_version }}
name: Ubuntu-${{ matrix.ubuntu_version }}-Qt-${{ matrix.qt_version }}-static-${{ matrix.static }} name: Ubuntu-${{ matrix.ubuntu_version }}-Qt-${{ matrix.qt_version }}-static-${{ matrix.static }}
needs: check-code-style
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@ -55,6 +65,7 @@ jobs:
MSVC: MSVC:
name: windows-${{ matrix.win_version }}-Qt-${{ matrix.qt_version }}-static-${{ matrix.static }} name: windows-${{ matrix.win_version }}-Qt-${{ matrix.qt_version }}-static-${{ matrix.static }}
runs-on: windows-${{ matrix.win_version }} runs-on: windows-${{ matrix.win_version }}
needs: check-code-style
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@ -96,6 +107,7 @@ jobs:
MinGW-w64: MinGW-w64:
runs-on: windows-2022 runs-on: windows-2022
name: msys2-${{ matrix.msystem }}-Qt-${{ matrix.qt_version }}-static-${{ matrix.static }} name: msys2-${{ matrix.msystem }}-Qt-${{ matrix.qt_version }}-static-${{ matrix.static }}
needs: check-code-style
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@ -165,6 +177,7 @@ jobs:
macos: macos:
runs-on: macos-${{ matrix.macos_version }} runs-on: macos-${{ matrix.macos_version }}
name: macos-${{ matrix.macos_version }}-Qt-${{ matrix.qt_version }}-static-${{ matrix.static }} name: macos-${{ matrix.macos_version }}-Qt-${{ matrix.qt_version }}-static-${{ matrix.static }}
needs: check-code-style
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:

View File

@ -1,16 +1,18 @@
#include "../limereport/version.h"
#include <QApplication> #include <QApplication>
#include <QUuid> #include <QCommandLineParser>
#include <LimeReport>
#include <iostream>
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
#include <QFile> #include <QFile>
#include <QCommandLineParser> #include <QUuid>
#include "../limereport/version.h"
#include <LimeReport>
#include <iostream>
#ifdef _WIN32 #ifdef _WIN32
#include <io.h>
#include <fcntl.h> #include <fcntl.h>
#include <io.h>
#endif #endif
int main(int argc, char* argv[]) int main(int argc, char* argv[])
@ -23,15 +25,20 @@ int main(int argc, char *argv[])
QCommandLineParser parser; QCommandLineParser parser;
parser.addHelpOption(); parser.addHelpOption();
parser.addVersionOption(); parser.addVersionOption();
QCommandLineOption sourceOption(QStringList() << "s" << "source", QCommandLineOption sourceOption(
QStringList() << "s"
<< "source",
QCoreApplication::translate("main", "Limereport pattern file name"), QCoreApplication::translate("main", "Limereport pattern file name"),
QCoreApplication::translate("main", "source")); QCoreApplication::translate("main", "source"));
parser.addOption(sourceOption); parser.addOption(sourceOption);
QCommandLineOption destinationOption(QStringList() << "d" << "destination", QCommandLineOption destinationOption(QStringList() << "d"
<< "destination",
QCoreApplication::translate("main", "Output file name"), QCoreApplication::translate("main", "Output file name"),
QCoreApplication::translate("main", "destination")); QCoreApplication::translate("main", "destination"));
parser.addOption(destinationOption); 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", "Report parameter (can be more than one)"),
QCoreApplication::translate("main", "param_name=param_value")); QCoreApplication::translate("main", "param_name=param_value"));
parser.addOption(variablesOption); parser.addOption(variablesOption);
@ -45,7 +52,8 @@ int main(int argc, char *argv[])
} }
if (!report.loadFromFile(parser.value(sourceOption))) { if (!report.loadFromFile(parser.value(sourceOption))) {
std::cerr<<"Error! Report file \""+parser.value(sourceOption).toStdString()+"\" not found \n"; std::cerr << "Error! Report file \"" + parser.value(sourceOption).toStdString()
+ "\" not found \n";
return 1; return 1;
} }

View File

@ -28,8 +28,8 @@
* GNU General Public License for more details. * * GNU General Public License for more details. *
****************************************************************************/ ****************************************************************************/
#include "mainwindow.h" #include "mainwindow.h"
#include <QApplication>
#include <QApplication>
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {

View File

@ -29,15 +29,17 @@
****************************************************************************/ ****************************************************************************/
#include "mainwindow.h" #include "mainwindow.h"
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
#include <QDebug>
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
#include <QPrinter>
#include <QStringListModel>
#include <QtSql/QSqlQuery> #include <QtSql/QSqlQuery>
#include <QtSql/QSqlRecord> #include <QtSql/QSqlRecord>
#include <LimeReport>
#include <LRCallbackDS> #include <LRCallbackDS>
#include <QDebug> #include <LimeReport>
#include <QStringListModel>
#include <QPrinter>
#ifdef BUILD_WITH_EASY_PROFILER #ifdef BUILD_WITH_EASY_PROFILER
#include "easy/profiler.h" #include "easy/profiler.h"
@ -49,14 +51,16 @@
MainWindow::MainWindow(QWidget* parent): MainWindow::MainWindow(QWidget* parent):
QMainWindow(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); ui->setupUi(this);
report = new LimeReport::ReportEngine(this); report = new LimeReport::ReportEngine(this);
connect(report, SIGNAL(renderStarted()), this, SLOT(renderStarted())); connect(report, SIGNAL(renderStarted()), this, SLOT(renderStarted()));
connect(report, SIGNAL(renderPageFinished(int)), connect(report, SIGNAL(renderPageFinished(int)), this, SLOT(renderPageFinished(int)));
this, SLOT(renderPageFinished(int)));
connect(report, SIGNAL(renderFinished()), this, SLOT(renderFinished())); connect(report, SIGNAL(renderFinished()), this, SLOT(renderFinished()));
QFile dbFile(QApplication::applicationDirPath() + "/demo_reports/northwind.db"); QFile dbFile(QApplication::applicationDirPath() + "/demo_reports/northwind.db");
@ -80,34 +84,39 @@ MainWindow::MainWindow(QWidget *parent) :
} }
} }
LimeReport::ICallbackDatasource * callbackDatasource = report->dataManager()->createCallbackDatasource("master"); LimeReport::ICallbackDatasource* callbackDatasource
connect(callbackDatasource, SIGNAL(getCallbackData(LimeReport::CallbackInfo,QVariant&)), = report->dataManager()->createCallbackDatasource("master");
this, SLOT(slotGetCallbackData(LimeReport::CallbackInfo,QVariant&))); connect(callbackDatasource, SIGNAL(getCallbackData(LimeReport::CallbackInfo, QVariant&)), this,
connect(callbackDatasource, SIGNAL(changePos(const LimeReport::CallbackInfo::ChangePosType&,bool&)), SLOT(slotGetCallbackData(LimeReport::CallbackInfo, QVariant&)));
this, SLOT(slotChangePos(const LimeReport::CallbackInfo::ChangePosType&,bool&))); connect(callbackDatasource,
SIGNAL(changePos(const LimeReport::CallbackInfo::ChangePosType&, bool&)), this,
SLOT(slotChangePos(const LimeReport::CallbackInfo::ChangePosType&, bool&)));
callbackDatasource = report->dataManager()->createCallbackDatasource("detail"); callbackDatasource = report->dataManager()->createCallbackDatasource("detail");
connect(callbackDatasource, SIGNAL(getCallbackData(LimeReport::CallbackInfo,QVariant&)), connect(callbackDatasource, SIGNAL(getCallbackData(LimeReport::CallbackInfo, QVariant&)), this,
this, SLOT(slotGetCallbackChildData(LimeReport::CallbackInfo,QVariant&))); SLOT(slotGetCallbackChildData(LimeReport::CallbackInfo, QVariant&)));
connect(callbackDatasource, SIGNAL(changePos(const LimeReport::CallbackInfo::ChangePosType&,bool&)), connect(callbackDatasource,
this, SLOT(slotChangeChildPos(const LimeReport::CallbackInfo::ChangePosType&,bool&))); SIGNAL(changePos(const LimeReport::CallbackInfo::ChangePosType&, bool&)), this,
SLOT(slotChangeChildPos(const LimeReport::CallbackInfo::ChangePosType&, bool&)));
callbackDatasource = report->dataManager()->createCallbackDatasource("oneSlotDS"); callbackDatasource = report->dataManager()->createCallbackDatasource("oneSlotDS");
connect(callbackDatasource, SIGNAL(getCallbackData(LimeReport::CallbackInfo,QVariant&)), connect(callbackDatasource, SIGNAL(getCallbackData(LimeReport::CallbackInfo, QVariant&)), this,
this, SLOT(slotOneSlotDS(LimeReport::CallbackInfo,QVariant&))); SLOT(slotOneSlotDS(LimeReport::CallbackInfo, QVariant&)));
QStringList simpleData; QStringList simpleData;
simpleData << "value1" << "value2" << "value3"; simpleData << "value1"
<< "value2"
<< "value3";
QStringListModel* stringListModel = new QStringListModel(); QStringListModel* stringListModel = new QStringListModel();
stringListModel->setStringList(simpleData); stringListModel->setStringList(simpleData);
report->dataManager()->addModel("string_list", stringListModel, true); report->dataManager()->addModel("string_list", stringListModel, true);
QStringList strList; QStringList strList;
strList<<"value1"<<"value2"; strList << "value1"
//QScriptValue value = qScriptValueFromSequence(report->scriptManager()->scriptEngine(),strList); << "value2";
// QScriptValue value =
// qScriptValueFromSequence(report->scriptManager()->scriptEngine(),strList);
// report->scriptManager()->scriptEngine()->globalObject().setProperty("test_list",value); // report->scriptManager()->scriptEngine()->globalObject().setProperty("test_list",value);
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
@ -123,7 +132,8 @@ void MainWindow::on_pushButton_clicked()
EASY_BLOCK("design report"); EASY_BLOCK("design report");
report->dataManager()->clearUserVariables(); report->dataManager()->clearUserVariables();
if (!ui->leVariableName->text().isEmpty() && !ui->leVariableValue->text().isEmpty()) { if (!ui->leVariableName->text().isEmpty() && !ui->leVariableValue->text().isEmpty()) {
report->dataManager()->setReportVariable(ui->leVariableName->text(), ui->leVariableValue->text()); report->dataManager()->setReportVariable(ui->leVariableName->text(),
ui->leVariableValue->text());
} }
report->setShowProgressDialog(false); report->setShowProgressDialog(false);
report->designReport(); report->designReport();
@ -135,7 +145,9 @@ void MainWindow::on_pushButton_clicked()
void MainWindow::on_pushButton_2_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()) { if (!fileName.isEmpty()) {
EASY_PROFILER_ENABLE; EASY_PROFILER_ENABLE;
EASY_BLOCK("Load file"); EASY_BLOCK("Load file");
@ -143,7 +155,8 @@ void MainWindow::on_pushButton_2_clicked()
EASY_END_BLOCK; EASY_END_BLOCK;
EASY_BLOCK("Set report variable"); EASY_BLOCK("Set report variable");
if (!ui->leVariableName->text().isEmpty() && !ui->leVariableValue->text().isEmpty()) { if (!ui->leVariableName->text().isEmpty() && !ui->leVariableValue->text().isEmpty()) {
report->dataManager()->setReportVariable(ui->leVariableName->text(), ui->leVariableValue->text()); report->dataManager()->setReportVariable(ui->leVariableName->text(),
ui->leVariableValue->text());
} }
EASY_END_BLOCK; EASY_END_BLOCK;
#ifdef BUILD_WITH_EASY_PROFILER #ifdef BUILD_WITH_EASY_PROFILER
@ -210,22 +223,28 @@ void MainWindow::prepareData(QSqlQuery* ds, LimeReport::CallbackInfo info, QVari
case LimeReport::CallbackInfo::ColumnData: case LimeReport::CallbackInfo::ColumnData:
data = ds->value(ds->record().indexOf(info.columnName)); data = ds->value(ds->record().indexOf(info.columnName));
break; 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); 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; QSqlQuery* ds = m_customers;
if (!ds) return; if (!ds)
if (type == LimeReport::CallbackInfo::First) {result = ds->first();} return;
else {result = ds->next();} if (type == LimeReport::CallbackInfo::First) {
result = ds->first();
} else {
result = ds->next();
}
if (result) { if (result) {
m_orders->bindValue(":id", m_customers->value(m_customers->record().indexOf("CustomerID"))); m_orders->bindValue(":id", m_customers->value(m_customers->record().indexOf("CustomerID")));
m_orders->exec(); m_orders->exec();
@ -234,22 +253,29 @@ void MainWindow::slotChangePos(const LimeReport::CallbackInfo::ChangePosType &ty
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); 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; QSqlQuery* ds = m_orders;
if (!ds) return; if (!ds)
if (type == LimeReport::CallbackInfo::First) result = ds->first(); return;
else result = ds->next(); 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; QStringList columns;
columns << "Name" << "Value" << "Image"; columns << "Name"
<< "Value"
<< "Image";
switch (info.dataType) { switch (info.dataType) {
case LimeReport::CallbackInfo::RowCount: case LimeReport::CallbackInfo::RowCount:
data = 4; data = 4;
@ -271,6 +297,7 @@ void MainWindow::slotOneSlotDS(LimeReport::CallbackInfo info, QVariant &data)
data = info.columnName + " " + QString::number(info.index); data = info.columnName + " " + QString::number(info.index);
} }
break; break;
default: break; default:
break;
} }
} }

View File

@ -30,18 +30,18 @@
#ifndef MAINWINDOW_H #ifndef MAINWINDOW_H
#define MAINWINDOW_H #define MAINWINDOW_H
#include "lrreportengine.h"
#include <QMainWindow> #include <QMainWindow>
#include <QProgressDialog> #include <QProgressDialog>
#include <QtSql/QSqlDatabase> #include <QtSql/QSqlDatabase>
#include <QtSql/QSqlQueryModel> #include <QtSql/QSqlQueryModel>
#include "lrreportengine.h"
namespace Ui { namespace Ui {
class MainWindow; class MainWindow;
} }
class MainWindow : public QMainWindow class MainWindow: public QMainWindow {
{
Q_OBJECT Q_OBJECT
public: public:
@ -58,8 +58,10 @@ private slots:
void slotGetCallbackChildData(LimeReport::CallbackInfo info, QVariant& data); void slotGetCallbackChildData(LimeReport::CallbackInfo info, QVariant& data);
void slotChangeChildPos(const LimeReport::CallbackInfo::ChangePosType& type, bool& result); void slotChangeChildPos(const LimeReport::CallbackInfo::ChangePosType& type, bool& result);
void slotOneSlotDS(LimeReport::CallbackInfo info, QVariant& data); void slotOneSlotDS(LimeReport::CallbackInfo info, QVariant& data);
private: private:
void prepareData(QSqlQuery* ds, LimeReport::CallbackInfo info, QVariant& data); void prepareData(QSqlQuery* ds, LimeReport::CallbackInfo info, QVariant& data);
private: private:
Ui::MainWindow* ui; Ui::MainWindow* ui;
LimeReport::ReportEngine* report; LimeReport::ReportEngine* report;
@ -73,9 +75,6 @@ private:
int m_currentOrderRecord; int m_currentOrderRecord;
QSqlQuery* m_customers; QSqlQuery* m_customers;
QSqlQuery* m_orders; QSqlQuery* m_orders;
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H

View File

@ -1,4 +1,5 @@
#include "mainwindow.h" #include "mainwindow.h"
#include <QApplication> #include <QApplication>
int main(int argc, char* argv[]) int main(int argc, char* argv[])

View File

@ -1,17 +1,16 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
#include <QSqlDatabase>
#include <QDir>
#include <QDebug> #include <QDebug>
#include <QDir>
#include <QSqlDatabase>
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
#include <QDesktopWidget> #include <QDesktopWidget>
#else #else
#include <QScreen> #include <QScreen>
#endif #endif
MainWindow::MainWindow(QWidget *parent) : MainWindow::MainWindow(QWidget* parent): QMainWindow(parent), ui(new Ui::MainWindow)
QMainWindow(parent),
ui(new Ui::MainWindow)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -22,7 +21,8 @@ MainWindow::MainWindow(QWidget *parent) :
m_pageNavigator->setPrefix(tr("Page :")); m_pageNavigator->setPrefix(tr("Page :"));
ui->toolBar->insertWidget(ui->actionZoom_Out, m_scalePercent); ui->toolBar->insertWidget(ui->actionZoom_Out, m_scalePercent);
ui->toolBar->insertWidget(ui->actionNext_Page, m_pageNavigator); ui->toolBar->insertWidget(ui->actionNext_Page, m_pageNavigator);
connect(m_scalePercent, SIGNAL(currentIndexChanged(QString)), this, SLOT(scaleComboboxChanged(QString))); connect(m_scalePercent, SIGNAL(currentIndexChanged(QString)), this,
SLOT(scaleComboboxChanged(QString)));
connect(m_pageNavigator, SIGNAL(valueChanged(int)), this, SLOT(slotPageNavigatorChanged(int))); connect(m_pageNavigator, SIGNAL(valueChanged(int)), this, SLOT(slotPageNavigatorChanged(int)));
ui->groupBox_2->layout()->addWidget(m_preview); ui->groupBox_2->layout()->addWidget(m_preview);
buildReportsTree(QApplication::applicationDirPath() + "/demo_reports/", ui->treeWidget); buildReportsTree(QApplication::applicationDirPath() + "/demo_reports/", ui->treeWidget);
@ -33,7 +33,8 @@ MainWindow::MainWindow(QWidget *parent) :
connect(ui->actionNext_Page, SIGNAL(triggered()), m_preview, SLOT(nextPage())); connect(ui->actionNext_Page, SIGNAL(triggered()), m_preview, SLOT(nextPage()));
connect(ui->actionLast_Page, SIGNAL(triggered()), m_preview, SLOT(lastPage())); connect(ui->actionLast_Page, SIGNAL(triggered()), m_preview, SLOT(lastPage()));
connect(m_preview, SIGNAL(scalePercentChanged(int)), this, SLOT(slotScalePercentChanged(int))); connect(m_preview, SIGNAL(scalePercentChanged(int)), this, SLOT(slotScalePercentChanged(int)));
//connect(ui->cbScalePercent, SIGNAL(currentIndexChanged(QString)), this, SLOT(scaleComboboxChanged(QString))); // connect(ui->cbScalePercent, SIGNAL(currentIndexChanged(QString)), this,
// SLOT(scaleComboboxChanged(QString)));
connect(ui->actionFit_Width, SIGNAL(triggered()), m_preview, SLOT(fitWidth())); connect(ui->actionFit_Width, SIGNAL(triggered()), m_preview, SLOT(fitWidth()));
connect(ui->actionFit_Page, SIGNAL(triggered()), m_preview, SLOT(fitPage())); connect(ui->actionFit_Page, SIGNAL(triggered()), m_preview, SLOT(fitPage()));
connect(m_preview, SIGNAL(pagesSet(int)), this, SLOT(slotPagesSet(int))); connect(m_preview, SIGNAL(pagesSet(int)), this, SLOT(slotPagesSet(int)));
@ -68,21 +69,17 @@ MainWindow::MainWindow(QWidget *parent) :
if (ui->treeWidget->topLevelItem(index)->childCount() > 0) if (ui->treeWidget->topLevelItem(index)->childCount() > 0)
++index; ++index;
else { 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)); ui->treeWidget->setCurrentItem(ui->treeWidget->topLevelItem(index));
break; break;
} }
} }
} }
m_preview->refreshPages(); m_preview->refreshPages();
} }
MainWindow::~MainWindow() MainWindow::~MainWindow() { delete ui; }
{
delete ui;
}
void MainWindow::enableUI(bool value) void MainWindow::enableUI(bool value)
{ {
@ -127,15 +124,9 @@ void MainWindow::slotPagesSet(int pagesCount)
enableUI(true); enableUI(true);
} }
void MainWindow::slotPageChanged(int page) void MainWindow::slotPageChanged(int page) { m_pageNavigator->setValue(page); }
{
m_pageNavigator->setValue(page);
}
void MainWindow::slotPageNavigatorChanged(int page) void MainWindow::slotPageNavigatorChanged(int page) { m_preview->pageNavigatorChanged(page); }
{
m_preview->pageNavigatorChanged(page);
}
void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem* item, int) void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem* item, int)
{ {
@ -166,7 +157,4 @@ void MainWindow::slotDesignReport()
m_preview->refreshPages(); m_preview->refreshPages();
} }
void MainWindow::slotOneToOne() void MainWindow::slotOneToOne() { m_preview->setScalePercent(100); }
{
m_preview->setScalePercent(100);
}

View File

@ -1,25 +1,26 @@
#ifndef MAINWINDOW_H #ifndef MAINWINDOW_H
#define MAINWINDOW_H #define MAINWINDOW_H
#include <QMainWindow>
#include <LimeReport>
#include <QTreeWidget>
#include <QDir>
#include <QDebug>
#include <QComboBox> #include <QComboBox>
#include <QDebug>
#include <QDir>
#include <QMainWindow>
#include <QSpinBox> #include <QSpinBox>
#include <QTreeWidget>
#include <LimeReport>
namespace Ui { namespace Ui {
class MainWindow; class MainWindow;
} }
class MainWindow : public QMainWindow class MainWindow: public QMainWindow {
{
Q_OBJECT Q_OBJECT
public: public:
explicit MainWindow(QWidget* parent = 0); explicit MainWindow(QWidget* parent = 0);
~MainWindow(); ~MainWindow();
private: private:
void enableUI(bool value); void enableUI(bool value);
private slots: private slots:
@ -32,9 +33,9 @@ private slots:
// void on_sbPageNavigator_valueChanged(int arg1); // void on_sbPageNavigator_valueChanged(int arg1);
void slotDesignReport(); void slotDesignReport();
void slotOneToOne(); void slotOneToOne();
private: private:
template< typename T > template <typename T> void buildReportsTree(const QString& path, T* parentItem)
void buildReportsTree(const QString &path, T* parentItem)
{ {
QDir reportsDir(path); QDir reportsDir(path);
QStringList items = reportsDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); QStringList items = reportsDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
@ -55,6 +56,7 @@ private:
} }
} }
void initPercentCombobox(); void initPercentCombobox();
private: private:
Ui::MainWindow* ui; Ui::MainWindow* ui;
LimeReport::ReportEngine m_report; LimeReport::ReportEngine m_report;

View File

@ -1,4 +1,5 @@
#include "designersettingmanager.h" #include "designersettingmanager.h"
#include <QMessageBox> #include <QMessageBox>
DesignerSettingManager::DesignerSettingManager(QObject* parent): QObject(parent) DesignerSettingManager::DesignerSettingManager(QObject* parent): QObject(parent)
@ -6,10 +7,7 @@ DesignerSettingManager::DesignerSettingManager(QObject *parent) : QObject(parent
m_setting = new QSettings("LimeReport", QCoreApplication::applicationName()); m_setting = new QSettings("LimeReport", QCoreApplication::applicationName());
} }
DesignerSettingManager::~DesignerSettingManager() DesignerSettingManager::~DesignerSettingManager() { delete m_setting; }
{
delete m_setting;
}
void DesignerSettingManager::getAvailableLanguages(QList<QLocale::Language>* languages) void DesignerSettingManager::getAvailableLanguages(QList<QLocale::Language>* languages)
{ {
@ -36,7 +34,8 @@ QLocale::Language DesignerSettingManager::getCurrentDefaultLanguage()
void DesignerSettingManager::currentDefaultLanguageChanged(QLocale::Language language) 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->beginGroup("ReportDesigner");
m_setting->setValue("DesignerLanguage", (int)language); m_setting->setValue("DesignerLanguage", (int)language);
m_setting->endGroup(); m_setting->endGroup();

View File

@ -1,13 +1,12 @@
#ifndef DESIGNERSETTINGMANAGER_H #ifndef DESIGNERSETTINGMANAGER_H
#define DESIGNERSETTINGMANAGER_H #define DESIGNERSETTINGMANAGER_H
#include <QObject>
#include <QLocale>
#include <QApplication> #include <QApplication>
#include <QLocale>
#include <QObject>
#include <QSettings> #include <QSettings>
class DesignerSettingManager : public QObject class DesignerSettingManager: public QObject {
{
Q_OBJECT Q_OBJECT
public: public:
explicit DesignerSettingManager(QObject* parent = 0); explicit DesignerSettingManager(QObject* parent = 0);
@ -16,6 +15,7 @@ public slots:
void getAvailableLanguages(QList<QLocale::Language>* languages); void getAvailableLanguages(QList<QLocale::Language>* languages);
QLocale::Language getCurrentDefaultLanguage(); QLocale::Language getCurrentDefaultLanguage();
void currentDefaultLanguageChanged(QLocale::Language language); void currentDefaultLanguageChanged(QLocale::Language language);
private: private:
QSettings* m_setting; QSettings* m_setting;
}; };

View File

@ -1,9 +1,11 @@
#include <QApplication>
#include <LimeReport>
#include <QTranslator>
#include <QDebug>
#include "designersettingmanager.h" #include "designersettingmanager.h"
#include <QApplication>
#include <QDebug>
#include <QTranslator>
#include <LimeReport>
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
QApplication a(argc, argv); QApplication a(argc, argv);
@ -23,13 +25,15 @@ int main(int argc, char *argv[])
if (limeReportTranslator.load("limereport_" + designerTranslation, translationPath)) { if (limeReportTranslator.load("limereport_" + designerTranslation, translationPath)) {
static_cast<void>(qtBaseTranslator.load("qtbase_" + 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(&qtBaseTranslator);
a.installTranslator(&qtDesignerTranslator); a.installTranslator(&qtDesignerTranslator);
a.installTranslator(&limeReportTranslator); a.installTranslator(&limeReportTranslator);
Qt::LayoutDirection layoutDirection = QLocale(manager.getCurrentDefaultLanguage()).textDirection(); Qt::LayoutDirection layoutDirection
= QLocale(manager.getCurrentDefaultLanguage()).textDirection();
a.setLayoutDirection(layoutDirection); a.setLayoutDirection(layoutDirection);
} }
@ -42,8 +46,8 @@ int main(int argc, char *argv[])
QObject::connect(&report, SIGNAL(getAvailableDesignerLanguages(QList<QLocale::Language>*)), QObject::connect(&report, SIGNAL(getAvailableDesignerLanguages(QList<QLocale::Language>*)),
&manager, SLOT(getAvailableLanguages(QList<QLocale::Language>*))); &manager, SLOT(getAvailableLanguages(QList<QLocale::Language>*)));
QObject::connect(&report, SIGNAL(getCurrentDefaultDesignerLanguage()), QObject::connect(&report, SIGNAL(getCurrentDefaultDesignerLanguage()), &manager,
&manager, SLOT(getCurrentDefaultLanguage())); SLOT(getCurrentDefaultLanguage()));
QObject::connect(&report, SIGNAL(currentDefaultDesignerLanguageChanged(QLocale::Language)), QObject::connect(&report, SIGNAL(currentDefaultDesignerLanguageChanged(QLocale::Language)),
&manager, SLOT(currentDefaultLanguageChanged(QLocale::Language))); &manager, SLOT(currentDefaultLanguageChanged(QLocale::Language)));
@ -52,4 +56,3 @@ int main(int argc, char *argv[])
report.designReport(); report.designReport();
return a.exec(); return a.exec();
} }

View File

@ -1,12 +1,14 @@
#include "lrdesignerplugin.h" #include "lrdesignerplugin.h"
#include <QRect>
#include "lrreportdesignwindow.h" #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); return new LimeReport::ReportDesignWindow(report, parent, settings);
} }
@ -14,4 +16,3 @@ LimeReport::ReportDesignWindowInterface* ReportDesignerFactoryPlugin::getDesigne
#if QT_VERSION < 0x050000 #if QT_VERSION < 0x050000
Q_EXPORT_PLUGIN2(LimeReportPluginInterface, ReportDesignerFactoryPlugin) Q_EXPORT_PLUGIN2(LimeReportPluginInterface, ReportDesignerFactoryPlugin)
#endif #endif

View File

@ -2,6 +2,7 @@
#define LRDESIGNERPLUGIN_H #define LRDESIGNERPLUGIN_H
#include <QMainWindow> #include <QMainWindow>
#include <lrdesignerplugininterface.h> #include <lrdesignerplugininterface.h>
class ReportDesignerFactoryPlugin: public QObject, public LimeReportDesignerPluginInterface { class ReportDesignerFactoryPlugin: public QObject, public LimeReportDesignerPluginInterface {
@ -13,7 +14,9 @@ class ReportDesignerFactoryPlugin : public QObject, public LimeReportDesignerPlu
public: public:
~ReportDesignerFactoryPlugin(); ~ReportDesignerFactoryPlugin();
LimeReport::ReportDesignWindowInterface* getDesignerWindow(LimeReport::ReportEnginePrivateInterface* report, QWidget* parent, QSettings* settings); LimeReport::ReportDesignWindowInterface*
getDesignerWindow(LimeReport::ReportEnginePrivateInterface* report, QWidget* parent,
QSettings* settings);
}; };
#endif #endif

View File

@ -4,8 +4,18 @@
namespace LimeReport { namespace LimeReport {
struct CallbackInfo { struct CallbackInfo {
enum DataType{IsEmpty, HasNext, ColumnHeaderData, ColumnData, ColumnCount, RowCount}; enum DataType {
enum ChangePosType{First, Next}; IsEmpty,
HasNext,
ColumnHeaderData,
ColumnData,
ColumnCount,
RowCount
};
enum ChangePosType {
First,
Next
};
DataType dataType; DataType dataType;
int index; int index;
QString columnName; QString columnName;
@ -18,7 +28,6 @@ signals:
void changePos(const LimeReport::CallbackInfo::ChangePosType& type, bool& result); void changePos(const LimeReport::CallbackInfo::ChangePosType& type, bool& result);
}; };
} } // namespace LimeReport
#endif // LRVIRTUALDATASOURCEINTF #endif // LRVIRTUALDATASOURCEINTF

View File

@ -1,12 +1,15 @@
#ifndef LRDATASOURCEINTF_H #ifndef LRDATASOURCEINTF_H
#define LRDATASOURCEINTF_H #define LRDATASOURCEINTF_H
#include <QSharedPointer>
#include <QAbstractItemModel> #include <QAbstractItemModel>
#include <QSharedPointer>
namespace LimeReport { namespace LimeReport {
class IDataSource { class IDataSource {
public: public:
enum DatasourceMode{DESIGN_MODE,RENDER_MODE}; enum DatasourceMode {
DESIGN_MODE,
RENDER_MODE
};
typedef QSharedPointer<IDataSource> Ptr; typedef QSharedPointer<IDataSource> Ptr;
virtual ~IDataSource() { } virtual ~IDataSource() { }
virtual bool next() = 0; virtual bool next() = 0;
@ -19,8 +22,12 @@ public:
virtual QVariant data(const QString& columnName) = 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) = 0;
virtual QVariant dataByRowIndex(const QString& columnName, int rowIndex, int roleName) = 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 dataByRowIndex(const QString& columnName, int rowIndex,
virtual QVariant dataByKeyField(const QString& columnName, const QString& keyColumnName, QVariant keyData) = 0; const QString& roleName)
= 0;
virtual QVariant dataByKeyField(const QString& columnName, const QString& keyColumnName,
QVariant keyData)
= 0;
virtual int columnCount() = 0; virtual int columnCount() = 0;
virtual QString columnNameByIndex(int columnIndex) = 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;
@ -33,7 +40,8 @@ public:
class IDataSourceHolder { class IDataSourceHolder {
public: public:
virtual ~IDataSourceHolder() { } virtual ~IDataSourceHolder() { }
virtual IDataSource* dataSource(IDataSource::DatasourceMode mode = IDataSource::RENDER_MODE) = 0; virtual IDataSource* dataSource(IDataSource::DatasourceMode mode = IDataSource::RENDER_MODE)
= 0;
virtual QString lastError() const = 0; virtual QString lastError() const = 0;
virtual bool isInvalid() const = 0; virtual bool isInvalid() const = 0;
virtual bool isOwned() const = 0; virtual bool isOwned() const = 0;
@ -47,5 +55,3 @@ public:
} // namespace LimeReport } // namespace LimeReport
#endif // LRDATASOURCEINTF_H #endif // LRDATASOURCEINTF_H

View File

@ -31,8 +31,8 @@
#define LRDATASOURCEMANAGERINTF_H #define LRDATASOURCEMANAGERINTF_H
#include "lrcallbackdatasourceintf.h" #include "lrcallbackdatasourceintf.h"
#include "lrglobal.h"
#include "lrdatasourceintf.h" #include "lrdatasourceintf.h"
#include "lrglobal.h"
class QVariant; class QVariant;
class QString; class QString;
@ -55,7 +55,9 @@ public:
virtual bool containsVariable(const QString& variableName) = 0; virtual bool containsVariable(const QString& variableName) = 0;
virtual QVariant variable(const QString& variableName) = 0; virtual QVariant variable(const QString& variableName) = 0;
virtual bool addModel(const QString& name, QAbstractItemModel* model, bool owned) = 0; virtual bool addModel(const QString& name, QAbstractItemModel* model, bool owned) = 0;
virtual void addCSV(const QString& name, const QString& csvText, const QString& separator, bool firstRowIsHeader) = 0; virtual void addCSV(const QString& name, const QString& csvText, const QString& separator,
bool firstRowIsHeader)
= 0;
virtual void removeModel(const QString& name) = 0; virtual void removeModel(const QString& name) = 0;
virtual bool containsDatasource(const QString& dataSourceName) = 0; virtual bool containsDatasource(const QString& dataSourceName) = 0;
virtual void clearUserVariables() = 0; virtual void clearUserVariables() = 0;
@ -69,6 +71,5 @@ public:
virtual IDataSourceHolder* dataSourceHolder(const QString& name) = 0; virtual IDataSourceHolder* dataSourceHolder(const QString& name) = 0;
}; };
} } // namespace LimeReport
#endif // LRDATASOURCEMANAGERINTF_H #endif // LRDATASOURCEMANAGERINTF_H

View File

@ -27,17 +27,20 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. * * GNU General Public License for more details. *
****************************************************************************/ ****************************************************************************/
#include <QString>
#include <QDebug>
#include "lrglobal.h" #include "lrglobal.h"
#include <QDebug>
#include <QString>
namespace LimeReport { namespace LimeReport {
QString extractClassName(QString className) QString extractClassName(QString className)
{ {
int startPos = className.lastIndexOf("::"); int startPos = className.lastIndexOf("::");
if(startPos==-1) startPos=0; if (startPos == -1)
else startPos+=2; startPos = 0;
else
startPos += 2;
return className.right(className.length() - startPos); return className.right(className.length() - startPos);
} }
@ -46,7 +49,8 @@ bool ReportSettings::suppressAbsentFieldsAndVarsWarnings() const
return m_suppressAbsentFieldsAndVarsWarnings; return m_suppressAbsentFieldsAndVarsWarnings;
} }
void ReportSettings::setSuppressAbsentFieldsAndVarsWarnings(bool suppressAbsentFieldsAndVarsWarnings) void ReportSettings::setSuppressAbsentFieldsAndVarsWarnings(
bool suppressAbsentFieldsAndVarsWarnings)
{ {
m_suppressAbsentFieldsAndVarsWarnings = suppressAbsentFieldsAndVarsWarnings; m_suppressAbsentFieldsAndVarsWarnings = suppressAbsentFieldsAndVarsWarnings;
} }
@ -68,9 +72,11 @@ QString replaceHTMLSymbols(const QString &value)
} }
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
QVector<QString> normalizeCaptures(const QRegExp& reg){ QVector<QString> normalizeCaptures(const QRegExp& reg)
{
#else #else
QVector<QString> normalizeCaptures(const QRegularExpressionMatch &reg){ QVector<QString> normalizeCaptures(const QRegularExpressionMatch& reg)
{
#endif #endif
QVector<QString> result; QVector<QString> result;
foreach (QString cap, reg.capturedTexts()) { foreach (QString cap, reg.capturedTexts()) {
@ -80,7 +86,8 @@ QVector<QString> normalizeCaptures(const QRegularExpressionMatch &reg){
return result; return result;
} }
bool isColorDark(QColor color){ bool isColorDark(QColor color)
{
qreal darkness = 1 - (0.299 * color.red() + 0.587 * color.green() + 0.114 * color.blue()) / 255; qreal darkness = 1 - (0.299 * color.red() + 0.587 * color.green() + 0.114 * color.blue()) / 255;
if (darkness < 0.5) { if (darkness < 0.5) {
return false; return false;

View File

@ -30,11 +30,13 @@
#ifndef LRGLOBAL_H #ifndef LRGLOBAL_H
#define LRGLOBAL_H #define LRGLOBAL_H
#include "qglobal.h" #include "qglobal.h"
#include <stdexcept>
#include <QString> #include <QString>
#include <QStyleOptionViewItem> #include <QStyleOptionViewItem>
#include <QtGlobal> #include <QtGlobal>
#include <stdexcept>
#if defined(LIMEREPORT_EXPORTS) #if defined(LIMEREPORT_EXPORTS)
#define LIMEREPORT_EXPORT Q_DECL_EXPORT #define LIMEREPORT_EXPORT Q_DECL_EXPORT
#elif defined(LIMEREPORT_IMPORTS) #elif defined(LIMEREPORT_IMPORTS)
@ -80,10 +82,16 @@ namespace Const{
const qreal BAND_NAME_TEXT_OPACITY = 0.6; const qreal BAND_NAME_TEXT_OPACITY = 0.6;
const qreal SELECTION_OPACITY = 0.3; const qreal SELECTION_OPACITY = 0.3;
const QString FIELD_RX = "\\$D\\s*\\{\\s*([^{}]*)\\s*\\}"; const QString FIELD_RX = "\\$D\\s*\\{\\s*([^{}]*)\\s*\\}";
const QString VARIABLE_RX = "\\$V\\s*\\{\\s*(?:([^\\{\\},]*)|(?:([^\\{\\}]*)\\s*,\\s*([^\\{\\}]*)))\\s*\\}"; const QString VARIABLE_RX = "\\$V\\s*\\{\\s*(?:([^\\{\\},]*)|(?:([^\\{\\}]*)\\s*,\\s*([^\\{"
const QString NAMED_VARIABLE_RX = "\\$V\\s*\\{\\s*(?:(%1)|(?:(%1)\\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 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 DATASOURCE_INDEX = 3;
const int VALUE_INDEX = 2; const int VALUE_INDEX = 2;
const int EXPRESSION_ARGUMENT_INDEX = 1; const int EXPRESSION_ARGUMENT_INDEX = 1;
@ -100,7 +108,7 @@ namespace Const{
const char SCRIPT_SIGN = 'S'; const char SCRIPT_SIGN = 'S';
const char FIELD_SIGN = 'D'; const char FIELD_SIGN = 'D';
const char VARIABLE_SIGN = 'V'; const char VARIABLE_SIGN = 'V';
} } // namespace Const
QString extractClassName(QString className); QString extractClassName(QString className);
QString escapeSimbols(const QString& value); QString escapeSimbols(const QString& value);
QString replaceHTMLSymbols(const QString& value); QString replaceHTMLSymbols(const QString& value);
@ -111,16 +119,33 @@ namespace Const{
#endif #endif
bool isColorDark(QColor color); bool isColorDark(QColor color);
enum ExpandType {EscapeSymbols, NoEscapeSymbols, ReplaceHTMLSymbols}; enum ExpandType {
enum RenderPass {FirstPass = 1, SecondPass = 2}; EscapeSymbols,
enum ArrangeType {AsNeeded, Force}; NoEscapeSymbols,
enum ScaleType {FitWidth, FitPage, OneToOne, Percents}; ReplaceHTMLSymbols
enum PreviewHint{ShowAllPreviewBars = 0, };
enum RenderPass {
FirstPass = 1,
SecondPass = 2
};
enum ArrangeType {
AsNeeded,
Force
};
enum ScaleType {
FitWidth,
FitPage,
OneToOne,
Percents
};
enum PreviewHint {
ShowAllPreviewBars = 0,
HidePreviewToolBar = 1, HidePreviewToolBar = 1,
HidePreviewMenuBar = 2, HidePreviewMenuBar = 2,
HidePreviewStatusBar = 4, HidePreviewStatusBar = 4,
HideAllPreviewBar = 7, HideAllPreviewBar = 7,
PreviewBarsUserSetting = 8}; PreviewBarsUserSetting = 8
};
Q_DECLARE_FLAGS(PreviewHints, PreviewHint) Q_DECLARE_FLAGS(PreviewHints, PreviewHint)
Q_FLAGS(PreviewHints) Q_FLAGS(PreviewHints)
@ -133,23 +158,28 @@ namespace Const{
class LIMEREPORT_EXPORT ReportSettings { class LIMEREPORT_EXPORT ReportSettings {
public: public:
#ifdef DEFAULT_ITEM_PADDING #ifdef DEFAULT_ITEM_PADDING
ReportSettings():m_suppressAbsentFieldsAndVarsWarnings(false), m_baseItemPadding(DEFAULT_ITEM_PADDING){} ReportSettings():
m_suppressAbsentFieldsAndVarsWarnings(false),
m_baseItemPadding(DEFAULT_ITEM_PADDING)
{
}
#else #else
ReportSettings(): m_suppressAbsentFieldsAndVarsWarnings(false), m_baseItemPadding(0) { } ReportSettings(): m_suppressAbsentFieldsAndVarsWarnings(false), m_baseItemPadding(0) { }
#endif #endif
void setDefaultValues(){ void setDefaultValues()
{
m_suppressAbsentFieldsAndVarsWarnings = false; m_suppressAbsentFieldsAndVarsWarnings = false;
#ifdef DEFAULT_ITEM_PADDING #ifdef DEFAULT_ITEM_PADDING
m_baseItemPadding = DEFAULT_ITEM_PADDING; m_baseItemPadding = DEFAULT_ITEM_PADDING;
#else #else
m_baseItemPadding = 0; m_baseItemPadding = 0;
#endif #endif
} }
bool suppressAbsentFieldsAndVarsWarnings() const; bool suppressAbsentFieldsAndVarsWarnings() const;
void setSuppressAbsentFieldsAndVarsWarnings(bool suppressAbsentFieldsAndVarsWarnings); void setSuppressAbsentFieldsAndVarsWarnings(bool suppressAbsentFieldsAndVarsWarnings);
int baseItemPadding() const; int baseItemPadding() const;
void setBaseItemPadding(int newBaseTextItemPadding); void setBaseItemPadding(int newBaseTextItemPadding);
private: private:
bool m_suppressAbsentFieldsAndVarsWarnings; bool m_suppressAbsentFieldsAndVarsWarnings;
int m_baseItemPadding; int m_baseItemPadding;
@ -157,7 +187,9 @@ namespace Const{
class LIMEREPORT_EXPORT IExternalPainter { class LIMEREPORT_EXPORT IExternalPainter {
public: public:
virtual void paintByExternalPainter(const QString& objectName, QPainter* painter, const QStyleOptionGraphicsItem* options) = 0; virtual void paintByExternalPainter(const QString& objectName, QPainter* painter,
const QStyleOptionGraphicsItem* options)
= 0;
virtual ~IExternalPainter(); virtual ~IExternalPainter();
}; };
@ -182,11 +214,18 @@ namespace Const{
QRegularExpression getNamedVariableRegEx(QString variableName); QRegularExpression getNamedVariableRegEx(QString variableName);
#endif #endif
class LIMEREPORT_EXPORT Enums {
class LIMEREPORT_EXPORT Enums
{
public: public:
enum VariableDataType {Undefined, String, Bool, Int, Real, Date, Time, DateTime}; enum VariableDataType {
Undefined,
String,
Bool,
Int,
Real,
Date,
Time,
DateTime
};
#if QT_VERSION >= 0x050500 #if QT_VERSION >= 0x050500
Q_ENUM(VariableDataType) Q_ENUM(VariableDataType)
#else #else

View File

@ -1,12 +1,13 @@
#ifndef LRPREVIEWREPORTWIDGET_H #ifndef LRPREVIEWREPORTWIDGET_H
#define LRPREVIEWREPORTWIDGET_H #define LRPREVIEWREPORTWIDGET_H
#include <QWidget>
#include <QTimer>
#include <QPrinter>
#include "lrglobal.h" #include "lrglobal.h"
#include "lrpreparedpagesintf.h" #include "lrpreparedpagesintf.h"
#include <QPrinter>
#include <QTimer>
#include <QWidget>
namespace LimeReport { namespace LimeReport {
namespace Ui { namespace Ui {
@ -18,17 +19,18 @@ class ReportEnginePrivate;
class ReportEngine; class ReportEngine;
class PageDesignIntf; class PageDesignIntf;
class LIMEREPORT_EXPORT PreviewReportWidget : public QWidget class LIMEREPORT_EXPORT PreviewReportWidget: public QWidget {
{
Q_OBJECT Q_OBJECT
friend class ReportEnginePrivate; friend class ReportEnginePrivate;
friend class PreviewReportWindow; friend class PreviewReportWindow;
friend class PreviewReportWidgetPrivate; friend class PreviewReportWidgetPrivate;
public: public:
explicit PreviewReportWidget(ReportEngine* report, QWidget* parent = 0); explicit PreviewReportWidget(ReportEngine* report, QWidget* parent = 0);
~PreviewReportWidget(); ~PreviewReportWidget();
QList<QString> aviableExporters(); 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; ScaleType scaleType() const;
int scalePercent() const; int scalePercent() const;
void setScaleType(const ScaleType& scaleType, int percent = 0); void setScaleType(const ScaleType& scaleType, int percent = 0);
@ -59,6 +61,7 @@ public slots:
void setScalePercent(int percent); void setScalePercent(int percent);
void fitWidth(); void fitWidth();
void fitPage(); void fitPage();
protected: protected:
void resizeEvent(QResizeEvent*); void resizeEvent(QResizeEvent*);
signals: signals:
@ -72,11 +75,13 @@ private slots:
void reportEngineDestroyed(QObject* object); void reportEngineDestroyed(QObject* object);
void slotZoomed(double); void slotZoomed(double);
void resizeDone(); void resizeDone();
private: private:
void initPreview(); void initPreview();
void setErrorsMesagesVisible(bool visible); void setErrorsMesagesVisible(bool visible);
void setErrorMessages(const QStringList& value); void setErrorMessages(const QStringList& value);
void emitPageSet(); void emitPageSet();
private: private:
Ui::PreviewReportWidget* ui; Ui::PreviewReportWidget* ui;
PreviewReportWidgetPrivate* d_ptr; PreviewReportWidgetPrivate* d_ptr;

View File

@ -1,14 +1,14 @@
#ifndef LRRENDERENGINE_H #ifndef LRRENDERENGINE_H
#define LRRENDERENGINE_H #define LRRENDERENGINE_H
#include <QObject>
#include <QSettings>
#include <QPrintDialog>
#include "lrglobal.h"
#include "lrdatasourcemanagerintf.h" #include "lrdatasourcemanagerintf.h"
#include "lrscriptenginemanagerintf.h" #include "lrglobal.h"
#include "lrpreviewreportwidget.h" #include "lrpreviewreportwidget.h"
#include "lrscriptenginemanagerintf.h"
#include <QObject>
#include <QPrintDialog>
#include <QSettings>
namespace LimeReport { namespace LimeReport {
@ -17,10 +17,12 @@ public:
int fromPage() const { return m_fromPage; } int fromPage() const { return m_fromPage; }
int toPage() const { return m_toPage; } int toPage() const { return m_toPage; }
QPrintDialog::PrintRange rangeType() const { return m_rangeType; } QPrintDialog::PrintRange rangeType() const { return m_rangeType; }
PrintRange(QAbstractPrintDialog::PrintRange rangeType=QPrintDialog::AllPages, int fromPage=0, int toPage=0); PrintRange(QAbstractPrintDialog::PrintRange rangeType = QPrintDialog::AllPages,
int fromPage = 0, int toPage = 0);
void setRangeType(QAbstractPrintDialog::PrintRange rangeType) { m_rangeType = rangeType; } void setRangeType(QAbstractPrintDialog::PrintRange rangeType) { m_rangeType = rangeType; }
void setFromPage(int fromPage) { m_fromPage = fromPage; } void setFromPage(int fromPage) { m_fromPage = fromPage; }
void setToPage(int toPage) { m_toPage = toPage; } void setToPage(int toPage) { m_toPage = toPage; }
private: private:
QPrintDialog::PrintRange m_rangeType; QPrintDialog::PrintRange m_rangeType;
int m_fromPage; int m_fromPage;
@ -39,8 +41,10 @@ class RenderEnginePrivate;
class LIMEREPORT_EXPORT RenderEngine: public QObject { class LIMEREPORT_EXPORT RenderEngine: public QObject {
Q_OBJECT Q_OBJECT
friend class PreviewReportWidget; friend class PreviewReportWidget;
public: public:
static void setSettings(QSettings* value) { m_settings = value; } static void setSettings(QSettings* value) { m_settings = value; }
public: public:
explicit RenderEngine(QObject* parent = 0); explicit RenderEngine(QObject* parent = 0);
explicit RenderEngine(RenderEnginePrivate* dd, QObject* parent = 0); explicit RenderEngine(RenderEnginePrivate* dd, QObject* parent = 0);
@ -78,11 +82,14 @@ signals:
void onLoad(bool& loaded); void onLoad(bool& loaded);
public slots: public slots:
void cancelRender(); void cancelRender();
protected: protected:
QObject* d_ptr; QObject* d_ptr;
private: private:
static QSettings* m_settings; static QSettings* m_settings;
void init(); void init();
private: private:
Q_DECLARE_PRIVATE(RenderEngine) Q_DECLARE_PRIVATE(RenderEngine)
}; };

View File

@ -31,16 +31,16 @@
#define LRREPORTDESIGNINTF_H #define LRREPORTDESIGNINTF_H
#include <QObject> #include <QObject>
#include <QSettings>
#include <QPrintDialog> #include <QPrintDialog>
#include <QSettings>
//#include <QJSEngine> //#include <QJSEngine>
#include "lrglobal.h"
#include "lrdatasourcemanagerintf.h" #include "lrdatasourcemanagerintf.h"
#include "lrscriptenginemanagerintf.h" #include "lrglobal.h"
#include "lrpreparedpagesintf.h"
#include "lrpreviewreportwidget.h" #include "lrpreviewreportwidget.h"
#include "lrreportdesignwindowintrerface.h" #include "lrreportdesignwindowintrerface.h"
#include "lrpreparedpagesintf.h" #include "lrscriptenginemanagerintf.h"
class QPrinter; class QPrinter;
class QGraphicsScene; class QGraphicsScene;
@ -52,10 +52,12 @@ public:
int fromPage() const { return m_fromPage; } int fromPage() const { return m_fromPage; }
int toPage() const { return m_toPage; } int toPage() const { return m_toPage; }
QPrintDialog::PrintRange rangeType() const { return m_rangeType; } QPrintDialog::PrintRange rangeType() const { return m_rangeType; }
PrintRange(QAbstractPrintDialog::PrintRange rangeType=QPrintDialog::AllPages, int fromPage=0, int toPage=0); PrintRange(QAbstractPrintDialog::PrintRange rangeType = QPrintDialog::AllPages,
int fromPage = 0, int toPage = 0);
void setRangeType(QAbstractPrintDialog::PrintRange rangeType) { m_rangeType = rangeType; } void setRangeType(QAbstractPrintDialog::PrintRange rangeType) { m_rangeType = rangeType; }
void setFromPage(int fromPage) { m_fromPage = fromPage; } void setFromPage(int fromPage) { m_fromPage = fromPage; }
void setToPage(int toPage) { m_toPage = toPage; } void setToPage(int toPage) { m_toPage = toPage; }
private: private:
QPrintDialog::PrintRange m_rangeType; QPrintDialog::PrintRange m_rangeType;
int m_fromPage; int m_fromPage;
@ -64,9 +66,20 @@ private:
class LIMEREPORT_EXPORT ItemGeometry { class LIMEREPORT_EXPORT ItemGeometry {
public: public:
enum Type{Millimeters, Pixels}; enum Type {
ItemGeometry(qreal x, qreal y, qreal width, qreal height, Qt::Alignment anchor, Type type = Millimeters) Millimeters,
:m_x(x), m_y(y), m_width(width), m_height(height), m_type(type), m_anchor(anchor){} 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) { } ItemGeometry(): m_x(0), m_y(0), m_width(0), m_height(0), m_type(Millimeters) { }
qreal x() const; qreal x() const;
@ -98,8 +111,14 @@ private:
class LIMEREPORT_EXPORT WatermarkSetting { class LIMEREPORT_EXPORT WatermarkSetting {
public: public:
WatermarkSetting(const QString& text, const ItemGeometry& geometry, const QFont& font) 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)){} 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(): m_font(QFont()), m_opacity(50), m_geometry(ItemGeometry()) { }
QString text() const; QString text() const;
void setText(const QString& text); void setText(const QString& text);
@ -131,7 +150,6 @@ class ItemBuilder{
virtual ItemGeometry geometry() = 0; virtual ItemGeometry geometry() = 0;
}; };
class DataSourceManager; class DataSourceManager;
class ReportEnginePrivate; class ReportEnginePrivate;
class PageDesignIntf; class PageDesignIntf;
@ -147,8 +165,10 @@ class LIMEREPORT_EXPORT ReportEngine : public QObject{
friend class ReportDesignWidget; friend class ReportDesignWidget;
friend class PreviewReportWidget; friend class PreviewReportWidget;
friend class TranslationEditor; friend class TranslationEditor;
public: public:
static void setSettings(QSettings* value) { m_settings = value; } static void setSettings(QSettings* value) { m_settings = value; }
public: public:
explicit ReportEngine(QObject* parent = 0); explicit ReportEngine(QObject* parent = 0);
~ReportEngine(); ~ReportEngine();
@ -158,7 +178,8 @@ public:
void printToFile(const QString& fileName); void printToFile(const QString& fileName);
QGraphicsScene* createPreviewScene(QObject* parent = 0); QGraphicsScene* createPreviewScene(QObject* parent = 0);
bool printToPDF(const QString& fileName); 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(PreviewHints hints = PreviewBarsUserSetting);
void previewReport(QPrinter* printer, PreviewHints hints = PreviewBarsUserSetting); void previewReport(QPrinter* printer, PreviewHints hints = PreviewBarsUserSetting);
void designReport(); void designReport();
@ -234,14 +255,17 @@ signals:
void currentDefaultDesignerLanguageChanged(QLocale::Language); void currentDefaultDesignerLanguageChanged(QLocale::Language);
QLocale::Language getCurrentDefaultDesignerLanguage(); QLocale::Language getCurrentDefaultDesignerLanguage();
void externalPaint(const QString& objectName, QPainter* painter, const QStyleOptionGraphicsItem*); void externalPaint(const QString& objectName, QPainter* painter,
const QStyleOptionGraphicsItem*);
public slots: public slots:
void cancelRender(); void cancelRender();
void cancelPrinting(); void cancelPrinting();
protected: protected:
ReportEnginePrivate* const d_ptr; ReportEnginePrivate* const d_ptr;
ReportEngine(ReportEnginePrivate& dd, QObject* parent = 0); ReportEngine(ReportEnginePrivate& dd, QObject* parent = 0);
private: private:
Q_DECLARE_PRIVATE(ReportEngine) Q_DECLARE_PRIVATE(ReportEngine)
static QSettings* m_settings; static QSettings* m_settings;

View File

@ -54,8 +54,7 @@ namespace LimeReport{
#ifdef USE_QJSENGINE #ifdef USE_QJSENGINE
typedef QJSEngine ScriptEngineType; typedef QJSEngine ScriptEngineType;
typedef QJSValue ScriptValueType; typedef QJSValue ScriptValueType;
template <typename T> template <typename T> static inline QJSValue getJSValue(QJSEngine& e, T* p)
static inline QJSValue getJSValue(QJSEngine &e, T *p)
{ {
QJSValue res = e.newQObject(p); QJSValue res = e.newQObject(p);
QQmlEngine::setObjectOwnership(p, QQmlEngine::CppOwnership); QQmlEngine::setObjectOwnership(p, QQmlEngine::CppOwnership);
@ -71,14 +70,15 @@ public:
virtual ScriptEngineType* scriptEngine() = 0; virtual ScriptEngineType* scriptEngine() = 0;
#ifdef USE_QTSCRIPTENGINE #ifdef USE_QTSCRIPTENGINE
virtual bool addFunction(const QString& name, ScriptEngineType::FunctionSignature function, virtual bool addFunction(const QString& name, ScriptEngineType::FunctionSignature function,
const QString& category="", const QString& description="") = 0; const QString& category = "", const QString& description = "")
= 0;
#endif #endif
virtual bool addFunction(const QString& name, const QString& script, virtual bool addFunction(const QString& name, const QString& script,
const QString &category="", const QString &description="") = 0; const QString& category = "", const QString& description = "")
= 0;
virtual const QString& lastError() const = 0; virtual const QString& lastError() const = 0;
virtual ScriptValueType moveQObjectToScript(QObject* object, const QString objectName) = 0; virtual ScriptValueType moveQObjectToScript(QObject* object, const QString objectName) = 0;
virtual ~IScriptEngineManager() { } virtual ~IScriptEngineManager() { }
}; };
} // namespace LimeReport } // namespace LimeReport

View File

@ -28,6 +28,7 @@
* GNU General Public License for more details. * * GNU General Public License for more details. *
****************************************************************************/ ****************************************************************************/
#include "lrdataband.h" #include "lrdataband.h"
#include "lrdesignelementsfactory.h" #include "lrdesignelementsfactory.h"
#include "lrglobal.h" #include "lrglobal.h"
@ -37,52 +38,47 @@ const QString xmlTagFooter = "DataFooter";
namespace { namespace {
LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIntf* parent){ LimeReport::BaseDesignIntf* createBand(QObject* owner, LimeReport::BaseDesignIntf* parent)
{
return new LimeReport::DataBand(owner, parent); return new LimeReport::DataBand(owner, parent);
} }
LimeReport::BaseDesignIntf * createHeader(QObject* owner, LimeReport::BaseDesignIntf* parent){ LimeReport::BaseDesignIntf* createHeader(QObject* owner, LimeReport::BaseDesignIntf* parent)
{
return new LimeReport::DataHeaderBand(owner, parent); return new LimeReport::DataHeaderBand(owner, parent);
} }
LimeReport::BaseDesignIntf * createFooter(QObject* owner, LimeReport::BaseDesignIntf* parent){ LimeReport::BaseDesignIntf* createFooter(QObject* owner, LimeReport::BaseDesignIntf* parent)
{
return new LimeReport::DataFooterBand(owner, parent); return new LimeReport::DataFooterBand(owner, parent);
} }
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator( bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
xmlTag, xmlTag, LimeReport::ItemAttribs(QObject::tr("Data"), LimeReport::Const::bandTAG), createBand);
LimeReport::ItemAttribs(QObject::tr("Data"),LimeReport::Const::bandTAG), bool VARIABLE_IS_NOT_USED registredHeader
createBand = LimeReport::DesignElementsFactory::instance().registerCreator(
);
bool VARIABLE_IS_NOT_USED registredHeader = LimeReport::DesignElementsFactory::instance().registerCreator(
xmlTagHeader, xmlTagHeader,
LimeReport::ItemAttribs(QObject::tr("DataHeader"), LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("DataHeader"), LimeReport::Const::bandTAG),
createHeader createHeader);
); bool VARIABLE_IS_NOT_USED registredFooter
bool VARIABLE_IS_NOT_USED registredFooter = LimeReport::DesignElementsFactory::instance().registerCreator( = LimeReport::DesignElementsFactory::instance().registerCreator(
xmlTagFooter, xmlTagFooter,
LimeReport::ItemAttribs(QObject::tr("DataFooter"), LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("DataFooter"), LimeReport::Const::bandTAG),
createFooter createFooter);
);
} } // namespace
namespace LimeReport { namespace LimeReport {
DataBand::DataBand(QObject *owner, QGraphicsItem *parent) DataBand::DataBand(QObject* owner, QGraphicsItem* parent):
: DataBandDesignIntf(LimeReport::BandDesignIntf::Data,xmlTag,owner,parent) { DataBandDesignIntf(LimeReport::BandDesignIntf::Data, xmlTag, owner, parent)
{
setBandTypeText(tr("Data")); setBandTypeText(tr("Data"));
setFixedPos(false); setFixedPos(false);
setMarkerColor(bandColor()); setMarkerColor(bandColor());
} }
bool DataBand::isUnique() const bool DataBand::isUnique() const { return false; }
{
return false;
}
QColor DataBand::bandColor() const QColor DataBand::bandColor() const { return QColor(Qt::darkGreen); }
{
return QColor(Qt::darkGreen);
}
void DataBand::preparePopUpMenu(QMenu& menu) void DataBand::preparePopUpMenu(QMenu& menu)
{ {
@ -111,9 +107,6 @@ void DataBand::preparePopUpMenu(QMenu &menu)
currAction = menu.addAction(tr("Start new page")); currAction = menu.addAction(tr("Start new page"));
currAction->setCheckable(true); currAction->setCheckable(true);
currAction->setChecked(startNewPage()); currAction->setChecked(startNewPage());
} }
void DataBand::processPopUpAction(QAction* action) void DataBand::processPopUpAction(QAction* action)
@ -149,8 +142,8 @@ BaseDesignIntf *DataBand::createSameTypeItem(QObject *owner, QGraphicsItem *pare
return new DataBand(owner, parent); return new DataBand(owner, parent);
} }
DataHeaderBand::DataHeaderBand(QObject *owner, QGraphicsItem *parent) DataHeaderBand::DataHeaderBand(QObject* owner, QGraphicsItem* parent):
:BandDesignIntf(BandDesignIntf::DataHeader,xmlTagHeader,owner,parent) BandDesignIntf(BandDesignIntf::DataHeader, xmlTagHeader, owner, parent)
{ {
setBandTypeText(tr("DataHeader")); setBandTypeText(tr("DataHeader"));
setMarkerColor(bandColor()); setMarkerColor(bandColor());
@ -188,8 +181,8 @@ void DataHeaderBand::processPopUpAction(QAction *action)
} }
} }
DataFooterBand::DataFooterBand(QObject *owner, QGraphicsItem *parent) DataFooterBand::DataFooterBand(QObject* owner, QGraphicsItem* parent):
:BandDesignIntf(BandDesignIntf::DataFooter,xmlTagFooter,owner,parent) BandDesignIntf(BandDesignIntf::DataFooter, xmlTagFooter, owner, parent)
{ {
setBandTypeText(tr("DataFooter")); setBandTypeText(tr("DataFooter"));
setMarkerColor(bandColor()); setMarkerColor(bandColor());
@ -211,5 +204,4 @@ void DataFooterBand::processPopUpAction(QAction *action)
} }
} }
} } // namespace LimeReport

View File

@ -32,41 +32,46 @@
#include "lrbanddesignintf.h" #include "lrbanddesignintf.h"
#include "lrbasedesignintf.h" #include "lrbasedesignintf.h"
#include <QObject> #include <QObject>
namespace LimeReport { namespace LimeReport {
class DataBand : public DataBandDesignIntf class DataBand: public DataBandDesignIntf {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool keepSubdetailTogether READ tryToKeepTogether WRITE setTryToKeepTogether) Q_PROPERTY(bool keepSubdetailTogether READ tryToKeepTogether WRITE setTryToKeepTogether)
Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable) Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable)
Q_PROPERTY(bool keepFooterTogether READ keepFooterTogether WRITE setKeepFooterTogether) Q_PROPERTY(bool keepFooterTogether READ keepFooterTogether WRITE setKeepFooterTogether)
Q_PROPERTY(bool sliceLastRow READ sliceLastRow WRITE setSliceLastRow) Q_PROPERTY(bool sliceLastRow READ sliceLastRow WRITE setSliceLastRow)
Q_PROPERTY(int columnsCount READ columnsCount WRITE setColumnsCount) 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 startNewPage READ startNewPage WRITE setStartNewPage)
Q_PROPERTY(bool startFromNewPage READ startFromNewPage WRITE setStartFromNewPage) Q_PROPERTY(bool startFromNewPage READ startFromNewPage WRITE setStartFromNewPage)
Q_PROPERTY(QColor alternateBackgroundColor READ alternateBackgroundColor WRITE setAlternateBackgroundColor) Q_PROPERTY(QColor alternateBackgroundColor READ alternateBackgroundColor WRITE
Q_PROPERTY(bool useAlternateBackgroundColor READ useAlternateBackgroundColor WRITE setUseAlternateBackgroundColor) setAlternateBackgroundColor)
Q_PROPERTY(bool useAlternateBackgroundColor READ useAlternateBackgroundColor WRITE
setUseAlternateBackgroundColor)
public: public:
DataBand(QObject* owner = 0, QGraphicsItem* parent = 0); DataBand(QObject* owner = 0, QGraphicsItem* parent = 0);
bool isUnique() const; bool isUnique() const;
bool isData() const { return true; } bool isData() const { return true; }
protected: protected:
QColor bandColor() const; QColor bandColor() const;
void preparePopUpMenu(QMenu& menu); void preparePopUpMenu(QMenu& menu);
void processPopUpAction(QAction* action); void processPopUpAction(QAction* action);
private: 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_OBJECT
Q_PROPERTY(bool reprintOnEachPage READ reprintOnEachPage WRITE setReprintOnEachPage) Q_PROPERTY(bool reprintOnEachPage READ reprintOnEachPage WRITE setReprintOnEachPage)
Q_PROPERTY(int columnsCount READ columnsCount WRITE setColumnsCount) 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 printAlways READ printAlways WRITE setPrintAlways)
Q_PROPERTY(bool repeatOnEachRow READ repeatOnEachRow WRITE setRepeatOnEachRow) Q_PROPERTY(bool repeatOnEachRow READ repeatOnEachRow WRITE setRepeatOnEachRow)
public: public:
@ -74,35 +79,41 @@ public:
bool isUnique() const { return false; } bool isUnique() const { return false; }
bool isHeader() const { return true; } bool isHeader() const { return true; }
QColor bandColor() const { return QColor(Qt::darkGreen); } QColor bandColor() const { return QColor(Qt::darkGreen); }
protected: protected:
void preparePopUpMenu(QMenu& menu); void preparePopUpMenu(QMenu& menu);
void processPopUpAction(QAction* action); void processPopUpAction(QAction* action);
private: private:
BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0){ BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0)
{
return new DataHeaderBand(owner, parent); return new DataHeaderBand(owner, parent);
} }
}; };
class DataFooterBand : public BandDesignIntf class DataFooterBand: public BandDesignIntf {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY(int columnsCount READ columnsCount WRITE setColumnsCount) Q_PROPERTY(int columnsCount READ columnsCount WRITE setColumnsCount)
Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable) 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) Q_PROPERTY(bool printAlways READ printAlways WRITE setPrintAlways)
public: public:
DataFooterBand(QObject* owner = 0, QGraphicsItem* parent = 0); DataFooterBand(QObject* owner = 0, QGraphicsItem* parent = 0);
bool isUnique() const { return false; } bool isUnique() const { return false; }
bool isFooter() const { return true; } bool isFooter() const { return true; }
QColor bandColor() const { return QColor(Qt::darkGreen); } QColor bandColor() const { return QColor(Qt::darkGreen); }
protected: protected:
void preparePopUpMenu(QMenu& menu); void preparePopUpMenu(QMenu& menu);
void processPopUpAction(QAction* action); void processPopUpAction(QAction* action);
private: private:
BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0){ BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0)
{
return new DataFooterBand(owner, parent); return new DataFooterBand(owner, parent);
} }
}; };
} } // namespace LimeReport
#endif // LRDATABAND_H #endif // LRDATABAND_H

View File

@ -28,51 +28,53 @@
* GNU General Public License for more details. * * GNU General Public License for more details. *
****************************************************************************/ ****************************************************************************/
#include "lrgroupbands.h" #include "lrgroupbands.h"
#include "lrglobal.h"
#include "lrdatasourcemanager.h" #include "lrdatasourcemanager.h"
#include "lrglobal.h"
const QString xmlTagHeader = QLatin1String("GroupHeader"); const QString xmlTagHeader = QLatin1String("GroupHeader");
const QString xmlTagFooter = QLatin1String("GroupFooter"); const QString xmlTagFooter = QLatin1String("GroupFooter");
namespace { namespace {
LimeReport::BaseDesignIntf* createHeader(QObject* owner, LimeReport::BaseDesignIntf* parent){ LimeReport::BaseDesignIntf* createHeader(QObject* owner, LimeReport::BaseDesignIntf* parent)
{
return new LimeReport::GroupBandHeader(owner, 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, xmlTagHeader,
LimeReport::ItemAttribs(QObject::tr("GroupHeader"), LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("GroupHeader"), LimeReport::Const::bandTAG),
createHeader createHeader);
);
LimeReport::BaseDesignIntf * createFooter(QObject* owner, LimeReport::BaseDesignIntf* parent){ LimeReport::BaseDesignIntf* createFooter(QObject* owner, LimeReport::BaseDesignIntf* parent)
{
return new LimeReport::GroupBandFooter(owner, parent); 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, xmlTagFooter,
LimeReport::ItemAttribs(QObject::tr("GroupFooter"), LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("GroupFooter"), LimeReport::Const::bandTAG),
createFooter createFooter);
);
} } // namespace
namespace LimeReport { namespace LimeReport {
GroupBandHeader::GroupBandHeader(QObject *owner, QGraphicsItem *parent) GroupBandHeader::GroupBandHeader(QObject* owner, QGraphicsItem* parent):
: BandDesignIntf(BandDesignIntf::GroupHeader, xmlTagHeader, owner,parent), BandDesignIntf(BandDesignIntf::GroupHeader, xmlTagHeader, owner, parent),
m_groupFiledName(""), m_groupStarted(false), m_resetPageNumber(false) m_groupFiledName(""),
m_groupStarted(false),
m_resetPageNumber(false)
{ {
setBandTypeText(tr("GroupHeader")); setBandTypeText(tr("GroupHeader"));
setFixedPos(false); setFixedPos(false);
setMarkerColor(bandColor()); setMarkerColor(bandColor());
} }
bool GroupBandHeader::isUnique() const bool GroupBandHeader::isUnique() const { return false; }
{
return false;
}
// bool GroupBandHeader::tryToKeepTogether() // bool GroupBandHeader::tryToKeepTogether()
//{ //{
@ -98,34 +100,28 @@ void GroupBandHeader::startGroup(DataSourceManager* dataManager)
m_groupFieldValue = ds->data(m_groupFiledName); 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); if (!parentBand)
} return "";
QString GroupBandHeader::findDataSourceName(BandDesignIntf* parentBand){
if (!parentBand) return "";
if (!parentBand->datasourceName().isEmpty()) if (!parentBand->datasourceName().isEmpty())
return parentBand->datasourceName(); return parentBand->datasourceName();
else else
return findDataSourceName(parentBand->parentBand()); 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; QString result = m_condition;
if (!m_condition.isEmpty()) { if (!m_condition.isEmpty()) {
result = expandUserVariables(result, FirstPass, NoEscapeSymbols, dataManager); result = expandUserVariables(result, FirstPass, NoEscapeSymbols, dataManager);
@ -137,7 +133,8 @@ QString GroupBandHeader::calcCondition(DataSourceManager* dataManager){
bool GroupBandHeader::isNeedToClose(DataSourceManager* dataManager) bool GroupBandHeader::isNeedToClose(DataSourceManager* dataManager)
{ {
if (!m_groupStarted) return false; if (!m_groupStarted)
return false;
if ((m_groupFiledName.isNull() || m_groupFiledName.isEmpty()) && condition().isEmpty()) { if ((m_groupFiledName.isNull() || m_groupFiledName.isEmpty()) && condition().isEmpty()) {
dataManager->putError(tr("Group field not found")); dataManager->putError(tr("Group field not found"));
return false; return false;
@ -150,8 +147,10 @@ bool GroupBandHeader::isNeedToClose(DataSourceManager* dataManager)
if (dataManager->containsDatasource(datasourceName)) { if (dataManager->containsDatasource(datasourceName)) {
IDataSource* ds = dataManager->dataSource(datasourceName); IDataSource* ds = dataManager->dataSource(datasourceName);
if (ds) { if (ds) {
if (ds->data(m_groupFiledName).isNull() && m_groupFieldValue.isNull()) return false; if (ds->data(m_groupFiledName).isNull() && m_groupFieldValue.isNull())
if (!ds->data(m_groupFiledName).isValid()) return false; return false;
if (!ds->data(m_groupFiledName).isValid())
return false;
return ds->data(m_groupFiledName) != m_groupFieldValue; return ds->data(m_groupFiledName) != m_groupFieldValue;
} }
} else { } else {
@ -174,48 +173,33 @@ void GroupBandHeader::closeGroup()
m_groupStarted = false; m_groupStarted = false;
} }
int GroupBandHeader::index() int GroupBandHeader::index() { return bandIndex(); }
{
return bandIndex();
}
bool GroupBandHeader::startNewPage() const bool GroupBandHeader::startNewPage() const { return BandDesignIntf::startNewPage(); }
{
return BandDesignIntf::startNewPage();
}
void GroupBandHeader::setStartNewPage(bool startNewPage) void GroupBandHeader::setStartNewPage(bool startNewPage)
{ {
BandDesignIntf::setStartNewPage(startNewPage); BandDesignIntf::setStartNewPage(startNewPage);
} }
bool GroupBandHeader::resetPageNumber() const bool GroupBandHeader::resetPageNumber() const { return m_resetPageNumber; }
{
return m_resetPageNumber;
}
void GroupBandHeader::setResetPageNumber(bool resetPageNumber) void GroupBandHeader::setResetPageNumber(bool resetPageNumber)
{ {
m_resetPageNumber = resetPageNumber; m_resetPageNumber = resetPageNumber;
} }
GroupBandFooter::GroupBandFooter(QObject *owner, QGraphicsItem *parent) GroupBandFooter::GroupBandFooter(QObject* owner, QGraphicsItem* parent):
:BandDesignIntf(BandDesignIntf::GroupFooter, xmlTagFooter, owner,parent) BandDesignIntf(BandDesignIntf::GroupFooter, xmlTagFooter, owner, parent)
{ {
setBandTypeText(tr("GroupFooter")); setBandTypeText(tr("GroupFooter"));
setFixedPos(false); setFixedPos(false);
setMarkerColor(bandColor()); setMarkerColor(bandColor());
} }
bool GroupBandFooter::isUnique() const bool GroupBandFooter::isUnique() const { return false; }
{
return false;
}
QColor GroupBandFooter::bandColor() const QColor GroupBandFooter::bandColor() const { return QColor(Qt::darkBlue); }
{
return QColor(Qt::darkBlue);
}
BaseDesignIntf* GroupBandFooter::createSameTypeItem(QObject* owner, QGraphicsItem* parent) BaseDesignIntf* GroupBandFooter::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
{ {

View File

@ -60,6 +60,7 @@ public:
bool isGroupHeader() const { return true; } bool isGroupHeader() const { return true; }
QString condition() const; QString condition() const;
void setCondition(const QString& condition); void setCondition(const QString& condition);
private: private:
virtual BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0); virtual BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0);
void startGroup(DataSourceManager* dataManager); void startGroup(DataSourceManager* dataManager);
@ -69,6 +70,7 @@ private:
int index(); int index();
QString findDataSourceName(BandDesignIntf* parentBand); QString findDataSourceName(BandDesignIntf* parentBand);
QString calcCondition(DataSourceManager* dataManager); QString calcCondition(DataSourceManager* dataManager);
private: private:
QVariant m_groupFieldValue; QVariant m_groupFieldValue;
QString m_groupFiledName; QString m_groupFiledName;
@ -86,6 +88,7 @@ public:
virtual bool isUnique() const; virtual bool isUnique() const;
QColor bandColor() const; QColor bandColor() const;
virtual bool isFooter() const { return true; } virtual bool isFooter() const { return true; }
private: private:
virtual BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0); virtual BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0);
}; };

View File

@ -28,6 +28,7 @@
* GNU General Public License for more details. * * GNU General Public License for more details. *
****************************************************************************/ ****************************************************************************/
#include "lrpagefooter.h" #include "lrpagefooter.h"
#include "lrdesignelementsfactory.h" #include "lrdesignelementsfactory.h"
#include "lrglobal.h" #include "lrglobal.h"
#include "lrpagedesignintf.h" #include "lrpagedesignintf.h"
@ -35,22 +36,23 @@
const QString xmlTag = "PageFooter"; const QString xmlTag = "PageFooter";
namespace { namespace {
LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIntf* parent){ LimeReport::BaseDesignIntf* createBand(QObject* owner, LimeReport::BaseDesignIntf* parent)
{
return new LimeReport::PageFooter(owner, parent); return new LimeReport::PageFooter(owner, parent);
} }
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator( bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
xmlTag, xmlTag, LimeReport::ItemAttribs(QObject::tr("Page Footer"), LimeReport::Const::bandTAG),
LimeReport::ItemAttribs(QObject::tr("Page Footer"),LimeReport::Const::bandTAG), createBand);
createBand } // namespace
);
}
namespace LimeReport { namespace LimeReport {
PageFooter::PageFooter(QObject *owner, QGraphicsItem *parent) PageFooter::PageFooter(QObject* owner, QGraphicsItem* parent):
: BandDesignIntf(LimeReport::BandDesignIntf::PageFooter,xmlTag,owner,parent), BandDesignIntf(LimeReport::BandDesignIntf::PageFooter, xmlTag, owner, parent),
m_printOnFirstPage(true), m_printOnLastPage(true), m_removeGap(false) m_printOnFirstPage(true),
m_printOnLastPage(true),
m_removeGap(false)
{ {
setBandTypeText(tr("Page Footer")); setBandTypeText(tr("Page Footer"));
setMarkerColor(bandColor()); setMarkerColor(bandColor());
@ -62,10 +64,7 @@ BaseDesignIntf *PageFooter::createSameTypeItem(QObject *owner, QGraphicsItem *pa
return new PageFooter(owner, parent); return new PageFooter(owner, parent);
} }
QColor PageFooter::bandColor() const QColor PageFooter::bandColor() const { return QColor(246, 120, 12); }
{
return QColor(246,120,12);
}
void PageFooter::preparePopUpMenu(QMenu& menu) void PageFooter::preparePopUpMenu(QMenu& menu)
{ {
@ -76,7 +75,6 @@ void PageFooter::preparePopUpMenu(QMenu &menu)
action = menu.addAction(tr("Print on last page")); action = menu.addAction(tr("Print on last page"));
action->setCheckable(true); action->setCheckable(true);
action->setChecked(printOnLastPage()); action->setChecked(printOnLastPage());
} }
void PageFooter::processPopUpAction(QAction* action) void PageFooter::processPopUpAction(QAction* action)
@ -90,20 +88,11 @@ void PageFooter::processPopUpAction(QAction *action)
BandDesignIntf::processPopUpAction(action); BandDesignIntf::processPopUpAction(action);
} }
bool PageFooter::removeGap() const bool PageFooter::removeGap() const { return m_removeGap; }
{
return m_removeGap;
}
void PageFooter::setRemoveGap(bool removeGap) void PageFooter::setRemoveGap(bool removeGap) { m_removeGap = removeGap; }
{
m_removeGap = removeGap;
}
bool PageFooter::printOnFirstPage() const bool PageFooter::printOnFirstPage() const { return m_printOnFirstPage; }
{
return m_printOnFirstPage;
}
void PageFooter::setPrintOnFirstPage(bool printOnFirstPage) void PageFooter::setPrintOnFirstPage(bool printOnFirstPage)
{ {
@ -115,10 +104,7 @@ void PageFooter::setPrintOnFirstPage(bool printOnFirstPage)
} }
} }
bool PageFooter::printOnLastPage() const bool PageFooter::printOnLastPage() const { return m_printOnLastPage; }
{
return m_printOnLastPage;
}
void PageFooter::setPrintOnLastPage(bool printOnLastPage) void PageFooter::setPrintOnLastPage(bool printOnLastPage)
{ {

View File

@ -32,11 +32,11 @@
#include "lrbanddesignintf.h" #include "lrbanddesignintf.h"
#include "lrbasedesignintf.h" #include "lrbasedesignintf.h"
#include <QObject> #include <QObject>
namespace LimeReport { namespace LimeReport {
class PageFooter : public BandDesignIntf class PageFooter: public BandDesignIntf {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool printOnFirstPage READ printOnFirstPage WRITE setPrintOnFirstPage) Q_PROPERTY(bool printOnFirstPage READ printOnFirstPage WRITE setPrintOnFirstPage)
Q_PROPERTY(bool printOnLastPage READ printOnLastPage WRITE setPrintOnLastPage) Q_PROPERTY(bool printOnLastPage READ printOnLastPage WRITE setPrintOnLastPage)
@ -56,11 +56,12 @@ protected:
QColor bandColor() const; QColor bandColor() const;
void preparePopUpMenu(QMenu& menu); void preparePopUpMenu(QMenu& menu);
void processPopUpAction(QAction* action); void processPopUpAction(QAction* action);
private: private:
bool m_printOnFirstPage; bool m_printOnFirstPage;
bool m_printOnLastPage; bool m_printOnLastPage;
bool m_removeGap; bool m_removeGap;
}; };
} } // namespace LimeReport
#endif // LRPAGEFOOTER_H #endif // LRPAGEFOOTER_H

View File

@ -28,32 +28,34 @@
* GNU General Public License for more details. * * GNU General Public License for more details. *
****************************************************************************/ ****************************************************************************/
#include "lrpageheader.h" #include "lrpageheader.h"
#include "lrdesignelementsfactory.h"
#include "lrbanddesignintf.h" #include "lrbanddesignintf.h"
#include "lrbasedesignintf.h" #include "lrbasedesignintf.h"
#include "lrpageitemdesignintf.h" #include "lrdesignelementsfactory.h"
#include "lrglobal.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){ LimeReport::BaseDesignIntf* createBand(QObject* owner, LimeReport::BaseDesignIntf* parent)
{
return new LimeReport::PageHeader(owner, parent); return new LimeReport::PageHeader(owner, parent);
} }
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator( bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
xmlTag, xmlTag, LimeReport::ItemAttribs(QObject::tr("Page Header"), LimeReport::Const::bandTAG),
LimeReport::ItemAttribs(QObject::tr("Page Header"),LimeReport::Const::bandTAG), createBand);
createBand } // namespace
);
}
namespace LimeReport { namespace LimeReport {
PageHeader::PageHeader(QObject* owner, QGraphicsItem *parent) PageHeader::PageHeader(QObject* owner, QGraphicsItem* parent):
: BandDesignIntf(LimeReport::BandDesignIntf::PageHeader,xmlTag,owner,parent), BandDesignIntf(LimeReport::BandDesignIntf::PageHeader, xmlTag, owner, parent),
m_printOnFirstPage(true), m_printOnLastPage(true) { m_printOnFirstPage(true),
m_printOnLastPage(true)
{
setBandTypeText(tr("Page Header")); setBandTypeText(tr("Page Header"));
setMarkerColor(bandColor()); setMarkerColor(bandColor());
} }
@ -63,29 +65,17 @@ BaseDesignIntf *PageHeader::createSameTypeItem(QObject *owner, QGraphicsItem *pa
return new PageHeader(owner, parent); return new PageHeader(owner, parent);
} }
QColor PageHeader::bandColor() const QColor PageHeader::bandColor() const { return QColor(246, 120, 12); }
{
return QColor(246,120,12);
}
bool PageHeader::printOnLastPage() const bool PageHeader::printOnLastPage() const { return m_printOnLastPage; }
{
return m_printOnLastPage;
}
void PageHeader::setPrintOnLastPage(bool printOnLastPage) void PageHeader::setPrintOnLastPage(bool printOnLastPage) { m_printOnLastPage = printOnLastPage; }
{
m_printOnLastPage = printOnLastPage;
}
bool PageHeader::printOnFirstPage() const bool PageHeader::printOnFirstPage() const { return m_printOnFirstPage; }
{
return m_printOnFirstPage;
}
void PageHeader::setPrintOnFirstPage(bool printOnFirstPage) void PageHeader::setPrintOnFirstPage(bool printOnFirstPage)
{ {
m_printOnFirstPage = printOnFirstPage; m_printOnFirstPage = printOnFirstPage;
} }
} } // namespace LimeReport

View File

@ -30,13 +30,13 @@
#ifndef LRPAGEHEADER_H #ifndef LRPAGEHEADER_H
#define LRPAGEHEADER_H #define LRPAGEHEADER_H
#include <QObject>
#include "lrbanddesignintf.h" #include "lrbanddesignintf.h"
#include "lrbasedesignintf.h" #include "lrbasedesignintf.h"
#include <QObject>
namespace LimeReport { namespace LimeReport {
class PageHeader : public LimeReport::BandDesignIntf class PageHeader: public LimeReport::BandDesignIntf {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool printOnFirstPage READ printOnFirstPage WRITE setPrintOnFirstPage) Q_PROPERTY(bool printOnFirstPage READ printOnFirstPage WRITE setPrintOnFirstPage)
Q_PROPERTY(bool printOnLastPage READ printOnLastPage WRITE setPrintOnLastPage) Q_PROPERTY(bool printOnLastPage READ printOnLastPage WRITE setPrintOnLastPage)
@ -47,12 +47,14 @@ public:
bool printOnLastPage() const; bool printOnLastPage() const;
void setPrintOnLastPage(bool printOnLastPage); void setPrintOnLastPage(bool printOnLastPage);
bool isHeader() const { return true; } bool isHeader() const { return true; }
protected: protected:
virtual BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0); virtual BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0);
QColor bandColor() const; QColor bandColor() const;
private: private:
bool m_printOnFirstPage; bool m_printOnFirstPage;
bool m_printOnLastPage; bool m_printOnLastPage;
}; };
} } // namespace LimeReport
#endif // LRPAGEHEADER_H #endif // LRPAGEHEADER_H

View File

@ -28,6 +28,7 @@
* GNU General Public License for more details. * * GNU General Public License for more details. *
****************************************************************************/ ****************************************************************************/
#include "lrreportfooter.h" #include "lrreportfooter.h"
#include "lrdesignelementsfactory.h" #include "lrdesignelementsfactory.h"
#include "lrglobal.h" #include "lrglobal.h"
@ -35,20 +36,20 @@ const QString xmlTag ="ReportFooter";
namespace { namespace {
LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIntf* parent){ LimeReport::BaseDesignIntf* createBand(QObject* owner, LimeReport::BaseDesignIntf* parent)
{
return new LimeReport::ReportFooter(owner, parent); return new LimeReport::ReportFooter(owner, parent);
} }
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator( bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
xmlTag, xmlTag, LimeReport::ItemAttribs(QObject::tr("Report Footer"), LimeReport::Const::bandTAG),
LimeReport::ItemAttribs(QObject::tr("Report Footer"),LimeReport::Const::bandTAG), createBand);
createBand } // namespace
);
}
namespace LimeReport { namespace LimeReport {
ReportFooter::ReportFooter(QObject *owner, QGraphicsItem *parent) ReportFooter::ReportFooter(QObject* owner, QGraphicsItem* parent):
: BandDesignIntf(LimeReport::BandDesignIntf::ReportFooter,xmlTag,owner,parent) { BandDesignIntf(LimeReport::BandDesignIntf::ReportFooter, xmlTag, owner, parent)
{
setBandTypeText(tr("Report Footer")); setBandTypeText(tr("Report Footer"));
setMarkerColor(bandColor()); setMarkerColor(bandColor());
} }
@ -58,14 +59,8 @@ BaseDesignIntf *ReportFooter::createSameTypeItem(QObject *owner, QGraphicsItem *
return new ReportFooter(owner, parent); return new ReportFooter(owner, parent);
} }
QColor ReportFooter::bandColor() const QColor ReportFooter::bandColor() const { return QColor(152, 69, 167); }
{
return QColor(152,69,167);
}
bool ReportFooter::isFooter() const bool ReportFooter::isFooter() const { return true; }
{
return true;
}
} } // namespace LimeReport

View File

@ -30,22 +30,23 @@
#ifndef LRREPORTFOOTER_H #ifndef LRREPORTFOOTER_H
#define LRREPORTFOOTER_H #define LRREPORTFOOTER_H
#include <QObject>
#include "lrbanddesignintf.h" #include "lrbanddesignintf.h"
#include "lrbasedesignintf.h" #include "lrbasedesignintf.h"
#include <QObject>
namespace LimeReport { namespace LimeReport {
class ReportFooter : public BandDesignIntf class ReportFooter: public BandDesignIntf {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY(int maxScalePercent READ maxScalePercent WRITE setMaxScalePercent) Q_PROPERTY(int maxScalePercent READ maxScalePercent WRITE setMaxScalePercent)
Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable) Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable)
public: public:
ReportFooter(QObject* owner = 0, QGraphicsItem* parent = 0); ReportFooter(QObject* owner = 0, QGraphicsItem* parent = 0);
virtual BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0); virtual BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0);
protected: protected:
QColor bandColor() const; QColor bandColor() const;
bool isFooter() const; bool isFooter() const;
}; };
} } // namespace LimeReport
#endif // LRREPORTFOOTER_H #endif // LRREPORTFOOTER_H

View File

@ -28,25 +28,27 @@
* GNU General Public License for more details. * * GNU General Public License for more details. *
****************************************************************************/ ****************************************************************************/
#include "lrreportheader.h" #include "lrreportheader.h"
#include "lrdesignelementsfactory.h" #include "lrdesignelementsfactory.h"
#include "lrglobal.h" #include "lrglobal.h"
const QString xmlTag = "ReportHeader"; const QString xmlTag = "ReportHeader";
namespace { namespace {
LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIntf* parent){ LimeReport::BaseDesignIntf* createBand(QObject* owner, LimeReport::BaseDesignIntf* parent)
{
return new LimeReport::ReportHeader(owner, parent); return new LimeReport::ReportHeader(owner, parent);
} }
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator( bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
xmlTag, xmlTag, LimeReport::ItemAttribs(QObject::tr("Report Header"), LimeReport::Const::bandTAG),
LimeReport::ItemAttribs(QObject::tr("Report Header"),LimeReport::Const::bandTAG), createBand);
createBand } // namespace
);
}
namespace LimeReport { namespace LimeReport {
ReportHeader::ReportHeader(QObject *owner, QGraphicsItem *parent) ReportHeader::ReportHeader(QObject* owner, QGraphicsItem* parent):
: BandDesignIntf(LimeReport::BandDesignIntf::ReportHeader,xmlTag,owner,parent), m_printBeforePageHeader(false) { BandDesignIntf(LimeReport::BandDesignIntf::ReportHeader, xmlTag, owner, parent),
m_printBeforePageHeader(false)
{
setBandTypeText(tr("Report Header")); setBandTypeText(tr("Report Header"));
setMarkerColor(bandColor()); setMarkerColor(bandColor());
} }
@ -55,15 +57,9 @@ BaseDesignIntf *ReportHeader::createSameTypeItem(QObject *owner, QGraphicsItem *
return new ReportHeader(owner, parent); return new ReportHeader(owner, parent);
} }
QColor ReportHeader::bandColor() const QColor ReportHeader::bandColor() const { return QColor(152, 69, 167); }
{
return QColor(152,69,167);
}
bool ReportHeader::printBeforePageHeader() const bool ReportHeader::printBeforePageHeader() const { return m_printBeforePageHeader; }
{
return m_printBeforePageHeader;
}
void ReportHeader::setPrintBeforePageHeader(bool printBeforePageHeader) void ReportHeader::setPrintBeforePageHeader(bool printBeforePageHeader)
{ {
@ -73,5 +69,4 @@ void ReportHeader::setPrintBeforePageHeader(bool printBeforePageHeader)
} }
} }
} } // namespace LimeReport

View File

@ -30,13 +30,13 @@
#ifndef LRREPORTHEADER_H #ifndef LRREPORTHEADER_H
#define LRREPORTHEADER_H #define LRREPORTHEADER_H
#include <QObject>
#include "lrbanddesignintf.h" #include "lrbanddesignintf.h"
#include "lrbasedesignintf.h" #include "lrbasedesignintf.h"
#include <QObject>
namespace LimeReport { namespace LimeReport {
class ReportHeader : public LimeReport::BandDesignIntf class ReportHeader: public LimeReport::BandDesignIntf {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable) Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable)
Q_PROPERTY(bool printBeforePageHeader READ printBeforePageHeader WRITE setPrintBeforePageHeader) Q_PROPERTY(bool printBeforePageHeader READ printBeforePageHeader WRITE setPrintBeforePageHeader)
@ -46,9 +46,10 @@ public:
bool printBeforePageHeader() const; bool printBeforePageHeader() const;
void setPrintBeforePageHeader(bool printBeforePageHeader); void setPrintBeforePageHeader(bool printBeforePageHeader);
bool isHeader() const { return true; } bool isHeader() const { return true; }
protected: protected:
QColor bandColor() const; QColor bandColor() const;
bool m_printBeforePageHeader; bool m_printBeforePageHeader;
}; };
} } // namespace LimeReport
#endif // LRREPORTHEADER_H #endif // LRREPORTHEADER_H

View File

@ -28,10 +28,10 @@
* GNU General Public License for more details. * * GNU General Public License for more details. *
****************************************************************************/ ****************************************************************************/
#include "lrsubdetailband.h" #include "lrsubdetailband.h"
#include "lrdesignelementsfactory.h" #include "lrdesignelementsfactory.h"
#include "lrglobal.h" #include "lrglobal.h"
const QString xmlTagBand = QLatin1String("SubDetail"); const QString xmlTagBand = QLatin1String("SubDetail");
const QString xmlTagHeader = QLatin1String("SubDetailHeader"); const QString xmlTagHeader = QLatin1String("SubDetailHeader");
const QString xmlTagFooter = QLatin1String("SubDetailFooter"); const QString xmlTagFooter = QLatin1String("SubDetailFooter");
@ -39,35 +39,36 @@ const QColor BAND_COLOR = Qt::red;
namespace { namespace {
LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIntf* parent){ LimeReport::BaseDesignIntf* createBand(QObject* owner, LimeReport::BaseDesignIntf* parent)
{
return new LimeReport::SubDetailBand(owner, parent); return new LimeReport::SubDetailBand(owner, parent);
} }
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator( bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
xmlTagBand, xmlTagBand, LimeReport::ItemAttribs(QObject::tr("SubDetail"), LimeReport::Const::bandTAG),
LimeReport::ItemAttribs(QObject::tr("SubDetail"),LimeReport::Const::bandTAG), createBand);
createBand
);
LimeReport::BaseDesignIntf * createHeader(QObject* owner, LimeReport::BaseDesignIntf* parent){ LimeReport::BaseDesignIntf* createHeader(QObject* owner, LimeReport::BaseDesignIntf* parent)
{
return new LimeReport::SubDetailHeaderBand(owner, 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, xmlTagHeader,
LimeReport::ItemAttribs(QObject::tr("SubDetailHeader"), LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("SubDetailHeader"), LimeReport::Const::bandTAG),
createHeader createHeader);
);
LimeReport::BaseDesignIntf * createFooter(QObject* owner, LimeReport::BaseDesignIntf* parent){ LimeReport::BaseDesignIntf* createFooter(QObject* owner, LimeReport::BaseDesignIntf* parent)
{
return new LimeReport::SubDetailFooterBand(owner, parent); 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, xmlTagFooter,
LimeReport::ItemAttribs(QObject::tr("SubDetailFooter"), LimeReport::Const::bandTAG), LimeReport::ItemAttribs(QObject::tr("SubDetailFooter"), LimeReport::Const::bandTAG),
createFooter createFooter);
);
} // namespace } // namespace
@ -75,8 +76,8 @@ namespace LimeReport{
// SubDetailBand // SubDetailBand
SubDetailBand::SubDetailBand(QObject *owner, QGraphicsItem *parent) SubDetailBand::SubDetailBand(QObject* owner, QGraphicsItem* parent):
: DataBandDesignIntf(BandDesignIntf::SubDetailBand, xmlTagBand, owner,parent) DataBandDesignIntf(BandDesignIntf::SubDetailBand, xmlTagBand, owner, parent)
{ {
setBandTypeText(tr("SubDetail")); setBandTypeText(tr("SubDetail"));
setFixedPos(false); setFixedPos(false);
@ -98,29 +99,20 @@ BaseDesignIntf *SubDetailBand::createSameTypeItem(QObject *owner, QGraphicsItem
return new SubDetailBand(owner, parent); return new SubDetailBand(owner, parent);
} }
QColor SubDetailBand::bandColor() const QColor SubDetailBand::bandColor() const { return BAND_COLOR; }
{
return BAND_COLOR;
}
// SubDetailHeaderBand // SubDetailHeaderBand
SubDetailHeaderBand::SubDetailHeaderBand(QObject *owner, QGraphicsItem *parent) SubDetailHeaderBand::SubDetailHeaderBand(QObject* owner, QGraphicsItem* parent):
:BandDesignIntf(BandDesignIntf::SubDetailHeader,xmlTagHeader,owner,parent) BandDesignIntf(BandDesignIntf::SubDetailHeader, xmlTagHeader, owner, parent)
{ {
setBandTypeText(tr("SubDetailHeader")); setBandTypeText(tr("SubDetailHeader"));
setMarkerColor(bandColor()); setMarkerColor(bandColor());
} }
bool SubDetailHeaderBand::isUnique() const bool SubDetailHeaderBand::isUnique() const { return false; }
{
return false;
}
QColor SubDetailHeaderBand::bandColor() const QColor SubDetailHeaderBand::bandColor() const { return BAND_COLOR; }
{
return BAND_COLOR;
}
BaseDesignIntf* SubDetailHeaderBand::createSameTypeItem(QObject* owner, QGraphicsItem* parent) BaseDesignIntf* SubDetailHeaderBand::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
{ {
@ -129,26 +121,19 @@ BaseDesignIntf *SubDetailHeaderBand::createSameTypeItem(QObject *owner, QGraphic
// SubDetailFooterBand // SubDetailFooterBand
SubDetailFooterBand::SubDetailFooterBand(QObject *owner, QGraphicsItem *parent) SubDetailFooterBand::SubDetailFooterBand(QObject* owner, QGraphicsItem* parent):
: BandDesignIntf(BandDesignIntf::SubDetailFooter,xmlTagFooter,owner,parent) BandDesignIntf(BandDesignIntf::SubDetailFooter, xmlTagFooter, owner, parent)
{ {
setMarkerColor(bandColor()); setMarkerColor(bandColor());
} }
bool SubDetailFooterBand::isUnique() const bool SubDetailFooterBand::isUnique() const { return false; }
{
return false;
}
QColor SubDetailFooterBand::bandColor() const QColor SubDetailFooterBand::bandColor() const { return BAND_COLOR; }
{
return BAND_COLOR;
}
BaseDesignIntf* SubDetailFooterBand::createSameTypeItem(QObject* owner, QGraphicsItem* parent) BaseDesignIntf* SubDetailFooterBand::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
{ {
return new SubDetailFooterBand(owner, parent); return new SubDetailFooterBand(owner, parent);
} }
} // namespace LimeReport
}

View File

@ -35,62 +35,71 @@
namespace LimeReport { namespace LimeReport {
class SubDetailBand : public DataBandDesignIntf class SubDetailBand: public DataBandDesignIntf {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable) Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable)
Q_PROPERTY(int columnsCount READ columnsCount WRITE setColumnsCount) 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(bool keepFooterTogether READ keepFooterTogether WRITE setKeepFooterTogether)
Q_PROPERTY(QColor alternateBackgroundColor READ alternateBackgroundColor WRITE setAlternateBackgroundColor) Q_PROPERTY(QColor alternateBackgroundColor READ alternateBackgroundColor WRITE
Q_PROPERTY(bool useAlternateBackgroundColor READ useAlternateBackgroundColor WRITE setUseAlternateBackgroundColor) setAlternateBackgroundColor)
Q_PROPERTY(bool useAlternateBackgroundColor READ useAlternateBackgroundColor WRITE
setUseAlternateBackgroundColor)
public: public:
SubDetailBand(QObject* owner = 0, QGraphicsItem* parent = 0); SubDetailBand(QObject* owner = 0, QGraphicsItem* parent = 0);
bool isUnique() const { return false; } bool isUnique() const { return false; }
int bandNestingLevel() { return 1; } int bandNestingLevel() { return 1; }
bool isHasHeader() const; bool isHasHeader() const;
bool isHasFooter() const; bool isHasFooter() const;
private: private:
virtual BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0); virtual BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0);
protected: protected:
virtual QColor bandColor() const; virtual QColor bandColor() const;
}; };
class SubDetailHeaderBand : public BandDesignIntf class SubDetailHeaderBand: public BandDesignIntf {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY(int columnsCount READ columnsCount WRITE setColumnsCount) 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 printAlways READ printAlways WRITE setPrintAlways)
public: public:
SubDetailHeaderBand(QObject* owner = 0, QGraphicsItem* parent = 0); SubDetailHeaderBand(QObject* owner = 0, QGraphicsItem* parent = 0);
bool isUnique() const; bool isUnique() const;
bool isHeader() const { return true; } bool isHeader() const { return true; }
int bandNestingLevel() { return 1; } int bandNestingLevel() { return 1; }
protected: protected:
QColor bandColor() const; QColor bandColor() const;
private: 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_OBJECT
Q_PROPERTY(int columnsCount READ columnsCount WRITE setColumnsCount) Q_PROPERTY(int columnsCount READ columnsCount WRITE setColumnsCount)
Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable) 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) Q_PROPERTY(bool printAlways READ printAlways WRITE setPrintAlways)
public: public:
SubDetailFooterBand(QObject* owner = 0, QGraphicsItem* parent = 0); SubDetailFooterBand(QObject* owner = 0, QGraphicsItem* parent = 0);
virtual bool isUnique() const; virtual bool isUnique() const;
bool isFooter() const { return true; } bool isFooter() const { return true; }
int bandNestingLevel() { return 1; } int bandNestingLevel() { return 1; }
protected: protected:
QColor bandColor() const; QColor bandColor() const;
private: private:
BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0); BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0);
private: private:
}; };
} } // namespace LimeReport
#endif // LRSUBDETAILBAND_H #endif // LRSUBDETAILBAND_H

View File

@ -1,24 +1,24 @@
#include "lrtearoffband.h" #include "lrtearoffband.h"
#include "lrdesignelementsfactory.h" #include "lrdesignelementsfactory.h"
#include "lrglobal.h" #include "lrglobal.h"
const QString xmlTag = "TearOffBand"; const QString xmlTag = "TearOffBand";
namespace { namespace {
LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIntf* parent){ LimeReport::BaseDesignIntf* createBand(QObject* owner, LimeReport::BaseDesignIntf* parent)
{
return new LimeReport::TearOffBand(owner, parent); return new LimeReport::TearOffBand(owner, parent);
} }
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator( bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
xmlTag, xmlTag, LimeReport::ItemAttribs(QObject::tr("Tear-off Band"), LimeReport::Const::bandTAG),
LimeReport::ItemAttribs(QObject::tr("Tear-off Band"),LimeReport::Const::bandTAG), createBand);
createBand } // namespace
);
}
namespace LimeReport { namespace LimeReport {
TearOffBand::TearOffBand(QObject *owner, QGraphicsItem *parent) TearOffBand::TearOffBand(QObject* owner, QGraphicsItem* parent):
:BandDesignIntf(LimeReport::BandDesignIntf::TearOffBand,xmlTag,owner,parent) BandDesignIntf(LimeReport::BandDesignIntf::TearOffBand, xmlTag, owner, parent)
{ {
setBandTypeText(tr("Tear-off Band")); setBandTypeText(tr("Tear-off Band"));
setMarkerColor(bandColor()); setMarkerColor(bandColor());
@ -29,9 +29,6 @@ BaseDesignIntf *TearOffBand::createSameTypeItem(QObject *owner, QGraphicsItem *p
return new TearOffBand(owner, parent); return new TearOffBand(owner, parent);
} }
QColor TearOffBand::bandColor() const QColor TearOffBand::bandColor() const { return QColor(200, 200, 200); }
{
return QColor(200,200,200);
}
} // namedpace LimeReport } // namespace LimeReport

View File

@ -4,12 +4,12 @@
namespace LimeReport { namespace LimeReport {
class TearOffBand : public BandDesignIntf class TearOffBand: public BandDesignIntf {
{
Q_OBJECT Q_OBJECT
public: public:
TearOffBand(QObject* owner = 0, QGraphicsItem* parent = 0); TearOffBand(QObject* owner = 0, QGraphicsItem* parent = 0);
virtual BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0); virtual BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0);
protected: protected:
QColor bandColor() const; QColor bandColor() const;
bool isUnique() const { return true; } bool isUnique() const { return true; }

View File

@ -30,54 +30,61 @@
#ifndef LRATTRIBABSTRACTFACTORY_H #ifndef LRATTRIBABSTRACTFACTORY_H
#define LRATTRIBABSTRACTFACTORY_H #define LRATTRIBABSTRACTFACTORY_H
#include "lrsingleton.h"
#include "lrglobal.h" #include "lrglobal.h"
#include <stdexcept> #include "lrsingleton.h"
#include <QMap> #include <QMap>
#include <QString> #include <QString>
#include <stdexcept>
namespace LimeReport { namespace LimeReport {
template template <typename AbstractProduct, typename IdentifierType, typename ProductCreator,
< typename Attribs>
typename AbstractProduct, class AttribsAbstractFactory:
typename IdentifierType, public Singleton<
typename ProductCreator, AttribsAbstractFactory<AbstractProduct, IdentifierType, ProductCreator, Attribs>> {
typename Attribs
>
class AttribsAbstractFactory
: public Singleton< AttribsAbstractFactory< AbstractProduct,IdentifierType,ProductCreator,Attribs > >
{
private: private:
typedef QMap<IdentifierType, ProductCreator> FactoryMap; typedef QMap<IdentifierType, ProductCreator> FactoryMap;
typedef QMap<IdentifierType, Attribs> AliasMap; typedef QMap<IdentifierType, Attribs> AliasMap;
friend class Singleton< AttribsAbstractFactory< AbstractProduct,IdentifierType,ProductCreator,Attribs > >; friend class Singleton<
AttribsAbstractFactory<AbstractProduct, IdentifierType, ProductCreator, Attribs>>;
public: public:
bool registerCreator(const IdentifierType& id, Attribs attribs, ProductCreator creator){ bool registerCreator(const IdentifierType& id, Attribs attribs, ProductCreator creator)
if (m_factoryMap.contains(id)) return true; {
return (m_factoryMap.insert(id,creator).value() == creator) && if (m_factoryMap.contains(id))
(m_attribsMap.insert(id,attribs).value() == attribs); 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); return (m_factoryMap.remove(id) == 1) && (m_attribsMap.remove(id) == 1);
} }
ProductCreator objectCreator(const IdentifierType& id){ ProductCreator objectCreator(const IdentifierType& id)
{
if (m_factoryMap.contains(id)) { if (m_factoryMap.contains(id)) {
return m_factoryMap[id]; return m_factoryMap[id];
} else return 0; } else
return 0;
} }
QString attribs(const IdentifierType& id){ QString attribs(const IdentifierType& id)
{
if (m_attribsMap.contains(id)) { if (m_attribsMap.contains(id)) {
return m_attribsMap.value(id); return m_attribsMap.value(id);
} else return ""; } else
return "";
} }
const FactoryMap& map() { return m_factoryMap; } const FactoryMap& map() { return m_factoryMap; }
const AliasMap& attribsMap() { return m_attribsMap; } const AliasMap& attribsMap() { return m_attribsMap; }
int mapElementCount() { return m_factoryMap.count(); } int mapElementCount() { return m_factoryMap.count(); }
private: private:
FactoryMap m_factoryMap; FactoryMap m_factoryMap;
AliasMap m_attribsMap; AliasMap m_attribsMap;
}; };
} } // namespace LimeReport
#endif // LRATTRIBABSTRACTFACTORY_H #endif // LRATTRIBABSTRACTFACTORY_H

View File

@ -30,34 +30,31 @@
#ifndef LRSIMPLEABSTRACTFACTORY_H #ifndef LRSIMPLEABSTRACTFACTORY_H
#define LRSIMPLEABSTRACTFACTORY_H #define LRSIMPLEABSTRACTFACTORY_H
#include "lrsingleton.h"
#include "lrglobal.h" #include "lrglobal.h"
#include <stdexcept> #include "lrsingleton.h"
#include <QHash> #include <QHash>
#include <QMap> #include <QMap>
#include <QString> #include <QString>
#include <stdexcept>
namespace LimeReport { namespace LimeReport {
template template <typename AbstractProduct, typename IdentifierType, typename ProductCreator>
< class SimpleAbstractFactory:
typename AbstractProduct, public Singleton<SimpleAbstractFactory<AbstractProduct, IdentifierType, ProductCreator>> {
typename IdentifierType,
typename ProductCreator
>
class SimpleAbstractFactory
: public Singleton< SimpleAbstractFactory< AbstractProduct,IdentifierType,ProductCreator > >
{
private: private:
typedef QHash<IdentifierType, ProductCreator> FactoryMap; typedef QHash<IdentifierType, ProductCreator> FactoryMap;
friend class Singleton<SimpleAbstractFactory<AbstractProduct, IdentifierType, ProductCreator>>; friend class Singleton<SimpleAbstractFactory<AbstractProduct, IdentifierType, ProductCreator>>;
public: public:
bool registerCreator(const IdentifierType& id, ProductCreator creator){ bool registerCreator(const IdentifierType& id, ProductCreator creator)
{
return (m_factoryMap.insert(id, creator).value() == creator); return (m_factoryMap.insert(id, creator).value() == creator);
} }
bool unregisterCreator(const IdentifierType& id){ bool unregisterCreator(const IdentifierType& id) { return (m_factoryMap.remove(id) == 1); }
return (m_factoryMap.remove(id)==1); ProductCreator objectCreator(const IdentifierType& id)
} {
ProductCreator objectCreator(const IdentifierType& id){
if (m_factoryMap.contains(id)) { if (m_factoryMap.contains(id)) {
return m_factoryMap[id]; return m_factoryMap[id];
} else { } else {
@ -66,38 +63,43 @@ public:
} }
const FactoryMap& map() { return m_factoryMap; } const FactoryMap& map() { return m_factoryMap; }
int mapElementCount() { return m_factoryMap.count(); } int mapElementCount() { return m_factoryMap.count(); }
private: private:
FactoryMap m_factoryMap; FactoryMap m_factoryMap;
}; };
template template <typename AbstractProduct, typename IdentifierType, typename ProductCreator,
< typename Attribs>
typename AbstractProduct, class AttribAbstractFactory:
typename IdentifierType, public SimpleAbstractFactory<AbstractProduct, IdentifierType, ProductCreator> {
typename ProductCreator,
typename Attribs
>
class AttribAbstractFactory : public SimpleAbstractFactory< AbstractProduct,IdentifierType,ProductCreator >{
typedef SimpleAbstractFactory<AbstractProduct, IdentifierType, ProductCreator> SimpleFactory; typedef SimpleAbstractFactory<AbstractProduct, IdentifierType, ProductCreator> SimpleFactory;
typedef QMap<IdentifierType, Attribs> AliasMap; typedef QMap<IdentifierType, Attribs> AliasMap;
friend class Singleton<AttribAbstractFactory< AbstractProduct,IdentifierType,ProductCreator,Attribs > >; friend class Singleton<
AttribAbstractFactory<AbstractProduct, IdentifierType, ProductCreator, Attribs>>;
public: public:
bool registerCreator(const IdentifierType &id, Attribs attribs, ProductCreator creator){ bool registerCreator(const IdentifierType& id, Attribs attribs, ProductCreator creator)
return SimpleFactory::registerCreator(id,creator) && (m_attribsMap.insert(id,attribs).value()==attribs); {
return SimpleFactory::registerCreator(id, creator)
&& (m_attribsMap.insert(id, attribs).value() == attribs);
} }
bool unregisterCreator(const IdentifierType &id){ bool unregisterCreator(const IdentifierType& id)
{
return SimpleFactory::unregisterCreator(id) && (m_attribsMap.remove(id) == 1); return SimpleFactory::unregisterCreator(id) && (m_attribsMap.remove(id) == 1);
} }
QString attribs(const IdentifierType& id){ QString attribs(const IdentifierType& id)
{
if (m_attribsMap.contains(id)) { if (m_attribsMap.contains(id)) {
return m_attribsMap.value(id); return m_attribsMap.value(id);
} else return ""; } else
return "";
} }
const AliasMap& attribsMap() { return m_attribsMap; } const AliasMap& attribsMap() { return m_attribsMap; }
private: private:
AliasMap m_attribsMap; AliasMap m_attribsMap;
}; };
} } // namespace LimeReport
#endif // LRSIMPLEABSTRACTFACTORY_H #endif // LRSIMPLEABSTRACTFACTORY_H

View File

@ -34,26 +34,25 @@
namespace LimeReport { namespace LimeReport {
template <typename T> template <typename T> class Singleton {
class Singleton
{
public: public:
static T& instance(){ static T& instance()
{
if (0 == inst) { if (0 == inst) {
inst = new T(); inst = new T();
::atexit(destroy); ::atexit(destroy);
} else {}; } else {
};
return *inst; return *inst;
} }
private: private:
static T* inst; static T* inst;
private: private:
static void destroy() { static void destroy() { delete inst; }
delete inst;
}
}; };
template <typename T> template <typename T> T* Singleton<T>::inst = 0;
T* Singleton< T >::inst =0; } // namespace LimeReport
}
#endif // LRSINGLETON_H #endif // LRSINGLETON_H

View File

@ -29,29 +29,33 @@
****************************************************************************/ ****************************************************************************/
#include "lrconnectiondialog.h" #include "lrconnectiondialog.h"
#include "ui_lrconnectiondialog.h" #include "ui_lrconnectiondialog.h"
#include "lrglobal.h" #include "lrglobal.h"
#include <QDebug>
#include <QFileDialog>
#include <QMessageBox>
#include <QSqlDatabase> #include <QSqlDatabase>
#include <QSqlError> #include <QSqlError>
#include <QDebug>
#include <QMessageBox>
#include <stdexcept> #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), 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); ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true); setAttribute(Qt::WA_DeleteOnClose, true);
m_changeMode = m_connection != 0; m_changeMode = m_connection != 0;
} }
ConnectionDialog::~ConnectionDialog() ConnectionDialog::~ConnectionDialog() { delete ui; }
{
delete ui;
}
void ConnectionDialog::init() void ConnectionDialog::init()
{ {
@ -59,24 +63,21 @@ void ConnectionDialog::init()
ui->cbbUseDefaultConnection->setEnabled(!m_controller->containsDefaultConnection()); ui->cbbUseDefaultConnection->setEnabled(!m_controller->containsDefaultConnection());
} }
void ConnectionDialog::showEvent(QShowEvent *) void ConnectionDialog::showEvent(QShowEvent*) { connectionToUI(); }
{
connectionToUI();
}
void ConnectionDialog::slotAccept() void ConnectionDialog::slotAccept()
{ {
try { try {
checkFieldsFill(); checkFieldsFill();
if (ui->cbAutoConnect->isChecked()) checkConnection(); if (ui->cbAutoConnect->isChecked())
checkConnection();
if (!m_connection) { if (!m_connection) {
m_controller->addConnectionDesc(uiToConnection()); m_controller->addConnectionDesc(uiToConnection());
} else { } else {
m_controller->changeConnectionDesc(uiToConnection(m_connection)); m_controller->changeConnectionDesc(uiToConnection(m_connection));
} }
close(); close();
} } catch (LimeReport::ReportError& exception) {
catch(LimeReport::ReportError &exception){
QMessageBox::critical(this, tr("Error"), exception.what()); QMessageBox::critical(this, tr("Error"), exception.what());
} }
} }
@ -85,7 +86,8 @@ void ConnectionDialog::slotCheckConnection()
{ {
try { try {
checkConnection(); checkConnection();
QMessageBox::information(this,tr("Connection"),tr("Connection succsesfully established!")); QMessageBox::information(this, tr("Connection"),
tr("Connection succsesfully established!"));
} catch (LimeReport::ReportError& exception) { } catch (LimeReport::ReportError& exception) {
QMessageBox::critical(this, tr("Error"), exception.what()); QMessageBox::critical(this, tr("Error"), exception.what());
} }
@ -93,9 +95,12 @@ void ConnectionDialog::slotCheckConnection()
void ConnectionDialog::checkFieldsFill() void ConnectionDialog::checkFieldsFill()
{ {
if (ui->leConnectionName->text().isEmpty()){throw LimeReport::ReportError(tr("Connection Name is empty"));} if (ui->leConnectionName->text().isEmpty()) {
throw LimeReport::ReportError(tr("Connection Name is empty"));
}
if (!m_changeMode && QSqlDatabase::connectionNames().contains(ui->leConnectionName->text())) { if (!m_changeMode && QSqlDatabase::connectionNames().contains(ui->leConnectionName->text())) {
throw LimeReport::ReportError(tr("Connection with name ")+ui->leConnectionName->text()+tr(" already exists! ")); throw LimeReport::ReportError(tr("Connection with name ") + ui->leConnectionName->text()
+ tr(" already exists! "));
} }
} }
@ -131,9 +136,11 @@ ConnectionDesc *ConnectionDialog::uiToConnection(LimeReport::ConnectionDesc* con
void ConnectionDialog::connectionToUI() void ConnectionDialog::connectionToUI()
{ {
init(); init();
if (!m_connection) return; if (!m_connection)
return;
ui->leConnectionName->setText(ConnectionDesc::connectionNameForUser(m_connection->name())); 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->leDataBase->setText(m_connection->databaseName());
ui->leServerName->setText(m_connection->host()); ui->leServerName->setText(m_connection->host());
ui->leUserName->setText(m_connection->userName()); ui->leUserName->setText(m_connection->userName());
@ -166,10 +173,3 @@ void ConnectionDialog::on_toolButton_2_toggled(bool checked)
} }
} // namespace LimeReport } // namespace LimeReport

View File

@ -30,21 +30,23 @@
#ifndef LRCONNECTIONDIALOG_H #ifndef LRCONNECTIONDIALOG_H
#define LRCONNECTIONDIALOG_H #define LRCONNECTIONDIALOG_H
#include <QDialog>
#include "lrdatadesignintf.h" #include "lrdatadesignintf.h"
#include <QDialog>
namespace LimeReport { namespace LimeReport {
namespace Ui { namespace Ui {
class ConnectionDialog; class ConnectionDialog;
} }
class ConnectionDialog : public QDialog class ConnectionDialog: public QDialog {
{
Q_OBJECT Q_OBJECT
public: 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(); ~ConnectionDialog();
protected: protected:
void showEvent(QShowEvent*); void showEvent(QShowEvent*);
void init(); void init();

View File

@ -27,31 +27,36 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. * * GNU General Public License for more details. *
****************************************************************************/ ****************************************************************************/
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QDebug>
#include <QMessageBox>
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlQuery>
#include <QtSql/QSqlQueryModel>
#include <QtSql/QSqlError>
#include <QFileInfo>
#include <QTableView>
#include <QDockWidget>
#include <QMainWindow>
#include "ui_lrdatabrowser.h" #include "ui_lrdatabrowser.h"
#include "lrdatabrowser.h"
#include "lrsqleditdialog.h"
#include "lrconnectiondialog.h" #include "lrconnectiondialog.h"
#include "lrdatabrowser.h"
#include "lrreportengine_p.h" #include "lrreportengine_p.h"
#include "lrsqleditdialog.h"
#include "lrvariabledialog.h" #include "lrvariabledialog.h"
#include <QDebug>
#include <QDockWidget>
#include <QFileInfo>
#include <QHBoxLayout>
#include <QMainWindow>
#include <QMessageBox>
#include <QTableView>
#include <QVBoxLayout>
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlError>
#include <QtSql/QSqlQuery>
#include <QtSql/QSqlQueryModel>
namespace LimeReport { namespace LimeReport {
DataBrowser::DataBrowser(QWidget* parent): DataBrowser::DataBrowser(QWidget* parent):
QWidget(parent), QWidget(parent),
ui(new Ui::DataBrowser), m_report(0), m_closingWindows(false), m_settings(0), m_ownedSettings(false) ui(new Ui::DataBrowser),
m_report(0),
m_closingWindows(false),
m_settings(0),
m_ownedSettings(false)
{ {
ui->setupUi(this); ui->setupUi(this);
connect(ui->addConnection, SIGNAL(clicked()), this, SLOT(slotAddConnection())); connect(ui->addConnection, SIGNAL(clicked()), this, SLOT(slotAddConnection()));
@ -76,10 +81,7 @@ DataBrowser::~DataBrowser()
if (m_settings && m_ownedSettings) if (m_settings && m_ownedSettings)
delete m_settings; delete m_settings;
} }
QSize DataBrowser::sizeHint() const QSize DataBrowser::sizeHint() const { return QSize(100, 200); }
{
return QSize(100,200);
}
void DataBrowser::slotAddConnection() void DataBrowser::slotAddConnection()
{ {
@ -108,15 +110,11 @@ void DataBrowser::slotSQLEditingFinished(SQLEditResult result)
void DataBrowser::slotDeleteConnection() void DataBrowser::slotDeleteConnection()
{ {
if (!getConnectionName(NameForUser).isEmpty()) { if (!getConnectionName(NameForUser).isEmpty()) {
if ( if (QMessageBox::critical(this, tr("Attention"),
QMessageBox::critical( tr("Do you really want to delete \"%1\" connection?")
this, .arg(getConnectionName(NameForUser)),
tr("Attention"), QMessageBox::Ok | QMessageBox::No, QMessageBox::No)
tr("Do you really want to delete \"%1\" connection?").arg(getConnectionName(NameForUser)), == QMessageBox::Ok) {
QMessageBox::Ok|QMessageBox::No,
QMessageBox::No
) == QMessageBox::Ok
){
m_report->dataManager()->removeConnection(getConnectionName(NameForReport)); m_report->dataManager()->removeConnection(getConnectionName(NameForReport));
updateDataTree(); updateDataTree();
} }
@ -125,7 +123,8 @@ void DataBrowser::slotDeleteConnection()
void DataBrowser::slotAddDataSource() void DataBrowser::slotAddDataSource()
{ {
SQLEditDialog *sqlEdit = new SQLEditDialog(this,m_report->dataManager(),SQLEditDialog::AddMode); SQLEditDialog* sqlEdit
= new SQLEditDialog(this, m_report->dataManager(), SQLEditDialog::AddMode);
sqlEdit->setAttribute(Qt::WA_DeleteOnClose, true); sqlEdit->setAttribute(Qt::WA_DeleteOnClose, true);
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
sqlEdit->setWindowModality(Qt::WindowModal); sqlEdit->setWindowModality(Qt::WindowModal);
@ -135,7 +134,8 @@ void DataBrowser::slotAddDataSource()
sqlEdit->setSettings(settings()); sqlEdit->setSettings(settings());
sqlEdit->setDataSources(m_report->dataManager()); sqlEdit->setDataSources(m_report->dataManager());
sqlEdit->setDefaultConnection(getConnectionName(NameForReport)); sqlEdit->setDefaultConnection(getConnectionName(NameForReport));
connect(sqlEdit,SIGNAL(signalSqlEditingFinished(SQLEditResult)),this,SLOT(slotSQLEditingFinished(SQLEditResult))); connect(sqlEdit, SIGNAL(signalSqlEditingFinished(SQLEditResult)), this,
SLOT(slotSQLEditingFinished(SQLEditResult)));
sqlEdit->exec(); sqlEdit->exec();
} }
@ -153,14 +153,16 @@ void DataBrowser::updateDataTree()
foreach (QString dataSourceName, m_report->datasourcesNames()) { foreach (QString dataSourceName, m_report->datasourcesNames()) {
QTreeWidgetItem *item=new QTreeWidgetItem(QStringList(dataSourceName),DataBrowserTree::Table); QTreeWidgetItem* item
QTreeWidgetItem *parentItem = findByNameAndType( = new QTreeWidgetItem(QStringList(dataSourceName), DataBrowserTree::Table);
ConnectionDesc::connectionNameForUser(m_report->dataManager()->connectionName(dataSourceName)), QTreeWidgetItem* parentItem
DataBrowserTree::Connection = findByNameAndType(ConnectionDesc::connectionNameForUser(
); m_report->dataManager()->connectionName(dataSourceName)),
DataBrowserTree::Connection);
if (parentItem) { if (parentItem) {
parentItem->addChild(item); parentItem->addChild(item);
if (!parentItem->isExpanded()) ui->dataTree->expandItem(parentItem); if (!parentItem->isExpanded())
ui->dataTree->expandItem(parentItem);
} else { } else {
ui->dataTree->addTopLevelItem(item); ui->dataTree->addTopLevelItem(item);
} }
@ -174,7 +176,8 @@ void DataBrowser::updateDataTree()
else else
item->setIcon(0, QIcon(":/databrowser/images/table_error")); item->setIcon(0, QIcon(":/databrowser/images/table_error"));
} else item->setIcon(0,QIcon(":/databrowser/images/table_error")); } else
item->setIcon(0, QIcon(":/databrowser/images/table_error"));
} catch (ReportError& /*exception*/) { } catch (ReportError& /*exception*/) {
item->setIcon(0, QIcon(":/databrowser/images/table_error")); item->setIcon(0, QIcon(":/databrowser/images/table_error"));
@ -192,11 +195,14 @@ void DataBrowser::updateDataTree()
void DataBrowser::updateVariablesTree() void DataBrowser::updateVariablesTree()
{ {
ui->variablesTree->clear(); ui->variablesTree->clear();
QTreeWidgetItem *reportVariables = new QTreeWidgetItem(QStringList(tr("Report variables")),DataBrowserTree::Category); QTreeWidgetItem* reportVariables
= new QTreeWidgetItem(QStringList(tr("Report variables")), DataBrowserTree::Category);
reportVariables->setIcon(0, QIcon(":/report/images/folder")); reportVariables->setIcon(0, QIcon(":/report/images/folder"));
QTreeWidgetItem *systemVariables =new QTreeWidgetItem(QStringList(tr("System variables")),DataBrowserTree::Category); QTreeWidgetItem* systemVariables
= new QTreeWidgetItem(QStringList(tr("System variables")), DataBrowserTree::Category);
systemVariables->setIcon(0, QIcon(":/report/images/folder")); systemVariables->setIcon(0, QIcon(":/report/images/folder"));
QTreeWidgetItem *externalVariables = new QTreeWidgetItem(QStringList(tr("External variables")),DataBrowserTree::Category); QTreeWidgetItem* externalVariables
= new QTreeWidgetItem(QStringList(tr("External variables")), DataBrowserTree::Category);
externalVariables->setIcon(0, QIcon(":/report/images/folder")); externalVariables->setIcon(0, QIcon(":/report/images/folder"));
ui->variablesTree->addTopLevelItem(reportVariables); ui->variablesTree->addTopLevelItem(reportVariables);
ui->variablesTree->addTopLevelItem(systemVariables); ui->variablesTree->addTopLevelItem(systemVariables);
@ -204,10 +210,10 @@ void DataBrowser::updateVariablesTree()
foreach (QString variableName, m_report->dataManager()->variableNames()) { foreach (QString variableName, m_report->dataManager()->variableNames()) {
QStringList values; QStringList values;
values<<variableName+((m_report->dataManager()->variableIsSystem(variableName))? values << variableName
"": + ((m_report->dataManager()->variableIsSystem(variableName))
" ["+m_report->dataManager()->variable(variableName).toString()+"]" ? ""
) : " [" + m_report->dataManager()->variable(variableName).toString() + "]")
<< variableName; << variableName;
QTreeWidgetItem* item = new QTreeWidgetItem(values, DataBrowserTree::Variable); QTreeWidgetItem* item = new QTreeWidgetItem(values, DataBrowserTree::Variable);
item->setIcon(0, QIcon(":/databrowser/images/value")); item->setIcon(0, QIcon(":/databrowser/images/value"));
@ -221,7 +227,8 @@ void DataBrowser::updateVariablesTree()
foreach (QString variableName, m_report->dataManager()->userVariableNames()) { foreach (QString variableName, m_report->dataManager()->userVariableNames()) {
if (!m_report->dataManager()->variableNames().contains(variableName)) { if (!m_report->dataManager()->variableNames().contains(variableName)) {
QStringList values; QStringList values;
values<<variableName+" ["+m_report->dataManager()->variable(variableName).toString()+"]" values << variableName + " ["
+ m_report->dataManager()->variable(variableName).toString() + "]"
<< variableName; << variableName;
QTreeWidgetItem* item = new QTreeWidgetItem(values, DataBrowserTree::ExternalVariable); QTreeWidgetItem* item = new QTreeWidgetItem(values, DataBrowserTree::ExternalVariable);
item->setIcon(0, QIcon(":/databrowser/images/value")); item->setIcon(0, QIcon(":/databrowser/images/value"));
@ -248,7 +255,8 @@ void DataBrowser::closeAllDataWindows()
void DataBrowser::setSettings(QSettings* value, bool owned) void DataBrowser::setSettings(QSettings* value, bool owned)
{ {
if (m_settings && m_ownedSettings) delete m_settings; if (m_settings && m_ownedSettings)
delete m_settings;
m_settings = value; m_settings = value;
m_ownedSettings = owned; m_ownedSettings = owned;
} }
@ -264,16 +272,15 @@ QSettings *DataBrowser::settings()
} }
} }
void DataBrowser::slotDatasourcesChanged() void DataBrowser::slotDatasourcesChanged() { updateDataTree(); }
{
updateDataTree();
}
void DataBrowser::fillFields(QTreeWidgetItem* parentItem, LimeReport::IDataSource* dataSource) void DataBrowser::fillFields(QTreeWidgetItem* parentItem, LimeReport::IDataSource* dataSource)
{ {
if (!dataSource) return; if (!dataSource)
return;
for (int i = 0; i < dataSource->columnCount(); i++) { for (int i = 0; i < dataSource->columnCount(); i++) {
QTreeWidgetItem *item = new QTreeWidgetItem(QStringList(dataSource->columnNameByIndex(i)),DataBrowserTree::Row); QTreeWidgetItem* item = new QTreeWidgetItem(QStringList(dataSource->columnNameByIndex(i)),
DataBrowserTree::Row);
item->setIcon(0, QIcon(":/databrowser/images/field")); item->setIcon(0, QIcon(":/databrowser/images/field"));
parentItem->addChild(item); parentItem->addChild(item);
} }
@ -282,11 +289,15 @@ void DataBrowser::fillFields(QTreeWidgetItem *parentItem, LimeReport::IDataSourc
QTreeWidgetItem* DataBrowser::findByNameAndType(QString name, int itemType) QTreeWidgetItem* DataBrowser::findByNameAndType(QString name, int itemType)
{ {
if (name.isEmpty()) return 0; if (name.isEmpty())
QList<QTreeWidgetItem *>items = ui->dataTree->findItems(name,Qt::MatchContains | Qt::MatchRecursive); return 0;
QList<QTreeWidgetItem*> items
= ui->dataTree->findItems(name, Qt::MatchContains | Qt::MatchRecursive);
if (!items.isEmpty()) { if (!items.isEmpty()) {
for (int i = 0; i < items.count(); i++) { for (int i = 0; i < items.count(); i++) {
if ( (items.at(i)->type()==itemType)/* && (items.at(0)->text(0)==name)*/){ return items.at(i);} if ((items.at(i)->type() == itemType) /* && (items.at(0)->text(0)==name)*/) {
return items.at(i);
}
} }
} }
return 0; return 0;
@ -303,13 +314,16 @@ void DataBrowser::slotViewDatasource()
QString DataBrowser::getDatasourceName() QString DataBrowser::getDatasourceName()
{ {
if (ui->dataTree->currentItem()) { if (ui->dataTree->currentItem()) {
if (ui->dataTree->currentItem()->type() == DataBrowserTree::Table) return ui->dataTree->currentItem()->text(0); if (ui->dataTree->currentItem()->type() == DataBrowserTree::Table)
if (ui->dataTree->currentItem()->type() == DataBrowserTree::Row) return ui->dataTree->currentItem()->parent()->text(0); return ui->dataTree->currentItem()->text(0);
if (ui->dataTree->currentItem()->type() == DataBrowserTree::Row)
return ui->dataTree->currentItem()->parent()->text(0);
}; };
return QString(); return QString();
} }
QTreeWidgetItem* findConnectionItem(QTreeWidgetItem* item){ QTreeWidgetItem* findConnectionItem(QTreeWidgetItem* item)
{
if (item->type() == DataBrowserTree::Connection) { if (item->type() == DataBrowserTree::Connection) {
return item; return item;
} else { } else {
@ -331,19 +345,17 @@ QString DataBrowser::getConnectionName(NameType nameType)
case NameForReport: case NameForReport:
return ConnectionDesc::connectionNameForReport(ci->text(0)); return ConnectionDesc::connectionNameForReport(ci->text(0));
} }
} } else
else return QString(); return QString();
}; };
return QString(); return QString();
} }
QString DataBrowser::getVariable() QString DataBrowser::getVariable()
{ {
if( if (ui->variablesTree->currentItem()
ui->variablesTree->currentItem() && && (ui->variablesTree->currentItem()->type() == DataBrowserTree::Variable
(ui->variablesTree->currentItem()->type() == DataBrowserTree::Variable || || ui->variablesTree->currentItem()->type() == DataBrowserTree::ExternalVariable)) {
ui->variablesTree->currentItem()->type() == DataBrowserTree::ExternalVariable)
){
return ui->variablesTree->currentItem()->text(1); return ui->variablesTree->currentItem()->text(1);
} }
return QString(); return QString();
@ -353,7 +365,8 @@ void DataBrowser::slotEditDatasource()
{ {
if (!getDatasourceName().isEmpty()) { if (!getDatasourceName().isEmpty()) {
closeDataWindow(getDatasourceName()); closeDataWindow(getDatasourceName());
SQLEditDialog *sqlEdit = new SQLEditDialog(this,m_report->dataManager(),SQLEditDialog::EditMode); SQLEditDialog* sqlEdit
= new SQLEditDialog(this, m_report->dataManager(), SQLEditDialog::EditMode);
sqlEdit->setAttribute(Qt::WA_DeleteOnClose); sqlEdit->setAttribute(Qt::WA_DeleteOnClose);
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
sqlEdit->setWindowModality(Qt::WindowModal); sqlEdit->setWindowModality(Qt::WindowModal);
@ -362,7 +375,8 @@ void DataBrowser::slotEditDatasource()
#endif #endif
sqlEdit->setSettings(settings()); sqlEdit->setSettings(settings());
sqlEdit->setDataSources(m_report->dataManager(), getDatasourceName()); sqlEdit->setDataSources(m_report->dataManager(), getDatasourceName());
connect(sqlEdit,SIGNAL(signalSqlEditingFinished(SQLEditResult)),this,SLOT(slotSQLEditingFinished(SQLEditResult))); connect(sqlEdit, SIGNAL(signalSqlEditingFinished(SQLEditResult)), this,
SLOT(slotSQLEditingFinished(SQLEditResult)));
sqlEdit->exec(); sqlEdit->exec();
} }
} }
@ -372,15 +386,11 @@ void DataBrowser::slotDeleteDatasource()
QString datasourceName = getDatasourceName(); QString datasourceName = getDatasourceName();
QTreeWidgetItem* item = findByNameAndType(datasourceName, DataBrowserTree::Table); QTreeWidgetItem* item = findByNameAndType(datasourceName, DataBrowserTree::Table);
if (item) { if (item) {
if ( if (QMessageBox::critical(
QMessageBox::critical( this, tr("Attention"),
this,
tr("Attention"),
tr("Do you really want to delete \"%1\" datasource?").arg(datasourceName), tr("Do you really want to delete \"%1\" datasource?").arg(datasourceName),
QMessageBox::Ok|QMessageBox::No, QMessageBox::Ok | QMessageBox::No, QMessageBox::No)
QMessageBox::No == QMessageBox::Ok) {
) == QMessageBox::Ok
){
removeDatasource(datasourceName); removeDatasource(datasourceName);
} }
} }
@ -390,7 +400,8 @@ void DataBrowser::setReportEditor(LimeReport::ReportDesignWidget *report)
{ {
m_report = report; m_report = report;
connect(m_report, SIGNAL(cleared()), this, SLOT(slotClear())); connect(m_report, SIGNAL(cleared()), this, SLOT(slotClear()));
connect(m_report->dataManager(), SIGNAL(datasourcesChanged()), this, SLOT(slotDatasourcesChanged())); connect(m_report->dataManager(), SIGNAL(datasourcesChanged()), this,
SLOT(slotDatasourcesChanged()));
updateDataTree(); updateDataTree();
updateVariablesTree(); updateVariablesTree();
} }
@ -398,7 +409,8 @@ void DataBrowser::setReportEditor(LimeReport::ReportDesignWidget *report)
void DataBrowser::slotClear() void DataBrowser::slotClear()
{ {
ui->dataTree->clear(); ui->dataTree->clear();
foreach(QDockWidget* window,m_dataWindows.values()) window->close(); foreach (QDockWidget* window, m_dataWindows.values())
window->close();
updateDataTree(); updateDataTree();
updateVariablesTree(); updateVariablesTree();
} }
@ -417,12 +429,10 @@ void DataBrowser::initConnections()
std::sort(connections.begin(), connections.end()); std::sort(connections.begin(), connections.end());
foreach (QString connectionName, connections) { foreach (QString connectionName, connections) {
QTreeWidgetItem* item = new QTreeWidgetItem( QTreeWidgetItem* item = new QTreeWidgetItem(
ui->dataTree, ui->dataTree, QStringList(ConnectionDesc::connectionNameForUser(connectionName)),
QStringList(ConnectionDesc::connectionNameForUser(connectionName)), DataBrowserTree::Connection);
DataBrowserTree::Connection if (!m_report->dataManager()->connectionNames().contains(
); ConnectionDesc::connectionNameForReport(connectionName), Qt::CaseInsensitive)) {
if (!m_report->dataManager()->connectionNames().contains(ConnectionDesc::connectionNameForReport(connectionName), Qt::CaseInsensitive))
{
item->setIcon(0, QIcon(":/databrowser/images/database_connected")); item->setIcon(0, QIcon(":/databrowser/images/database_connected"));
} else { } else {
if (m_report->dataManager()->isConnectionConnected(connectionName)) if (m_report->dataManager()->isConnectionConnected(connectionName))
@ -433,7 +443,6 @@ void DataBrowser::initConnections()
items.append(item); items.append(item);
} }
// foreach (QString connectionName, connections) { // foreach (QString connectionName, connections) {
// QTreeWidgetItem *item=new QTreeWidgetItem( // QTreeWidgetItem *item=new QTreeWidgetItem(
// ui->dataTree, // ui->dataTree,
@ -470,7 +479,8 @@ QDockWidget *DataBrowser::createDataWindow(QString datasourceName)
try { try {
IDataSourceHolder* holder = m_report->dataManager()->dataSourceHolder(datasourceName); IDataSourceHolder* holder = m_report->dataManager()->dataSourceHolder(datasourceName);
if (holder) holder->update(); if (holder)
holder->update();
IDataSource* datasource = m_report->dataManager()->dataSource(datasourceName); IDataSource* datasource = m_report->dataManager()->dataSource(datasourceName);
if (datasource) { if (datasource) {
tableView->setModel(datasource->model()); tableView->setModel(datasource->model());
@ -497,17 +507,16 @@ QDockWidget *DataBrowser::dataWindow(QString datasourceName)
{ {
if (m_dataWindows.contains(datasourceName)) { if (m_dataWindows.contains(datasourceName)) {
return m_dataWindows.value(datasourceName); return m_dataWindows.value(datasourceName);
} else return createDataWindow(datasourceName); } else
return createDataWindow(datasourceName);
} }
void DataBrowser::setMainWindow(QMainWindow *mainWindow) void DataBrowser::setMainWindow(QMainWindow* mainWindow) { m_mainWindow = mainWindow; }
{
m_mainWindow=mainWindow;
}
void DataBrowser::slotDataWindowClosed() void DataBrowser::slotDataWindowClosed()
{ {
if (isClosingWindows()) return; if (isClosingWindows())
return;
for (int i = 0; i < m_dataWindows.count(); i++) { for (int i = 0; i < m_dataWindows.count(); i++) {
if (m_dataWindows.values().at(i) == sender()) { if (m_dataWindows.values().at(i) == sender()) {
m_dataWindows.remove(m_dataWindows.keys().at(i)); m_dataWindows.remove(m_dataWindows.keys().at(i));
@ -519,10 +528,8 @@ void DataBrowser::slotChangeConnection()
{ {
if (!getConnectionName(NameForUser).isEmpty()) { if (!getConnectionName(NameForUser).isEmpty()) {
ConnectionDialog* connectionEdit = new ConnectionDialog( ConnectionDialog* connectionEdit = new ConnectionDialog(
this, this, m_report->dataManager()->connectionByName(getConnectionName(NameForReport)),
m_report->dataManager()->connectionByName(getConnectionName(NameForReport)), this);
this
);
connectionEdit->setAttribute(Qt::WA_DeleteOnClose, true); connectionEdit->setAttribute(Qt::WA_DeleteOnClose, true);
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
connectionEdit->setWindowModality(Qt::WindowModal); connectionEdit->setWindowModality(Qt::WindowModal);
@ -558,7 +565,8 @@ void DataBrowser::slotChangeConnectionState()
void DataBrowser::slotVariableEditorAccept(const QString& variable) void DataBrowser::slotVariableEditorAccept(const QString& variable)
{ {
updateVariablesTree(); updateVariablesTree();
QList<QTreeWidgetItem*> items = ui->variablesTree->findItems(variable, Qt::MatchContains | Qt::MatchRecursive); QList<QTreeWidgetItem*> items
= ui->variablesTree->findItems(variable, Qt::MatchContains | Qt::MatchRecursive);
if (!items.isEmpty()) { if (!items.isEmpty()) {
ui->variablesTree->setCurrentItem(items.at(0)); ui->variablesTree->setCurrentItem(items.at(0));
} }
@ -607,7 +615,8 @@ void DataBrowser::changeQuery(SQLEditResult result)
void DataBrowser::addSubQuery(SQLEditResult result) void DataBrowser::addSubQuery(SQLEditResult result)
{ {
try { try {
m_report->dataManager()->addSubQuery(result.datasourceName, result.sql, result.connectionName, result.masterDatasource); m_report->dataManager()->addSubQuery(result.datasourceName, result.sql,
result.connectionName, result.masterDatasource);
} catch (ReportError& exception) { } catch (ReportError& exception) {
qDebug() << exception.what(); qDebug() << exception.what();
} }
@ -626,7 +635,8 @@ void DataBrowser::changeSubQuery(SQLEditResult result)
void DataBrowser::addProxy(SQLEditResult result) void DataBrowser::addProxy(SQLEditResult result)
{ {
try { try {
m_report->dataManager()->addProxy(result.datasourceName,result.masterDatasource,result.childDataSource,result.fieldMap); m_report->dataManager()->addProxy(result.datasourceName, result.masterDatasource,
result.childDataSource, result.fieldMap);
} catch (ReportError& exception) { } catch (ReportError& exception) {
qDebug() << exception.what(); qDebug() << exception.what();
} }
@ -645,12 +655,8 @@ void DataBrowser::changeProxy(SQLEditResult result)
void DataBrowser::addCSV(SQLEditResult result) void DataBrowser::addCSV(SQLEditResult result)
{ {
try { try {
m_report->dataManager()->addCSV( m_report->dataManager()->addCSV(result.datasourceName, result.csv, result.separator,
result.datasourceName, result.firstRowIsHeader);
result.csv,
result.separator,
result.firstRowIsHeader
);
} catch (ReportError& exception) { } catch (ReportError& exception) {
qDebug() << exception.what(); qDebug() << exception.what();
} }
@ -668,14 +674,17 @@ void DataBrowser::changeCSV(SQLEditResult result)
SQLEditResult::ResultMode DataBrowser::currentDatasourceType(const QString& datasourceName) SQLEditResult::ResultMode DataBrowser::currentDatasourceType(const QString& datasourceName)
{ {
if (m_report->dataManager()->isQuery(datasourceName)) return SQLEditResult::Query; if (m_report->dataManager()->isQuery(datasourceName))
if (m_report->dataManager()->isSubQuery(datasourceName)) return SQLEditResult::SubQuery; return SQLEditResult::Query;
if (m_report->dataManager()->isProxy(datasourceName)) return SQLEditResult::SubProxy; if (m_report->dataManager()->isSubQuery(datasourceName))
if (m_report->dataManager()->isCSV(datasourceName)) return SQLEditResult::CSVText; return SQLEditResult::SubQuery;
if (m_report->dataManager()->isProxy(datasourceName))
return SQLEditResult::SubProxy;
if (m_report->dataManager()->isCSV(datasourceName))
return SQLEditResult::CSVText;
return SQLEditResult::Undefined; return SQLEditResult::Undefined;
} }
void DataBrowser::applyChanges(SQLEditResult result) void DataBrowser::applyChanges(SQLEditResult result)
{ {
if (result.resultMode == currentDatasourceType(result.oldDatasourceName)) { if (result.resultMode == currentDatasourceType(result.oldDatasourceName)) {
@ -692,7 +701,8 @@ void DataBrowser::applyChanges(SQLEditResult result)
case SQLEditResult::CSVText: case SQLEditResult::CSVText:
changeCSV(result); changeCSV(result);
break; break;
default: break; default:
break;
} }
} else { } else {
removeDatasource(result.oldDatasourceName); removeDatasource(result.oldDatasourceName);
@ -722,7 +732,8 @@ void DataBrowser::addDatasource(SQLEditResult result)
activateItem(result.datasourceName, DataBrowserTree::Table); activateItem(result.datasourceName, DataBrowserTree::Table);
} }
void DataBrowser::activateItem(const QString& name, DataBrowserTree::NodeType type){ void DataBrowser::activateItem(const QString& name, DataBrowserTree::NodeType type)
{
QTreeWidgetItem* item = findByNameAndType(name, type); QTreeWidgetItem* item = findByNameAndType(name, type);
if (item) if (item)
item->treeWidget()->setCurrentItem(item); item->treeWidget()->setCurrentItem(item);
@ -737,7 +748,8 @@ void DataBrowser::addConnectionDesc(ConnectionDesc *connection)
void DataBrowser::changeConnectionDesc(ConnectionDesc* connection) void DataBrowser::changeConnectionDesc(ConnectionDesc* connection)
{ {
if (connection->autoconnect()) m_report->dataManager()->connectConnection(connection->name()); if (connection->autoconnect())
m_report->dataManager()->connectConnection(connection->name());
updateDataTree(); updateDataTree();
activateItem(connection->name(), DataBrowserTree::Connection); activateItem(connection->name(), DataBrowserTree::Connection);
} }
@ -745,33 +757,31 @@ void DataBrowser::changeConnectionDesc(ConnectionDesc *connection)
bool DataBrowser::checkConnectionDesc(ConnectionDesc* connection) bool DataBrowser::checkConnectionDesc(ConnectionDesc* connection)
{ {
bool result = m_report->dataManager()->checkConnectionDesc(connection); bool result = m_report->dataManager()->checkConnectionDesc(connection);
if (!result) setLastError(m_report->dataManager()->lastError()); if (!result)
setLastError(m_report->dataManager()->lastError());
return result; return result;
} }
bool DataBrowser::containsDefaultConnection() bool DataBrowser::containsDefaultConnection()
{ {
bool result = m_report->dataManager()->connectionByName(QSqlDatabase::defaultConnection) || bool result = m_report->dataManager()->connectionByName(QSqlDatabase::defaultConnection)
QSqlDatabase::contains(QSqlDatabase::defaultConnection); || QSqlDatabase::contains(QSqlDatabase::defaultConnection);
return result; return result;
} }
QString DataBrowser::lastError() const QString DataBrowser::lastError() const { return m_lastError; }
{
return m_lastError;
}
void DataBrowser::setLastError(const QString &lastError) void DataBrowser::setLastError(const QString& lastError) { m_lastError = lastError; }
{
m_lastError = lastError;
}
void DataBrowser::on_dataTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous) void DataBrowser::on_dataTree_currentItemChanged(QTreeWidgetItem* current,
QTreeWidgetItem* previous)
{ {
Q_UNUSED(previous) Q_UNUSED(previous)
if (current && (current->type() == DataBrowserTree::Connection)) { if (current && (current->type() == DataBrowserTree::Connection)) {
bool internalConnection = m_report->dataManager()->connectionByName(ConnectionDesc::connectionNameForReport(current->text(0))); bool internalConnection = m_report->dataManager()->connectionByName(
if (m_report->dataManager()->isConnectionConnected(ConnectionDesc::connectionNameForReport(current->text(0)))){ ConnectionDesc::connectionNameForReport(current->text(0)));
if (m_report->dataManager()->isConnectionConnected(
ConnectionDesc::connectionNameForReport(current->text(0)))) {
ui->pbConnect->setIcon(QIcon(":/databrowser/images/plug-connect.png")); ui->pbConnect->setIcon(QIcon(":/databrowser/images/plug-connect.png"));
} else { } else {
ui->pbConnect->setIcon(QIcon(":/databrowser/images/plug-disconnect.png")); ui->pbConnect->setIcon(QIcon(":/databrowser/images/plug-disconnect.png"));
@ -794,7 +804,9 @@ void DataBrowser::on_dataTree_currentItemChanged(QTreeWidgetItem *current, QTree
ui->deleteDataSource->setEnabled(holder->isRemovable()); ui->deleteDataSource->setEnabled(holder->isRemovable());
if (!holder->lastError().isEmpty()) { if (!holder->lastError().isEmpty()) {
ui->errorMessage->setEnabled(true); ui->errorMessage->setEnabled(true);
} else {ui->errorMessage->setEnabled(false);} } else {
ui->errorMessage->setEnabled(false);
}
} }
} }
} }
@ -808,15 +820,14 @@ void LimeReport::DataBrowser::on_addVariable_clicked()
dialog.setWindowModality(Qt::ApplicationModal); dialog.setWindowModality(Qt::ApplicationModal);
#endif #endif
dialog.setVariableContainer(m_report->dataManager()); dialog.setVariableContainer(m_report->dataManager());
connect(&dialog,SIGNAL(signalVariableAccepted(QString)),this,SLOT(slotVariableEditorAccept(QString))); connect(&dialog, SIGNAL(signalVariableAccepted(QString)), this,
SLOT(slotVariableEditorAccept(QString)));
dialog.exec(); dialog.exec();
} }
void DataBrowser::on_editVariable_clicked() void DataBrowser::on_editVariable_clicked()
{ {
if (!getVariable().isEmpty()) if (!getVariable().isEmpty()) {
{
LRVariableDialog dialog(this); LRVariableDialog dialog(this);
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
dialog.setWindowModality(Qt::WindowModal); dialog.setWindowModality(Qt::WindowModal);
@ -826,7 +837,8 @@ void DataBrowser::on_editVariable_clicked()
dialog.setVariableContainer(m_report->dataManager()); dialog.setVariableContainer(m_report->dataManager());
QString varName = getVariable(); QString varName = getVariable();
dialog.setVariableName(varName); dialog.setVariableName(varName);
connect(&dialog,SIGNAL(signalVariableAccepted(QString)),this,SLOT(slotVariableEditorAccept(QString))); connect(&dialog, SIGNAL(signalVariableAccepted(QString)), this,
SLOT(slotVariableEditorAccept(QString)));
dialog.exec(); dialog.exec();
} }
} }
@ -835,16 +847,19 @@ void DataBrowser::on_deleteVariable_clicked()
{ {
QString varName = getVariable(); QString varName = getVariable();
if (!varName.isEmpty()) { if (!varName.isEmpty()) {
if (QMessageBox::critical(this,tr("Attention"),QString(tr("Do you really want to delete variable \"%1\"?")).arg(varName), if (QMessageBox::critical(
QMessageBox::Ok|QMessageBox::Cancel, QMessageBox::Cancel this, tr("Attention"),
)==QMessageBox::Ok){ QString(tr("Do you really want to delete variable \"%1\"?")).arg(varName),
QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel)
== QMessageBox::Ok) {
m_report->dataManager()->deleteVariable(varName); m_report->dataManager()->deleteVariable(varName);
updateVariablesTree(); updateVariablesTree();
} }
} }
} }
void DataBrowser::on_variablesTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous) void DataBrowser::on_variablesTree_currentItemChanged(QTreeWidgetItem* current,
QTreeWidgetItem* previous)
{ {
Q_UNUSED(previous) Q_UNUSED(previous)
if (current) { if (current) {
@ -871,8 +886,11 @@ void DataBrowser::on_variablesTree_currentItemChanged(QTreeWidgetItem *current,
void DataBrowser::on_errorMessage_clicked() void DataBrowser::on_errorMessage_clicked()
{ {
if(!getDatasourceName().isEmpty()&&m_report->dataManager()->dataSourceHolder(getDatasourceName())){ if (!getDatasourceName().isEmpty()
QMessageBox::critical(this,tr("Error"),m_report->dataManager()->dataSourceHolder(getDatasourceName())->lastError()); && m_report->dataManager()->dataSourceHolder(getDatasourceName())) {
QMessageBox::critical(
this, tr("Error"),
m_report->dataManager()->dataSourceHolder(getDatasourceName())->lastError());
} }
} }
@ -880,21 +898,19 @@ void DataBrowser::on_varToReport_clicked()
{ {
QString varName = getVariable(); QString varName = getVariable();
if (!varName.isEmpty()) { if (!varName.isEmpty()) {
m_report->dataManager()->addVariable(varName,m_report->dataManager()->variable(varName), VarDesc::Report); m_report->dataManager()->addVariable(varName, m_report->dataManager()->variable(varName),
VarDesc::Report);
ui->varToReport->setEnabled(false); ui->varToReport->setEnabled(false);
updateVariablesTree(); updateVariablesTree();
} }
} }
void DataBrowser::on_variablesTree_itemDoubleClicked(QTreeWidgetItem* item, int) void DataBrowser::on_variablesTree_itemDoubleClicked(QTreeWidgetItem* item, int)
{ {
if (item) { if (item) {
QString varName = item->text(1); QString varName = item->text(1);
if ( if (!varName.isEmpty()
!varName.isEmpty() && && (m_report->dataManager()->variableType(varName) == VarDesc::Report)) {
(m_report->dataManager()->variableType(varName) == VarDesc::Report)
){
LRVariableDialog dialog(this); LRVariableDialog dialog(this);
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
dialog.setWindowModality(Qt::WindowModal); dialog.setWindowModality(Qt::WindowModal);
@ -903,7 +919,8 @@ void DataBrowser::on_variablesTree_itemDoubleClicked(QTreeWidgetItem *item, int
#endif #endif
dialog.setVariableContainer(m_report->dataManager()); dialog.setVariableContainer(m_report->dataManager());
dialog.setVariableName(varName); dialog.setVariableName(varName);
connect(&dialog,SIGNAL(signalVariableAccepted(QString)),this,SLOT(slotVariableEditorAccept(QString))); connect(&dialog, SIGNAL(signalVariableAccepted(QString)), this,
SLOT(slotVariableEditorAccept(QString)));
dialog.exec(); dialog.exec();
} }
} }

View File

@ -30,14 +30,14 @@
#ifndef LRDATABROWSER_H #ifndef LRDATABROWSER_H
#define LRDATABROWSER_H #define LRDATABROWSER_H
#include <QWidget> #include "lrdatabrowsertree.h"
#include <QTreeWidget>
#include <QToolButton>
#include <QDockWidget>
#include "lrreportdesignwidget.h" #include "lrreportdesignwidget.h"
#include "lrsqleditdialog.h" #include "lrsqleditdialog.h"
#include "lrdatabrowsertree.h"
#include <QDockWidget>
#include <QToolButton>
#include <QTreeWidget>
#include <QWidget>
namespace LimeReport { namespace LimeReport {
@ -45,11 +45,9 @@ namespace Ui {
class DataBrowser; class DataBrowser;
} }
class DataBrowser : public QWidget, public IConnectionController class DataBrowser: public QWidget, public IConnectionController {
{
Q_OBJECT Q_OBJECT
public: public:
explicit DataBrowser(QWidget* parent = 0); explicit DataBrowser(QWidget* parent = 0);
~DataBrowser(); ~DataBrowser();
QSize sizeHint() const; QSize sizeHint() const;
@ -88,7 +86,10 @@ private slots:
void on_variablesTree_itemDoubleClicked(QTreeWidgetItem* item, int); void on_variablesTree_itemDoubleClicked(QTreeWidgetItem* item, int);
private: private:
enum NameType{NameForUser, NameForReport}; enum NameType {
NameForUser,
NameForReport
};
QString getDatasourceName(); QString getDatasourceName();
QString getConnectionName(NameType nameType); QString getConnectionName(NameType nameType);
QString getVariable(); QString getVariable();
@ -130,5 +131,5 @@ private:
QString m_lastError; QString m_lastError;
}; };
} } // namespace LimeReport
#endif // LRDATABROWSER_H #endif // LRDATABROWSER_H

View File

@ -28,13 +28,13 @@
* GNU General Public License for more details. * * GNU General Public License for more details. *
****************************************************************************/ ****************************************************************************/
#include "lrdatabrowsertree.h" #include "lrdatabrowsertree.h"
#include <QDebug> #include <QDebug>
#include <QMimeData> #include <QMimeData>
namespace LimeReport { namespace LimeReport {
DataBrowserTree::DataBrowserTree(QWidget *parent) : DataBrowserTree::DataBrowserTree(QWidget* parent): QTreeWidget(parent) { }
QTreeWidget(parent){}
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QMimeData* DataBrowserTree::mimeData(const QList<QTreeWidgetItem*>& items) const QMimeData* DataBrowserTree::mimeData(const QList<QTreeWidgetItem*>& items) const
@ -44,7 +44,8 @@ QMimeData *DataBrowserTree::mimeData(const QList<QTreeWidgetItem *> items) const
{ {
QMimeData* result = QTreeWidget::mimeData(items); QMimeData* result = QTreeWidget::mimeData(items);
if (items.at(0)->type() == Row) { if (items.at(0)->type() == Row) {
result->setText("field:$D{"+items.at(0)->parent()->text(0)+"."+items.at(0)->data(0,Qt::DisplayRole).toString()+"}"); result->setText("field:$D{" + items.at(0)->parent()->text(0) + "."
+ items.at(0)->data(0, Qt::DisplayRole).toString() + "}");
} }
if (items.at(0)->type() == Variable) { if (items.at(0)->type() == Variable) {
result->setText("variable:$V{" + items.at(0)->text(0) + "}"); result->setText("variable:$V{" + items.at(0)->text(0) + "}");

View File

@ -34,13 +34,19 @@
namespace LimeReport { namespace LimeReport {
class DataBrowserTree: public QTreeWidget {
class DataBrowserTree : public QTreeWidget
{
Q_OBJECT Q_OBJECT
public: public:
enum NodeType{Connection, Table, Row, Category, Variable, ExternalVariable}; enum NodeType {
Connection,
Table,
Row,
Category,
Variable,
ExternalVariable
};
explicit DataBrowserTree(QWidget* parent = 0); explicit DataBrowserTree(QWidget* parent = 0);
protected: protected:
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
virtual QMimeData* mimeData(const QList<QTreeWidgetItem*>& items) const; virtual QMimeData* mimeData(const QList<QTreeWidgetItem*>& items) const;
@ -49,7 +55,6 @@ protected:
#endif #endif
public slots: public slots:
}; };
} // namespace LimeReport } // namespace LimeReport

View File

@ -28,18 +28,26 @@
* GNU General Public License for more details. * * GNU General Public License for more details. *
****************************************************************************/ ****************************************************************************/
#include "lrsqleditdialog.h" #include "lrsqleditdialog.h"
#include "lrreportengine_p.h"
#include "ui_lrsqleditdialog.h" #include "ui_lrsqleditdialog.h"
#include "lrreportengine_p.h"
#include <QDebug> #include <QDebug>
#include <QMessageBox> #include <QMessageBox>
#include <QSqlDatabase> #include <QSqlDatabase>
namespace LimeReport { namespace LimeReport {
SQLEditDialog::SQLEditDialog(QWidget *parent, LimeReport::DataSourceManager *dataSources, SQLDialogMode dialogMode) SQLEditDialog::SQLEditDialog(QWidget* parent, LimeReport::DataSourceManager* dataSources,
: QDialog(parent), ui(new Ui::SQLEditDialog), m_datasources(dataSources), m_dialogMode(dialogMode), SQLDialogMode dialogMode):
m_oldDatasourceName(""), m_settings(0), m_ownedSettings(false) { QDialog(parent),
ui(new Ui::SQLEditDialog),
m_datasources(dataSources),
m_dialogMode(dialogMode),
m_oldDatasourceName(""),
m_settings(0),
m_ownedSettings(false)
{
ui->setupUi(this); ui->setupUi(this);
m_masterDatasources = new QCompleter(this); m_masterDatasources = new QCompleter(this);
ui->leMaster->setCompleter(m_masterDatasources); ui->leMaster->setCompleter(m_masterDatasources);
@ -62,13 +70,15 @@ SQLEditDialog::SQLEditDialog(QWidget *parent, LimeReport::DataSourceManager *dat
connect(ui->pbHidePreview, SIGNAL(pressed()), this, SLOT(slotHidePreview())); connect(ui->pbHidePreview, SIGNAL(pressed()), this, SLOT(slotHidePreview()));
} }
SQLEditDialog::~SQLEditDialog() { SQLEditDialog::~SQLEditDialog()
{
delete ui; delete ui;
if (m_settings && m_ownedSettings) if (m_settings && m_ownedSettings)
delete m_settings; delete m_settings;
} }
QSettings *SQLEditDialog::settings() { QSettings* SQLEditDialog::settings()
{
if (m_settings) { if (m_settings) {
return m_settings; return m_settings;
} else { } 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) if (m_settings && m_ownedSettings)
delete m_settings; delete m_settings;
m_settings = value; m_settings = value;
m_ownedSettings = owned; m_ownedSettings = owned;
} }
void SQLEditDialog::accept() { void SQLEditDialog::accept()
{
SQLEditResult result; SQLEditResult result;
if (ui->tabWidget->currentIndex() == 1) { if (ui->tabWidget->currentIndex() == 1) {
@ -99,7 +111,8 @@ void SQLEditDialog::accept() {
result.resultMode = SQLEditResult::SubProxy; result.resultMode = SQLEditResult::SubProxy;
} }
result.connectionName = ConnectionDesc::connectionNameForReport(ui->cbbConnection->currentText()); result.connectionName
= ConnectionDesc::connectionNameForReport(ui->cbbConnection->currentText());
result.datasourceName = ui->leDatasourceName->text(); result.datasourceName = ui->leDatasourceName->text();
result.sql = ui->sqlText->toPlainText(); result.sql = ui->sqlText->toPlainText();
result.csv = ui->csvText->toPlainText(); result.csv = ui->csvText->toPlainText();
@ -114,10 +127,12 @@ void SQLEditDialog::accept() {
if (ui->fieldsMap->rowCount() > 0) { if (ui->fieldsMap->rowCount() > 0) {
for (int i = 0; i < ui->fieldsMap->rowCount(); ++i) { for (int i = 0; i < ui->fieldsMap->rowCount(); ++i) {
LimeReport::FieldsCorrelation fieldsCorrelation; LimeReport::FieldsCorrelation fieldsCorrelation;
fieldsCorrelation.master = fieldsCorrelation.master = ui->fieldsMap->item(i, 0)
ui->fieldsMap->item(i, 0) ? ui->fieldsMap->item(i, 0)->data(Qt::DisplayRole).toString() : ""; ? 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.detail = ui->fieldsMap->item(i, 1)
? ui->fieldsMap->item(i, 1)->data(Qt::DisplayRole).toString()
: "";
result.fieldMap.append(fieldsCorrelation); result.fieldMap.append(fieldsCorrelation);
} }
} }
@ -131,7 +146,8 @@ void SQLEditDialog::accept() {
} }
} }
void SQLEditDialog::showEvent(QShowEvent *) { void SQLEditDialog::showEvent(QShowEvent*)
{
ui->lblInfo->setVisible(false); ui->lblInfo->setVisible(false);
initConnections(); initConnections();
readSettings(); readSettings();
@ -141,7 +157,8 @@ 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()) if (ui->leDatasourceName->text().isEmpty())
throw LimeReport::ReportError(tr("Datasource Name is empty!")); throw LimeReport::ReportError(tr("Datasource Name is empty!"));
if (ui->sqlText->toPlainText().isEmpty() && (!ui->rbProxy)) if (ui->sqlText->toPlainText().isEmpty() && (!ui->rbProxy))
@ -149,20 +166,23 @@ void SQLEditDialog::check() {
if (m_dialogMode == AddMode) { if (m_dialogMode == AddMode) {
if (m_datasources->containsDatasource(ui->leDatasourceName->text())) { if (m_datasources->containsDatasource(ui->leDatasourceName->text())) {
throw LimeReport::ReportError( 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()) { foreach (QString connectionName, QSqlDatabase::connectionNames()) {
ui->cbbConnection->addItem(QIcon(":/databrowser/images/plug-connect.png"), ui->cbbConnection->addItem(QIcon(":/databrowser/images/plug-connect.png"),
ConnectionDesc::connectionNameForUser(connectionName)); ConnectionDesc::connectionNameForUser(connectionName));
} }
foreach (QString connectionName, m_datasources->connectionNames()) { foreach (QString connectionName, m_datasources->connectionNames()) {
connectionName = connectionName = (connectionName.compare(QSqlDatabase::defaultConnection) == 0)
(connectionName.compare(QSqlDatabase::defaultConnection) == 0) ? tr("defaultConnection") : connectionName; ? tr("defaultConnection")
: connectionName;
if (ui->cbbConnection->findText(connectionName, Qt::MatchExactly) == -1) if (ui->cbbConnection->findText(connectionName, Qt::MatchExactly) == -1)
ui->cbbConnection->addItem(QIcon(":/databrowser/images/plug-disconnect.png"), ui->cbbConnection->addItem(QIcon(":/databrowser/images/plug-disconnect.png"),
ConnectionDesc::connectionNameForUser(connectionName)); ConnectionDesc::connectionNameForUser(connectionName));
@ -170,12 +190,15 @@ void SQLEditDialog::initConnections() {
ui->cbbConnection->setCurrentIndex(ui->cbbConnection->findText(m_defaultConnection)); ui->cbbConnection->setCurrentIndex(ui->cbbConnection->findText(m_defaultConnection));
if (!m_oldDatasourceName.isEmpty()) { if (!m_oldDatasourceName.isEmpty()) {
ui->cbbConnection->setCurrentIndex(ui->cbbConnection->findText( ui->cbbConnection->setCurrentIndex(
ConnectionDesc::connectionNameForUser(m_datasources->connectionName(m_oldDatasourceName)))); 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; m_datasources = dataSources;
if (!datasourceName.isEmpty()) { if (!datasourceName.isEmpty()) {
ui->cbSubdetail->setEnabled(true); ui->cbSubdetail->setEnabled(true);
@ -205,24 +228,27 @@ void SQLEditDialog::setDataSources(LimeReport::DataSourceManager *dataSources, Q
if (dataSources->isCSV(datasourceName)) { if (dataSources->isCSV(datasourceName)) {
ui->csvText->setPlainText(dataSources->csvByName(datasourceName)->csvText()); ui->csvText->setPlainText(dataSources->csvByName(datasourceName)->csvText());
ui->leSeparator->setText(dataSources->csvByName(datasourceName)->separator()); ui->leSeparator->setText(dataSources->csvByName(datasourceName)->separator());
ui->cbUseFirstRowAsHeader->setChecked(dataSources->csvByName(datasourceName)->firstRowIsHeader()); ui->cbUseFirstRowAsHeader->setChecked(
dataSources->csvByName(datasourceName)->firstRowIsHeader());
initCSVMode(); initCSVMode();
} }
} }
} }
void SQLEditDialog::setDefaultConnection(QString defaultConnection) { void SQLEditDialog::setDefaultConnection(QString defaultConnection)
{
m_defaultConnection = ConnectionDesc::connectionNameForUser(defaultConnection); m_defaultConnection = ConnectionDesc::connectionNameForUser(defaultConnection);
} }
void SQLEditDialog::slotDataSourceNameEditing() { void SQLEditDialog::slotDataSourceNameEditing()
{
if (m_dialogMode == AddMode) { if (m_dialogMode == AddMode) {
QPalette palette = ui->leDatasourceName->palette(); QPalette palette = ui->leDatasourceName->palette();
if (m_datasources->containsDatasource(ui->leDatasourceName->text())) { if (m_datasources->containsDatasource(ui->leDatasourceName->text())) {
palette.setColor(QPalette::Text, Qt::red); palette.setColor(QPalette::Text, Qt::red);
ui->leDatasourceName->setPalette(palette); ui->leDatasourceName->setPalette(palette);
ui->lblInfo->setText( ui->lblInfo->setText(QString(tr("Datasource with name %1 already exist"))
QString(tr("Datasource with name %1 already exist")).arg(ui->leDatasourceName->text())); .arg(ui->leDatasourceName->text()));
ui->lblInfo->setVisible(true); ui->lblInfo->setVisible(true);
} else { } else {
palette.setColor(QPalette::Text, QApplication::palette().text().color()); 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) { 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->leMaster->setEnabled(checked);
ui->rbProxy->setEnabled(checked); ui->rbProxy->setEnabled(checked);
@ -247,19 +275,25 @@ void SQLEditDialog::on_cbSubdetail_clicked(bool checked) {
initQueryMode(); initQueryMode();
} }
void SQLEditDialog::on_rbProxy_clicked(bool checked) { void SQLEditDialog::on_rbProxy_clicked(bool checked)
{
if (checked) if (checked)
initProxyMode(); initProxyMode();
} }
void SQLEditDialog::on_rbSubQuery_clicked(bool checked) { void SQLEditDialog::on_rbSubQuery_clicked(bool checked)
{
if (checked) if (checked)
initSubQueryMode(); 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->gbSQL->setVisible(true);
ui->gbFieldsMap->setVisible(false); ui->gbFieldsMap->setVisible(false);
ui->pnlChildDatasource->setVisible(false); ui->pnlChildDatasource->setVisible(false);
@ -272,7 +306,8 @@ void SQLEditDialog::initQueryMode() {
ui->tabWidget->addTab(ui->csvTab, tr("CSV")); ui->tabWidget->addTab(ui->csvTab, tr("CSV"));
} }
void SQLEditDialog::initSubQueryMode() { void SQLEditDialog::initSubQueryMode()
{
ui->gbSQL->setVisible(true); ui->gbSQL->setVisible(true);
ui->gbFieldsMap->setVisible(false); ui->gbFieldsMap->setVisible(false);
ui->pnlChildDatasource->setVisible(false); ui->pnlChildDatasource->setVisible(false);
@ -286,7 +321,8 @@ void SQLEditDialog::initSubQueryMode() {
ui->tabWidget->removeTab(1); ui->tabWidget->removeTab(1);
} }
void SQLEditDialog::initProxyMode() { void SQLEditDialog::initProxyMode()
{
ui->gbSQL->setVisible(false); ui->gbSQL->setVisible(false);
ui->gbFieldsMap->setVisible(true); ui->gbFieldsMap->setVisible(true);
ui->pnlChildDatasource->setVisible(true); ui->pnlChildDatasource->setVisible(true);
@ -303,13 +339,14 @@ void SQLEditDialog::initProxyMode() {
void SQLEditDialog::initCSVMode() { ui->tabWidget->setCurrentWidget(ui->csvTab); } void SQLEditDialog::initCSVMode() { ui->tabWidget->setCurrentWidget(ui->csvTab); }
void SQLEditDialog::slotPreviewData() { void SQLEditDialog::slotPreviewData()
{
if (ui->cbbConnection->currentText().isEmpty()) { if (ui->cbbConnection->currentText().isEmpty()) {
QMessageBox::critical(this, tr("Attention"), tr("Connection is not specified")); QMessageBox::critical(this, tr("Attention"), tr("Connection is not specified"));
return; return;
} }
m_previewModel = m_previewModel = m_datasources->previewSQL(
m_datasources->previewSQL(ConnectionDesc::connectionNameForReport(ui->cbbConnection->currentText()), ConnectionDesc::connectionNameForReport(ui->cbbConnection->currentText()),
ui->sqlText->toPlainText(), ui->leMaster->text()); ui->sqlText->toPlainText(), ui->leMaster->text());
if (m_previewModel) { if (m_previewModel) {
ui->tvPreview->setModel(m_previewModel.data()); ui->tvPreview->setModel(m_previewModel.data());
@ -325,7 +362,8 @@ void SQLEditDialog::slotPreviewData() {
void SQLEditDialog::slotHidePreview() { hidePreview(); } void SQLEditDialog::slotHidePreview() { hidePreview(); }
void SQLEditDialog::writeSetting() { void SQLEditDialog::writeSetting()
{
if (settings() != 0) { if (settings() != 0) {
settings()->beginGroup("SQLEditor"); settings()->beginGroup("SQLEditor");
settings()->setValue("Geometry", saveGeometry()); settings()->setValue("Geometry", saveGeometry());
@ -333,7 +371,8 @@ void SQLEditDialog::writeSetting() {
} }
} }
void SQLEditDialog::readSettings() { void SQLEditDialog::readSettings()
{
if (settings() == 0) if (settings() == 0)
return; return;
settings()->beginGroup("SQLEditor"); settings()->beginGroup("SQLEditor");
@ -344,12 +383,16 @@ void SQLEditDialog::readSettings() {
settings()->endGroup(); settings()->endGroup();
} }
void SQLEditDialog::hidePreview() { void SQLEditDialog::hidePreview()
{
ui->gbDataPreview->setVisible(false); ui->gbDataPreview->setVisible(false);
ui->pbPreview->setText(tr("Preview")); ui->pbPreview->setText(tr("Preview"));
ui->pbHidePreview->setVisible(false); 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 } // namespace LimeReport

View File

@ -30,13 +30,15 @@
#ifndef LRSQLEDITDIALOG_H #ifndef LRSQLEDITDIALOG_H
#define LRSQLEDITDIALOG_H #define LRSQLEDITDIALOG_H
#include <stdexcept>
#include <QDialog>
#include <QCompleter>
#include <QSettings>
#include "lrreportengine_p.h"
#include "lrdatasourcemanager.h"
#include "lrdatadesignintf.h" #include "lrdatadesignintf.h"
#include "lrdatasourcemanager.h"
#include "lrreportengine_p.h"
#include <QCompleter>
#include <QDialog>
#include <QSettings>
#include <stdexcept>
namespace LimeReport { namespace LimeReport {
@ -46,13 +48,16 @@ namespace Ui {
struct SQLEditResult; struct SQLEditResult;
class SQLEditDialog : public QDialog class SQLEditDialog: public QDialog {
{
Q_OBJECT Q_OBJECT
public: public:
enum SQLDialogMode {AddMode,EditMode}; enum SQLDialogMode {
explicit SQLEditDialog(QWidget *parent, LimeReport::DataSourceManager* dataSources,SQLDialogMode dialogMode); AddMode,
EditMode
};
explicit SQLEditDialog(QWidget* parent, LimeReport::DataSourceManager* dataSources,
SQLDialogMode dialogMode);
void setDataSources(LimeReport::DataSourceManager* dataSources, QString datasourceName = ""); void setDataSources(LimeReport::DataSourceManager* dataSources, QString datasourceName = "");
void setDefaultConnection(QString defaultConnection); void setDefaultConnection(QString defaultConnection);
~SQLEditDialog(); ~SQLEditDialog();
@ -60,6 +65,7 @@ public:
void setSettings(QSettings* value, bool owned = false); void setSettings(QSettings* value, bool owned = false);
signals: signals:
void signalSqlEditingFinished(SQLEditResult result); void signalSqlEditingFinished(SQLEditResult result);
protected: protected:
void showEvent(QShowEvent*); void showEvent(QShowEvent*);
void closeEvent(QCloseEvent*); void closeEvent(QCloseEvent*);
@ -80,10 +86,12 @@ private slots:
void initCSVMode(); void initCSVMode();
void slotPreviewData(); void slotPreviewData();
void slotHidePreview(); void slotHidePreview();
private: private:
void writeSetting(); void writeSetting();
void readSettings(); void readSettings();
void hidePreview(); void hidePreview();
private: private:
Ui::SQLEditDialog* ui; Ui::SQLEditDialog* ui;
LimeReport::DataSourceManager* m_datasources; LimeReport::DataSourceManager* m_datasources;
@ -97,7 +105,13 @@ private:
}; };
struct SQLEditResult { struct SQLEditResult {
enum ResultMode{Query, SubQuery, SubProxy, CSVText, Undefined}; enum ResultMode {
Query,
SubQuery,
SubProxy,
CSVText,
Undefined
};
QString connectionName; QString connectionName;
QString datasourceName; QString datasourceName;
QString oldDatasourceName; QString oldDatasourceName;

View File

@ -29,12 +29,15 @@
****************************************************************************/ ****************************************************************************/
#include "lrvariabledialog.h" #include "lrvariabledialog.h"
#include "ui_lrvariabledialog.h" #include "ui_lrvariabledialog.h"
#include "lrglobal.h" #include "lrglobal.h"
#include "lrvariablesholder.h" #include "lrvariablesholder.h"
#include <stdexcept>
#include <QMessageBox> #include <QMessageBox>
#include <QMetaEnum> #include <QMetaEnum>
#include <stdexcept>
LRVariableDialog::LRVariableDialog(QWidget* parent): LRVariableDialog::LRVariableDialog(QWidget* parent):
QDialog(parent), QDialog(parent),
ui(new Ui::LRVariableDialog), ui(new Ui::LRVariableDialog),
@ -45,7 +48,8 @@ LRVariableDialog::LRVariableDialog(QWidget *parent) :
{ {
ui->setupUi(this); 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); 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->addItem(enumerator.key(i));
@ -54,10 +58,7 @@ LRVariableDialog::LRVariableDialog(QWidget *parent) :
// ui->lblType->setVisible(false); // ui->lblType->setVisible(false);
} }
LRVariableDialog::~LRVariableDialog() LRVariableDialog::~LRVariableDialog() { delete ui; }
{
delete ui;
}
void LRVariableDialog::setVariableContainer(LimeReport::IVariablesContainer* value) void LRVariableDialog::setVariableContainer(LimeReport::IVariablesContainer* value)
{ {
@ -74,14 +75,18 @@ void LRVariableDialog::setVariableName(const QString &value)
void LRVariableDialog::showEvent(QShowEvent*) void LRVariableDialog::showEvent(QShowEvent*)
{ {
ui->leName->setText(m_variableName); ui->leName->setText(m_variableName);
static int enumIndex = LimeReport::Enums::staticMetaObject.indexOfEnumerator("VariableDataType"); static int enumIndex
= LimeReport::Enums::staticMetaObject.indexOfEnumerator("VariableDataType");
QMetaEnum enumerator = LimeReport::Enums::staticMetaObject.enumerator(enumIndex); 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()); ui->leValue->setPlainText(m_variablesContainer->variable(m_variableName).toString());
#if QT_VERSION < 0x050000 #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 #else
ui->cbbType->setCurrentText(enumerator.valueToKey(m_variablesContainer->variableDataType(m_variableName))); ui->cbbType->setCurrentText(
enumerator.valueToKey(m_variablesContainer->variableDataType(m_variableName)));
#endif #endif
ui->cbbMandatory->setChecked(m_variablesContainer->variableIsMandatory(m_variableName)); ui->cbbMandatory->setChecked(m_variablesContainer->variableIsMandatory(m_variableName));
} }
@ -90,7 +95,8 @@ void LRVariableDialog::showEvent(QShowEvent *)
void LRVariableDialog::accept() void LRVariableDialog::accept()
{ {
try { try {
static int enumIndex = LimeReport::Enums::staticMetaObject.indexOfEnumerator("VariableDataType"); static int enumIndex
= LimeReport::Enums::staticMetaObject.indexOfEnumerator("VariableDataType");
QMetaEnum enumerator = LimeReport::Enums::staticMetaObject.enumerator(enumIndex); QMetaEnum enumerator = LimeReport::Enums::staticMetaObject.enumerator(enumIndex);
if (m_variablesContainer && !ui->leName->text().isEmpty()) { if (m_variablesContainer && !ui->leName->text().isEmpty()) {
@ -99,16 +105,19 @@ void LRVariableDialog::accept()
m_variablesContainer->changeVariable(m_oldVariableName, value()); m_variablesContainer->changeVariable(m_oldVariableName, value());
} else { } else {
m_variablesContainer->deleteVariable(m_oldVariableName); m_variablesContainer->deleteVariable(m_oldVariableName);
m_variablesContainer->addVariable(ui->leName->text(),value(), LimeReport::VarDesc::Report); m_variablesContainer->addVariable(ui->leName->text(), value(),
LimeReport::VarDesc::Report);
} }
} else { } else {
m_variablesContainer->addVariable(ui->leName->text(),value(), LimeReport::VarDesc::Report); m_variablesContainer->addVariable(ui->leName->text(), value(),
LimeReport::VarDesc::Report);
} }
m_variablesContainer->setVarableMandatory(ui->leName->text(),ui->cbbMandatory->isChecked()); m_variablesContainer->setVarableMandatory(ui->leName->text(),
ui->cbbMandatory->isChecked());
m_variablesContainer->setVariableDataType( m_variablesContainer->setVariableDataType(
ui->leName->text(), ui->leName->text(),
LimeReport::VariableDataType(enumerator.keysToValue(ui->cbbType->currentText().toLatin1())) LimeReport::VariableDataType(
); enumerator.keysToValue(ui->cbbType->currentText().toLatin1())));
emit signalVariableAccepted(ui->leName->text()); emit signalVariableAccepted(ui->leName->text());
QDialog::accept(); QDialog::accept();
} }
@ -117,7 +126,4 @@ void LRVariableDialog::accept()
} }
} }
QVariant LRVariableDialog::value() QVariant LRVariableDialog::value() { return ui->leValue->toPlainText(); }
{
return ui->leValue->toPlainText();
}

View File

@ -30,15 +30,15 @@
#ifndef LRVARIABLEDIALOG_H #ifndef LRVARIABLEDIALOG_H
#define LRVARIABLEDIALOG_H #define LRVARIABLEDIALOG_H
#include <QDialog>
#include "lrvariablesholder.h" #include "lrvariablesholder.h"
#include <QDialog>
namespace Ui { namespace Ui {
class LRVariableDialog; class LRVariableDialog;
} }
class LRVariableDialog : public QDialog class LRVariableDialog: public QDialog {
{
Q_OBJECT Q_OBJECT
public: public:
@ -46,14 +46,17 @@ public:
~LRVariableDialog(); ~LRVariableDialog();
void setVariableContainer(LimeReport::IVariablesContainer* value); void setVariableContainer(LimeReport::IVariablesContainer* value);
void setVariableName(const QString& value); void setVariableName(const QString& value);
protected: protected:
void showEvent(QShowEvent*); void showEvent(QShowEvent*);
private slots: private slots:
void accept(); void accept();
signals: signals:
void signalVariableAccepted(const QString& variable); void signalVariableAccepted(const QString& variable);
private: private:
QVariant value(); QVariant value();
private: private:
Ui::LRVariableDialog* ui; Ui::LRVariableDialog* ui;
QString m_variableName; QString m_variableName;

View File

@ -1,20 +1,17 @@
#include "lrdialogdesigner.h" #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 <QAction>
#include <QDebug> #include <QDebug>
#include <QDesignerActionEditorInterface>
#include <QDesignerComponents>
#include <QDesignerFormEditorInterface>
#include <QDesignerFormEditorPluginInterface>
#include <QDesignerFormWindowInterface>
#include <QDesignerFormWindowManagerInterface>
#include <QDesignerObjectInspectorInterface>
#include <QDesignerPropertyEditorInterface>
#include <QDesignerWidgetBoxInterface>
#include <QPluginLoader>
#include <QVBoxLayout> #include <QVBoxLayout>
#if HAVE_QT5 #if HAVE_QT5
@ -22,10 +19,12 @@
#endif #endif
#if HAVE_QT4 #if HAVE_QT4
#include "qdesigner_integration_p.h" #include "qdesigner_integration_p.h"
#include <QtDesigner/QDesignerIntegrationInterface> #include <QtDesigner/QDesignerIntegrationInterface>
#endif #endif
#include "pluginmanager_p.h" #include "pluginmanager_p.h"
#include "widgethost.h" #include "widgethost.h"
#include <abstractobjectinspector.h> #include <abstractobjectinspector.h>
namespace LimeReport { namespace LimeReport {
@ -43,17 +42,18 @@ DialogDesignerManager::DialogDesignerManager(QObject *parent) : QObject(parent)
m_editWidgetsAction->setCheckable(true); m_editWidgetsAction->setCheckable(true);
m_editWidgetsAction->setChecked(true); m_editWidgetsAction->setChecked(true);
connect(m_editWidgetsAction, SIGNAL(triggered()), this, SLOT(slotEditWidgets())); connect(m_editWidgetsAction, SIGNAL(triggered()), this, SLOT(slotEditWidgets()));
connect(m_formEditor->formWindowManager(), SIGNAL(activeFormWindowChanged(QDesignerFormWindowInterface*)), connect(m_formEditor->formWindowManager(),
this, SLOT(slotActiveFormWindowChanged(QDesignerFormWindowInterface*)) ); SIGNAL(activeFormWindowChanged(QDesignerFormWindowInterface*)), this,
SLOT(slotActiveFormWindowChanged(QDesignerFormWindowInterface*)));
m_modes = new QActionGroup(this); m_modes = new QActionGroup(this);
m_modes->setExclusive(true); m_modes->setExclusive(true);
m_modes->addAction(m_editWidgetsAction); m_modes->addAction(m_editWidgetsAction);
foreach ( QObject* o, QPluginLoader::staticInstances() << m_formEditor->pluginManager()->instances() ) foreach (QObject* o,
{ QPluginLoader::staticInstances() << m_formEditor->pluginManager()->instances()) {
if ( QDesignerFormEditorPluginInterface* fep = qobject_cast<QDesignerFormEditorPluginInterface*>( o ) ) if (QDesignerFormEditorPluginInterface* fep
{ = qobject_cast<QDesignerFormEditorPluginInterface*>(o)) {
if (!fep->isInitialized()) if (!fep->isInitialized())
fep->initialize(m_formEditor); fep->initialize(m_formEditor);
fep->action()->setCheckable(true); fep->action()->setCheckable(true);
@ -75,27 +75,31 @@ DialogDesignerManager::DialogDesignerManager(QObject *parent) : QObject(parent)
m_objectInspector->setObjectName(QLatin1String("ObjectInspector")); m_objectInspector->setObjectName(QLatin1String("ObjectInspector"));
m_formEditor->setObjectInspector(m_objectInspector); m_formEditor->setObjectInspector(m_objectInspector);
m_designerToolWindows.append(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 = QDesignerComponents::createPropertyEditor(m_formEditor, 0);
m_propertyEditor->setWindowTitle(tr("Property Editor")); m_propertyEditor->setWindowTitle(tr("Property Editor"));
m_propertyEditor->setObjectName(QLatin1String("PropertyEditor")); m_propertyEditor->setObjectName(QLatin1String("PropertyEditor"));
m_formEditor->setPropertyEditor(m_propertyEditor); m_formEditor->setPropertyEditor(m_propertyEditor);
m_designerToolWindows.append(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 = QDesignerComponents::createSignalSlotEditor(m_formEditor, 0);
m_signalSlotEditor->setWindowTitle(tr("Signals && Slots Editor")); m_signalSlotEditor->setWindowTitle(tr("Signals && Slots Editor"));
m_signalSlotEditor->setObjectName(QLatin1String("SignalsAndSlotsEditor")); m_signalSlotEditor->setObjectName(QLatin1String("SignalsAndSlotsEditor"));
m_designerToolWindows.append(m_signalSlotEditor); 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 = QDesignerComponents::createResourceEditor(m_formEditor, 0);
m_resourcesEditor->setWindowTitle(tr("Resource Editor")); m_resourcesEditor->setWindowTitle(tr("Resource Editor"));
m_resourcesEditor->setObjectName(QLatin1String("ResourceEditor")); m_resourcesEditor->setObjectName(QLatin1String("ResourceEditor"));
m_designerToolWindows.append(m_resourcesEditor); 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 = QDesignerComponents::createActionEditor(m_formEditor, 0);
m_actionEditor->setWindowTitle(tr("Action Editor")); m_actionEditor->setWindowTitle(tr("Action Editor"));
@ -110,7 +114,6 @@ DialogDesignerManager::DialogDesignerManager(QObject *parent) : QObject(parent)
m_designerIntegration = new QDesignerIntegration(m_formEditor, this); m_designerIntegration = new QDesignerIntegration(m_formEditor, this);
#endif #endif
m_formEditor->setIntegration(m_designerIntegration); m_formEditor->setIntegration(m_designerIntegration);
} }
DialogDesignerManager::~DialogDesignerManager() DialogDesignerManager::~DialogDesignerManager()
@ -145,7 +148,8 @@ void DialogDesignerManager::initToolBar(QToolBar *tb)
tb->addAction(m_formEditor->formWindowManager()->actionSplitHorizontal()); tb->addAction(m_formEditor->formWindowManager()->actionSplitHorizontal());
tb->addAction(m_formEditor->formWindowManager()->actionSplitVertical()); tb->addAction(m_formEditor->formWindowManager()->actionSplitVertical());
tb->addAction(m_formEditor->formWindowManager()->actionGridLayout()); 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()->actionFormLayout());
tb->addAction(m_formEditor->formWindowManager()->actionBreakLayout()); tb->addAction(m_formEditor->formWindowManager()->actionBreakLayout());
tb->addAction(m_formEditor->formWindowManager()->actionAdjustSize()); tb->addAction(m_formEditor->formWindowManager()->actionAdjustSize());
@ -153,7 +157,8 @@ void DialogDesignerManager::initToolBar(QToolBar *tb)
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); wnd->setContents(content);
m_formEditor->formWindowManager()->setActiveFormWindow(wnd); m_formEditor->formWindowManager()->setActiveFormWindow(wnd);
m_formEditor->objectInspector()->setFormWindow(wnd); m_formEditor->objectInspector()->setFormWindow(wnd);
@ -162,13 +167,13 @@ QWidget *DialogDesignerManager::createFormEditor(const QString &content)
DialogDesigner* dialogDesigner = new DialogDesigner(wnd, m_formEditor); DialogDesigner* dialogDesigner = new DialogDesigner(wnd, m_formEditor);
connect(dialogDesigner, SIGNAL(dialogChanged(QString)), this, SIGNAL(dialogChanged(QString))); 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*))); connect(dialogDesigner, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)));
m_dialogDesigners.append(dialogDesigner); m_dialogDesigners.append(dialogDesigner);
return dialogDesigner; return dialogDesigner;
} }
QByteArray DialogDesignerManager::getDialogDescription(QWidget* form) QByteArray DialogDesignerManager::getDialogDescription(QWidget* form)
@ -199,35 +204,17 @@ void DialogDesignerManager::setDirty(bool value)
} }
} }
QWidget* DialogDesignerManager::widgetBox() const QWidget* DialogDesignerManager::widgetBox() const { return m_widgetBox; }
{
return m_widgetBox;
}
QWidget* DialogDesignerManager::actionEditor() const QWidget* DialogDesignerManager::actionEditor() const { return m_actionEditor; }
{
return m_actionEditor;
}
QWidget* DialogDesignerManager::propertyEditor() const QWidget* DialogDesignerManager::propertyEditor() const { return m_propertyEditor; }
{
return m_propertyEditor;
}
QWidget* DialogDesignerManager::objectInspector() const QWidget* DialogDesignerManager::objectInspector() const { return m_objectInspector; }
{
return m_objectInspector;
}
QWidget *DialogDesignerManager::signalSlotEditor() const QWidget* DialogDesignerManager::signalSlotEditor() const { return m_signalSlotEditor; }
{
return m_signalSlotEditor;
}
QWidget *DialogDesignerManager::resourcesEditor() const QWidget* DialogDesignerManager::resourcesEditor() const { return m_resourcesEditor; }
{
return m_resourcesEditor;
}
void DialogDesignerManager::slotObjectDestroyed(QObject* object) void DialogDesignerManager::slotObjectDestroyed(QObject* object)
{ {
@ -243,9 +230,9 @@ void DialogDesignerManager::slotObjectDestroyed(QObject* object)
} }
for (int i = 0; i < m_designerToolWindows.size(); ++i) { for (int i = 0; i < m_designerToolWindows.size(); ++i) {
m_designerToolWindows[i] = m_designerToolWindows[i] == object ? 0 : m_designerToolWindows[i]; m_designerToolWindows[i]
= m_designerToolWindows[i] == object ? 0 : m_designerToolWindows[i];
} }
} }
void DialogDesignerManager::slotEditWidgets() void DialogDesignerManager::slotEditWidgets()
@ -276,8 +263,11 @@ QString DialogDesignerManager::iconPathByName(const QString &name)
return ""; return "";
} }
DialogDesigner::DialogDesigner(QDesignerFormWindowInterface* wnd, QDesignerFormEditorInterface* formEditor, QWidget *parent, Qt::WindowFlags flags) DialogDesigner::DialogDesigner(QDesignerFormWindowInterface* wnd,
:QWidget(parent, flags), m_formEditor(formEditor) QDesignerFormEditorInterface* formEditor, QWidget* parent,
Qt::WindowFlags flags):
QWidget(parent, flags),
m_formEditor(formEditor)
{ {
m_dialogName = wnd->mainContainer()->objectName(); m_dialogName = wnd->mainContainer()->objectName();
connect(wnd, SIGNAL(changed()), this, SLOT(slotDialogChanged())); connect(wnd, SIGNAL(changed()), this, SLOT(slotDialogChanged()));
@ -289,30 +279,17 @@ DialogDesigner::DialogDesigner(QDesignerFormWindowInterface* wnd, QDesignerFormE
QVBoxLayout* l = new QVBoxLayout(this); QVBoxLayout* l = new QVBoxLayout(this);
l->addWidget(m_designerHolder); l->addWidget(m_designerHolder);
setLayout(l); setLayout(l);
} }
DialogDesigner::~DialogDesigner() { } DialogDesigner::~DialogDesigner() { }
QString DialogDesigner::dialogName() const QString DialogDesigner::dialogName() const { return m_dialogName; }
{
return m_dialogName;
}
void DialogDesigner::setDialogName(const QString &dialogName) void DialogDesigner::setDialogName(const QString& dialogName) { m_dialogName = dialogName; }
{
m_dialogName = dialogName;
}
bool DialogDesigner::isChanged() bool DialogDesigner::isChanged() { return m_designerHolder->formWindow()->isDirty(); }
{
return m_designerHolder->formWindow()->isDirty();
}
void DialogDesigner::setChanged(bool value) void DialogDesigner::setChanged(bool value) { m_designerHolder->formWindow()->setDirty(value); }
{
m_designerHolder->formWindow()->setDirty(value);
}
QByteArray DialogDesigner::dialogContent() QByteArray DialogDesigner::dialogContent()
{ {
@ -349,8 +326,10 @@ void DialogDesigner::slotDialogChanged()
{ {
Q_ASSERT(m_designerHolder != NULL); Q_ASSERT(m_designerHolder != NULL);
if (m_designerHolder && m_designerHolder->formWindow()) { if (m_designerHolder && m_designerHolder->formWindow()) {
if ( m_designerHolder->formWindow()->mainContainer()->objectName().compare(m_dialogName) !=0 ){ if (m_designerHolder->formWindow()->mainContainer()->objectName().compare(m_dialogName)
emit dialogNameChanged(m_dialogName, m_designerHolder->formWindow()->mainContainer()->objectName()); != 0) {
emit dialogNameChanged(m_dialogName,
m_designerHolder->formWindow()->mainContainer()->objectName());
m_dialogName = m_designerHolder->formWindow()->mainContainer()->objectName(); m_dialogName = m_designerHolder->formWindow()->mainContainer()->objectName();
} }
emit dialogChanged(m_dialogName); emit dialogChanged(m_dialogName);
@ -358,4 +337,4 @@ void DialogDesigner::slotDialogChanged()
} }
} }
} } // namespace LimeReport

View File

@ -1,10 +1,10 @@
#ifndef DIALOGDESIGNER_H #ifndef DIALOGDESIGNER_H
#define DIALOGDESIGNER_H #define DIALOGDESIGNER_H
#include <QObject>
#include <QVector>
#include <QToolBar>
#include <QActionGroup> #include <QActionGroup>
#include <QObject>
#include <QToolBar>
#include <QVector>
class QDesignerFormEditorInterface; class QDesignerFormEditorInterface;
class QDesignerFormWindowInterface; class QDesignerFormWindowInterface;
@ -24,7 +24,8 @@ namespace LimeReport{
class DialogDesigner: public QWidget { class DialogDesigner: public QWidget {
Q_OBJECT Q_OBJECT
public: 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(); ~DialogDesigner();
QString dialogName() const; QString dialogName() const;
void setDialogName(const QString& dialogName); void setDialogName(const QString& dialogName);
@ -40,14 +41,14 @@ signals:
private slots: private slots:
void slotMainContainerNameChanged(QString newName); void slotMainContainerNameChanged(QString newName);
void slotDialogChanged(); void slotDialogChanged();
private: private:
QString m_dialogName; QString m_dialogName;
SharedTools::WidgetHost* m_designerHolder; SharedTools::WidgetHost* m_designerHolder;
QDesignerFormEditorInterface* m_formEditor; QDesignerFormEditorInterface* m_formEditor;
}; };
class DialogDesignerManager : public QObject class DialogDesignerManager: public QObject {
{
Q_OBJECT Q_OBJECT
public: public:
explicit DialogDesignerManager(QObject* parent = 0); explicit DialogDesignerManager(QObject* parent = 0);
@ -70,8 +71,10 @@ private slots:
void slotObjectDestroyed(QObject* object); void slotObjectDestroyed(QObject* object);
void slotEditWidgets(); void slotEditWidgets();
void slotActiveFormWindowChanged(QDesignerFormWindowInterface* formWindow); void slotActiveFormWindowChanged(QDesignerFormWindowInterface* formWindow);
private: private:
QString iconPathByName(const QString& name); QString iconPathByName(const QString& name);
private: private:
QDesignerFormEditorInterface* m_formEditor; QDesignerFormEditorInterface* m_formEditor;
QDesignerIntegrationInterface* m_designerIntegration; QDesignerIntegrationInterface* m_designerIntegration;

View File

@ -1,25 +1,29 @@
#include <QPrinter>
#include "lrpdfexporter.h" #include "lrpdfexporter.h"
#include "lrexportersfactory.h" #include "lrexportersfactory.h"
#include "lrreportengine_p.h" #include "lrreportengine_p.h"
#include <QPrinter>
namespace { namespace {
LimeReport::ReportExporterInterface* createPDFExporter(LimeReport::ReportEnginePrivate* parent){ LimeReport::ReportExporterInterface* createPDFExporter(LimeReport::ReportEnginePrivate* parent)
{
return new LimeReport::PDFExporter(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> &params) bool PDFExporter::exportPages(ReportPages pages, const QString& fileName,
const QMap<QString, QVariant>& params)
{ {
Q_UNUSED(params); Q_UNUSED(params);
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
@ -35,4 +39,4 @@ bool PDFExporter::exportPages(ReportPages pages, const QString &fileName, const
return false; return false;
} }
} } // namespace LimeReport

View File

@ -1,31 +1,24 @@
#ifndef LRPDFEXPORTER_H #ifndef LRPDFEXPORTER_H
#define LRPDFEXPORTER_H #define LRPDFEXPORTER_H
#include <QObject>
#include "lrexporterintf.h" #include "lrexporterintf.h"
#include <QObject>
namespace LimeReport { namespace LimeReport {
class ReportEnginePrivate; class ReportEnginePrivate;
class PDFExporter : public QObject, public ReportExporterInterface class PDFExporter: public QObject, public ReportExporterInterface {
{
Q_OBJECT Q_OBJECT
public: public:
explicit PDFExporter(ReportEnginePrivate* parent = NULL); explicit PDFExporter(ReportEnginePrivate* parent = NULL);
// ReportExporterInterface interface // ReportExporterInterface interface
bool exportPages(ReportPages pages, const QString &fileName, const QMap<QString, QVariant> &params); bool exportPages(ReportPages pages, const QString& fileName,
QString exporterName() const QMap<QString, QVariant>& params);
{ QString exporterName() { return "PDF"; }
return "PDF"; QString exporterFileExt() { return "pdf"; }
} QString hint() { return tr("Export to PDF"); }
QString exporterFileExt()
{
return "pdf";
}
QString hint()
{
return tr("Export to PDF");
}
private: private:
ReportEnginePrivate* m_reportEngine; ReportEnginePrivate* m_reportEngine;
}; };

View File

@ -10,12 +10,8 @@ void GridLinesChart::paintChart(QPainter *painter, QRectF chartRect)
const qreal valuesVMargin = this->valuesVMargin(painter); const qreal valuesVMargin = this->valuesVMargin(painter);
QRectF gridRect = chartRect.adjusted( QRectF gridRect
hPadding, = chartRect.adjusted(hPadding, vPadding + valuesVMargin * 2, -hPadding * 3, -vPadding * 3);
vPadding + valuesVMargin * 2,
-hPadding * 3,
-vPadding * 3
);
if (!m_chartItem->horizontalAxisOnTop()) { if (!m_chartItem->horizontalAxisOnTop()) {
// If horizontal axis is on the bottom, move grid a little up // If horizontal axis is on the bottom, move grid a little up
@ -23,9 +19,9 @@ void GridLinesChart::paintChart(QPainter *painter, QRectF chartRect)
} }
// Adapt font for horizontal axis // Adapt font for horizontal axis
painter->setFont(adaptFont((gridRect.width() - this->valuesHMargin(painter)) / xAxisData().segmentCount() * 0.8, painter->setFont(adaptFont((gridRect.width() - this->valuesHMargin(painter))
painter->font(), / xAxisData().segmentCount() * 0.8,
xAxisData())); painter->font(), xAxisData()));
const qreal valuesHMargin = this->valuesHMargin(painter); const qreal valuesHMargin = this->valuesHMargin(painter);
@ -34,15 +30,13 @@ void GridLinesChart::paintChart(QPainter *painter, QRectF chartRect)
paintGrid(painter, gridRect); paintGrid(painter, gridRect);
paintSerialLines( paintSerialLines(painter, gridRect.adjusted(hPadding + valuesHMargin, 0, 0, 0));
painter,
gridRect.adjusted(hPadding + valuesHMargin, 0, 0, 0)
);
} }
void GridLinesChart::paintSerialLines(QPainter* painter, QRectF barsRect) void GridLinesChart::paintSerialLines(QPainter* painter, QRectF barsRect)
{ {
if (valuesCount() == 0) return; if (valuesCount() == 0)
return;
painter->save(); painter->save();
painter->setRenderHint(QPainter::Antialiasing, true); painter->setRenderHint(QPainter::Antialiasing, true);
@ -109,4 +103,4 @@ void GridLinesChart::paintSerialLines(QPainter* painter, QRectF barsRect)
painter->restore(); painter->restore();
} }
} } // namespace LimeReport

View File

@ -12,6 +12,6 @@ public:
private: private:
void paintSerialLines(QPainter* painter, QRectF barsRect); void paintSerialLines(QPainter* painter, QRectF barsRect);
}; };
} } // namespace LimeReport
#endif // GRIDLINESCHART_H #endif // GRIDLINESCHART_H

View File

@ -8,33 +8,28 @@ void HorizontalBarChart::paintChart(QPainter *painter, QRectF chartRect)
const qreal valuesVMargin = this->valuesVMargin(painter); const qreal valuesVMargin = this->valuesVMargin(painter);
QRectF calcRect = verticalLabelsRect(painter, chartRect.adjusted( QRectF calcRect = verticalLabelsRect(
hPadding(chartRect), painter,
vPadding(chartRect) * 2, chartRect.adjusted(hPadding(chartRect), vPadding(chartRect) * 2, -(chartRect.width() * 0.9),
-(chartRect.width() * 0.9), -(vPadding(chartRect) * 2 + valuesVMargin)));
-(vPadding(chartRect) * 2 + valuesVMargin)
));
qreal barsShift = calcRect.width(); qreal barsShift = calcRect.width();
paintHorizontalGrid(painter, chartRect.adjusted( paintHorizontalGrid(painter,
hPadding(chartRect) + barsShift, chartRect.adjusted(hPadding(chartRect) + barsShift, vPadding(chartRect),
vPadding(chartRect), -(hPadding(chartRect)), -vPadding(chartRect)));
-(hPadding(chartRect)),
-vPadding(chartRect)));
paintHorizontalBars(painter, chartRect.adjusted( paintHorizontalBars(painter,
hPadding(chartRect) + barsShift, chartRect.adjusted(hPadding(chartRect) + barsShift, vPadding(chartRect) * 2,
vPadding(chartRect) * 2, -(hPadding(chartRect)), -(vPadding(chartRect) * 2)));
-(hPadding(chartRect)),
-(vPadding(chartRect) * 2) ));
paintVerticalLabels(painter, calcRect); 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->save();
painter->setRenderHint(QPainter::Antialiasing, false); painter->setRenderHint(QPainter::Antialiasing, false);
@ -44,7 +39,9 @@ void HorizontalBarChart::paintHorizontalBars(QPainter *painter, QRectF barsRect)
const qreal verticalOffset = painter->fontMetrics().height(); const qreal verticalOffset = painter->fontMetrics().height();
qreal vStep = (barsRect.height() - verticalOffset) / valuesCount() / seriesCount(); 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(); qreal curVOffset = barsRect.top();
@ -55,7 +52,8 @@ void HorizontalBarChart::paintHorizontalBars(QPainter *painter, QRectF barsRect)
painter->setBrush(series->color()); painter->setBrush(series->color());
qreal y = curVOffset; qreal y = curVOffset;
foreach (qreal value, series->data()->values()) { foreach (qreal value, series->data()->values()) {
painter->drawRect(QRectF((-minValue()*hStep)+barsRect.left(), y, value*hStep, vStep)); painter->drawRect(
QRectF((-minValue() * hStep) + barsRect.left(), y, value * hStep, vStep));
y += vStep * seriesCount(); y += vStep * seriesCount();
} }
curVOffset += vStep; curVOffset += vStep;
@ -67,9 +65,11 @@ void HorizontalBarChart::paintHorizontalBars(QPainter *painter, QRectF barsRect)
} }
int curColor = 0; int curColor = 0;
for (int i = 0; i < 9; ++i) { for (int i = 0; i < 9; ++i) {
if (curColor==3) curColor=0; if (curColor == 3)
curColor = 0;
painter->setBrush(color_map[curColor]); painter->setBrush(color_map[curColor]);
painter->drawRect(QRectF(barsRect.left(), curVOffset, designValues()[i]*hStep, vStep)); painter->drawRect(
QRectF(barsRect.left(), curVOffset, designValues()[i] * hStep, vStep));
curVOffset += vStep; curVOffset += vStep;
curColor++; curColor++;
} }
@ -77,4 +77,4 @@ void HorizontalBarChart::paintHorizontalBars(QPainter *painter, QRectF barsRect)
painter->restore(); painter->restore();
} }
} } // namespace LimeReport

View File

@ -11,59 +11,42 @@ void LinesChart::paintChart(QPainter *painter, QRectF chartRect)
QRectF calcRect = horizontalLabelsRect( QRectF calcRect = horizontalLabelsRect(
painter, painter,
chartRect.adjusted( chartRect.adjusted(hPadding(chartRect) * 2 + valuesHMargin,
hPadding(chartRect) * 2 + valuesHMargin, chartRect.height()
chartRect.height() - (painter->fontMetrics().height() + vPadding(chartRect)*2), - (painter->fontMetrics().height() + vPadding(chartRect) * 2),
-(hPadding(chartRect) * 2), -(hPadding(chartRect) * 2), -vPadding(chartRect)));
-vPadding(chartRect)
)
);
qreal barsShift = calcRect.height(); qreal barsShift = calcRect.height();
paintVerticalGrid( paintVerticalGrid(painter,
painter, chartRect.adjusted(hPadding(chartRect), vPadding(chartRect) + valuesVMargin,
chartRect.adjusted( -hPadding(chartRect), -(vPadding(chartRect) + barsShift)));
hPadding(chartRect), paintSerialLines(painter,
vPadding(chartRect) + valuesVMargin, chartRect.adjusted(hPadding(chartRect) * 2 + valuesHMargin,
-hPadding(chartRect),
-(vPadding(chartRect) + barsShift)
)
);
paintSerialLines(
painter,
chartRect.adjusted(
hPadding(chartRect) * 2 + valuesHMargin,
vPadding(chartRect) + valuesVMargin, vPadding(chartRect) + valuesVMargin,
-(hPadding(chartRect) * 2), -(hPadding(chartRect) * 2),
-(vPadding(chartRect)+barsShift) -(vPadding(chartRect) + barsShift)));
)
);
paintHorizontalLabels(painter, calcRect); paintHorizontalLabels(painter, calcRect);
} }
void LinesChart::drawDesignMode(QPainter* painter, qreal hStep, qreal vStep, qreal topShift, QRectF barsRect){ void LinesChart::drawDesignMode(QPainter* painter, qreal hStep, qreal vStep, qreal topShift,
QRectF barsRect)
{
for (int i = 0; i < valuesCount() - 1; ++i) { for (int i = 0; i < valuesCount() - 1; ++i) {
QPoint startPoint = QPoint((i + 1) * hStep + barsRect.left() - hStep / 2, QPoint startPoint = QPoint((i + 1) * hStep + barsRect.left() - hStep / 2,
(maxValue() * vStep+topShift) - designValues()[i] * vStep (maxValue() * vStep + topShift) - designValues()[i] * vStep);
);
QPoint endPoint = QPoint((i + 2) * hStep + barsRect.left() - hStep / 2, QPoint endPoint = QPoint((i + 2) * hStep + barsRect.left() - hStep / 2,
(maxValue() * vStep+topShift) - designValues()[i+1] * vStep (maxValue() * vStep + topShift) - designValues()[i + 1] * vStep);
);
drawSegment(painter, startPoint, endPoint, color_map[0]); drawSegment(painter, startPoint, endPoint, color_map[0]);
startPoint = QPoint((i + 1) * hStep + barsRect.left() - hStep / 2, startPoint = QPoint((i + 1) * hStep + barsRect.left() - hStep / 2,
(maxValue() * vStep+topShift) - designValues()[i+3] * vStep (maxValue() * vStep + topShift) - designValues()[i + 3] * vStep);
);
endPoint = QPoint((i + 2) * hStep + barsRect.left() - hStep / 2, endPoint = QPoint((i + 2) * hStep + barsRect.left() - hStep / 2,
(maxValue() * vStep+topShift) - designValues()[i+3+1] * vStep (maxValue() * vStep + topShift) - designValues()[i + 3 + 1] * vStep);
);
drawSegment(painter, startPoint, endPoint, color_map[1]); drawSegment(painter, startPoint, endPoint, color_map[1]);
startPoint = QPoint((i + 1) * hStep + barsRect.left() - hStep / 2, startPoint = QPoint((i + 1) * hStep + barsRect.left() - hStep / 2,
(maxValue() * vStep+topShift) - designValues()[i+6] * vStep (maxValue() * vStep + topShift) - designValues()[i + 6] * vStep);
);
endPoint = QPoint((i + 2) * hStep + barsRect.left() - hStep / 2, endPoint = QPoint((i + 2) * hStep + barsRect.left() - hStep / 2,
(maxValue() * vStep+topShift) - designValues()[i+6+1] * vStep (maxValue() * vStep + topShift) - designValues()[i + 6 + 1] * vStep);
);
drawSegment(painter, startPoint, endPoint, color_map[2]); drawSegment(painter, startPoint, endPoint, color_map[2]);
} }
} }
@ -118,7 +101,8 @@ void LinesChart::paintSeries(QPainter *painter, SeriesItem *series, QRectF barsR
void LinesChart::paintSerialLines(QPainter* painter, QRectF barsRect) void LinesChart::paintSerialLines(QPainter* painter, QRectF barsRect)
{ {
if (valuesCount() == 0) return; if (valuesCount() == 0)
return;
painter->save(); painter->save();
painter->setRenderHint(QPainter::Antialiasing, true); painter->setRenderHint(QPainter::Antialiasing, true);
@ -142,4 +126,3 @@ void LinesChart::paintSerialLines(QPainter* painter, QRectF barsRect)
} }
} // namespace LimeReport } // namespace LimeReport

View File

@ -8,14 +8,16 @@ class LinesChart: public AbstractBarChart{
public: public:
LinesChart(ChartItem* chartItem): AbstractBarChart(chartItem) { } LinesChart(ChartItem* chartItem): AbstractBarChart(chartItem) { }
void paintChart(QPainter* painter, QRectF chartRect); void paintChart(QPainter* painter, QRectF chartRect);
protected: protected:
void drawDesignMode(QPainter *painter, qreal hStep, qreal vStep, qreal topShift, QRectF barsRect); void drawDesignMode(QPainter* painter, qreal hStep, qreal vStep, qreal topShift,
QRectF barsRect);
qreal calculatePos(const AxisData& data, qreal value, qreal rectSize) const; qreal calculatePos(const AxisData& data, qreal value, qreal rectSize) const;
void paintSeries(QPainter* painter, SeriesItem* series, QRectF barsRect); void paintSeries(QPainter* painter, SeriesItem* series, QRectF barsRect);
private: private:
void paintSerialLines(QPainter* painter, QRectF barsRect); void paintSerialLines(QPainter* painter, QRectF barsRect);
}; };
} } // namespace LimeReport
#endif // LINESCHART_H #endif // LINESCHART_H

View File

@ -6,7 +6,8 @@ void PieChart::drawPercent(QPainter *painter, QRectF chartRect, qreal startAngle
{ {
painter->save(); painter->save();
QPointF center(chartRect.left()+chartRect.width()/2,chartRect.top()+chartRect.height()/2); QPointF center(chartRect.left() + chartRect.width() / 2,
chartRect.top() + chartRect.height() / 2);
qreal percent = angle / 3.6; qreal percent = angle / 3.6;
#if QT_VERSION < 0x050000 #if QT_VERSION < 0x050000
qreal radAngle = (angle / 2 + startAngle) * (M_PI / 180); qreal radAngle = (angle / 2 + startAngle) * (M_PI / 180);
@ -27,7 +28,6 @@ void PieChart::drawPercent(QPainter *painter, QRectF chartRect, qreal startAngle
if (arcLength >= radius) 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(); painter->restore();
} }
void PieChart::paintChart(QPainter* painter, QRectF chartRect) void PieChart::paintChart(QPainter* painter, QRectF chartRect)
@ -44,8 +44,8 @@ void PieChart::paintChart(QPainter *painter, QRectF chartRect)
QRectF tmpRect = chartRect; QRectF tmpRect = chartRect;
if (chartRect.height() > chartRect.width()) { if (chartRect.height() > chartRect.width()) {
tmpRect.setHeight(chartRect.width()); tmpRect.setHeight(chartRect.width());
tmpRect.adjust(0,(chartRect.bottom()-tmpRect.bottom())/2, tmpRect.adjust(0, (chartRect.bottom() - tmpRect.bottom()) / 2, 0,
0,(chartRect.bottom()-tmpRect.bottom())/2); (chartRect.bottom() - tmpRect.bottom()) / 2);
} else { } else {
tmpRect.setWidth(chartRect.height()); tmpRect.setWidth(chartRect.height());
} }
@ -53,7 +53,8 @@ void PieChart::paintChart(QPainter *painter, QRectF chartRect)
chartRect = tmpRect; chartRect = tmpRect;
painter->drawRect(chartRect); 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); SeriesItem* si = m_chartItem->series().at(0);
qreal sum = 0; qreal sum = 0;
foreach (qreal value, si->data()->values()) { foreach (qreal value, si->data()->values()) {
@ -100,25 +101,23 @@ void PieChart::paintChartLegend(QPainter *painter, QRectF legendRect)
painter->drawRect(legendRect); painter->drawRect(legendRect);
painter->setRenderHint(QPainter::Antialiasing, true); painter->setRenderHint(QPainter::Antialiasing, true);
QRectF indicatorsRect = legendRect.adjusted(painter->fontMetrics().height()/2,painter->fontMetrics().height()/2,0,0); QRectF indicatorsRect = legendRect.adjusted(painter->fontMetrics().height() / 2,
painter->fontMetrics().height() / 2, 0, 0);
if (!m_chartItem->series().isEmpty() && !m_chartItem->series().at(0)->data()->labels().isEmpty()){ if (!m_chartItem->series().isEmpty()
&& !m_chartItem->series().at(0)->data()->labels().isEmpty()) {
qreal cw = 0; qreal cw = 0;
SeriesItem* si = m_chartItem->series().at(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); QString label = si->data()->labels().at(i);
painter->setPen(Qt::black); 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->setPen(si->data()->colors().at(i));
painter->setBrush(si->data()->colors().at(i)); painter->setBrush(si->data()->colors().at(i));
painter->drawEllipse( painter->drawEllipse(indicatorsRect.adjusted(
indicatorsRect.adjusted( 0, cw + indicatorSize / 2, -(indicatorsRect.width() - indicatorSize),
0, -(indicatorsRect.height() - (cw + indicatorSize + indicatorSize / 2))));
cw+indicatorSize/2,
-(indicatorsRect.width()-indicatorSize),
-(indicatorsRect.height()-(cw+indicatorSize+indicatorSize/2))
)
);
cw += painter->fontMetrics().height(); cw += painter->fontMetrics().height();
} }
} else if (m_chartItem->itemMode() == DesignMode) { } else if (m_chartItem->itemMode() == DesignMode) {
@ -126,20 +125,15 @@ void PieChart::paintChartLegend(QPainter *painter, QRectF legendRect)
for (int i = 0; i < m_designLabels.size(); ++i) { for (int i = 0; i < m_designLabels.size(); ++i) {
QString label = m_designLabels.at(i); QString label = m_designLabels.at(i);
painter->setPen(Qt::black); 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->setBrush(color_map[i]);
painter->setPen(color_map[i]); painter->setPen(color_map[i]);
painter->drawEllipse( painter->drawEllipse(indicatorsRect.adjusted(
indicatorsRect.adjusted( 0, cw + indicatorSize / 2, -(indicatorsRect.width() - indicatorSize),
0, -(indicatorsRect.height() - (cw + indicatorSize + indicatorSize / 2))));
cw+indicatorSize/2,
-(indicatorsRect.width()-indicatorSize),
-(indicatorsRect.height()-(cw+indicatorSize+indicatorSize/2))
)
);
cw += painter->fontMetrics().height(); cw += painter->fontMetrics().height();
} }
} }
} }
@ -150,7 +144,8 @@ QSizeF PieChart::calcChartLegendSize(const QFont &font, qreal)
qreal cw = 0; qreal cw = 0;
qreal maxWidth = 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); SeriesItem* si = m_chartItem->series().at(0);
foreach (QString label, si->data()->labels()) { foreach (QString label, si->data()->labels()) {
cw += fm.height(); cw += fm.height();
@ -168,4 +163,4 @@ QSizeF PieChart::calcChartLegendSize(const QFont &font, qreal)
return QSizeF(maxWidth + fm.height() * 2, cw); return QSizeF(maxWidth + fm.height() * 2, cw);
} }
} } // namespace LimeReport

View File

@ -11,6 +11,7 @@ public:
QSizeF calcChartLegendSize(const QFont& font, qreal maxWidth = 0); QSizeF calcChartLegendSize(const QFont& font, qreal maxWidth = 0);
void paintChart(QPainter* painter, QRectF chartRect); void paintChart(QPainter* painter, QRectF chartRect);
void paintChartLegend(QPainter* painter, QRectF legendRect); void paintChartLegend(QPainter* painter, QRectF legendRect);
protected: protected:
void drawPercent(QPainter* painter, QRectF chartRect, qreal startAngle, qreal angle); void drawPercent(QPainter* painter, QRectF chartRect, qreal startAngle, qreal angle);
}; };

View File

@ -11,59 +11,45 @@ void VerticalBarChart::paintChart(QPainter *painter, QRectF chartRect)
QRectF calcRect = horizontalLabelsRect( QRectF calcRect = horizontalLabelsRect(
painter, painter,
chartRect.adjusted( chartRect.adjusted(hPadding(chartRect) * 2 + valuesHMargin,
hPadding(chartRect) * 2 + valuesHMargin, chartRect.height()
chartRect.height() - (painter->fontMetrics().height() + vPadding(chartRect) * 2), - (painter->fontMetrics().height() + vPadding(chartRect) * 2),
-(hPadding(chartRect) * 2), -(hPadding(chartRect) * 2), -vPadding(chartRect)));
-vPadding(chartRect)
)
);
qreal barsShift = calcRect.height(); qreal barsShift = calcRect.height();
paintVerticalGrid( paintVerticalGrid(painter,
painter, chartRect.adjusted(hPadding(chartRect), vPadding(chartRect) + valuesVMargin,
chartRect.adjusted( -hPadding(chartRect), -(vPadding(chartRect) + barsShift)));
hPadding(chartRect), paintVerticalBars(painter,
vPadding(chartRect) + valuesVMargin, chartRect.adjusted(hPadding(chartRect) * 2 + valuesHMargin,
-hPadding(chartRect),
-(vPadding(chartRect) + barsShift)
)
);
paintVerticalBars(
painter,
chartRect.adjusted(
hPadding(chartRect) * 2 + valuesHMargin,
vPadding(chartRect) + valuesVMargin, vPadding(chartRect) + valuesVMargin,
-hPadding(chartRect) * 2, -hPadding(chartRect) * 2,
-(vPadding(chartRect) + barsShift) -(vPadding(chartRect) + barsShift)));
) paintSerialLines(painter,
); chartRect.adjusted(hPadding(chartRect) * 2 + valuesHMargin,
paintSerialLines(
painter,
chartRect.adjusted(
hPadding(chartRect) * 2 + valuesHMargin,
vPadding(chartRect) + valuesVMargin, vPadding(chartRect) + valuesVMargin,
-hPadding(chartRect) * 2, -hPadding(chartRect) * 2,
-(vPadding(chartRect) + barsShift) -(vPadding(chartRect) + barsShift)));
)
);
paintHorizontalLabels(painter, calcRect); 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(); const qreal delta = yAxisData.delta();
int barSeriesCount = 0; int barSeriesCount = 0;
foreach (SeriesItem* series, m_chartItem->series()) { foreach (SeriesItem* series, m_chartItem->series()) {
if (series->preferredType() == SeriesItem::Bar) barSeriesCount++; if (series->preferredType() == SeriesItem::Bar)
barSeriesCount++;
} }
barSeriesCount = (m_chartItem->itemMode() == DesignMode) ? seriesCount() : barSeriesCount; barSeriesCount = (m_chartItem->itemMode() == DesignMode) ? seriesCount() : barSeriesCount;
if (barSeriesCount < 1) return; if (barSeriesCount < 1)
return;
painter->save(); painter->save();
painter->setRenderHint(QPainter::Antialiasing, false); painter->setRenderHint(QPainter::Antialiasing, false);
@ -78,7 +64,8 @@ void VerticalBarChart::paintVerticalBars(QPainter *painter, QRectF barsRect)
qreal curHOffset = curSeries * hStep + barsRect.left(); qreal curHOffset = curSeries * hStep + barsRect.left();
painter->setBrush(series->color()); painter->setBrush(series->color());
foreach (qreal value, series->data()->values()) { 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; curHOffset += hStep * barSeriesCount;
} }
curSeries++; curSeries++;
@ -88,9 +75,11 @@ void VerticalBarChart::paintVerticalBars(QPainter *painter, QRectF barsRect)
qreal curHOffset = barsRect.left(); qreal curHOffset = barsRect.left();
int curColor = 0; int curColor = 0;
for (int i = 0; i < 9; ++i) { for (int i = 0; i < 9; ++i) {
if (curColor == 3) curColor = 0; if (curColor == 3)
curColor = 0;
painter->setBrush(color_map[curColor]); 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; curHOffset += hStep;
curColor++; curColor++;
} }
@ -100,7 +89,8 @@ void VerticalBarChart::paintVerticalBars(QPainter *painter, QRectF barsRect)
void VerticalBarChart::paintSerialLines(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->save();
painter->setRenderHint(QPainter::Antialiasing, true); painter->setRenderHint(QPainter::Antialiasing, true);

View File

@ -31,8 +31,9 @@
namespace LimeReport { namespace LimeReport {
FontEditorWidget::FontEditorWidget(const QString& title, QWidget* parent) FontEditorWidget::FontEditorWidget(const QString& title, QWidget* parent):
:ItemEditorWidget(title, parent), m_ignoreSlots(false) ItemEditorWidget(title, parent),
m_ignoreSlots(false)
{ {
initEditor(); initEditor();
} }
@ -45,7 +46,6 @@ void FontEditorWidget::setItemEvent(BaseDesignIntf* item)
updateValues(font.value<QFont>()); updateValues(font.value<QFont>());
setEnabled(true); setEnabled(true);
} }
} }
void FontEditorWidget::initEditor() void FontEditorWidget::initEditor()
@ -56,17 +56,37 @@ void FontEditorWidget::initEditor()
m_fontNameEditor = new QFontComboBox(this); m_fontNameEditor = new QFontComboBox(this);
m_fontNameEditor->setFontFilters(QFontComboBox::AllFonts); 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); 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 = new QComboBox(this);
m_fontSizeEditor->setModel(&m_fontSizeModel); m_fontSizeEditor->setModel(&m_fontSizeModel);
m_fontSizeEditor->setEditable(true); m_fontSizeEditor->setEditable(true);
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3) #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 #else
connect(m_fontSizeEditor,SIGNAL(currentIndexChanged(QString)),this,SLOT(slotFontSizeChanged(QString))); connect(m_fontSizeEditor, SIGNAL(currentIndexChanged(QString)), this,
SLOT(slotFontSizeChanged(QString)));
#endif #endif
addWidget(m_fontSizeEditor); addWidget(m_fontSizeEditor);
@ -90,7 +110,6 @@ void FontEditorWidget::initEditor()
m_fontUnderline->setCheckable(true); 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); addAction(m_fontUnderline);
} }
void FontEditorWidget::updateValues(const QFont& font) void FontEditorWidget::updateValues(const QFont& font)
@ -104,11 +123,7 @@ void FontEditorWidget::updateValues(const QFont& font)
m_ignoreSlots = false; m_ignoreSlots = false;
} }
bool FontEditorWidget::ignoreSlots() const bool FontEditorWidget::ignoreSlots() const { return m_ignoreSlots; }
{
return m_ignoreSlots;
}
void FontEditorWidget::slotFontChanged(const QFont& /*font*/) void FontEditorWidget::slotFontChanged(const QFont& /*font*/)
{ {
@ -117,14 +132,16 @@ void FontEditorWidget::slotFontChanged(const QFont& /*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 = fontNameEditor()->currentFont();
m_resFont.setPointSize(value.toInt()); m_resFont.setPointSize(value.toInt());
} }
void FontEditorWidget::slotFontAttribsChanged(bool) void FontEditorWidget::slotFontAttribsChanged(bool)
{ {
if (m_ignoreSlots) return; if (m_ignoreSlots)
return;
m_resFont = m_fontNameEditor->currentFont(); m_resFont = m_fontNameEditor->currentFont();
m_resFont.setPointSize(m_fontSizeEditor->currentText().toInt()); m_resFont.setPointSize(m_fontSizeEditor->currentText().toInt());
m_resFont.setBold(m_fontBold->isChecked()); m_resFont.setBold(m_fontBold->isChecked());
@ -132,7 +149,8 @@ void FontEditorWidget::slotFontAttribsChanged(bool)
m_resFont.setUnderline(m_fontUnderline->isChecked()); 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(oldValue)
Q_UNUSED(newValue) Q_UNUSED(newValue)
@ -141,7 +159,6 @@ void FontEditorWidget::slotPropertyChanged(const QString &objectName, const QStr
} }
} }
void FontEditorWidgetForPage::slotFontChanged(const QFont& font) void FontEditorWidgetForPage::slotFontChanged(const QFont& font)
{ {
if (!ignoreSlots()) if (!ignoreSlots())
@ -167,13 +184,14 @@ void FontEditorWidgetForPage::slotFontAttribsChanged(bool value)
#ifdef HAVE_REPORT_DESIGNER #ifdef HAVE_REPORT_DESIGNER
void FontEditorWidgetForDesigner::initEditor() void FontEditorWidgetForDesigner::initEditor()
{ {
connect(m_reportEditor,SIGNAL(itemPropertyChanged(QString,QString,QVariant,QVariant)), connect(m_reportEditor, SIGNAL(itemPropertyChanged(QString, QString, QVariant, QVariant)), this,
this,SLOT(slotPropertyChanged(QString,QString,QVariant,QVariant))); SLOT(slotPropertyChanged(QString, QString, QVariant, QVariant)));
} }
void FontEditorWidgetForDesigner::slotFontChanged(const QFont& font) void FontEditorWidgetForDesigner::slotFontChanged(const QFont& font)
{ {
if (!ignoreSlots()) m_reportEditor->setFont(font); if (!ignoreSlots())
m_reportEditor->setFont(font);
} }
void FontEditorWidgetForDesigner::slotFontSizeChanged(const QString& value) void FontEditorWidgetForDesigner::slotFontSizeChanged(const QString& value)
@ -194,5 +212,4 @@ void FontEditorWidgetForDesigner::slotFontAttribsChanged(bool value)
#endif #endif
} // namespace LimeReport } // namespace LimeReport

View File

@ -30,10 +30,10 @@
#ifndef LRFONTEDITORWIDGET_H #ifndef LRFONTEDITORWIDGET_H
#define LRFONTEDITORWIDGET_H #define LRFONTEDITORWIDGET_H
#include <QToolBar> #include <QAction>
#include <QFontComboBox> #include <QFontComboBox>
#include <QStringListModel> #include <QStringListModel>
#include <QAction> #include <QToolBar>
#ifdef HAVE_REPORT_DESIGNER #ifdef HAVE_REPORT_DESIGNER
#include "lrreportdesignwidget.h" #include "lrreportdesignwidget.h"
@ -48,6 +48,7 @@ class FontEditorWidget :public ItemEditorWidget{
public: public:
explicit FontEditorWidget(const QString& title, QWidget* parent = 0); explicit FontEditorWidget(const QString& title, QWidget* parent = 0);
bool ignoreSlots() const; bool ignoreSlots() const;
protected: protected:
void setItemEvent(BaseDesignIntf* item); void setItemEvent(BaseDesignIntf* item);
QFontComboBox* fontNameEditor() { return m_fontNameEditor; } QFontComboBox* fontNameEditor() { return m_fontNameEditor; }
@ -56,11 +57,13 @@ protected slots:
virtual void slotFontChanged(const QFont&); virtual void slotFontChanged(const QFont&);
virtual void slotFontSizeChanged(const QString& value); virtual void slotFontSizeChanged(const QString& value);
virtual void slotFontAttribsChanged(bool); virtual void slotFontAttribsChanged(bool);
void slotPropertyChanged(const QString& objectName, const QString& property, const QVariant &oldValue, const QVariant &newValue); void slotPropertyChanged(const QString& objectName, const QString& property,
const QVariant& oldValue, const QVariant& newValue);
protected: protected:
QFont resFont() { return m_resFont; } QFont resFont() { return m_resFont; }
private:
private:
void updateValues(const QFont& font); void updateValues(const QFont& font);
QFontComboBox* m_fontNameEditor; QFontComboBox* m_fontNameEditor;
@ -73,18 +76,22 @@ private:
bool m_ignoreSlots; bool m_ignoreSlots;
QFont m_resFont; QFont m_resFont;
}; };
class FontEditorWidgetForPage: public FontEditorWidget { class FontEditorWidgetForPage: public FontEditorWidget {
Q_OBJECT Q_OBJECT
public: public:
explicit FontEditorWidgetForPage(PageDesignIntf* page, const QString &title, QWidget *parent = 0) explicit FontEditorWidgetForPage(PageDesignIntf* page, const QString& title,
: FontEditorWidget(title, parent), m_page(page){} QWidget* parent = 0):
FontEditorWidget(title, parent),
m_page(page)
{
}
protected slots: protected slots:
virtual void slotFontChanged(const QFont& font); virtual void slotFontChanged(const QFont& font);
virtual void slotFontSizeChanged(const QString& value); virtual void slotFontSizeChanged(const QString& value);
virtual void slotFontAttribsChanged(bool value); virtual void slotFontAttribsChanged(bool value);
private: private:
PageDesignIntf* m_page; PageDesignIntf* m_page;
}; };
@ -93,8 +100,13 @@ private:
class FontEditorWidgetForDesigner: public FontEditorWidget { class FontEditorWidgetForDesigner: public FontEditorWidget {
Q_OBJECT Q_OBJECT
public: public:
explicit FontEditorWidgetForDesigner(ReportDesignWidget* reportEditor, const QString &title, QWidget *parent = 0) explicit FontEditorWidgetForDesigner(ReportDesignWidget* reportEditor, const QString& title,
: FontEditorWidget(title, parent), m_reportEditor(reportEditor){initEditor();} QWidget* parent = 0):
FontEditorWidget(title, parent),
m_reportEditor(reportEditor)
{
initEditor();
}
protected: protected:
void initEditor(); void initEditor();
@ -102,6 +114,7 @@ protected slots:
virtual void slotFontChanged(const QFont& font); virtual void slotFontChanged(const QFont& font);
virtual void slotFontSizeChanged(const QString& value); virtual void slotFontSizeChanged(const QString& value);
virtual void slotFontAttribsChanged(bool value); virtual void slotFontAttribsChanged(bool value);
private: private:
ReportDesignWidget* m_reportEditor; ReportDesignWidget* m_reportEditor;
}; };

View File

@ -34,17 +34,19 @@ namespace LimeReport{
void ItemEditorWidget::setItem(BaseDesignIntf* item) void ItemEditorWidget::setItem(BaseDesignIntf* item)
{ {
if (m_item != item) { if (m_item != item) {
if (m_item) m_item->disconnect(this); if (m_item)
m_item->disconnect(this);
m_item = item; m_item = item;
connect(m_item, SIGNAL(destroyed(QObject*)), this, SLOT(slotItemDestroyed(QObject*))); connect(m_item, SIGNAL(destroyed(QObject*)), this, SLOT(slotItemDestroyed(QObject*)));
connect(m_item,SIGNAL(propertyChanged(QString,QVariant,QVariant)), connect(m_item, SIGNAL(propertyChanged(QString, QVariant, QVariant)), this,
this,SLOT(slotPropertyChanged(QString,QVariant,QVariant))); SLOT(slotPropertyChanged(QString, QVariant, QVariant)));
setEnabled(false); setEnabled(false);
setItemEvent(item); 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(propertName)
Q_UNUSED(oldValue) Q_UNUSED(oldValue)
@ -59,13 +61,10 @@ void ItemEditorWidget::slotItemDestroyed(QObject* item)
} }
} }
void ItemEditorWidget::slotPropertyChanged(const QString& propertName, const QVariant& oldValue, const QVariant& newValue) void ItemEditorWidget::slotPropertyChanged(const QString& propertName, const QVariant& oldValue,
const QVariant& newValue)
{ {
properyChangedEvent(propertName, oldValue, newValue); properyChangedEvent(propertName, oldValue, newValue);
} }
} } // namespace LimeReport

View File

@ -39,20 +39,26 @@
namespace LimeReport { namespace LimeReport {
class ItemEditorWidget : public QToolBar class ItemEditorWidget: public QToolBar {
{
Q_OBJECT Q_OBJECT
public: public:
explicit ItemEditorWidget(const QString &title, QWidget *parent = 0) explicit ItemEditorWidget(const QString& title, QWidget* parent = 0):
: QToolBar(title, parent), m_item(0){} QToolBar(title, parent),
m_item(0)
{
}
void setItem(BaseDesignIntf* item); void setItem(BaseDesignIntf* item);
protected: protected:
virtual void setItemEvent(BaseDesignIntf*) { } virtual void setItemEvent(BaseDesignIntf*) { }
virtual void properyChangedEvent(const QString& propertName, const QVariant& oldValue, const QVariant& newValue); virtual void properyChangedEvent(const QString& propertName, const QVariant& oldValue,
const QVariant& newValue);
BaseDesignIntf* item() { return m_item; } BaseDesignIntf* item() { return m_item; }
private slots: private slots:
void slotItemDestroyed(QObject* item); 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: private:
BaseDesignIntf* m_item; BaseDesignIntf* m_item;
}; };

View File

@ -31,88 +31,119 @@
namespace LimeReport { namespace LimeReport {
ItemsAlignmentEditorWidget::ItemsAlignmentEditorWidget(LimeReport::ReportDesignWidget* reportEditor, const QString& title, QWidget* parent) ItemsAlignmentEditorWidget::ItemsAlignmentEditorWidget(LimeReport::ReportDesignWidget* reportEditor,
:QToolBar(title,parent), m_reportEditor(reportEditor), m_page(0) const QString& title, QWidget* parent):
QToolBar(title, parent),
m_reportEditor(reportEditor),
m_page(0)
{ {
initEditor(); initEditor();
} }
ItemsAlignmentEditorWidget::ItemsAlignmentEditorWidget(ReportDesignWidget* reportEditor, QWidget* parent) ItemsAlignmentEditorWidget::ItemsAlignmentEditorWidget(ReportDesignWidget* reportEditor,
:QToolBar(parent), m_reportEditor(reportEditor), m_page(0) QWidget* parent):
QToolBar(parent),
m_reportEditor(reportEditor),
m_page(0)
{ {
initEditor(); initEditor();
} }
ItemsAlignmentEditorWidget::ItemsAlignmentEditorWidget(PageDesignIntf* page, const QString& title, QWidget* parent) ItemsAlignmentEditorWidget::ItemsAlignmentEditorWidget(PageDesignIntf* page, const QString& title,
:QToolBar(title,parent), m_reportEditor(0), m_page(page) QWidget* parent):
QToolBar(title, parent),
m_reportEditor(0),
m_page(page)
{ {
initEditor(); initEditor();
} }
ItemsAlignmentEditorWidget::ItemsAlignmentEditorWidget(PageDesignIntf* page, QWidget* parent) ItemsAlignmentEditorWidget::ItemsAlignmentEditorWidget(PageDesignIntf* page, QWidget* parent):
:QToolBar(parent), m_reportEditor(0), m_page(page) QToolBar(parent),
m_reportEditor(0),
m_page(page)
{ {
initEditor(); initEditor();
} }
void ItemsAlignmentEditorWidget::slotBringToFront() void ItemsAlignmentEditorWidget::slotBringToFront()
{ {
if (m_reportEditor) m_reportEditor->bringToFront(); if (m_reportEditor)
if (m_page) m_page->bringToFront(); m_reportEditor->bringToFront();
if (m_page)
m_page->bringToFront();
} }
void ItemsAlignmentEditorWidget::slotSendToBack() void ItemsAlignmentEditorWidget::slotSendToBack()
{ {
if (m_reportEditor) m_reportEditor->sendToBack(); if (m_reportEditor)
if (m_page) m_page->sendToBack(); m_reportEditor->sendToBack();
if (m_page)
m_page->sendToBack();
} }
void ItemsAlignmentEditorWidget::slotAlignToLeft() void ItemsAlignmentEditorWidget::slotAlignToLeft()
{ {
if (m_reportEditor) m_reportEditor->alignToLeft(); if (m_reportEditor)
if (m_page) m_page->alignToLeft(); m_reportEditor->alignToLeft();
if (m_page)
m_page->alignToLeft();
} }
void ItemsAlignmentEditorWidget::slotAlignToRight() void ItemsAlignmentEditorWidget::slotAlignToRight()
{ {
if (m_reportEditor) m_reportEditor->alignToRight(); if (m_reportEditor)
if (m_page) m_page->alignToRigth(); m_reportEditor->alignToRight();
if (m_page)
m_page->alignToRigth();
} }
void ItemsAlignmentEditorWidget::slotAlignToVCenter() void ItemsAlignmentEditorWidget::slotAlignToVCenter()
{ {
if (m_reportEditor) m_reportEditor->alignToVCenter(); if (m_reportEditor)
if (m_page) m_page->alignToVCenter(); m_reportEditor->alignToVCenter();
if (m_page)
m_page->alignToVCenter();
} }
void ItemsAlignmentEditorWidget::slotAlignToTop() void ItemsAlignmentEditorWidget::slotAlignToTop()
{ {
if (m_reportEditor) m_reportEditor->alignToTop(); if (m_reportEditor)
if (m_page) m_page->alignToTop(); m_reportEditor->alignToTop();
if (m_page)
m_page->alignToTop();
} }
void ItemsAlignmentEditorWidget::slotAlignToBottom() void ItemsAlignmentEditorWidget::slotAlignToBottom()
{ {
if (m_reportEditor) m_reportEditor->alignToBottom(); if (m_reportEditor)
if (m_page) m_page->alignToBottom(); m_reportEditor->alignToBottom();
if (m_page)
m_page->alignToBottom();
} }
void ItemsAlignmentEditorWidget::slotAlignToHCenter() void ItemsAlignmentEditorWidget::slotAlignToHCenter()
{ {
if (m_reportEditor) m_reportEditor->alignToHCenter(); if (m_reportEditor)
if (m_page) m_page->alignToHCenter(); m_reportEditor->alignToHCenter();
if (m_page)
m_page->alignToHCenter();
} }
void ItemsAlignmentEditorWidget::slotSameHeight() void ItemsAlignmentEditorWidget::slotSameHeight()
{ {
if (m_reportEditor) m_reportEditor->sameHeight(); if (m_reportEditor)
if (m_page) m_page->sameHeight(); m_reportEditor->sameHeight();
if (m_page)
m_page->sameHeight();
} }
void ItemsAlignmentEditorWidget::slotSameWidth() void ItemsAlignmentEditorWidget::slotSameWidth()
{ {
if (m_reportEditor) m_reportEditor->sameWidth(); if (m_reportEditor)
if (m_page) m_page->sameWidth(); m_reportEditor->sameWidth();
if (m_page)
m_page->sameWidth();
} }
void ItemsAlignmentEditorWidget::initEditor() void ItemsAlignmentEditorWidget::initEditor()

View File

@ -31,18 +31,20 @@
#define LRITEMSALIGNEDITORWIDGET_H #define LRITEMSALIGNEDITORWIDGET_H
#include "lrreportdesignwidget.h" #include "lrreportdesignwidget.h"
#include <QToolBar>
#include <QAction> #include <QAction>
#include <QToolBar>
namespace LimeReport { namespace LimeReport {
class ItemsAlignmentEditorWidget : public QToolBar class ItemsAlignmentEditorWidget: public QToolBar {
{
Q_OBJECT Q_OBJECT
public: public:
explicit ItemsAlignmentEditorWidget(ReportDesignWidget* reportEditor, const QString &title, QWidget *parent = 0); explicit ItemsAlignmentEditorWidget(ReportDesignWidget* reportEditor, const QString& title,
QWidget* parent = 0);
explicit ItemsAlignmentEditorWidget(ReportDesignWidget* reportEditor, QWidget* parent = 0); explicit ItemsAlignmentEditorWidget(ReportDesignWidget* reportEditor, QWidget* parent = 0);
explicit ItemsAlignmentEditorWidget(PageDesignIntf* page, const QString &title, QWidget *parent = 0); explicit ItemsAlignmentEditorWidget(PageDesignIntf* page, const QString& title,
QWidget* parent = 0);
explicit ItemsAlignmentEditorWidget(PageDesignIntf* page, QWidget* parent = 0); explicit ItemsAlignmentEditorWidget(PageDesignIntf* page, QWidget* parent = 0);
private slots: private slots:
void slotBringToFront(); void slotBringToFront();
@ -55,6 +57,7 @@ private slots:
void slotAlignToHCenter(); void slotAlignToHCenter();
void slotSameHeight(); void slotSameHeight();
void slotSameWidth(); void slotSameWidth();
private: private:
void initEditor(); void initEditor();
ReportDesignWidget* m_reportEditor; ReportDesignWidget* m_reportEditor;

View File

@ -28,14 +28,15 @@
* GNU General Public License for more details. * * GNU General Public License for more details. *
****************************************************************************/ ****************************************************************************/
#include "lritemsborderseditorwidget.h" #include "lritemsborderseditorwidget.h"
#include <QAction>
#include "lrbordereditor.h" #include "lrbordereditor.h"
#include <QAction>
namespace LimeReport { namespace LimeReport {
void ItemsBordersEditorWidget::setItemEvent(BaseDesignIntf* item) void ItemsBordersEditorWidget::setItemEvent(BaseDesignIntf* item)
{ {
if(QString(item->metaObject()->className()) == "LimeReport::ShapeItem") if (QString(item->metaObject()->className()) == "LimeReport::ShapeItem") {
{
setDisabled(true); setDisabled(true);
return; return;
} }
@ -47,7 +48,9 @@ void ItemsBordersEditorWidget::setItemEvent(BaseDesignIntf* item)
m_item = item; m_item = item;
} }
void ItemsBordersEditorWidget::properyChangedEvent(const QString& property, const QVariant& oldValue, const QVariant& newValue) void ItemsBordersEditorWidget::properyChangedEvent(const QString& property,
const QVariant& oldValue,
const QVariant& newValue)
{ {
Q_UNUSED(oldValue) Q_UNUSED(oldValue)
if (property == "borders") { if (property == "borders") {
@ -57,17 +60,12 @@ void ItemsBordersEditorWidget::properyChangedEvent(const QString& property, cons
} }
} }
void ItemsBordersEditorWidget::noBordesClicked() void ItemsBordersEditorWidget::noBordesClicked() { updateValues({}); }
{
updateValues({});
}
void ItemsBordersEditorWidget::allBordesClicked() void ItemsBordersEditorWidget::allBordesClicked()
{ {
int borders = BaseDesignIntf::LeftLine | int borders = BaseDesignIntf::LeftLine | BaseDesignIntf::RightLine | BaseDesignIntf::TopLine
BaseDesignIntf::RightLine | | BaseDesignIntf::BottomLine;
BaseDesignIntf::TopLine |
BaseDesignIntf::BottomLine;
updateValues((BaseDesignIntf::BorderLines)borders); updateValues((BaseDesignIntf::BorderLines)borders);
} }
@ -78,7 +76,8 @@ void ItemsBordersEditorWidget::editBorderClicked()
{ {
BorderEditor be; BorderEditor be;
be.loadItem(m_item); be.loadItem(m_item);
if ( be.exec() == QDialog::Rejected ) return; if (be.exec() == QDialog::Rejected)
return;
updateValues(be.borderSides()); updateValues(be.borderSides());
m_item->setBorderLinesFlags(be.borderSides()); m_item->setBorderLinesFlags(be.borderSides());
m_item->setBorderLineSize(be.borderWidth()); m_item->setBorderLineSize(be.borderWidth());
@ -131,7 +130,6 @@ void ItemsBordersEditorWidget::initEditor()
addAction(m_BorderEditor); addAction(m_BorderEditor);
setEnabled(false); setEnabled(false);
} }
void ItemsBordersEditorWidget::updateValues(BaseDesignIntf::BorderLines borders) void ItemsBordersEditorWidget::updateValues(BaseDesignIntf::BorderLines borders)
@ -154,10 +152,7 @@ BaseDesignIntf::BorderLines ItemsBordersEditorWidget::createBorders()
return (BaseDesignIntf::BorderLines)borders; return (BaseDesignIntf::BorderLines)borders;
} }
bool ItemsBordersEditorWidget::changing() const bool ItemsBordersEditorWidget::changing() const { return m_changing; }
{
return m_changing;
}
#ifdef HAVE_REPORT_DESIGNER #ifdef HAVE_REPORT_DESIGNER
void ItemsBordersEditorWidgetForDesigner::buttonClicked(bool) void ItemsBordersEditorWidgetForDesigner::buttonClicked(bool)
@ -182,14 +177,12 @@ void ItemsBordersEditorWidgetForDesigner::editBorderClicked()
{ {
BorderEditor be; BorderEditor be;
be.loadItem(m_item); be.loadItem(m_item);
if ( be.exec() == QDialog::Rejected ) return; if (be.exec() == QDialog::Rejected)
return;
m_reportEditor->setBordersExt( m_reportEditor->setBordersExt(be.borderSides(), be.borderWidth(),
be.borderSides(),
be.borderWidth(),
(LimeReport::BaseDesignIntf::BorderStyle)be.borderStyle(), (LimeReport::BaseDesignIntf::BorderStyle)be.borderStyle(),
be.borderColor() be.borderColor());
);
} }
#endif #endif

View File

@ -30,18 +30,21 @@
#ifndef LRITEMSBORDERSEDITORWIDGET_H #ifndef LRITEMSBORDERSEDITORWIDGET_H
#define LRITEMSBORDERSEDITORWIDGET_H #define LRITEMSBORDERSEDITORWIDGET_H
#include <QToolBar>
#include "lrreportdesignwidget.h"
#include "lritemeditorwidget.h" #include "lritemeditorwidget.h"
#include "lrreportdesignwidget.h"
#include <QToolBar>
namespace LimeReport { namespace LimeReport {
class ItemsBordersEditorWidget : public ItemEditorWidget class ItemsBordersEditorWidget: public ItemEditorWidget {
{
Q_OBJECT Q_OBJECT
public: public:
explicit ItemsBordersEditorWidget(const QString &title, QWidget *parent = 0) explicit ItemsBordersEditorWidget(const QString& title, QWidget* parent = 0):
: ItemEditorWidget(title, parent), m_changing(false), m_borders(0){ ItemEditorWidget(title, parent),
m_changing(false),
m_borders(0)
{
initEditor(); initEditor();
} }
bool changing() const; bool changing() const;
@ -50,11 +53,14 @@ protected slots:
virtual void allBordesClicked(); virtual void allBordesClicked();
virtual void buttonClicked(bool); virtual void buttonClicked(bool);
virtual void editBorderClicked(); virtual void editBorderClicked();
protected: protected:
void setItemEvent(BaseDesignIntf* item); void setItemEvent(BaseDesignIntf* item);
void properyChangedEvent(const QString &property, const QVariant &oldValue, const QVariant &newValue); void properyChangedEvent(const QString& property, const QVariant& oldValue,
const QVariant& newValue);
BaseDesignIntf::BorderLines createBorders(); BaseDesignIntf::BorderLines createBorders();
BaseDesignIntf* m_item; BaseDesignIntf* m_item;
private: private:
void initEditor(); void initEditor();
void updateValues(BaseDesignIntf::BorderLines borders); void updateValues(BaseDesignIntf::BorderLines borders);
@ -67,23 +73,26 @@ private:
QAction* m_BorderEditor; QAction* m_BorderEditor;
bool m_changing; bool m_changing;
int m_borders; int m_borders;
}; };
#ifdef HAVE_REPORT_DESIGNER #ifdef HAVE_REPORT_DESIGNER
class ItemsBordersEditorWidgetForDesigner: public ItemsBordersEditorWidget { class ItemsBordersEditorWidgetForDesigner: public ItemsBordersEditorWidget {
Q_OBJECT Q_OBJECT
public: public:
explicit ItemsBordersEditorWidgetForDesigner(ReportDesignWidget* reportEditor, const QString &title="", QWidget *parent = 0) explicit ItemsBordersEditorWidgetForDesigner(ReportDesignWidget* reportEditor,
: ItemsBordersEditorWidget(title,parent), m_reportEditor(reportEditor){} const QString& title = "", QWidget* parent = 0):
ItemsBordersEditorWidget(title, parent),
m_reportEditor(reportEditor)
{
}
protected slots: protected slots:
void buttonClicked(bool); void buttonClicked(bool);
void noBordesClicked(); void noBordesClicked();
void allBordesClicked(); void allBordesClicked();
void editBorderClicked(); void editBorderClicked();
private: private:
ReportDesignWidget* m_reportEditor; ReportDesignWidget* m_reportEditor;
}; };
#endif #endif

View File

@ -30,8 +30,10 @@
#include "lrtextalignmenteditorwidget.h" #include "lrtextalignmenteditorwidget.h"
namespace LimeReport { namespace LimeReport {
TextAlignmentEditorWidget::TextAlignmentEditorWidget(const QString& title, QWidget* parent) TextAlignmentEditorWidget::TextAlignmentEditorWidget(const QString& title, QWidget* parent):
:ItemEditorWidget(title, parent), m_textAttibutesIsChanging(false), m_flag(0) ItemEditorWidget(title, parent),
m_textAttibutesIsChanging(false),
m_flag(0)
{ {
initEditor(); initEditor();
} }
@ -109,19 +111,27 @@ void TextAlignmentEditorWidget::updateValues(const Qt::Alignment &align)
Qt::Alignment TextAlignmentEditorWidget::createAlignment() Qt::Alignment TextAlignmentEditorWidget::createAlignment()
{ {
Qt::Alignment align = Qt::Alignment(); Qt::Alignment align = Qt::Alignment();
if (m_textAliginLeft->isChecked()) align |= Qt::AlignLeft; if (m_textAliginLeft->isChecked())
if (m_textAliginHCenter->isChecked()) align |= Qt::AlignHCenter; align |= Qt::AlignLeft;
if (m_textAliginRight->isChecked()) align |= Qt::AlignRight; if (m_textAliginHCenter->isChecked())
if (m_textAliginJustify->isChecked()) align |= Qt::AlignJustify; align |= Qt::AlignHCenter;
if (m_textAliginTop->isChecked()) align |= Qt::AlignTop; if (m_textAliginRight->isChecked())
if (m_textAliginVCenter->isChecked()) align |= Qt::AlignVCenter; align |= Qt::AlignRight;
if (m_textAliginBottom->isChecked()) align |= Qt::AlignBottom; 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; return align;
} }
void TextAlignmentEditorWidget::slotTextHAttribsChanged(bool) void TextAlignmentEditorWidget::slotTextHAttribsChanged(bool)
{ {
if (m_textAttibutesIsChanging) return; if (m_textAttibutesIsChanging)
return;
m_textAttibutesIsChanging = true; m_textAttibutesIsChanging = true;
m_textAliginLeft->setChecked(sender() == m_textAliginLeft); m_textAliginLeft->setChecked(sender() == m_textAliginLeft);
@ -130,16 +140,21 @@ void TextAlignmentEditorWidget::slotTextHAttribsChanged(bool)
m_textAliginJustify->setChecked(sender() == m_textAliginJustify); m_textAliginJustify->setChecked(sender() == m_textAliginJustify);
m_flag = 0; m_flag = 0;
if (sender()==m_textAliginLeft) m_flag |= Qt::AlignLeft; if (sender() == m_textAliginLeft)
if (sender()==m_textAliginHCenter) m_flag |= Qt::AlignHCenter; m_flag |= Qt::AlignLeft;
if (sender()==m_textAliginRight) m_flag |= Qt::AlignRight; if (sender() == m_textAliginHCenter)
if (sender()==m_textAliginJustify) m_flag |= Qt::AlignJustify; m_flag |= Qt::AlignHCenter;
if (sender() == m_textAliginRight)
m_flag |= Qt::AlignRight;
if (sender() == m_textAliginJustify)
m_flag |= Qt::AlignJustify;
m_textAttibutesIsChanging = false; m_textAttibutesIsChanging = false;
} }
void TextAlignmentEditorWidget::slotTextVAttribsChanged(bool) void TextAlignmentEditorWidget::slotTextVAttribsChanged(bool)
{ {
if (m_textAttibutesIsChanging) return; if (m_textAttibutesIsChanging)
return;
m_textAttibutesIsChanging = true; m_textAttibutesIsChanging = true;
m_textAliginTop->setChecked(sender() == m_textAliginTop); m_textAliginTop->setChecked(sender() == m_textAliginTop);
@ -147,13 +162,19 @@ void TextAlignmentEditorWidget::slotTextVAttribsChanged(bool)
m_textAliginBottom->setChecked(sender() == m_textAliginBottom); m_textAliginBottom->setChecked(sender() == m_textAliginBottom);
m_flag = 0; m_flag = 0;
if (sender()==m_textAliginTop) m_flag |= Qt::AlignTop; if (sender() == m_textAliginTop)
if (sender()==m_textAliginVCenter) m_flag |= Qt::AlignVCenter; m_flag |= Qt::AlignTop;
if (sender()==m_textAliginBottom) m_flag |= Qt::AlignBottom; if (sender() == m_textAliginVCenter)
m_flag |= Qt::AlignVCenter;
if (sender() == m_textAliginBottom)
m_flag |= Qt::AlignBottom;
m_textAttibutesIsChanging = false; 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(oldValue)
Q_UNUSED(newValue) Q_UNUSED(newValue)
@ -163,23 +184,21 @@ void TextAlignmentEditorWidget::slotPropertyChanged(const QString &objectName, c
} }
} }
int TextAlignmentEditorWidget::flag() const int TextAlignmentEditorWidget::flag() const { return m_flag; }
{
return m_flag;
}
void TextAlignmentEditorWidgetForPage::initEditor() void TextAlignmentEditorWidgetForPage::initEditor()
{ {
TextAlignmentEditorWidget::initEditor(); TextAlignmentEditorWidget::initEditor();
connect(m_page,SIGNAL(itemPropertyChanged(QString,QString,QVariant,QVariant)), connect(m_page, SIGNAL(itemPropertyChanged(QString, QString, QVariant, QVariant)), this,
this,SLOT(slotPropertyChanged(QString,QString,QVariant,QVariant))); SLOT(slotPropertyChanged(QString, QString, QVariant, QVariant)));
} }
void TextAlignmentEditorWidgetForPage::slotTextHAttribsChanged(bool value) void TextAlignmentEditorWidgetForPage::slotTextHAttribsChanged(bool value)
{ {
TextAlignmentEditorWidget::slotTextHAttribsChanged(value); TextAlignmentEditorWidget::slotTextHAttribsChanged(value);
if (m_textAttibutesIsChanging) return; if (m_textAttibutesIsChanging)
return;
m_textAttibutesIsChanging = true; m_textAttibutesIsChanging = true;
m_page->changeSelectedGrpoupTextAlignPropperty(true, Qt::AlignmentFlag(flag())); m_page->changeSelectedGrpoupTextAlignPropperty(true, Qt::AlignmentFlag(flag()));
m_textAttibutesIsChanging = false; m_textAttibutesIsChanging = false;
@ -188,7 +207,8 @@ void TextAlignmentEditorWidgetForPage::slotTextHAttribsChanged(bool value)
void TextAlignmentEditorWidgetForPage::slotTextVAttribsChanged(bool value) void TextAlignmentEditorWidgetForPage::slotTextVAttribsChanged(bool value)
{ {
TextAlignmentEditorWidget::slotTextVAttribsChanged(value); TextAlignmentEditorWidget::slotTextVAttribsChanged(value);
if (m_textAttibutesIsChanging) return; if (m_textAttibutesIsChanging)
return;
m_textAttibutesIsChanging = true; m_textAttibutesIsChanging = true;
m_page->changeSelectedGrpoupTextAlignPropperty(false, Qt::AlignmentFlag(flag())); m_page->changeSelectedGrpoupTextAlignPropperty(false, Qt::AlignmentFlag(flag()));
m_textAttibutesIsChanging = false; m_textAttibutesIsChanging = false;
@ -197,15 +217,15 @@ void TextAlignmentEditorWidgetForPage::slotTextVAttribsChanged(bool value)
#ifdef HAVE_REPORT_DESIGNER #ifdef HAVE_REPORT_DESIGNER
void TextAlignmentEditorWidgetForDesigner::initEditor() void TextAlignmentEditorWidgetForDesigner::initEditor()
{ {
connect(m_reportEditor,SIGNAL(itemPropertyChanged(QString,QString,QVariant,QVariant)), connect(m_reportEditor, SIGNAL(itemPropertyChanged(QString, QString, QVariant, QVariant)), this,
this,SLOT(slotPropertyChanged(QString,QString,QVariant,QVariant))); SLOT(slotPropertyChanged(QString, QString, QVariant, QVariant)));
} }
void TextAlignmentEditorWidgetForDesigner::slotTextHAttribsChanged(bool value) void TextAlignmentEditorWidgetForDesigner::slotTextHAttribsChanged(bool value)
{ {
TextAlignmentEditorWidget::slotTextHAttribsChanged(value); TextAlignmentEditorWidget::slotTextHAttribsChanged(value);
if (m_textAttibutesIsChanging) return; if (m_textAttibutesIsChanging)
return;
m_textAttibutesIsChanging = true; m_textAttibutesIsChanging = true;
m_reportEditor->setTextAlign(true, Qt::AlignmentFlag(flag())); m_reportEditor->setTextAlign(true, Qt::AlignmentFlag(flag()));
m_textAttibutesIsChanging = false; m_textAttibutesIsChanging = false;
@ -214,7 +234,8 @@ void TextAlignmentEditorWidgetForDesigner::slotTextHAttribsChanged(bool value)
void TextAlignmentEditorWidgetForDesigner::slotTextVAttribsChanged(bool value) void TextAlignmentEditorWidgetForDesigner::slotTextVAttribsChanged(bool value)
{ {
TextAlignmentEditorWidget::slotTextVAttribsChanged(value); TextAlignmentEditorWidget::slotTextVAttribsChanged(value);
if (m_textAttibutesIsChanging) return; if (m_textAttibutesIsChanging)
return;
m_textAttibutesIsChanging = true; m_textAttibutesIsChanging = true;
m_reportEditor->setTextAlign(false, Qt::AlignmentFlag(flag())); m_reportEditor->setTextAlign(false, Qt::AlignmentFlag(flag()));
m_textAttibutesIsChanging = false; m_textAttibutesIsChanging = false;

View File

@ -30,30 +30,34 @@
#ifndef LRTEXTALIGNMENTEDITORWIDGET_H #ifndef LRTEXTALIGNMENTEDITORWIDGET_H
#define LRTEXTALIGNMENTEDITORWIDGET_H #define LRTEXTALIGNMENTEDITORWIDGET_H
#include "lrreportdesignwidget.h"
#include "lritemeditorwidget.h" #include "lritemeditorwidget.h"
#include <QToolBar> #include "lrreportdesignwidget.h"
#include <QAction> #include <QAction>
#include <QToolBar>
namespace LimeReport { namespace LimeReport {
class TextAlignmentEditorWidget:public ItemEditorWidget class TextAlignmentEditorWidget: public ItemEditorWidget {
{
Q_OBJECT Q_OBJECT
public: public:
explicit TextAlignmentEditorWidget(const QString& title, QWidget* parent = 0); explicit TextAlignmentEditorWidget(const QString& title, QWidget* parent = 0);
int flag() const; int flag() const;
protected: protected:
void setItemEvent(BaseDesignIntf* item); void setItemEvent(BaseDesignIntf* item);
void initEditor(); void initEditor();
bool m_textAttibutesIsChanging; bool m_textAttibutesIsChanging;
private: private:
void updateValues(const Qt::Alignment& align); void updateValues(const Qt::Alignment& align);
Qt::Alignment createAlignment(); Qt::Alignment createAlignment();
protected slots: protected slots:
virtual void slotTextHAttribsChanged(bool); virtual void slotTextHAttribsChanged(bool);
virtual void slotTextVAttribsChanged(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: private:
QAction* m_textAliginLeft; QAction* m_textAliginLeft;
QAction* m_textAliginRight; QAction* m_textAliginRight;
@ -68,13 +72,19 @@ private:
class TextAlignmentEditorWidgetForPage: public TextAlignmentEditorWidget { class TextAlignmentEditorWidgetForPage: public TextAlignmentEditorWidget {
Q_OBJECT Q_OBJECT
public: public:
TextAlignmentEditorWidgetForPage(PageDesignIntf* page, const QString &title, QWidget *parent = 0) TextAlignmentEditorWidgetForPage(PageDesignIntf* page, const QString& title,
:TextAlignmentEditorWidget(title, parent), m_page(page){} QWidget* parent = 0):
TextAlignmentEditorWidget(title, parent),
m_page(page)
{
}
protected: protected:
void initEditor(); void initEditor();
protected slots: protected slots:
void slotTextHAttribsChanged(bool value); void slotTextHAttribsChanged(bool value);
void slotTextVAttribsChanged(bool value); void slotTextVAttribsChanged(bool value);
private: private:
PageDesignIntf* m_page; PageDesignIntf* m_page;
}; };
@ -83,13 +93,20 @@ private:
class TextAlignmentEditorWidgetForDesigner: public TextAlignmentEditorWidget { class TextAlignmentEditorWidgetForDesigner: public TextAlignmentEditorWidget {
Q_OBJECT Q_OBJECT
public: public:
TextAlignmentEditorWidgetForDesigner(ReportDesignWidget* reportEditor, const QString &title, QWidget *parent = 0) TextAlignmentEditorWidgetForDesigner(ReportDesignWidget* reportEditor, const QString& title,
:TextAlignmentEditorWidget(title, parent), m_reportEditor(reportEditor){initEditor();} QWidget* parent = 0):
TextAlignmentEditorWidget(title, parent),
m_reportEditor(reportEditor)
{
initEditor();
}
protected: protected:
void initEditor(); void initEditor();
protected slots: protected slots:
void slotTextHAttribsChanged(bool value); void slotTextHAttribsChanged(bool value);
void slotTextVAttribsChanged(bool value); void slotTextVAttribsChanged(bool value);
private: private:
ReportDesignWidget* m_reportEditor; ReportDesignWidget* m_reportEditor;
}; };

View File

@ -2,9 +2,12 @@
namespace LimeReport { namespace LimeReport {
AbstractLayout::AbstractLayout(QString xmlTag, QObject* owner, QGraphicsItem* parent) AbstractLayout::AbstractLayout(QString xmlTag, QObject* owner, QGraphicsItem* parent):
: LayoutDesignIntf(xmlTag, owner, parent), m_isRelocating(false), m_layoutType(Layout), LayoutDesignIntf(xmlTag, owner, parent),
m_hideEmptyItems(false), m_layoutSpacing(0) m_isRelocating(false),
m_layoutType(Layout),
m_hideEmptyItems(false),
m_layoutSpacing(0)
{ {
setPossibleResizeDirectionFlags(AllDirections); setPossibleResizeDirectionFlags(AllDirections);
m_layoutMarker = new LayoutMarker(this); m_layoutMarker = new LayoutMarker(this);
@ -17,38 +20,25 @@ AbstractLayout::AbstractLayout(QString xmlTag, QObject* owner, QGraphicsItem* pa
AbstractLayout::~AbstractLayout() AbstractLayout::~AbstractLayout()
{ {
if (m_layoutMarker) { if (m_layoutMarker) {
delete m_layoutMarker; m_layoutMarker=0; delete m_layoutMarker;
m_layoutMarker = 0;
} }
} }
QList<BaseDesignIntf*>& AbstractLayout::layoutsChildren() QList<BaseDesignIntf*>& AbstractLayout::layoutsChildren() { return m_children; }
{
return m_children;
}
bool AbstractLayout::isRelocating() const bool AbstractLayout::isRelocating() const { return m_isRelocating; }
{
return m_isRelocating;
}
void AbstractLayout::setIsRelocating(bool isRelocating) void AbstractLayout::setIsRelocating(bool isRelocating) { m_isRelocating = isRelocating; }
{
m_isRelocating = isRelocating;
}
AbstractLayout::LayoutType AbstractLayout::layoutType() const AbstractLayout::LayoutType AbstractLayout::layoutType() const { return m_layoutType; }
{
return m_layoutType;
}
void AbstractLayout::setLayoutType(const LayoutType& layoutType) void AbstractLayout::setLayoutType(const LayoutType& layoutType) { m_layoutType = layoutType; }
{
m_layoutType = layoutType;
}
void AbstractLayout::addChild(BaseDesignIntf* item, bool updateSize) void AbstractLayout::addChild(BaseDesignIntf* item, bool updateSize)
{ {
if (updateSize) placeItemInLayout(item); if (updateSize)
placeItemInLayout(item);
m_children.append(item); m_children.append(item);
item->setParentItem(this); item->setParentItem(this);
@ -75,7 +65,8 @@ void AbstractLayout::removeChild(BaseDesignIntf *item)
void AbstractLayout::restoreChild(BaseDesignIntf* item) void AbstractLayout::restoreChild(BaseDesignIntf* item)
{ {
if (m_children.contains(item)) return; if (m_children.contains(item))
return;
m_isRelocating = true; m_isRelocating = true;
insertItemInLayout(item); insertItemInLayout(item);
@ -97,7 +88,8 @@ bool AbstractLayout::isEmpty() const
bool allItemsIsText = true; bool allItemsIsText = true;
foreach (QGraphicsItem* qgItem, childItems()) { foreach (QGraphicsItem* qgItem, childItems()) {
ContentItemDesignIntf* item = dynamic_cast<ContentItemDesignIntf*>(qgItem); 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)) if (!item && dynamic_cast<BaseDesignIntf*>(qgItem))
allItemsIsText = false; allItemsIsText = false;
} }
@ -111,15 +103,12 @@ void AbstractLayout::paintChild(BaseDesignIntf *child, QPointF parentPos, QPaint
paintChild(item, child->pos(), painter); paintChild(item, child->pos(), painter);
} }
} }
painter->drawRect( painter->drawRect(QRectF(parentPos.x() + child->pos().x(), parentPos.y() + child->pos().y(),
QRectF(parentPos.x()+child->pos().x(), parentPos.y()+child->pos().y(), child->rect().bottomRight().rx(), child->rect().bottomRight().ry()));
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->save();
@ -132,10 +121,7 @@ void AbstractLayout::paint(QPainter* painter, const QStyleOptionGraphicsItem* op
LayoutDesignIntf::paint(painter, option, widget); LayoutDesignIntf::paint(painter, option, widget);
} }
int AbstractLayout::childrenCount() int AbstractLayout::childrenCount() { return m_children.size(); }
{
return m_children.size();
}
void AbstractLayout::beforeDelete() void AbstractLayout::beforeDelete()
{ {
@ -158,10 +144,7 @@ void AbstractLayout::beforeDelete()
m_children.clear(); m_children.clear();
} }
void AbstractLayout::childAddedEvent(BaseDesignIntf* child) void AbstractLayout::childAddedEvent(BaseDesignIntf* child) { addChild(child, false); }
{
addChild(child,false);
}
void AbstractLayout::geometryChangedEvent(QRectF newRect, QRectF) void AbstractLayout::geometryChangedEvent(QRectF newRect, QRectF)
{ {
@ -245,7 +228,8 @@ void AbstractLayout::updateItemSize(DataSourceManager* dataManager, RenderPass p
BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight); BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight);
} }
void AbstractLayout::rebuildChildrenIfNeeded(){ void AbstractLayout::rebuildChildrenIfNeeded()
{
if (layoutsChildren().count() < childItems().size() - 1) { if (layoutsChildren().count() < childItems().size() - 1) {
layoutsChildren().clear(); layoutsChildren().clear();
foreach (BaseDesignIntf* childItem, childBaseItems()) { foreach (BaseDesignIntf* childItem, childBaseItems()) {
@ -257,57 +241,39 @@ void AbstractLayout::rebuildChildrenIfNeeded(){
void AbstractLayout::connectToLayout(BaseDesignIntf* item) void AbstractLayout::connectToLayout(BaseDesignIntf* item)
{ {
connect( connect(item, SIGNAL(destroyed(QObject*)), this, SLOT(slotOnChildDestroy(QObject*)));
item, SIGNAL(destroyed(QObject*)), connect(item, SIGNAL(geometryChanged(QObject*, QRectF, QRectF)), this,
this, SLOT(slotOnChildDestroy(QObject*)) SLOT(slotOnChildGeometryChanged(QObject*, QRectF, QRectF)));
); connect(item, SIGNAL(itemVisibleHasChanged(BaseDesignIntf*)), this,
connect( SLOT(slotOnChildVisibleHasChanged(BaseDesignIntf*)));
item,SIGNAL(geometryChanged(QObject*,QRectF,QRectF)), connect(item, SIGNAL(itemSelectedHasBeenChanged(BaseDesignIntf*, bool)), this,
this,SLOT(slotOnChildGeometryChanged(QObject*,QRectF,QRectF)) SLOT(slotOnChildSelectionHasChanged(BaseDesignIntf*, bool)));
); connect(item, SIGNAL(itemAlignChanged(BaseDesignIntf*, const ItemAlign&, const ItemAlign&)),
connect( this,
item, SIGNAL(itemVisibleHasChanged(BaseDesignIntf*)), SLOT(slotOnChildItemAlignChanged(BaseDesignIntf*, const ItemAlign&, const ItemAlign&)));
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( disconnect(
item, SIGNAL(destroyed(QObject*)), item, SIGNAL(itemAlignChanged(BaseDesignIntf*, const ItemAlign&, const ItemAlign&)), this,
this, SLOT(slotOnChildDestroy(QObject*)) SLOT(slotOnChildItemAlignChanged(BaseDesignIntf*, const ItemAlign&, const ItemAlign&)));
);
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&))
);
} }
BaseDesignIntf* AbstractLayout::findNext(BaseDesignIntf* item) BaseDesignIntf* AbstractLayout::findNext(BaseDesignIntf* item)
{ {
rebuildChildrenIfNeeded(); rebuildChildrenIfNeeded();
for (int i = 0; i < layoutsChildren().count(); ++i) { for (int i = 0; i < layoutsChildren().count(); ++i) {
if (layoutsChildren()[i]==item && layoutsChildren().size()>i+1){ return layoutsChildren()[i+1];} if (layoutsChildren()[i] == item && layoutsChildren().size() > i + 1) {
return layoutsChildren()[i + 1];
}
} }
return 0; return 0;
} }
@ -316,12 +282,15 @@ BaseDesignIntf *AbstractLayout::findPrior(BaseDesignIntf *item)
{ {
rebuildChildrenIfNeeded(); rebuildChildrenIfNeeded();
for (int i = 0; i < layoutsChildren().count(); ++i) { for (int i = 0; i < layoutsChildren().count(); ++i) {
if (layoutsChildren()[i]==item && i!=0){ return layoutsChildren()[i-1];} if (layoutsChildren()[i] == item && i != 0) {
return layoutsChildren()[i - 1];
}
} }
return 0; return 0;
} }
void AbstractLayout::insertItemInLayout(BaseDesignIntf *item){ void AbstractLayout::insertItemInLayout(BaseDesignIntf* item)
{
bool inserted = false; bool inserted = false;
for (int i = 0; i < layoutsChildren().length(); ++i) { for (int i = 0; i < layoutsChildren().length(); ++i) {
BaseDesignIntf* child = layoutsChildren()[i]; BaseDesignIntf* child = layoutsChildren()[i];
@ -331,7 +300,8 @@ void AbstractLayout::insertItemInLayout(BaseDesignIntf *item){
break; break;
} }
} }
if (!inserted) layoutsChildren().append(item); if (!inserted)
layoutsChildren().append(item);
} }
void AbstractLayout::slotOnChildDestroy(QObject* child) void AbstractLayout::slotOnChildDestroy(QObject* child)
@ -345,7 +315,8 @@ void AbstractLayout::slotOnChildDestroy(QObject* child)
} }
} }
void AbstractLayout::slotOnChildGeometryChanged(QObject* item, QRectF newGeometry, QRectF oldGeometry) void AbstractLayout::slotOnChildGeometryChanged(QObject* item, QRectF newGeometry,
QRectF oldGeometry)
{ {
if (!m_isRelocating && !isLoading()) { if (!m_isRelocating && !isLoading()) {
if (m_layoutType == Layout) { if (m_layoutType == Layout) {
@ -365,7 +336,8 @@ void AbstractLayout::slotOnChildGeometryChanged(QObject* item, QRectF newGeometr
} }
} }
void AbstractLayout::slotOnChildItemAlignChanged(BaseDesignIntf* item, const ItemAlign&, const ItemAlign&) void AbstractLayout::slotOnChildItemAlignChanged(BaseDesignIntf* item, const ItemAlign&,
const ItemAlign&)
{ {
item->setPossibleResizeDirectionFlags(ResizeBottom | ResizeRight); item->setPossibleResizeDirectionFlags(ResizeBottom | ResizeRight);
} }
@ -383,10 +355,7 @@ void AbstractLayout::slotOnChildSelectionHasChanged(BaseDesignIntf* item, bool v
item->setZValue(value ? item->zValue() + 1 : item->zValue() - 1); item->setZValue(value ? item->zValue() + 1 : item->zValue() - 1);
} }
int AbstractLayout::layoutSpacing() const int AbstractLayout::layoutSpacing() const { return m_layoutSpacing; }
{
return m_layoutSpacing;
}
void AbstractLayout::setLayoutSpacing(int layoutSpacing) void AbstractLayout::setLayoutSpacing(int layoutSpacing)
{ {
@ -402,10 +371,7 @@ void AbstractLayout::setLayoutSpacing(int layoutSpacing)
} }
} }
bool AbstractLayout::hideEmptyItems() const bool AbstractLayout::hideEmptyItems() const { return m_hideEmptyItems; }
{
return m_hideEmptyItems;
}
void AbstractLayout::setHideEmptyItems(bool hideEmptyItems) void AbstractLayout::setHideEmptyItems(bool hideEmptyItems)
{ {
@ -420,13 +386,11 @@ void AbstractLayout::setHideEmptyItems(bool hideEmptyItems)
QObject* AbstractLayout::at(int index) QObject* AbstractLayout::at(int index)
{ {
rebuildChildrenIfNeeded(); rebuildChildrenIfNeeded();
if (layoutsChildren().size() > index) return layoutsChildren()[index]; if (layoutsChildren().size() > index)
return layoutsChildren()[index];
return 0; return 0;
} }
LayoutMarker* AbstractLayout::layoutMarker() const LayoutMarker* AbstractLayout::layoutMarker() const { return m_layoutMarker; }
{
return m_layoutMarker;
}
} // namespace LimeReport } // namespace LimeReport

View File

@ -3,16 +3,19 @@
#include "lritemdesignintf.h" #include "lritemdesignintf.h"
#include "lrlayoutmarker.h" #include "lrlayoutmarker.h"
#include <QtGlobal> #include <QtGlobal>
namespace LimeReport { namespace LimeReport {
class AbstractLayout: public LayoutDesignIntf class AbstractLayout: public LayoutDesignIntf {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool hideEmptyItems READ hideEmptyItems WRITE setHideEmptyItems) Q_PROPERTY(bool hideEmptyItems READ hideEmptyItems WRITE setHideEmptyItems)
Q_PROPERTY(int layoutSpacing READ layoutSpacing WRITE setLayoutSpacing) Q_PROPERTY(int layoutSpacing READ layoutSpacing WRITE setLayoutSpacing)
public: public:
enum LayoutType{Layout,Table}; enum LayoutType {
Layout,
Table
};
#if QT_VERSION >= 0x050500 #if QT_VERSION >= 0x050500
Q_ENUM(LayoutType) Q_ENUM(LayoutType)
#else #else
@ -41,6 +44,7 @@ public:
int layoutSpacing() const; int layoutSpacing() const;
void setLayoutSpacing(int layoutSpacing); void setLayoutSpacing(int layoutSpacing);
qreal layoutSpacingMM() { return m_layoutSpacing * Const::mmFACTOR; } qreal layoutSpacingMM() { return m_layoutSpacing * Const::mmFACTOR; }
protected: protected:
void beforeDelete(); void beforeDelete();
void childAddedEvent(BaseDesignIntf* child); void childAddedEvent(BaseDesignIntf* child);
@ -56,6 +60,7 @@ protected:
void connectToLayout(BaseDesignIntf* item); void connectToLayout(BaseDesignIntf* item);
void disconnectFromLayout(BaseDesignIntf* item); void disconnectFromLayout(BaseDesignIntf* item);
virtual void insertItemInLayout(BaseDesignIntf* item); virtual void insertItemInLayout(BaseDesignIntf* item);
private: private:
virtual void sortChildren() = 0; virtual void sortChildren() = 0;
virtual void divideSpace() = 0; virtual void divideSpace() = 0;
@ -71,6 +76,7 @@ private slots:
void slotOnChildItemAlignChanged(BaseDesignIntf* item, const ItemAlign&, const ItemAlign&); void slotOnChildItemAlignChanged(BaseDesignIntf* item, const ItemAlign&, const ItemAlign&);
void slotOnChildVisibleHasChanged(BaseDesignIntf*); void slotOnChildVisibleHasChanged(BaseDesignIntf*);
void slotOnChildSelectionHasChanged(BaseDesignIntf* item, bool value); void slotOnChildSelectionHasChanged(BaseDesignIntf* item, bool value);
private: private:
QList<BaseDesignIntf*> m_children; QList<BaseDesignIntf*> m_children;
bool m_isRelocating; bool m_isRelocating;

View File

@ -28,23 +28,26 @@
* GNU General Public License for more details. * * GNU General Public License for more details. *
****************************************************************************/ ****************************************************************************/
#include "lralignpropitem.h" #include "lralignpropitem.h"
#include "objectinspector/propertyItems/lrenumpropitem.h"
#include "objectinspector/editors/lrcomboboxeditor.h"
#include "lrtextitem.h" #include "lrtextitem.h"
#include "objectinspector/editors/lrcomboboxeditor.h"
#include "objectinspector/propertyItems/lrenumpropitem.h"
namespace { namespace {
LimeReport::ObjectPropItem * createAlignItem( LimeReport::ObjectPropItem* createAlignItem(QObject* object,
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly LimeReport::ObjectPropItem::ObjectsList* objects,
){ const QString& name, const QString& displayName,
return new LimeReport::AlignmentPropItem(object, objects, name, displayName, data, parent, readonly); 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( bool VARIABLE_IS_NOT_USED registred = LimeReport::ObjectPropFactory::instance().registerCreator(
LimeReport::APropIdent("alignment","LimeReport::TextItem"), LimeReport::APropIdent("alignment", "LimeReport::TextItem"), QObject::tr("alignment"),
QObject::tr("alignment"), createAlignItem);
createAlignItem } // namespace
);
}
namespace LimeReport { namespace LimeReport {
@ -54,15 +57,19 @@ QString AlignmentPropItem::associateValue(int value, const AlignMap* map) const
QMap<QString, Qt::Alignment>::const_iterator it = map->constBegin(); QMap<QString, Qt::Alignment>::const_iterator it = map->constBegin();
for (; it != map->constEnd(); ++it) { for (; it != map->constEnd(); ++it) {
if ((value & it.value())) { if ((value & it.value())) {
if (result.isEmpty()) result+=it.key(); if (result.isEmpty())
else result=result+" | "+it.key(); result += it.key();
else
result = result + " | " + it.key();
} }
} }
return result; return result;
} }
AlignmentPropItem::AlignmentPropItem(QObject *object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value, ObjectPropItem *parent, bool readonly) AlignmentPropItem::AlignmentPropItem(QObject* object, ObjectsList* objects, const QString& name,
:ObjectPropItem(object, objects, name,displayName,value,parent,readonly) 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("Left"), Qt::AlignLeft);
@ -74,8 +81,10 @@ AlignmentPropItem::AlignmentPropItem(QObject *object, ObjectsList* objects, cons
m_vertMap.insert(tr("Center"), Qt::AlignVCenter); m_vertMap.insert(tr("Center"), Qt::AlignVCenter);
m_vertMap.insert(tr("Botom"), Qt::AlignBottom); m_vertMap.insert(tr("Botom"), Qt::AlignBottom);
m_horizEditor = new AlignmentItemEditor(object, objects, name,tr("horizontal"),value.toInt(),this,false,m_horizMap); m_horizEditor = new AlignmentItemEditor(object, objects, name, tr("horizontal"), value.toInt(),
m_vertEditor = new AlignmentItemEditor(object, objects, name,tr("vertical"), value.toInt(),this,false,m_vertMap); 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_horizEditor);
this->appendItem(m_vertEditor); this->appendItem(m_vertEditor);
@ -83,8 +92,8 @@ AlignmentPropItem::AlignmentPropItem(QObject *object, ObjectsList* objects, cons
QString AlignmentPropItem::displayValue() const QString AlignmentPropItem::displayValue() const
{ {
return associateValue(propertyValue().toInt(),&m_horizMap)+" | "+ return associateValue(propertyValue().toInt(), &m_horizMap) + " | "
associateValue(propertyValue().toInt(),&m_vertMap); + associateValue(propertyValue().toInt(), &m_vertMap);
} }
void AlignmentPropItem::setPropertyValue(QVariant value) void AlignmentPropItem::setPropertyValue(QVariant value)
@ -94,23 +103,30 @@ void AlignmentPropItem::setPropertyValue(QVariant value)
ObjectPropItem::setPropertyValue(value); ObjectPropItem::setPropertyValue(value);
} }
AlignmentItemEditor::AlignmentItemEditor(QObject *object, ObjectsList* objects, const QString &name, const QString &displayName, const QVariant &value, ObjectPropItem *parent, AlignmentItemEditor::AlignmentItemEditor(QObject* object, ObjectsList* objects, const QString& name,
bool readonly, AlignMap acceptableValues) const QString& displayName, const QVariant& value,
:ObjectPropItem(object, objects, name, displayName, value, parent, readonly),m_acceptableValues(acceptableValues) 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]); 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 flags = object()->property(propertyName().toLatin1()).toInt();
int align = m_acceptableValues.value(qobject_cast<ComboBoxEditor*>(propertyEditor)->text()); int align = m_acceptableValues.value(qobject_cast<ComboBoxEditor*>(propertyEditor)->text());
flags = clearAcceptableValues(flags) | align; flags = clearAcceptableValues(flags) | align;
object()->setProperty(propertyName().toLatin1(), flags); object()->setProperty(propertyName().toLatin1(), flags);
if (objects()) if (objects())
foreach(QObject* item,*objects()){item->setProperty(propertyName().toLatin1(),flags);} foreach (QObject* item, *objects()) {
item->setProperty(propertyName().toLatin1(), flags);
}
parent()->setPropertyValue(flags); parent()->setPropertyValue(flags);
model->setData(index, align); model->setData(index, align);
} }
@ -119,19 +135,17 @@ QVector<int> AlignmentItemEditor::extractAcceptableValue(int flags)
{ {
QVector<int> result; QVector<int> result;
AlignMap::const_iterator it = m_acceptableValues.constBegin(); AlignMap::const_iterator it = m_acceptableValues.constBegin();
for (;it != m_acceptableValues.constEnd();++it) for (; it != m_acceptableValues.constEnd(); ++it) {
{ if (flags & it.value())
if (flags & it.value()) result<<it.value(); result << it.value();
} }
return result; return result;
} }
int AlignmentItemEditor::clearAcceptableValues(int flags) int AlignmentItemEditor::clearAcceptableValues(int flags)
{ {
AlignMap::const_iterator it = m_acceptableValues.constBegin(); AlignMap::const_iterator it = m_acceptableValues.constBegin();
for (;it != m_acceptableValues.constEnd();++it) for (; it != m_acceptableValues.constEnd(); ++it) {
{
if (flags & it.value()) if (flags & it.value())
flags = flags ^ it.value(); flags = flags ^ it.value();
} }
@ -161,9 +175,10 @@ QString AlignmentItemEditor::displayValue() const
void AlignmentItemEditor::setPropertyValue(QVariant value) void AlignmentItemEditor::setPropertyValue(QVariant value)
{ {
QVector<int> _accpepttableValueList = extractAcceptableValue(value.toInt()); QVector<int> _accpepttableValueList = extractAcceptableValue(value.toInt());
if(_accpepttableValueList.isEmpty()) return; if (_accpepttableValueList.isEmpty())
return;
ObjectPropItem::setPropertyValue(_accpepttableValueList[0]); ObjectPropItem::setPropertyValue(_accpepttableValueList[0]);
} }
} } // namespace LimeReport

View File

@ -39,14 +39,16 @@ typedef QMap<QString,Qt::Alignment> AlignMap;
class AlignmentItemEditor; class AlignmentItemEditor;
class AlignmentPropItem : public ObjectPropItem class AlignmentPropItem: public ObjectPropItem {
{
Q_OBJECT Q_OBJECT
public: public:
AlignmentPropItem(): ObjectPropItem(), m_horizEditor(NULL), m_vertEditor(NULL) { } AlignmentPropItem(): ObjectPropItem(), m_horizEditor(NULL), m_vertEditor(NULL) { }
AlignmentPropItem(QObject *object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value, ObjectPropItem* parent, bool readonly=true); AlignmentPropItem(QObject* object, ObjectsList* objects, const QString& name,
const QString& displayName, const QVariant& value, ObjectPropItem* parent,
bool readonly = true);
QString displayValue() const; QString displayValue() const;
void setPropertyValue(QVariant value); void setPropertyValue(QVariant value);
private: private:
AlignMap m_vertMap; AlignMap m_vertMap;
AlignMap m_horizMap; AlignMap m_horizMap;
@ -55,26 +57,27 @@ private:
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 Q_OBJECT
public: public:
AlignmentItemEditor(): ObjectPropItem() { } AlignmentItemEditor(): ObjectPropItem() { }
AlignmentItemEditor(QObject* object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value, ObjectPropItem* parent, bool readonly, AlignmentItemEditor(QObject* object, ObjectsList* objects, const QString& name,
AlignMap acceptableValues); const QString& displayName, const QVariant& value, ObjectPropItem* parent,
bool readonly, AlignMap acceptableValues);
void setModelData(QWidget* propertyEditor, QAbstractItemModel* model, const QModelIndex& index); void setModelData(QWidget* propertyEditor, QAbstractItemModel* model, const QModelIndex& index);
void setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const; void setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const;
QWidget* createProperyEditor(QWidget* parent) const; QWidget* createProperyEditor(QWidget* parent) const;
QString displayValue() const; QString displayValue() const;
void setPropertyValue(QVariant value); void setPropertyValue(QVariant value);
protected: protected:
QVector<int> extractAcceptableValue(int flags); QVector<int> extractAcceptableValue(int flags);
int clearAcceptableValues(int flags); int clearAcceptableValues(int flags);
AlignMap acceptableValues() const { return m_acceptableValues; } AlignMap acceptableValues() const { return m_acceptableValues; }
private: private:
AlignMap m_acceptableValues; AlignMap m_acceptableValues;
}; };
} // namespace LimeReport
}
#endif // LRALIGNPROPITEM_H #endif // LRALIGNPROPITEM_H

View File

@ -28,32 +28,45 @@
* GNU General Public License for more details. * * GNU General Public License for more details. *
****************************************************************************/ ****************************************************************************/
#include "lrbarcodeitem.h" #include "lrbarcodeitem.h"
#include "lrdesignelementsfactory.h" #include "lrdesignelementsfactory.h"
#include "qzint.h"
#include "lrglobal.h" #include "lrglobal.h"
#include "qzint.h"
namespace { namespace {
const QString xmlTag = "BarcodeItem"; const QString xmlTag = "BarcodeItem";
LimeReport::BaseDesignIntf * createBarcodeItem(QObject* owner, LimeReport::BaseDesignIntf* parent){ LimeReport::BaseDesignIntf* createBarcodeItem(QObject* owner, LimeReport::BaseDesignIntf* parent)
{
return new LimeReport::BarcodeItem(owner, parent); return new LimeReport::BarcodeItem(owner, parent);
} }
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(xmlTag, LimeReport::ItemAttribs(QObject::tr("Barcode Item"),"Item"), createBarcodeItem); bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
xmlTag, LimeReport::ItemAttribs(QObject::tr("Barcode Item"), "Item"), createBarcodeItem);
} } // namespace
namespace LimeReport { namespace LimeReport {
BarcodeItem::BarcodeItem(QObject* owner,QGraphicsItem* parent) BarcodeItem::BarcodeItem(QObject* owner, QGraphicsItem* parent):
: ContentItemDesignIntf(xmlTag,owner,parent),m_designTestValue("1"), m_barcodeType(CODE128), ContentItemDesignIntf(xmlTag, owner, parent),
m_foregroundColor(Qt::black), m_backgroundColor(Qt::white), m_whitespace(10), m_angle(Angle0), m_designTestValue("1"),
m_barcodeWidth(0), m_securityLevel(0), m_pdf417CodeWords(928), m_inputMode(UNICODE_INPUT_MODE), m_barcodeType(CODE128),
m_hideText(false), m_option3(0), m_hideIfEmpty(false) m_foregroundColor(Qt::black),
{} m_backgroundColor(Qt::white),
m_whitespace(10),
m_angle(Angle0),
m_barcodeWidth(0),
m_securityLevel(0),
m_pdf417CodeWords(928),
m_inputMode(UNICODE_INPUT_MODE),
m_hideText(false),
m_option3(0),
m_hideIfEmpty(false)
{
}
BarcodeItem::~BarcodeItem() BarcodeItem::~BarcodeItem() { }
{}
BaseDesignIntf* BarcodeItem::createSameTypeItem(QObject* owner, QGraphicsItem* parent) BaseDesignIntf* BarcodeItem::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
{ {
@ -64,8 +77,10 @@ void BarcodeItem::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *opti
{ {
ppainter->save(); ppainter->save();
Zint::QZint bc; Zint::QZint bc;
if (itemMode() & DesignMode) bc.setText(m_designTestValue); if (itemMode() & DesignMode)
else bc.setText(m_content); bc.setText(m_designTestValue);
else
bc.setText(m_content);
bc.setInputMode(m_inputMode); bc.setInputMode(m_inputMode);
bc.setSymbol(m_barcodeType); bc.setSymbol(m_barcodeType);
bc.setWhitespace(m_whitespace); bc.setWhitespace(m_whitespace);
@ -77,7 +92,8 @@ void BarcodeItem::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *opti
bc.setHideText(m_hideText); bc.setHideText(m_hideText);
bc.setOption3(m_option3); bc.setOption3(m_option3);
if (isSelected()) ppainter->setOpacity(Const::SELECTION_OPACITY); if (isSelected())
ppainter->setOpacity(Const::SELECTION_OPACITY);
QRectF bcRect; QRectF bcRect;
@ -117,10 +133,7 @@ void BarcodeItem::setContent(const QString &content)
} }
} }
QString BarcodeItem::datasource() const QString BarcodeItem::datasource() const { return m_datasource; }
{
return m_datasource;
}
void BarcodeItem::setDatasource(const QString& datasource) void BarcodeItem::setDatasource(const QString& datasource)
{ {
@ -132,10 +145,7 @@ void BarcodeItem::setDatasource(const QString &datasource)
} }
} }
QString BarcodeItem::field() const QString BarcodeItem::field() const { return m_field; }
{
return m_field;
}
void BarcodeItem::setField(const QString& field) void BarcodeItem::setField(const QString& field)
{ {
@ -197,10 +207,7 @@ void BarcodeItem::setWhitespace(int value)
} }
} }
BarcodeItem::AngleType BarcodeItem::angle() const BarcodeItem::AngleType BarcodeItem::angle() const { return m_angle; }
{
return m_angle;
}
void BarcodeItem::setAngle(const AngleType& angle) void BarcodeItem::setAngle(const AngleType& angle)
{ {
@ -214,10 +221,7 @@ void BarcodeItem::setAngle(const AngleType &angle)
} }
} }
int BarcodeItem::barcodeWidth() const int BarcodeItem::barcodeWidth() const { return m_barcodeWidth; }
{
return m_barcodeWidth;
}
void BarcodeItem::setBarcodeWidth(int barcodeWidth) void BarcodeItem::setBarcodeWidth(int barcodeWidth)
{ {
@ -231,10 +235,7 @@ void BarcodeItem::setBarcodeWidth(int barcodeWidth)
} }
} }
int BarcodeItem::securityLevel() const int BarcodeItem::securityLevel() const { return m_securityLevel; }
{
return m_securityLevel;
}
void BarcodeItem::setSecurityLevel(int securityLevel) void BarcodeItem::setSecurityLevel(int securityLevel)
{ {
@ -248,10 +249,7 @@ void BarcodeItem::setSecurityLevel(int securityLevel)
} }
} }
int BarcodeItem::pdf417CodeWords() const int BarcodeItem::pdf417CodeWords() const { return m_pdf417CodeWords; }
{
return m_pdf417CodeWords;
}
void BarcodeItem::setPdf417CodeWords(int pdf417CodeWords) void BarcodeItem::setPdf417CodeWords(int pdf417CodeWords)
{ {
@ -265,10 +263,7 @@ void BarcodeItem::setPdf417CodeWords(int pdf417CodeWords)
} }
} }
BarcodeItem::InputMode BarcodeItem::inputMode() const BarcodeItem::InputMode BarcodeItem::inputMode() const { return m_inputMode; }
{
return m_inputMode;
}
void BarcodeItem::setInputMode(const InputMode& inputMode) void BarcodeItem::setInputMode(const InputMode& inputMode)
{ {
@ -282,10 +277,7 @@ void BarcodeItem::setInputMode(const InputMode &inputMode)
} }
} }
bool BarcodeItem::hideText() const bool BarcodeItem::hideText() const { return m_hideText; }
{
return m_hideText;
}
void BarcodeItem::setHideText(bool hideText) void BarcodeItem::setHideText(bool hideText)
{ {
@ -298,10 +290,7 @@ void BarcodeItem::setHideText(bool hideText)
} }
} }
int BarcodeItem::option3() const int BarcodeItem::option3() const { return m_option3; }
{
return m_option3;
}
void BarcodeItem::setOption3(int option3) void BarcodeItem::setOption3(int option3)
{ {
@ -315,10 +304,7 @@ void BarcodeItem::setOption3(int option3)
} }
} }
bool BarcodeItem::hideIfEmpty() const bool BarcodeItem::hideIfEmpty() const { return m_hideIfEmpty; }
{
return m_hideIfEmpty;
}
void BarcodeItem::setHideIfEmpty(bool hideIfEmpty) void BarcodeItem::setHideIfEmpty(bool hideIfEmpty)
{ {
@ -328,10 +314,7 @@ void BarcodeItem::setHideIfEmpty(bool hideIfEmpty)
} }
} }
bool BarcodeItem::isEmpty() const bool BarcodeItem::isEmpty() const { return m_content.isEmpty(); }
{
return m_content.isEmpty();
}
void BarcodeItem::expandContent(QString data, DataSourceManager* dataManager, RenderPass pass) 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) void BarcodeItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight)
{ {
if (content().isEmpty()) if (content().isEmpty()) {
{ if (!m_datasource.isEmpty() && !m_field.isEmpty()) {
if (!m_datasource.isEmpty() && !m_field.isEmpty())
{
IDataSource* ds = dataManager->dataSource(m_datasource); IDataSource* ds = dataManager->dataSource(m_datasource);
if (ds) if (ds) {
{
QVariant data = ds->data(m_field); QVariant data = ds->data(m_field);
if (data.isValid()) if (data.isValid()) {
{ switch (pass) {
switch(pass)
{
case FirstPass: case FirstPass:
expandContent(data.toString(), dataManager, pass); expandContent(data.toString(), dataManager, pass);
break; break;
@ -371,10 +349,13 @@ void BarcodeItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass
} }
} }
BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight); BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight);
if (isEmpty() && hideIfEmpty()) setVisible(false); if (isEmpty() && hideIfEmpty())
setVisible(false);
} }
bool BarcodeItem::isNeedUpdateSize(RenderPass pass) const bool BarcodeItem::isNeedUpdateSize(RenderPass pass) const
{return (pass==FirstPass)?true:false;} {
return (pass == FirstPass) ? true : false;
} }
} // namespace LimeReport

View File

@ -30,6 +30,7 @@
#ifndef LRBARCODEITEM_H #ifndef LRBARCODEITEM_H
#define LRBARCODEITEM_H #define LRBARCODEITEM_H
#include "lritemdesignintf.h" #include "lritemdesignintf.h"
#include <QtGlobal> #include <QtGlobal>
namespace LimeReport { namespace LimeReport {
@ -140,10 +141,14 @@ public:
CODEONE = 141, CODEONE = 141,
GRIDMATRIX = 142, GRIDMATRIX = 142,
UPNQR = 143 UPNQR = 143
}; };
enum AngleType{Angle0,Angle90,Angle180,Angle270}; enum AngleType {
Angle0,
Angle90,
Angle180,
Angle270
};
enum InputMode { enum InputMode {
DATA_INPUT_MODE = 0, DATA_INPUT_MODE = 0,
@ -223,5 +228,5 @@ private:
bool m_hideIfEmpty; bool m_hideIfEmpty;
}; };
} } // namespace LimeReport
#endif // LRBARCODEITEM_H #endif // LRBARCODEITEM_H

View File

@ -1,8 +1,10 @@
#include "lrbordereditor.h" #include "lrbordereditor.h"
#include "ui_lrbordereditor.h" #include "ui_lrbordereditor.h"
#include <QColorDialog>
#include "lrbasedesignintf.h" #include "lrbasedesignintf.h"
#include <QColorDialog>
namespace LimeReport { namespace LimeReport {
BorderEditor::BorderEditor(QWidget* parent): BorderEditor::BorderEditor(QWidget* parent):
@ -12,23 +14,26 @@ BorderEditor::BorderEditor(QWidget *parent) :
m_borderWidth(1) m_borderWidth(1)
{ {
ui->setupUi(this); ui->setupUi(this);
connect( connect(ui->borderFrame,
ui->borderFrame, SIGNAL(borderSideClicked(LimeReport::BaseDesignIntf::BorderSide, bool)), SIGNAL(borderSideClicked(LimeReport::BaseDesignIntf::BorderSide, bool)), this,
this, SLOT(checkToolButtons(LimeReport::BaseDesignIntf::BorderSide, bool)) SLOT(checkToolButtons(LimeReport::BaseDesignIntf::BorderSide, bool)));
);
} }
void BorderEditor::loadItem(LimeReport::BaseDesignIntf* item) void BorderEditor::loadItem(LimeReport::BaseDesignIntf* item)
{ {
m_item = item; m_item = item;
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine, 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, 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, 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, emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::BottomLine,
item->borderLines() & LimeReport::BaseDesignIntf::BottomLine); item->borderLines()
& LimeReport::BaseDesignIntf::BottomLine);
QPen pen; QPen pen;
pen.setWidthF(item->borderLineSize()); pen.setWidthF(item->borderLineSize());
@ -58,20 +63,11 @@ LimeReport::BaseDesignIntf::BorderStyle BorderEditor::borderStyle()
return (LimeReport::BaseDesignIntf::BorderStyle)m_borderStyle; return (LimeReport::BaseDesignIntf::BorderStyle)m_borderStyle;
} }
QString BorderEditor::borderColor() QString BorderEditor::borderColor() { return m_borderColor; }
{
return m_borderColor;
}
double BorderEditor::borderWidth() double BorderEditor::borderWidth() { return m_borderWidth; }
{
return m_borderWidth;
}
BorderEditor::~BorderEditor() BorderEditor::~BorderEditor() { delete ui; }
{
delete ui;
}
void BorderEditor::on_listWidget_currentRowChanged(int currentRow) void BorderEditor::on_listWidget_currentRowChanged(int currentRow)
{ {
@ -91,8 +87,7 @@ void BorderEditor::on_comboBox_currentTextChanged(const QString &arg1)
void BorderEditor::checkToolButtons(LimeReport::BaseDesignIntf::BorderSide side, bool check) void BorderEditor::checkToolButtons(LimeReport::BaseDesignIntf::BorderSide side, bool check)
{ {
switch(side) switch (side) {
{
case BaseDesignIntf::BorderSide::TopLine: case BaseDesignIntf::BorderSide::TopLine:
ui->topLine->setChecked(check); ui->topLine->setChecked(check);
break; break;
@ -108,44 +103,53 @@ void BorderEditor::checkToolButtons(LimeReport::BaseDesignIntf::BorderSide side,
} }
} }
void BorderEditor::on_topLine_clicked(bool checked){ void BorderEditor::on_topLine_clicked(bool checked)
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine, 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); 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); 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); emit ui->borderFrame->borderSideClicked(BaseDesignIntf::BorderSide::RightLine, checked);
} }
void BorderEditor::on_allLines_clicked() void BorderEditor::on_allLines_clicked()
{ {
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine, true); 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::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() void BorderEditor::on_noLines_clicked()
{ {
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::TopLine, false); 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::BottomLine,
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::LeftLine, false); false);
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::RightLine, false); emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::LeftLine,
false);
emit ui->borderFrame->borderSideClicked(LimeReport::BaseDesignIntf::BorderSide::RightLine,
false);
} }
void BorderEditor::on_selectColor_clicked() void BorderEditor::on_selectColor_clicked()
{ {
QColorDialog cd(this); QColorDialog cd(this);
if(cd.exec() == QDialog::Rejected) return; if (cd.exec() == QDialog::Rejected)
return;
QPen pen = ui->borderFrame->pen(); QPen pen = ui->borderFrame->pen();
pen.setColor(cd.selectedColor().name()); pen.setColor(cd.selectedColor().name());
m_borderColor = pen.color().name(); m_borderColor = pen.color().name();

View File

@ -1,18 +1,17 @@
#ifndef LRBORDEREDITOR_H #ifndef LRBORDEREDITOR_H
#define LRBORDEREDITOR_H #define LRBORDEREDITOR_H
#include <QDialog>
#include "lrbasedesignintf.h" #include "lrbasedesignintf.h"
#include <QDialog>
namespace LimeReport { namespace LimeReport {
namespace Ui { namespace Ui {
class BorderEditor; class BorderEditor;
} }
class LIMEREPORT_EXPORT BorderEditor: public QDialog {
class LIMEREPORT_EXPORT BorderEditor : public QDialog
{
Q_OBJECT Q_OBJECT
public: public:

View File

@ -1,17 +1,19 @@
#include "lrborderframeeditor.h" #include "lrborderframeeditor.h"
#include "ui_lrborderframeeditor.h" #include "ui_lrborderframeeditor.h"
#include <QPainter>
#include <QGraphicsLineItem>
#include <QDebug>
#include <QMouseEvent>
#include "lrbasedesignintf.h" #include "lrbasedesignintf.h"
#include "lrbordereditor.h" #include "lrbordereditor.h"
#include <QDebug>
#include <QGraphicsLineItem>
#include <QMouseEvent>
#include <QPainter>
namespace LimeReport { namespace LimeReport {
BorderFrameEditor::BorderFrameEditor(QWidget *parent) BorderFrameEditor::BorderFrameEditor(QWidget* parent):
: QWidget(parent) QWidget(parent),
, ui(new Ui::BorderFrameEditor) ui(new Ui::BorderFrameEditor)
{ {
ui->setupUi(this); ui->setupUi(this);
scene = new QGraphicsScene(ui->graphicsView); scene = new QGraphicsScene(ui->graphicsView);
@ -26,8 +28,10 @@ BorderFrameEditor::BorderFrameEditor(QWidget *parent)
scene->addLine(10, vRect.bottom() - 5, 10, vRect.bottom() - 10, QPen(Qt::gray)); scene->addLine(10, vRect.bottom() - 5, 10, vRect.bottom() - 10, QPen(Qt::gray));
scene->addLine(5, vRect.bottom() - 10, 10, vRect.bottom() - 10, QPen(Qt::gray)); scene->addLine(5, vRect.bottom() - 10, 10, vRect.bottom() - 10, QPen(Qt::gray));
// bottomRight // bottomRight
scene->addLine(vRect.right() - 10, vRect.bottom() - 5, vRect.right()- 10, vRect.bottom() - 10, QPen(Qt::gray)); scene->addLine(vRect.right() - 10, vRect.bottom() - 5, vRect.right() - 10, vRect.bottom() - 10,
scene->addLine(vRect.right() - 5, vRect.bottom() - 10, vRect.right() - 10, vRect.bottom() - 10, QPen(Qt::gray)); QPen(Qt::gray));
scene->addLine(vRect.right() - 5, vRect.bottom() - 10, vRect.right() - 10, vRect.bottom() - 10,
QPen(Qt::gray));
// topRight // topRight
scene->addLine(vRect.width() - 10, 5, vRect.width() - 10, 10, QPen(Qt::gray)); 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->addLine(vRect.width() - 5, 10, vRect.width() - 10, 10, QPen(Qt::gray));
@ -40,18 +44,13 @@ BorderFrameEditor::BorderFrameEditor(QWidget *parent)
scene->addItem(io); scene->addItem(io);
QRectF bR = io->sceneBoundingRect(); QRectF bR = io->sceneBoundingRect();
io->setPos( scene->sceneRect().center().x() - bR.width()/2, scene->sceneRect().center().y() - bR.height()/2 ); io->setPos(scene->sceneRect().center().x() - bR.width() / 2,
connect( scene->sceneRect().center().y() - bR.height() / 2);
this, SIGNAL(borderSideClicked(LimeReport::BaseDesignIntf::BorderSide, bool)), connect(this, SIGNAL(borderSideClicked(LimeReport::BaseDesignIntf::BorderSide, bool)), this,
this, SLOT(slotBorderSideClicked(LimeReport::BaseDesignIntf::BorderSide, bool)) SLOT(slotBorderSideClicked(LimeReport::BaseDesignIntf::BorderSide, bool)));
);
} }
BorderFrameEditor::~BorderFrameEditor() BorderFrameEditor::~BorderFrameEditor() { delete ui; }
{
delete ui;
}
void BorderFrameEditor::setPen(QPen pen) void BorderFrameEditor::setPen(QPen pen)
{ {
@ -59,10 +58,7 @@ void BorderFrameEditor::setPen(QPen pen)
updateBorders(); updateBorders();
} }
QPen BorderFrameEditor::pen() QPen BorderFrameEditor::pen() { return m_pen; }
{
return m_pen;
}
void BorderFrameEditor::setAllLines() void BorderFrameEditor::setAllLines()
{ {
@ -94,7 +90,6 @@ void BorderFrameEditor::unSetAllLines()
scene->removeItem(rightLine); scene->removeItem(rightLine);
rightLine = NULL; rightLine = NULL;
} }
} }
void BorderFrameEditor::mousePressEvent(QMouseEvent* event) void BorderFrameEditor::mousePressEvent(QMouseEvent* event)
@ -119,39 +114,46 @@ void BorderFrameEditor::slotBorderSideClicked(BaseDesignIntf::BorderSide side, b
case BaseDesignIntf::BorderSide::TopLine: case BaseDesignIntf::BorderSide::TopLine:
if (show) { if (show) {
if (!topLine) topLine = createSideLine(side); if (!topLine)
topLine = createSideLine(side);
} else { } else {
if (topLine) scene->removeItem(topLine); if (topLine)
scene->removeItem(topLine);
topLine = NULL; topLine = NULL;
} }
break; break;
case BaseDesignIntf::LeftLine: case BaseDesignIntf::LeftLine:
if (show) { if (show) {
if (!leftLine) leftLine = createSideLine(side); if (!leftLine)
leftLine = createSideLine(side);
} else { } else {
if (leftLine) scene->removeItem(leftLine); if (leftLine)
scene->removeItem(leftLine);
leftLine = NULL; leftLine = NULL;
} }
break; break;
case BaseDesignIntf::BottomLine: case BaseDesignIntf::BottomLine:
if (show) { if (show) {
if (!bottomLine) bottomLine = createSideLine(side); if (!bottomLine)
bottomLine = createSideLine(side);
} else { } else {
if (bottomLine) scene->removeItem(bottomLine); if (bottomLine)
scene->removeItem(bottomLine);
bottomLine = NULL; bottomLine = NULL;
} }
break; break;
case BaseDesignIntf::RightLine: case BaseDesignIntf::RightLine:
if (show) { if (show) {
if (!rightLine) rightLine = createSideLine(side); if (!rightLine)
rightLine = createSideLine(side);
} else { } else {
if(rightLine) scene->removeItem(rightLine); if (rightLine)
scene->removeItem(rightLine);
rightLine = NULL; rightLine = NULL;
} }
} }
updateBorders(); updateBorders();
} }
@ -164,18 +166,24 @@ QGraphicsLineItem *BorderFrameEditor::createSideLine(LimeReport::BaseDesignIntf:
case BaseDesignIntf::BorderSide::LeftLine: case BaseDesignIntf::BorderSide::LeftLine:
return scene->addLine(QLineF(10, 10, 10, rect().height() - 10), m_pen); return scene->addLine(QLineF(10, 10, 10, rect().height() - 10), m_pen);
case BaseDesignIntf::BorderSide::RightLine: 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: 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() void BorderFrameEditor::updateBorders()
{ {
if (topLine) topLine->setPen(m_pen); if (topLine)
if (leftLine) leftLine->setPen(m_pen); topLine->setPen(m_pen);
if (bottomLine) bottomLine->setPen(m_pen); if (leftLine)
if (rightLine) rightLine->setPen(m_pen); leftLine->setPen(m_pen);
if (bottomLine)
bottomLine->setPen(m_pen);
if (rightLine)
rightLine->setPen(m_pen);
} }
} // namespace LimeReport } // namespace LimeReport

View File

@ -1,16 +1,18 @@
#ifndef WIDGET #ifndef WIDGET
#define WIDGET #define WIDGET
#include <QWidget>
#include <QGraphicsScene>
#include <QGraphicsLineItem>
#include "lrbasedesignintf.h" #include "lrbasedesignintf.h"
#include <QGraphicsLineItem>
#include <QGraphicsScene>
#include <QWidget>
namespace LimeReport { namespace LimeReport {
namespace Ui { class BorderFrameEditor; } namespace Ui {
class BorderFrameEditor;
}
class BorderFrameEditor : public QWidget class BorderFrameEditor: public QWidget {
{
Q_OBJECT Q_OBJECT
public: public:
@ -20,6 +22,7 @@ public:
QPen pen(); QPen pen();
void setAllLines(); void setAllLines();
void unSetAllLines(); void unSetAllLines();
protected: protected:
void mousePressEvent(QMouseEvent* event); void mousePressEvent(QMouseEvent* event);
signals: signals:
@ -30,17 +33,12 @@ private slots:
private: private:
QGraphicsLineItem* createSideLine(LimeReport::BaseDesignIntf::BorderSide side); QGraphicsLineItem* createSideLine(LimeReport::BaseDesignIntf::BorderSide side);
void updateBorders(); void updateBorders();
private: private:
Ui::BorderFrameEditor* ui; Ui::BorderFrameEditor* ui;
QGraphicsScene* scene; QGraphicsScene* scene;
QGraphicsLineItem *topLine = NULL QGraphicsLineItem *topLine = NULL, *bottomLine = NULL, *leftLine = NULL, *rightLine = NULL;
,*bottomLine = NULL
,*leftLine = NULL
,*rightLine = NULL;
QPen m_pen; QPen m_pen;
}; };
} // namespace LimeReport } // namespace LimeReport
#endif // WIDGET #endif // WIDGET

View File

@ -1,13 +1,17 @@
#include "lrchartaxiseditor.h" #include "lrchartaxiseditor.h"
#include "ui_lrchartaxiseditor.h" #include "ui_lrchartaxiseditor.h"
#include "lraxisdata.h"
#include "lraxisdata.h"
#include "lrbasedesignintf.h" #include "lrbasedesignintf.h"
ChartAxisEditor::ChartAxisEditor(LimeReport::ChartItem *item, LimeReport::PageDesignIntf *page, bool isXAxis, QSettings *settings, QWidget *parent): ChartAxisEditor::ChartAxisEditor(LimeReport::ChartItem* item, LimeReport::PageDesignIntf* page,
QWidget(parent), ui(new Ui::ChartAxisEditor), m_chartItem(item), m_page(page), bool isXAxis, QSettings* settings, QWidget* parent):
m_settings(settings), m_isXAxis(isXAxis) QWidget(parent),
ui(new Ui::ChartAxisEditor),
m_chartItem(item),
m_page(page),
m_settings(settings),
m_isXAxis(isXAxis)
{ {
ui->setupUi(this); ui->setupUi(this);
readSetting(); readSetting();
@ -33,7 +37,8 @@ QSettings* ChartAxisEditor::settings()
void ChartAxisEditor::readSetting() void ChartAxisEditor::readSetting()
{ {
if (settings() == 0) return; if (settings() == 0)
return;
settings()->beginGroup("ChartAxisEditor"); settings()->beginGroup("ChartAxisEditor");
QVariant v = settings()->value("Geometry"); QVariant v = settings()->value("Geometry");
@ -59,7 +64,8 @@ void ChartAxisEditor::init()
ui->gbAxis->setTitle(m_isXAxis ? QObject::tr("X Axis") : QObject::tr("Y Axis")); ui->gbAxis->setTitle(m_isXAxis ? QObject::tr("X Axis") : QObject::tr("Y Axis"));
ui->direction_checkbox->setVisible(!m_isXAxis); 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->minimumSpinBox->setValue(axisData->manualMinimum());
ui->maximumSpinBox->setValue(axisData->manualMaximum()); ui->maximumSpinBox->setValue(axisData->manualMaximum());
@ -96,7 +102,8 @@ void ChartAxisEditor::on_stepCheckBox_stateChanged(int arg1)
void ChartAxisEditor::on_pushButtonOk_clicked() 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) { if (!m_isXAxis) {
axisData->setReverseDirection(ui->direction_checkbox->isChecked()); axisData->setReverseDirection(ui->direction_checkbox->isChecked());
} }
@ -135,8 +142,4 @@ void ChartAxisEditor::on_enableScaleCalculation_checkbox_stateChanged(int arg1)
ui->stepCheckBox->setEnabled(isEnabled); ui->stepCheckBox->setEnabled(isEnabled);
} }
void ChartAxisEditor::on_cancelButton_clicked() void ChartAxisEditor::on_cancelButton_clicked() { close(); }
{
close();
}

View File

@ -1,15 +1,15 @@
#ifndef CHARTAXISEDITOR_H #ifndef CHARTAXISEDITOR_H
#define CHARTAXISEDITOR_H #define CHARTAXISEDITOR_H
#include <QWidget>
#include "lrchartitem.h" #include "lrchartitem.h"
#include <QWidget>
namespace Ui { namespace Ui {
class ChartAxisEditor; class ChartAxisEditor;
} }
class ChartAxisEditor : public QWidget class ChartAxisEditor: public QWidget {
{
Q_OBJECT Q_OBJECT
public: public:
ChartAxisEditor(LimeReport::ChartItem* item, LimeReport::PageDesignIntf* page, bool isXAxis, ChartAxisEditor(LimeReport::ChartItem* item, LimeReport::PageDesignIntf* page, bool isXAxis,

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,9 @@
#ifndef LRCHARTITEM_H #ifndef LRCHARTITEM_H
#define LRCHARTITEM_H #define LRCHARTITEM_H
#include "lritemdesignintf.h"
#include "lrglobal.h"
#include "lraxisdata.h" #include "lraxisdata.h"
#include "lrglobal.h"
#include "lritemdesignintf.h"
#include <QtGlobal> #include <QtGlobal>
namespace LimeReport { namespace LimeReport {
@ -19,7 +20,13 @@ public:
QList<qreal>& xAxisValues() { return m_xAxisValues; } QList<qreal>& xAxisValues() { return m_xAxisValues; }
QList<QString>& labels() { return m_labels; } QList<QString>& labels() { return m_labels; }
QList<QColor>& colors() { return m_colors; } QList<QColor>& colors() { return m_colors; }
void clear(){ m_values.clear(); m_labels.clear(); m_colors.clear(); } void clear()
{
m_values.clear();
m_labels.clear();
m_colors.clear();
}
private: private:
QList<qreal> m_values, m_xAxisValues; QList<qreal> m_values, m_xAxisValues;
QList<QString> m_labels; QList<QString> m_labels;
@ -35,7 +42,10 @@ class SeriesItem : public QObject{
Q_PROPERTY(QColor color READ color WRITE setColor) Q_PROPERTY(QColor color READ color WRITE setColor)
Q_PROPERTY(SeriesItemPreferredType preferredType READ preferredType WRITE setPreferredType) Q_PROPERTY(SeriesItemPreferredType preferredType READ preferredType WRITE setPreferredType)
public: public:
enum SeriesItemPreferredType {Bar, Line}; enum SeriesItemPreferredType {
Bar,
Line
};
#if QT_VERSION >= 0x050500 #if QT_VERSION >= 0x050500
Q_ENUM(SeriesItemPreferredType) Q_ENUM(SeriesItemPreferredType)
#else #else
@ -58,6 +68,7 @@ public:
SeriesItemPreferredType preferredType() const; SeriesItemPreferredType preferredType() const;
void setPreferredType(const SeriesItemPreferredType& preferredType); void setPreferredType(const SeriesItemPreferredType& preferredType);
bool isEmpty() { return m_data.values().isEmpty(); } bool isEmpty() { return m_data.values().isEmpty(); }
private: private:
QString m_name; QString m_name;
QString m_valuesColumn; QString m_valuesColumn;
@ -77,13 +88,16 @@ public:
virtual void paintChart(QPainter* painter, QRectF rect) = 0; virtual void paintChart(QPainter* painter, QRectF rect) = 0;
virtual void paintChartLegend(QPainter* painter, QRectF legendRect) = 0; virtual void paintChartLegend(QPainter* painter, QRectF legendRect) = 0;
virtual QSizeF calcChartLegendSize(const QFont& font, qreal maxWidth = 0) = 0; virtual QSizeF calcChartLegendSize(const QFont& font, qreal maxWidth = 0) = 0;
virtual QRectF calcChartLegendRect(const QFont& font, const QRectF& parentRect, bool takeAllRect, qreal borderMargin, qreal titleOffset); virtual QRectF calcChartLegendRect(const QFont& font, const QRectF& parentRect,
bool takeAllRect, qreal borderMargin, qreal titleOffset);
QFont titleFont(); QFont titleFont();
void setTitleFont(const QFont& value); void setTitleFont(const QFont& value);
protected: protected:
QVector<qreal> legendColumnWidths() const; QVector<qreal> legendColumnWidths() const;
virtual void prepareLegendToPaint(QRectF& legendRect, QPainter* painter); virtual void prepareLegendToPaint(QRectF& legendRect, QPainter* painter);
protected: protected:
// Title font must be placed here instead of CharItem, becuase // Title font must be placed here instead of CharItem, becuase
// it would cause crash when creating CharItem object on embedded // it would cause crash when creating CharItem object on embedded
@ -96,6 +110,7 @@ protected:
class AbstractSeriesChart: public AbstractChart { class AbstractSeriesChart: public AbstractChart {
public: public:
AbstractSeriesChart(ChartItem* chartItem); AbstractSeriesChart(ChartItem* chartItem);
protected: protected:
AxisData& xAxisData() const; AxisData& xAxisData() const;
AxisData& yAxisData() const; AxisData& yAxisData() const;
@ -123,8 +138,9 @@ protected:
private: private:
bool calculateLegendColumnWidths(qreal indicatorWidth, qreal maxWidth, const QFontMetrics& fm); bool calculateLegendColumnWidths(qreal indicatorWidth, qreal maxWidth, const QFontMetrics& fm);
bool calculateLegendSingleColumnWidth(qreal &currentRowWidth, int &currentColumn, int &maxColumnCount, bool calculateLegendSingleColumnWidth(qreal& currentRowWidth, int& currentColumn,
const qreal itemWidth, const qreal maxRowWidth); int& maxColumnCount, const qreal itemWidth,
const qreal maxRowWidth);
qreal m_designValues[9]; qreal m_designValues[9];
}; };
@ -132,18 +148,19 @@ class AbstractBarChart: public AbstractSeriesChart{
public: public:
AbstractBarChart(ChartItem* chartItem): AbstractSeriesChart(chartItem) { } AbstractBarChart(ChartItem* chartItem): AbstractSeriesChart(chartItem) { }
void paintChartLegend(QPainter* painter, QRectF legendRect); void paintChartLegend(QPainter* painter, QRectF legendRect);
protected: protected:
QRectF verticalLabelsRect(QPainter* painter, QRectF horizontalLabelsRect); QRectF verticalLabelsRect(QPainter* painter, QRectF horizontalLabelsRect);
virtual QRectF horizontalLabelsRect(QPainter* painter, QRectF horizontalLabelsRect); virtual QRectF horizontalLabelsRect(QPainter* painter, QRectF horizontalLabelsRect);
private: private:
void drawVerticalLegendItem(QPainter *painter, int i, const QString &text, void drawVerticalLegendItem(QPainter* painter, int i, const QString& text, int indicatorSize,
int indicatorSize, const QRectF &indicatorsRect, const QColor &indicatorColor); const QRectF& indicatorsRect, const QColor& indicatorColor);
void drawHorizontalLegendItem(QPainter *painter, int i, const QString &text, void drawHorizontalLegendItem(QPainter* painter, int i, const QString& text, int indicatorSize,
int indicatorSize, const QRectF &indicatorsRect, const QColor &indicatorColor); const QRectF& indicatorsRect, const QColor& indicatorColor);
}; };
class ChartItem : public LimeReport::ItemDesignIntf class ChartItem: public LimeReport::ItemDesignIntf {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY(QObject* xAxisSettings READ xAxisSettings WRITE setXAxisSettings) Q_PROPERTY(QObject* xAxisSettings READ xAxisSettings WRITE setXAxisSettings)
Q_PROPERTY(QObject* yAxisSettings READ yAxisSettings WRITE setYAxisSettings) Q_PROPERTY(QObject* yAxisSettings READ yAxisSettings WRITE setYAxisSettings)
@ -170,13 +187,32 @@ class ChartItem : public LimeReport::ItemDesignIntf
Q_PROPERTY(QString xAxisField READ xAxisField WRITE setXAxisField) Q_PROPERTY(QString xAxisField READ xAxisField WRITE setXAxisField)
Q_PROPERTY(GridChartLines gridChartLines READ gridChartLines WRITE setGridChartLines) Q_PROPERTY(GridChartLines gridChartLines READ gridChartLines WRITE setGridChartLines)
friend class AbstractChart; friend class AbstractChart;
public:
enum LegendAlign{LegendAlignRightTop,LegendAlignRightCenter,LegendAlignRightBottom, public:
LegendAlignBottomLeft,LegendAlignBottomCenter,LegendAlignBottomRight}; enum LegendAlign {
enum LegendStyle{LegendPoints, LegendLines}; LegendAlignRightTop,
enum TitleAlign{TitleAlignLeft, TitleAlignCenter, TitleAlignRight}; LegendAlignRightCenter,
enum ChartType{Pie, VerticalBar, HorizontalBar, Lines, GridLines}; LegendAlignRightBottom,
LegendAlignBottomLeft,
LegendAlignBottomCenter,
LegendAlignBottomRight
};
enum LegendStyle {
LegendPoints,
LegendLines
};
enum TitleAlign {
TitleAlignLeft,
TitleAlignCenter,
TitleAlignRight
};
enum ChartType {
Pie,
VerticalBar,
HorizontalBar,
Lines,
GridLines
};
enum LineType { enum LineType {
NoLine = 0, NoLine = 0,
HorizontalLine = 1, HorizontalLine = 1,
@ -280,6 +316,7 @@ protected:
void fillLabels(IDataSource* dataSource); void fillLabels(IDataSource* dataSource);
bool isNeedUpdateSize(RenderPass pass) const; bool isNeedUpdateSize(RenderPass pass) const;
void setSeries(ACollectionProperty series) { Q_UNUSED(series) } void setSeries(ACollectionProperty series) { Q_UNUSED(series) }
private: private:
QList<SeriesItem*> m_series; QList<SeriesItem*> m_series;
QString m_datasource; QString m_datasource;

View File

@ -1,12 +1,20 @@
#include "lrchartitemeditor.h" #include "lrchartitemeditor.h"
#include "ui_lrchartitemeditor.h" #include "ui_lrchartitemeditor.h"
#include "lrchartitem.h" #include "lrchartitem.h"
#include "lrpagedesignintf.h" #include "lrpagedesignintf.h"
#include <QColorDialog> #include <QColorDialog>
ChartItemEditor::ChartItemEditor(LimeReport::ChartItem *item, LimeReport::PageDesignIntf *page, QSettings *settings, QWidget *parent): ChartItemEditor::ChartItemEditor(LimeReport::ChartItem* item, LimeReport::PageDesignIntf* page,
QWidget(parent), ui(new Ui::ChartItemEditor), m_charItem(item), m_page(page), QSettings* settings, QWidget* parent):
m_settings(settings), m_ownedSettings(false), m_isReadingSetting(false) QWidget(parent),
ui(new Ui::ChartItemEditor),
m_charItem(item),
m_page(page),
m_settings(settings),
m_ownedSettings(false),
m_isReadingSetting(false)
{ {
ui->setupUi(this); ui->setupUi(this);
QHBoxLayout* colorLayout = new QHBoxLayout(); QHBoxLayout* colorLayout = new QHBoxLayout();
@ -49,7 +57,8 @@ QSettings* ChartItemEditor::settings()
void ChartItemEditor::readSetting() void ChartItemEditor::readSetting()
{ {
if (settings()==0) return; if (settings() == 0)
return;
m_isReadingSetting = true; m_isReadingSetting = true;
@ -101,7 +110,8 @@ void ChartItemEditor::init()
if (!m_charItem->datasource().isEmpty()) { if (!m_charItem->datasource().isEmpty()) {
if (m_page && m_page->datasourceManager()) { if (m_page && m_page->datasourceManager()) {
LimeReport::IDataSource* ds = m_page->datasourceManager()->dataSource(m_charItem->datasource()); LimeReport::IDataSource* ds
= m_page->datasourceManager()->dataSource(m_charItem->datasource());
if (ds) { if (ds) {
for (int i = 0; i < ds->columnCount(); ++i) { for (int i = 0; i < ds->columnCount(); ++i) {
ui->valuesFieldComboBox->addItem(ds->columnNameByIndex(i)); ui->valuesFieldComboBox->addItem(ds->columnNameByIndex(i));
@ -110,18 +120,20 @@ void ChartItemEditor::init()
} }
} }
} }
} }
static int enumIndex = LimeReport::SeriesItem::staticMetaObject.indexOfEnumerator("SeriesItemPreferredType"); static int enumIndex
= LimeReport::SeriesItem::staticMetaObject.indexOfEnumerator("SeriesItemPreferredType");
QMetaEnum enumerator = LimeReport::SeriesItem::staticMetaObject.enumerator(enumIndex); 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)); ui->seriesTypeComboBox->addItem(enumerator.key(i));
} }
#if QT_VERSION < 0x050000 #if QT_VERSION < 0x050000
ui->labelsFieldComboBox->setCurrentIndex(ui->labelsFieldComboBox->findText( m_charItem->labelsField())); ui->labelsFieldComboBox->setCurrentIndex(
ui->xAxisFieldComboBox->setCurrentIndex(ui->xAxisFieldComboBox->findText( m_charItem->xAxisField())); ui->labelsFieldComboBox->findText(m_charItem->labelsField()));
ui->xAxisFieldComboBox->setCurrentIndex(
ui->xAxisFieldComboBox->findText(m_charItem->xAxisField()));
#else #else
ui->labelsFieldComboBox->setCurrentText(m_charItem->labelsField()); ui->labelsFieldComboBox->setCurrentText(m_charItem->labelsField());
ui->xAxisFieldComboBox->setCurrentText(m_charItem->xAxisField()); ui->xAxisFieldComboBox->setCurrentText(m_charItem->xAxisField());
@ -200,14 +212,18 @@ void ChartItemEditor::slotAddSeries()
{ {
LimeReport::SeriesItem* series = new LimeReport::SeriesItem(); LimeReport::SeriesItem* series = new LimeReport::SeriesItem();
int curSeriesNumber = m_charItem->series().count(); int curSeriesNumber = m_charItem->series().count();
while (m_charItem->isSeriesExists("Series"+QString::number(curSeriesNumber))) curSeriesNumber++; while (m_charItem->isSeriesExists("Series" + QString::number(curSeriesNumber)))
curSeriesNumber++;
series->setName("Series" + QString::number(curSeriesNumber)); series->setName("Series" + QString::number(curSeriesNumber));
series->setValuesColumn(""); series->setValuesColumn("");
series->setLabelsColumn(""); 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); m_charItem->series().append(series);
ui->tableWidget->setRowCount(m_charItem->series().count()); ui->tableWidget->setRowCount(m_charItem->series().count());
ui->tableWidget->setItem(m_charItem->series().count()-1, 0, new QTableWidgetItem(series->name())); ui->tableWidget->setItem(m_charItem->series().count() - 1, 0,
new QTableWidgetItem(series->name()));
ui->tableWidget->selectRow(m_charItem->series().count() - 1); ui->tableWidget->selectRow(m_charItem->series().count() - 1);
#if QT_VERSION < 0x050000 #if QT_VERSION < 0x050000
ui->valuesFieldComboBox->setEditText(""); ui->valuesFieldComboBox->setEditText("");
@ -233,18 +249,22 @@ void ChartItemEditor::slotDeleteSeries()
void ChartItemEditor::on_tableWidget_itemSelectionChanged() void ChartItemEditor::on_tableWidget_itemSelectionChanged()
{ {
if (ui->tableWidget->selectionModel()->hasSelection()) { if (ui->tableWidget->selectionModel()->hasSelection()) {
LimeReport::SeriesItem* series = m_charItem->series().at(ui->tableWidget->selectionModel()->currentIndex().row()); LimeReport::SeriesItem* series
= m_charItem->series().at(ui->tableWidget->selectionModel()->currentIndex().row());
ui->seriesNameLineEdit->setText(series->name()); ui->seriesNameLineEdit->setText(series->name());
#if QT_VERSION < 0x050000 #if QT_VERSION < 0x050000
ui->valuesFieldComboBox->setCurrentIndex(ui->valuesFieldComboBox->findText(series->valuesColumn())); ui->valuesFieldComboBox->setCurrentIndex(
ui->valuesFieldComboBox->findText(series->valuesColumn()));
#else #else
ui->valuesFieldComboBox->setCurrentText(series->valuesColumn()); ui->valuesFieldComboBox->setCurrentText(series->valuesColumn());
#endif #endif
m_colorIndicator->setColor(series->color()); 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); QMetaEnum enumerator = LimeReport::SeriesItem::staticMetaObject.enumerator(enumIndex);
#if QT_VERSION < 0x050000 #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 #else
ui->seriesTypeComboBox->setCurrentText(enumerator.valueToKey(series->preferredType())); ui->seriesTypeComboBox->setCurrentText(enumerator.valueToKey(series->preferredType()));
#endif #endif
@ -284,10 +304,13 @@ void ChartItemEditor::slotChangeSeriesColor()
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); QMetaEnum enumerator = LimeReport::SeriesItem::staticMetaObject.enumerator(enumIndex);
if (currentSeries()) { if (currentSeries()) {
currentSeries()->setPreferredType(static_cast<LimeReport::SeriesItem::SeriesItemPreferredType>(enumerator.keysToValue(arg1.toLatin1()))); currentSeries()->setPreferredType(
static_cast<LimeReport::SeriesItem::SeriesItemPreferredType>(
enumerator.keysToValue(arg1.toLatin1())));
} }
} }

View File

@ -1,23 +1,24 @@
#ifndef CHARITEMEDITOR_H #ifndef CHARITEMEDITOR_H
#define CHARITEMEDITOR_H #define CHARITEMEDITOR_H
#include <QWidget>
#include "lrchartitem.h" #include "lrchartitem.h"
#include "lrcolorindicator.h" #include "lrcolorindicator.h"
#include <QTableWidgetItem> #include <QTableWidgetItem>
#include <QToolButton> #include <QToolButton>
#include <QWidget>
namespace Ui { namespace Ui {
class ChartItemEditor; class ChartItemEditor;
} }
class ChartItemEditor : public QWidget class ChartItemEditor: public QWidget {
{
Q_OBJECT Q_OBJECT
public: public:
ChartItemEditor(LimeReport::ChartItem* item, LimeReport::PageDesignIntf* page, ChartItemEditor(LimeReport::ChartItem* item, LimeReport::PageDesignIntf* page,
QSettings* settings = 0, QWidget* parent = 0); QSettings* settings = 0, QWidget* parent = 0);
~ChartItemEditor(); ~ChartItemEditor();
public: public:
QSettings* settings(); QSettings* settings();
void rebuildTable(); void rebuildTable();
@ -50,6 +51,7 @@ private:
void enableSeriesEditor(); void enableSeriesEditor();
void disableSeriesEditor(); void disableSeriesEditor();
LimeReport::SeriesItem* currentSeries(); LimeReport::SeriesItem* currentSeries();
private: private:
Ui::ChartItemEditor* ui; Ui::ChartItemEditor* ui;
LimeReport::ChartItem* m_charItem; LimeReport::ChartItem* m_charItem;

View File

@ -14,7 +14,6 @@ public:
virtual QString fileFilter() const = 0; virtual QString fileFilter() const = 0;
}; };
} } // namespace LimeReport
#endif // LREDITABLEIMAGEITEMINTF_H #endif // LREDITABLEIMAGEITEMINTF_H

View File

@ -28,14 +28,14 @@
* GNU General Public License for more details. * * GNU General Public License for more details. *
****************************************************************************/ ****************************************************************************/
#include "lrhorizontallayout.h" #include "lrhorizontallayout.h"
#include "lrbasedesignintf.h"
#include "lrdesignelementsfactory.h" #include "lrdesignelementsfactory.h"
#include <QDebug> #include <QDebug>
#include <QObject>
#include <QGraphicsScene> #include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent> #include <QGraphicsSceneMouseEvent>
#include <QObject>
#include "lrbasedesignintf.h"
const QString xmlTag = "HLayout"; const QString xmlTag = "HLayout";
@ -46,25 +46,23 @@ LimeReport::BaseDesignIntf *createHLayout(QObject *owner, LimeReport::BaseDesign
return new LimeReport::HorizontalLayout(owner, parent); return new LimeReport::HorizontalLayout(owner, parent);
} }
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator( bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator(
xmlTag, xmlTag, LimeReport::ItemAttribs(QObject::tr("HLayout"), LimeReport::Const::bandTAG),
LimeReport::ItemAttribs(QObject::tr("HLayout"), LimeReport::Const::bandTAG), createHLayout);
createHLayout } // namespace
);
}
namespace LimeReport { namespace LimeReport {
bool horizontalLessThen(BaseDesignIntf *c1, BaseDesignIntf* c2){ bool horizontalLessThen(BaseDesignIntf* c1, BaseDesignIntf* c2)
{
return c1->pos().x() < c2->pos().x(); return c1->pos().x() < c2->pos().x();
} }
HorizontalLayout::HorizontalLayout(QObject *owner, QGraphicsItem *parent) HorizontalLayout::HorizontalLayout(QObject* owner, QGraphicsItem* parent):
: AbstractLayout(xmlTag, owner, parent) AbstractLayout(xmlTag, owner, parent)
{} {
}
HorizontalLayout::~HorizontalLayout() HorizontalLayout::~HorizontalLayout() { }
{}
BaseDesignIntf* HorizontalLayout::createSameTypeItem(QObject* owner, QGraphicsItem* parent) BaseDesignIntf* HorizontalLayout::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
{ {
@ -76,14 +74,16 @@ bool HorizontalLayout::canBeSplitted(int height) const
foreach (QGraphicsItem* qgItem, childItems()) { foreach (QGraphicsItem* qgItem, childItems()) {
BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(qgItem); BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(qgItem);
if (item) if (item)
if (!item->canBeSplitted(height - item->pos().y())) return false; if (!item->canBeSplitted(height - item->pos().y()))
return false;
} }
return true; 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); upperPart->initFromItem(this);
qreal maxHeight = 0; qreal maxHeight = 0;
foreach (BaseDesignIntf* item, childBaseItems()) { foreach (BaseDesignIntf* item, childBaseItems()) {
@ -91,11 +91,14 @@ BaseDesignIntf *HorizontalLayout::cloneUpperPart(int height, QObject *owner, QGr
if ((item->geometry().top() < height) && (item->geometry().bottom() > height)) { if ((item->geometry().top() < height) && (item->geometry().bottom() > height)) {
int sliceHeight = height - item->geometry().top(); int sliceHeight = height - item->geometry().top();
if (item->canBeSplitted(sliceHeight)) { if (item->canBeSplitted(sliceHeight)) {
BaseDesignIntf* slicedPart = item->cloneUpperPart(sliceHeight,upperPart,upperPart); BaseDesignIntf* slicedPart
if (maxHeight<slicedPart->height()) maxHeight = slicedPart->height(); = item->cloneUpperPart(sliceHeight, upperPart, upperPart);
if (maxHeight < slicedPart->height())
maxHeight = slicedPart->height();
} else { } else {
item->cloneEmpty(sliceHeight, upperPart, upperPart); item->cloneEmpty(sliceHeight, upperPart, upperPart);
item->setPos(item->pos().x(),item->pos().y()+((height+1)-item->geometry().top())); item->setPos(item->pos().x(),
item->pos().y() + ((height + 1) - item->geometry().top()));
} }
} }
} }
@ -111,7 +114,8 @@ BaseDesignIntf *HorizontalLayout::cloneUpperPart(int height, QObject *owner, QGr
BaseDesignIntf* HorizontalLayout::cloneBottomPart(int height, QObject* owner, QGraphicsItem* parent) BaseDesignIntf* HorizontalLayout::cloneBottomPart(int height, QObject* owner, QGraphicsItem* parent)
{ {
qreal maxHeight = 0; qreal maxHeight = 0;
HorizontalLayout* bottomPart = dynamic_cast<HorizontalLayout*>(createSameTypeItem(owner,parent)); HorizontalLayout* bottomPart
= dynamic_cast<HorizontalLayout*>(createSameTypeItem(owner, parent));
bottomPart->initFromItem(this); bottomPart->initFromItem(this);
foreach (BaseDesignIntf* item, childBaseItems()) { foreach (BaseDesignIntf* item, childBaseItems()) {
if ((item->geometry().top() < height) && (item->geometry().bottom() > height)) { if ((item->geometry().top() < height) && (item->geometry().bottom() > height)) {
@ -150,14 +154,17 @@ void HorizontalLayout::updateLayoutSize()
qreal h = 0; qreal h = 0;
int visibleItemCount = 0; int visibleItemCount = 0;
foreach (BaseDesignIntf* item, layoutsChildren()) { foreach (BaseDesignIntf* item, layoutsChildren()) {
if (item->isEmpty() && hideEmptyItems()) item->setVisible(false); if (item->isEmpty() && hideEmptyItems())
item->setVisible(false);
if (item->isVisible()) { if (item->isVisible()) {
if (h<item->height()) h=item->height(); if (h < item->height())
h = item->height();
w += item->width(); w += item->width();
visibleItemCount++; visibleItemCount++;
} }
} }
if (h>0) setHeight(h+spaceBorder*2); if (h > 0)
setHeight(h + spaceBorder * 2);
if (layoutType() == Layout) if (layoutType() == Layout)
setWidth(w + layoutSpacingMM() * (visibleItemCount - 1)); setWidth(w + layoutSpacingMM() * (visibleItemCount - 1));
else { else {
@ -199,7 +206,8 @@ void HorizontalLayout::relocateChildren()
} }
} }
void HorizontalLayout::divideSpace(){ void HorizontalLayout::divideSpace()
{
setIsRelocating(true); setIsRelocating(true);
qreal itemsSumSize = 0; qreal itemsSumSize = 0;
int visibleItemsCount = 0; int visibleItemsCount = 0;
@ -218,13 +226,16 @@ void HorizontalLayout::divideSpace(){
qreal delta = (width() - (itemsSumSize + spaceBorder * 2)); qreal delta = (width() - (itemsSumSize + spaceBorder * 2));
layoutsChildren().last()->setWidth(layoutsChildren().last()->width() + delta); layoutsChildren().last()->setWidth(layoutsChildren().last()->width() + delta);
} else { } else {
qreal delta = (width() - (itemsSumSize+spaceBorder*2)) / (visibleItemsCount!=0 ? visibleItemsCount : 1); qreal delta = (width() - (itemsSumSize + spaceBorder * 2))
/ (visibleItemsCount != 0 ? visibleItemsCount : 1);
for (int i = 0; i < layoutsChildren().size(); ++i) { for (int i = 0; i < layoutsChildren().size(); ++i) {
if (layoutsChildren()[i]->isVisible() || itemMode() == DesignMode) if (layoutsChildren()[i]->isVisible() || itemMode() == DesignMode)
layoutsChildren()[i]->setWidth(layoutsChildren()[i]->width() + delta); layoutsChildren()[i]->setWidth(layoutsChildren()[i]->width() + delta);
if ((i + 1) < layoutsChildren().size()) if ((i + 1) < layoutsChildren().size())
if (layoutsChildren()[i + 1]->isVisible() || itemMode() == DesignMode) if (layoutsChildren()[i + 1]->isVisible() || itemMode() == DesignMode)
layoutsChildren()[i+1]->setPos(layoutsChildren()[i+1]->pos().x()+delta*(i+1),layoutsChildren()[i+1]->pos().y()); layoutsChildren()[i + 1]->setPos(layoutsChildren()[i + 1]->pos().x()
+ delta * (i + 1),
layoutsChildren()[i + 1]->pos().y());
} }
} }
setIsRelocating(false); setIsRelocating(false);

View File

@ -29,15 +29,13 @@
****************************************************************************/ ****************************************************************************/
#ifndef LRHORIZONTALLAYOUT_H #ifndef LRHORIZONTALLAYOUT_H
#define LRHORIZONTALLAYOUT_H #define LRHORIZONTALLAYOUT_H
#include "lrabstractlayout.h"
#include "lritemdesignintf.h" #include "lritemdesignintf.h"
#include "lrlayoutmarker.h" #include "lrlayoutmarker.h"
#include "lrabstractlayout.h"
namespace LimeReport namespace LimeReport {
{
class HorizontalLayout : public AbstractLayout class HorizontalLayout: public AbstractLayout {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY(LayoutType layoutType READ layoutType WRITE setLayoutType) Q_PROPERTY(LayoutType layoutType READ layoutType WRITE setLayoutType)
public: public:

View File

@ -28,30 +28,38 @@
* GNU General Public License for more details. * * GNU General Public License for more details. *
****************************************************************************/ ****************************************************************************/
#include "lrimageitem.h" #include "lrimageitem.h"
#include "lrdatasourcemanager.h"
#include "lrdesignelementsfactory.h" #include "lrdesignelementsfactory.h"
#include "lrglobal.h" #include "lrglobal.h"
#include "lrdatasourcemanager.h"
#include "lrpagedesignintf.h"
#include "lrimageitemeditor.h" #include "lrimageitemeditor.h"
#include "lrpagedesignintf.h"
namespace { namespace {
const QString xmlTag = "ImageItem"; const QString xmlTag = "ImageItem";
LimeReport::BaseDesignIntf * createImageItem(QObject* owner, LimeReport::BaseDesignIntf* parent){ LimeReport::BaseDesignIntf* createImageItem(QObject* owner, LimeReport::BaseDesignIntf* parent)
{
return new LimeReport::ImageItem(owner, parent); return new LimeReport::ImageItem(owner, parent);
} }
bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator( 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 { namespace LimeReport {
ImageItem::ImageItem(QObject* owner,QGraphicsItem* parent) ImageItem::ImageItem(QObject* owner, QGraphicsItem* parent):
:ItemDesignIntf(xmlTag,owner,parent), m_useExternalPainter(false), m_externalPainter(0), ItemDesignIntf(xmlTag, owner, parent),
m_autoSize(false), m_scale(true), m_useExternalPainter(false),
m_keepAspectRatio(true), m_center(true), m_format(Binary){} 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)
{ {
@ -60,7 +68,8 @@ BaseDesignIntf *ImageItem::createSameTypeItem(QObject *owner, QGraphicsItem *par
return result; return result;
} }
void ImageItem::loadPictureFromVariant(QVariant& data){ void ImageItem::loadPictureFromVariant(QVariant& data)
{
// TODO: Migrate to QMetaType // TODO: Migrate to QMetaType
if (data.isValid()) { if (data.isValid()) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
@ -83,7 +92,6 @@ void ImageItem::loadPictureFromVariant(QVariant& data){
break; break;
} }
} }
} }
} }
@ -97,7 +105,6 @@ void ImageItem::preparePopUpMenu(QMenu &menu)
QAction* action = menu.addAction(tr("Watermark")); QAction* action = menu.addAction(tr("Watermark"));
action->setCheckable(true); action->setCheckable(true);
action->setChecked(isWatermark()); action->setChecked(isWatermark());
} }
void ImageItem::processPopUpAction(QAction* action) void ImageItem::processPopUpAction(QAction* action)
@ -111,7 +118,8 @@ void ImageItem::processPopUpAction(QAction *action)
ItemDesignIntf::processPopUpAction(action); ItemDesignIntf::processPopUpAction(action);
} }
QImage getFileByResourcePath(QString resourcePath) { QImage getFileByResourcePath(QString resourcePath)
{
QFileInfo resourceFile(resourcePath); QFileInfo resourceFile(resourcePath);
if (resourceFile.exists()) if (resourceFile.exists())
return QImage(resourcePath); return QImage(resourcePath);
@ -125,10 +133,7 @@ QImage ImageItem::drawImage() const
return image(); return image();
} }
bool ImageItem::useExternalPainter() const bool ImageItem::useExternalPainter() const { return m_useExternalPainter; }
{
return m_useExternalPainter;
}
void ImageItem::setUseExternalPainter(bool value) void ImageItem::setUseExternalPainter(bool value)
{ {
@ -165,7 +170,8 @@ void ImageItem::setImageAsByteArray(QByteArray image)
QString ImageItem::fileFilter() const 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) void ImageItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight)
@ -179,7 +185,8 @@ void ImageItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass,
loadPictureFromVariant(data); loadPictureFromVariant(data);
} }
} else if (!m_resourcePath.isEmpty()) { } else if (!m_resourcePath.isEmpty()) {
m_resourcePath = expandUserVariables(m_resourcePath, pass, NoEscapeSymbols, dataManager); m_resourcePath
= expandUserVariables(m_resourcePath, pass, NoEscapeSymbols, dataManager);
m_resourcePath = expandDataFields(m_resourcePath, NoEscapeSymbols, dataManager); m_resourcePath = expandDataFields(m_resourcePath, NoEscapeSymbols, dataManager);
m_picture = QImage(m_resourcePath); m_picture = QImage(m_resourcePath);
} else if (!m_variable.isEmpty()) { } else if (!m_variable.isEmpty()) {
@ -209,19 +216,13 @@ void ImageItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass,
BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight); BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight);
} }
bool ImageItem::isNeedUpdateSize(RenderPass) const bool ImageItem::isNeedUpdateSize(RenderPass) const { return m_picture.isNull() || m_autoSize; }
{
return m_picture.isNull() || m_autoSize;
}
QString ImageItem::resourcePath() const QString ImageItem::resourcePath() const { return m_resourcePath; }
{
return m_resourcePath;
}
qreal ImageItem::minHeight() const{ qreal ImageItem::minHeight() const
if (!m_picture.isNull() && autoSize())
{ {
if (!m_picture.isNull() && autoSize()) {
return m_picture.height(); return m_picture.height();
} else { } else {
return 0; return 0;
@ -238,10 +239,7 @@ void ImageItem::setVariable(const QString& content)
} }
} }
bool ImageItem::center() const bool ImageItem::center() const { return m_center; }
{
return m_center;
}
void ImageItem::setCenter(bool center) void ImageItem::setCenter(bool center)
{ {
@ -252,10 +250,7 @@ void ImageItem::setCenter(bool center)
} }
} }
bool ImageItem::keepAspectRatio() const bool ImageItem::keepAspectRatio() const { return m_keepAspectRatio; }
{
return m_keepAspectRatio;
}
void ImageItem::setKeepAspectRatio(bool keepAspectRatio) void ImageItem::setKeepAspectRatio(bool keepAspectRatio)
{ {
@ -266,10 +261,7 @@ void ImageItem::setKeepAspectRatio(bool keepAspectRatio)
} }
} }
bool ImageItem::scale() const bool ImageItem::scale() const { return m_scale; }
{
return m_scale;
}
void ImageItem::setScale(bool scale) void ImageItem::setScale(bool scale)
{ {
@ -279,10 +271,7 @@ void ImageItem::setScale(bool scale)
notify("scale", !scale, scale); notify("scale", !scale, scale);
} }
} }
bool ImageItem::autoSize() const bool ImageItem::autoSize() const { return m_autoSize; }
{
return m_autoSize;
}
void ImageItem::setAutoSize(bool autoSize) void ImageItem::setAutoSize(bool autoSize)
{ {
@ -300,10 +289,7 @@ void ImageItem::setAutoSize(bool autoSize)
} }
} }
QString ImageItem::field() const QString ImageItem::field() const { return m_field; }
{
return m_field;
}
void ImageItem::setField(const QString& field) void ImageItem::setField(const QString& field)
{ {
@ -315,10 +301,7 @@ void ImageItem::setField(const QString &field)
} }
} }
QString ImageItem::datasource() const QString ImageItem::datasource() const { return m_datasource; }
{
return m_datasource;
}
void ImageItem::setDatasource(const QString& datasource) void ImageItem::setDatasource(const QString& datasource)
{ {
@ -330,18 +313,21 @@ void ImageItem::setDatasource(const QString &datasource)
} }
} }
void ImageItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) void ImageItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{ {
painter->save(); painter->save();
if (isSelected()) painter->setOpacity(Const::SELECTION_OPACITY); if (isSelected())
else painter->setOpacity(qreal(opacity())/100); painter->setOpacity(Const::SELECTION_OPACITY);
else
painter->setOpacity(qreal(opacity()) / 100);
QPointF point = rect().topLeft(); QPointF point = rect().topLeft();
QImage img; QImage img;
if (m_scale && !drawImage().isNull()) { if (m_scale && !drawImage().isNull()) {
img = drawImage().scaled(rect().width(), rect().height(), keepAspectRatio() ? Qt::KeepAspectRatio : Qt::IgnoreAspectRatio, Qt::SmoothTransformation); img = drawImage().scaled(rect().width(), rect().height(),
keepAspectRatio() ? Qt::KeepAspectRatio : Qt::IgnoreAspectRatio,
Qt::SmoothTransformation);
} else { } else {
img = drawImage(); img = drawImage();
} }
@ -383,7 +369,10 @@ void ImageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
painter->setPen(Qt::black); painter->setPen(Qt::black);
if (!datasource().isEmpty() && !field().isEmpty()) if (!datasource().isEmpty() && !field().isEmpty())
text = datasource() + "." + field(); text = datasource() + "." + field();
else if (m_useExternalPainter) text = tr("Ext."); else text = tr("Image"); else if (m_useExternalPainter)
text = tr("Ext.");
else
text = tr("Image");
painter->drawText(rect().adjusted(4, 4, -4, -4), Qt::AlignCenter, text); painter->drawText(rect().adjusted(4, 4, -4, -4), Qt::AlignCenter, text);
} else { } else {
if (m_externalPainter && m_useExternalPainter) if (m_externalPainter && m_useExternalPainter)
@ -410,11 +399,10 @@ void ImageItem::setImage(QImage value)
} }
} }
QImage ImageItem::image() const{ QImage ImageItem::image() const { return m_picture; }
return m_picture;
}
void ImageItem::setResourcePath(const QString &value){ void ImageItem::setResourcePath(const QString& value)
{
if (m_resourcePath != value) { if (m_resourcePath != value) {
QString oldValue = m_resourcePath; QString oldValue = m_resourcePath;
m_resourcePath = value; m_resourcePath = value;
@ -423,10 +411,7 @@ void ImageItem::setResourcePath(const QString &value){
} }
} }
ImageItem::Format ImageItem::format() const ImageItem::Format ImageItem::format() const { return m_format; }
{
return m_format;
}
void ImageItem::setFormat(Format format) void ImageItem::setFormat(Format format)
{ {
@ -438,9 +423,6 @@ void ImageItem::setFormat(Format format)
} }
} }
} } // namespace LimeReport
bool LimeReport::ImageItem::isEmpty() const bool LimeReport::ImageItem::isEmpty() const { return drawImage().isNull(); }
{
return drawImage().isNull();
}

View File

@ -29,14 +29,14 @@
****************************************************************************/ ****************************************************************************/
#ifndef LRIMAGEITEM_H #ifndef LRIMAGEITEM_H
#define LRIMAGEITEM_H #define LRIMAGEITEM_H
#include "lritemdesignintf.h"
#include "lreditableimageitemintf.h" #include "lreditableimageitemintf.h"
#include "lritemdesignintf.h"
#include <QtGlobal> #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_OBJECT
Q_PROPERTY(QImage image READ image WRITE setImage) Q_PROPERTY(QImage image READ image WRITE setImage)
Q_PROPERTY(int opacity READ opacity WRITE setOpacity) Q_PROPERTY(int opacity READ opacity WRITE setOpacity)
@ -90,7 +90,10 @@ public:
QString variable() { return m_variable; } QString variable() { return m_variable; }
void setVariable(const QString& variable); void setVariable(const QString& variable);
void setExternalPainter(IExternalPainter* externalPainter){ m_externalPainter = externalPainter;} void setExternalPainter(IExternalPainter* externalPainter)
{
m_externalPainter = externalPainter;
}
bool useExternalPainter() const; bool useExternalPainter() const;
void setUseExternalPainter(bool value); void setUseExternalPainter(bool value);
@ -100,6 +103,7 @@ public:
QByteArray imageAsByteArray() const; QByteArray imageAsByteArray() const;
void setImageAsByteArray(QByteArray image); void setImageAsByteArray(QByteArray image);
QString fileFilter() const; QString fileFilter() const;
protected: protected:
BaseDesignIntf* createSameTypeItem(QObject* owner, QGraphicsItem* parent); BaseDesignIntf* createSameTypeItem(QObject* owner, QGraphicsItem* parent);
void updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight); void updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight);
@ -109,6 +113,7 @@ protected:
void preparePopUpMenu(QMenu& menu); void preparePopUpMenu(QMenu& menu);
void processPopUpAction(QAction* action); void processPopUpAction(QAction* action);
QImage drawImage() const; QImage drawImage() const;
private: private:
QImage m_picture; QImage m_picture;
bool m_useExternalPainter; bool m_useExternalPainter;
@ -123,11 +128,10 @@ private:
Format m_format; Format m_format;
QString m_variable; QString m_variable;
// BaseDesignIntf interface // BaseDesignIntf interface
public: public:
bool isEmpty() const override; bool isEmpty() const override;
}; };
} } // namespace LimeReport
#endif // LRIMAGEITEM_H #endif // LRIMAGEITEM_H

View File

@ -1,13 +1,15 @@
#include "lrimageitemeditor.h" #include "lrimageitemeditor.h"
#include "ui_lrimageitemeditor.h" #include "ui_lrimageitemeditor.h"
#include "lrimageitem.h" #include "lrimageitem.h"
#include <QFileInfo>
#include <QFileDialog> #include <QFileDialog>
#include <QFileInfo>
ImageItemEditor::ImageItemEditor(LimeReport::IEditableImageItem* item, QWidget* parent): ImageItemEditor::ImageItemEditor(LimeReport::IEditableImageItem* item, QWidget* parent):
QWidget(parent), QWidget(parent),
ui(new Ui::ImageItemEditor), m_item(item) ui(new Ui::ImageItemEditor),
m_item(item)
{ {
ui->setupUi(this); ui->setupUi(this);
m_image = item->imageAsByteArray(); m_image = item->imageAsByteArray();
@ -15,10 +17,7 @@ ImageItemEditor::ImageItemEditor(LimeReport::IEditableImageItem *item, QWidget *
updateImage(); updateImage();
} }
ImageItemEditor::~ImageItemEditor() ImageItemEditor::~ImageItemEditor() { delete ui; }
{
delete ui;
}
void ImageItemEditor::updateImage() void ImageItemEditor::updateImage()
{ {
@ -33,7 +32,8 @@ void ImageItemEditor::updateImage()
void ImageItemEditor::on_tbLoadImage_clicked() 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); QFile file(fileName);
if (file.open(QIODevice::ReadOnly)) { if (file.open(QIODevice::ReadOnly)) {
m_image = file.readAll(); m_image = file.readAll();
@ -55,10 +55,7 @@ void ImageItemEditor::on_buttonBox_accepted()
this->close(); this->close();
} }
void ImageItemEditor::on_buttonBox_rejected() void ImageItemEditor::on_buttonBox_rejected() { this->close(); }
{
this->close();
}
void ImageItemEditor::on_toolButton_clicked() void ImageItemEditor::on_toolButton_clicked()
{ {

View File

@ -1,9 +1,10 @@
#ifndef LRIMAGEITEMEDITOR_H #ifndef LRIMAGEITEMEDITOR_H
#define LRIMAGEITEMEDITOR_H #define LRIMAGEITEMEDITOR_H
#include <QWidget>
#include "lreditableimageitemintf.h" #include "lreditableimageitemintf.h"
#include <QWidget>
namespace Ui { namespace Ui {
class ImageItemEditor; class ImageItemEditor;
} }
@ -12,15 +13,16 @@ namespace LimeReport {
class ImageItem; class ImageItem;
} }
class ImageItemEditor : public QWidget class ImageItemEditor: public QWidget {
{
Q_OBJECT Q_OBJECT
public: public:
explicit ImageItemEditor(LimeReport::IEditableImageItem* item, QWidget* parent = NULL); explicit ImageItemEditor(LimeReport::IEditableImageItem* item, QWidget* parent = NULL);
~ImageItemEditor(); ~ImageItemEditor();
private: private:
void updateImage(); void updateImage();
private: private:
Ui::ImageItemEditor* ui; Ui::ImageItemEditor* ui;
LimeReport::IEditableImageItem* m_item; LimeReport::IEditableImageItem* m_item;

View File

@ -1,11 +1,16 @@
#include "lrlayoutmarker.h" #include "lrlayoutmarker.h"
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsScene> #include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>
namespace LimeReport { namespace LimeReport {
LayoutMarker::LayoutMarker(BaseDesignIntf* layout, QGraphicsItem *parent) LayoutMarker::LayoutMarker(BaseDesignIntf* layout, QGraphicsItem* parent):
:QGraphicsItem(parent), m_rect(0,0,30,30), m_color(Qt::red), m_layout(layout){ QGraphicsItem(parent),
m_rect(0, 0, 30, 30),
m_color(Qt::red),
m_layout(layout)
{
setFlag(QGraphicsItem::ItemIsMovable); setFlag(QGraphicsItem::ItemIsMovable);
} }
@ -16,7 +21,8 @@ void LayoutMarker::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QW
painter->fillRect(boundingRect(), m_color); painter->fillRect(boundingRect(), m_color);
painter->setRenderHint(QPainter::Antialiasing); painter->setRenderHint(QPainter::Antialiasing);
qreal size = (boundingRect().width()<boundingRect().height()) ? boundingRect().width() : boundingRect().height(); qreal size = (boundingRect().width() < boundingRect().height()) ? boundingRect().width()
: boundingRect().height();
if (m_layout->isSelected()) { if (m_layout->isSelected()) {
painter->setOpacity(1); painter->setOpacity(1);
@ -65,5 +71,4 @@ void LayoutMarker::mousePressEvent(QGraphicsSceneMouseEvent *event)
} }
} }
} // namespace LimeReport } // namespace LimeReport

View File

@ -1,9 +1,10 @@
#ifndef LRLAYOUTMARKER_H #ifndef LRLAYOUTMARKER_H
#define LRLAYOUTMARKER_H #define LRLAYOUTMARKER_H
#include <QGraphicsItem>
#include "lrbanddesignintf.h" #include "lrbanddesignintf.h"
#include <QGraphicsItem>
namespace LimeReport { namespace LimeReport {
class LayoutMarker: public QGraphicsItem { class LayoutMarker: public QGraphicsItem {
@ -16,8 +17,10 @@ public:
void setColor(QColor color); void setColor(QColor color);
qreal width() { return m_rect.width(); } qreal width() { return m_rect.width(); }
qreal height() { return m_rect.height(); } qreal height() { return m_rect.height(); }
protected: protected:
void mousePressEvent(QGraphicsSceneMouseEvent* event); void mousePressEvent(QGraphicsSceneMouseEvent* event);
private: private:
QRectF m_rect; QRectF m_rect;
QColor m_color; QColor m_color;

View File

@ -1,9 +1,11 @@
#include "lrpageeditor.h" #include "lrpageeditor.h"
#include "ui_lrpageeditor.h" #include "ui_lrpageeditor.h"
#include "lrpagedesignintf.h" #include "lrpagedesignintf.h"
#include "lrpageitemdesignintf.h" #include "lrpageitemdesignintf.h"
#include <QPushButton>
#include <QPageSize> #include <QPageSize>
#include <QPushButton>
namespace LimeReport { namespace LimeReport {
@ -14,7 +16,9 @@ PageEditor::PageEditor(QWidget *parent, LimeReport::PageItemDesignIntf *page) :
ui->setupUi(this); ui->setupUi(this);
m_page = page; m_page = page;
// Paper // Paper
QMetaEnum pageSizes = page->metaObject()->property(page->metaObject()->indexOfProperty("pageSize")).enumerator(); QMetaEnum pageSizes = page->metaObject()
->property(page->metaObject()->indexOfProperty("pageSize"))
.enumerator();
for (int i = 0; i < pageSizes.keyCount(); i++) { for (int i = 0; i < pageSizes.keyCount(); i++) {
ui->format->addItem(pageSizes.key(i)); ui->format->addItem(pageSizes.key(i));
@ -23,7 +27,8 @@ PageEditor::PageEditor(QWidget *parent, LimeReport::PageItemDesignIntf *page) :
ui->width->setValue(m_page->width() / m_page->unitFactor()); ui->width->setValue(m_page->width() / m_page->unitFactor());
ui->height->setValue(m_page->height() / m_page->unitFactor()); ui->height->setValue(m_page->height() / m_page->unitFactor());
ui->portrait->setChecked(m_page->pageOrientation() == LimeReport::PageItemDesignIntf::Portrait); ui->portrait->setChecked(m_page->pageOrientation() == LimeReport::PageItemDesignIntf::Portrait);
ui->landscape->setChecked(m_page->pageOrientation() == LimeReport::PageItemDesignIntf::Landscape); ui->landscape->setChecked(m_page->pageOrientation()
== LimeReport::PageItemDesignIntf::Landscape);
// Margins // Margins
ui->marginTop->setValue(m_page->topMargin()); ui->marginTop->setValue(m_page->topMargin());
ui->marginRight->setValue(m_page->rightMargin()); ui->marginRight->setValue(m_page->rightMargin());
@ -37,17 +42,17 @@ PageEditor::PageEditor(QWidget *parent, LimeReport::PageItemDesignIntf *page) :
ui->fullPage->setChecked(m_page->fullPage()); ui->fullPage->setChecked(m_page->fullPage());
} }
PageEditor::~PageEditor() PageEditor::~PageEditor() { delete ui; }
{
delete ui;
}
void PageEditor::applyChanges() void PageEditor::applyChanges()
{ {
m_page->setPageSize(static_cast<LimeReport::PageItemDesignIntf::PageSize>(ui->format->currentIndex())); m_page->setPageSize(
static_cast<LimeReport::PageItemDesignIntf::PageSize>(ui->format->currentIndex()));
m_page->setWidth(ui->width->value() * LimeReport::Const::mmFACTOR); m_page->setWidth(ui->width->value() * LimeReport::Const::mmFACTOR);
m_page->setHeight(ui->height->value() * LimeReport::Const::mmFACTOR); m_page->setHeight(ui->height->value() * LimeReport::Const::mmFACTOR);
m_page->setPageOrientation(ui->portrait->isChecked()? LimeReport::PageItemDesignIntf::Portrait : LimeReport::PageItemDesignIntf::Landscape); m_page->setPageOrientation(ui->portrait->isChecked()
? LimeReport::PageItemDesignIntf::Portrait
: LimeReport::PageItemDesignIntf::Landscape);
m_page->setTopMargin(ui->marginTop->value()); m_page->setTopMargin(ui->marginTop->value());
m_page->setBottomMargin(ui->marginBottom->value()); m_page->setBottomMargin(ui->marginBottom->value());
m_page->setRightMargin(ui->marginRight->value()); m_page->setRightMargin(ui->marginRight->value());
@ -65,7 +70,8 @@ QSizeF PageEditor::getRectByPageSize(const LimeReport::PageItemDesignIntf::PageS
QPrinter printer; QPrinter printer;
printer.setOutputFormat(QPrinter::PdfFormat); printer.setOutputFormat(QPrinter::PdfFormat);
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
printer.setOrientation(ui->portrait->isChecked() ? QPrinter::Portrait : QPrinter::Landscape); printer.setOrientation(ui->portrait->isChecked() ? QPrinter::Portrait
: QPrinter::Landscape);
printer.setPaperSize((QPrinter::PageSize)size); printer.setPaperSize((QPrinter::PageSize)size);
return QSizeF(printer.paperSize(QPrinter::Millimeter).width() * m_page->unitFactor(), return QSizeF(printer.paperSize(QPrinter::Millimeter).width() * m_page->unitFactor(),
printer.paperSize(QPrinter::Millimeter).height() * m_page->unitFactor()); printer.paperSize(QPrinter::Millimeter).height() * m_page->unitFactor());
@ -73,8 +79,10 @@ QSizeF PageEditor::getRectByPageSize(const LimeReport::PageItemDesignIntf::PageS
#else #else
printer.setPageOrientation((QPageLayout::Orientation)m_page->pageOrientation()); printer.setPageOrientation((QPageLayout::Orientation)m_page->pageOrientation());
printer.setPageSize(QPageSize((QPageSize::PageSizeId)size)); printer.setPageSize(QPageSize((QPageSize::PageSizeId)size));
return QSizeF(printer.pageLayout().pageSize().size(QPageSize::Millimeter).width() * m_page->unitFactor(), return QSizeF(printer.pageLayout().pageSize().size(QPageSize::Millimeter).width()
printer.pageLayout().pageSize().size(QPageSize::Millimeter).height() * m_page->unitFactor()); * m_page->unitFactor(),
printer.pageLayout().pageSize().size(QPageSize::Millimeter).height()
* m_page->unitFactor());
#endif #endif
} else { } else {
return QSizeF(m_page->getItemWidth(), m_page->getItemHeight()); return QSizeF(m_page->getItemWidth(), m_page->getItemHeight());
@ -84,16 +92,14 @@ QSizeF PageEditor::getRectByPageSize(const LimeReport::PageItemDesignIntf::PageS
void PageEditor::on_format_currentIndexChanged(int index) void PageEditor::on_format_currentIndexChanged(int index)
{ {
QPageSize ps = *new QPageSize(); QPageSize ps = *new QPageSize();
if(ui->format->currentText() != "Custom") if (ui->format->currentText() != "Custom") {
{ QSizeF pageSize
QSizeF pageSize = getRectByPageSize(static_cast<LimeReport::PageItemDesignIntf::PageSize>(index)); = getRectByPageSize(static_cast<LimeReport::PageItemDesignIntf::PageSize>(index));
ui->width->setValue(pageSize.width() / m_page->unitFactor()); ui->width->setValue(pageSize.width() / m_page->unitFactor());
ui->height->setValue(pageSize.height() / m_page->unitFactor()); ui->height->setValue(pageSize.height() / m_page->unitFactor());
} }
} }
void PageEditor::on_buttonBox_clicked(QAbstractButton* button) void PageEditor::on_buttonBox_clicked(QAbstractButton* button)
{ {
switch (ui->buttonBox->buttonRole(button)) { switch (ui->buttonBox->buttonRole(button)) {
@ -104,7 +110,6 @@ void PageEditor::on_buttonBox_clicked(QAbstractButton *button)
applyChanges(); applyChanges();
accept(); accept();
} }
} }
} // namespace } // namespace LimeReport

Some files were not shown because too many files have changed in this diff Show More