mirror of
				https://github.com/fralx/LimeReport.git
				synced 2025-10-31 05:11:56 +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:
		
							
								
								
									
										41
									
								
								.clang-format
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								.clang-format
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,41 @@ | |||||||
|  | --- | ||||||
|  | BasedOnStyle: WebKit | ||||||
|  | Language: Cpp | ||||||
|  | AlignAfterOpenBracket: Align | ||||||
|  | AllowShortEnumsOnASingleLine: false | ||||||
|  | BreakInheritanceList: AfterColon | ||||||
|  | BreakConstructorInitializers: AfterColon | ||||||
|  | SpaceBeforeCtorInitializerColon: false | ||||||
|  | ConstructorInitializerAllOnOneLineOrOnePerLine: true | ||||||
|  | AllowAllConstructorInitializersOnNextLine: false | ||||||
|  | SpaceBeforeInheritanceColon: false | ||||||
|  | PointerAlignment: Left | ||||||
|  | ReflowComments: true | ||||||
|  | FixNamespaceComments: true | ||||||
|  | SortIncludes: true | ||||||
|  | SortUsingDeclarations: true | ||||||
|  | IncludeBlocks: Regroup | ||||||
|  | # regular expressions are matched against the filename of an include (including the <> or “”) in order: | ||||||
|  | # topmost: main header file (the one that has the same name as .cpp-file) and ui_XXX.h, if exists | ||||||
|  | # second group: local header files (i.e. "something.h") | ||||||
|  | # third group: external header files (i.e. <smth/other.h>) | ||||||
|  | # fourth group: Qt toolkit headers (actually, anything that starts with a 'Q') | ||||||
|  | # last group: all other external header files | ||||||
|  | # headers in all groups are sorted by name | ||||||
|  | IncludeCategories: | ||||||
|  |   - Regex:           '"ui_.*' | ||||||
|  |     Priority:        0 | ||||||
|  |   - Regex:           '^".*' | ||||||
|  |     Priority:        1 | ||||||
|  |   - Regex:           '^<Qt.*' | ||||||
|  |     Priority:        3 | ||||||
|  |   - Regex:           '^<.*/.*\.h>' | ||||||
|  |     Priority:        2 | ||||||
|  |   - Regex:           '^<Q.*' | ||||||
|  |     Priority:        3 | ||||||
|  |   - Regex:           '^<.*' | ||||||
|  |     Priority:        4 | ||||||
|  | ColumnLimit: 100 | ||||||
|  | TabWidth: 4 | ||||||
|  | UseTab: Never | ||||||
|  | MaxEmptyLinesToKeep: 1 | ||||||
							
								
								
									
										13
									
								
								.github/workflows/cmake.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										13
									
								
								.github/workflows/cmake.yml
									
									
									
									
										vendored
									
									
								
							| @@ -11,9 +11,19 @@ env: | |||||||
|   BUILD_TYPE: Release |   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: | ||||||
|   | |||||||
| @@ -1,19 +1,21 @@ | |||||||
|  | #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[]) | ||||||
| { | { | ||||||
|     QApplication a(argc, argv); |     QApplication a(argc, argv); | ||||||
|     QApplication::setApplicationVersion(LIMEREPORT_VERSION_STR); |     QApplication::setApplicationVersion(LIMEREPORT_VERSION_STR); | ||||||
| @@ -23,63 +25,69 @@ 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( | ||||||
|                QCoreApplication::translate("main", "Limereport pattern file name"), |         QStringList() << "s" | ||||||
|                QCoreApplication::translate("main", "source")); |                       << "source", | ||||||
|  |         QCoreApplication::translate("main", "Limereport pattern file name"), | ||||||
|  |         QCoreApplication::translate("main", "source")); | ||||||
|     parser.addOption(sourceOption); |     parser.addOption(sourceOption); | ||||||
|     QCommandLineOption destinationOption(QStringList() << "d" << "destination", |     QCommandLineOption destinationOption(QStringList() << "d" | ||||||
|                QCoreApplication::translate("main", "Output file name"), |                                                        << "destination", | ||||||
|                QCoreApplication::translate("main", "destination")); |                                          QCoreApplication::translate("main", "Output file name"), | ||||||
|  |                                          QCoreApplication::translate("main", "destination")); | ||||||
|     parser.addOption(destinationOption); |     parser.addOption(destinationOption); | ||||||
|     QCommandLineOption variablesOption(QStringList() << "p" << "param", |     QCommandLineOption variablesOption( | ||||||
|                QCoreApplication::translate("main", "Report parameter (can be more than one)"), |         QStringList() << "p" | ||||||
|                QCoreApplication::translate("main", "param_name=param_value")); |                       << "param", | ||||||
|  |         QCoreApplication::translate("main", "Report parameter (can be more than one)"), | ||||||
|  |         QCoreApplication::translate("main", "param_name=param_value")); | ||||||
|     parser.addOption(variablesOption); |     parser.addOption(variablesOption); | ||||||
|     parser.process(a); |     parser.process(a); | ||||||
|  |  | ||||||
|     LimeReport::ReportEngine report; |     LimeReport::ReportEngine report; | ||||||
|  |  | ||||||
|     if (parser.value(sourceOption).isEmpty()){ |     if (parser.value(sourceOption).isEmpty()) { | ||||||
|         std::cerr<<"Error! Report file is not specified !! \n"; |         std::cerr << "Error! Report file is not specified !! \n"; | ||||||
|         return 1; |         return 1; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     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; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (!parser.values(variablesOption).isEmpty()){ |     if (!parser.values(variablesOption).isEmpty()) { | ||||||
|         foreach(QString var, parser.values(variablesOption)){ |         foreach (QString var, parser.values(variablesOption)) { | ||||||
|             QStringList varItem = var.split("="); |             QStringList varItem = var.split("="); | ||||||
|             if (varItem.size() == 2) |             if (varItem.size() == 2) | ||||||
|                 report.dataManager()->setReportVariable(varItem.at(0),varItem.at(1)); |                 report.dataManager()->setReportVariable(varItem.at(0), varItem.at(1)); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (parser.value(destinationOption).isEmpty()){ |     if (parser.value(destinationOption).isEmpty()) { | ||||||
|         report.printToPDF(QFileInfo(parser.value(sourceOption)).baseName()); |         report.printToPDF(QFileInfo(parser.value(sourceOption)).baseName()); | ||||||
|     } else { |     } else { | ||||||
|         report.printToPDF(parser.value(destinationOption)); |         report.printToPDF(parser.value(destinationOption)); | ||||||
|     } |     } | ||||||
| #else | #else | ||||||
|     std::cerr<<"This demo intended for Qt 5.2 and higher\n"; |     std::cerr << "This demo intended for Qt 5.2 and higher\n"; | ||||||
| #endif | #endif | ||||||
| //    QUuid uid = QUuid::createUuid(); |     //    QUuid uid = QUuid::createUuid(); | ||||||
| //    QString uidStr = uid.toString()+".pdf"; |     //    QString uidStr = uid.toString()+".pdf"; | ||||||
| //    report.printToPDF(uidStr); |     //    report.printToPDF(uidStr); | ||||||
| //    QFile in(uidStr); |     //    QFile in(uidStr); | ||||||
| //    QFile out; |     //    QFile out; | ||||||
| //    out.open(stdout, QFile::WriteOnly); |     //    out.open(stdout, QFile::WriteOnly); | ||||||
| //    in.open(QIODevice::ReadOnly); |     //    in.open(QIODevice::ReadOnly); | ||||||
| //#ifdef _WIN32 |     //#ifdef _WIN32 | ||||||
| //    _setmode(fileno(stdout),O_BINARY); |     //    _setmode(fileno(stdout),O_BINARY); | ||||||
| //#endif |     //#endif | ||||||
| //    QByteArray buffer = in.readAll(); |     //    QByteArray buffer = in.readAll(); | ||||||
| //    fwrite(buffer,1,buffer.size(),stdout); |     //    fwrite(buffer,1,buffer.size(),stdout); | ||||||
| //    in.close(); |     //    in.close(); | ||||||
| //    in.remove(); |     //    in.remove(); | ||||||
|  |  | ||||||
|     return 0; |     return 0; | ||||||
|     //return a.exec(); |     // return a.exec(); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -28,10 +28,10 @@ | |||||||
|  *   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[]) |  | ||||||
| { | { | ||||||
|     QApplication a(argc, argv); |     QApplication a(argc, argv); | ||||||
|     MainWindow w; |     MainWindow w; | ||||||
|   | |||||||
| @@ -29,85 +29,94 @@ | |||||||
|  ****************************************************************************/ |  ****************************************************************************/ | ||||||
| #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" | ||||||
| #else | #else | ||||||
| # define EASY_BLOCK(...) | #define EASY_BLOCK(...) | ||||||
| # define EASY_END_BLOCK | #define EASY_END_BLOCK | ||||||
| # define EASY_PROFILER_ENABLE | #define EASY_PROFILER_ENABLE | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| 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"); | ||||||
|     if (dbFile.exists()){ |     if (dbFile.exists()) { | ||||||
|         m_db = QSqlDatabase::addDatabase("QSQLITE"); |         m_db = QSqlDatabase::addDatabase("QSQLITE"); | ||||||
|         m_db.setDatabaseName(dbFile.fileName()); |         m_db.setDatabaseName(dbFile.fileName()); | ||||||
|         if (m_db.open()){ |         if (m_db.open()) { | ||||||
|             QSqlQueryModel* customersModel = new QSqlQueryModel(); |             QSqlQueryModel* customersModel = new QSqlQueryModel(); | ||||||
|             customersModel->setQuery("select * from customers", m_db); |             customersModel->setQuery("select * from customers", m_db); | ||||||
|             report->dataManager()->addModel("external_customers_data",customersModel,true); |             report->dataManager()->addModel("external_customers_data", customersModel, true); | ||||||
|             QSqlQueryModel* ordersModel = new QSqlQueryModel(); |             QSqlQueryModel* ordersModel = new QSqlQueryModel(); | ||||||
|             ordersModel->setQuery("Select * from orders",m_db); |             ordersModel->setQuery("Select * from orders", m_db); | ||||||
|             report->dataManager()->addModel("external_orders_data",ordersModel,true); |             report->dataManager()->addModel("external_orders_data", ordersModel, true); | ||||||
|             m_customers = new QSqlQuery("Select * from customers limit 10",m_db); |             m_customers = new QSqlQuery("Select * from customers limit 10", m_db); | ||||||
|             m_customers->first(); |             m_customers->first(); | ||||||
|             m_orders = new QSqlQuery(m_db); |             m_orders = new QSqlQuery(m_db); | ||||||
|             m_orders->prepare("Select * from orders where CustomerID = :id"); |             m_orders->prepare("Select * from orders where CustomerID = :id"); | ||||||
|             int index = m_customers->record().indexOf("CustomerID"); |             int index = m_customers->record().indexOf("CustomerID"); | ||||||
|             m_orders->bindValue(":id",m_customers->value(index)); |             m_orders->bindValue(":id", m_customers->value(index)); | ||||||
|             m_orders->exec(); |             m_orders->exec(); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     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"; | ||||||
|     //report->scriptManager()->scriptEngine()->globalObject().setProperty("test_list",value); |     // QScriptValue value = | ||||||
|  |     // qScriptValueFromSequence(report->scriptManager()->scriptEngine(),strList); | ||||||
|  |     // report->scriptManager()->scriptEngine()->globalObject().setProperty("test_list",value); | ||||||
| } | } | ||||||
|  |  | ||||||
| MainWindow::~MainWindow() | MainWindow::~MainWindow() | ||||||
| @@ -122,8 +131,9 @@ void MainWindow::on_pushButton_clicked() | |||||||
|     EASY_PROFILER_ENABLE; |     EASY_PROFILER_ENABLE; | ||||||
|     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,27 +145,30 @@ 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"); | ||||||
|         report->loadFromFile(fileName); |         report->loadFromFile(fileName); | ||||||
|         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 | ||||||
|         profiler::dumpBlocksToFile("test.prof"); |         profiler::dumpBlocksToFile("test.prof"); | ||||||
| #endif | #endif | ||||||
| //        QPrinter* printer = new QPrinter; |         //        QPrinter* printer = new QPrinter; | ||||||
| //        QPrintDialog dialog(printer); |         //        QPrintDialog dialog(printer); | ||||||
| //        if (dialog.exec()){ |         //        if (dialog.exec()){ | ||||||
| //            QMap<QString, QPrinter*> printers; |         //            QMap<QString, QPrinter*> printers; | ||||||
| //            printers.insert("default",printer); |         //            printers.insert("default",printer); | ||||||
| //            report->printReport(printers); |         //            report->printReport(printers); | ||||||
| //        } |         //        } | ||||||
|         report->setShowProgressDialog(true); |         report->setShowProgressDialog(true); | ||||||
|         report->previewReport(); |         report->previewReport(); | ||||||
|     } |     } | ||||||
| @@ -163,10 +176,10 @@ void MainWindow::on_pushButton_2_clicked() | |||||||
|  |  | ||||||
| void MainWindow::renderStarted() | void MainWindow::renderStarted() | ||||||
| { | { | ||||||
|     if (report->isShowProgressDialog()){ |     if (report->isShowProgressDialog()) { | ||||||
|         m_currentPage = 0; |         m_currentPage = 0; | ||||||
|         m_progressDialog = new QProgressDialog(tr("Start render"),tr("Cancel"),0,0,this); |         m_progressDialog = new QProgressDialog(tr("Start render"), tr("Cancel"), 0, 0, this); | ||||||
|         //m_progressDialog->setWindowModality(Qt::WindowModal); |         // m_progressDialog->setWindowModality(Qt::WindowModal); | ||||||
|         connect(m_progressDialog, SIGNAL(canceled()), report, SLOT(cancelRender())); |         connect(m_progressDialog, SIGNAL(canceled()), report, SLOT(cancelRender())); | ||||||
|         QApplication::processEvents(); |         QApplication::processEvents(); | ||||||
|         m_progressDialog->show(); |         m_progressDialog->show(); | ||||||
| @@ -175,22 +188,22 @@ void MainWindow::renderStarted() | |||||||
|  |  | ||||||
| void MainWindow::renderPageFinished(int renderedPageCount) | void MainWindow::renderPageFinished(int renderedPageCount) | ||||||
| { | { | ||||||
|     if (m_progressDialog){ |     if (m_progressDialog) { | ||||||
|         m_progressDialog->setLabelText(QString::number(renderedPageCount)+tr(" page rendered")); |         m_progressDialog->setLabelText(QString::number(renderedPageCount) + tr(" page rendered")); | ||||||
|         m_progressDialog->setValue(renderedPageCount); |         m_progressDialog->setValue(renderedPageCount); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void MainWindow::renderFinished() | void MainWindow::renderFinished() | ||||||
| { | { | ||||||
|     if (m_progressDialog){ |     if (m_progressDialog) { | ||||||
|         m_progressDialog->close(); |         m_progressDialog->close(); | ||||||
|         delete m_progressDialog; |         delete m_progressDialog; | ||||||
|     } |     } | ||||||
|     m_progressDialog = 0; |     m_progressDialog = 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| void MainWindow::prepareData(QSqlQuery* ds, LimeReport::CallbackInfo info, QVariant &data) | void MainWindow::prepareData(QSqlQuery* ds, LimeReport::CallbackInfo info, QVariant& data) | ||||||
| { | { | ||||||
|     switch (info.dataType) { |     switch (info.dataType) { | ||||||
|     case LimeReport::CallbackInfo::ColumnCount: |     case LimeReport::CallbackInfo::ColumnCount: | ||||||
| @@ -210,67 +223,81 @@ 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) { | ||||||
|     if (result){ |         result = ds->first(); | ||||||
|         m_orders->bindValue(":id",m_customers->value(m_customers->record().indexOf("CustomerID"))); |     } else { | ||||||
|  |         result = ds->next(); | ||||||
|  |     } | ||||||
|  |     if (result) { | ||||||
|  |         m_orders->bindValue(":id", m_customers->value(m_customers->record().indexOf("CustomerID"))); | ||||||
|         m_orders->exec(); |         m_orders->exec(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void MainWindow::slotGetCallbackChildData(LimeReport::CallbackInfo info, QVariant &data) | void MainWindow::slotGetCallbackChildData(LimeReport::CallbackInfo info, QVariant& data) | ||||||
| { | { | ||||||
|     if (!m_orders) return ; |     if (!m_orders) | ||||||
|  |         return; | ||||||
|     prepareData(m_orders, info, data); |     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; | ||||||
|                 break; |         break; | ||||||
|             case LimeReport::CallbackInfo::ColumnCount: |     case LimeReport::CallbackInfo::ColumnCount: | ||||||
|                 data = columns.size(); |         data = columns.size(); | ||||||
|                 break; |         break; | ||||||
| //            case LimeReport::CallbackInfo::IsEmpty: |         //            case LimeReport::CallbackInfo::IsEmpty: | ||||||
| //                data = false; |         //                data = false; | ||||||
| //                break; |         //                break; | ||||||
|             case LimeReport::CallbackInfo::ColumnHeaderData: { |     case LimeReport::CallbackInfo::ColumnHeaderData: { | ||||||
|                 data = columns.at(info.index); |         data = columns.at(info.index); | ||||||
|                 break; |         break; | ||||||
|             } |     } | ||||||
|             case LimeReport::CallbackInfo::ColumnData: |     case LimeReport::CallbackInfo::ColumnData: | ||||||
|                 if (info.columnName == "Image") |         if (info.columnName == "Image") | ||||||
|                     data = QImage(":/report//images/logo32"); |             data = QImage(":/report//images/logo32"); | ||||||
|                 else { |         else { | ||||||
|                     data = info.columnName+" "+QString::number(info.index); |             data = info.columnName + " " + QString::number(info.index); | ||||||
|                 } |  | ||||||
|                 break; |  | ||||||
|             default: break; |  | ||||||
|         } |         } | ||||||
|  |         break; | ||||||
|  |     default: | ||||||
|  |         break; | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -30,22 +30,22 @@ | |||||||
| #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: | ||||||
|     explicit MainWindow(QWidget *parent = 0); |     explicit MainWindow(QWidget* parent = 0); | ||||||
|     ~MainWindow(); |     ~MainWindow(); | ||||||
| private slots: | private slots: | ||||||
|     void on_pushButton_clicked(); |     void on_pushButton_clicked(); | ||||||
| @@ -58,11 +58,13 @@ 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; | ||||||
|     QProgressDialog* m_progressDialog; |     QProgressDialog* m_progressDialog; | ||||||
|     int m_currentPage; |     int m_currentPage; | ||||||
|     QSqlDatabase m_db; |     QSqlDatabase m_db; | ||||||
| @@ -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 | ||||||
|   | |||||||
| @@ -1,7 +1,8 @@ | |||||||
| #include "mainwindow.h" | #include "mainwindow.h" | ||||||
|  |  | ||||||
| #include <QApplication> | #include <QApplication> | ||||||
|  |  | ||||||
| int main(int argc, char *argv[]) | int main(int argc, char* argv[]) | ||||||
| { | { | ||||||
|     QApplication a(argc, argv); |     QApplication a(argc, argv); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -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); | ||||||
|  |  | ||||||
| @@ -20,20 +19,22 @@ MainWindow::MainWindow(QWidget *parent) : | |||||||
|     m_pageNavigator = new QSpinBox(this); |     m_pageNavigator = new QSpinBox(this); | ||||||
|  |  | ||||||
|     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); | ||||||
|     connect(ui->actionZoomIn, SIGNAL(triggered()), m_preview, SLOT(zoomIn())); |     connect(ui->actionZoomIn, SIGNAL(triggered()), m_preview, SLOT(zoomIn())); | ||||||
|     connect(ui->actionZoom_Out, SIGNAL(triggered()), m_preview, SLOT(zoomOut())); |     connect(ui->actionZoom_Out, SIGNAL(triggered()), m_preview, SLOT(zoomOut())); | ||||||
|     connect(ui->actionFirst_Page, SIGNAL(triggered()), m_preview, SLOT(firstPage())); |     connect(ui->actionFirst_Page, SIGNAL(triggered()), m_preview, SLOT(firstPage())); | ||||||
|     connect(ui->actionPrior_Page, SIGNAL(triggered()), m_preview, SLOT(priorPage())); |     connect(ui->actionPrior_Page, SIGNAL(triggered()), m_preview, SLOT(priorPage())); | ||||||
|     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))); | ||||||
| @@ -45,44 +46,40 @@ MainWindow::MainWindow(QWidget *parent) : | |||||||
|     initPercentCombobox(); |     initPercentCombobox(); | ||||||
|     enableUI(false); |     enableUI(false); | ||||||
| #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) | #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) | ||||||
|     QDesktopWidget *desktop = QApplication::desktop(); |     QDesktopWidget* desktop = QApplication::desktop(); | ||||||
|  |  | ||||||
|     int screenWidth = desktop->screenGeometry().width(); |     int screenWidth = desktop->screenGeometry().width(); | ||||||
|     int screenHeight = desktop->screenGeometry().height(); |     int screenHeight = desktop->screenGeometry().height(); | ||||||
| #else | #else | ||||||
|     QScreen *screen = QGuiApplication::primaryScreen(); |     QScreen* screen = QGuiApplication::primaryScreen(); | ||||||
|  |  | ||||||
|     int screenWidth = screen->geometry().width(); |     int screenWidth = screen->geometry().width(); | ||||||
|     int screenHeight = screen->geometry().height(); |     int screenHeight = screen->geometry().height(); | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|     int x = screenWidth*0.1; |     int x = screenWidth * 0.1; | ||||||
|     int y = screenHeight*0.1; |     int y = screenHeight * 0.1; | ||||||
|  |  | ||||||
|     resize(screenWidth*0.8, screenHeight*0.8); |     resize(screenWidth * 0.8, screenHeight * 0.8); | ||||||
|     move(x, y); |     move(x, y); | ||||||
|  |  | ||||||
|     if (ui->treeWidget->topLevelItemCount()>0){ |     if (ui->treeWidget->topLevelItemCount() > 0) { | ||||||
|         int index = 0; |         int index = 0; | ||||||
|         while (index<ui->treeWidget->topLevelItemCount()){ |         while (index < ui->treeWidget->topLevelItemCount()) { | ||||||
|             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) | ||||||
| { | { | ||||||
| @@ -104,21 +101,21 @@ void MainWindow::enableUI(bool value) | |||||||
|  |  | ||||||
| void MainWindow::slotScalePercentChanged(int percent) | void MainWindow::slotScalePercentChanged(int percent) | ||||||
| { | { | ||||||
|     //ui->cbScalePercent->setEditText(QString("%1%").arg(percent)); |     // ui->cbScalePercent->setEditText(QString("%1%").arg(percent)); | ||||||
|     m_scalePercent->setEditText(QString("%1%").arg(percent)); |     m_scalePercent->setEditText(QString("%1%").arg(percent)); | ||||||
| } | } | ||||||
|  |  | ||||||
| void MainWindow::scaleComboboxChanged(QString text) | void MainWindow::scaleComboboxChanged(QString text) | ||||||
| { | { | ||||||
|     m_preview->setScalePercent(text.remove(text.count()-1,1).toInt()); |     m_preview->setScalePercent(text.remove(text.count() - 1, 1).toInt()); | ||||||
| } | } | ||||||
|  |  | ||||||
| void MainWindow::slotPagesSet(int pagesCount) | void MainWindow::slotPagesSet(int pagesCount) | ||||||
| { | { | ||||||
| //    ui->sbPageNavigator->setSuffix(tr(" of %1").arg(pagesCount)); |     //    ui->sbPageNavigator->setSuffix(tr(" of %1").arg(pagesCount)); | ||||||
| //    ui->sbPageNavigator->setMinimum(1); |     //    ui->sbPageNavigator->setMinimum(1); | ||||||
| //    ui->sbPageNavigator->setMaximum(pagesCount); |     //    ui->sbPageNavigator->setMaximum(pagesCount); | ||||||
| //    ui->sbPageNavigator->setValue(1); |     //    ui->sbPageNavigator->setValue(1); | ||||||
|  |  | ||||||
|     m_pageNavigator->setSuffix(tr(" of %1").arg(pagesCount)); |     m_pageNavigator->setSuffix(tr(" of %1").arg(pagesCount)); | ||||||
|     m_pageNavigator->setMinimum(1); |     m_pageNavigator->setMinimum(1); | ||||||
| @@ -127,35 +124,29 @@ 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) | ||||||
| { | { | ||||||
|     if (!m_report.isBusy()){ |     if (!m_report.isBusy()) { | ||||||
|         m_report.loadFromFile(item->data(0,Qt::UserRole).toString()); |         m_report.loadFromFile(item->data(0, Qt::UserRole).toString()); | ||||||
|         m_preview->refreshPages(); |         m_preview->refreshPages(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void MainWindow::initPercentCombobox() | void MainWindow::initPercentCombobox() | ||||||
| { | { | ||||||
|     for (int i = 10; i<310; i+=10){ |     for (int i = 10; i < 310; i += 10) { | ||||||
| //        ui->cbScalePercent->addItem(QString("%1%").arg(i)); |         //        ui->cbScalePercent->addItem(QString("%1%").arg(i)); | ||||||
|         m_scalePercent->addItem(QString("%1%").arg(i)); |         m_scalePercent->addItem(QString("%1%").arg(i)); | ||||||
|     } |     } | ||||||
| //    ui->cbScalePercent->setCurrentIndex(4); |     //    ui->cbScalePercent->setCurrentIndex(4); | ||||||
|     m_scalePercent->setCurrentIndex(4); |     m_scalePercent->setCurrentIndex(4); | ||||||
| } | } | ||||||
|  |  | ||||||
| //void MainWindow::on_sbPageNavigator_valueChanged(int arg1) | // void MainWindow::on_sbPageNavigator_valueChanged(int arg1) | ||||||
| //{ | //{ | ||||||
| //    m_preview->pageNavigatorChanged(arg1); | //    m_preview->pageNavigatorChanged(arg1); | ||||||
| //} | //} | ||||||
| @@ -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); |  | ||||||
| } |  | ||||||
|   | |||||||
| @@ -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: | ||||||
| @@ -28,35 +29,36 @@ private slots: | |||||||
|     void slotPagesSet(int pagesCount); |     void slotPagesSet(int pagesCount); | ||||||
|     void slotPageChanged(int page); |     void slotPageChanged(int page); | ||||||
|     void slotPageNavigatorChanged(int page); |     void slotPageNavigatorChanged(int page); | ||||||
|     void on_treeWidget_itemClicked(QTreeWidgetItem *item, int); |     void on_treeWidget_itemClicked(QTreeWidgetItem* item, int); | ||||||
|     //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); | ||||||
|         foreach( QString dir, items){ |         foreach (QString dir, items) { | ||||||
|             QTreeWidgetItem* listItem = new QTreeWidgetItem(parentItem); |             QTreeWidgetItem* listItem = new QTreeWidgetItem(parentItem); | ||||||
|             listItem->setText(0,dir); |             listItem->setText(0, dir); | ||||||
|             listItem->setIcon(0,QIcon(":/images/images/folder.png")); |             listItem->setIcon(0, QIcon(":/images/images/folder.png")); | ||||||
|             buildReportsTree(reportsDir.path()+"/"+dir, listItem); |             buildReportsTree(reportsDir.path() + "/" + dir, listItem); | ||||||
|         } |         } | ||||||
|         QStringList nameFilters; |         QStringList nameFilters; | ||||||
|         nameFilters <<"*.lrxml"; |         nameFilters << "*.lrxml"; | ||||||
|         items = reportsDir.entryList(nameFilters, QDir::Files); |         items = reportsDir.entryList(nameFilters, QDir::Files); | ||||||
|         foreach( QString file, items){ |         foreach (QString file, items) { | ||||||
|             QTreeWidgetItem* listItem = new QTreeWidgetItem(parentItem); |             QTreeWidgetItem* listItem = new QTreeWidgetItem(parentItem); | ||||||
|             listItem->setIcon(0,QIcon(":/images/images/report.png")); |             listItem->setIcon(0, QIcon(":/images/images/report.png")); | ||||||
|             listItem->setText(0,file); |             listItem->setText(0, file); | ||||||
|             listItem->setData(0,Qt::UserRole,reportsDir.path()+"/"+file); |             listItem->setData(0, Qt::UserRole, reportsDir.path() + "/" + file); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     void initPercentCombobox(); |     void initPercentCombobox(); | ||||||
|  |  | ||||||
| private: | private: | ||||||
|     Ui::MainWindow *ui; |     Ui::MainWindow* ui; | ||||||
|     LimeReport::ReportEngine m_report; |     LimeReport::ReportEngine m_report; | ||||||
|     LimeReport::PreviewReportWidget* m_preview; |     LimeReport::PreviewReportWidget* m_preview; | ||||||
|     QComboBox* m_scalePercent; |     QComboBox* m_scalePercent; | ||||||
|   | |||||||
| @@ -1,21 +1,19 @@ | |||||||
| #include "designersettingmanager.h" | #include "designersettingmanager.h" | ||||||
|  |  | ||||||
| #include <QMessageBox> | #include <QMessageBox> | ||||||
|  |  | ||||||
| DesignerSettingManager::DesignerSettingManager(QObject *parent) : QObject(parent) | DesignerSettingManager::DesignerSettingManager(QObject* parent): QObject(parent) | ||||||
| { | { | ||||||
|     m_setting = new QSettings("LimeReport",QCoreApplication::applicationName()); |     m_setting = new QSettings("LimeReport", QCoreApplication::applicationName()); | ||||||
| } | } | ||||||
|  |  | ||||||
| DesignerSettingManager::~DesignerSettingManager() | DesignerSettingManager::~DesignerSettingManager() { delete m_setting; } | ||||||
| { |  | ||||||
|     delete m_setting; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void DesignerSettingManager::getAvailableLanguages(QList<QLocale::Language>* languages) | void DesignerSettingManager::getAvailableLanguages(QList<QLocale::Language>* languages) | ||||||
| { | { | ||||||
|     languages->append(QLocale::Russian); |     languages->append(QLocale::Russian); | ||||||
|     languages->append(QLocale::English); |     languages->append(QLocale::English); | ||||||
| //    languages->append(QLocale::Arabic); |     //    languages->append(QLocale::Arabic); | ||||||
|     languages->append(QLocale::French); |     languages->append(QLocale::French); | ||||||
|     languages->append(QLocale::Chinese); |     languages->append(QLocale::Chinese); | ||||||
|     languages->append(QLocale::Spanish); |     languages->append(QLocale::Spanish); | ||||||
| @@ -27,8 +25,8 @@ QLocale::Language DesignerSettingManager::getCurrentDefaultLanguage() | |||||||
|     m_setting->beginGroup("ReportDesigner"); |     m_setting->beginGroup("ReportDesigner"); | ||||||
|     QVariant v = m_setting->value("DesignerLanguage"); |     QVariant v = m_setting->value("DesignerLanguage"); | ||||||
|     m_setting->endGroup(); |     m_setting->endGroup(); | ||||||
|     if (v.isValid()){ |     if (v.isValid()) { | ||||||
|         return static_cast<QLocale::Language>(v.toInt()) ; |         return static_cast<QLocale::Language>(v.toInt()); | ||||||
|     } else { |     } else { | ||||||
|         return QLocale::system().language(); |         return QLocale::system().language(); | ||||||
|     } |     } | ||||||
| @@ -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(); | ||||||
|   | |||||||
| @@ -1,21 +1,21 @@ | |||||||
| #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); | ||||||
|     ~DesignerSettingManager(); |     ~DesignerSettingManager(); | ||||||
| public slots: | 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; | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -1,10 +1,12 @@ | |||||||
| #include <QApplication> |  | ||||||
| #include <LimeReport> |  | ||||||
| #include <QTranslator> |  | ||||||
| #include <QDebug> |  | ||||||
| #include "designersettingmanager.h" | #include "designersettingmanager.h" | ||||||
|  |  | ||||||
| int main(int argc, char *argv[]) | #include <QApplication> | ||||||
|  | #include <QDebug> | ||||||
|  | #include <QTranslator> | ||||||
|  |  | ||||||
|  | #include <LimeReport> | ||||||
|  |  | ||||||
|  | int main(int argc, char* argv[]) | ||||||
| { | { | ||||||
|     QApplication a(argc, argv); |     QApplication a(argc, argv); | ||||||
|  |  | ||||||
| @@ -21,29 +23,31 @@ int main(int argc, char *argv[]) | |||||||
|  |  | ||||||
|     QString designerTranslation = QLocale(manager.getCurrentDefaultLanguage()).name(); |     QString designerTranslation = QLocale(manager.getCurrentDefaultLanguage()).name(); | ||||||
|  |  | ||||||
|     if (limeReportTranslator.load("limereport_"+designerTranslation, translationPath)){ |     if (limeReportTranslator.load("limereport_" + designerTranslation, translationPath)) { | ||||||
|         static_cast<void>(qtBaseTranslator.load("qtbase_" + designerTranslation, translationPath)); |         static_cast<void>(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); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     LimeReport::ReportEngine report; |     LimeReport::ReportEngine report; | ||||||
|     report.setPreviewLayoutDirection(layoutDirection); |     report.setPreviewLayoutDirection(layoutDirection); | ||||||
|  |  | ||||||
|     if (a.arguments().count()>1){ |     if (a.arguments().count() > 1) { | ||||||
|         report.loadFromFile(a.arguments().at(1)); |         report.loadFromFile(a.arguments().at(1)); | ||||||
|     } |     } | ||||||
|     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(); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -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 | ||||||
|  |  | ||||||
|   | |||||||
| @@ -2,18 +2,21 @@ | |||||||
| #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 { | ||||||
|     Q_OBJECT |     Q_OBJECT | ||||||
| #if QT_VERSION >= 0x050000 | #if QT_VERSION >= 0x050000 | ||||||
|     Q_PLUGIN_METADATA(IID "ru.limereport.DersignerFactoryInterface") |     Q_PLUGIN_METADATA(IID "ru.limereport.DersignerFactoryInterface") | ||||||
| #endif | #endif | ||||||
|     Q_INTERFACES( LimeReportDesignerPluginInterface ) |     Q_INTERFACES(LimeReportDesignerPluginInterface) | ||||||
|  |  | ||||||
| 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 | ||||||
|   | |||||||
| @@ -3,22 +3,31 @@ | |||||||
| #include <QObject> | #include <QObject> | ||||||
| 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; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| class ICallbackDatasource :public QObject{ | class ICallbackDatasource: public QObject { | ||||||
|     Q_OBJECT |     Q_OBJECT | ||||||
| signals: | signals: | ||||||
|     void getCallbackData(const LimeReport::CallbackInfo& info, QVariant& data); |     void getCallbackData(const LimeReport::CallbackInfo& info, QVariant& data); | ||||||
|     void changePos(const LimeReport::CallbackInfo::ChangePosType& type, bool& result); |     void changePos(const LimeReport::CallbackInfo::ChangePosType& type, bool& result); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| } | } // namespace LimeReport | ||||||
|  |  | ||||||
| #endif // LRVIRTUALDATASOURCEINTF | #endif // LRVIRTUALDATASOURCEINTF | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,14 +1,17 @@ | |||||||
| #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; | ||||||
|     virtual bool hasNext() = 0; |     virtual bool hasNext() = 0; | ||||||
|     virtual bool prior() = 0; |     virtual bool prior() = 0; | ||||||
| @@ -18,12 +21,16 @@ public: | |||||||
|     virtual bool eof() = 0; |     virtual bool eof() = 0; | ||||||
|     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; | ||||||
|     virtual int columnIndexByName(QString name) = 0; |     virtual int columnIndexByName(QString name) = 0; | ||||||
|     virtual bool isInvalid() const = 0; |     virtual bool isInvalid() const = 0; | ||||||
|     virtual QString lastError() = 0; |     virtual QString lastError() = 0; | ||||||
| @@ -32,8 +39,9 @@ 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 | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -31,34 +31,36 @@ | |||||||
| #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; | ||||||
| class QAbstractItemModel; | class QAbstractItemModel; | ||||||
| namespace LimeReport{ | namespace LimeReport { | ||||||
|  |  | ||||||
| class IDbCredentialsProvider{ | class IDbCredentialsProvider { | ||||||
| public: | public: | ||||||
|     virtual ~IDbCredentialsProvider(){} |     virtual ~IDbCredentialsProvider() { } | ||||||
|     virtual QString getUserName(const QString& connectionName) = 0; |     virtual QString getUserName(const QString& connectionName) = 0; | ||||||
|     virtual QString getPassword(const QString& connectionName) = 0; |     virtual QString getPassword(const QString& connectionName) = 0; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| class IDataSourceManager{ | class IDataSourceManager { | ||||||
| public: | public: | ||||||
|     virtual ~IDataSourceManager(){} |     virtual ~IDataSourceManager() { } | ||||||
|     virtual void setReportVariable(const QString& name, const QVariant& value) = 0; |     virtual void setReportVariable(const QString& name, const QVariant& value) = 0; | ||||||
|     virtual void setDefaultDatabasePath(const QString &defaultDatabasePath) = 0; |     virtual void setDefaultDatabasePath(const QString& defaultDatabasePath) = 0; | ||||||
|     virtual void deleteVariable(const QString& name) = 0; |     virtual void deleteVariable(const QString& name) = 0; | ||||||
|     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; | ||||||
|     virtual ICallbackDatasource* createCallbackDatasource(const QString& name) = 0; |     virtual ICallbackDatasource* createCallbackDatasource(const QString& name) = 0; | ||||||
|     virtual void registerDbCredentialsProvider(IDbCredentialsProvider* provider) = 0; |     virtual void registerDbCredentialsProvider(IDbCredentialsProvider* provider) = 0; | ||||||
|     virtual QStringList variableNames() = 0; |     virtual QStringList variableNames() = 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 | ||||||
|  |  | ||||||
|   | |||||||
| @@ -27,18 +27,21 @@ | |||||||
|  *   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; | ||||||
|     return className.right(className.length()-startPos); |     else | ||||||
|  |         startPos += 2; | ||||||
|  |     return className.right(className.length() - startPos); | ||||||
| } | } | ||||||
|  |  | ||||||
| bool ReportSettings::suppressAbsentFieldsAndVarsWarnings() const | bool ReportSettings::suppressAbsentFieldsAndVarsWarnings() const | ||||||
| @@ -46,31 +49,34 @@ 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; | ||||||
| } | } | ||||||
|  |  | ||||||
| QString escapeSimbols(const QString &value) | QString escapeSimbols(const QString& value) | ||||||
| { | { | ||||||
|     QString result = value; |     QString result = value; | ||||||
|     result.replace("\"","\\\""); |     result.replace("\"", "\\\""); | ||||||
|     result.replace('\n',"\\n"); |     result.replace('\n', "\\n"); | ||||||
|     return result; |     return result; | ||||||
| } | } | ||||||
|  |  | ||||||
| QString replaceHTMLSymbols(const QString &value) | QString replaceHTMLSymbols(const QString& value) | ||||||
| { | { | ||||||
|     QString result = value; |     QString result = value; | ||||||
|     result.replace("<","<"); |     result.replace("<", "<"); | ||||||
|     result.replace(">",">"); |     result.replace(">", ">"); | ||||||
|     return result; |     return result; | ||||||
| } | } | ||||||
|  |  | ||||||
| #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 ®){ | 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,13 +86,14 @@ QVector<QString> normalizeCaptures(const QRegularExpressionMatch ®){ | |||||||
|     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; | { | ||||||
|     if(darkness<0.5){ |     qreal darkness = 1 - (0.299 * color.red() + 0.587 * color.green() + 0.114 * color.blue()) / 255; | ||||||
|  |     if (darkness < 0.5) { | ||||||
|         return false; |         return false; | ||||||
|     } else { |     } else { | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| } //namespace LimeReport | } // namespace LimeReport | ||||||
|   | |||||||
| @@ -30,23 +30,25 @@ | |||||||
| #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) | ||||||
| #  define LIMEREPORT_EXPORT Q_DECL_IMPORT | #define LIMEREPORT_EXPORT Q_DECL_IMPORT | ||||||
| #else | #else | ||||||
| #  define LIMEREPORT_EXPORT   /**/ | #define LIMEREPORT_EXPORT /**/ | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| namespace LimeReport { | namespace LimeReport { | ||||||
|  |  | ||||||
| #ifdef __GNUC__ | #ifdef __GNUC__ | ||||||
| #define VARIABLE_IS_NOT_USED __attribute__ ((unused)) | #define VARIABLE_IS_NOT_USED __attribute__((unused)) | ||||||
| #else | #else | ||||||
| #define VARIABLE_IS_NOT_USED | #define VARIABLE_IS_NOT_USED | ||||||
| #endif | #endif | ||||||
| @@ -55,12 +57,12 @@ namespace LimeReport { | |||||||
| Q_NAMESPACE | Q_NAMESPACE | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| namespace Const{ | namespace Const { | ||||||
|     int const DEFAULT_GRID_STEP = 1; |     int const DEFAULT_GRID_STEP = 1; | ||||||
|     int const RESIZE_HANDLE_SIZE = 5; |     int const RESIZE_HANDLE_SIZE = 5; | ||||||
|     int const SELECTION_PEN_SIZE = 1; |     int const SELECTION_PEN_SIZE = 1; | ||||||
|     int const MINIMUM_ITEM_WIDTH = 2*RESIZE_HANDLE_SIZE; |     int const MINIMUM_ITEM_WIDTH = 2 * RESIZE_HANDLE_SIZE; | ||||||
|     int const MINIMUM_ITEM_HEIGHT = 2*RESIZE_HANDLE_SIZE; |     int const MINIMUM_ITEM_HEIGHT = 2 * RESIZE_HANDLE_SIZE; | ||||||
|     double const RESIZE_ZONE_OPACITY = 0.5; |     double const RESIZE_ZONE_OPACITY = 0.5; | ||||||
|     double const SELECTED_RESIZE_ZONE_OPACITY = 0.6; |     double const SELECTED_RESIZE_ZONE_OPACITY = 0.6; | ||||||
|     Qt::GlobalColor const RESIZE_ZONE_COLOR = Qt::green; |     Qt::GlobalColor const RESIZE_ZONE_COLOR = Qt::green; | ||||||
| @@ -80,15 +82,21 @@ 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; | ||||||
|  |  | ||||||
|     const QString GROUP_FUNCTION_RX = "(%1\\s*"+GROUP_FUNCTION_PARAM_RX+")"; |     const QString GROUP_FUNCTION_RX = "(%1\\s*" + GROUP_FUNCTION_PARAM_RX + ")"; | ||||||
|     const QString GROUP_FUNCTION_NAME_RX = "%1\\s*\\((.*[^\\)])\\)"; |     const QString GROUP_FUNCTION_NAME_RX = "%1\\s*\\((.*[^\\)])\\)"; | ||||||
|     const int SCENE_MARGIN = 50; |     const int SCENE_MARGIN = 50; | ||||||
|     const QString FUNCTION_MANAGER_NAME = "LimeReport"; |     const QString FUNCTION_MANAGER_NAME = "LimeReport"; | ||||||
| @@ -100,104 +108,135 @@ 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); | ||||||
| #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1) | #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1) | ||||||
|     QVector<QString> normalizeCaptures(const QRegularExpressionMatch ®); | QVector<QString> normalizeCaptures(const QRegularExpressionMatch& reg); | ||||||
| #else | #else | ||||||
|     QVector<QString> normalizeCaptures(const QRegExp ®);     | QVector<QString> normalizeCaptures(const QRegExp& reg); | ||||||
| #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, | }; | ||||||
|                      HidePreviewToolBar = 1, | enum RenderPass { | ||||||
|                      HidePreviewMenuBar = 2, |     FirstPass = 1, | ||||||
|                      HidePreviewStatusBar = 4, |     SecondPass = 2 | ||||||
|                      HideAllPreviewBar = 7, | }; | ||||||
|                      PreviewBarsUserSetting = 8}; | enum ArrangeType { | ||||||
|  |     AsNeeded, | ||||||
|  |     Force | ||||||
|  | }; | ||||||
|  | enum ScaleType { | ||||||
|  |     FitWidth, | ||||||
|  |     FitPage, | ||||||
|  |     OneToOne, | ||||||
|  |     Percents | ||||||
|  | }; | ||||||
|  | enum PreviewHint { | ||||||
|  |     ShowAllPreviewBars = 0, | ||||||
|  |     HidePreviewToolBar = 1, | ||||||
|  |     HidePreviewMenuBar = 2, | ||||||
|  |     HidePreviewStatusBar = 4, | ||||||
|  |     HideAllPreviewBar = 7, | ||||||
|  |     PreviewBarsUserSetting = 8 | ||||||
|  | }; | ||||||
|  |  | ||||||
|     Q_DECLARE_FLAGS(PreviewHints, PreviewHint) | Q_DECLARE_FLAGS(PreviewHints, PreviewHint) | ||||||
|     Q_FLAGS(PreviewHints) | Q_FLAGS(PreviewHints) | ||||||
|  |  | ||||||
|     class LIMEREPORT_EXPORT ReportError : public std::runtime_error{ | class LIMEREPORT_EXPORT ReportError: public std::runtime_error { | ||||||
|     public: | public: | ||||||
|         ReportError(const QString& message); |     ReportError(const QString& message); | ||||||
|     }; | }; | ||||||
|  |  | ||||||
|     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; | ||||||
|  |     void setSuppressAbsentFieldsAndVarsWarnings(bool suppressAbsentFieldsAndVarsWarnings); | ||||||
|  |     int baseItemPadding() const; | ||||||
|  |     void setBaseItemPadding(int newBaseTextItemPadding); | ||||||
|  |  | ||||||
|         } | private: | ||||||
|         bool suppressAbsentFieldsAndVarsWarnings() const; |     bool m_suppressAbsentFieldsAndVarsWarnings; | ||||||
|         void setSuppressAbsentFieldsAndVarsWarnings(bool suppressAbsentFieldsAndVarsWarnings); |     int m_baseItemPadding; | ||||||
|         int baseItemPadding() const; | }; | ||||||
|         void setBaseItemPadding(int newBaseTextItemPadding); |  | ||||||
|     private: |  | ||||||
|         bool m_suppressAbsentFieldsAndVarsWarnings; |  | ||||||
|         int m_baseItemPadding; |  | ||||||
|     }; |  | ||||||
|  |  | ||||||
|     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, | ||||||
|         virtual ~IExternalPainter(); |                                         const QStyleOptionGraphicsItem* options) | ||||||
|     }; |         = 0; | ||||||
|  |     virtual ~IExternalPainter(); | ||||||
|  | }; | ||||||
|  |  | ||||||
|     class LIMEREPORT_EXPORT IPainterProxy{ | class LIMEREPORT_EXPORT IPainterProxy { | ||||||
|     public: | public: | ||||||
|         virtual void setExternalPainter(IExternalPainter* externalPainter) = 0; |     virtual void setExternalPainter(IExternalPainter* externalPainter) = 0; | ||||||
|         virtual ~IPainterProxy(); |     virtual ~IPainterProxy(); | ||||||
|     }; | }; | ||||||
|  |  | ||||||
| #if QT_VERSION < 0x050000 | #if QT_VERSION < 0x050000 | ||||||
|     typedef QStyleOptionViewItemV4 StyleOptionViewItem; | typedef QStyleOptionViewItemV4 StyleOptionViewItem; | ||||||
| #else | #else | ||||||
|     typedef QStyleOptionViewItem StyleOptionViewItem; | typedef QStyleOptionViewItem StyleOptionViewItem; | ||||||
| #endif | #endif | ||||||
| #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1) | #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1) | ||||||
|     QRegularExpression getRegEx(QString expression); | QRegularExpression getRegEx(QString expression); | ||||||
|     QRegularExpression getVariableRegEx(); | QRegularExpression getVariableRegEx(); | ||||||
|     QRegularExpression getFieldRegEx(); | QRegularExpression getFieldRegEx(); | ||||||
|     QRegularExpression getScriptRegEx(); | QRegularExpression getScriptRegEx(); | ||||||
|     QRegularExpression getGroupFunctionRegEx(QString functionName); | QRegularExpression getGroupFunctionRegEx(QString functionName); | ||||||
|     QRegularExpression getGroupFunctionNameRegEx(QString functionName); | QRegularExpression getGroupFunctionNameRegEx(QString functionName); | ||||||
|     QRegularExpression getNamedVariableRegEx(QString variableName); | QRegularExpression getNamedVariableRegEx(QString variableName); | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | class LIMEREPORT_EXPORT Enums { | ||||||
|     class LIMEREPORT_EXPORT Enums | public: | ||||||
|     { |     enum VariableDataType { | ||||||
|     public: |         Undefined, | ||||||
|         enum VariableDataType {Undefined, String, Bool, Int, Real, Date, Time, DateTime}; |         String, | ||||||
| #if QT_VERSION >= 0x050500 |         Bool, | ||||||
|         Q_ENUM(VariableDataType) |         Int, | ||||||
| #else |         Real, | ||||||
|         Q_ENUMS(VariableDataType) |         Date, | ||||||
| #endif |         Time, | ||||||
|     private: |         DateTime | ||||||
|         Enums(){} |  | ||||||
|         Q_GADGET |  | ||||||
|     }; |     }; | ||||||
|  | #if QT_VERSION >= 0x050500 | ||||||
|  |     Q_ENUM(VariableDataType) | ||||||
|  | #else | ||||||
|  |     Q_ENUMS(VariableDataType) | ||||||
|  | #endif | ||||||
|  | private: | ||||||
|  |     Enums() { } | ||||||
|  |     Q_GADGET | ||||||
|  | }; | ||||||
|  |  | ||||||
|     typedef Enums::VariableDataType VariableDataType; | typedef Enums::VariableDataType VariableDataType; | ||||||
|  |  | ||||||
| } // namespace LimeReport | } // namespace LimeReport | ||||||
|  |  | ||||||
|   | |||||||
| @@ -2,16 +2,16 @@ | |||||||
| #define LRPREPAREDPAGESINTF_H | #define LRPREPAREDPAGESINTF_H | ||||||
| #include "lrglobal.h" | #include "lrglobal.h" | ||||||
| namespace LimeReport { | namespace LimeReport { | ||||||
| class LIMEREPORT_EXPORT IPreparedPages{ | class LIMEREPORT_EXPORT IPreparedPages { | ||||||
| public: | public: | ||||||
|     virtual ~IPreparedPages(){}; |     virtual ~IPreparedPages() {}; | ||||||
|     virtual bool loadFromFile(const QString& fileName) = 0; |     virtual bool loadFromFile(const QString& fileName) = 0; | ||||||
|     virtual bool loadFromString(const QString data) = 0; |     virtual bool loadFromString(const QString data) = 0; | ||||||
|     virtual bool loadFromByteArray(QByteArray* data) = 0; |     virtual bool loadFromByteArray(QByteArray* data) = 0; | ||||||
|     virtual bool saveToFile(const QString& fileName) = 0; |     virtual bool saveToFile(const QString& fileName) = 0; | ||||||
|     virtual QString saveToString()  = 0; |     virtual QString saveToString() = 0; | ||||||
|     virtual QByteArray  saveToByteArray() = 0; |     virtual QByteArray saveToByteArray() = 0; | ||||||
|     virtual void clear() = 0; |     virtual void clear() = 0; | ||||||
| }; | }; | ||||||
| } //namespace LimeReport | } // namespace LimeReport | ||||||
| #endif // LRPREPAREDPAGESINTF_H | #endif // LRPREPAREDPAGESINTF_H | ||||||
|   | |||||||
| @@ -1,16 +1,17 @@ | |||||||
| #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 { | ||||||
| class PreviewReportWidget; |     class PreviewReportWidget; | ||||||
| } | } | ||||||
|  |  | ||||||
| class PreviewReportWidgetPrivate; | class PreviewReportWidgetPrivate; | ||||||
| @@ -18,29 +19,30 @@ 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); | ||||||
|     void setPreviewPageBackgroundColor(QColor color); |     void setPreviewPageBackgroundColor(QColor color); | ||||||
|     QColor previewPageBackgroundColor(); |     QColor previewPageBackgroundColor(); | ||||||
|     QPrinter *defaultPrinter() const; |     QPrinter* defaultPrinter() const; | ||||||
|     void setDefaultPrinter(QPrinter *defaultPrinter); |     void setDefaultPrinter(QPrinter* defaultPrinter); | ||||||
|     void startInsertTextItem(); |     void startInsertTextItem(); | ||||||
|     void activateItemSelectionMode(); |     void activateItemSelectionMode(); | ||||||
|     void deleteSelectedItems(); |     void deleteSelectedItems(); | ||||||
|     void activateCurrentPage(); |     void activateCurrentPage(); | ||||||
|     void resize(ScaleType scaleType, int percent=0); |     void resize(ScaleType scaleType, int percent = 0); | ||||||
|  |  | ||||||
| public slots: | public slots: | ||||||
|     void refreshPages(); |     void refreshPages(); | ||||||
| @@ -59,8 +61,9 @@ 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: | ||||||
|     void pageChanged(int page); |     void pageChanged(int page); | ||||||
|     void scalePercentChanged(int percent); |     void scalePercentChanged(int percent); | ||||||
| @@ -72,20 +75,22 @@ 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; | ||||||
|     ScaleType m_scaleType; |     ScaleType m_scaleType; | ||||||
|     int       m_scalePercent; |     int m_scalePercent; | ||||||
|     QTimer    m_resizeTimer; |     QTimer m_resizeTimer; | ||||||
|     QColor    m_previewPageBackgroundColor; |     QColor m_previewPageBackgroundColor; | ||||||
|     QPrinter* m_defaultPrinter; |     QPrinter* m_defaultPrinter; | ||||||
|     void printPages(QPrinter *printer); |     void printPages(QPrinter* printer); | ||||||
|     bool m_scaleChanging; |     bool m_scaleChanging; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,26 +1,28 @@ | |||||||
| #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" | ||||||
|  |  | ||||||
| namespace LimeReport{ | #include <QObject> | ||||||
|  | #include <QPrintDialog> | ||||||
|  | #include <QSettings> | ||||||
|  |  | ||||||
| class PrintRange{ | namespace LimeReport { | ||||||
|  |  | ||||||
|  | class PrintRange { | ||||||
| public: | 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, | ||||||
|     void setRangeType(QAbstractPrintDialog::PrintRange rangeType){ m_rangeType=rangeType;} |                int fromPage = 0, int toPage = 0); | ||||||
|     void setFromPage(int fromPage){ m_fromPage = fromPage;} |     void setRangeType(QAbstractPrintDialog::PrintRange rangeType) { m_rangeType = rangeType; } | ||||||
|     void setToPage(int toPage){ m_toPage = toPage;} |     void setFromPage(int fromPage) { m_fromPage = fromPage; } | ||||||
|  |     void setToPage(int toPage) { m_toPage = toPage; } | ||||||
|  |  | ||||||
| private: | private: | ||||||
|     QPrintDialog::PrintRange m_rangeType; |     QPrintDialog::PrintRange m_rangeType; | ||||||
|     int m_fromPage; |     int m_fromPage; | ||||||
| @@ -32,34 +34,36 @@ class PageDesignIntf; | |||||||
| class PageItemDesignIntf; | class PageItemDesignIntf; | ||||||
| class PreviewReportWidget; | class PreviewReportWidget; | ||||||
|  |  | ||||||
| typedef QList< QSharedPointer<PageItemDesignIntf> > ReportPages; | typedef QList<QSharedPointer<PageItemDesignIntf>> ReportPages; | ||||||
|  |  | ||||||
| class RenderEnginePrivate; | 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); | ||||||
|     ~RenderEngine(); |     ~RenderEngine(); | ||||||
|     bool    printReport(QPrinter *printer=0); |     bool printReport(QPrinter* printer = 0); | ||||||
|     bool    printPages(ReportPages pages, QPrinter *printer); |     bool printPages(ReportPages pages, QPrinter* printer); | ||||||
|     void    printToFile(const QString& fileName); |     void printToFile(const QString& fileName); | ||||||
|     PageDesignIntf *createPreviewScene(QObject *parent = 0); |     PageDesignIntf* createPreviewScene(QObject* parent = 0); | ||||||
|     bool    printToPDF(const QString& fileName); |     bool printToPDF(const QString& fileName); | ||||||
|     void    previewReport(PreviewHints hints = PreviewBarsUserSetting); |     void previewReport(PreviewHints hints = PreviewBarsUserSetting); | ||||||
|     IDataSourceManager* dataManager(); |     IDataSourceManager* dataManager(); | ||||||
|     IScriptEngineManager* scriptManager(); |     IScriptEngineManager* scriptManager(); | ||||||
|     bool    loadFromFile(const QString& fileName, bool autoLoadPreviewOnChange = false); |     bool loadFromFile(const QString& fileName, bool autoLoadPreviewOnChange = false); | ||||||
|     bool    loadFromByteArray(QByteArray *data); |     bool loadFromByteArray(QByteArray* data); | ||||||
|     bool    loadFromString(const QString& data); |     bool loadFromString(const QString& data); | ||||||
|     QString reportFileName(); |     QString reportFileName(); | ||||||
|     void    setReportFileName(const QString& fileName); |     void setReportFileName(const QString& fileName); | ||||||
|     QString lastError(); |     QString lastError(); | ||||||
|     PreviewReportWidget *createPreviewWidget(QWidget *parent = 0); |     PreviewReportWidget* createPreviewWidget(QWidget* parent = 0); | ||||||
|     void setPreviewWindowTitle(const QString& title); |     void setPreviewWindowTitle(const QString& title); | ||||||
|     void setPreviewWindowIcon(const QIcon& icon); |     void setPreviewWindowIcon(const QIcon& icon); | ||||||
|     void setResultEditable(bool value); |     void setResultEditable(bool value); | ||||||
| @@ -70,7 +74,7 @@ public: | |||||||
|     bool setReportLanguage(QLocale::Language language); |     bool setReportLanguage(QLocale::Language language); | ||||||
|     Qt::LayoutDirection previewLayoutDirection(); |     Qt::LayoutDirection previewLayoutDirection(); | ||||||
|     void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection); |     void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection); | ||||||
|     QSettings* settings(){ return m_settings;} |     QSettings* settings() { return m_settings; } | ||||||
| signals: | signals: | ||||||
|     void renderStarted(); |     void renderStarted(); | ||||||
|     void renderFinished(); |     void renderFinished(); | ||||||
| @@ -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) | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -6,9 +6,9 @@ | |||||||
|  |  | ||||||
| namespace LimeReport { | namespace LimeReport { | ||||||
|  |  | ||||||
| class ReportDesignWindowInterface: public QMainWindow{ | class ReportDesignWindowInterface: public QMainWindow { | ||||||
| public: | public: | ||||||
|     ReportDesignWindowInterface(QWidget* parent = 0): QMainWindow(parent){} |     ReportDesignWindowInterface(QWidget* parent = 0): QMainWindow(parent) { } | ||||||
|     virtual bool checkNeedToSave() = 0; |     virtual bool checkNeedToSave() = 0; | ||||||
|     virtual void showModal() = 0; |     virtual void showModal() = 0; | ||||||
|     virtual void showNonModal() = 0; |     virtual void showNonModal() = 0; | ||||||
|   | |||||||
| @@ -31,61 +31,74 @@ | |||||||
| #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; | ||||||
|  |  | ||||||
| namespace LimeReport { | namespace LimeReport { | ||||||
|  |  | ||||||
| class PrintRange{ | class PrintRange { | ||||||
| public: | 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, | ||||||
|     void setRangeType(QAbstractPrintDialog::PrintRange rangeType){ m_rangeType=rangeType;} |                int fromPage = 0, int toPage = 0); | ||||||
|     void setFromPage(int fromPage){ m_fromPage = fromPage;} |     void setRangeType(QAbstractPrintDialog::PrintRange rangeType) { m_rangeType = rangeType; } | ||||||
|     void setToPage(int toPage){ m_toPage = toPage;} |     void setFromPage(int fromPage) { m_fromPage = fromPage; } | ||||||
|  |     void setToPage(int toPage) { m_toPage = toPage; } | ||||||
|  |  | ||||||
| private: | private: | ||||||
|     QPrintDialog::PrintRange m_rangeType; |     QPrintDialog::PrintRange m_rangeType; | ||||||
|     int m_fromPage; |     int m_fromPage; | ||||||
|     int m_toPage; |     int m_toPage; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| 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(): m_x(0), m_y(0), m_width(0), m_height(0), m_type(Millimeters){} |     }; | ||||||
|  |     ItemGeometry(qreal x, qreal y, qreal width, qreal height, Qt::Alignment anchor, | ||||||
|  |                  Type type = Millimeters): | ||||||
|  |         m_x(x), | ||||||
|  |         m_y(y), | ||||||
|  |         m_width(width), | ||||||
|  |         m_height(height), | ||||||
|  |         m_type(type), | ||||||
|  |         m_anchor(anchor) | ||||||
|  |     { | ||||||
|  |     } | ||||||
|  |     ItemGeometry(): m_x(0), m_y(0), m_width(0), m_height(0), m_type(Millimeters) { } | ||||||
|  |  | ||||||
|     qreal x() const; |     qreal x() const; | ||||||
|     void setX(const qreal &x); |     void setX(const qreal& x); | ||||||
|  |  | ||||||
|     qreal y() const; |     qreal y() const; | ||||||
|     void setY(const qreal &y); |     void setY(const qreal& y); | ||||||
|  |  | ||||||
|     qreal width() const; |     qreal width() const; | ||||||
|     void setWidth(const qreal &width); |     void setWidth(const qreal& width); | ||||||
|  |  | ||||||
|     qreal height() const; |     qreal height() const; | ||||||
|     void setHeight(const qreal &height); |     void setHeight(const qreal& height); | ||||||
|  |  | ||||||
|     Type type() const; |     Type type() const; | ||||||
|     void setType(const Type &type); |     void setType(const Type& type); | ||||||
|  |  | ||||||
|     Qt::Alignment anchor() const; |     Qt::Alignment anchor() const; | ||||||
|     void setAnchor(const Qt::Alignment &anchor); |     void setAnchor(const Qt::Alignment& anchor); | ||||||
|  |  | ||||||
| private: | private: | ||||||
|     qreal m_x; |     qreal m_x; | ||||||
| @@ -96,42 +109,47 @@ private: | |||||||
|     Qt::Alignment m_anchor; |     Qt::Alignment m_anchor; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| 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), | ||||||
|     WatermarkSetting(): m_font(QFont()), m_opacity(50), m_geometry(ItemGeometry()){} |         m_font(font), | ||||||
|  |         m_opacity(50), | ||||||
|  |         m_geometry(geometry), | ||||||
|  |         m_color(QColor(Qt::black)) | ||||||
|  |     { | ||||||
|  |     } | ||||||
|  |     WatermarkSetting(): m_font(QFont()), m_opacity(50), m_geometry(ItemGeometry()) { } | ||||||
|     QString text() const; |     QString text() const; | ||||||
|     void setText(const QString &text); |     void setText(const QString& text); | ||||||
|  |  | ||||||
|     QFont font() const; |     QFont font() const; | ||||||
|     void setFont(const QFont &font); |     void setFont(const QFont& font); | ||||||
|  |  | ||||||
|     int opacity() const; |     int opacity() const; | ||||||
|     void setOpacity(const int &opacity); |     void setOpacity(const int& opacity); | ||||||
|  |  | ||||||
|     ItemGeometry geometry() const; |     ItemGeometry geometry() const; | ||||||
|     void setGeometry(const ItemGeometry &geometry); |     void setGeometry(const ItemGeometry& geometry); | ||||||
|  |  | ||||||
|     QColor color() const; |     QColor color() const; | ||||||
|     void setColor(const QColor &color); |     void setColor(const QColor& color); | ||||||
|  |  | ||||||
| private: | private: | ||||||
|     QString m_text; |     QString m_text; | ||||||
|     QFont   m_font; |     QFont m_font; | ||||||
|     int   m_opacity; |     int m_opacity; | ||||||
|     ItemGeometry m_geometry; |     ItemGeometry m_geometry; | ||||||
|     QColor m_color; |     QColor m_color; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| class ItemBuilder{ | class ItemBuilder { | ||||||
|     virtual void setProperty(QString name, QVariant value) = 0; |     virtual void setProperty(QString name, QVariant value) = 0; | ||||||
|     virtual QVariant property(QString name) = 0; |     virtual QVariant property(QString name) = 0; | ||||||
|     virtual void setGeometry(ItemGeometry geometry) = 0; |     virtual void setGeometry(ItemGeometry geometry) = 0; | ||||||
|     virtual ItemGeometry geometry() = 0; |     virtual ItemGeometry geometry() = 0; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  |  | ||||||
| class DataSourceManager; | class DataSourceManager; | ||||||
| class ReportEnginePrivate; | class ReportEnginePrivate; | ||||||
| class PageDesignIntf; | class PageDesignIntf; | ||||||
| @@ -140,47 +158,50 @@ class ReportDesignWidget; | |||||||
| class PreviewReportWidget; | class PreviewReportWidget; | ||||||
| class PreparedPages; | class PreparedPages; | ||||||
|  |  | ||||||
| typedef QList< QSharedPointer<PageItemDesignIntf> > ReportPages; | typedef QList<QSharedPointer<PageItemDesignIntf>> ReportPages; | ||||||
|  |  | ||||||
| class LIMEREPORT_EXPORT ReportEngine : public QObject{ | class LIMEREPORT_EXPORT ReportEngine: public QObject { | ||||||
|     Q_OBJECT |     Q_OBJECT | ||||||
|     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(); | ||||||
|     bool    printReport(QPrinter *printer=0); |     bool printReport(QPrinter* printer = 0); | ||||||
|     bool    printReport(QMap<QString, QPrinter*> printers, bool printToAllPrinters = false); |     bool printReport(QMap<QString, QPrinter*> printers, bool printToAllPrinters = false); | ||||||
|     bool    printPages(ReportPages pages, QPrinter *printer); |     bool printPages(ReportPages pages, QPrinter* printer); | ||||||
|     void    printToFile(const QString& fileName); |     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 = "", | ||||||
|     void    previewReport(PreviewHints hints = PreviewBarsUserSetting); |                       const QMap<QString, QVariant>& params = QMap<QString, QVariant>()); | ||||||
|     void    previewReport(QPrinter* printer, PreviewHints hints = PreviewBarsUserSetting); |     void previewReport(PreviewHints hints = PreviewBarsUserSetting); | ||||||
|     void    designReport(); |     void previewReport(QPrinter* printer, PreviewHints hints = PreviewBarsUserSetting); | ||||||
|  |     void designReport(); | ||||||
|     ReportDesignWindowInterface* getDesignerWindow(); |     ReportDesignWindowInterface* getDesignerWindow(); | ||||||
|     void    setShowProgressDialog(bool value); |     void setShowProgressDialog(bool value); | ||||||
|     bool    isShowProgressDialog(); |     bool isShowProgressDialog(); | ||||||
|     IDataSourceManager* dataManager(); |     IDataSourceManager* dataManager(); | ||||||
|     IScriptEngineManager* scriptManager(); |     IScriptEngineManager* scriptManager(); | ||||||
|     bool    loadFromFile(const QString& fileName, bool autoLoadPreviewOnChange = false); |     bool loadFromFile(const QString& fileName, bool autoLoadPreviewOnChange = false); | ||||||
|     bool    loadFromByteArray(QByteArray *data); |     bool loadFromByteArray(QByteArray* data); | ||||||
|     bool    loadFromString(const QString& data); |     bool loadFromString(const QString& data); | ||||||
|     QString reportFileName(); |     QString reportFileName(); | ||||||
|     void    setReportFileName(const QString& fileName); |     void setReportFileName(const QString& fileName); | ||||||
|     bool    saveToFile(const QString& fileName); |     bool saveToFile(const QString& fileName); | ||||||
|     QByteArray  saveToByteArray(); |     QByteArray saveToByteArray(); | ||||||
|     QString saveToString(); |     QString saveToString(); | ||||||
|     QString lastError(); |     QString lastError(); | ||||||
|     void setCurrentReportsDir(const QString& dirName); |     void setCurrentReportsDir(const QString& dirName); | ||||||
|     bool setDefaultExportDir(const QString& dirName); |     bool setDefaultExportDir(const QString& dirName); | ||||||
|     void setReportName(const QString& name); |     void setReportName(const QString& name); | ||||||
|     QString reportName(); |     QString reportName(); | ||||||
|     PreviewReportWidget *createPreviewWidget(QWidget *parent = 0); |     PreviewReportWidget* createPreviewWidget(QWidget* parent = 0); | ||||||
|     void setPreviewWindowTitle(const QString& title); |     void setPreviewWindowTitle(const QString& title); | ||||||
|     void setPreviewWindowIcon(const QIcon& icon); |     void setPreviewWindowIcon(const QIcon& icon); | ||||||
|     void setPreviewPageBackgroundColor(QColor color); |     void setPreviewPageBackgroundColor(QColor color); | ||||||
| @@ -201,8 +222,8 @@ public: | |||||||
|     QList<QLocale::Language> designerLanguages(); |     QList<QLocale::Language> designerLanguages(); | ||||||
|     QLocale::Language currentDesignerLanguage(); |     QLocale::Language currentDesignerLanguage(); | ||||||
|     ScaleType previewScaleType(); |     ScaleType previewScaleType(); | ||||||
|     int  previewScalePercent(); |     int previewScalePercent(); | ||||||
|     void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0); |     void setPreviewScaleType(const ScaleType& previewScaleType, int percent = 0); | ||||||
|     void addWatermark(const WatermarkSetting& watermarkSetting); |     void addWatermark(const WatermarkSetting& watermarkSetting); | ||||||
|     void clearWatermarks(); |     void clearWatermarks(); | ||||||
|     IPreparedPages* preparedPages(); |     IPreparedPages* preparedPages(); | ||||||
| @@ -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; | ||||||
|   | |||||||
| @@ -32,15 +32,15 @@ | |||||||
| #include "qglobal.h" | #include "qglobal.h" | ||||||
|  |  | ||||||
| #if QT_VERSION >= 0x050600 | #if QT_VERSION >= 0x050600 | ||||||
|     #ifndef USE_QTSCRIPTENGINE | #ifndef USE_QTSCRIPTENGINE | ||||||
|         #ifndef USE_QJSENGINE | #ifndef USE_QJSENGINE | ||||||
|             #define USE_QJSENGINE | #define USE_QJSENGINE | ||||||
|         #endif | #endif | ||||||
|     #endif | #endif | ||||||
| #else | #else | ||||||
|     #ifndef USE_QTSCRIPTENGINE | #ifndef USE_QTSCRIPTENGINE | ||||||
|         #define USE_QTSCRIPTENGINE | #define USE_QTSCRIPTENGINE | ||||||
|     #endif | #endif | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #ifdef USE_QJSENGINE | #ifdef USE_QJSENGINE | ||||||
| @@ -49,38 +49,38 @@ | |||||||
| #include <QtScript/QScriptEngine> | #include <QtScript/QScriptEngine> | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| namespace LimeReport{ | 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); |     return res; | ||||||
|         return res; | } | ||||||
|     } |  | ||||||
| #else | #else | ||||||
|     typedef QScriptEngine ScriptEngineType; | typedef QScriptEngine ScriptEngineType; | ||||||
|     typedef QScriptValue ScriptValueType; | typedef QScriptValue ScriptValueType; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| class IScriptEngineManager{ | class IScriptEngineManager { | ||||||
| public: | 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 | ||||||
|  |  | ||||||
| #endif // LRSCRIPTENGINEMANAGERINTF_H | #endif // LRSCRIPTENGINEMANAGERINTF_H | ||||||
|   | |||||||
| @@ -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" | ||||||
|  |  | ||||||
| @@ -35,56 +36,51 @@ const QString xmlTag = "Data"; | |||||||
| const QString xmlTagHeader = "DataHeader"; | const QString xmlTagHeader = "DataHeader"; | ||||||
| const QString xmlTagFooter = "DataFooter"; | 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( | ||||||
|     ); |         xmlTagHeader, | ||||||
| bool VARIABLE_IS_NOT_USED registredHeader = LimeReport::DesignElementsFactory::instance().registerCreator( |         LimeReport::ItemAttribs(QObject::tr("DataHeader"), LimeReport::Const::bandTAG), | ||||||
|             xmlTagHeader, |         createHeader); | ||||||
|             LimeReport::ItemAttribs(QObject::tr("DataHeader"),LimeReport::Const::bandTAG), | bool VARIABLE_IS_NOT_USED registredFooter | ||||||
|             createHeader |     = LimeReport::DesignElementsFactory::instance().registerCreator( | ||||||
|         ); |         xmlTagFooter, | ||||||
| bool VARIABLE_IS_NOT_USED registredFooter = LimeReport::DesignElementsFactory::instance().registerCreator( |         LimeReport::ItemAttribs(QObject::tr("DataFooter"), LimeReport::Const::bandTAG), | ||||||
|             xmlTagFooter, |         createFooter); | ||||||
|             LimeReport::ItemAttribs(QObject::tr("DataFooter"),LimeReport::Const::bandTAG), |  | ||||||
|             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")); |  | ||||||
|         setFixedPos(false); |  | ||||||
|         setMarkerColor(bandColor()); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| bool DataBand::isUnique() const |  | ||||||
| { | { | ||||||
|     return false; |     setBandTypeText(tr("Data")); | ||||||
|  |     setFixedPos(false); | ||||||
|  |     setMarkerColor(bandColor()); | ||||||
| } | } | ||||||
|  |  | ||||||
| QColor DataBand::bandColor() const | bool DataBand::isUnique() const { return false; } | ||||||
| { |  | ||||||
|     return QColor(Qt::darkGreen); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void DataBand::preparePopUpMenu(QMenu &menu) | QColor DataBand::bandColor() const { return QColor(Qt::darkGreen); } | ||||||
|  |  | ||||||
|  | void DataBand::preparePopUpMenu(QMenu& menu) | ||||||
| { | { | ||||||
|     BandDesignIntf::preparePopUpMenu(menu); |     BandDesignIntf::preparePopUpMenu(menu); | ||||||
|  |  | ||||||
| @@ -111,52 +107,49 @@ 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) | ||||||
| { | { | ||||||
|     BandDesignIntf::processPopUpAction(action); |     BandDesignIntf::processPopUpAction(action); | ||||||
|     if (action->text().compare(tr("Keep footer together")) == 0){ |     if (action->text().compare(tr("Keep footer together")) == 0) { | ||||||
|         setProperty("keepFooterTogether",action->isChecked()); |         setProperty("keepFooterTogether", action->isChecked()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (action->text().compare(tr("Keep subdetail together")) == 0){ |     if (action->text().compare(tr("Keep subdetail together")) == 0) { | ||||||
|         setProperty("keepSubdetailTogether",action->isChecked()); |         setProperty("keepSubdetailTogether", action->isChecked()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (action->text().compare(tr("Slice last row")) == 0){ |     if (action->text().compare(tr("Slice last row")) == 0) { | ||||||
|         setProperty("sliceLastRow",action->isChecked()); |         setProperty("sliceLastRow", action->isChecked()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (action->text().compare(tr("Use alternate background color")) == 0){ |     if (action->text().compare(tr("Use alternate background color")) == 0) { | ||||||
|         setProperty("useAlternateBackgroundColor",action->isChecked()); |         setProperty("useAlternateBackgroundColor", action->isChecked()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (action->text().compare(tr("Start new page")) == 0){ |     if (action->text().compare(tr("Start new page")) == 0) { | ||||||
|         setProperty("startNewPage",action->isChecked()); |         setProperty("startNewPage", action->isChecked()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (action->text().compare(tr("Start from new page")) == 0){ |     if (action->text().compare(tr("Start from new page")) == 0) { | ||||||
|         setProperty("startFromNewPage",action->isChecked()); |         setProperty("startFromNewPage", action->isChecked()); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| BaseDesignIntf *DataBand::createSameTypeItem(QObject *owner, QGraphicsItem *parent) | BaseDesignIntf* DataBand::createSameTypeItem(QObject* owner, QGraphicsItem* parent) | ||||||
| { | { | ||||||
|     return new DataBand(owner,parent); |     return new DataBand(owner, parent); | ||||||
| } | } | ||||||
|  |  | ||||||
| DataHeaderBand::DataHeaderBand(QObject *owner, QGraphicsItem *parent) | 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()); | ||||||
| } | } | ||||||
|  |  | ||||||
| void DataHeaderBand::preparePopUpMenu(QMenu &menu) | void DataHeaderBand::preparePopUpMenu(QMenu& menu) | ||||||
| { | { | ||||||
|     BandDesignIntf::preparePopUpMenu(menu); |     BandDesignIntf::preparePopUpMenu(menu); | ||||||
|     QAction* currAction = menu.addAction(tr("Reprint on each page")); |     QAction* currAction = menu.addAction(tr("Reprint on each page")); | ||||||
| @@ -172,30 +165,30 @@ void DataHeaderBand::preparePopUpMenu(QMenu &menu) | |||||||
|     currAction->setChecked(printAlways()); |     currAction->setChecked(printAlways()); | ||||||
| } | } | ||||||
|  |  | ||||||
| void DataHeaderBand::processPopUpAction(QAction *action) | void DataHeaderBand::processPopUpAction(QAction* action) | ||||||
| { | { | ||||||
|     BandDesignIntf::processPopUpAction(action); |     BandDesignIntf::processPopUpAction(action); | ||||||
|     if (action->text().compare(tr("Reprint on each page")) == 0){ |     if (action->text().compare(tr("Reprint on each page")) == 0) { | ||||||
|         setProperty("reprintOnEachPage",action->isChecked()); |         setProperty("reprintOnEachPage", action->isChecked()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (action->text().compare(tr("Repeat on each row")) == 0){ |     if (action->text().compare(tr("Repeat on each row")) == 0) { | ||||||
|         setProperty("repeatOnEachRow",action->isChecked()); |         setProperty("repeatOnEachRow", action->isChecked()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (action->text().compare(tr("Print always")) == 0){ |     if (action->text().compare(tr("Print always")) == 0) { | ||||||
|         setProperty("printAlways",action->isChecked()); |         setProperty("printAlways", action->isChecked()); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| 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()); | ||||||
| } | } | ||||||
|  |  | ||||||
| void DataFooterBand::preparePopUpMenu(QMenu &menu) | void DataFooterBand::preparePopUpMenu(QMenu& menu) | ||||||
| { | { | ||||||
|     BandDesignIntf::preparePopUpMenu(menu); |     BandDesignIntf::preparePopUpMenu(menu); | ||||||
|     QAction* currAction = menu.addAction(tr("Print always")); |     QAction* currAction = menu.addAction(tr("Print always")); | ||||||
| @@ -203,13 +196,12 @@ void DataFooterBand::preparePopUpMenu(QMenu &menu) | |||||||
|     currAction->setChecked(printAlways()); |     currAction->setChecked(printAlways()); | ||||||
| } | } | ||||||
|  |  | ||||||
| void DataFooterBand::processPopUpAction(QAction *action) | void DataFooterBand::processPopUpAction(QAction* action) | ||||||
| { | { | ||||||
|     BandDesignIntf::processPopUpAction(action); |     BandDesignIntf::processPopUpAction(action); | ||||||
|     if (action->text().compare(tr("Print always")) == 0){ |     if (action->text().compare(tr("Print always")) == 0) { | ||||||
|         setProperty("printAlways",action->isChecked()); |         setProperty("printAlways", action->isChecked()); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| } | } // namespace LimeReport | ||||||
|  |  | ||||||
|   | |||||||
| @@ -32,77 +32,88 @@ | |||||||
|  |  | ||||||
| #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: | ||||||
|     DataHeaderBand(QObject* owner=0, QGraphicsItem* parent=0); |     DataHeaderBand(QObject* owner = 0, QGraphicsItem* parent = 0); | ||||||
|     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 | ||||||
|   | |||||||
| @@ -28,131 +28,130 @@ | |||||||
|  *   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 | ||||||
|        xmlTagHeader, |     = LimeReport::DesignElementsFactory::instance().registerCreator( | ||||||
|         LimeReport::ItemAttribs(QObject::tr("GroupHeader"),LimeReport::Const::bandTAG), |         xmlTagHeader, | ||||||
|         createHeader |         LimeReport::ItemAttribs(QObject::tr("GroupHeader"), LimeReport::Const::bandTAG), | ||||||
|     ); |         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() | ||||||
| //{ | //{ | ||||||
| //    return m_tryToKeepTogether; | //    return m_tryToKeepTogether; | ||||||
| //} | //} | ||||||
|  |  | ||||||
| BaseDesignIntf *GroupBandHeader::createSameTypeItem(QObject *owner, QGraphicsItem *parent) | BaseDesignIntf* GroupBandHeader::createSameTypeItem(QObject* owner, QGraphicsItem* parent) | ||||||
| { | { | ||||||
|     return new GroupBandHeader(owner, parent); |     return new GroupBandHeader(owner, parent); | ||||||
| } | } | ||||||
|  |  | ||||||
| void GroupBandHeader::startGroup(DataSourceManager* dataManager) | void GroupBandHeader::startGroup(DataSourceManager* dataManager) | ||||||
| { | { | ||||||
|     m_groupStarted=true; |     m_groupStarted = true; | ||||||
|  |  | ||||||
|     QString lineVar = QLatin1String("line_")+objectName().toLower(); |     QString lineVar = QLatin1String("line_") + objectName().toLower(); | ||||||
|     dataManager->setReportVariable(lineVar,1); |     dataManager->setReportVariable(lineVar, 1); | ||||||
|  |  | ||||||
|     QString datasourceName = findDataSourceName(parentBand()); |     QString datasourceName = findDataSourceName(parentBand()); | ||||||
|     if (dataManager->containsDatasource(datasourceName)){ |     if (dataManager->containsDatasource(datasourceName)) { | ||||||
|         IDataSource* ds = dataManager->dataSource(datasourceName); |         IDataSource* ds = dataManager->dataSource(datasourceName); | ||||||
|         if (ds && ds->columnIndexByName(m_groupFiledName)!=-1) |         if (ds && ds->columnIndexByName(m_groupFiledName) != -1) | ||||||
|             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); | ||||||
|         result=expandScripts(result, dataManager); |         result = expandScripts(result, dataManager); | ||||||
|         result=expandDataFields(result, NoEscapeSymbols, dataManager); |         result = expandDataFields(result, NoEscapeSymbols, dataManager); | ||||||
|     } |     } | ||||||
|     return result; |     return result; | ||||||
| } | } | ||||||
|  |  | ||||||
| bool GroupBandHeader::isNeedToClose(DataSourceManager* dataManager) | bool GroupBandHeader::isNeedToClose(DataSourceManager* dataManager) | ||||||
| { | { | ||||||
|     if (!m_groupStarted) return false; |     if (!m_groupStarted) | ||||||
|     if ((m_groupFiledName.isNull() || m_groupFiledName.isEmpty()) && condition().isEmpty()){ |         return false; | ||||||
|  |     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; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (!m_condition.isEmpty()){ |     if (!m_condition.isEmpty()) { | ||||||
|         return m_conditionValue != calcCondition(dataManager); |         return m_conditionValue != calcCondition(dataManager); | ||||||
|     } else { |     } else { | ||||||
|         QString datasourceName = findDataSourceName(parentBand()); |         QString datasourceName = findDataSourceName(parentBand()); | ||||||
|         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; | ||||||
|                 return ds->data(m_groupFiledName)!=m_groupFieldValue; |                 if (!ds->data(m_groupFiledName).isValid()) | ||||||
|  |                     return false; | ||||||
|  |                 return ds->data(m_groupFiledName) != m_groupFieldValue; | ||||||
|             } |             } | ||||||
|         } else { |         } else { | ||||||
|             dataManager->putError(tr("Datasource \"%1\" not found!").arg(datasourceName)); |             dataManager->putError(tr("Datasource \"%1\" not found!").arg(datasourceName)); | ||||||
| @@ -164,62 +163,47 @@ bool GroupBandHeader::isNeedToClose(DataSourceManager* dataManager) | |||||||
|  |  | ||||||
| bool GroupBandHeader::isStarted() | bool GroupBandHeader::isStarted() | ||||||
| { | { | ||||||
|     return m_groupStarted;//!m_groupFieldValue.isNull(); |     return m_groupStarted; //! m_groupFieldValue.isNull(); | ||||||
| } | } | ||||||
|  |  | ||||||
| void GroupBandHeader::closeGroup() | void GroupBandHeader::closeGroup() | ||||||
| { | { | ||||||
|     m_groupFieldValue=QVariant(); |     m_groupFieldValue = QVariant(); | ||||||
|     m_conditionValue=""; |     m_conditionValue = ""; | ||||||
|     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; } | ||||||
|  |  | ||||||
|  | QColor GroupBandFooter::bandColor() const { return QColor(Qt::darkBlue); } | ||||||
|  |  | ||||||
|  | BaseDesignIntf* GroupBandFooter::createSameTypeItem(QObject* owner, QGraphicsItem* parent) | ||||||
| { | { | ||||||
|     return false; |     return new GroupBandFooter(owner, parent); | ||||||
| } | } | ||||||
|  |  | ||||||
| QColor GroupBandFooter::bandColor() const | } // namespace LimeReport | ||||||
| { |  | ||||||
|     return QColor(Qt::darkBlue); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| BaseDesignIntf *GroupBandFooter::createSameTypeItem(QObject *owner, QGraphicsItem *parent) |  | ||||||
| { |  | ||||||
|     return new GroupBandFooter(owner,parent); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| } //namespace LimeReport |  | ||||||
|   | |||||||
| @@ -33,61 +33,64 @@ | |||||||
| #include "lrbanddesignintf.h" | #include "lrbanddesignintf.h" | ||||||
| #include "lrdesignelementsfactory.h" | #include "lrdesignelementsfactory.h" | ||||||
|  |  | ||||||
| namespace LimeReport{ | namespace LimeReport { | ||||||
|  |  | ||||||
| class GroupBandHeader : public BandDesignIntf, public IGroupBand{ | class GroupBandHeader: public BandDesignIntf, public IGroupBand { | ||||||
|     Q_OBJECT |     Q_OBJECT | ||||||
|     Q_PROPERTY(QString groupFieldName READ groupFieldName WRITE setGroupFieldName) |     Q_PROPERTY(QString groupFieldName READ groupFieldName WRITE setGroupFieldName) | ||||||
|     Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable ) |     Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable) | ||||||
|     Q_PROPERTY(bool keepGroupTogether READ tryToKeepTogether WRITE setTryToKeepTogether) |     Q_PROPERTY(bool keepGroupTogether READ tryToKeepTogether WRITE setTryToKeepTogether) | ||||||
|     Q_PROPERTY(bool startNewPage READ startNewPage WRITE setStartNewPage) |     Q_PROPERTY(bool startNewPage READ startNewPage WRITE setStartNewPage) | ||||||
|     Q_PROPERTY(bool resetPageNumber READ resetPageNumber WRITE setResetPageNumber) |     Q_PROPERTY(bool resetPageNumber READ resetPageNumber WRITE setResetPageNumber) | ||||||
|     Q_PROPERTY(bool reprintOnEachPage READ reprintOnEachPage WRITE setReprintOnEachPage) |     Q_PROPERTY(bool reprintOnEachPage READ reprintOnEachPage WRITE setReprintOnEachPage) | ||||||
|     Q_PROPERTY(QString condition READ condition WRITE setCondition) |     Q_PROPERTY(QString condition READ condition WRITE setCondition) | ||||||
| public: | public: | ||||||
|     GroupBandHeader(QObject* owner = 0, QGraphicsItem* parent=0); |     GroupBandHeader(QObject* owner = 0, QGraphicsItem* parent = 0); | ||||||
|     virtual bool isUnique() const; |     virtual bool isUnique() const; | ||||||
|     QVariant groupFieldValue(){return m_groupFieldValue;} |     QVariant groupFieldValue() { return m_groupFieldValue; } | ||||||
|     void setGroupFieldValue(QVariant value){m_groupFieldValue=value;} |     void setGroupFieldValue(QVariant value) { m_groupFieldValue = value; } | ||||||
|     QString groupFieldName(){return m_groupFiledName;} |     QString groupFieldName() { return m_groupFiledName; } | ||||||
|     void setGroupFieldName(QString fieldName){m_groupFiledName=fieldName;} |     void setGroupFieldName(QString fieldName) { m_groupFiledName = fieldName; } | ||||||
|     QColor bandColor() const; |     QColor bandColor() const; | ||||||
|     bool startNewPage() const; |     bool startNewPage() const; | ||||||
|     void setStartNewPage(bool startNewPage); |     void setStartNewPage(bool startNewPage); | ||||||
|     bool resetPageNumber() const; |     bool resetPageNumber() const; | ||||||
|     void setResetPageNumber(bool resetPageNumber); |     void setResetPageNumber(bool resetPageNumber); | ||||||
|     bool isHeader() const{return true;} |     bool isHeader() const { return true; } | ||||||
|     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); | ||||||
|     bool isNeedToClose(DataSourceManager *dataManager); |     bool isNeedToClose(DataSourceManager* dataManager); | ||||||
|     bool isStarted(); |     bool isStarted(); | ||||||
|     void closeGroup(); |     void closeGroup(); | ||||||
|     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; | ||||||
|     bool m_groupStarted; |     bool m_groupStarted; | ||||||
|     //bool m_startNewPage; |     // bool m_startNewPage; | ||||||
|     bool m_resetPageNumber; |     bool m_resetPageNumber; | ||||||
|     QString m_condition; |     QString m_condition; | ||||||
|     QString m_conditionValue; |     QString m_conditionValue; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| class GroupBandFooter : public BandDesignIntf{ | class GroupBandFooter: public BandDesignIntf { | ||||||
|     Q_OBJECT |     Q_OBJECT | ||||||
| public: | public: | ||||||
|     GroupBandFooter(QObject* owner = 0, QGraphicsItem* parent=0); |     GroupBandFooter(QObject* owner = 0, QGraphicsItem* parent = 0); | ||||||
|     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); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| } // namespace LimeReport | } // namespace LimeReport | ||||||
|   | |||||||
| @@ -28,46 +28,45 @@ | |||||||
|  *   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" | ||||||
|  |  | ||||||
| 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()); | ||||||
|         setAutoHeight(false); |     setAutoHeight(false); | ||||||
| } | } | ||||||
|  |  | ||||||
| BaseDesignIntf *PageFooter::createSameTypeItem(QObject *owner, QGraphicsItem *parent) | BaseDesignIntf* PageFooter::createSameTypeItem(QObject* owner, QGraphicsItem* parent) | ||||||
| { | { | ||||||
|     return new PageFooter(owner,parent); |     return new PageFooter(owner, parent); | ||||||
| } | } | ||||||
|  |  | ||||||
| QColor PageFooter::bandColor() const | QColor PageFooter::bandColor() const { return QColor(246, 120, 12); } | ||||||
| { |  | ||||||
|     return QColor(246,120,12); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void PageFooter::preparePopUpMenu(QMenu &menu) | void PageFooter::preparePopUpMenu(QMenu& menu) | ||||||
| { | { | ||||||
|     QAction* action = menu.addAction(tr("Print on first page")); |     QAction* action = menu.addAction(tr("Print on first page")); | ||||||
|     action->setCheckable(true); |     action->setCheckable(true); | ||||||
| @@ -76,57 +75,44 @@ 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) | ||||||
| { | { | ||||||
|     if (action->text().compare(tr("Print on first page")) == 0){ |     if (action->text().compare(tr("Print on first page")) == 0) { | ||||||
|         page()->setPropertyToSelectedItems("printOnFirstPage",action->isChecked()); |         page()->setPropertyToSelectedItems("printOnFirstPage", action->isChecked()); | ||||||
|     } |     } | ||||||
|     if (action->text().compare(tr("Print on last page")) == 0){ |     if (action->text().compare(tr("Print on last page")) == 0) { | ||||||
|         page()->setPropertyToSelectedItems("printOnLastPage",action->isChecked()); |         page()->setPropertyToSelectedItems("printOnLastPage", action->isChecked()); | ||||||
|     } |     } | ||||||
|     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) | ||||||
| { | { | ||||||
|     if (m_printOnFirstPage != printOnFirstPage){ |     if (m_printOnFirstPage != printOnFirstPage) { | ||||||
|         bool oldValue = m_printOnFirstPage; |         bool oldValue = m_printOnFirstPage; | ||||||
|         m_printOnFirstPage = printOnFirstPage; |         m_printOnFirstPage = printOnFirstPage; | ||||||
|         update(); |         update(); | ||||||
|         notify("printOnFirstPage",oldValue,printOnFirstPage); |         notify("printOnFirstPage", oldValue, 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) | ||||||
| { | { | ||||||
|     if (m_printOnLastPage != printOnLastPage){ |     if (m_printOnLastPage != printOnLastPage) { | ||||||
|         bool oldValue = m_printOnLastPage; |         bool oldValue = m_printOnLastPage; | ||||||
|         m_printOnLastPage = printOnLastPage; |         m_printOnLastPage = printOnLastPage; | ||||||
|         update(); |         update(); | ||||||
|         notify("printOnLastPage",oldValue,printOnLastPage); |         notify("printOnLastPage", oldValue, printOnLastPage); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -32,19 +32,19 @@ | |||||||
|  |  | ||||||
| #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) | ||||||
|     Q_PROPERTY(bool removeGap READ removeGap WRITE setRemoveGap) |     Q_PROPERTY(bool removeGap READ removeGap WRITE setRemoveGap) | ||||||
| public: | public: | ||||||
|     PageFooter(QObject* owner = 0, QGraphicsItem* parent=0); |     PageFooter(QObject* owner = 0, QGraphicsItem* parent = 0); | ||||||
|     virtual BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0); |     virtual BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0); | ||||||
|     virtual bool isFooter() const {return true;} |     virtual bool isFooter() const { return true; } | ||||||
|     bool printOnLastPage() const; |     bool printOnLastPage() const; | ||||||
|     void setPrintOnLastPage(bool printOnLastPage); |     void setPrintOnLastPage(bool printOnLastPage); | ||||||
|     bool printOnFirstPage() const; |     bool printOnFirstPage() const; | ||||||
| @@ -53,14 +53,15 @@ public: | |||||||
|     void setRemoveGap(bool removeGap); |     void setRemoveGap(bool removeGap); | ||||||
|  |  | ||||||
| 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: | ||||||
|     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 | ||||||
|   | |||||||
| @@ -28,64 +28,54 @@ | |||||||
|  *   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()); | ||||||
| } | } | ||||||
|  |  | ||||||
| BaseDesignIntf *PageHeader::createSameTypeItem(QObject *owner, QGraphicsItem *parent) | BaseDesignIntf* PageHeader::createSameTypeItem(QObject* owner, QGraphicsItem* parent) | ||||||
| { | { | ||||||
|     return new PageHeader(owner,parent); |     return new PageHeader(owner, parent); | ||||||
| } | } | ||||||
|  |  | ||||||
| QColor PageHeader::bandColor() const | 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 | ||||||
|   | |||||||
| @@ -30,29 +30,31 @@ | |||||||
| #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) | ||||||
| public: | public: | ||||||
|     PageHeader(QObject* owner = 0, QGraphicsItem* parent=0); |     PageHeader(QObject* owner = 0, QGraphicsItem* parent = 0); | ||||||
|     bool printOnFirstPage() const; |     bool printOnFirstPage() const; | ||||||
|     void setPrintOnFirstPage(bool printOnFirstPage); |     void setPrintOnFirstPage(bool printOnFirstPage); | ||||||
|     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 | ||||||
|   | |||||||
| @@ -28,44 +28,39 @@ | |||||||
|  *   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" | ||||||
|  |  | ||||||
| const QString xmlTag ="ReportFooter"; | 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()); | ||||||
| } | } | ||||||
|  |  | ||||||
| BaseDesignIntf *ReportFooter::createSameTypeItem(QObject *owner, QGraphicsItem *parent) | BaseDesignIntf* ReportFooter::createSameTypeItem(QObject* owner, QGraphicsItem* parent) | ||||||
| { | { | ||||||
|     return new ReportFooter(owner,parent); |     return new ReportFooter(owner, parent); | ||||||
| } | } | ||||||
|  |  | ||||||
| QColor ReportFooter::bandColor() const | 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 | ||||||
|   | |||||||
| @@ -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" | ||||||
|  |  | ||||||
| namespace LimeReport{ | #include <QObject> | ||||||
| class ReportFooter : public BandDesignIntf |  | ||||||
| { | namespace LimeReport { | ||||||
|  | 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 | ||||||
|   | |||||||
| @@ -28,50 +28,45 @@ | |||||||
|  *   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), | ||||||
|         setBandTypeText(tr("Report Header")); |     m_printBeforePageHeader(false) | ||||||
|         setMarkerColor(bandColor()); |  | ||||||
| } |  | ||||||
| BaseDesignIntf *ReportHeader::createSameTypeItem(QObject *owner, QGraphicsItem *parent) |  | ||||||
| { | { | ||||||
|     return new ReportHeader(owner,parent); |     setBandTypeText(tr("Report Header")); | ||||||
|  |     setMarkerColor(bandColor()); | ||||||
|  | } | ||||||
|  | BaseDesignIntf* ReportHeader::createSameTypeItem(QObject* owner, QGraphicsItem* 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) | ||||||
| { | { | ||||||
|     if (m_printBeforePageHeader != printBeforePageHeader){ |     if (m_printBeforePageHeader != printBeforePageHeader) { | ||||||
|         m_printBeforePageHeader = printBeforePageHeader; |         m_printBeforePageHeader = printBeforePageHeader; | ||||||
|         notify("printBeforePageHeader",!m_printBeforePageHeader,m_printBeforePageHeader); |         notify("printBeforePageHeader", !m_printBeforePageHeader, m_printBeforePageHeader); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| } | } // namespace LimeReport | ||||||
|  |  | ||||||
|   | |||||||
| @@ -30,25 +30,26 @@ | |||||||
| #ifndef LRREPORTHEADER_H | #ifndef LRREPORTHEADER_H | ||||||
| #define LRREPORTHEADER_H | #define LRREPORTHEADER_H | ||||||
|  |  | ||||||
| #include <QObject> |  | ||||||
| #include "lrbanddesignintf.h" | #include "lrbanddesignintf.h" | ||||||
| #include "lrbasedesignintf.h" | #include "lrbasedesignintf.h" | ||||||
|  |  | ||||||
| namespace LimeReport{ | #include <QObject> | ||||||
| class ReportHeader : public LimeReport::BandDesignIntf |  | ||||||
| { | namespace LimeReport { | ||||||
|  | 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) | ||||||
| public: | public: | ||||||
|     ReportHeader(QObject* owner = 0, QGraphicsItem *parent=0); |     ReportHeader(QObject* owner = 0, QGraphicsItem* parent = 0); | ||||||
|     virtual BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0); |     virtual BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0); | ||||||
|     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 | ||||||
|   | |||||||
| @@ -28,55 +28,56 @@ | |||||||
|  *   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"); | ||||||
| const QColor BAND_COLOR = Qt::red; | 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 | ||||||
|        xmlTagHeader, |     = LimeReport::DesignElementsFactory::instance().registerCreator( | ||||||
|         LimeReport::ItemAttribs(QObject::tr("SubDetailHeader"),LimeReport::Const::bandTAG), |         xmlTagHeader, | ||||||
|         createHeader |         LimeReport::ItemAttribs(QObject::tr("SubDetailHeader"), LimeReport::Const::bandTAG), | ||||||
|     ); |         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 | ||||||
|  |  | ||||||
| namespace LimeReport{ | 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); | ||||||
| @@ -93,62 +94,46 @@ bool SubDetailBand::isHasFooter() const | |||||||
|     return isConnectedToBand(BandDesignIntf::SubDetailFooter); |     return isConnectedToBand(BandDesignIntf::SubDetailFooter); | ||||||
| } | } | ||||||
|  |  | ||||||
| BaseDesignIntf *SubDetailBand::createSameTypeItem(QObject *owner, QGraphicsItem *parent) | BaseDesignIntf* SubDetailBand::createSameTypeItem(QObject* owner, QGraphicsItem* parent) | ||||||
| { | { | ||||||
|     return new SubDetailBand(owner,parent); |     return new SubDetailBand(owner, parent); | ||||||
| } | } | ||||||
|  |  | ||||||
| QColor SubDetailBand::bandColor() const | 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; } | ||||||
|  |  | ||||||
|  | QColor SubDetailHeaderBand::bandColor() const { return BAND_COLOR; } | ||||||
|  |  | ||||||
|  | BaseDesignIntf* SubDetailHeaderBand::createSameTypeItem(QObject* owner, QGraphicsItem* parent) | ||||||
| { | { | ||||||
|     return false; |     return new SubDetailHeaderBand(owner, parent); | ||||||
| } | } | ||||||
|  |  | ||||||
| QColor SubDetailHeaderBand::bandColor() const | // SubDetailFooterBand | ||||||
| { |  | ||||||
|     return BAND_COLOR; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| BaseDesignIntf *SubDetailHeaderBand::createSameTypeItem(QObject *owner, QGraphicsItem *parent) | SubDetailFooterBand::SubDetailFooterBand(QObject* owner, QGraphicsItem* parent): | ||||||
| { |     BandDesignIntf(BandDesignIntf::SubDetailFooter, xmlTagFooter, owner, parent) | ||||||
|     return new SubDetailHeaderBand(owner,parent); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| //SubDetailFooterBand |  | ||||||
|  |  | ||||||
| SubDetailFooterBand::SubDetailFooterBand(QObject *owner, QGraphicsItem *parent) |  | ||||||
|     : BandDesignIntf(BandDesignIntf::SubDetailFooter,xmlTagFooter,owner,parent) |  | ||||||
| { | { | ||||||
|     setMarkerColor(bandColor()); |     setMarkerColor(bandColor()); | ||||||
| } | } | ||||||
|  |  | ||||||
| bool SubDetailFooterBand::isUnique() const | bool SubDetailFooterBand::isUnique() const { return false; } | ||||||
|  |  | ||||||
|  | QColor SubDetailFooterBand::bandColor() const { return BAND_COLOR; } | ||||||
|  |  | ||||||
|  | BaseDesignIntf* SubDetailFooterBand::createSameTypeItem(QObject* owner, QGraphicsItem* parent) | ||||||
| { | { | ||||||
|     return false; |     return new SubDetailFooterBand(owner, parent); | ||||||
| } | } | ||||||
|  |  | ||||||
| QColor SubDetailFooterBand::bandColor() const | } // namespace LimeReport | ||||||
| { |  | ||||||
|     return BAND_COLOR; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| BaseDesignIntf *SubDetailFooterBand::createSameTypeItem(QObject *owner, QGraphicsItem *parent) |  | ||||||
| { |  | ||||||
|     return new SubDetailFooterBand(owner,parent); |  | ||||||
| } |  | ||||||
|  |  | ||||||
|  |  | ||||||
| } |  | ||||||
|   | |||||||
| @@ -33,64 +33,73 @@ | |||||||
| #include "lrbanddesignintf.h" | #include "lrbanddesignintf.h" | ||||||
| #include "lrbasedesignintf.h" | #include "lrbasedesignintf.h" | ||||||
|  |  | ||||||
| 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 | ||||||
|   | |||||||
| @@ -1,37 +1,34 @@ | |||||||
| #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()); | ||||||
| } | } | ||||||
|  |  | ||||||
| BaseDesignIntf *TearOffBand::createSameTypeItem(QObject *owner, QGraphicsItem *parent) | BaseDesignIntf* TearOffBand::createSameTypeItem(QObject* owner, QGraphicsItem* parent) | ||||||
| { | { | ||||||
|     return new TearOffBand(owner,parent); |     return new TearOffBand(owner, parent); | ||||||
| } | } | ||||||
|  |  | ||||||
| QColor TearOffBand::bandColor() const | QColor TearOffBand::bandColor() const { return QColor(200, 200, 200); } | ||||||
| { |  | ||||||
|     return QColor(200,200,200); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| } // namedpace LimeReport | } // namespace LimeReport | ||||||
|   | |||||||
| @@ -4,16 +4,16 @@ | |||||||
|  |  | ||||||
| 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; } | ||||||
|     bool isFooter() const{ return true;} |     bool isFooter() const { return true; } | ||||||
| }; | }; | ||||||
|  |  | ||||||
| } // namespace LimeReport | } // namespace LimeReport | ||||||
|   | |||||||
| @@ -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> | ||||||
|  |  | ||||||
| namespace LimeReport{ | #include <stdexcept> | ||||||
|  |  | ||||||
| template | namespace LimeReport { | ||||||
| < |  | ||||||
|     typename AbstractProduct, | template <typename AbstractProduct, typename IdentifierType, typename ProductCreator, | ||||||
|     typename IdentifierType, |           typename Attribs> | ||||||
|     typename ProductCreator, | class AttribsAbstractFactory: | ||||||
|     typename Attribs |     public Singleton< | ||||||
| > |         AttribsAbstractFactory<AbstractProduct, IdentifierType, ProductCreator, 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 | ||||||
|   | |||||||
| @@ -30,74 +30,76 @@ | |||||||
| #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> | ||||||
| namespace LimeReport{ |  | ||||||
|  |  | ||||||
| template | #include <stdexcept> | ||||||
| < | namespace LimeReport { | ||||||
|     typename AbstractProduct, |  | ||||||
|     typename IdentifierType, | template <typename AbstractProduct, typename IdentifierType, typename ProductCreator> | ||||||
|     typename ProductCreator | class SimpleAbstractFactory: | ||||||
| > |     public Singleton<SimpleAbstractFactory<AbstractProduct, IdentifierType, 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 { | ||||||
|             return 0; |             return 0; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     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, |     typedef SimpleAbstractFactory<AbstractProduct, IdentifierType, ProductCreator> SimpleFactory; | ||||||
|         typename Attribs |     typedef QMap<IdentifierType, Attribs> AliasMap; | ||||||
| > |     friend class Singleton< | ||||||
| class AttribAbstractFactory : public SimpleAbstractFactory< AbstractProduct,IdentifierType,ProductCreator >{ |         AttribAbstractFactory<AbstractProduct, IdentifierType, ProductCreator, Attribs>>; | ||||||
|     typedef SimpleAbstractFactory< AbstractProduct,IdentifierType,ProductCreator > SimpleFactory; |  | ||||||
|     typedef QMap<IdentifierType,Attribs> AliasMap; | public: | ||||||
|     friend class Singleton<AttribAbstractFactory< AbstractProduct,IdentifierType,ProductCreator,Attribs > >; |     bool registerCreator(const IdentifierType& id, Attribs attribs, ProductCreator creator) | ||||||
| public : |     { | ||||||
|     bool registerCreator(const IdentifierType &id, Attribs attribs, ProductCreator creator){ |         return SimpleFactory::registerCreator(id, creator) | ||||||
|         return SimpleFactory::registerCreator(id,creator) &&  (m_attribsMap.insert(id,attribs).value()==attribs); |             && (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 | ||||||
|   | |||||||
| @@ -32,28 +32,27 @@ | |||||||
|  |  | ||||||
| #include <cstdlib> | #include <cstdlib> | ||||||
|  |  | ||||||
| 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 | ||||||
|   | |||||||
| @@ -29,111 +29,118 @@ | |||||||
|  ****************************************************************************/ |  ****************************************************************************/ | ||||||
| #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() | ||||||
| { | { | ||||||
|    ui->cbbDrivers->addItems(QSqlDatabase::drivers()); |     ui->cbbDrivers->addItems(QSqlDatabase::drivers()); | ||||||
|    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()) | ||||||
|         if (!m_connection){ |             checkConnection(); | ||||||
|  |         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()); |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void ConnectionDialog::slotCheckConnection() | void ConnectionDialog::slotCheckConnection() | ||||||
| { | { | ||||||
|     try{ |     try { | ||||||
|         checkConnection(); |         checkConnection(); | ||||||
|         QMessageBox::information(this,tr("Connection"),tr("Connection succsesfully established!")); |         QMessageBox::information(this, tr("Connection"), | ||||||
|     } catch(LimeReport::ReportError &exception) { |                                  tr("Connection succsesfully established!")); | ||||||
|         QMessageBox::critical(this,tr("Error"),exception.what()); |     } catch (LimeReport::ReportError& exception) { | ||||||
|  |         QMessageBox::critical(this, tr("Error"), exception.what()); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void ConnectionDialog::checkFieldsFill() | void ConnectionDialog::checkFieldsFill() | ||||||
| { | { | ||||||
|     if (ui->leConnectionName->text().isEmpty()){throw LimeReport::ReportError(tr("Connection Name is empty"));} |     if (ui->leConnectionName->text().isEmpty()) { | ||||||
|     if (!m_changeMode&&QSqlDatabase::connectionNames().contains(ui->leConnectionName->text())) { |         throw LimeReport::ReportError(tr("Connection Name is empty")); | ||||||
|         throw LimeReport::ReportError(tr("Connection with name ")+ui->leConnectionName->text()+tr(" already exists! ")); |     } | ||||||
|  |     if (!m_changeMode && QSqlDatabase::connectionNames().contains(ui->leConnectionName->text())) { | ||||||
|  |         throw LimeReport::ReportError(tr("Connection with name ") + ui->leConnectionName->text() | ||||||
|  |                                       + tr(" already exists! ")); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| bool ConnectionDialog::checkConnection() | bool ConnectionDialog::checkConnection() | ||||||
| { | { | ||||||
|     QScopedPointer<LimeReport::ConnectionDesc> con(uiToConnection()); |     QScopedPointer<LimeReport::ConnectionDesc> con(uiToConnection()); | ||||||
|     if (!m_controller->checkConnectionDesc(con.data())){ |     if (!m_controller->checkConnectionDesc(con.data())) { | ||||||
|         throw LimeReport::ReportError(m_controller->lastError()); |         throw LimeReport::ReportError(m_controller->lastError()); | ||||||
|     } |     } | ||||||
|     return true; |     return true; | ||||||
| } | } | ||||||
|  |  | ||||||
| ConnectionDesc *ConnectionDialog::uiToConnection(LimeReport::ConnectionDesc* conDesc) | ConnectionDesc* ConnectionDialog::uiToConnection(LimeReport::ConnectionDesc* conDesc) | ||||||
| { | { | ||||||
|     LimeReport::ConnectionDesc* result; |     LimeReport::ConnectionDesc* result; | ||||||
|     if (conDesc) |     if (conDesc) | ||||||
|         result = conDesc; |         result = conDesc; | ||||||
|     else |     else | ||||||
|         result = new LimeReport::ConnectionDesc(); |         result = new LimeReport::ConnectionDesc(); | ||||||
|     result ->setName(ConnectionDesc::connectionNameForReport(ui->leConnectionName->text())); |     result->setName(ConnectionDesc::connectionNameForReport(ui->leConnectionName->text())); | ||||||
|     result ->setHost(ui->leServerName->text()); |     result->setHost(ui->leServerName->text()); | ||||||
|     if (!ui->lePort->text().isEmpty()) |     if (!ui->lePort->text().isEmpty()) | ||||||
|         result->setPort(ui->lePort->text()); |         result->setPort(ui->lePort->text()); | ||||||
|     result ->setDriver(ui->cbbDrivers->currentText()); |     result->setDriver(ui->cbbDrivers->currentText()); | ||||||
|     result ->setUserName(ui->leUserName->text()); |     result->setUserName(ui->leUserName->text()); | ||||||
|     result ->setPassword(ui->lePassword->text()); |     result->setPassword(ui->lePassword->text()); | ||||||
|     result ->setDatabaseName(ui->leDataBase->text()); |     result->setDatabaseName(ui->leDataBase->text()); | ||||||
|     result ->setAutoconnect(ui->cbAutoConnect->isChecked()); |     result->setAutoconnect(ui->cbAutoConnect->isChecked()); | ||||||
|     result->setKeepDBCredentials(!ui->cbbKeepCredentials->isChecked()); |     result->setKeepDBCredentials(!ui->cbbKeepCredentials->isChecked()); | ||||||
|     return result ; |     return result; | ||||||
| } | } | ||||||
|  |  | ||||||
| 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()); | ||||||
| @@ -151,7 +158,7 @@ void ConnectionDialog::on_toolButton_clicked() | |||||||
|  |  | ||||||
| void ConnectionDialog::on_cbbUseDefaultConnection_toggled(bool checked) | void ConnectionDialog::on_cbbUseDefaultConnection_toggled(bool checked) | ||||||
| { | { | ||||||
|     if (checked){ |     if (checked) { | ||||||
|         m_savedConnectionName = ui->leConnectionName->text(); |         m_savedConnectionName = ui->leConnectionName->text(); | ||||||
|         ui->leConnectionName->setText(tr("defaultConnection")); |         ui->leConnectionName->setText(tr("defaultConnection")); | ||||||
|         ui->leConnectionName->setEnabled(false); |         ui->leConnectionName->setEnabled(false); | ||||||
| @@ -166,10 +173,3 @@ void ConnectionDialog::on_toolButton_2_toggled(bool checked) | |||||||
| } | } | ||||||
|  |  | ||||||
| } // namespace LimeReport | } // namespace LimeReport | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -30,27 +30,29 @@ | |||||||
| #ifndef LRCONNECTIONDIALOG_H | #ifndef LRCONNECTIONDIALOG_H | ||||||
| #define LRCONNECTIONDIALOG_H | #define LRCONNECTIONDIALOG_H | ||||||
|  |  | ||||||
| #include <QDialog> |  | ||||||
| #include "lrdatadesignintf.h" | #include "lrdatadesignintf.h" | ||||||
|  |  | ||||||
| namespace LimeReport{ | #include <QDialog> | ||||||
|  |  | ||||||
|  | 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(); | ||||||
|     void checkFieldsFill(); |     void checkFieldsFill(); | ||||||
|     bool checkConnection(); |     bool checkConnection(); | ||||||
|     ConnectionDesc* uiToConnection(LimeReport::ConnectionDesc *conDesc = 0); |     ConnectionDesc* uiToConnection(LimeReport::ConnectionDesc* conDesc = 0); | ||||||
|     void connectionToUI(); |     void connectionToUI(); | ||||||
| signals: | signals: | ||||||
|     void conectionRegistred(LimeReport::ConnectionDesc* connectionDesc); |     void conectionRegistred(LimeReport::ConnectionDesc* connectionDesc); | ||||||
| @@ -63,7 +65,7 @@ private slots: | |||||||
|     void on_toolButton_2_toggled(bool checked); |     void on_toolButton_2_toggled(bool checked); | ||||||
|  |  | ||||||
| private: | private: | ||||||
|     Ui::ConnectionDialog *ui; |     Ui::ConnectionDialog* ui; | ||||||
|     ConnectionDesc* m_connection; |     ConnectionDesc* m_connection; | ||||||
|     bool m_changeMode; |     bool m_changeMode; | ||||||
|     IConnectionController* m_controller; |     IConnectionController* m_controller; | ||||||
|   | |||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -30,27 +30,25 @@ | |||||||
| #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" |  | ||||||
|  |  | ||||||
| namespace LimeReport{ | #include <QDockWidget> | ||||||
|  | #include <QToolButton> | ||||||
|  | #include <QTreeWidget> | ||||||
|  | #include <QWidget> | ||||||
|  |  | ||||||
|  | namespace LimeReport { | ||||||
|  |  | ||||||
| namespace Ui { | 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; | ||||||
|     void setReportEditor(LimeReport::ReportDesignWidget* report); |     void setReportEditor(LimeReport::ReportDesignWidget* report); | ||||||
| @@ -62,7 +60,7 @@ public: | |||||||
|     void setSettings(QSettings* value, bool owned = false); |     void setSettings(QSettings* value, bool owned = false); | ||||||
|     QSettings* settings(); |     QSettings* settings(); | ||||||
|     QString lastError() const; |     QString lastError() const; | ||||||
|     void setLastError(const QString &lastError); |     void setLastError(const QString& lastError); | ||||||
|  |  | ||||||
| private slots: | private slots: | ||||||
|     void slotDatasourcesChanged(); |     void slotDatasourcesChanged(); | ||||||
| @@ -77,24 +75,27 @@ private slots: | |||||||
|     void slotDataWindowClosed(); |     void slotDataWindowClosed(); | ||||||
|     void slotChangeConnection(); |     void slotChangeConnection(); | ||||||
|     void slotChangeConnectionState(); |     void slotChangeConnectionState(); | ||||||
|     void slotVariableEditorAccept(const QString &variable); |     void slotVariableEditorAccept(const QString& variable); | ||||||
|     void on_dataTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous); |     void on_dataTree_currentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous); | ||||||
|     void on_editVariable_clicked(); |     void on_editVariable_clicked(); | ||||||
|     void on_deleteVariable_clicked(); |     void on_deleteVariable_clicked(); | ||||||
|     void on_addVariable_clicked(); |     void on_addVariable_clicked(); | ||||||
|     void on_variablesTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous); |     void on_variablesTree_currentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous); | ||||||
|     void on_errorMessage_clicked(); |     void on_errorMessage_clicked(); | ||||||
|     void on_varToReport_clicked(); |     void on_varToReport_clicked(); | ||||||
|     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(); | ||||||
|     bool isClosingWindows() const {return m_closingWindows;} |     bool isClosingWindows() const { return m_closingWindows; } | ||||||
|     QTreeWidgetItem * findByNameAndType(QString name, int itemType); |     QTreeWidgetItem* findByNameAndType(QString name, int itemType); | ||||||
|     void fillFields(QTreeWidgetItem *parentItem, LimeReport::IDataSource *dataSource); |     void fillFields(QTreeWidgetItem* parentItem, LimeReport::IDataSource* dataSource); | ||||||
|     QDockWidget* createDataWindow(QString datasourceName); |     QDockWidget* createDataWindow(QString datasourceName); | ||||||
|     void closeDataWindow(QString datasourceName); |     void closeDataWindow(QString datasourceName); | ||||||
|     QDockWidget* dataWindow(QString datasourceName); |     QDockWidget* dataWindow(QString datasourceName); | ||||||
| @@ -113,22 +114,22 @@ private: | |||||||
|     void applyChanges(SQLEditResult result); |     void applyChanges(SQLEditResult result); | ||||||
|     void addDatasource(SQLEditResult result); |     void addDatasource(SQLEditResult result); | ||||||
|  |  | ||||||
|     void addConnectionDesc(ConnectionDesc *connection); |     void addConnectionDesc(ConnectionDesc* connection); | ||||||
|     void changeConnectionDesc(ConnectionDesc *connection); |     void changeConnectionDesc(ConnectionDesc* connection); | ||||||
|     bool checkConnectionDesc(ConnectionDesc *connection); |     bool checkConnectionDesc(ConnectionDesc* connection); | ||||||
|     bool containsDefaultConnection(); |     bool containsDefaultConnection(); | ||||||
|     void activateItem(const QString &name, DataBrowserTree::NodeType type); |     void activateItem(const QString& name, DataBrowserTree::NodeType type); | ||||||
|  |  | ||||||
| private: | private: | ||||||
|     Ui::DataBrowser*           ui; |     Ui::DataBrowser* ui; | ||||||
|     ReportDesignWidget*         m_report; |     ReportDesignWidget* m_report; | ||||||
|     QMap<QString,QDockWidget*>  m_dataWindows; |     QMap<QString, QDockWidget*> m_dataWindows; | ||||||
|     QMainWindow*                m_mainWindow; |     QMainWindow* m_mainWindow; | ||||||
|     bool                        m_closingWindows; |     bool m_closingWindows; | ||||||
|     QSettings*                  m_settings; |     QSettings* m_settings; | ||||||
|     bool                        m_ownedSettings; |     bool m_ownedSettings; | ||||||
|     QString                     m_lastError; |     QString m_lastError; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| } | } // namespace LimeReport | ||||||
| #endif // LRDATABROWSER_H | #endif // LRDATABROWSER_H | ||||||
|   | |||||||
| @@ -28,29 +28,30 @@ | |||||||
|  *   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 | ||||||
| #else | #else | ||||||
| QMimeData *DataBrowserTree::mimeData(const QList<QTreeWidgetItem *> items) const | QMimeData* DataBrowserTree::mimeData(const QList<QTreeWidgetItem*> items) const | ||||||
| #endif | #endif | ||||||
| { | { | ||||||
|     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) + "}"); | ||||||
|     } |     } | ||||||
|     if (items.at(0)->type()==ExternalVariable){ |     if (items.at(0)->type() == ExternalVariable) { | ||||||
|         result->setText("variable:$V{"+items.at(0)->text(0)+"}"); |         result->setText("variable:$V{" + items.at(0)->text(0) + "}"); | ||||||
|     } |     } | ||||||
|     return result; |     return result; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -32,24 +32,29 @@ | |||||||
|  |  | ||||||
| #include <QTreeWidget> | #include <QTreeWidget> | ||||||
|  |  | ||||||
| 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 { | ||||||
|     explicit DataBrowserTree(QWidget *parent = 0); |         Connection, | ||||||
|  |         Table, | ||||||
|  |         Row, | ||||||
|  |         Category, | ||||||
|  |         Variable, | ||||||
|  |         ExternalVariable | ||||||
|  |     }; | ||||||
|  |     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; | ||||||
| #else | #else | ||||||
|     virtual QMimeData *mimeData(const QList<QTreeWidgetItem*> items) const; |     virtual QMimeData* mimeData(const QList<QTreeWidgetItem*> items) const; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| public slots: | public slots: | ||||||
|  |  | ||||||
| }; | }; | ||||||
|  |  | ||||||
| } // namespace LimeReport | } // namespace LimeReport | ||||||
|   | |||||||
| @@ -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); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -126,22 +141,24 @@ void SQLEditDialog::accept() { | |||||||
|         check(); |         check(); | ||||||
|         emit signalSqlEditingFinished(result); |         emit signalSqlEditingFinished(result); | ||||||
|         QDialog::accept(); |         QDialog::accept(); | ||||||
|     } catch (LimeReport::ReportError &exception) { |     } catch (LimeReport::ReportError& exception) { | ||||||
|         QMessageBox::critical(this, tr("Error"), exception.what()); |         QMessageBox::critical(this, tr("Error"), exception.what()); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void SQLEditDialog::showEvent(QShowEvent *) { | void SQLEditDialog::showEvent(QShowEvent*) | ||||||
|  | { | ||||||
|     ui->lblInfo->setVisible(false); |     ui->lblInfo->setVisible(false); | ||||||
|     initConnections(); |     initConnections(); | ||||||
|     readSettings(); |     readSettings(); | ||||||
| } | } | ||||||
|  |  | ||||||
| void SQLEditDialog::closeEvent(QCloseEvent *) { writeSetting(); } | void SQLEditDialog::closeEvent(QCloseEvent*) { writeSetting(); } | ||||||
|  |  | ||||||
| void SQLEditDialog::hideEvent(QHideEvent *) { writeSetting(); } | void SQLEditDialog::hideEvent(QHideEvent*) { writeSetting(); } | ||||||
|  |  | ||||||
| void SQLEditDialog::check() { | void SQLEditDialog::check() | ||||||
|  | { | ||||||
|     if (ui->leDatasourceName->text().isEmpty()) |     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); | ||||||
| @@ -191,11 +214,11 @@ void SQLEditDialog::setDataSources(LimeReport::DataSourceManager *dataSources, Q | |||||||
|         } |         } | ||||||
|         if (dataSources->isProxy(datasourceName)) { |         if (dataSources->isProxy(datasourceName)) { | ||||||
|             initProxyMode(); |             initProxyMode(); | ||||||
|             LimeReport::ProxyDesc *proxyDesc = dataSources->proxyByName(datasourceName); |             LimeReport::ProxyDesc* proxyDesc = dataSources->proxyByName(datasourceName); | ||||||
|             ui->leChild->setText(proxyDesc->child()); |             ui->leChild->setText(proxyDesc->child()); | ||||||
|             ui->leMaster->setText(proxyDesc->master()); |             ui->leMaster->setText(proxyDesc->master()); | ||||||
|             int curIndex = 0; |             int curIndex = 0; | ||||||
|             foreach (LimeReport::FieldMapDesc *fields, *proxyDesc->fieldsMap()) { |             foreach (LimeReport::FieldMapDesc* fields, *proxyDesc->fieldsMap()) { | ||||||
|                 ui->fieldsMap->setRowCount(curIndex + 1); |                 ui->fieldsMap->setRowCount(curIndex + 1); | ||||||
|                 ui->fieldsMap->setItem(curIndex, 0, new QTableWidgetItem(fields->master())); |                 ui->fieldsMap->setItem(curIndex, 0, new QTableWidgetItem(fields->master())); | ||||||
|                 ui->fieldsMap->setItem(curIndex, 1, new QTableWidgetItem(fields->detail())); |                 ui->fieldsMap->setItem(curIndex, 1, new QTableWidgetItem(fields->detail())); | ||||||
| @@ -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,14 +339,15 @@ 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()); | ||||||
|         ui->gbDataPreview->setVisible(true); |         ui->gbDataPreview->setVisible(true); | ||||||
| @@ -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 | ||||||
|   | |||||||
| @@ -30,15 +30,17 @@ | |||||||
| #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" | ||||||
|  |  | ||||||
| namespace LimeReport{ | #include <QCompleter> | ||||||
|  | #include <QDialog> | ||||||
|  | #include <QSettings> | ||||||
|  |  | ||||||
|  | #include <stdexcept> | ||||||
|  |  | ||||||
|  | namespace LimeReport { | ||||||
|  |  | ||||||
| namespace Ui { | namespace Ui { | ||||||
|     class SQLEditDialog; |     class SQLEditDialog; | ||||||
| @@ -46,22 +48,26 @@ 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, | ||||||
|     void setDataSources(LimeReport::DataSourceManager *dataSources,QString datasourceName=""); |         EditMode | ||||||
|  |     }; | ||||||
|  |     explicit SQLEditDialog(QWidget* parent, LimeReport::DataSourceManager* dataSources, | ||||||
|  |                            SQLDialogMode dialogMode); | ||||||
|  |     void setDataSources(LimeReport::DataSourceManager* dataSources, QString datasourceName = ""); | ||||||
|     void setDefaultConnection(QString defaultConnection); |     void setDefaultConnection(QString defaultConnection); | ||||||
|     ~SQLEditDialog(); |     ~SQLEditDialog(); | ||||||
|     QSettings* settings(); |     QSettings* settings(); | ||||||
|     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*); | ||||||
|     void hideEvent(QHideEvent*); |     void hideEvent(QHideEvent*); | ||||||
|     void check(); |     void check(); | ||||||
| @@ -80,12 +86,14 @@ 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; | ||||||
|     SQLDialogMode m_dialogMode; |     SQLDialogMode m_dialogMode; | ||||||
|     QString m_oldDatasourceName; |     QString m_oldDatasourceName; | ||||||
| @@ -96,8 +104,14 @@ private: | |||||||
|     QSharedPointer<QAbstractItemModel> m_previewModel; |     QSharedPointer<QAbstractItemModel> m_previewModel; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| 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; | ||||||
|   | |||||||
| @@ -29,13 +29,16 @@ | |||||||
|  ****************************************************************************/ |  ****************************************************************************/ | ||||||
| #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> | ||||||
|  |  | ||||||
| LRVariableDialog::LRVariableDialog(QWidget *parent) : | #include <stdexcept> | ||||||
|  |  | ||||||
|  | LRVariableDialog::LRVariableDialog(QWidget* parent): | ||||||
|     QDialog(parent), |     QDialog(parent), | ||||||
|     ui(new Ui::LRVariableDialog), |     ui(new Ui::LRVariableDialog), | ||||||
|     m_variableName(""), |     m_variableName(""), | ||||||
| @@ -45,43 +48,45 @@ 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)); | ||||||
|     } |     } | ||||||
|     //ui->cbbType->setVisible(false); |     // ui->cbbType->setVisible(false); | ||||||
|     //ui->lblType->setVisible(false); |     // ui->lblType->setVisible(false); | ||||||
| } | } | ||||||
|  |  | ||||||
| LRVariableDialog::~LRVariableDialog() | LRVariableDialog::~LRVariableDialog() { delete ui; } | ||||||
|  |  | ||||||
|  | void LRVariableDialog::setVariableContainer(LimeReport::IVariablesContainer* value) | ||||||
| { | { | ||||||
|     delete ui; |     m_variablesContainer = value; | ||||||
| } | } | ||||||
|  |  | ||||||
| void LRVariableDialog::setVariableContainer(LimeReport::IVariablesContainer *value) | void LRVariableDialog::setVariableName(const QString& value) | ||||||
| { | { | ||||||
|     m_variablesContainer=value; |     m_variableName = value; | ||||||
|  |     m_changeMode = true; | ||||||
|  |     m_oldVariableName = value; | ||||||
| } | } | ||||||
|  |  | ||||||
| void LRVariableDialog::setVariableName(const QString &value) | void LRVariableDialog::showEvent(QShowEvent*) | ||||||
| { |  | ||||||
|     m_variableName=value; |  | ||||||
|     m_changeMode=true; |  | ||||||
|     m_oldVariableName=value; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| 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)); | ||||||
|     } |     } | ||||||
| @@ -89,35 +94,36 @@ 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()) { | ||||||
|             if (m_changeMode){ |             if (m_changeMode) { | ||||||
|                 if (m_oldVariableName==ui->leName->text()){ |                 if (m_oldVariableName == ui->leName->text()) { | ||||||
|                     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(); | ||||||
|         } |         } | ||||||
|     } catch (LimeReport::ReportError &exception){ |     } catch (LimeReport::ReportError& exception) { | ||||||
|         QMessageBox::critical(this,tr("Attention"),exception.what()); |         QMessageBox::critical(this, tr("Attention"), exception.what()); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| QVariant LRVariableDialog::value() | QVariant LRVariableDialog::value() { return ui->leValue->toPlainText(); } | ||||||
| { |  | ||||||
|     return ui->leValue->toPlainText(); |  | ||||||
| } |  | ||||||
|   | |||||||
| @@ -30,32 +30,35 @@ | |||||||
| #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: | ||||||
|     explicit LRVariableDialog(QWidget *parent = 0); |     explicit LRVariableDialog(QWidget* parent = 0); | ||||||
|     ~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; | ||||||
|     LimeReport::IVariablesContainer* m_variablesContainer; |     LimeReport::IVariablesContainer* m_variablesContainer; | ||||||
|     bool m_changeMode; |     bool m_changeMode; | ||||||
|   | |||||||
| @@ -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,15 +19,17 @@ | |||||||
| #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 { | ||||||
|  |  | ||||||
| DialogDesignerManager::DialogDesignerManager(QObject *parent) : QObject(parent) | DialogDesignerManager::DialogDesignerManager(QObject* parent): QObject(parent) | ||||||
| { | { | ||||||
|     QDesignerComponents::initializeResources(); |     QDesignerComponents::initializeResources(); | ||||||
|     m_formEditor = QDesignerComponents::createFormEditor(this); |     m_formEditor = QDesignerComponents::createFormEditor(this); | ||||||
| @@ -43,20 +42,21 @@ 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); | ||||||
|             fep->action()->setIcon(QIcon(iconPathByName(fep->action()->objectName()))); |             fep->action()->setIcon(QIcon(iconPathByName(fep->action()->objectName()))); | ||||||
|             m_modes->addAction(fep->action()); |             m_modes->addAction(fep->action()); | ||||||
|         } |         } | ||||||
| @@ -68,54 +68,57 @@ DialogDesignerManager::DialogDesignerManager(QObject *parent) : QObject(parent) | |||||||
|     m_formEditor->setWidgetBox(m_widgetBox); |     m_formEditor->setWidgetBox(m_widgetBox); | ||||||
|     m_formEditor->setTopLevel(m_widgetBox); |     m_formEditor->setTopLevel(m_widgetBox); | ||||||
|     m_designerToolWindows.append(m_widgetBox); |     m_designerToolWindows.append(m_widgetBox); | ||||||
|     connect(m_widgetBox, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)) ); |     connect(m_widgetBox, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*))); | ||||||
|  |  | ||||||
|     m_objectInspector = QDesignerComponents::createObjectInspector(m_formEditor, 0); |     m_objectInspector = QDesignerComponents::createObjectInspector(m_formEditor, 0); | ||||||
|     m_objectInspector->setWindowTitle(tr("Object Inspector")); |     m_objectInspector->setWindowTitle(tr("Object Inspector")); | ||||||
|     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")); | ||||||
|     m_actionEditor->setObjectName("ActionEditor"); |     m_actionEditor->setObjectName("ActionEditor"); | ||||||
|     m_formEditor->setActionEditor(m_actionEditor); |     m_formEditor->setActionEditor(m_actionEditor); | ||||||
|     m_designerToolWindows.append(m_actionEditor); |     m_designerToolWindows.append(m_actionEditor); | ||||||
|     connect(m_actionEditor, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)) ); |     connect(m_actionEditor, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*))); | ||||||
|  |  | ||||||
| #if QT_VERSION < 0x050000 | #if QT_VERSION < 0x050000 | ||||||
|     m_designerIntegration = new qdesigner_internal::QDesignerIntegration(m_formEditor,this); |     m_designerIntegration = new qdesigner_internal::QDesignerIntegration(m_formEditor, this); | ||||||
| #else | #else | ||||||
|     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() | ||||||
| { | { | ||||||
|     for (int i = 0; i<m_designerToolWindows.size();++i){ |     for (int i = 0; i < m_designerToolWindows.size(); ++i) { | ||||||
|         if (m_designerToolWindows[i]) |         if (m_designerToolWindows[i]) | ||||||
|             delete m_designerToolWindows[i]; |             delete m_designerToolWindows[i]; | ||||||
|     } |     } | ||||||
| @@ -124,9 +127,9 @@ DialogDesignerManager::~DialogDesignerManager() | |||||||
|     delete m_formEditor; |     delete m_formEditor; | ||||||
| } | } | ||||||
|  |  | ||||||
| void DialogDesignerManager::initToolBar(QToolBar *tb) | void DialogDesignerManager::initToolBar(QToolBar* tb) | ||||||
| { | { | ||||||
|     tb->setIconSize(QSize(16,16)); |     tb->setIconSize(QSize(16, 16)); | ||||||
|     m_formEditor->formWindowManager()->actionCopy()->setIcon(QIcon(":/report/images/copy")); |     m_formEditor->formWindowManager()->actionCopy()->setIcon(QIcon(":/report/images/copy")); | ||||||
|     tb->addAction(m_formEditor->formWindowManager()->actionCopy()); |     tb->addAction(m_formEditor->formWindowManager()->actionCopy()); | ||||||
|     m_formEditor->formWindowManager()->actionPaste()->setIcon(QIcon(":/report/images/paste")); |     m_formEditor->formWindowManager()->actionPaste()->setIcon(QIcon(":/report/images/paste")); | ||||||
| @@ -145,15 +148,17 @@ void DialogDesignerManager::initToolBar(QToolBar *tb) | |||||||
|     tb->addAction(m_formEditor->formWindowManager()->actionSplitHorizontal()); |     tb->addAction(m_formEditor->formWindowManager()->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()); | ||||||
| } | } | ||||||
|  |  | ||||||
| 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,79 +167,61 @@ 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) | ||||||
| { | { | ||||||
|     QByteArray result; |     QByteArray result; | ||||||
|     DialogDesigner* dialogDesigner = dynamic_cast<DialogDesigner*>(form); |     DialogDesigner* dialogDesigner = dynamic_cast<DialogDesigner*>(form); | ||||||
|     Q_ASSERT(dialogDesigner != NULL); |     Q_ASSERT(dialogDesigner != NULL); | ||||||
|     //SharedTools::WidgetHost* wh = dynamic_cast<SharedTools::WidgetHost*>(form); |     // SharedTools::WidgetHost* wh = dynamic_cast<SharedTools::WidgetHost*>(form); | ||||||
|     if (dialogDesigner){ |     if (dialogDesigner) { | ||||||
|         result = dialogDesigner->dialogContent(); |         result = dialogDesigner->dialogContent(); | ||||||
|         //wh->formWindow()->setDirty(false); |         // wh->formWindow()->setDirty(false); | ||||||
|     } |     } | ||||||
|     return result; |     return result; | ||||||
| } | } | ||||||
|  |  | ||||||
| void DialogDesignerManager::setActiveEditor(QWidget *widget) | void DialogDesignerManager::setActiveEditor(QWidget* widget) | ||||||
| { | { | ||||||
|     SharedTools::WidgetHost* wh = dynamic_cast<SharedTools::WidgetHost*>(widget); |     SharedTools::WidgetHost* wh = dynamic_cast<SharedTools::WidgetHost*>(widget); | ||||||
|     if (wh){ |     if (wh) { | ||||||
|         m_formEditor->formWindowManager()->setActiveFormWindow(wh->formWindow()); |         m_formEditor->formWindowManager()->setActiveFormWindow(wh->formWindow()); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void DialogDesignerManager::setDirty(bool value) | void DialogDesignerManager::setDirty(bool value) | ||||||
| { | { | ||||||
|     foreach(DialogDesigner* dialogDesigner, m_dialogDesigners){ |     foreach (DialogDesigner* dialogDesigner, m_dialogDesigners) { | ||||||
|         dialogDesigner->setChanged(value); |         dialogDesigner->setChanged(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) | ||||||
| { | { | ||||||
|  |  | ||||||
|     QList<DialogDesigner*>::Iterator it = m_dialogDesigners.begin(); |     QList<DialogDesigner*>::Iterator it = m_dialogDesigners.begin(); | ||||||
|     while(it!=m_dialogDesigners.end()){ |     while (it != m_dialogDesigners.end()) { | ||||||
|         if (*it == object){ |         if (*it == object) { | ||||||
|             it = m_dialogDesigners.erase(it); |             it = m_dialogDesigners.erase(it); | ||||||
|             return; |             return; | ||||||
|         } else { |         } else { | ||||||
| @@ -242,22 +229,22 @@ 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() | ||||||
| { | { | ||||||
|    for (int i = 0; i<m_formEditor->formWindowManager()->formWindowCount(); ++i){ |     for (int i = 0; i < m_formEditor->formWindowManager()->formWindowCount(); ++i) { | ||||||
|        m_formEditor->formWindowManager()->formWindow(i)->editWidgets(); |         m_formEditor->formWindowManager()->formWindow(i)->editWidgets(); | ||||||
|    } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void DialogDesignerManager::slotActiveFormWindowChanged(QDesignerFormWindowInterface *formWindow) | void DialogDesignerManager::slotActiveFormWindowChanged(QDesignerFormWindowInterface* formWindow) | ||||||
| { | { | ||||||
|     if (formWindow){ |     if (formWindow) { | ||||||
|         m_editWidgetsAction->setEnabled(true); |         m_editWidgetsAction->setEnabled(true); | ||||||
|         m_editWidgetsAction->trigger(); |         m_editWidgetsAction->trigger(); | ||||||
|         m_editWidgetsAction->setChecked(true); |         m_editWidgetsAction->setChecked(true); | ||||||
| @@ -265,7 +252,7 @@ void DialogDesignerManager::slotActiveFormWindowChanged(QDesignerFormWindowInter | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| QString DialogDesignerManager::iconPathByName(const QString &name) | QString DialogDesignerManager::iconPathByName(const QString& name) | ||||||
| { | { | ||||||
|     if (name.compare("__qt_edit_signals_slots_action") == 0) |     if (name.compare("__qt_edit_signals_slots_action") == 0) | ||||||
|         return ":/images/images/signalslottool.png"; |         return ":/images/images/signalslottool.png"; | ||||||
| @@ -276,43 +263,33 @@ 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())); | ||||||
|  |  | ||||||
|     m_designerHolder = new SharedTools::WidgetHost(this,wnd); |     m_designerHolder = new SharedTools::WidgetHost(this, wnd); | ||||||
|     m_designerHolder->setFrameStyle( QFrame::NoFrame | QFrame::Plain ); |     m_designerHolder->setFrameStyle(QFrame::NoFrame | QFrame::Plain); | ||||||
|     m_designerHolder->setFocusProxy( wnd ); |     m_designerHolder->setFocusProxy(wnd); | ||||||
|  |  | ||||||
|     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() | ||||||
| { | { | ||||||
| @@ -324,7 +301,7 @@ QByteArray DialogDesigner::dialogContent() | |||||||
| void DialogDesigner::undo() | void DialogDesigner::undo() | ||||||
| { | { | ||||||
|     Q_ASSERT(m_formEditor != NULL); |     Q_ASSERT(m_formEditor != NULL); | ||||||
|     if (m_formEditor){ |     if (m_formEditor) { | ||||||
|         m_formEditor->formWindowManager()->actionUndo()->trigger(); |         m_formEditor->formWindowManager()->actionUndo()->trigger(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @@ -332,14 +309,14 @@ void DialogDesigner::undo() | |||||||
| void DialogDesigner::redo() | void DialogDesigner::redo() | ||||||
| { | { | ||||||
|     Q_ASSERT(m_formEditor != NULL); |     Q_ASSERT(m_formEditor != NULL); | ||||||
|     if (m_formEditor){ |     if (m_formEditor) { | ||||||
|         m_formEditor->formWindowManager()->actionRedo()->trigger(); |         m_formEditor->formWindowManager()->actionRedo()->trigger(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void DialogDesigner::slotMainContainerNameChanged(QString newName) | void DialogDesigner::slotMainContainerNameChanged(QString newName) | ||||||
| { | { | ||||||
|     if (m_dialogName.compare(newName) != 0){ |     if (m_dialogName.compare(newName) != 0) { | ||||||
|         emit dialogNameChanged(m_dialogName, newName); |         emit dialogNameChanged(m_dialogName, newName); | ||||||
|         m_dialogName = newName; |         m_dialogName = newName; | ||||||
|     } |     } | ||||||
| @@ -348,9 +325,11 @@ void DialogDesigner::slotMainContainerNameChanged(QString newName) | |||||||
| void DialogDesigner::slotDialogChanged() | 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 | ||||||
|   | |||||||
| @@ -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; | ||||||
| @@ -15,21 +15,22 @@ class QDesignerPropertyEditorInterface; | |||||||
| class QDesignerObjectInspectorInterface; | class QDesignerObjectInspectorInterface; | ||||||
| class QDesignerFormWindowManagerInterface; | class QDesignerFormWindowManagerInterface; | ||||||
|  |  | ||||||
| namespace SharedTools{ | namespace SharedTools { | ||||||
|     class WidgetHost; | class WidgetHost; | ||||||
| } | } | ||||||
|  |  | ||||||
| namespace LimeReport{ | 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); | ||||||
|     bool    isChanged(); |     bool isChanged(); | ||||||
|     void    setChanged(bool value); |     void setChanged(bool value); | ||||||
|     QByteArray dialogContent(); |     QByteArray dialogContent(); | ||||||
| public slots: | public slots: | ||||||
|     void undo(); |     void undo(); | ||||||
| @@ -40,17 +41,17 @@ 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); | ||||||
|     ~DialogDesignerManager(); |     ~DialogDesignerManager(); | ||||||
|     void initToolBar(QToolBar* tb); |     void initToolBar(QToolBar* tb); | ||||||
|     QWidget* createFormEditor(const QString& content); |     QWidget* createFormEditor(const QString& content); | ||||||
| @@ -69,9 +70,11 @@ signals: | |||||||
| private slots: | 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; | ||||||
|   | |||||||
| @@ -1,32 +1,36 @@ | |||||||
| #include <QPrinter> |  | ||||||
|  |  | ||||||
| #include "lrpdfexporter.h" | #include "lrpdfexporter.h" | ||||||
|  |  | ||||||
| #include "lrexportersfactory.h" | #include "lrexportersfactory.h" | ||||||
| #include "lrreportengine_p.h" | #include "lrreportengine_p.h" | ||||||
|  |  | ||||||
| namespace{ | #include <QPrinter> | ||||||
|  |  | ||||||
| LimeReport::ReportExporterInterface* createPDFExporter(LimeReport::ReportEnginePrivate* parent){ | namespace { | ||||||
|  |  | ||||||
|  | LimeReport::ReportExporterInterface* createPDFExporter(LimeReport::ReportEnginePrivate* parent) | ||||||
|  | { | ||||||
|     return new LimeReport::PDFExporter(parent); |     return new LimeReport::PDFExporter(parent); | ||||||
| } | } | ||||||
|  |  | ||||||
| bool VARIABLE_IS_NOT_USED registred = LimeReport::ExportersFactory::instance().registerCreator("PDF", LimeReport::ExporterAttribs(QObject::tr("Export to PDF"), "PDFExporter"), createPDFExporter); | bool VARIABLE_IS_NOT_USED registred = LimeReport::ExportersFactory::instance().registerCreator( | ||||||
|  |     "PDF", LimeReport::ExporterAttribs(QObject::tr("Export to PDF"), "PDFExporter"), | ||||||
|  |     createPDFExporter); | ||||||
|  |  | ||||||
| } | } // namespace | ||||||
|  |  | ||||||
| namespace LimeReport{ | namespace LimeReport { | ||||||
|  |  | ||||||
| PDFExporter::PDFExporter(ReportEnginePrivate *parent) : QObject(parent), m_reportEngine(parent) | PDFExporter::PDFExporter(ReportEnginePrivate* parent): QObject(parent), m_reportEngine(parent) { } | ||||||
| {} |  | ||||||
|  |  | ||||||
| bool PDFExporter::exportPages(ReportPages pages, const QString &fileName, const QMap<QString, QVariant> ¶ms) | bool PDFExporter::exportPages(ReportPages pages, const QString& fileName, | ||||||
|  |                               const QMap<QString, QVariant>& params) | ||||||
| { | { | ||||||
|     Q_UNUSED(params); |     Q_UNUSED(params); | ||||||
|     if (!fileName.isEmpty()){ |     if (!fileName.isEmpty()) { | ||||||
|         QPrinter printer; |         QPrinter printer; | ||||||
|         printer.setOutputFileName(fileName); |         printer.setOutputFileName(fileName); | ||||||
|         printer.setOutputFormat(QPrinter::PdfFormat); |         printer.setOutputFormat(QPrinter::PdfFormat); | ||||||
|         if (!pages.isEmpty()){ |         if (!pages.isEmpty()) { | ||||||
|             m_reportEngine->printPages(pages, &printer); |             m_reportEngine->printPages(pages, &printer); | ||||||
|         } |         } | ||||||
|         m_reportEngine->emitPrintedToPDF(fileName); |         m_reportEngine->emitPrintedToPDF(fileName); | ||||||
| @@ -35,4 +39,4 @@ bool PDFExporter::exportPages(ReportPages pages, const QString &fileName, const | |||||||
|     return false; |     return false; | ||||||
| } | } | ||||||
|  |  | ||||||
| } | } // namespace LimeReport | ||||||
|   | |||||||
| @@ -1,35 +1,28 @@ | |||||||
| #ifndef LRPDFEXPORTER_H | #ifndef LRPDFEXPORTER_H | ||||||
| #define LRPDFEXPORTER_H | #define LRPDFEXPORTER_H | ||||||
|  |  | ||||||
| #include <QObject> |  | ||||||
| #include "lrexporterintf.h" | #include "lrexporterintf.h" | ||||||
|  |  | ||||||
| namespace LimeReport{ | #include <QObject> | ||||||
|  |  | ||||||
|  | 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> ¶ms); |     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; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| } //namespace LimeReport | } // namespace LimeReport | ||||||
|  |  | ||||||
| #endif // LRPDFEXPORTER_H | #endif // LRPDFEXPORTER_H | ||||||
|   | |||||||
| @@ -1,7 +1,7 @@ | |||||||
| #include "lrgridlineschart.h" | #include "lrgridlineschart.h" | ||||||
|  |  | ||||||
| namespace LimeReport { | namespace LimeReport { | ||||||
| void GridLinesChart::paintChart(QPainter *painter, QRectF chartRect) | void GridLinesChart::paintChart(QPainter* painter, QRectF chartRect) | ||||||
| { | { | ||||||
|     updateMinAndMaxValues(); |     updateMinAndMaxValues(); | ||||||
|  |  | ||||||
| @@ -10,22 +10,18 @@ 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 | ||||||
|         gridRect.adjust(0, -valuesVMargin, 0 , -valuesVMargin); |         gridRect.adjust(0, -valuesVMargin, 0, -valuesVMargin); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // 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,23 +30,21 @@ 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); | ||||||
|  |  | ||||||
|     const AxisData &yAxisData = this->yAxisData(); |     const AxisData& yAxisData = this->yAxisData(); | ||||||
|     const qreal delta = yAxisData.delta(); |     const qreal delta = yAxisData.delta(); | ||||||
|  |  | ||||||
|     if (m_chartItem->itemMode() == DesignMode){ |     if (m_chartItem->itemMode() == DesignMode) { | ||||||
|         const qreal hStep = barsRect.width() / valuesCount(); |         const qreal hStep = barsRect.width() / valuesCount(); | ||||||
|         const qreal vStep = barsRect.height() / delta; |         const qreal vStep = barsRect.height() / delta; | ||||||
|         const qreal topShift = (delta - (maxValue() - minValue())) * vStep + barsRect.top(); |         const qreal topShift = (delta - (maxValue() - minValue())) * vStep + barsRect.top(); | ||||||
| @@ -59,7 +53,7 @@ void GridLinesChart::paintSerialLines(QPainter* painter, QRectF barsRect) | |||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     const AxisData &xAxisData = this->xAxisData(); |     const AxisData& xAxisData = this->xAxisData(); | ||||||
|     const qreal hStep = barsRect.width() / (xAxisData.rangeMax() - xAxisData.rangeMin()); |     const qreal hStep = barsRect.width() / (xAxisData.rangeMax() - xAxisData.rangeMin()); | ||||||
|  |  | ||||||
|     qreal leftMargin = 0; |     qreal leftMargin = 0; | ||||||
| @@ -70,8 +64,8 @@ void GridLinesChart::paintSerialLines(QPainter* painter, QRectF barsRect) | |||||||
|         pen.setWidth(m_chartItem->seriesLineWidth()); |         pen.setWidth(m_chartItem->seriesLineWidth()); | ||||||
|         painter->setPen(pen); |         painter->setPen(pen); | ||||||
|  |  | ||||||
|         const QList<qreal> &xAxisValues = series->data()->xAxisValues(); |         const QList<qreal>& xAxisValues = series->data()->xAxisValues(); | ||||||
|         const QList<qreal> &values = series->data()->values(); |         const QList<qreal>& values = series->data()->values(); | ||||||
|         const int xAxisValuesSize = xAxisValues.size(); |         const int xAxisValuesSize = xAxisValues.size(); | ||||||
|         qreal lastXPos = 0; |         qreal lastXPos = 0; | ||||||
|         qreal lastYPos = 0; |         qreal lastYPos = 0; | ||||||
| @@ -85,16 +79,16 @@ void GridLinesChart::paintSerialLines(QPainter* painter, QRectF barsRect) | |||||||
|             leftMargin = barsRect.left(); |             leftMargin = barsRect.left(); | ||||||
|             lastXPos = calculatePos(xAxisData, xAxisValues.first(), barsRect.width()); |             lastXPos = calculatePos(xAxisData, xAxisValues.first(), barsRect.width()); | ||||||
|         } |         } | ||||||
|         for (int i = 0; i < values.count() - 1; ++i ) { |         for (int i = 0; i < values.count() - 1; ++i) { | ||||||
|             const qreal startY = lastYPos; |             const qreal startY = lastYPos; | ||||||
|             const qreal endY = calculatePos(yAxisData, values.at(i+1), barsRect.height()); |             const qreal endY = calculatePos(yAxisData, values.at(i + 1), barsRect.height()); | ||||||
|             // Record last used Y position to only calculate new one |             // Record last used Y position to only calculate new one | ||||||
|             lastYPos = endY; |             lastYPos = endY; | ||||||
|  |  | ||||||
|             qreal startX = lastXPos; |             qreal startX = lastXPos; | ||||||
|             qreal endX = 0; |             qreal endX = 0; | ||||||
|             if (i + 1 < xAxisValuesSize) { |             if (i + 1 < xAxisValuesSize) { | ||||||
|                 endX = calculatePos(xAxisData, xAxisValues.at(i+1), barsRect.width()); |                 endX = calculatePos(xAxisData, xAxisValues.at(i + 1), barsRect.width()); | ||||||
|             } else { |             } else { | ||||||
|                 endX = startX + hStep; |                 endX = startX + hStep; | ||||||
|             } |             } | ||||||
| @@ -109,4 +103,4 @@ void GridLinesChart::paintSerialLines(QPainter* painter, QRectF barsRect) | |||||||
|  |  | ||||||
|     painter->restore(); |     painter->restore(); | ||||||
| } | } | ||||||
| } | } // namespace LimeReport | ||||||
|   | |||||||
| @@ -4,14 +4,14 @@ | |||||||
| #include "lrlineschart.h" | #include "lrlineschart.h" | ||||||
|  |  | ||||||
| namespace LimeReport { | namespace LimeReport { | ||||||
| class GridLinesChart : public LinesChart{ | class GridLinesChart: public LinesChart { | ||||||
| public: | public: | ||||||
|     GridLinesChart(ChartItem* chartItem):LinesChart(chartItem){} |     GridLinesChart(ChartItem* chartItem): LinesChart(chartItem) { } | ||||||
|     void paintChart(QPainter *painter, QRectF chartRect); |     void paintChart(QPainter* painter, QRectF chartRect); | ||||||
|  |  | ||||||
| private: | private: | ||||||
|     void paintSerialLines(QPainter *painter, QRectF barsRect); |     void paintSerialLines(QPainter* painter, QRectF barsRect); | ||||||
| }; | }; | ||||||
| } | } // namespace LimeReport | ||||||
|  |  | ||||||
| #endif // GRIDLINESCHART_H | #endif // GRIDLINESCHART_H | ||||||
|   | |||||||
| @@ -1,52 +1,49 @@ | |||||||
| #include "lrhorizontalbarchart.h" | #include "lrhorizontalbarchart.h" | ||||||
|  |  | ||||||
| namespace LimeReport{ | namespace LimeReport { | ||||||
|  |  | ||||||
| void HorizontalBarChart::paintChart(QPainter *painter, QRectF chartRect) | void HorizontalBarChart::paintChart(QPainter* painter, QRectF chartRect) | ||||||
| { | { | ||||||
|     updateMinAndMaxValues(); |     updateMinAndMaxValues(); | ||||||
|  |  | ||||||
|     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); | ||||||
|  |  | ||||||
|     const AxisData &yAxisData = this->yAxisData(); |     const AxisData& yAxisData = this->yAxisData(); | ||||||
|     const qreal delta = yAxisData.delta(); |     const qreal delta = yAxisData.delta(); | ||||||
|  |  | ||||||
|     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(); | ||||||
|         if (m_chartItem->horizontalAxisOnTop()) { |         if (m_chartItem->horizontalAxisOnTop()) { | ||||||
|             curVOffset += verticalOffset; |             curVOffset += verticalOffset; | ||||||
| @@ -55,8 +52,9 @@ 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( | ||||||
|                 y+=vStep*seriesCount(); |                     QRectF((-minValue() * hStep) + barsRect.left(), y, value * hStep, vStep)); | ||||||
|  |                 y += vStep * seriesCount(); | ||||||
|             } |             } | ||||||
|             curVOffset += vStep; |             curVOffset += vStep; | ||||||
|         } |         } | ||||||
| @@ -66,15 +64,17 @@ void HorizontalBarChart::paintHorizontalBars(QPainter *painter, QRectF barsRect) | |||||||
|             curVOffset += verticalOffset; |             curVOffset += verticalOffset; | ||||||
|         } |         } | ||||||
|         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( | ||||||
|             curVOffset+=vStep; |                 QRectF(barsRect.left(), curVOffset, designValues()[i] * hStep, vStep)); | ||||||
|  |             curVOffset += vStep; | ||||||
|             curColor++; |             curColor++; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     painter->restore(); |     painter->restore(); | ||||||
| } | } | ||||||
|  |  | ||||||
| } | } // namespace LimeReport | ||||||
|   | |||||||
| @@ -3,13 +3,13 @@ | |||||||
|  |  | ||||||
| #include "lrchartitem.h" | #include "lrchartitem.h" | ||||||
|  |  | ||||||
| namespace LimeReport{ | namespace LimeReport { | ||||||
|  |  | ||||||
| class HorizontalBarChart: public AbstractBarChart{ | class HorizontalBarChart: public AbstractBarChart { | ||||||
| public: | public: | ||||||
|     HorizontalBarChart(ChartItem* chartItem):AbstractBarChart(chartItem){} |     HorizontalBarChart(ChartItem* chartItem): AbstractBarChart(chartItem) { } | ||||||
|     void paintChart(QPainter *painter, QRectF chartRect); |     void paintChart(QPainter* painter, QRectF chartRect); | ||||||
|     void paintHorizontalBars(QPainter *painter, QRectF barsRect); |     void paintHorizontalBars(QPainter* painter, QRectF barsRect); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| } // namespace LimeReport | } // namespace LimeReport | ||||||
|   | |||||||
| @@ -2,7 +2,7 @@ | |||||||
|  |  | ||||||
| namespace LimeReport { | namespace LimeReport { | ||||||
|  |  | ||||||
| void LinesChart::paintChart(QPainter *painter, QRectF chartRect) | void LinesChart::paintChart(QPainter* painter, QRectF chartRect) | ||||||
| { | { | ||||||
|     updateMinAndMaxValues(); |     updateMinAndMaxValues(); | ||||||
|  |  | ||||||
| @@ -11,64 +11,47 @@ 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) + valuesVMargin, | ||||||
|             -(vPadding(chartRect) + barsShift) |                                         -(hPadding(chartRect) * 2), | ||||||
|         ) |                                         -(vPadding(chartRect) + barsShift))); | ||||||
|     ); |  | ||||||
|     paintSerialLines( |  | ||||||
|         painter, |  | ||||||
|         chartRect.adjusted( |  | ||||||
|             hPadding(chartRect) * 2 + valuesHMargin, |  | ||||||
|             vPadding(chartRect) + valuesVMargin, |  | ||||||
|             -(hPadding(chartRect) * 2), |  | ||||||
|             -(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, | ||||||
|     for (int i = 0; i < valuesCount()-1; ++i){ |                                 QRectF barsRect) | ||||||
|         QPoint startPoint = QPoint((i+1) * hStep + barsRect.left() - hStep/2, | { | ||||||
|                                    (maxValue() * vStep+topShift) - designValues()[i] * vStep |     for (int i = 0; i < valuesCount() - 1; ++i) { | ||||||
|                                    ); |         QPoint startPoint = QPoint((i + 1) * hStep + barsRect.left() - hStep / 2, | ||||||
|         QPoint endPoint = QPoint((i+2) * hStep + barsRect.left() - hStep/2, |                                    (maxValue() * vStep + topShift) - designValues()[i] * vStep); | ||||||
|                                  (maxValue() * vStep+topShift) - designValues()[i+1] * vStep |         QPoint endPoint = QPoint((i + 2) * hStep + barsRect.left() - hStep / 2, | ||||||
|                                  ); |                                  (maxValue() * vStep + topShift) - designValues()[i + 1] * vStep); | ||||||
|         drawSegment(painter, startPoint, endPoint, color_map[0]); |         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]); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| qreal LinesChart::calculatePos(const AxisData &data, qreal value, qreal rectSize) const | qreal LinesChart::calculatePos(const AxisData& data, qreal value, qreal rectSize) const | ||||||
| { | { | ||||||
|     if (data.type() == AxisData::XAxis || (data.reverseDirection() && data.rangeMin() >= 0)) { |     if (data.type() == AxisData::XAxis || (data.reverseDirection() && data.rangeMin() >= 0)) { | ||||||
|         // Not flipping for minimum less than 0 because lower number is at the bottom. |         // Not flipping for minimum less than 0 because lower number is at the bottom. | ||||||
| @@ -78,10 +61,10 @@ qreal LinesChart::calculatePos(const AxisData &data, qreal value, qreal rectSize | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void LinesChart::paintSeries(QPainter *painter, SeriesItem *series, QRectF barsRect) | void LinesChart::paintSeries(QPainter* painter, SeriesItem* series, QRectF barsRect) | ||||||
| { | { | ||||||
|     const AxisData &yAxisData = this->yAxisData(); |     const AxisData& yAxisData = this->yAxisData(); | ||||||
|     const AxisData &xAxisData = this->xAxisData(); |     const AxisData& xAxisData = this->xAxisData(); | ||||||
|  |  | ||||||
|     const qreal xAxisDiff = std::max(1.0, xAxisData.maxValue() - xAxisData.minValue()); |     const qreal xAxisDiff = std::max(1.0, xAxisData.maxValue() - xAxisData.minValue()); | ||||||
|     const qreal hStep = barsRect.width() / xAxisDiff; |     const qreal hStep = barsRect.width() / xAxisDiff; | ||||||
| @@ -91,17 +74,17 @@ void LinesChart::paintSeries(QPainter *painter, SeriesItem *series, QRectF barsR | |||||||
|     pen.setWidth(4); |     pen.setWidth(4); | ||||||
|     painter->setPen(pen); |     painter->setPen(pen); | ||||||
|  |  | ||||||
|     const QList<qreal> &values = series->data()->values(); |     const QList<qreal>& values = series->data()->values(); | ||||||
|  |  | ||||||
|     qreal lastYValue = 0; |     qreal lastYValue = 0; | ||||||
|     qreal lastXValue = barsRect.left() + hStep/2; |     qreal lastXValue = barsRect.left() + hStep / 2; | ||||||
|     if (!values.isEmpty()) { |     if (!values.isEmpty()) { | ||||||
|         // Calculate first point position on plot before loop |         // Calculate first point position on plot before loop | ||||||
|         lastYValue = calculatePos(yAxisData, values.first(), barsRect.height()); |         lastYValue = calculatePos(yAxisData, values.first(), barsRect.height()); | ||||||
|     } |     } | ||||||
|     for (int i = 0; i < values.count()-1; ++i ){ |     for (int i = 0; i < values.count() - 1; ++i) { | ||||||
|         const qreal startY = lastYValue; |         const qreal startY = lastYValue; | ||||||
|         const qreal endY = calculatePos(yAxisData, values.at(i+1), barsRect.height()); |         const qreal endY = calculatePos(yAxisData, values.at(i + 1), barsRect.height()); | ||||||
|         // Record last used Y position to only calculate new one |         // Record last used Y position to only calculate new one | ||||||
|         lastYValue = endY; |         lastYValue = endY; | ||||||
|  |  | ||||||
| @@ -118,13 +101,14 @@ 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); | ||||||
|  |  | ||||||
|     if (m_chartItem->itemMode() == DesignMode){ |     if (m_chartItem->itemMode() == DesignMode) { | ||||||
|         const AxisData &yAxisData = this->yAxisData(); |         const AxisData& yAxisData = this->yAxisData(); | ||||||
|         const qreal delta = yAxisData.delta(); |         const qreal delta = yAxisData.delta(); | ||||||
|         const qreal hStep = barsRect.width() / valuesCount(); |         const qreal hStep = barsRect.width() / valuesCount(); | ||||||
|         const qreal vStep = barsRect.height() / delta; |         const qreal vStep = barsRect.height() / delta; | ||||||
| @@ -134,12 +118,11 @@ void LinesChart::paintSerialLines(QPainter* painter, QRectF barsRect) | |||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     for (SeriesItem *series : m_chartItem->series()) { |     for (SeriesItem* series : m_chartItem->series()) { | ||||||
|         paintSeries(painter, series, barsRect); |         paintSeries(painter, series, barsRect); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     painter->restore(); |     painter->restore(); | ||||||
| } | } | ||||||
|  |  | ||||||
| } //namespace LimeReport | } // namespace LimeReport | ||||||
|  |  | ||||||
|   | |||||||
| @@ -4,18 +4,20 @@ | |||||||
| #include "lrchartitem.h" | #include "lrchartitem.h" | ||||||
|  |  | ||||||
| namespace LimeReport { | namespace LimeReport { | ||||||
| class LinesChart: public AbstractBarChart{ | 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, | ||||||
|     qreal calculatePos(const AxisData &data, qreal value, qreal rectSize) const; |                         QRectF barsRect); | ||||||
|     void paintSeries(QPainter *painter, SeriesItem *series, QRectF barsRect); |     qreal calculatePos(const AxisData& data, qreal value, qreal rectSize) const; | ||||||
|  |     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 | ||||||
|   | |||||||
| @@ -1,36 +1,36 @@ | |||||||
| #include "lrpiechart.h" | #include "lrpiechart.h" | ||||||
|  |  | ||||||
| namespace LimeReport{ | namespace LimeReport { | ||||||
|  |  | ||||||
| void PieChart::drawPercent(QPainter *painter, QRectF chartRect, qreal startAngle, qreal angle) | void PieChart::drawPercent(QPainter* painter, QRectF chartRect, qreal startAngle, qreal angle) | ||||||
| { | { | ||||||
|     painter->save(); |     painter->save(); | ||||||
|  |  | ||||||
|     QPointF center(chartRect.left()+chartRect.width()/2,chartRect.top()+chartRect.height()/2); |     QPointF center(chartRect.left() + chartRect.width() / 2, | ||||||
|     qreal percent = angle/3.6; |                    chartRect.top() + chartRect.height() / 2); | ||||||
|  |     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); | ||||||
| #else | #else | ||||||
|     qreal radAngle = qDegreesToRadians(angle/2+startAngle); |     qreal radAngle = qDegreesToRadians(angle / 2 + startAngle); | ||||||
| #endif | #endif | ||||||
|     qreal radius = painter->fontMetrics().boundingRect("99,9%").width(); |     qreal radius = painter->fontMetrics().boundingRect("99,9%").width(); | ||||||
|     qreal border = chartRect.height()*0.02; |     qreal border = chartRect.height() * 0.02; | ||||||
|     qreal length = (chartRect.height())/2-(radius/2+border); |     qreal length = (chartRect.height()) / 2 - (radius / 2 + border); | ||||||
|     qreal x,y; |     qreal x, y; | ||||||
|     x = length*qCos(radAngle); |     x = length * qCos(radAngle); | ||||||
|     y = length*qSin(radAngle); |     y = length * qSin(radAngle); | ||||||
|     QPointF endPoint(center.x()+x,center.y()-y); |     QPointF endPoint(center.x() + x, center.y() - y); | ||||||
|     painter->setPen(Qt::white); |     painter->setPen(Qt::white); | ||||||
|     QRectF textRect(endPoint.x()-(radius/2),endPoint.y()-(radius/2),radius,radius); |     QRectF textRect(endPoint.x() - (radius / 2), endPoint.y() - (radius / 2), radius, radius); | ||||||
|  |  | ||||||
|     qreal arcLength = 3.14 * length * angle / 180; |     qreal arcLength = 3.14 * length * angle / 180; | ||||||
|     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) | ||||||
| { | { | ||||||
|     painter->save(); |     painter->save(); | ||||||
|     QPen pen(Qt::white); |     QPen pen(Qt::white); | ||||||
| @@ -42,10 +42,10 @@ void PieChart::paintChart(QPainter *painter, QRectF chartRect) | |||||||
|     painter->setBackground(QBrush(Qt::NoBrush)); |     painter->setBackground(QBrush(Qt::NoBrush)); | ||||||
|  |  | ||||||
|     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,31 +53,32 @@ 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()) { | ||||||
|             sum+=value; |             sum += value; | ||||||
|         } |         } | ||||||
|         qreal onePercent = sum / 100; |         qreal onePercent = sum / 100; | ||||||
|         qreal currentDegree = 0; |         qreal currentDegree = 0; | ||||||
|         for(int i=0; i<si->data()->values().count(); ++i){ |         for (int i = 0; i < si->data()->values().count(); ++i) { | ||||||
|             qreal value = si->data()->values().at(i); |             qreal value = si->data()->values().at(i); | ||||||
|             qreal sectorDegree = (value/onePercent)*3.6; |             qreal sectorDegree = (value / onePercent) * 3.6; | ||||||
|             painter->setBrush(si->data()->colors().at(i)); |             painter->setBrush(si->data()->colors().at(i)); | ||||||
|             painter->drawPie(chartRect,currentDegree*16,sectorDegree*16); |             painter->drawPie(chartRect, currentDegree * 16, sectorDegree * 16); | ||||||
|             drawPercent(painter, chartRect, currentDegree, sectorDegree); |             drawPercent(painter, chartRect, currentDegree, sectorDegree); | ||||||
|             currentDegree += sectorDegree; |             currentDegree += sectorDegree; | ||||||
|         } |         } | ||||||
|     } else if (m_chartItem->itemMode() == DesignMode){ |     } else if (m_chartItem->itemMode() == DesignMode) { | ||||||
|         painter->setBrush(color_map[0]); |         painter->setBrush(color_map[0]); | ||||||
|         painter->drawPie(chartRect,0,260*16); |         painter->drawPie(chartRect, 0, 260 * 16); | ||||||
|         drawPercent(painter, chartRect, 0, 260); |         drawPercent(painter, chartRect, 0, 260); | ||||||
|         painter->setBrush(color_map[1]); |         painter->setBrush(color_map[1]); | ||||||
|         painter->drawPie(chartRect,260*16,40*16); |         painter->drawPie(chartRect, 260 * 16, 40 * 16); | ||||||
|         drawPercent(painter, chartRect, 260, 40); |         drawPercent(painter, chartRect, 260, 40); | ||||||
|         painter->setBrush(color_map[2]); |         painter->setBrush(color_map[2]); | ||||||
|         painter->drawPie(chartRect,300*16,60*16); |         painter->drawPie(chartRect, 300 * 16, 60 * 16); | ||||||
|         drawPercent(painter, chartRect, 300, 60); |         drawPercent(painter, chartRect, 300, 60); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -89,83 +90,77 @@ void PieChart::paintChart(QPainter *painter, QRectF chartRect) | |||||||
|     painter->restore(); |     painter->restore(); | ||||||
| } | } | ||||||
|  |  | ||||||
| void PieChart::paintChartLegend(QPainter *painter, QRectF legendRect) | void PieChart::paintChartLegend(QPainter* painter, QRectF legendRect) | ||||||
| { | { | ||||||
|     prepareLegendToPaint(legendRect, painter); |     prepareLegendToPaint(legendRect, painter); | ||||||
|  |  | ||||||
|     int indicatorSize = painter->fontMetrics().height()/2; |     int indicatorSize = painter->fontMetrics().height() / 2; | ||||||
|     painter->setRenderHint(QPainter::Antialiasing,false); |     painter->setRenderHint(QPainter::Antialiasing, false); | ||||||
|  |  | ||||||
|     if (m_chartItem->drawLegendBorder()) |     if (m_chartItem->drawLegendBorder()) | ||||||
|         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) { | ||||||
|         qreal cw = 0; |         qreal cw = 0; | ||||||
|         for (int i=0;i<m_designLabels.size();++i){ |         for (int i = 0; i < m_designLabels.size(); ++i) { | ||||||
|             QString label = m_designLabels.at(i); |             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(); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| QSizeF PieChart::calcChartLegendSize(const QFont &font, qreal) | QSizeF PieChart::calcChartLegendSize(const QFont& font, qreal) | ||||||
| { | { | ||||||
|     QFontMetrics fm(font); |     QFontMetrics fm(font); | ||||||
|  |  | ||||||
|     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(); | ||||||
|             if (maxWidth<fm.boundingRect(label).width()) |             if (maxWidth < fm.boundingRect(label).width()) | ||||||
|                 maxWidth = fm.boundingRect(label).width()+10; |                 maxWidth = fm.boundingRect(label).width() + 10; | ||||||
|         } |         } | ||||||
|     } else { |     } else { | ||||||
|         foreach(QString label, m_designLabels){ |         foreach (QString label, m_designLabels) { | ||||||
|             cw += fm.height(); |             cw += fm.height(); | ||||||
|             if (maxWidth<fm.boundingRect(label).width()) |             if (maxWidth < fm.boundingRect(label).width()) | ||||||
|                 maxWidth = fm.boundingRect(label).width()+10; |                 maxWidth = fm.boundingRect(label).width() + 10; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     cw += fm.height(); |     cw += fm.height(); | ||||||
|     return  QSizeF(maxWidth+fm.height()*2,cw); |     return QSizeF(maxWidth + fm.height() * 2, cw); | ||||||
| } | } | ||||||
|  |  | ||||||
| } | } // namespace LimeReport | ||||||
|   | |||||||
| @@ -3,16 +3,17 @@ | |||||||
|  |  | ||||||
| #include "lrchartitem.h" | #include "lrchartitem.h" | ||||||
|  |  | ||||||
| namespace LimeReport{ | namespace LimeReport { | ||||||
|  |  | ||||||
| class PieChart : public AbstractChart{ | class PieChart: public AbstractChart { | ||||||
| public: | public: | ||||||
|     PieChart(ChartItem* chartItem):AbstractChart(chartItem){} |     PieChart(ChartItem* chartItem): AbstractChart(chartItem) { } | ||||||
|     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); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| } // namespace LimeReport | } // namespace LimeReport | ||||||
|   | |||||||
| @@ -1,8 +1,8 @@ | |||||||
| #include "lrverticalbarchart.h" | #include "lrverticalbarchart.h" | ||||||
|  |  | ||||||
| namespace LimeReport{ | namespace LimeReport { | ||||||
|  |  | ||||||
| void VerticalBarChart::paintChart(QPainter *painter, QRectF chartRect) | void VerticalBarChart::paintChart(QPainter* painter, QRectF chartRect) | ||||||
| { | { | ||||||
|     updateMinAndMaxValues(); |     updateMinAndMaxValues(); | ||||||
|  |  | ||||||
| @@ -11,74 +11,61 @@ 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) + valuesVMargin, | ||||||
|             -(vPadding(chartRect) + barsShift) |                                          -hPadding(chartRect) * 2, | ||||||
|         ) |                                          -(vPadding(chartRect) + barsShift))); | ||||||
|     ); |     paintSerialLines(painter, | ||||||
|     paintVerticalBars( |                      chartRect.adjusted(hPadding(chartRect) * 2 + valuesHMargin, | ||||||
|         painter, |                                         vPadding(chartRect) + valuesVMargin, | ||||||
|         chartRect.adjusted( |                                         -hPadding(chartRect) * 2, | ||||||
|             hPadding(chartRect) * 2 + valuesHMargin, |                                         -(vPadding(chartRect) + barsShift))); | ||||||
|             vPadding(chartRect) + valuesVMargin, |  | ||||||
|             -hPadding(chartRect) * 2, |  | ||||||
|             -(vPadding(chartRect) + barsShift) |  | ||||||
|         ) |  | ||||||
|     ); |  | ||||||
|     paintSerialLines( |  | ||||||
|         painter, |  | ||||||
|         chartRect.adjusted( |  | ||||||
|             hPadding(chartRect) * 2 + valuesHMargin, |  | ||||||
|             vPadding(chartRect) + valuesVMargin, |  | ||||||
|             -hPadding(chartRect) * 2, |  | ||||||
|             -(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); | ||||||
|  |  | ||||||
|     qreal vStep = barsRect.height() / delta; |     qreal vStep = barsRect.height() / delta; | ||||||
|     qreal hStep = (barsRect.width() / valuesCount()) / (barSeriesCount == 0 ? 1 : barSeriesCount); |     qreal hStep = (barsRect.width() / valuesCount()) / (barSeriesCount == 0 ? 1 : barSeriesCount); | ||||||
|     qreal topShift = (delta - (maxValue() - minValue())) * vStep + barsRect.top(); |     qreal topShift = (delta - (maxValue() - minValue())) * vStep + barsRect.top(); | ||||||
|  |  | ||||||
|     if (!m_chartItem->series().isEmpty() && (m_chartItem->itemMode() != DesignMode)){ |     if (!m_chartItem->series().isEmpty() && (m_chartItem->itemMode() != DesignMode)) { | ||||||
|         int curSeries = 0; |         int curSeries = 0; | ||||||
|         foreach (SeriesItem* series, m_chartItem->series()) { |         foreach (SeriesItem* series, m_chartItem->series()) { | ||||||
|             if (series->preferredType() == SeriesItem::Bar){ |             if (series->preferredType() == SeriesItem::Bar) { | ||||||
|                 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++; | ||||||
| @@ -87,10 +74,12 @@ void VerticalBarChart::paintVerticalBars(QPainter *painter, QRectF barsRect) | |||||||
|     } else { |     } else { | ||||||
|         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,13 +89,14 @@ 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); | ||||||
|  |  | ||||||
|     for (SeriesItem *series : m_chartItem->series()) { |     for (SeriesItem* series : m_chartItem->series()) { | ||||||
|         if (series->preferredType() == SeriesItem::Line){ |         if (series->preferredType() == SeriesItem::Line) { | ||||||
|             paintSeries(painter, series, barsRect); |             paintSeries(painter, series, barsRect); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -3,17 +3,17 @@ | |||||||
|  |  | ||||||
| #include "lrlineschart.h" | #include "lrlineschart.h" | ||||||
|  |  | ||||||
| namespace LimeReport{ | namespace LimeReport { | ||||||
|  |  | ||||||
| class VerticalBarChart: public LinesChart{ | class VerticalBarChart: public LinesChart { | ||||||
| public: | public: | ||||||
|     VerticalBarChart(ChartItem* chartItem):LinesChart(chartItem){} |     VerticalBarChart(ChartItem* chartItem): LinesChart(chartItem) { } | ||||||
|     void paintChart(QPainter *painter, QRectF chartRect); |     void paintChart(QPainter* painter, QRectF chartRect); | ||||||
| //    void paintVerticalGrid(QPainter *painter, QRectF gridRect); |     //    void paintVerticalGrid(QPainter *painter, QRectF gridRect); | ||||||
|     void paintVerticalBars(QPainter *painter, QRectF barsRect); |     void paintVerticalBars(QPainter* painter, QRectF barsRect); | ||||||
|     void paintSerialLines(QPainter *painter, QRectF barsRect); |     void paintSerialLines(QPainter* painter, QRectF barsRect); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| } //namespace LimeReport | } // namespace LimeReport | ||||||
|  |  | ||||||
| #endif // VERTICALBARCHART_H | #endif // VERTICALBARCHART_H | ||||||
|   | |||||||
| @@ -29,10 +29,11 @@ | |||||||
|  ****************************************************************************/ |  ****************************************************************************/ | ||||||
| #include "lrfonteditorwidget.h" | #include "lrfonteditorwidget.h" | ||||||
|  |  | ||||||
| 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(); | ||||||
| } | } | ||||||
| @@ -40,91 +41,107 @@ FontEditorWidget::FontEditorWidget(const QString& title, QWidget* parent) | |||||||
| void FontEditorWidget::setItemEvent(BaseDesignIntf* item) | void FontEditorWidget::setItemEvent(BaseDesignIntf* item) | ||||||
| { | { | ||||||
|  |  | ||||||
|     QVariant font=item->property("font"); |     QVariant font = item->property("font"); | ||||||
|     if (font.isValid()){ |     if (font.isValid()) { | ||||||
|         updateValues(font.value<QFont>()); |         updateValues(font.value<QFont>()); | ||||||
|         setEnabled(true); |         setEnabled(true); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| void FontEditorWidget::initEditor() | void FontEditorWidget::initEditor() | ||||||
| { | { | ||||||
|     setIconSize(QSize(24,24)); |     setIconSize(QSize(24, 24)); | ||||||
|     setAllowedAreas(Qt::TopToolBarArea); |     setAllowedAreas(Qt::TopToolBarArea); | ||||||
|     setFloatable(false); |     setFloatable(false); | ||||||
|  |  | ||||||
|     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); | ||||||
|  |  | ||||||
|     addSeparator(); |     addSeparator(); | ||||||
|     setEnabled(false); |     setEnabled(false); | ||||||
|  |  | ||||||
|     m_fontBold = new QAction(tr("Font bold"),this); |     m_fontBold = new QAction(tr("Font bold"), this); | ||||||
|     m_fontBold->setIcon(QIcon(":/report/images/textBold")); |     m_fontBold->setIcon(QIcon(":/report/images/textBold")); | ||||||
|     m_fontBold->setCheckable(true); |     m_fontBold->setCheckable(true); | ||||||
|     connect(m_fontBold,SIGNAL(toggled(bool)),this,SLOT(slotFontAttribsChanged(bool))); |     connect(m_fontBold, SIGNAL(toggled(bool)), this, SLOT(slotFontAttribsChanged(bool))); | ||||||
|     addAction(m_fontBold); |     addAction(m_fontBold); | ||||||
|  |  | ||||||
|     m_fontItalic = new QAction(tr("Font Italic"),this); |     m_fontItalic = new QAction(tr("Font Italic"), this); | ||||||
|     m_fontItalic->setIcon(QIcon(":/report/images/textItalic")); |     m_fontItalic->setIcon(QIcon(":/report/images/textItalic")); | ||||||
|     m_fontItalic->setCheckable(true); |     m_fontItalic->setCheckable(true); | ||||||
|     connect(m_fontItalic,SIGNAL(toggled(bool)),this,SLOT(slotFontAttribsChanged(bool))); |     connect(m_fontItalic, SIGNAL(toggled(bool)), this, SLOT(slotFontAttribsChanged(bool))); | ||||||
|     addAction(m_fontItalic); |     addAction(m_fontItalic); | ||||||
|  |  | ||||||
|     m_fontUnderline = new QAction(tr("Font Underline"),this); |     m_fontUnderline = new QAction(tr("Font Underline"), this); | ||||||
|     m_fontUnderline->setIcon(QIcon(":/report/images/textUnderline")); |     m_fontUnderline->setIcon(QIcon(":/report/images/textUnderline")); | ||||||
|     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) | ||||||
| { | { | ||||||
|     m_ignoreSlots=true; |     m_ignoreSlots = true; | ||||||
|     m_fontNameEditor->setCurrentFont(font); |     m_fontNameEditor->setCurrentFont(font); | ||||||
|     m_fontSizeEditor->setEditText(QString::number(font.pointSize())); |     m_fontSizeEditor->setEditText(QString::number(font.pointSize())); | ||||||
|     m_fontBold->setChecked(font.bold()); |     m_fontBold->setChecked(font.bold()); | ||||||
|     m_fontItalic->setChecked(font.italic()); |     m_fontItalic->setChecked(font.italic()); | ||||||
|     m_fontUnderline->setChecked(font.underline()); |     m_fontUnderline->setChecked(font.underline()); | ||||||
|     m_ignoreSlots=false; |     m_ignoreSlots = false; | ||||||
| } |  | ||||||
|  |  | ||||||
| bool FontEditorWidget::ignoreSlots() const |  | ||||||
| { |  | ||||||
|     return m_ignoreSlots; |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  | bool FontEditorWidget::ignoreSlots() const { return m_ignoreSlots; } | ||||||
|  |  | ||||||
| void FontEditorWidget::slotFontChanged(const QFont& /*font*/) | void FontEditorWidget::slotFontChanged(const QFont& /*font*/) | ||||||
| { | { | ||||||
|      //if (page()) page()->setFont(font); |     // if (page()) page()->setFont(font); | ||||||
| } | } | ||||||
|  |  | ||||||
| void FontEditorWidget::slotFontSizeChanged(const QString &value) | void FontEditorWidget::slotFontSizeChanged(const QString& value) | ||||||
| { | { | ||||||
|     if (m_ignoreSlots) return; |     if (m_ignoreSlots) | ||||||
|  |         return; | ||||||
|     m_resFont = fontNameEditor()->currentFont(); |     m_resFont = 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,16 +149,16 @@ 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) | ||||||
|     if (item()&&(item()->objectName()==objectName)&&(property=="font")){ |     if (item() && (item()->objectName() == objectName) && (property == "font")) { | ||||||
|         updateValues(item()->property("font").value<QFont>()); |         updateValues(item()->property("font").value<QFont>()); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| void FontEditorWidgetForPage::slotFontChanged(const QFont& font) | void FontEditorWidgetForPage::slotFontChanged(const QFont& font) | ||||||
| { | { | ||||||
|     if (!ignoreSlots()) |     if (!ignoreSlots()) | ||||||
| @@ -150,7 +167,7 @@ void FontEditorWidgetForPage::slotFontChanged(const QFont& font) | |||||||
|  |  | ||||||
| void FontEditorWidgetForPage::slotFontSizeChanged(const QString& value) | void FontEditorWidgetForPage::slotFontSizeChanged(const QString& value) | ||||||
| { | { | ||||||
|     if (!ignoreSlots()){ |     if (!ignoreSlots()) { | ||||||
|         FontEditorWidget::slotFontSizeChanged(value); |         FontEditorWidget::slotFontSizeChanged(value); | ||||||
|         m_page->setFont(resFont()); |         m_page->setFont(resFont()); | ||||||
|     } |     } | ||||||
| @@ -158,7 +175,7 @@ void FontEditorWidgetForPage::slotFontSizeChanged(const QString& value) | |||||||
|  |  | ||||||
| void FontEditorWidgetForPage::slotFontAttribsChanged(bool value) | void FontEditorWidgetForPage::slotFontAttribsChanged(bool value) | ||||||
| { | { | ||||||
|     if (!ignoreSlots()){ |     if (!ignoreSlots()) { | ||||||
|         FontEditorWidget::slotFontAttribsChanged(value); |         FontEditorWidget::slotFontAttribsChanged(value); | ||||||
|         m_page->setFont(resFont()); |         m_page->setFont(resFont()); | ||||||
|     } |     } | ||||||
| @@ -167,18 +184,19 @@ 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) | ||||||
| { | { | ||||||
|     if (!ignoreSlots()){ |     if (!ignoreSlots()) { | ||||||
|         FontEditorWidget::slotFontSizeChanged(value); |         FontEditorWidget::slotFontSizeChanged(value); | ||||||
|         m_reportEditor->setFont(resFont()); |         m_reportEditor->setFont(resFont()); | ||||||
|     } |     } | ||||||
| @@ -186,7 +204,7 @@ void FontEditorWidgetForDesigner::slotFontSizeChanged(const QString& value) | |||||||
|  |  | ||||||
| void FontEditorWidgetForDesigner::slotFontAttribsChanged(bool value) | void FontEditorWidgetForDesigner::slotFontAttribsChanged(bool value) | ||||||
| { | { | ||||||
|     if (!ignoreSlots()){ |     if (!ignoreSlots()) { | ||||||
|         FontEditorWidget::slotFontAttribsChanged(value); |         FontEditorWidget::slotFontAttribsChanged(value); | ||||||
|         m_reportEditor->setFont(resFont()); |         m_reportEditor->setFont(resFont()); | ||||||
|     } |     } | ||||||
| @@ -194,5 +212,4 @@ void FontEditorWidgetForDesigner::slotFontAttribsChanged(bool value) | |||||||
|  |  | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | } // namespace LimeReport | ||||||
| } //namespace LimeReport |  | ||||||
|   | |||||||
| @@ -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" | ||||||
| @@ -41,27 +41,30 @@ | |||||||
|  |  | ||||||
| #include "lritemeditorwidget.h" | #include "lritemeditorwidget.h" | ||||||
|  |  | ||||||
| namespace LimeReport{ | namespace LimeReport { | ||||||
|  |  | ||||||
| class FontEditorWidget :public ItemEditorWidget{ | class FontEditorWidget: public ItemEditorWidget { | ||||||
|     Q_OBJECT |     Q_OBJECT | ||||||
| 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; } | ||||||
|     void initEditor(); |     void initEditor(); | ||||||
| protected slots: | 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, | ||||||
| protected: |                              const QVariant& oldValue, const QVariant& newValue); | ||||||
|     QFont resFont(){return m_resFont;} |  | ||||||
| private: |  | ||||||
|  |  | ||||||
|     void updateValues(const QFont &font); | protected: | ||||||
|  |     QFont resFont() { return m_resFont; } | ||||||
|  |  | ||||||
|  | private: | ||||||
|  |     void updateValues(const QFont& font); | ||||||
|  |  | ||||||
|     QFontComboBox* m_fontNameEditor; |     QFontComboBox* m_fontNameEditor; | ||||||
|     QComboBox* m_fontSizeEditor; |     QComboBox* m_fontSizeEditor; | ||||||
| @@ -73,28 +76,37 @@ 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; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| #ifdef HAVE_REPORT_DESIGNER | #ifdef HAVE_REPORT_DESIGNER | ||||||
| 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,11 +114,12 @@ 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; | ||||||
| }; | }; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| } //namespace LimeReport | } // namespace LimeReport | ||||||
|  |  | ||||||
| #endif // LRFONTEDITORWIDGET_H | #endif // LRFONTEDITORWIDGET_H | ||||||
|   | |||||||
| @@ -29,22 +29,24 @@ | |||||||
|  ****************************************************************************/ |  ****************************************************************************/ | ||||||
| #include "lritemeditorwidget.h" | #include "lritemeditorwidget.h" | ||||||
|  |  | ||||||
| namespace LimeReport{ | 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=item; |             m_item->disconnect(this); | ||||||
|         connect(m_item,SIGNAL(destroyed(QObject*)),this,SLOT(slotItemDestroyed(QObject*))); |         m_item = item; | ||||||
|         connect(m_item,SIGNAL(propertyChanged(QString,QVariant,QVariant)), |         connect(m_item, SIGNAL(destroyed(QObject*)), this, SLOT(slotItemDestroyed(QObject*))); | ||||||
|                 this,SLOT(slotPropertyChanged(QString,QVariant,QVariant))); |         connect(m_item, SIGNAL(propertyChanged(QString, QVariant, QVariant)), this, | ||||||
|  |                 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) | ||||||
| @@ -53,19 +55,16 @@ void ItemEditorWidget::properyChangedEvent(const QString& propertName, const QVa | |||||||
|  |  | ||||||
| void ItemEditorWidget::slotItemDestroyed(QObject* item) | void ItemEditorWidget::slotItemDestroyed(QObject* item) | ||||||
| { | { | ||||||
|     if (item==m_item) { |     if (item == m_item) { | ||||||
|         m_item = 0; |         m_item = 0; | ||||||
|         setEnabled(false); |         setEnabled(false); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void ItemEditorWidget::slotPropertyChanged(const QString& propertName, const QVariant& oldValue, const QVariant& newValue) | void ItemEditorWidget::slotPropertyChanged(const QString& propertName, const QVariant& oldValue, | ||||||
|  |                                            const QVariant& newValue) | ||||||
| { | { | ||||||
|     properyChangedEvent(propertName,oldValue,newValue); |     properyChangedEvent(propertName, oldValue, newValue); | ||||||
| } | } | ||||||
|  |  | ||||||
| } | } // namespace LimeReport | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -39,20 +39,26 @@ | |||||||
|  |  | ||||||
| namespace LimeReport { | 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), | ||||||
|     void setItem(BaseDesignIntf *item); |         m_item(0) | ||||||
|  |     { | ||||||
|  |     } | ||||||
|  |     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, | ||||||
|     BaseDesignIntf* item(){return m_item;} |                                      const QVariant& newValue); | ||||||
|  |     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; | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -29,143 +29,174 @@ | |||||||
|  ****************************************************************************/ |  ****************************************************************************/ | ||||||
| #include "lritemsaligneditorwidget.h" | #include "lritemsaligneditorwidget.h" | ||||||
|  |  | ||||||
| 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() | ||||||
| { | { | ||||||
|     m_bringToFront = new QAction(tr("Bring to top"),this); |     m_bringToFront = new QAction(tr("Bring to top"), this); | ||||||
|     m_bringToFront->setIcon(QIcon(":/report/images/bringToTop")); |     m_bringToFront->setIcon(QIcon(":/report/images/bringToTop")); | ||||||
|     connect(m_bringToFront,SIGNAL(triggered()),this,SLOT(slotBringToFront())); |     connect(m_bringToFront, SIGNAL(triggered()), this, SLOT(slotBringToFront())); | ||||||
|     addAction(m_bringToFront); |     addAction(m_bringToFront); | ||||||
|  |  | ||||||
|     m_sendToBack = new QAction(tr("Send to back"),this); |     m_sendToBack = new QAction(tr("Send to back"), this); | ||||||
|     m_sendToBack->setIcon(QIcon(":/report/images/sendToBack")); |     m_sendToBack->setIcon(QIcon(":/report/images/sendToBack")); | ||||||
|     connect(m_sendToBack,SIGNAL(triggered()),this,SLOT(slotSendToBack())); |     connect(m_sendToBack, SIGNAL(triggered()), this, SLOT(slotSendToBack())); | ||||||
|     addAction(m_sendToBack); |     addAction(m_sendToBack); | ||||||
|  |  | ||||||
|     m_alignToLeft = new QAction(tr("Align to left"),this); |     m_alignToLeft = new QAction(tr("Align to left"), this); | ||||||
|     m_alignToLeft->setIcon(QIcon(":/report/images/alignToLeft")); |     m_alignToLeft->setIcon(QIcon(":/report/images/alignToLeft")); | ||||||
|     connect(m_alignToLeft,SIGNAL(triggered()),this,SLOT(slotAlignToLeft())); |     connect(m_alignToLeft, SIGNAL(triggered()), this, SLOT(slotAlignToLeft())); | ||||||
|     addAction(m_alignToLeft); |     addAction(m_alignToLeft); | ||||||
|  |  | ||||||
|     m_alignToRight = new QAction(tr("Align to right"),this); |     m_alignToRight = new QAction(tr("Align to right"), this); | ||||||
|     m_alignToRight->setIcon(QIcon(":/report/images/alignToRight")); |     m_alignToRight->setIcon(QIcon(":/report/images/alignToRight")); | ||||||
|     connect(m_alignToRight,SIGNAL(triggered()),this,SLOT(slotAlignToRight())); |     connect(m_alignToRight, SIGNAL(triggered()), this, SLOT(slotAlignToRight())); | ||||||
|     addAction(m_alignToRight); |     addAction(m_alignToRight); | ||||||
|  |  | ||||||
|     m_alignToVCenter = new QAction(tr("Align to vertical center"),this); |     m_alignToVCenter = new QAction(tr("Align to vertical center"), this); | ||||||
|     m_alignToVCenter->setIcon(QIcon(":/report/images/alignToVCenter")); |     m_alignToVCenter->setIcon(QIcon(":/report/images/alignToVCenter")); | ||||||
|     connect(m_alignToVCenter,SIGNAL(triggered()),this,SLOT(slotAlignToVCenter())); |     connect(m_alignToVCenter, SIGNAL(triggered()), this, SLOT(slotAlignToVCenter())); | ||||||
|     addAction(m_alignToVCenter); |     addAction(m_alignToVCenter); | ||||||
|  |  | ||||||
|     m_alignToTop = new QAction(tr("Align to top"),this); |     m_alignToTop = new QAction(tr("Align to top"), this); | ||||||
|     m_alignToTop->setIcon(QIcon(":/report/images/alignToTop")); |     m_alignToTop->setIcon(QIcon(":/report/images/alignToTop")); | ||||||
|     connect(m_alignToTop,SIGNAL(triggered()),this,SLOT(slotAlignToTop())); |     connect(m_alignToTop, SIGNAL(triggered()), this, SLOT(slotAlignToTop())); | ||||||
|     addAction(m_alignToTop); |     addAction(m_alignToTop); | ||||||
|  |  | ||||||
|     m_alignToBottom = new QAction(tr("Align to bottom"),this); |     m_alignToBottom = new QAction(tr("Align to bottom"), this); | ||||||
|     m_alignToBottom->setIcon(QIcon(":/report/images/alignToBottom")); |     m_alignToBottom->setIcon(QIcon(":/report/images/alignToBottom")); | ||||||
|     connect(m_alignToBottom,SIGNAL(triggered()),this,SLOT(slotAlignToBottom())); |     connect(m_alignToBottom, SIGNAL(triggered()), this, SLOT(slotAlignToBottom())); | ||||||
|     addAction(m_alignToBottom); |     addAction(m_alignToBottom); | ||||||
|  |  | ||||||
|     m_alignToHCenter = new QAction(tr("Align to horizontal center"),this); |     m_alignToHCenter = new QAction(tr("Align to horizontal center"), this); | ||||||
|     m_alignToHCenter->setIcon(QIcon(":/report/images/alignToHCenter")); |     m_alignToHCenter->setIcon(QIcon(":/report/images/alignToHCenter")); | ||||||
|     connect(m_alignToHCenter,SIGNAL(triggered()),this,SLOT(slotAlignToHCenter())); |     connect(m_alignToHCenter, SIGNAL(triggered()), this, SLOT(slotAlignToHCenter())); | ||||||
|     addAction(m_alignToHCenter); |     addAction(m_alignToHCenter); | ||||||
|  |  | ||||||
|     m_sameHeight = new QAction(tr("Set same height"),this); |     m_sameHeight = new QAction(tr("Set same height"), this); | ||||||
|     m_sameHeight->setIcon(QIcon(":/report/images/sameHeight")); |     m_sameHeight->setIcon(QIcon(":/report/images/sameHeight")); | ||||||
|     connect(m_sameHeight,SIGNAL(triggered()),this,SLOT(slotSameHeight())); |     connect(m_sameHeight, SIGNAL(triggered()), this, SLOT(slotSameHeight())); | ||||||
|     addAction(m_sameHeight); |     addAction(m_sameHeight); | ||||||
|  |  | ||||||
|     m_sameWidth = new QAction(tr("Set same width"),this); |     m_sameWidth = new QAction(tr("Set same width"), this); | ||||||
|     m_sameWidth->setIcon(QIcon(":/report/images/sameWidth")); |     m_sameWidth->setIcon(QIcon(":/report/images/sameWidth")); | ||||||
|     connect(m_sameWidth,SIGNAL(triggered()),this,SLOT(slotSameWidth())); |     connect(m_sameWidth, SIGNAL(triggered()), this, SLOT(slotSameWidth())); | ||||||
|     addAction(m_sameWidth); |     addAction(m_sameWidth); | ||||||
| } | } | ||||||
|  |  | ||||||
| } //namespace LimeReport | } // namespace LimeReport | ||||||
|   | |||||||
| @@ -31,19 +31,21 @@ | |||||||
| #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, | ||||||
|     explicit ItemsAlignmentEditorWidget(ReportDesignWidget* reportEditor, QWidget *parent = 0); |                                         QWidget* parent = 0); | ||||||
|     explicit ItemsAlignmentEditorWidget(PageDesignIntf* page, const QString &title, QWidget *parent = 0); |     explicit ItemsAlignmentEditorWidget(ReportDesignWidget* reportEditor, QWidget* parent = 0); | ||||||
|     explicit ItemsAlignmentEditorWidget(PageDesignIntf* page, QWidget *parent = 0); |     explicit ItemsAlignmentEditorWidget(PageDesignIntf* page, const QString& title, | ||||||
|  |                                         QWidget* parent = 0); | ||||||
|  |     explicit ItemsAlignmentEditorWidget(PageDesignIntf* page, QWidget* parent = 0); | ||||||
| private slots: | private slots: | ||||||
|     void slotBringToFront(); |     void slotBringToFront(); | ||||||
|     void slotSendToBack(); |     void slotSendToBack(); | ||||||
| @@ -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; | ||||||
| @@ -72,6 +75,6 @@ private: | |||||||
|     QAction* m_sameWidth; |     QAction* m_sameWidth; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| } //namespace LimeReport | } // namespace LimeReport | ||||||
|  |  | ||||||
| #endif // LRITEMSALIGNEDITORWIDGET_H | #endif // LRITEMSALIGNEDITORWIDGET_H | ||||||
|   | |||||||
| @@ -28,57 +28,56 @@ | |||||||
|  *   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" | ||||||
| namespace LimeReport{ |  | ||||||
|  | #include <QAction> | ||||||
|  | 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; | ||||||
|     } |     } | ||||||
|     QVariant borders=item->property("borders"); |     QVariant borders = item->property("borders"); | ||||||
|     if (borders.isValid()){ |     if (borders.isValid()) { | ||||||
|         updateValues((BaseDesignIntf::BorderLines)borders.toInt()); |         updateValues((BaseDesignIntf::BorderLines)borders.toInt()); | ||||||
|         setEnabled(true); |         setEnabled(true); | ||||||
|     } |     } | ||||||
|     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") { | ||||||
|         m_changing = true; |         m_changing = true; | ||||||
|         updateValues((BaseDesignIntf::BorderLines)newValue.toInt()); |         updateValues((BaseDesignIntf::BorderLines)newValue.toInt()); | ||||||
|         m_changing = false; |         m_changing = false; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| 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); | ||||||
| } | } | ||||||
|  |  | ||||||
| void ItemsBordersEditorWidget::buttonClicked(bool){} | void ItemsBordersEditorWidget::buttonClicked(bool) { } | ||||||
|  |  | ||||||
| void ItemsBordersEditorWidget::editBorderClicked() | 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()); | ||||||
| @@ -89,49 +88,48 @@ void ItemsBordersEditorWidget::editBorderClicked() | |||||||
| void ItemsBordersEditorWidget::initEditor() | void ItemsBordersEditorWidget::initEditor() | ||||||
| { | { | ||||||
|  |  | ||||||
|     m_topLine = new QAction(tr("Top line"),this); |     m_topLine = new QAction(tr("Top line"), this); | ||||||
|     m_topLine->setIcon(QIcon(":/report/images/topLine")); |     m_topLine->setIcon(QIcon(":/report/images/topLine")); | ||||||
|     m_topLine->setCheckable(true); |     m_topLine->setCheckable(true); | ||||||
|     connect(m_topLine,SIGNAL(toggled(bool)),this,SLOT(buttonClicked(bool))); |     connect(m_topLine, SIGNAL(toggled(bool)), this, SLOT(buttonClicked(bool))); | ||||||
|     addAction(m_topLine); |     addAction(m_topLine); | ||||||
|  |  | ||||||
|     m_bottomLine = new QAction(tr("Bottom line"),this); |     m_bottomLine = new QAction(tr("Bottom line"), this); | ||||||
|     m_bottomLine->setIcon(QIcon(":/report/images/bottomLine")); |     m_bottomLine->setIcon(QIcon(":/report/images/bottomLine")); | ||||||
|     m_bottomLine->setCheckable(true); |     m_bottomLine->setCheckable(true); | ||||||
|     connect(m_bottomLine,SIGNAL(toggled(bool)),this,SLOT(buttonClicked(bool))); |     connect(m_bottomLine, SIGNAL(toggled(bool)), this, SLOT(buttonClicked(bool))); | ||||||
|     addAction(m_bottomLine); |     addAction(m_bottomLine); | ||||||
|  |  | ||||||
|     m_leftLine = new QAction(tr("Left line"),this); |     m_leftLine = new QAction(tr("Left line"), this); | ||||||
|     m_leftLine->setIcon(QIcon(":/report/images/leftLine")); |     m_leftLine->setIcon(QIcon(":/report/images/leftLine")); | ||||||
|     m_leftLine->setCheckable(true); |     m_leftLine->setCheckable(true); | ||||||
|     connect(m_leftLine,SIGNAL(toggled(bool)),this,SLOT(buttonClicked(bool))); |     connect(m_leftLine, SIGNAL(toggled(bool)), this, SLOT(buttonClicked(bool))); | ||||||
|     addAction(m_leftLine); |     addAction(m_leftLine); | ||||||
|  |  | ||||||
|     m_rightLine = new QAction(tr("Right line"),this); |     m_rightLine = new QAction(tr("Right line"), this); | ||||||
|     m_rightLine->setIcon(QIcon(":/report/images/rightLine")); |     m_rightLine->setIcon(QIcon(":/report/images/rightLine")); | ||||||
|     m_rightLine->setCheckable(true); |     m_rightLine->setCheckable(true); | ||||||
|     connect(m_rightLine,SIGNAL(toggled(bool)),this,SLOT(buttonClicked(bool))); |     connect(m_rightLine, SIGNAL(toggled(bool)), this, SLOT(buttonClicked(bool))); | ||||||
|     addAction(m_rightLine); |     addAction(m_rightLine); | ||||||
|  |  | ||||||
|     addSeparator(); |     addSeparator(); | ||||||
|  |  | ||||||
|     m_noLines = new QAction(tr("No borders"),this); |     m_noLines = new QAction(tr("No borders"), this); | ||||||
|     m_noLines->setIcon(QIcon(":/report/images/noLines")); |     m_noLines->setIcon(QIcon(":/report/images/noLines")); | ||||||
|     connect(m_noLines,SIGNAL(triggered()),this,SLOT(noBordesClicked())); |     connect(m_noLines, SIGNAL(triggered()), this, SLOT(noBordesClicked())); | ||||||
|     addAction(m_noLines); |     addAction(m_noLines); | ||||||
|  |  | ||||||
|     m_allLines = new QAction(tr("All borders"),this); |     m_allLines = new QAction(tr("All borders"), this); | ||||||
|     m_allLines->setIcon(QIcon(":/report/images/allLines")); |     m_allLines->setIcon(QIcon(":/report/images/allLines")); | ||||||
|     connect(m_allLines,SIGNAL(triggered()),this,SLOT(allBordesClicked())); |     connect(m_allLines, SIGNAL(triggered()), this, SLOT(allBordesClicked())); | ||||||
|     addAction(m_allLines); |     addAction(m_allLines); | ||||||
|     addSeparator(); |     addSeparator(); | ||||||
|     m_BorderEditor = new QAction(tr("Edit border"),this); |     m_BorderEditor = new QAction(tr("Edit border"), this); | ||||||
|     m_BorderEditor->setIcon(QIcon(":/report/images/borderEditor")); |     m_BorderEditor->setIcon(QIcon(":/report/images/borderEditor")); | ||||||
|     connect(m_BorderEditor,SIGNAL(triggered()),this,SLOT(editBorderClicked())); |     connect(m_BorderEditor, SIGNAL(triggered()), this, SLOT(editBorderClicked())); | ||||||
|     addAction(m_BorderEditor); |     addAction(m_BorderEditor); | ||||||
|  |  | ||||||
|     setEnabled(false); |     setEnabled(false); | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| void ItemsBordersEditorWidget::updateValues(BaseDesignIntf::BorderLines borders) | void ItemsBordersEditorWidget::updateValues(BaseDesignIntf::BorderLines borders) | ||||||
| @@ -147,17 +145,14 @@ void ItemsBordersEditorWidget::updateValues(BaseDesignIntf::BorderLines borders) | |||||||
| BaseDesignIntf::BorderLines ItemsBordersEditorWidget::createBorders() | BaseDesignIntf::BorderLines ItemsBordersEditorWidget::createBorders() | ||||||
| { | { | ||||||
|     int borders = 0; |     int borders = 0; | ||||||
|     borders += (m_topLine->isChecked()) ? BaseDesignIntf::TopLine:0; |     borders += (m_topLine->isChecked()) ? BaseDesignIntf::TopLine : 0; | ||||||
|     borders += (m_bottomLine->isChecked()) ? BaseDesignIntf::BottomLine:0; |     borders += (m_bottomLine->isChecked()) ? BaseDesignIntf::BottomLine : 0; | ||||||
|     borders += (m_leftLine->isChecked()) ? BaseDesignIntf::LeftLine:0; |     borders += (m_leftLine->isChecked()) ? BaseDesignIntf::LeftLine : 0; | ||||||
|     borders += (m_rightLine->isChecked()) ? BaseDesignIntf::RightLine:0; |     borders += (m_rightLine->isChecked()) ? BaseDesignIntf::RightLine : 0; | ||||||
|     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,16 +177,14 @@ 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(), |                                   (LimeReport::BaseDesignIntf::BorderStyle)be.borderStyle(), | ||||||
|                 be.borderWidth(), |                                   be.borderColor()); | ||||||
|                 (LimeReport::BaseDesignIntf::BorderStyle)be.borderStyle(), |  | ||||||
|                 be.borderColor() |  | ||||||
|     ); |  | ||||||
| } | } | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| } //namespace LimeReport | } // namespace LimeReport | ||||||
|   | |||||||
| @@ -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" | ||||||
|  |  | ||||||
| namespace LimeReport{ | #include <QToolBar> | ||||||
|  |  | ||||||
| class ItemsBordersEditorWidget : public ItemEditorWidget | namespace LimeReport { | ||||||
| { |  | ||||||
|  | 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,26 +73,29 @@ 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 | ||||||
|  |  | ||||||
| }//namespace LimeReport | } // namespace LimeReport | ||||||
|  |  | ||||||
| #endif // LRITEMSBORDERSEDITORWIDGET_H | #endif // LRITEMSBORDERSEDITORWIDGET_H | ||||||
|   | |||||||
| @@ -29,17 +29,19 @@ | |||||||
|  ****************************************************************************/ |  ****************************************************************************/ | ||||||
| #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(); | ||||||
| } | } | ||||||
|  |  | ||||||
| void TextAlignmentEditorWidget::setItemEvent(BaseDesignIntf *item) | void TextAlignmentEditorWidget::setItemEvent(BaseDesignIntf* item) | ||||||
| { | { | ||||||
|     QVariant align=item->property("alignment"); |     QVariant align = item->property("alignment"); | ||||||
|     if (align.isValid()){ |     if (align.isValid()) { | ||||||
|         updateValues(Qt::Alignment(align.value<int>())); |         updateValues(Qt::Alignment(align.value<int>())); | ||||||
|         setEnabled(true); |         setEnabled(true); | ||||||
|     } |     } | ||||||
| @@ -47,178 +49,197 @@ void TextAlignmentEditorWidget::setItemEvent(BaseDesignIntf *item) | |||||||
|  |  | ||||||
| void TextAlignmentEditorWidget::initEditor() | void TextAlignmentEditorWidget::initEditor() | ||||||
| { | { | ||||||
|     m_textAliginLeft = new QAction(tr("Text align left"),this); |     m_textAliginLeft = new QAction(tr("Text align left"), this); | ||||||
|     m_textAliginLeft->setIcon(QIcon(":/report/images/textAlignHLeft")); |     m_textAliginLeft->setIcon(QIcon(":/report/images/textAlignHLeft")); | ||||||
|     m_textAliginLeft->setCheckable(true); |     m_textAliginLeft->setCheckable(true); | ||||||
|     connect(m_textAliginLeft,SIGNAL(toggled(bool)),this,SLOT(slotTextHAttribsChanged(bool))); |     connect(m_textAliginLeft, SIGNAL(toggled(bool)), this, SLOT(slotTextHAttribsChanged(bool))); | ||||||
|     addAction(m_textAliginLeft); |     addAction(m_textAliginLeft); | ||||||
|  |  | ||||||
|     m_textAliginHCenter = new QAction(tr("Text align center"),this); |     m_textAliginHCenter = new QAction(tr("Text align center"), this); | ||||||
|     m_textAliginHCenter->setIcon(QIcon(":/report/images/textAlignHCenter")); |     m_textAliginHCenter->setIcon(QIcon(":/report/images/textAlignHCenter")); | ||||||
|     m_textAliginHCenter->setCheckable(true); |     m_textAliginHCenter->setCheckable(true); | ||||||
|     connect(m_textAliginHCenter,SIGNAL(toggled(bool)),this,SLOT(slotTextHAttribsChanged(bool))); |     connect(m_textAliginHCenter, SIGNAL(toggled(bool)), this, SLOT(slotTextHAttribsChanged(bool))); | ||||||
|     addAction(m_textAliginHCenter); |     addAction(m_textAliginHCenter); | ||||||
|  |  | ||||||
|     m_textAliginRight = new QAction(tr("Text align right"),this); |     m_textAliginRight = new QAction(tr("Text align right"), this); | ||||||
|     m_textAliginRight->setIcon(QIcon(":/report/images/textAlignHRight")); |     m_textAliginRight->setIcon(QIcon(":/report/images/textAlignHRight")); | ||||||
|     m_textAliginRight->setCheckable(true); |     m_textAliginRight->setCheckable(true); | ||||||
|     connect(m_textAliginRight,SIGNAL(toggled(bool)),this,SLOT(slotTextHAttribsChanged(bool))); |     connect(m_textAliginRight, SIGNAL(toggled(bool)), this, SLOT(slotTextHAttribsChanged(bool))); | ||||||
|     addAction(m_textAliginRight); |     addAction(m_textAliginRight); | ||||||
|  |  | ||||||
|     m_textAliginJustify = new QAction(tr("Text align justify"),this); |     m_textAliginJustify = new QAction(tr("Text align justify"), this); | ||||||
|     m_textAliginJustify->setIcon(QIcon(":/report/images/textAlignHJustify")); |     m_textAliginJustify->setIcon(QIcon(":/report/images/textAlignHJustify")); | ||||||
|     m_textAliginJustify->setCheckable(true); |     m_textAliginJustify->setCheckable(true); | ||||||
|     connect(m_textAliginJustify,SIGNAL(toggled(bool)),this,SLOT(slotTextHAttribsChanged(bool))); |     connect(m_textAliginJustify, SIGNAL(toggled(bool)), this, SLOT(slotTextHAttribsChanged(bool))); | ||||||
|     addAction(m_textAliginJustify); |     addAction(m_textAliginJustify); | ||||||
|  |  | ||||||
|     addSeparator(); |     addSeparator(); | ||||||
|  |  | ||||||
|     m_textAliginTop = new QAction(tr("Text align top"),this); |     m_textAliginTop = new QAction(tr("Text align top"), this); | ||||||
|     m_textAliginTop->setIcon(QIcon(":/report/images/textAlignVTop")); |     m_textAliginTop->setIcon(QIcon(":/report/images/textAlignVTop")); | ||||||
|     m_textAliginTop->setCheckable(true); |     m_textAliginTop->setCheckable(true); | ||||||
|     connect(m_textAliginTop,SIGNAL(toggled(bool)),this,SLOT(slotTextVAttribsChanged(bool))); |     connect(m_textAliginTop, SIGNAL(toggled(bool)), this, SLOT(slotTextVAttribsChanged(bool))); | ||||||
|     addAction(m_textAliginTop); |     addAction(m_textAliginTop); | ||||||
|  |  | ||||||
|     m_textAliginVCenter = new QAction(tr("Text align center"),this); |     m_textAliginVCenter = new QAction(tr("Text align center"), this); | ||||||
|     m_textAliginVCenter->setIcon(QIcon(":/report/images/textAlignVCenter")); |     m_textAliginVCenter->setIcon(QIcon(":/report/images/textAlignVCenter")); | ||||||
|     m_textAliginVCenter->setCheckable(true); |     m_textAliginVCenter->setCheckable(true); | ||||||
|     connect(m_textAliginVCenter,SIGNAL(toggled(bool)),this,SLOT(slotTextVAttribsChanged(bool))); |     connect(m_textAliginVCenter, SIGNAL(toggled(bool)), this, SLOT(slotTextVAttribsChanged(bool))); | ||||||
|     addAction(m_textAliginVCenter); |     addAction(m_textAliginVCenter); | ||||||
|  |  | ||||||
|     m_textAliginBottom = new QAction(tr("Text align bottom"),this); |     m_textAliginBottom = new QAction(tr("Text align bottom"), this); | ||||||
|     m_textAliginBottom->setIcon(QIcon(":/report/images/textAlignVBottom")); |     m_textAliginBottom->setIcon(QIcon(":/report/images/textAlignVBottom")); | ||||||
|     m_textAliginBottom->setCheckable(true); |     m_textAliginBottom->setCheckable(true); | ||||||
|     connect(m_textAliginBottom,SIGNAL(toggled(bool)),this,SLOT(slotTextVAttribsChanged(bool))); |     connect(m_textAliginBottom, SIGNAL(toggled(bool)), this, SLOT(slotTextVAttribsChanged(bool))); | ||||||
|     addAction(m_textAliginBottom); |     addAction(m_textAliginBottom); | ||||||
|     setEnabled(false); |     setEnabled(false); | ||||||
| } | } | ||||||
|  |  | ||||||
| void TextAlignmentEditorWidget::updateValues(const Qt::Alignment &align) | void TextAlignmentEditorWidget::updateValues(const Qt::Alignment& align) | ||||||
| { | { | ||||||
|     m_textAttibutesIsChanging=true; |     m_textAttibutesIsChanging = true; | ||||||
|     m_textAliginLeft->setChecked((align & Qt::AlignLeft)==Qt::AlignLeft); |     m_textAliginLeft->setChecked((align & Qt::AlignLeft) == Qt::AlignLeft); | ||||||
|     m_textAliginRight->setChecked((align & Qt::AlignRight)==Qt::AlignRight); |     m_textAliginRight->setChecked((align & Qt::AlignRight) == Qt::AlignRight); | ||||||
|     m_textAliginHCenter->setChecked((align & Qt::AlignHCenter)==Qt::AlignHCenter); |     m_textAliginHCenter->setChecked((align & Qt::AlignHCenter) == Qt::AlignHCenter); | ||||||
|     m_textAliginJustify->setChecked((align & Qt::AlignJustify)==Qt::AlignJustify); |     m_textAliginJustify->setChecked((align & Qt::AlignJustify) == Qt::AlignJustify); | ||||||
|     m_textAliginTop->setChecked((align & Qt::AlignTop)==Qt::AlignTop); |     m_textAliginTop->setChecked((align & Qt::AlignTop) == Qt::AlignTop); | ||||||
|     m_textAliginVCenter->setChecked((align & Qt::AlignVCenter)==Qt::AlignVCenter); |     m_textAliginVCenter->setChecked((align & Qt::AlignVCenter) == Qt::AlignVCenter); | ||||||
|     m_textAliginBottom->setChecked((align & Qt::AlignBottom)==Qt::AlignBottom); |     m_textAliginBottom->setChecked((align & Qt::AlignBottom) == Qt::AlignBottom); | ||||||
|     m_textAttibutesIsChanging=false; |     m_textAttibutesIsChanging = false; | ||||||
| } | } | ||||||
|  |  | ||||||
| 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); | ||||||
|     m_textAliginHCenter->setChecked(sender()==m_textAliginHCenter); |     m_textAliginHCenter->setChecked(sender() == m_textAliginHCenter); | ||||||
|     m_textAliginRight->setChecked(sender()==m_textAliginRight); |     m_textAliginRight->setChecked(sender() == m_textAliginRight); | ||||||
|     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); | ||||||
|     m_textAliginVCenter->setChecked(sender()==m_textAliginVCenter); |     m_textAliginVCenter->setChecked(sender() == m_textAliginVCenter); | ||||||
|     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) | ||||||
|  |  | ||||||
|     if (item()&&(item()->objectName()==objectName)&&(property=="alignment")){ |     if (item() && (item()->objectName() == objectName) && (property == "alignment")) { | ||||||
|         updateValues(Qt::Alignment(item()->property("alignment").value<int>())); |         updateValues(Qt::Alignment(item()->property("alignment").value<int>())); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| 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; | ||||||
| } | } | ||||||
|  |  | ||||||
| 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; | ||||||
| } | } | ||||||
|  |  | ||||||
| #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; | ||||||
| } | } | ||||||
|  |  | ||||||
| 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; | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| } //namespace LimeReport | } // namespace LimeReport | ||||||
|   | |||||||
| @@ -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; | ||||||
| @@ -65,36 +69,49 @@ private: | |||||||
|     int m_flag; |     int m_flag; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| 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; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| #ifdef HAVE_REPORT_DESIGNER | #ifdef HAVE_REPORT_DESIGNER | ||||||
| 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; | ||||||
| }; | }; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| } //namespace LimeReport | } // namespace LimeReport | ||||||
|  |  | ||||||
| #endif // LRTEXTALIGNMENTEDITORWIDGET_H | #endif // LRTEXTALIGNMENTEDITORWIDGET_H | ||||||
|   | |||||||
| @@ -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); | ||||||
| @@ -58,13 +48,13 @@ void AbstractLayout::addChild(BaseDesignIntf* item, bool updateSize) | |||||||
|  |  | ||||||
|     connectToLayout(item); |     connectToLayout(item); | ||||||
|  |  | ||||||
|     if (updateSize){ |     if (updateSize) { | ||||||
|         relocateChildren(); |         relocateChildren(); | ||||||
|         updateLayoutSize(); |         updateLayoutSize(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void AbstractLayout::removeChild(BaseDesignIntf *item) | void AbstractLayout::removeChild(BaseDesignIntf* item) | ||||||
| { | { | ||||||
|     if (!item) { |     if (!item) { | ||||||
|         return; |         return; | ||||||
| @@ -75,8 +65,9 @@ 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)) | ||||||
|     m_isRelocating=true; |         return; | ||||||
|  |     m_isRelocating = true; | ||||||
|  |  | ||||||
|     insertItemInLayout(item); |     insertItemInLayout(item); | ||||||
|  |  | ||||||
| @@ -88,7 +79,7 @@ void AbstractLayout::restoreChild(BaseDesignIntf* item) | |||||||
|     item->setParentItem(this); |     item->setParentItem(this); | ||||||
|  |  | ||||||
|     updateLayoutSize(); |     updateLayoutSize(); | ||||||
|     m_isRelocating=false; |     m_isRelocating = false; | ||||||
| } | } | ||||||
|  |  | ||||||
| bool AbstractLayout::isEmpty() const | bool AbstractLayout::isEmpty() const | ||||||
| @@ -97,54 +88,49 @@ 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; | ||||||
|     } |     } | ||||||
|     return (isEmpty && allItemsIsText); |     return (isEmpty && allItemsIsText); | ||||||
| } | } | ||||||
|  |  | ||||||
| void AbstractLayout::paintChild(BaseDesignIntf *child, QPointF parentPos, QPainter *painter) | void AbstractLayout::paintChild(BaseDesignIntf* child, QPointF parentPos, QPainter* painter) | ||||||
| { | { | ||||||
|     if (!child->childBaseItems().isEmpty()){ |     if (!child->childBaseItems().isEmpty()) { | ||||||
|         foreach (BaseDesignIntf* item, child->childBaseItems()) { |         foreach (BaseDesignIntf* item, child->childBaseItems()) { | ||||||
|             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(); | ||||||
|         painter->setPen(Qt::red); |         painter->setPen(Qt::red); | ||||||
|         foreach( BaseDesignIntf* item, m_children){ |         foreach (BaseDesignIntf* item, m_children) { | ||||||
|             paintChild(item, QPointF(0,0), painter); |             paintChild(item, QPointF(0, 0), painter); | ||||||
|         } |         } | ||||||
|         painter->restore(); |         painter->restore(); | ||||||
|     } |     } | ||||||
|     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() | ||||||
| { | { | ||||||
| #ifdef HAVE_QT5 | #ifdef HAVE_QT5 | ||||||
|     foreach (QObject *item, children()) { |     foreach (QObject* item, children()) { | ||||||
| #else | #else | ||||||
|     foreach (QObject *item, QObject::children()) { |     foreach (QObject* item, QObject::children()) { | ||||||
| #endif | #endif | ||||||
|         BaseDesignIntf *bi = dynamic_cast<BaseDesignIntf*>(item); |         BaseDesignIntf* bi = dynamic_cast<BaseDesignIntf*>(item); | ||||||
|         if (bi) { |         if (bi) { | ||||||
|             bi->disconnect(this); |             bi->disconnect(this); | ||||||
|             bi->setParentItem(parentItem()); |             bi->setParentItem(parentItem()); | ||||||
| @@ -158,16 +144,13 @@ 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) | ||||||
| { | { | ||||||
|     layoutMarker()->setHeight(newRect.height()); |     layoutMarker()->setHeight(newRect.height()); | ||||||
|     relocateChildren(); |     relocateChildren(); | ||||||
|     if (!isRelocating()){ |     if (!isRelocating()) { | ||||||
|         divideSpace(); |         divideSpace(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @@ -175,7 +158,7 @@ void AbstractLayout::geometryChangedEvent(QRectF newRect, QRectF) | |||||||
| void AbstractLayout::initMode(BaseDesignIntf::ItemMode mode) | void AbstractLayout::initMode(BaseDesignIntf::ItemMode mode) | ||||||
| { | { | ||||||
|     BaseDesignIntf::initMode(mode); |     BaseDesignIntf::initMode(mode); | ||||||
|     if ((mode==PreviewMode)||(mode==PrintMode)){ |     if ((mode == PreviewMode) || (mode == PrintMode)) { | ||||||
|         layoutMarker()->setVisible(false); |         layoutMarker()->setVisible(false); | ||||||
|     } else { |     } else { | ||||||
|         layoutMarker()->setVisible(true); |         layoutMarker()->setVisible(true); | ||||||
| @@ -185,22 +168,22 @@ void AbstractLayout::initMode(BaseDesignIntf::ItemMode mode) | |||||||
| void AbstractLayout::setBorderLinesFlags(BaseDesignIntf::BorderLines flags) | void AbstractLayout::setBorderLinesFlags(BaseDesignIntf::BorderLines flags) | ||||||
| { | { | ||||||
|     BaseDesignIntf::setBorderLinesFlags(flags); |     BaseDesignIntf::setBorderLinesFlags(flags); | ||||||
|     if (flags!=0) |     if (flags != 0) | ||||||
|         relocateChildren(); |         relocateChildren(); | ||||||
| } | } | ||||||
|  |  | ||||||
| void AbstractLayout::collectionLoadFinished(const QString& collectionName) | void AbstractLayout::collectionLoadFinished(const QString& collectionName) | ||||||
| { | { | ||||||
|     ItemDesignIntf::collectionLoadFinished(collectionName); |     ItemDesignIntf::collectionLoadFinished(collectionName); | ||||||
|     if (collectionName.compare("children",Qt::CaseInsensitive)==0){ |     if (collectionName.compare("children", Qt::CaseInsensitive) == 0) { | ||||||
| #ifdef HAVE_QT5 | #ifdef HAVE_QT5 | ||||||
|         foreach(QObject* obj, children()){ |         foreach (QObject* obj, children()) { | ||||||
| #else | #else | ||||||
|         foreach(QObject* obj,QObject::children()){ |         foreach (QObject* obj, QObject::children()) { | ||||||
| #endif | #endif | ||||||
|             BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(obj); |             BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(obj); | ||||||
|             if (item) { |             if (item) { | ||||||
|                 addChild(item,false); |                 addChild(item, false); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -220,9 +203,9 @@ bool AbstractLayout::isNeedUpdateSize(RenderPass pass) const | |||||||
|  |  | ||||||
| QVariant AbstractLayout::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant& value) | QVariant AbstractLayout::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant& value) | ||||||
| { | { | ||||||
|     if (change == QGraphicsItem::ItemSelectedHasChanged){ |     if (change == QGraphicsItem::ItemSelectedHasChanged) { | ||||||
|         setIsRelocating(true); |         setIsRelocating(true); | ||||||
|         foreach(BaseDesignIntf* item, layoutsChildren()){ |         foreach (BaseDesignIntf* item, layoutsChildren()) { | ||||||
|             item->setVisible(!value.toBool()); |             item->setVisible(!value.toBool()); | ||||||
|         } |         } | ||||||
|         setIsRelocating(false); |         setIsRelocating(false); | ||||||
| @@ -234,7 +217,7 @@ void AbstractLayout::updateItemSize(DataSourceManager* dataManager, RenderPass p | |||||||
| { | { | ||||||
|     setIsRelocating(true); |     setIsRelocating(true); | ||||||
|     ItemDesignIntf::updateItemSize(dataManager, pass, maxHeight); |     ItemDesignIntf::updateItemSize(dataManager, pass, maxHeight); | ||||||
|     foreach(QGraphicsItem *child, childItems()){ |     foreach (QGraphicsItem* child, childItems()) { | ||||||
|         BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(child); |         BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(child); | ||||||
|         if (item && item->isNeedUpdateSize(pass)) |         if (item && item->isNeedUpdateSize(pass)) | ||||||
|             item->updateItemSize(dataManager, pass, maxHeight); |             item->updateItemSize(dataManager, pass, maxHeight); | ||||||
| @@ -245,8 +228,9 @@ 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()) { | ||||||
|             layoutsChildren().append(childItem); |             layoutsChildren().append(childItem); | ||||||
| @@ -255,89 +239,75 @@ 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; | ||||||
| } | } | ||||||
|  |  | ||||||
| BaseDesignIntf *AbstractLayout::findPrior(BaseDesignIntf *item) | 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]; | ||||||
|         if (child->pos() == item->pos()){ |         if (child->pos() == item->pos()) { | ||||||
|             layoutsChildren().insert(i, item); |             layoutsChildren().insert(i, item); | ||||||
|             inserted = true; |             inserted = true; | ||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     if (!inserted) layoutsChildren().append(item); |     if (!inserted) | ||||||
|  |         layoutsChildren().append(item); | ||||||
| } | } | ||||||
|  |  | ||||||
| void AbstractLayout::slotOnChildDestroy(QObject* child) | void AbstractLayout::slotOnChildDestroy(QObject* child) | ||||||
| { | { | ||||||
|     m_children.removeAll(static_cast<BaseDesignIntf*>(child)); |     m_children.removeAll(static_cast<BaseDesignIntf*>(child)); | ||||||
|     if (m_children.count() < 2 && !static_cast<LayoutDesignIntf*>(child)){ |     if (m_children.count() < 2 && !static_cast<LayoutDesignIntf*>(child)) { | ||||||
|         beforeDelete(); |         beforeDelete(); | ||||||
|     } else { |     } else { | ||||||
|         relocateChildren(); |         relocateChildren(); | ||||||
| @@ -345,19 +315,20 @@ void AbstractLayout::slotOnChildDestroy(QObject* child) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void AbstractLayout::slotOnChildGeometryChanged(QObject* item, QRectF newGeometry, QRectF oldGeometry) | void AbstractLayout::slotOnChildGeometryChanged(QObject* item, QRectF newGeometry, | ||||||
|  |                                                 QRectF oldGeometry) | ||||||
| { | { | ||||||
|     if (!m_isRelocating && !isLoading()){ |     if (!m_isRelocating && !isLoading()) { | ||||||
|         if (m_layoutType == Layout){ |         if (m_layoutType == Layout) { | ||||||
|             relocateChildren(); |             relocateChildren(); | ||||||
|             updateLayoutSize(); |             updateLayoutSize(); | ||||||
|         } else { |         } else { | ||||||
|             m_isRelocating = true; |             m_isRelocating = true; | ||||||
|             qreal delta = newGeometry.width()-oldGeometry.width(); |             qreal delta = newGeometry.width() - oldGeometry.width(); | ||||||
|             BaseDesignIntf* resizingItem = findNext(dynamic_cast<BaseDesignIntf*>(item)); |             BaseDesignIntf* resizingItem = findNext(dynamic_cast<BaseDesignIntf*>(item)); | ||||||
|             if (resizingItem) { |             if (resizingItem) { | ||||||
|                 resizingItem->setWidth(resizingItem->width()-delta); |                 resizingItem->setWidth(resizingItem->width() - delta); | ||||||
|                 resizingItem->setPos(resizingItem->pos().x()+delta,resizingItem->pos().y()); |                 resizingItem->setPos(resizingItem->pos().x() + delta, resizingItem->pos().y()); | ||||||
|             } |             } | ||||||
|             updateLayoutSize(); |             updateLayoutSize(); | ||||||
|             m_isRelocating = false; |             m_isRelocating = false; | ||||||
| @@ -365,7 +336,8 @@ void AbstractLayout::slotOnChildGeometryChanged(QObject* item, QRectF newGeometr | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void AbstractLayout::slotOnChildItemAlignChanged(BaseDesignIntf* item, const ItemAlign&, const ItemAlign&) | void AbstractLayout::slotOnChildItemAlignChanged(BaseDesignIntf* item, const ItemAlign&, | ||||||
|  |                                                  const ItemAlign&) | ||||||
| { | { | ||||||
|     item->setPossibleResizeDirectionFlags(ResizeBottom | ResizeRight); |     item->setPossibleResizeDirectionFlags(ResizeBottom | ResizeRight); | ||||||
| } | } | ||||||
| @@ -373,28 +345,25 @@ void AbstractLayout::slotOnChildItemAlignChanged(BaseDesignIntf* item, const Ite | |||||||
| void AbstractLayout::slotOnChildVisibleHasChanged(BaseDesignIntf*) | void AbstractLayout::slotOnChildVisibleHasChanged(BaseDesignIntf*) | ||||||
| { | { | ||||||
|     relocateChildren(); |     relocateChildren(); | ||||||
|     if (m_layoutType == Table && !m_isRelocating){ |     if (m_layoutType == Table && !m_isRelocating) { | ||||||
|         divideSpace(); |         divideSpace(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void AbstractLayout::slotOnChildSelectionHasChanged(BaseDesignIntf* item, bool value) | void AbstractLayout::slotOnChildSelectionHasChanged(BaseDesignIntf* item, bool value) | ||||||
| { | { | ||||||
|     item->setZValue(value ? item->zValue()+1 : item->zValue()-1); |     item->setZValue(value ? item->zValue() + 1 : item->zValue() - 1); | ||||||
| } | } | ||||||
|  |  | ||||||
| int AbstractLayout::layoutSpacing() const | int AbstractLayout::layoutSpacing() const { return m_layoutSpacing; } | ||||||
| { |  | ||||||
|     return m_layoutSpacing; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void AbstractLayout::setLayoutSpacing(int layoutSpacing) | void AbstractLayout::setLayoutSpacing(int layoutSpacing) | ||||||
| { | { | ||||||
|      if (m_layoutSpacing != layoutSpacing){ |     if (m_layoutSpacing != layoutSpacing) { | ||||||
|         int oldValue = m_layoutSpacing; |         int oldValue = m_layoutSpacing; | ||||||
|         m_layoutSpacing = layoutSpacing; |         m_layoutSpacing = layoutSpacing; | ||||||
|         if (!isLoading()){ |         if (!isLoading()) { | ||||||
|             int delta  = (m_layoutSpacing - oldValue)  * (m_children.count()-1); |             int delta = (m_layoutSpacing - oldValue) * (m_children.count() - 1); | ||||||
|             notify("layoutSpacing", oldValue, m_layoutSpacing); |             notify("layoutSpacing", oldValue, m_layoutSpacing); | ||||||
|             setWidth(width() + delta); |             setWidth(width() + delta); | ||||||
|         } |         } | ||||||
| @@ -402,16 +371,13 @@ 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) | ||||||
| { | { | ||||||
|     m_hideEmptyItems = hideEmptyItems; |     m_hideEmptyItems = hideEmptyItems; | ||||||
|  |  | ||||||
|     if (m_hideEmptyItems != hideEmptyItems){ |     if (m_hideEmptyItems != hideEmptyItems) { | ||||||
|         m_hideEmptyItems = hideEmptyItems; |         m_hideEmptyItems = hideEmptyItems; | ||||||
|         notify("hideEmptyItems", !m_hideEmptyItems, m_hideEmptyItems); |         notify("hideEmptyItems", !m_hideEmptyItems, m_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 | ||||||
|   | |||||||
| @@ -3,22 +3,25 @@ | |||||||
|  |  | ||||||
| #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 | ||||||
|     Q_ENUMS(LayoutType) |     Q_ENUMS(LayoutType) | ||||||
| #endif | #endif | ||||||
|     AbstractLayout(QString xmlTag, QObject *owner = 0, QGraphicsItem *parent = 0); |     AbstractLayout(QString xmlTag, QObject* owner = 0, QGraphicsItem* parent = 0); | ||||||
|     ~AbstractLayout(); |     ~AbstractLayout(); | ||||||
|     QList<BaseDesignIntf*>& layoutsChildren(); |     QList<BaseDesignIntf*>& layoutsChildren(); | ||||||
|     LayoutMarker* layoutMarker() const; |     LayoutMarker* layoutMarker() const; | ||||||
| @@ -27,9 +30,9 @@ public: | |||||||
|     LayoutType layoutType() const; |     LayoutType layoutType() const; | ||||||
|     void setLayoutType(const LayoutType& layoutType); |     void setLayoutType(const LayoutType& layoutType); | ||||||
|  |  | ||||||
|     void addChild(BaseDesignIntf *item,bool updateSize=true); |     void addChild(BaseDesignIntf* item, bool updateSize = true); | ||||||
|     void removeChild(BaseDesignIntf *item); |     void removeChild(BaseDesignIntf* item); | ||||||
|     void restoreChild(BaseDesignIntf *item); |     void restoreChild(BaseDesignIntf* item); | ||||||
|     bool isEmpty() const; |     bool isEmpty() const; | ||||||
|     void paintChild(BaseDesignIntf* child, QPointF parentPos, QPainter* painter); |     void paintChild(BaseDesignIntf* child, QPointF parentPos, QPainter* painter); | ||||||
|     void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget); |     void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget); | ||||||
| @@ -37,42 +40,45 @@ public: | |||||||
|     bool hideEmptyItems() const; |     bool hideEmptyItems() const; | ||||||
|     void setHideEmptyItems(bool hideEmptyItems); |     void setHideEmptyItems(bool hideEmptyItems); | ||||||
|     Q_INVOKABLE QObject* at(int index); |     Q_INVOKABLE QObject* at(int index); | ||||||
|     int  childrenCount(); |     int childrenCount(); | ||||||
|     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); | ||||||
|     void geometryChangedEvent(QRectF newRect, QRectF); |     void geometryChangedEvent(QRectF newRect, QRectF); | ||||||
|     void initMode(ItemMode mode); |     void initMode(ItemMode mode); | ||||||
|     void setBorderLinesFlags(BorderLines flags); |     void setBorderLinesFlags(BorderLines flags); | ||||||
|     void collectionLoadFinished(const QString &collectionName); |     void collectionLoadFinished(const QString& collectionName); | ||||||
|     void objectLoadFinished(); |     void objectLoadFinished(); | ||||||
|     bool isNeedUpdateSize(RenderPass pass) const; |     bool isNeedUpdateSize(RenderPass pass) const; | ||||||
|     QVariant itemChange(GraphicsItemChange change, const QVariant &value); |     QVariant itemChange(GraphicsItemChange change, const QVariant& value); | ||||||
|     void updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight); |     void updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight); | ||||||
|     void rebuildChildrenIfNeeded(); |     void rebuildChildrenIfNeeded(); | ||||||
|     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; | ||||||
|     virtual void updateLayoutSize() = 0; |     virtual void updateLayoutSize() = 0; | ||||||
|     virtual void relocateChildren() = 0; |     virtual void relocateChildren() = 0; | ||||||
|     virtual BaseDesignIntf* findNext(BaseDesignIntf *item); |     virtual BaseDesignIntf* findNext(BaseDesignIntf* item); | ||||||
|     virtual BaseDesignIntf* findPrior(BaseDesignIntf *item); |     virtual BaseDesignIntf* findPrior(BaseDesignIntf* item); | ||||||
|     virtual void placeItemInLayout(BaseDesignIntf* item) = 0; |     virtual void placeItemInLayout(BaseDesignIntf* item) = 0; | ||||||
|  |  | ||||||
| private slots: | private slots: | ||||||
|     void slotOnChildDestroy(QObject *child); |     void slotOnChildDestroy(QObject* child); | ||||||
|     void slotOnChildGeometryChanged(QObject*item, QRectF newGeometry, QRectF oldGeometry); |     void slotOnChildGeometryChanged(QObject* item, QRectF newGeometry, QRectF oldGeometry); | ||||||
|     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; | ||||||
|     LayoutMarker* m_layoutMarker; |     LayoutMarker* m_layoutMarker; | ||||||
|     LayoutType m_layoutType; |     LayoutType m_layoutType; | ||||||
|   | |||||||
| @@ -28,54 +28,63 @@ | |||||||
|  *   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) | ||||||
|  | { | ||||||
|     bool VARIABLE_IS_NOT_USED registred = LimeReport::ObjectPropFactory::instance().registerCreator( |     return new LimeReport::AlignmentPropItem(object, objects, name, displayName, data, parent, | ||||||
|                 LimeReport::APropIdent("alignment","LimeReport::TextItem"), |                                              readonly); | ||||||
|                 QObject::tr("alignment"), |  | ||||||
|                 createAlignItem |  | ||||||
|                 ); |  | ||||||
| } | } | ||||||
|  |  | ||||||
| namespace LimeReport{ | bool VARIABLE_IS_NOT_USED registred = LimeReport::ObjectPropFactory::instance().registerCreator( | ||||||
|  |     LimeReport::APropIdent("alignment", "LimeReport::TextItem"), QObject::tr("alignment"), | ||||||
|  |     createAlignItem); | ||||||
|  | } // namespace | ||||||
|  |  | ||||||
|  | namespace LimeReport { | ||||||
|  |  | ||||||
| QString AlignmentPropItem::associateValue(int value, const AlignMap* map) const | QString AlignmentPropItem::associateValue(int value, const AlignMap* map) const | ||||||
| { | { | ||||||
|     QString result; |     QString result; | ||||||
|     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); | ||||||
|     m_horizMap.insert(tr("Right"),Qt::AlignRight); |     m_horizMap.insert(tr("Right"), Qt::AlignRight); | ||||||
|     m_horizMap.insert(tr("Center"),Qt::AlignHCenter); |     m_horizMap.insert(tr("Center"), Qt::AlignHCenter); | ||||||
|     m_horizMap.insert(tr("Justify"),Qt::AlignJustify); |     m_horizMap.insert(tr("Justify"), Qt::AlignJustify); | ||||||
|  |  | ||||||
|     m_vertMap.insert(tr("Top"),Qt::AlignTop); |     m_vertMap.insert(tr("Top"), Qt::AlignTop); | ||||||
|     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,62 +103,67 @@ 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); | ||||||
| } | } | ||||||
|  |  | ||||||
| QVector<int> AlignmentItemEditor::extractAcceptableValue(int flags) | 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(); | ||||||
|     } |     } | ||||||
|     return flags; |     return flags; | ||||||
| } | } | ||||||
|  |  | ||||||
| QWidget *AlignmentItemEditor::createProperyEditor(QWidget *parent) const | QWidget* AlignmentItemEditor::createProperyEditor(QWidget* parent) const | ||||||
| { | { | ||||||
|     ComboBoxEditor *editor = new ComboBoxEditor(parent); |     ComboBoxEditor* editor = new ComboBoxEditor(parent); | ||||||
|     QStringList enumValues; |     QStringList enumValues; | ||||||
|     enumValues<<m_acceptableValues.keys(); |     enumValues << m_acceptableValues.keys(); | ||||||
|     editor->addItems(enumValues); |     editor->addItems(enumValues); | ||||||
|     return editor; |     return editor; | ||||||
| } | } | ||||||
|  |  | ||||||
| void AlignmentItemEditor::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const | void AlignmentItemEditor::setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const | ||||||
| { | { | ||||||
|     ComboBoxEditor *editor=qobject_cast<ComboBoxEditor *>(propertyEditor); |     ComboBoxEditor* editor = qobject_cast<ComboBoxEditor*>(propertyEditor); | ||||||
|     editor->setTextValue(m_acceptableValues.key(Qt::Alignment(propertyValue().toInt()))); |     editor->setTextValue(m_acceptableValues.key(Qt::Alignment(propertyValue().toInt()))); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -160,10 +174,11 @@ 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 | ||||||
|   | |||||||
| @@ -33,48 +33,51 @@ | |||||||
| #include "lrobjectpropitem.h" | #include "lrobjectpropitem.h" | ||||||
| #include "objectinspector/propertyItems/lrenumpropitem.h" | #include "objectinspector/propertyItems/lrenumpropitem.h" | ||||||
|  |  | ||||||
| namespace LimeReport{ | namespace LimeReport { | ||||||
|  |  | ||||||
| typedef QMap<QString,Qt::Alignment> AlignMap; | typedef QMap<QString, Qt::Alignment> AlignMap; | ||||||
|  |  | ||||||
| class AlignmentItemEditor; | class 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; | ||||||
|     AlignmentItemEditor* m_horizEditor; |     AlignmentItemEditor* m_horizEditor; | ||||||
|     AlignmentItemEditor* m_vertEditor; |     AlignmentItemEditor* m_vertEditor; | ||||||
|     QString associateValue(int value, const AlignMap *map) const; |     QString associateValue(int value, const AlignMap* map) const; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| class AlignmentItemEditor : public ObjectPropItem | class AlignmentItemEditor: public ObjectPropItem { | ||||||
| { |  | ||||||
|     Q_OBJECT |     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, | ||||||
|     void        setModelData(QWidget * propertyEditor, QAbstractItemModel * model, const QModelIndex & index); |                         bool readonly, AlignMap acceptableValues); | ||||||
|     void        setPropertyEditorData(QWidget * propertyEditor, const QModelIndex &) const; |     void setModelData(QWidget* propertyEditor, QAbstractItemModel* model, const QModelIndex& index); | ||||||
|     QWidget*    createProperyEditor(QWidget *parent) const; |     void setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const; | ||||||
|     QString     displayValue() const; |     QWidget* createProperyEditor(QWidget* parent) 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 | ||||||
|   | |||||||
| @@ -28,44 +28,59 @@ | |||||||
|  *   GNU General Public License for more details.                          * |  *   GNU General Public License for more details.                          * | ||||||
|  ****************************************************************************/ |  ****************************************************************************/ | ||||||
| #include "lrbarcodeitem.h" | #include "lrbarcodeitem.h" | ||||||
| #include "lrdesignelementsfactory.h" |  | ||||||
| #include "qzint.h" |  | ||||||
| #include "lrglobal.h" |  | ||||||
|  |  | ||||||
| namespace{ | #include "lrdesignelementsfactory.h" | ||||||
|  | #include "lrglobal.h" | ||||||
|  | #include "qzint.h" | ||||||
|  |  | ||||||
|  | namespace { | ||||||
|  |  | ||||||
| const QString xmlTag = "BarcodeItem"; | 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 LimeReport{ | } // namespace | ||||||
|  |  | ||||||
| BarcodeItem::BarcodeItem(QObject* owner,QGraphicsItem* parent) | namespace LimeReport { | ||||||
|     : ContentItemDesignIntf(xmlTag,owner,parent),m_designTestValue("1"), m_barcodeType(CODE128), |  | ||||||
|       m_foregroundColor(Qt::black), m_backgroundColor(Qt::white), m_whitespace(10), m_angle(Angle0), | BarcodeItem::BarcodeItem(QObject* owner, QGraphicsItem* parent): | ||||||
|       m_barcodeWidth(0), m_securityLevel(0), m_pdf417CodeWords(928), m_inputMode(UNICODE_INPUT_MODE), |     ContentItemDesignIntf(xmlTag, owner, parent), | ||||||
|       m_hideText(false), m_option3(0), m_hideIfEmpty(false) |     m_designTestValue("1"), | ||||||
| {} |     m_barcodeType(CODE128), | ||||||
|  |     m_foregroundColor(Qt::black), | ||||||
| BarcodeItem::~BarcodeItem() |     m_backgroundColor(Qt::white), | ||||||
| {} |     m_whitespace(10), | ||||||
|  |     m_angle(Angle0), | ||||||
| BaseDesignIntf *BarcodeItem::createSameTypeItem(QObject *owner, QGraphicsItem *parent) |     m_barcodeWidth(0), | ||||||
|  |     m_securityLevel(0), | ||||||
|  |     m_pdf417CodeWords(928), | ||||||
|  |     m_inputMode(UNICODE_INPUT_MODE), | ||||||
|  |     m_hideText(false), | ||||||
|  |     m_option3(0), | ||||||
|  |     m_hideIfEmpty(false) | ||||||
| { | { | ||||||
|     return new BarcodeItem(owner,parent); |  | ||||||
| } | } | ||||||
|  |  | ||||||
| void BarcodeItem::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *option, QWidget *widget) | BarcodeItem::~BarcodeItem() { } | ||||||
|  |  | ||||||
|  | BaseDesignIntf* BarcodeItem::createSameTypeItem(QObject* owner, QGraphicsItem* parent) | ||||||
|  | { | ||||||
|  |     return new BarcodeItem(owner, parent); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | void BarcodeItem::paint(QPainter* ppainter, const QStyleOptionGraphicsItem* option, QWidget* widget) | ||||||
| { | { | ||||||
|     ppainter->save(); |     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; | ||||||
|  |  | ||||||
| @@ -86,45 +102,42 @@ void BarcodeItem::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *opti | |||||||
|         bcRect = rect(); |         bcRect = rect(); | ||||||
|         break; |         break; | ||||||
|     case Angle90: |     case Angle90: | ||||||
|         ppainter->translate(width(),0); |         ppainter->translate(width(), 0); | ||||||
|         ppainter->rotate(90); |         ppainter->rotate(90); | ||||||
|         bcRect = QRectF(0,0,height(),width()); |         bcRect = QRectF(0, 0, height(), width()); | ||||||
|         break; |         break; | ||||||
|     case Angle180: |     case Angle180: | ||||||
|         bcRect = rect(); |         bcRect = rect(); | ||||||
|         ppainter->translate(width(),height()); |         ppainter->translate(width(), height()); | ||||||
|         ppainter->rotate(180); |         ppainter->rotate(180); | ||||||
|         break; |         break; | ||||||
|     case Angle270: |     case Angle270: | ||||||
|         ppainter->translate(0,height()); |         ppainter->translate(0, height()); | ||||||
|         ppainter->rotate(270); |         ppainter->rotate(270); | ||||||
|         bcRect = QRectF(0,0,height(),width()); |         bcRect = QRectF(0, 0, height(), width()); | ||||||
|         break; |         break; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     bc.render(*ppainter,bcRect); |     bc.render(*ppainter, bcRect); | ||||||
|     ppainter->restore(); |     ppainter->restore(); | ||||||
|     ItemDesignIntf::paint(ppainter,option,widget); |     ItemDesignIntf::paint(ppainter, option, widget); | ||||||
| } | } | ||||||
|  |  | ||||||
| void BarcodeItem::setContent(const QString &content) | void BarcodeItem::setContent(const QString& content) | ||||||
| { | { | ||||||
|     if (m_content!=content){ |     if (m_content != content) { | ||||||
|         QString oldValue = m_content; |         QString oldValue = m_content; | ||||||
|         m_content=content; |         m_content = content; | ||||||
|         update(); |         update(); | ||||||
|         notify("content",oldValue,m_content); |         notify("content", oldValue, m_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) | ||||||
| { | { | ||||||
|     if (m_datasource != datasource){ |     if (m_datasource != datasource) { | ||||||
|         QString oldValue = m_datasource; |         QString oldValue = m_datasource; | ||||||
|         m_datasource = datasource; |         m_datasource = datasource; | ||||||
|         update(); |         update(); | ||||||
| @@ -132,14 +145,11 @@ 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) | ||||||
| { | { | ||||||
|     if (m_field != field){ |     if (m_field != field) { | ||||||
|         QString oldValue = m_field; |         QString oldValue = m_field; | ||||||
|         m_field = field; |         m_field = field; | ||||||
|         update(); |         update(); | ||||||
| @@ -149,189 +159,162 @@ void BarcodeItem::setField(const QString &field) | |||||||
|  |  | ||||||
| void BarcodeItem::setBarcodeType(BarcodeItem::BarcodeType value) | void BarcodeItem::setBarcodeType(BarcodeItem::BarcodeType value) | ||||||
| { | { | ||||||
|     if (m_barcodeType!=value){ |     if (m_barcodeType != value) { | ||||||
|         BarcodeType oldValue = m_barcodeType; |         BarcodeType oldValue = m_barcodeType; | ||||||
|         m_barcodeType = value; |         m_barcodeType = value; | ||||||
|         update(); |         update(); | ||||||
|         notify("barcodeType",oldValue,value); |         notify("barcodeType", oldValue, value); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void BarcodeItem::setDesignTestValue(QString value) | void BarcodeItem::setDesignTestValue(QString value) | ||||||
| { | { | ||||||
|     if (m_designTestValue!=value){ |     if (m_designTestValue != value) { | ||||||
|         QString oldValue = m_designTestValue; |         QString oldValue = m_designTestValue; | ||||||
|         m_designTestValue=value; |         m_designTestValue = value; | ||||||
|         update(); |         update(); | ||||||
|         notify("testValue",oldValue,value); |         notify("testValue", oldValue, value); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void BarcodeItem::setForegroundColor(QColor value) | void BarcodeItem::setForegroundColor(QColor value) | ||||||
| { | { | ||||||
|     if (m_foregroundColor != value){ |     if (m_foregroundColor != value) { | ||||||
|         QColor oldValue = m_foregroundColor; |         QColor oldValue = m_foregroundColor; | ||||||
|         m_foregroundColor=value; |         m_foregroundColor = value; | ||||||
|         update(); |         update(); | ||||||
|         notify("foregroundColor",oldValue,value); |         notify("foregroundColor", oldValue, value); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void BarcodeItem::setBackgroundColor(QColor value) | void BarcodeItem::setBackgroundColor(QColor value) | ||||||
| { | { | ||||||
|     if (m_backgroundColor != value){ |     if (m_backgroundColor != value) { | ||||||
|         QColor oldValue = m_backgroundColor; |         QColor oldValue = m_backgroundColor; | ||||||
|         m_backgroundColor=value; |         m_backgroundColor = value; | ||||||
|         update(); |         update(); | ||||||
|         notify("backgroundColor",oldValue,value); |         notify("backgroundColor", oldValue, value); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void BarcodeItem::setWhitespace(int value) | void BarcodeItem::setWhitespace(int value) | ||||||
| { | { | ||||||
|     if (m_whitespace != value){ |     if (m_whitespace != value) { | ||||||
|         int oldValue = m_whitespace; |         int oldValue = m_whitespace; | ||||||
|         m_whitespace = value; |         m_whitespace = value; | ||||||
|         update(); |         update(); | ||||||
|         notify("whitespace",oldValue,value); |         notify("whitespace", oldValue, 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) | ||||||
| { | { | ||||||
|     if (m_angle!=angle){ |     if (m_angle != angle) { | ||||||
|         AngleType oldValue = m_angle; |         AngleType oldValue = m_angle; | ||||||
|         m_angle = angle; |         m_angle = angle; | ||||||
|         if (!isLoading()){ |         if (!isLoading()) { | ||||||
|             update(); |             update(); | ||||||
|             notify("angle",oldValue,angle); |             notify("angle", oldValue, 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) | ||||||
| { | { | ||||||
|     if (m_barcodeWidth != barcodeWidth){ |     if (m_barcodeWidth != barcodeWidth) { | ||||||
|         int oldValue = m_barcodeWidth; |         int oldValue = m_barcodeWidth; | ||||||
|         m_barcodeWidth = barcodeWidth; |         m_barcodeWidth = barcodeWidth; | ||||||
|         if (!isLoading()){ |         if (!isLoading()) { | ||||||
|             update(); |             update(); | ||||||
|             notify("barcodeWidth",oldValue,m_barcodeWidth); |             notify("barcodeWidth", oldValue, m_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) | ||||||
| { | { | ||||||
|     if (m_securityLevel != securityLevel){ |     if (m_securityLevel != securityLevel) { | ||||||
|         int oldValue = m_securityLevel; |         int oldValue = m_securityLevel; | ||||||
|         m_securityLevel = securityLevel; |         m_securityLevel = securityLevel; | ||||||
|         if (!isLoading()){ |         if (!isLoading()) { | ||||||
|             update(); |             update(); | ||||||
|             notify("securityLevel",oldValue,m_securityLevel); |             notify("securityLevel", oldValue, m_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) | ||||||
| { | { | ||||||
|     if (m_pdf417CodeWords != pdf417CodeWords){ |     if (m_pdf417CodeWords != pdf417CodeWords) { | ||||||
|         int oldValue = m_pdf417CodeWords; |         int oldValue = m_pdf417CodeWords; | ||||||
|         m_pdf417CodeWords = pdf417CodeWords; |         m_pdf417CodeWords = pdf417CodeWords; | ||||||
|         if (!isLoading()){ |         if (!isLoading()) { | ||||||
|             update(); |             update(); | ||||||
|             notify("pdf417CodeWords",oldValue,m_pdf417CodeWords); |             notify("pdf417CodeWords", oldValue, m_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) | ||||||
| { | { | ||||||
|     if (m_inputMode != inputMode){ |     if (m_inputMode != inputMode) { | ||||||
|         InputMode oldValue = m_inputMode; |         InputMode oldValue = m_inputMode; | ||||||
|         m_inputMode = inputMode; |         m_inputMode = inputMode; | ||||||
|         if (!isLoading()){ |         if (!isLoading()) { | ||||||
|             update(); |             update(); | ||||||
|             notify("inputMode",oldValue,inputMode); |             notify("inputMode", oldValue, 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) | ||||||
| { | { | ||||||
|     if (m_hideText != hideText){ |     if (m_hideText != hideText) { | ||||||
|         m_hideText = hideText; |         m_hideText = hideText; | ||||||
|         if (!isLoading()){ |         if (!isLoading()) { | ||||||
|             update(); |             update(); | ||||||
|             notify("hideText", !m_hideText, m_hideText); |             notify("hideText", !m_hideText, m_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) | ||||||
| { | { | ||||||
|     if (m_option3 != option3){ |     if (m_option3 != option3) { | ||||||
|         int oldValue = m_option3; |         int oldValue = m_option3; | ||||||
|         m_option3 = option3; |         m_option3 = option3; | ||||||
|         if(!isLoading()){ |         if (!isLoading()) { | ||||||
|             update(); |             update(); | ||||||
|             notify("option3", oldValue, m_option3); |             notify("option3", oldValue, m_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) | ||||||
| { | { | ||||||
|     if (m_hideIfEmpty != hideIfEmpty){ |     if (m_hideIfEmpty != hideIfEmpty) { | ||||||
|         m_hideIfEmpty = hideIfEmpty; |         m_hideIfEmpty = hideIfEmpty; | ||||||
|         notify("hideIfEmpty",!m_hideIfEmpty, m_hideIfEmpty); |         notify("hideIfEmpty", !m_hideIfEmpty, m_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,28 +325,23 @@ 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); | ||||||
|         { |             if (ds) { | ||||||
|            IDataSource* ds = dataManager->dataSource(m_datasource); |                 QVariant data = ds->data(m_field); | ||||||
|            if (ds) |                 if (data.isValid()) { | ||||||
|            { |                     switch (pass) { | ||||||
|                QVariant data = ds->data(m_field); |                     case FirstPass: | ||||||
|                if (data.isValid()) |                         expandContent(data.toString(), dataManager, pass); | ||||||
|                { |                         break; | ||||||
|                    switch(pass) |                     default:; | ||||||
|                    { |                     } | ||||||
|                    case FirstPass: |                 } | ||||||
|                        expandContent(data.toString(), dataManager, pass); |             } | ||||||
|                        break; |  | ||||||
|                    default:; |  | ||||||
|                    } |  | ||||||
|                } |  | ||||||
|            } |  | ||||||
|         } |         } | ||||||
|     } else { |     } else { | ||||||
|         switch(pass){ |         switch (pass) { | ||||||
|         case FirstPass: |         case FirstPass: | ||||||
|             expandContent(content(), dataManager, pass); |             expandContent(content(), 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 | ||||||
|   | |||||||
| @@ -30,11 +30,12 @@ | |||||||
| #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 { | ||||||
|  |  | ||||||
| class BarcodeItem : public LimeReport::ContentItemDesignIntf { | class BarcodeItem: public LimeReport::ContentItemDesignIntf { | ||||||
|     Q_OBJECT |     Q_OBJECT | ||||||
|     Q_PROPERTY(QString content READ content WRITE setContent) |     Q_PROPERTY(QString content READ content WRITE setContent) | ||||||
|     Q_PROPERTY(BarcodeType barcodeType READ barcodeType WRITE setBarcodeType) |     Q_PROPERTY(BarcodeType barcodeType READ barcodeType WRITE setBarcodeType) | ||||||
| @@ -54,103 +55,107 @@ class BarcodeItem : public LimeReport::ContentItemDesignIntf { | |||||||
|     Q_PROPERTY(bool hideIfEmpty READ hideIfEmpty WRITE setHideIfEmpty) |     Q_PROPERTY(bool hideIfEmpty READ hideIfEmpty WRITE setHideIfEmpty) | ||||||
| public: | public: | ||||||
|     enum BarcodeType { |     enum BarcodeType { | ||||||
|         CODE11          =1, |         CODE11 = 1, | ||||||
|         C25MATRIX       =2, |         C25MATRIX = 2, | ||||||
|         C25INTER        =3, |         C25INTER = 3, | ||||||
|         C25IATA         =4, |         C25IATA = 4, | ||||||
|         C25LOGIC        =6, |         C25LOGIC = 6, | ||||||
|         C25IND          =7, |         C25IND = 7, | ||||||
|         CODE39          =8, |         CODE39 = 8, | ||||||
|         EXCODE39        =9, |         EXCODE39 = 9, | ||||||
|         EANX            =13, |         EANX = 13, | ||||||
|         EANX_CHK        =14, |         EANX_CHK = 14, | ||||||
|         EAN128          =16, |         EAN128 = 16, | ||||||
|         CODABAR         =18, |         CODABAR = 18, | ||||||
|         CODE128         =20, |         CODE128 = 20, | ||||||
|         DPLEIT          =21, |         DPLEIT = 21, | ||||||
|         DPIDENT         =22, |         DPIDENT = 22, | ||||||
|         CODE16K         =23, |         CODE16K = 23, | ||||||
|         CODE93          =25, |         CODE93 = 25, | ||||||
|         FLAT            =28, |         FLAT = 28, | ||||||
|         RSS14           =29, |         RSS14 = 29, | ||||||
|         RSS_LTD         =30, |         RSS_LTD = 30, | ||||||
|         RSS_EXP         =31, |         RSS_EXP = 31, | ||||||
|         TELEPEN         =32, |         TELEPEN = 32, | ||||||
|         UPCA            =34, |         UPCA = 34, | ||||||
|         UPCE            =37, |         UPCE = 37, | ||||||
|         POSTNET         =40, |         POSTNET = 40, | ||||||
|         MSI_PLESSEY     =47, |         MSI_PLESSEY = 47, | ||||||
|         FIM             =49, |         FIM = 49, | ||||||
|         LOGMARS         =50, |         LOGMARS = 50, | ||||||
|         PHARMA          =51, |         PHARMA = 51, | ||||||
|         PZN             =52, |         PZN = 52, | ||||||
|         PHARMA_TWO      =53, |         PHARMA_TWO = 53, | ||||||
|         PDF417          =55, |         PDF417 = 55, | ||||||
|         PDF417TRUNC     =56, |         PDF417TRUNC = 56, | ||||||
|         MAXICODE        =57, |         MAXICODE = 57, | ||||||
|         QRCODE          =58, |         QRCODE = 58, | ||||||
|         CODE128B        =60, |         CODE128B = 60, | ||||||
|         AUSPOST         =63, |         AUSPOST = 63, | ||||||
|         AUSREPLY        =66, |         AUSREPLY = 66, | ||||||
|         AUSROUTE        =67, |         AUSROUTE = 67, | ||||||
|         AUSREDIRECT     =68, |         AUSREDIRECT = 68, | ||||||
|         ISBNX           =69, |         ISBNX = 69, | ||||||
|         RM4SCC          =70, |         RM4SCC = 70, | ||||||
|         DATAMATRIX      =71, |         DATAMATRIX = 71, | ||||||
|         ITF14           =72, |         ITF14 = 72, | ||||||
|         CODABLOCKF      =74, |         CODABLOCKF = 74, | ||||||
|         NVE18           =75, |         NVE18 = 75, | ||||||
|         KOREAPOST       =77, |         KOREAPOST = 77, | ||||||
|         RSS14STACK      =79, |         RSS14STACK = 79, | ||||||
|         RSS14STACK_OMNI =80, |         RSS14STACK_OMNI = 80, | ||||||
|         RSS_EXPSTACK    =81, |         RSS_EXPSTACK = 81, | ||||||
|         PLANET          =82, |         PLANET = 82, | ||||||
|         MICROPDF417     =84, |         MICROPDF417 = 84, | ||||||
|         ONECODE         =85, |         ONECODE = 85, | ||||||
|         PLESSEY         =86, |         PLESSEY = 86, | ||||||
|         KIX             =90, |         KIX = 90, | ||||||
|         AZTEC           =92, |         AZTEC = 92, | ||||||
|         DAFT            =93, |         DAFT = 93, | ||||||
|         ITALYPOST       =94, |         ITALYPOST = 94, | ||||||
|         DPD             =96, |         DPD = 96, | ||||||
|         MICROQR         =97, |         MICROQR = 97, | ||||||
|         HIBC_128        =98, |         HIBC_128 = 98, | ||||||
|         HIBC_39         =99, |         HIBC_39 = 99, | ||||||
|         HIBC_DM         =102, |         HIBC_DM = 102, | ||||||
|         HIBC_QR         =104, |         HIBC_QR = 104, | ||||||
|         HIBC_PDF        =106, |         HIBC_PDF = 106, | ||||||
|         HIBC_MICPDF     =108, |         HIBC_MICPDF = 108, | ||||||
|         HIBC_BLOCKF     =110, |         HIBC_BLOCKF = 110, | ||||||
|         HIBC_AZTEC      =112, |         HIBC_AZTEC = 112, | ||||||
|         DOTCODE         =115, |         DOTCODE = 115, | ||||||
|         HANXIN          =116, |         HANXIN = 116, | ||||||
|         TELEPEN_NUM     =128, |         TELEPEN_NUM = 128, | ||||||
|         CODE32          =129, |         CODE32 = 129, | ||||||
| //        EANX_CC         =130, |         //        EANX_CC         =130, | ||||||
| //        EAN128_CC       =131, |         //        EAN128_CC       =131, | ||||||
| //        RSS14_CC        =132, |         //        RSS14_CC        =132, | ||||||
| //        RSS_LTD_CC      =133, |         //        RSS_LTD_CC      =133, | ||||||
| //        RSS_EXP_CC      =134, |         //        RSS_EXP_CC      =134, | ||||||
| //        UPCA_CC         =135, |         //        UPCA_CC         =135, | ||||||
| //        UPCE_CC         =136, |         //        UPCE_CC         =136, | ||||||
| //        RSS14STACK_CC   =137, |         //        RSS14STACK_CC   =137, | ||||||
| //        RSS14_OMNI_CC   =138, |         //        RSS14_OMNI_CC   =138, | ||||||
| //        RSS_EXPSTACK_CC =139, |         //        RSS_EXPSTACK_CC =139, | ||||||
|         CHANNEL         =140, |         CHANNEL = 140, | ||||||
|         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, | ||||||
|         UNICODE_INPUT_MODE  = 1, |         UNICODE_INPUT_MODE = 1, | ||||||
|         GS1_INPUT_MODE      = 2, |         GS1_INPUT_MODE = 2, | ||||||
|         KANJI_INPUT_MODE    = 3, |         KANJI_INPUT_MODE = 3, | ||||||
|         SJIS_INPUT_MODE     = 4 |         SJIS_INPUT_MODE = 4 | ||||||
|     }; |     }; | ||||||
| #if QT_VERSION >= 0x050500 | #if QT_VERSION >= 0x050500 | ||||||
|     Q_ENUM(BarcodeType) |     Q_ENUM(BarcodeType) | ||||||
| @@ -161,30 +166,30 @@ public: | |||||||
|     Q_ENUMS(AngleType) |     Q_ENUMS(AngleType) | ||||||
|     Q_ENUMS(InputMode) |     Q_ENUMS(InputMode) | ||||||
| #endif | #endif | ||||||
|     BarcodeItem(QObject *owner, QGraphicsItem *parent); |     BarcodeItem(QObject* owner, QGraphicsItem* parent); | ||||||
|     ~BarcodeItem(); |     ~BarcodeItem(); | ||||||
|     virtual BaseDesignIntf* createSameTypeItem(QObject *owner, QGraphicsItem *parent); |     virtual BaseDesignIntf* createSameTypeItem(QObject* owner, QGraphicsItem* parent); | ||||||
|     virtual void paint(QPainter *ppainter, const QStyleOptionGraphicsItem *option, QWidget *widget); |     virtual void paint(QPainter* ppainter, const QStyleOptionGraphicsItem* option, QWidget* widget); | ||||||
|     virtual void updateItemSize(DataSourceManager *dataManager, RenderPass pass, int maxHeight); |     virtual void updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight); | ||||||
|     virtual bool isNeedUpdateSize(RenderPass pass) const; |     virtual bool isNeedUpdateSize(RenderPass pass) const; | ||||||
|     void setContent(const QString& content); |     void setContent(const QString& content); | ||||||
|     QString content() const {return m_content;} |     QString content() const { return m_content; } | ||||||
|     void setBarcodeType(BarcodeType value); |     void setBarcodeType(BarcodeType value); | ||||||
|     BarcodeType barcodeType(){return m_barcodeType;} |     BarcodeType barcodeType() { return m_barcodeType; } | ||||||
|     QString datasource() const; |     QString datasource() const; | ||||||
|     void setDatasource(const QString &datasource); |     void setDatasource(const QString& datasource); | ||||||
|     QString field() const; |     QString field() const; | ||||||
|     void setField(const QString &field); |     void setField(const QString& field); | ||||||
|     void setDesignTestValue(QString value); |     void setDesignTestValue(QString value); | ||||||
|     QString designTestValue(){return m_designTestValue;} |     QString designTestValue() { return m_designTestValue; } | ||||||
|     QColor foregroundColor(){return m_foregroundColor;} |     QColor foregroundColor() { return m_foregroundColor; } | ||||||
|     void setForegroundColor(QColor value); |     void setForegroundColor(QColor value); | ||||||
|     QColor backgroundColor(){return m_backgroundColor;} |     QColor backgroundColor() { return m_backgroundColor; } | ||||||
|     void setBackgroundColor(QColor value); |     void setBackgroundColor(QColor value); | ||||||
|     int whitespace(){return m_whitespace;} |     int whitespace() { return m_whitespace; } | ||||||
|     void setWhitespace(int value); |     void setWhitespace(int value); | ||||||
|     AngleType angle() const; |     AngleType angle() const; | ||||||
|     void setAngle(const AngleType &angle); |     void setAngle(const AngleType& angle); | ||||||
|     int barcodeWidth() const; |     int barcodeWidth() const; | ||||||
|     void setBarcodeWidth(int barcodeWidth); |     void setBarcodeWidth(int barcodeWidth); | ||||||
|     int securityLevel() const; |     int securityLevel() const; | ||||||
| @@ -192,7 +197,7 @@ public: | |||||||
|     int pdf417CodeWords() const; |     int pdf417CodeWords() const; | ||||||
|     void setPdf417CodeWords(int pdf417CodeWords); |     void setPdf417CodeWords(int pdf417CodeWords); | ||||||
|     InputMode inputMode() const; |     InputMode inputMode() const; | ||||||
|     void setInputMode(const InputMode &inputMode); |     void setInputMode(const InputMode& inputMode); | ||||||
|     bool hideText() const; |     bool hideText() const; | ||||||
|     void setHideText(bool hideText); |     void setHideText(bool hideText); | ||||||
|     int option3() const; |     int option3() const; | ||||||
| @@ -202,7 +207,7 @@ public: | |||||||
|     bool isEmpty() const; |     bool isEmpty() const; | ||||||
|  |  | ||||||
| private: | private: | ||||||
|     void expandContent(QString data, DataSourceManager *dataManager, RenderPass pass); |     void expandContent(QString data, DataSourceManager* dataManager, RenderPass pass); | ||||||
|  |  | ||||||
| private: | private: | ||||||
|     QString m_content; |     QString m_content; | ||||||
| @@ -223,5 +228,5 @@ private: | |||||||
|     bool m_hideIfEmpty; |     bool m_hideIfEmpty; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| } | } // namespace LimeReport | ||||||
| #endif // LRBARCODEITEM_H | #endif // LRBARCODEITEM_H | ||||||
|   | |||||||
| @@ -1,34 +1,39 @@ | |||||||
| #include "lrbordereditor.h" | #include "lrbordereditor.h" | ||||||
| #include "ui_lrbordereditor.h" | #include "ui_lrbordereditor.h" | ||||||
| #include <QColorDialog> |  | ||||||
| #include "lrbasedesignintf.h" | #include "lrbasedesignintf.h" | ||||||
|  |  | ||||||
| namespace LimeReport{ | #include <QColorDialog> | ||||||
|  |  | ||||||
| BorderEditor::BorderEditor(QWidget *parent) : | namespace LimeReport { | ||||||
|  |  | ||||||
|  | BorderEditor::BorderEditor(QWidget* parent): | ||||||
|     QDialog(parent), |     QDialog(parent), | ||||||
|     ui(new Ui::BorderEditor), |     ui(new Ui::BorderEditor), | ||||||
|     m_borderStyle(1), |     m_borderStyle(1), | ||||||
|     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()); | ||||||
| @@ -39,7 +44,7 @@ void BorderEditor::loadItem(LimeReport::BaseDesignIntf *item) | |||||||
|     ui->listWidget->setCurrentRow((Qt::PenStyle)item->borderStyle()); |     ui->listWidget->setCurrentRow((Qt::PenStyle)item->borderStyle()); | ||||||
|     ui->comboBox->setCurrentText(QString::number(item->borderLineSize())); |     ui->comboBox->setCurrentText(QString::number(item->borderLineSize())); | ||||||
|     m_borderWidth = ui->comboBox->currentText().toDouble(); |     m_borderWidth = ui->comboBox->currentText().toDouble(); | ||||||
|     m_borderStyle =ui->listWidget->currentRow(); |     m_borderStyle = ui->listWidget->currentRow(); | ||||||
|     ui->colorIndicator->setStyleSheet(QString("background-color:%1;").arg(m_borderColor)); |     ui->colorIndicator->setStyleSheet(QString("background-color:%1;").arg(m_borderColor)); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -50,28 +55,19 @@ LimeReport::BaseDesignIntf::BorderLines BorderEditor::borderSides() | |||||||
|     borders += (ui->bottomLine->isChecked()) ? LimeReport::BaseDesignIntf::BottomLine : 0; |     borders += (ui->bottomLine->isChecked()) ? LimeReport::BaseDesignIntf::BottomLine : 0; | ||||||
|     borders += (ui->leftLine->isChecked()) ? LimeReport::BaseDesignIntf::LeftLine : 0; |     borders += (ui->leftLine->isChecked()) ? LimeReport::BaseDesignIntf::LeftLine : 0; | ||||||
|     borders += (ui->rightLine->isChecked()) ? LimeReport::BaseDesignIntf::RightLine : 0; |     borders += (ui->rightLine->isChecked()) ? LimeReport::BaseDesignIntf::RightLine : 0; | ||||||
|     return (LimeReport::BaseDesignIntf::BorderLines) borders; |     return (LimeReport::BaseDesignIntf::BorderLines)borders; | ||||||
| } | } | ||||||
|  |  | ||||||
| LimeReport::BaseDesignIntf::BorderStyle BorderEditor::borderStyle() | 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) | ||||||
| { | { | ||||||
| @@ -81,7 +77,7 @@ void BorderEditor::on_listWidget_currentRowChanged(int currentRow) | |||||||
|     ui->borderFrame->setPen(pen); |     ui->borderFrame->setPen(pen); | ||||||
| } | } | ||||||
|  |  | ||||||
| void BorderEditor::on_comboBox_currentTextChanged(const QString &arg1) | void BorderEditor::on_comboBox_currentTextChanged(const QString& arg1) | ||||||
| { | { | ||||||
|     QPen pen = ui->borderFrame->pen(); |     QPen pen = ui->borderFrame->pen(); | ||||||
|     pen.setWidthF(arg1.toDouble()); |     pen.setWidthF(arg1.toDouble()); | ||||||
| @@ -91,61 +87,69 @@ 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; |     case BaseDesignIntf::BorderSide::BottomLine: | ||||||
|         case BaseDesignIntf::BorderSide::BottomLine: |         ui->bottomLine->setChecked(check); | ||||||
|             ui->bottomLine->setChecked(check); |         break; | ||||||
|             break; |     case BaseDesignIntf::BorderSide::LeftLine: | ||||||
|         case BaseDesignIntf::BorderSide::LeftLine: |         ui->leftLine->setChecked(check); | ||||||
|             ui->leftLine->setChecked(check); |         break; | ||||||
|             break; |     case BaseDesignIntf::BorderSide::RightLine: | ||||||
|         case BaseDesignIntf::BorderSide::RightLine: |         ui->rightLine->setChecked(check); | ||||||
|             ui->rightLine->setChecked(check); |         break; | ||||||
|             break; |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| 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(); | ||||||
|   | |||||||
| @@ -1,23 +1,22 @@ | |||||||
| #ifndef LRBORDEREDITOR_H | #ifndef LRBORDEREDITOR_H | ||||||
| #define LRBORDEREDITOR_H | #define LRBORDEREDITOR_H | ||||||
|  |  | ||||||
| #include <QDialog> |  | ||||||
| #include "lrbasedesignintf.h" | #include "lrbasedesignintf.h" | ||||||
|  |  | ||||||
| namespace LimeReport{ | #include <QDialog> | ||||||
|  |  | ||||||
|  | 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: | ||||||
|     explicit BorderEditor(QWidget *parent = nullptr); |     explicit BorderEditor(QWidget* parent = nullptr); | ||||||
|     void loadItem(LimeReport::BaseDesignIntf *item); |     void loadItem(LimeReport::BaseDesignIntf* item); | ||||||
|     LimeReport::BaseDesignIntf::BorderLines borderSides(); |     LimeReport::BaseDesignIntf::BorderLines borderSides(); | ||||||
|     LimeReport::BaseDesignIntf::BorderStyle borderStyle(); |     LimeReport::BaseDesignIntf::BorderStyle borderStyle(); | ||||||
|     QString borderColor(); |     QString borderColor(); | ||||||
| @@ -26,7 +25,7 @@ public: | |||||||
|  |  | ||||||
| private slots: | private slots: | ||||||
|     void on_listWidget_currentRowChanged(int currentRow); |     void on_listWidget_currentRowChanged(int currentRow); | ||||||
|     void on_comboBox_currentTextChanged(const QString &arg1); |     void on_comboBox_currentTextChanged(const QString& arg1); | ||||||
|     void on_noLines_clicked(); |     void on_noLines_clicked(); | ||||||
|     void on_topLine_clicked(bool checked); |     void on_topLine_clicked(bool checked); | ||||||
|     void on_bottomLine_clicked(bool checked); |     void on_bottomLine_clicked(bool checked); | ||||||
| @@ -37,8 +36,8 @@ private slots: | |||||||
|     void on_selectColor_clicked(); |     void on_selectColor_clicked(); | ||||||
|  |  | ||||||
| private: | private: | ||||||
|     Ui::BorderEditor *ui; |     Ui::BorderEditor* ui; | ||||||
|     LimeReport::BaseDesignIntf *m_item; |     LimeReport::BaseDesignIntf* m_item; | ||||||
|     QString m_borderColor; |     QString m_borderColor; | ||||||
|     int m_borderStyle; |     int m_borderStyle; | ||||||
|     double m_borderWidth; |     double m_borderWidth; | ||||||
|   | |||||||
| @@ -1,57 +1,56 @@ | |||||||
| #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" | ||||||
|  |  | ||||||
| namespace LimeReport{ | #include <QDebug> | ||||||
|  | #include <QGraphicsLineItem> | ||||||
|  | #include <QMouseEvent> | ||||||
|  | #include <QPainter> | ||||||
|  |  | ||||||
| BorderFrameEditor::BorderFrameEditor(QWidget *parent) | namespace LimeReport { | ||||||
|     : QWidget(parent) |  | ||||||
|     , ui(new Ui::BorderFrameEditor) | BorderFrameEditor::BorderFrameEditor(QWidget* parent): | ||||||
|  |     QWidget(parent), | ||||||
|  |     ui(new Ui::BorderFrameEditor) | ||||||
| { | { | ||||||
|     ui->setupUi(this); |     ui->setupUi(this); | ||||||
|     scene = new QGraphicsScene(ui->graphicsView); |     scene = new QGraphicsScene(ui->graphicsView); | ||||||
|  |  | ||||||
|     QRect vRect = rect(); |     QRect vRect = rect(); | ||||||
|  |  | ||||||
|     //Draw corder lines |     // Draw corder lines | ||||||
|     //topLeft |     // topLeft | ||||||
|     scene->addLine(10, 5, 10, 10, QPen(Qt::gray)); |     scene->addLine(10, 5, 10, 10, QPen(Qt::gray)); | ||||||
|     scene->addLine(5, 10, 10, 10, QPen(Qt::gray)); |     scene->addLine(5, 10, 10, 10, QPen(Qt::gray)); | ||||||
|     //bottomLeft |     // bottomLeft | ||||||
|     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)); | ||||||
|     //topRight |     scene->addLine(vRect.right() - 5, vRect.bottom() - 10, vRect.right() - 10, vRect.bottom() - 10, | ||||||
|  |                    QPen(Qt::gray)); | ||||||
|  |     // topRight | ||||||
|     scene->addLine(vRect.width() - 10, 5, vRect.width() - 10, 10, QPen(Qt::gray)); |     scene->addLine(vRect.width() - 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)); | ||||||
|     scene->setSceneRect(vRect); |     scene->setSceneRect(vRect); | ||||||
|     ui->graphicsView->setScene(scene); |     ui->graphicsView->setScene(scene); | ||||||
|     QGraphicsSimpleTextItem * io = new QGraphicsSimpleTextItem(); |     QGraphicsSimpleTextItem* io = new QGraphicsSimpleTextItem(); | ||||||
|     io->setAcceptedMouseButtons(Qt::LeftButton); |     io->setAcceptedMouseButtons(Qt::LeftButton); | ||||||
|     io->setPos(scene->sceneRect().center()); |     io->setPos(scene->sceneRect().center()); | ||||||
|     io->setText(tr("Text")); |     io->setText(tr("Text")); | ||||||
|     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() | ||||||
| { | { | ||||||
| @@ -78,34 +74,33 @@ void BorderFrameEditor::setAllLines() | |||||||
|  |  | ||||||
| void BorderFrameEditor::unSetAllLines() | void BorderFrameEditor::unSetAllLines() | ||||||
| { | { | ||||||
|     if (topLine){ |     if (topLine) { | ||||||
|         scene->removeItem(topLine); |         scene->removeItem(topLine); | ||||||
|         topLine = NULL; |         topLine = NULL; | ||||||
|     } |     } | ||||||
|     if (leftLine){ |     if (leftLine) { | ||||||
|         scene->removeItem(leftLine); |         scene->removeItem(leftLine); | ||||||
|         leftLine = NULL; |         leftLine = NULL; | ||||||
|     } |     } | ||||||
|     if (bottomLine){ |     if (bottomLine) { | ||||||
|         scene->removeItem(bottomLine); |         scene->removeItem(bottomLine); | ||||||
|         bottomLine = NULL; |         bottomLine = NULL; | ||||||
|     } |     } | ||||||
|     if (rightLine){ |     if (rightLine) { | ||||||
|         scene->removeItem(rightLine); |         scene->removeItem(rightLine); | ||||||
|         rightLine = NULL; |         rightLine = NULL; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| void BorderFrameEditor::mousePressEvent(QMouseEvent *event) | void BorderFrameEditor::mousePressEvent(QMouseEvent* event) | ||||||
| { | { | ||||||
|     if (event->x() >= 10 && event->y() <30) |     if (event->x() >= 10 && event->y() < 30) | ||||||
|         emit borderSideClicked(BaseDesignIntf::BorderSide::TopLine, !topLine); |         emit borderSideClicked(BaseDesignIntf::BorderSide::TopLine, !topLine); | ||||||
|  |  | ||||||
|     if ((event->x() >= 10 && event->x() < 30) && (event->y() > 10)) |     if ((event->x() >= 10 && event->x() < 30) && (event->y() > 10)) | ||||||
|         emit borderSideClicked(BaseDesignIntf::BorderSide::LeftLine, !leftLine); |         emit borderSideClicked(BaseDesignIntf::BorderSide::LeftLine, !leftLine); | ||||||
|  |  | ||||||
|     if (event->x() >= 10 && (event->y() >80 && event->y() < rect().bottom())) |     if (event->x() >= 10 && (event->y() > 80 && event->y() < rect().bottom())) | ||||||
|         emit borderSideClicked(BaseDesignIntf::BorderSide::BottomLine, !bottomLine); |         emit borderSideClicked(BaseDesignIntf::BorderSide::BottomLine, !bottomLine); | ||||||
|  |  | ||||||
|     if ((event->x() >= 130 && event->x() < rect().width()) && event->y() > 10) |     if ((event->x() >= 130 && event->x() < rect().width()) && event->y() > 10) | ||||||
| @@ -115,67 +110,80 @@ void BorderFrameEditor::mousePressEvent(QMouseEvent *event) | |||||||
| void BorderFrameEditor::slotBorderSideClicked(BaseDesignIntf::BorderSide side, bool show) | void BorderFrameEditor::slotBorderSideClicked(BaseDesignIntf::BorderSide side, bool show) | ||||||
| { | { | ||||||
|  |  | ||||||
|     switch(side){ |     switch (side) { | ||||||
|  |  | ||||||
|     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(); | ||||||
| } | } | ||||||
|  |  | ||||||
| QGraphicsLineItem *BorderFrameEditor::createSideLine(LimeReport::BaseDesignIntf::BorderSide side) | QGraphicsLineItem* BorderFrameEditor::createSideLine(LimeReport::BaseDesignIntf::BorderSide side) | ||||||
| { | { | ||||||
|     switch(side){ |     switch (side) { | ||||||
|     case BaseDesignIntf::BorderSide::TopLine: |     case BaseDesignIntf::BorderSide::TopLine: | ||||||
|         return scene->addLine(QLineF(10, 10, rect().width() - 10, 10), m_pen); |         return scene->addLine(QLineF(10, 10, rect().width() - 10, 10), m_pen); | ||||||
|     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 | ||||||
|   | |||||||
| @@ -1,46 +1,44 @@ | |||||||
| #ifndef WIDGET | #ifndef WIDGET | ||||||
| #define WIDGET | #define WIDGET | ||||||
|  |  | ||||||
| #include <QWidget> |  | ||||||
| #include <QGraphicsScene> |  | ||||||
| #include <QGraphicsLineItem> |  | ||||||
| #include "lrbasedesignintf.h" | #include "lrbasedesignintf.h" | ||||||
| namespace LimeReport{ |  | ||||||
|  |  | ||||||
| namespace Ui { class BorderFrameEditor; } | #include <QGraphicsLineItem> | ||||||
|  | #include <QGraphicsScene> | ||||||
|  | #include <QWidget> | ||||||
|  | namespace LimeReport { | ||||||
|  |  | ||||||
| class BorderFrameEditor : public QWidget | namespace Ui { | ||||||
| { |     class BorderFrameEditor; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | class BorderFrameEditor: public QWidget { | ||||||
|     Q_OBJECT |     Q_OBJECT | ||||||
|  |  | ||||||
| public: | public: | ||||||
|     BorderFrameEditor(QWidget *parent = nullptr); |     BorderFrameEditor(QWidget* parent = nullptr); | ||||||
|     ~BorderFrameEditor(); |     ~BorderFrameEditor(); | ||||||
|     void setPen(QPen pen); |     void setPen(QPen pen); | ||||||
|     QPen pen(); |     QPen pen(); | ||||||
|     void setAllLines(); |     void setAllLines(); | ||||||
|     void unSetAllLines(); |     void unSetAllLines(); | ||||||
|  |  | ||||||
| protected: | protected: | ||||||
|     void mousePressEvent(QMouseEvent *event); |     void mousePressEvent(QMouseEvent* event); | ||||||
| signals: | signals: | ||||||
|     void borderSideClicked(LimeReport::BaseDesignIntf::BorderSide side, bool show); |     void borderSideClicked(LimeReport::BaseDesignIntf::BorderSide side, bool show); | ||||||
| private slots: | private slots: | ||||||
|     void slotBorderSideClicked(LimeReport::BaseDesignIntf::BorderSide side, bool show); |     void slotBorderSideClicked(LimeReport::BaseDesignIntf::BorderSide side, bool show); | ||||||
|  |  | ||||||
| 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 | ||||||
|   | |||||||
| @@ -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(); | ||||||
| @@ -24,16 +28,17 @@ ChartAxisEditor::~ChartAxisEditor() | |||||||
|  |  | ||||||
| QSettings* ChartAxisEditor::settings() | QSettings* ChartAxisEditor::settings() | ||||||
| { | { | ||||||
|     if (m_settings){ |     if (m_settings) { | ||||||
|         return m_settings; |         return m_settings; | ||||||
|     } |     } | ||||||
|     m_settings = new QSettings("LimeReport",QCoreApplication::applicationName()); |     m_settings = new QSettings("LimeReport", QCoreApplication::applicationName()); | ||||||
|     return m_settings; |     return m_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"); | ||||||
| @@ -50,7 +55,7 @@ void ChartAxisEditor::writeSetting() | |||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|     settings()->beginGroup("ChartAxisEditor"); |     settings()->beginGroup("ChartAxisEditor"); | ||||||
|     settings()->setValue("Geometry",saveGeometry()); |     settings()->setValue("Geometry", saveGeometry()); | ||||||
|     settings()->endGroup(); |     settings()->endGroup(); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -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(); |  | ||||||
| } |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,22 +1,22 @@ | |||||||
| #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, | ||||||
|                     QSettings* settings=0, QWidget *parent = 0); |                     QSettings* settings = 0, QWidget* parent = 0); | ||||||
|     ~ChartAxisEditor(); |     ~ChartAxisEditor(); | ||||||
|  |  | ||||||
|     QSettings *settings(); |     QSettings* settings(); | ||||||
| private slots: | private slots: | ||||||
|     void on_minimumCheckBox_stateChanged(int arg1); |     void on_minimumCheckBox_stateChanged(int arg1); | ||||||
|     void on_maximumCheckBox_stateChanged(int arg1); |     void on_maximumCheckBox_stateChanged(int arg1); | ||||||
| @@ -31,7 +31,7 @@ private: | |||||||
|     void writeSetting(); |     void writeSetting(); | ||||||
|     void init(); |     void init(); | ||||||
|  |  | ||||||
|     Ui::ChartAxisEditor *ui; |     Ui::ChartAxisEditor* ui; | ||||||
|     LimeReport::ChartItem* m_chartItem; |     LimeReport::ChartItem* m_chartItem; | ||||||
|     LimeReport::PageDesignIntf* m_page; |     LimeReport::PageDesignIntf* m_page; | ||||||
|     QSettings* m_settings; |     QSettings* m_settings; | ||||||
|   | |||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1,32 +1,39 @@ | |||||||
| #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 { | ||||||
|  |  | ||||||
| QColor generateColor(); | QColor generateColor(); | ||||||
| extern QColor color_map[39]; | extern QColor color_map[39]; | ||||||
|  |  | ||||||
| class IDataSource; | class IDataSource; | ||||||
|  |  | ||||||
| class SeriesItemData : public QObject{ | class SeriesItemData: public QObject { | ||||||
|     Q_OBJECT |     Q_OBJECT | ||||||
| public: | public: | ||||||
|     QList<qreal>& values(){ return m_values;} |     QList<qreal>& values() { return m_values; } | ||||||
|     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; | ||||||
|     QList<QColor> m_colors; |     QList<QColor> m_colors; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| class SeriesItem : public QObject{ | class SeriesItem: public QObject { | ||||||
|     Q_OBJECT |     Q_OBJECT | ||||||
|     Q_PROPERTY(QString name READ name WRITE setName) |     Q_PROPERTY(QString name READ name WRITE setName) | ||||||
|     Q_PROPERTY(QString valuesColumn READ valuesColumn WRITE setValuesColumn) |     Q_PROPERTY(QString valuesColumn READ valuesColumn WRITE setValuesColumn) | ||||||
| @@ -35,29 +42,33 @@ class SeriesItem : public QObject{ | |||||||
|     Q_PROPERTY(QColor color READ color WRITE setColor) |     Q_PROPERTY(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 | ||||||
|     Q_ENUMS(SeriesItemPreferredType) |     Q_ENUMS(SeriesItemPreferredType) | ||||||
| #endif | #endif | ||||||
|     SeriesItem(QObject* parent = 0) : QObject(parent), m_preferredType(Bar){} |     SeriesItem(QObject* parent = 0): QObject(parent), m_preferredType(Bar) { } | ||||||
|     QString name() const; |     QString name() const; | ||||||
|     void setName(const QString &name); |     void setName(const QString& name); | ||||||
|     QString valuesColumn() const; |     QString valuesColumn() const; | ||||||
|     void setValuesColumn(const QString &valuesColumn); |     void setValuesColumn(const QString& valuesColumn); | ||||||
|     QString labelsColumn() const; |     QString labelsColumn() const; | ||||||
|     void setLabelsColumn(const QString &labelsColumn); |     void setLabelsColumn(const QString& labelsColumn); | ||||||
|     QString xAxisColumn() const; |     QString xAxisColumn() const; | ||||||
|     void setXAxisColumn(const QString &xAxisColumn); |     void setXAxisColumn(const QString& xAxisColumn); | ||||||
|     SeriesItem* clone(); |     SeriesItem* clone(); | ||||||
|     void fillSeriesData(IDataSource* dataSource); |     void fillSeriesData(IDataSource* dataSource); | ||||||
|     SeriesItemData* data(){ return &m_data;} |     SeriesItemData* data() { return &m_data; } | ||||||
|     QColor color() const; |     QColor color() const; | ||||||
|     void setColor(const QColor &color); |     void setColor(const QColor& color); | ||||||
|     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; | ||||||
| @@ -73,17 +84,20 @@ class ChartItem; | |||||||
| class AbstractChart { | class AbstractChart { | ||||||
| public: | public: | ||||||
|     AbstractChart(ChartItem* chartItem); |     AbstractChart(ChartItem* chartItem); | ||||||
|     virtual ~AbstractChart(){} |     virtual ~AbstractChart() { } | ||||||
|     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 | ||||||
| @@ -93,57 +107,60 @@ protected: | |||||||
|     QVector<qreal> m_legendColumnWidths; |     QVector<qreal> m_legendColumnWidths; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| 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; | ||||||
|     qreal maxValue(); |     qreal maxValue(); | ||||||
|     qreal minValue(); |     qreal minValue(); | ||||||
|     void updateMinAndMaxValues(); |     void updateMinAndMaxValues(); | ||||||
|     int valuesCount(); |     int valuesCount(); | ||||||
|     int seriesCount(); |     int seriesCount(); | ||||||
|     bool verticalLabels(QPainter* painter, QRectF labelsRect); |     bool verticalLabels(QPainter* painter, QRectF labelsRect); | ||||||
|     QSizeF calcChartLegendSize(const QFont &font, qreal maxWidth); |     QSizeF calcChartLegendSize(const QFont& font, qreal maxWidth); | ||||||
|     qreal* designValues(){ return m_designValues;} |     qreal* designValues() { return m_designValues; } | ||||||
|     virtual qreal hPadding(QRectF chartRect); |     virtual qreal hPadding(QRectF chartRect); | ||||||
|     virtual qreal vPadding(QRectF chartRect); |     virtual qreal vPadding(QRectF chartRect); | ||||||
|     virtual void paintHorizontalLabels(QPainter *painter, QRectF labelsRect); |     virtual void paintHorizontalLabels(QPainter* painter, QRectF labelsRect); | ||||||
|     virtual void paintVerticalLabels(QPainter *painter, QRectF labelsRect); |     virtual void paintVerticalLabels(QPainter* painter, QRectF labelsRect); | ||||||
|     virtual void paintHorizontalGrid(QPainter *painter, QRectF gridRect); |     virtual void paintHorizontalGrid(QPainter* painter, QRectF gridRect); | ||||||
|     virtual void paintGrid(QPainter *painter, QRectF gridRect); |     virtual void paintGrid(QPainter* painter, QRectF gridRect); | ||||||
|     virtual void paintVerticalGrid(QPainter *painter, QRectF gridRect); |     virtual void paintVerticalGrid(QPainter* painter, QRectF gridRect); | ||||||
|     virtual void drawSegment(QPainter *painter, QPoint startPoint, QPoint endPoint, QColor color); |     virtual void drawSegment(QPainter* painter, QPoint startPoint, QPoint endPoint, QColor color); | ||||||
|     virtual qreal valuesHMargin(QPainter *painter); |     virtual qreal valuesHMargin(QPainter* painter); | ||||||
|     virtual qreal valuesVMargin(QPainter *painter); |     virtual qreal valuesVMargin(QPainter* painter); | ||||||
|     virtual QFont adaptLabelsFont(QRectF rect, QFont font); |     virtual QFont adaptLabelsFont(QRectF rect, QFont font); | ||||||
|     virtual QFont adaptFont(qreal width, QFont font, const AxisData &axisData); |     virtual QFont adaptFont(qreal width, QFont font, const AxisData& axisData); | ||||||
|     virtual QString axisLabel(int i, const AxisData &axisData); |     virtual QString axisLabel(int i, const AxisData& axisData); | ||||||
|  |  | ||||||
| private: | private: | ||||||
|     bool calculateLegendColumnWidths(qreal indicatorWidth, qreal maxWidth, const QFontMetrics &fm); |     bool calculateLegendColumnWidths(qreal indicatorWidth, qreal maxWidth, const QFontMetrics& fm); | ||||||
|     bool calculateLegendSingleColumnWidth(qreal ¤tRowWidth, int ¤tColumn, int &maxColumnCount, |     bool calculateLegendSingleColumnWidth(qreal& currentRowWidth, int& currentColumn, | ||||||
|                                           const qreal itemWidth, const qreal maxRowWidth); |                                           int& maxColumnCount, const qreal itemWidth, | ||||||
|     qreal m_designValues [9]; |                                           const qreal maxRowWidth); | ||||||
|  |     qreal m_designValues[9]; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| class AbstractBarChart: public AbstractSeriesChart{ | 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) | ||||||
| @@ -160,23 +177,42 @@ class ChartItem : public LimeReport::ItemDesignIntf | |||||||
|     Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont) |     Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont) | ||||||
|     Q_PROPERTY(QFont font READ font WRITE setCharItemFont) |     Q_PROPERTY(QFont font READ font WRITE setCharItemFont) | ||||||
|  |  | ||||||
|     //linesChart |     // linesChart | ||||||
|     Q_PROPERTY(bool drawPoints READ drawPoints WRITE setDrawPoints) |     Q_PROPERTY(bool drawPoints READ drawPoints WRITE setDrawPoints) | ||||||
|     Q_PROPERTY(int seriesLineWidth READ seriesLineWidth WRITE setSeriesLineWidth) |     Q_PROPERTY(int seriesLineWidth READ seriesLineWidth WRITE setSeriesLineWidth) | ||||||
|     Q_PROPERTY(bool horizontalAxisOnTop READ horizontalAxisOnTop WRITE setHorizontalAxisOnTop) |     Q_PROPERTY(bool horizontalAxisOnTop READ horizontalAxisOnTop WRITE setHorizontalAxisOnTop) | ||||||
|  |  | ||||||
|     //gridChart |     // gridChart | ||||||
|     Q_FLAGS(GridChartLines) |     Q_FLAGS(GridChartLines) | ||||||
|     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, | ||||||
| @@ -200,48 +236,48 @@ public: | |||||||
|  |  | ||||||
|     ChartItem(QObject* owner, QGraphicsItem* parent); |     ChartItem(QObject* owner, QGraphicsItem* parent); | ||||||
|     ~ChartItem(); |     ~ChartItem(); | ||||||
|     virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); |     virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget); | ||||||
|  |  | ||||||
|     QObject* xAxisSettings(); |     QObject* xAxisSettings(); | ||||||
|     void setYAxisSettings(QObject *axis); |     void setYAxisSettings(QObject* axis); | ||||||
|     QObject* yAxisSettings(); |     QObject* yAxisSettings(); | ||||||
|     void setXAxisSettings(QObject *axis); |     void setXAxisSettings(QObject* axis); | ||||||
|  |  | ||||||
|     AxisData *xAxisData(); |     AxisData* xAxisData(); | ||||||
|     AxisData *yAxisData(); |     AxisData* yAxisData(); | ||||||
|  |  | ||||||
|     void showAxisEditorDialog(bool isXAxis); |     void showAxisEditorDialog(bool isXAxis); | ||||||
|  |  | ||||||
|     QList<SeriesItem *> &series(); |     QList<SeriesItem*>& series(); | ||||||
|     void setSeries(const QList<SeriesItem *> &series); |     void setSeries(const QList<SeriesItem*>& series); | ||||||
|     bool isSeriesExists(const QString& name); |     bool isSeriesExists(const QString& name); | ||||||
|  |  | ||||||
|     QString datasource() const; |     QString datasource() const; | ||||||
|     void setDatasource(const QString &datasource); |     void setDatasource(const QString& datasource); | ||||||
|  |  | ||||||
|     QString chartTitle() const; |     QString chartTitle() const; | ||||||
|     void setChartTitle(const QString &chartTitle); |     void setChartTitle(const QString& chartTitle); | ||||||
|  |  | ||||||
|     bool drawLegendBorder() const; |     bool drawLegendBorder() const; | ||||||
|     void setDrawLegendBorder(bool drawLegendBorder); |     void setDrawLegendBorder(bool drawLegendBorder); | ||||||
|  |  | ||||||
|     LegendAlign legendAlign() const; |     LegendAlign legendAlign() const; | ||||||
|     void setLegendAlign(const LegendAlign &legendAlign); |     void setLegendAlign(const LegendAlign& legendAlign); | ||||||
|  |  | ||||||
|     LegendStyle legendStyle() const; |     LegendStyle legendStyle() const; | ||||||
|     void setLegendStyle(const LegendStyle &legendStyle); |     void setLegendStyle(const LegendStyle& legendStyle); | ||||||
|  |  | ||||||
|     TitleAlign titleAlign() const; |     TitleAlign titleAlign() const; | ||||||
|     void setTitleAlign(const TitleAlign &titleAlign); |     void setTitleAlign(const TitleAlign& titleAlign); | ||||||
|  |  | ||||||
|     ChartType chartType() const; |     ChartType chartType() const; | ||||||
|     void setChartType(const ChartType &chartType); |     void setChartType(const ChartType& chartType); | ||||||
|  |  | ||||||
|     QString labelsField() const; |     QString labelsField() const; | ||||||
|     void setLabelsField(const QString &labelsField); |     void setLabelsField(const QString& labelsField); | ||||||
|  |  | ||||||
|     QList<QString> labels() const; |     QList<QString> labels() const; | ||||||
|     void setLabels(const QList<QString> &labels); |     void setLabels(const QList<QString>& labels); | ||||||
|     QWidget* defaultEditor(); |     QWidget* defaultEditor(); | ||||||
|  |  | ||||||
|     bool showLegend() const; |     bool showLegend() const; | ||||||
| @@ -254,7 +290,7 @@ public: | |||||||
|     void setSeriesLineWidth(int newSeriesLineWidth); |     void setSeriesLineWidth(int newSeriesLineWidth); | ||||||
|  |  | ||||||
|     QString xAxisField() const; |     QString xAxisField() const; | ||||||
|     void setXAxisField(const QString &xAxisField); |     void setXAxisField(const QString& xAxisField); | ||||||
|  |  | ||||||
|     bool horizontalAxisOnTop() const; |     bool horizontalAxisOnTop() const; | ||||||
|     void setHorizontalAxisOnTop(bool horizontalAxisOnTop); |     void setHorizontalAxisOnTop(bool horizontalAxisOnTop); | ||||||
| @@ -266,20 +302,21 @@ public: | |||||||
|     void setTitleFont(QFont value); |     void setTitleFont(QFont value); | ||||||
|     void setCharItemFont(QFont value); |     void setCharItemFont(QFont value); | ||||||
|  |  | ||||||
|     QSettings *settings(); |     QSettings* settings(); | ||||||
|  |  | ||||||
| protected: | protected: | ||||||
|     void paintChartTitle(QPainter* painter, QRectF titleRect); |     void paintChartTitle(QPainter* painter, QRectF titleRect); | ||||||
|     virtual BaseDesignIntf* createSameTypeItem(QObject *owner, QGraphicsItem *parent); |     virtual BaseDesignIntf* createSameTypeItem(QObject* owner, QGraphicsItem* parent); | ||||||
|     //ICollectionContainer |     // ICollectionContainer | ||||||
|     QObject* createElement(const QString& collectionName, const QString& elementType); |     QObject* createElement(const QString& collectionName, const QString& elementType); | ||||||
|     int elementsCount(const QString& collectionName); |     int elementsCount(const QString& collectionName); | ||||||
|     QObject* elementAt(const QString& collectionName,int index); |     QObject* elementAt(const QString& collectionName, int index); | ||||||
|     void collectionLoadFinished(const QString& collectionName){Q_UNUSED(collectionName)}     |     void collectionLoadFinished(const QString& collectionName) { Q_UNUSED(collectionName) } | ||||||
|     void updateItemSize(DataSourceManager *dataManager, RenderPass, int); |     void updateItemSize(DataSourceManager* dataManager, RenderPass, int); | ||||||
|     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; | ||||||
| @@ -288,9 +325,9 @@ private: | |||||||
|     AbstractChart* m_chart; |     AbstractChart* m_chart; | ||||||
|     bool m_legendBorder; |     bool m_legendBorder; | ||||||
|     LegendAlign m_legendAlign; |     LegendAlign m_legendAlign; | ||||||
|     TitleAlign  m_titleAlign; |     TitleAlign m_titleAlign; | ||||||
|     ChartType   m_chartType; |     ChartType m_chartType; | ||||||
|     QString     m_labelsField; |     QString m_labelsField; | ||||||
|     QList<QString> m_labels; |     QList<QString> m_labels; | ||||||
|     bool m_isEmpty; |     bool m_isEmpty; | ||||||
|     bool m_showLegend; |     bool m_showLegend; | ||||||
| @@ -302,5 +339,5 @@ private: | |||||||
|     LegendStyle m_legendStyle; |     LegendStyle m_legendStyle; | ||||||
|     AxisData *m_xAxisData, *m_yAxisData; |     AxisData *m_xAxisData, *m_yAxisData; | ||||||
| }; | }; | ||||||
| } //namespace LimeReport | } // namespace LimeReport | ||||||
| #endif // LRCHARTITEM_H | #endif // LRCHARTITEM_H | ||||||
|   | |||||||
| @@ -1,21 +1,29 @@ | |||||||
| #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(); | ||||||
|     colorLayout->setContentsMargins(0, 0, 0, 0); |     colorLayout->setContentsMargins(0, 0, 0, 0); | ||||||
|     m_colorButton = new QToolButton(); |     m_colorButton = new QToolButton(); | ||||||
|     m_colorButton->setText("..."); |     m_colorButton->setText("..."); | ||||||
|     m_colorButton->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); |     m_colorButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); | ||||||
|     m_colorIndicator = new ColorIndicator(); |     m_colorIndicator = new ColorIndicator(); | ||||||
|     m_colorIndicator->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); |     m_colorIndicator->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); | ||||||
|     ui->colorWidget->setLayout(colorLayout); |     ui->colorWidget->setLayout(colorLayout); | ||||||
|     colorLayout->addWidget(m_colorIndicator); |     colorLayout->addWidget(m_colorIndicator); | ||||||
|     colorLayout->addWidget(m_colorButton); |     colorLayout->addWidget(m_colorButton); | ||||||
| @@ -38,10 +46,10 @@ ChartItemEditor::~ChartItemEditor() | |||||||
|  |  | ||||||
| QSettings* ChartItemEditor::settings() | QSettings* ChartItemEditor::settings() | ||||||
| { | { | ||||||
|     if (m_settings){ |     if (m_settings) { | ||||||
|         return m_settings; |         return m_settings; | ||||||
|     } else { |     } else { | ||||||
|         m_settings = new QSettings("LimeReport",QCoreApplication::applicationName()); |         m_settings = new QSettings("LimeReport", QCoreApplication::applicationName()); | ||||||
|         m_ownedSettings = true; |         m_ownedSettings = true; | ||||||
|         return m_settings; |         return m_settings; | ||||||
|     } |     } | ||||||
| @@ -49,17 +57,18 @@ QSettings* ChartItemEditor::settings() | |||||||
|  |  | ||||||
| void ChartItemEditor::readSetting() | void ChartItemEditor::readSetting() | ||||||
| { | { | ||||||
|     if (settings()==0) return; |     if (settings() == 0) | ||||||
|  |         return; | ||||||
|  |  | ||||||
|     m_isReadingSetting = true; |     m_isReadingSetting = true; | ||||||
|  |  | ||||||
|     settings()->beginGroup("ChartItemEditor"); |     settings()->beginGroup("ChartItemEditor"); | ||||||
|     QVariant v = settings()->value("Geometry"); |     QVariant v = settings()->value("Geometry"); | ||||||
|     if (v.isValid()){ |     if (v.isValid()) { | ||||||
|         restoreGeometry(v.toByteArray()); |         restoreGeometry(v.toByteArray()); | ||||||
|     } |     } | ||||||
|     v = settings()->value("State"); |     v = settings()->value("State"); | ||||||
|     if (v.isValid()){ |     if (v.isValid()) { | ||||||
|         ui->splitter->restoreState(v.toByteArray()); |         ui->splitter->restoreState(v.toByteArray()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -70,10 +79,10 @@ void ChartItemEditor::readSetting() | |||||||
|  |  | ||||||
| void ChartItemEditor::writeSetting() | void ChartItemEditor::writeSetting() | ||||||
| { | { | ||||||
|     if (settings()!=0){ |     if (settings() != 0) { | ||||||
|         settings()->beginGroup("ChartItemEditor"); |         settings()->beginGroup("ChartItemEditor"); | ||||||
|         settings()->setValue("Geometry",saveGeometry()); |         settings()->setValue("Geometry", saveGeometry()); | ||||||
|         settings()->setValue("State",ui->splitter->saveState()); |         settings()->setValue("State", ui->splitter->saveState()); | ||||||
|         settings()->endGroup(); |         settings()->endGroup(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @@ -82,9 +91,9 @@ void ChartItemEditor::rebuildTable() | |||||||
| { | { | ||||||
|     ui->tableWidget->clearContents(); |     ui->tableWidget->clearContents(); | ||||||
|     ui->tableWidget->setRowCount(m_charItem->series().count()); |     ui->tableWidget->setRowCount(m_charItem->series().count()); | ||||||
|     for( int i=0;i<m_charItem->series().count();++i){ |     for (int i = 0; i < m_charItem->series().count(); ++i) { | ||||||
|         QTableWidgetItem* newRow = new QTableWidgetItem(m_charItem->series().at(i)->name()); |         QTableWidgetItem* newRow = new QTableWidgetItem(m_charItem->series().at(i)->name()); | ||||||
|         ui->tableWidget->setItem(i,0,newRow); |         ui->tableWidget->setItem(i, 0, newRow); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -95,38 +104,41 @@ void ChartItemEditor::init() | |||||||
|     ui->tableWidget->setColumnCount(1); |     ui->tableWidget->setColumnCount(1); | ||||||
|     ui->tableWidget->setRowCount(m_charItem->series().count()); |     ui->tableWidget->setRowCount(m_charItem->series().count()); | ||||||
|     ui->tableWidget->horizontalHeader()->setStretchLastSection(true); |     ui->tableWidget->horizontalHeader()->setStretchLastSection(true); | ||||||
|     ui->tableWidget->setHorizontalHeaderItem(0,new QTableWidgetItem(tr("Series name"))); |     ui->tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Series name"))); | ||||||
|  |  | ||||||
|     rebuildTable(); |     rebuildTable(); | ||||||
|  |  | ||||||
|     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 | ||||||
|             if (ds){ |                 = m_page->datasourceManager()->dataSource(m_charItem->datasource()); | ||||||
|                 for (int i=0;i<ds->columnCount();++i){ |             if (ds) { | ||||||
|                    ui->valuesFieldComboBox->addItem(ds->columnNameByIndex(i)); |                 for (int i = 0; i < ds->columnCount(); ++i) { | ||||||
|                    ui->labelsFieldComboBox->addItem(ds->columnNameByIndex(i)); |                     ui->valuesFieldComboBox->addItem(ds->columnNameByIndex(i)); | ||||||
|                    ui->xAxisFieldComboBox->addItem(ds->columnNameByIndex(i)); |                     ui->labelsFieldComboBox->addItem(ds->columnNameByIndex(i)); | ||||||
|  |                     ui->xAxisFieldComboBox->addItem(ds->columnNameByIndex(i)); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     static int enumIndex = LimeReport::SeriesItem::staticMetaObject.indexOfEnumerator("SeriesItemPreferredType"); |     static int enumIndex | ||||||
|  |         = LimeReport::SeriesItem::staticMetaObject.indexOfEnumerator("SeriesItemPreferredType"); | ||||||
|     QMetaEnum enumerator = LimeReport::SeriesItem::staticMetaObject.enumerator(enumIndex); |     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()); | ||||||
| #endif | #endif | ||||||
|     if (!m_charItem->series().isEmpty()){ |     if (!m_charItem->series().isEmpty()) { | ||||||
|         enableSeriesEditor(); |         enableSeriesEditor(); | ||||||
|         ui->tableWidget->selectRow(0); |         ui->tableWidget->selectRow(0); | ||||||
|     } else { |     } else { | ||||||
| @@ -160,30 +172,30 @@ void ChartItemEditor::disableSeriesEditor() | |||||||
|     ui->seriesTypeComboBox->setDisabled(true); |     ui->seriesTypeComboBox->setDisabled(true); | ||||||
| } | } | ||||||
|  |  | ||||||
| LimeReport::SeriesItem *ChartItemEditor::currentSeries() | LimeReport::SeriesItem* ChartItemEditor::currentSeries() | ||||||
| { | { | ||||||
|     int curRow = ui->tableWidget->currentRow(); |     int curRow = ui->tableWidget->currentRow(); | ||||||
|     if ((curRow>-1) && !m_charItem->series().isEmpty() && m_charItem->series().count()>curRow){ |     if ((curRow > -1) && !m_charItem->series().isEmpty() && m_charItem->series().count() > curRow) { | ||||||
|         return m_charItem->series().at(curRow); |         return m_charItem->series().at(curRow); | ||||||
|     } |     } | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| void ChartItemEditor::resizeEvent(QResizeEvent *) | void ChartItemEditor::resizeEvent(QResizeEvent*) | ||||||
| { | { | ||||||
| #ifdef Q_OS_UNIX | #ifdef Q_OS_UNIX | ||||||
|     writeSetting(); |     writeSetting(); | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
| void ChartItemEditor::moveEvent(QMoveEvent *) | void ChartItemEditor::moveEvent(QMoveEvent*) | ||||||
| { | { | ||||||
| #ifdef Q_OS_UNIX | #ifdef Q_OS_UNIX | ||||||
|     writeSetting(); |     writeSetting(); | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
| void ChartItemEditor::on_splitter_splitterMoved(int , int ) | void ChartItemEditor::on_splitter_splitterMoved(int, int) | ||||||
| { | { | ||||||
| #ifdef Q_OS_UNIX | #ifdef Q_OS_UNIX | ||||||
|     writeSetting(); |     writeSetting(); | ||||||
| @@ -200,15 +212,19 @@ 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))) | ||||||
|     series->setName("Series"+QString::number(curSeriesNumber)); |         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, | ||||||
|     ui->tableWidget->selectRow(m_charItem->series().count()-1); |                              new QTableWidgetItem(series->name())); | ||||||
|  |     ui->tableWidget->selectRow(m_charItem->series().count() - 1); | ||||||
| #if QT_VERSION < 0x050000 | #if QT_VERSION < 0x050000 | ||||||
|     ui->valuesFieldComboBox->setEditText(""); |     ui->valuesFieldComboBox->setEditText(""); | ||||||
| #else | #else | ||||||
| @@ -219,10 +235,10 @@ void ChartItemEditor::slotAddSeries() | |||||||
| void ChartItemEditor::slotDeleteSeries() | void ChartItemEditor::slotDeleteSeries() | ||||||
| { | { | ||||||
|     QList<LimeReport::SeriesItem*> itemsToRemove; |     QList<LimeReport::SeriesItem*> itemsToRemove; | ||||||
|     foreach(QModelIndex index,ui->tableWidget->selectionModel()->selectedRows()){ |     foreach (QModelIndex index, ui->tableWidget->selectionModel()->selectedRows()) { | ||||||
|       itemsToRemove.append(m_charItem->series().at(index.row())); |         itemsToRemove.append(m_charItem->series().at(index.row())); | ||||||
|     }; |     }; | ||||||
|     foreach (LimeReport::SeriesItem* series, itemsToRemove){ |     foreach (LimeReport::SeriesItem* series, itemsToRemove) { | ||||||
|         m_charItem->series().removeOne(series); |         m_charItem->series().removeOne(series); | ||||||
|         delete series; |         delete series; | ||||||
|     } |     } | ||||||
| @@ -232,19 +248,23 @@ 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 | ||||||
| @@ -252,22 +272,22 @@ void ChartItemEditor::on_tableWidget_itemSelectionChanged() | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void ChartItemEditor::on_seriesNameLineEdit_textChanged(const QString &arg1) | void ChartItemEditor::on_seriesNameLineEdit_textChanged(const QString& arg1) | ||||||
| { | { | ||||||
|     if (currentSeries()){ |     if (currentSeries()) { | ||||||
|         currentSeries()->setName(arg1); |         currentSeries()->setName(arg1); | ||||||
|         ui->tableWidget->currentItem()->setText(arg1); |         ui->tableWidget->currentItem()->setText(arg1); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void ChartItemEditor::on_valuesFieldComboBox_currentTextChanged(const QString &arg1) | void ChartItemEditor::on_valuesFieldComboBox_currentTextChanged(const QString& arg1) | ||||||
| { | { | ||||||
|     if (currentSeries()){ |     if (currentSeries()) { | ||||||
|         currentSeries()->setValuesColumn(arg1); |         currentSeries()->setValuesColumn(arg1); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void ChartItemEditor::on_labelsFieldComboBox_currentTextChanged(const QString &arg1) | void ChartItemEditor::on_labelsFieldComboBox_currentTextChanged(const QString& arg1) | ||||||
| { | { | ||||||
|     if (!m_initing) |     if (!m_initing) | ||||||
|         m_charItem->setLabelsField(arg1); |         m_charItem->setLabelsField(arg1); | ||||||
| @@ -276,27 +296,30 @@ void ChartItemEditor::on_labelsFieldComboBox_currentTextChanged(const QString &a | |||||||
| void ChartItemEditor::slotChangeSeriesColor() | void ChartItemEditor::slotChangeSeriesColor() | ||||||
| { | { | ||||||
|     QColorDialog colorDialog; |     QColorDialog colorDialog; | ||||||
|     if (colorDialog.exec()){ |     if (colorDialog.exec()) { | ||||||
|         currentSeries()->setColor(colorDialog.selectedColor()); |         currentSeries()->setColor(colorDialog.selectedColor()); | ||||||
|         m_colorIndicator->setColor(colorDialog.selectedColor()); |         m_colorIndicator->setColor(colorDialog.selectedColor()); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void ChartItemEditor::on_seriesTypeComboBox_currentIndexChanged(const QString &arg1) | void ChartItemEditor::on_seriesTypeComboBox_currentIndexChanged(const QString& arg1) | ||||||
| { | { | ||||||
|     static int enumIndex = LimeReport::SeriesItem::staticMetaObject.indexOfEnumerator("SeriesItemPreferredType"); |     static int enumIndex | ||||||
|  |         = LimeReport::SeriesItem::staticMetaObject.indexOfEnumerator("SeriesItemPreferredType"); | ||||||
|     QMetaEnum enumerator = LimeReport::SeriesItem::staticMetaObject.enumerator(enumIndex); |     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()))); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void ChartItemEditor::on_xAxisFieldComboBox_currentTextChanged(const QString &arg1) | void ChartItemEditor::on_xAxisFieldComboBox_currentTextChanged(const QString& arg1) | ||||||
| { | { | ||||||
|     if (!m_initing) |     if (!m_initing) | ||||||
|         m_charItem->setXAxisField(arg1); |         m_charItem->setXAxisField(arg1); | ||||||
| } | } | ||||||
| void ChartItemEditor::on_tableWidget_itemChanged(QTableWidgetItem *item) | void ChartItemEditor::on_tableWidget_itemChanged(QTableWidgetItem* item) | ||||||
| { | { | ||||||
|     if (ui->seriesNameLineEdit->hasFocus()) |     if (ui->seriesNameLineEdit->hasFocus()) | ||||||
|         return; |         return; | ||||||
|   | |||||||
| @@ -1,30 +1,31 @@ | |||||||
| #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(); | ||||||
|  |  | ||||||
| protected: | protected: | ||||||
|     void resizeEvent(QResizeEvent *); |     void resizeEvent(QResizeEvent*); | ||||||
|     void moveEvent(QMoveEvent *); |     void moveEvent(QMoveEvent*); | ||||||
|  |  | ||||||
| signals: | signals: | ||||||
|     void editingFinished(); |     void editingFinished(); | ||||||
| @@ -35,13 +36,13 @@ private slots: | |||||||
|     void slotAddSeries(); |     void slotAddSeries(); | ||||||
|     void slotDeleteSeries(); |     void slotDeleteSeries(); | ||||||
|     void on_tableWidget_itemSelectionChanged(); |     void on_tableWidget_itemSelectionChanged(); | ||||||
|     void on_seriesNameLineEdit_textChanged(const QString &arg1); |     void on_seriesNameLineEdit_textChanged(const QString& arg1); | ||||||
|     void on_valuesFieldComboBox_currentTextChanged(const QString &arg1); |     void on_valuesFieldComboBox_currentTextChanged(const QString& arg1); | ||||||
|     void on_labelsFieldComboBox_currentTextChanged(const QString &arg1); |     void on_labelsFieldComboBox_currentTextChanged(const QString& arg1); | ||||||
|     void slotChangeSeriesColor(); |     void slotChangeSeriesColor(); | ||||||
|     void on_seriesTypeComboBox_currentIndexChanged(const QString &arg1); |     void on_seriesTypeComboBox_currentIndexChanged(const QString& arg1); | ||||||
|     void on_xAxisFieldComboBox_currentTextChanged(const QString &arg1); |     void on_xAxisFieldComboBox_currentTextChanged(const QString& arg1); | ||||||
|     void on_tableWidget_itemChanged(QTableWidgetItem *item); |     void on_tableWidget_itemChanged(QTableWidgetItem* item); | ||||||
|  |  | ||||||
| private: | private: | ||||||
|     void readSetting(); |     void readSetting(); | ||||||
| @@ -50,8 +51,9 @@ 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; | ||||||
|     LimeReport::PageDesignIntf* m_page; |     LimeReport::PageDesignIntf* m_page; | ||||||
|     QSettings* m_settings; |     QSettings* m_settings; | ||||||
|   | |||||||
| @@ -5,16 +5,15 @@ | |||||||
|  |  | ||||||
| namespace LimeReport { | namespace LimeReport { | ||||||
|  |  | ||||||
| class IEditableImageItem{ | class IEditableImageItem { | ||||||
| public: | public: | ||||||
|     virtual QByteArray imageAsByteArray() const = 0; |     virtual QByteArray imageAsByteArray() const = 0; | ||||||
|     virtual void setImageAsByteArray(QByteArray image) = 0; |     virtual void setImageAsByteArray(QByteArray image) = 0; | ||||||
|     virtual QString resourcePath() const  = 0; |     virtual QString resourcePath() const = 0; | ||||||
|     virtual void setResourcePath(const QString &value) = 0; |     virtual void setResourcePath(const QString& value) = 0; | ||||||
|     virtual QString fileFilter() const = 0; |     virtual QString fileFilter() const = 0; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| } | } // namespace LimeReport | ||||||
|  |  | ||||||
|  |  | ||||||
| #endif // LREDITABLEIMAGEITEMINTF_H | #endif // LREDITABLEIMAGEITEMINTF_H | ||||||
|   | |||||||
| @@ -28,101 +28,105 @@ | |||||||
|  *   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"; | ||||||
|  |  | ||||||
| namespace { | namespace { | ||||||
|  |  | ||||||
| LimeReport::BaseDesignIntf *createHLayout(QObject *owner, LimeReport::BaseDesignIntf  *parent) | LimeReport::BaseDesignIntf* createHLayout(QObject* owner, LimeReport::BaseDesignIntf* parent) | ||||||
| { | { | ||||||
|     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) | ||||||
| { | { | ||||||
|     return new LimeReport::HorizontalLayout(owner, parent); |     return new LimeReport::HorizontalLayout(owner, parent); | ||||||
| } | } | ||||||
|  |  | ||||||
| bool HorizontalLayout::canBeSplitted(int height) const | 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()) { | ||||||
|  |  | ||||||
|         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())); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     foreach(BaseDesignIntf* item, upperPart->childBaseItems()){ |     foreach (BaseDesignIntf* item, upperPart->childBaseItems()) { | ||||||
|         item->setHeight((maxHeight<height)?maxHeight:height); |         item->setHeight((maxHeight < height) ? maxHeight : height); | ||||||
|     } |     } | ||||||
|     upperPart->setHeight(height); |     upperPart->setHeight(height); | ||||||
|  |  | ||||||
|     return upperPart; |     return upperPart; | ||||||
| } | } | ||||||
|  |  | ||||||
| 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)) { | ||||||
|             BaseDesignIntf* tmpItem=item->cloneBottomPart(height,bottomPart,bottomPart); |             BaseDesignIntf* tmpItem = item->cloneBottomPart(height, bottomPart, bottomPart); | ||||||
|             tmpItem->setPos(tmpItem->pos().x(),0); |             tmpItem->setPos(tmpItem->pos().x(), 0); | ||||||
|             if (maxHeight<tmpItem->height()) |             if (maxHeight < tmpItem->height()) | ||||||
|                 maxHeight = tmpItem->height(); |                 maxHeight = tmpItem->height(); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (!bottomPart->isEmpty()){ |     if (!bottomPart->isEmpty()) { | ||||||
|         foreach (BaseDesignIntf* item, bottomPart->childBaseItems()) { |         foreach (BaseDesignIntf* item, bottomPart->childBaseItems()) { | ||||||
|             item->setHeight(maxHeight); |             item->setHeight(maxHeight); | ||||||
|         } |         } | ||||||
| @@ -131,7 +135,7 @@ BaseDesignIntf *HorizontalLayout::cloneBottomPart(int height, QObject *owner, QG | |||||||
|     return bottomPart; |     return bottomPart; | ||||||
| } | } | ||||||
|  |  | ||||||
| void HorizontalLayout::setItemAlign(const BaseDesignIntf::ItemAlign &itemAlign) | void HorizontalLayout::setItemAlign(const BaseDesignIntf::ItemAlign& itemAlign) | ||||||
| { | { | ||||||
|     if (itemAlign == ParentWidthItemAlign) |     if (itemAlign == ParentWidthItemAlign) | ||||||
|         setLayoutType(Table); |         setLayoutType(Table); | ||||||
| @@ -140,29 +144,32 @@ void HorizontalLayout::setItemAlign(const BaseDesignIntf::ItemAlign &itemAlign) | |||||||
|  |  | ||||||
| void HorizontalLayout::sortChildren() | void HorizontalLayout::sortChildren() | ||||||
| { | { | ||||||
|     std::sort(layoutsChildren().begin(),layoutsChildren().end(),horizontalLessThen); |     std::sort(layoutsChildren().begin(), layoutsChildren().end(), horizontalLessThen); | ||||||
| } | } | ||||||
|  |  | ||||||
| void HorizontalLayout::updateLayoutSize() | void HorizontalLayout::updateLayoutSize() | ||||||
| { | { | ||||||
|     int spaceBorder = (borderLines() != 0) ? borderLineSize() : 0; |     int spaceBorder = (borderLines() != 0) ? borderLineSize() : 0; | ||||||
|     qreal w = spaceBorder*2; |     qreal w = spaceBorder * 2; | ||||||
|     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()) | ||||||
|         if (item->isVisible()){ |             item->setVisible(false); | ||||||
|             if (h<item->height()) h=item->height(); |         if (item->isVisible()) { | ||||||
|             w+=item->width(); |             if (h < item->height()) | ||||||
|  |                 h = item->height(); | ||||||
|  |             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 { | ||||||
|         relocateChildren(); |         relocateChildren(); | ||||||
|         if (!isRelocating()){ |         if (!isRelocating()) { | ||||||
|             divideSpace(); |             divideSpace(); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -172,7 +179,7 @@ void HorizontalLayout::relocateChildren() | |||||||
| { | { | ||||||
|     int spaceBorder = (borderLines() != 0) ? borderLineSize() : 0; |     int spaceBorder = (borderLines() != 0) ? borderLineSize() : 0; | ||||||
|     QList<BaseDesignIntf*> newChildren; |     QList<BaseDesignIntf*> newChildren; | ||||||
|     if (layoutsChildren().count() < childItems().size()-1){ |     if (layoutsChildren().count() < childItems().size() - 1) { | ||||||
|         auto oldChildren = layoutsChildren(); |         auto oldChildren = layoutsChildren(); | ||||||
|         layoutsChildren().clear(); |         layoutsChildren().clear(); | ||||||
|         foreach (BaseDesignIntf* item, childBaseItems()) { |         foreach (BaseDesignIntf* item, childBaseItems()) { | ||||||
| @@ -182,14 +189,14 @@ void HorizontalLayout::relocateChildren() | |||||||
|             layoutsChildren().append(item); |             layoutsChildren().append(item); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     std::sort(layoutsChildren().begin(),layoutsChildren().end(),horizontalLessThen); |     std::sort(layoutsChildren().begin(), layoutsChildren().end(), horizontalLessThen); | ||||||
|     qreal curX = spaceBorder; |     qreal curX = spaceBorder; | ||||||
|     setIsRelocating(true); |     setIsRelocating(true); | ||||||
|     foreach (BaseDesignIntf* item, layoutsChildren()) { |     foreach (BaseDesignIntf* item, layoutsChildren()) { | ||||||
|         if (item->isVisible() || itemMode() == DesignMode){ |         if (item->isVisible() || itemMode() == DesignMode) { | ||||||
|             item->setPos(curX,spaceBorder); |             item->setPos(curX, spaceBorder); | ||||||
|             curX += item->width() + layoutSpacingMM(); |             curX += item->width() + layoutSpacingMM(); | ||||||
|             item->setHeight(height()-(spaceBorder * 2)); |             item->setHeight(height() - (spaceBorder * 2)); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     setIsRelocating(false); |     setIsRelocating(false); | ||||||
| @@ -199,32 +206,36 @@ 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; | ||||||
|     int spaceBorder = (borderLines() != 0) ? borderLineSize() : 0; |     int spaceBorder = (borderLines() != 0) ? borderLineSize() : 0; | ||||||
|  |  | ||||||
|     foreach(BaseDesignIntf* item, layoutsChildren()){ |     foreach (BaseDesignIntf* item, layoutsChildren()) { | ||||||
|         if (item->isVisible() || itemMode() == DesignMode ){ |         if (item->isVisible() || itemMode() == DesignMode) { | ||||||
|             itemsSumSize += item->width(); |             itemsSumSize += item->width(); | ||||||
|             visibleItemsCount++; |             visibleItemsCount++; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     itemsSumSize += layoutSpacingMM() * (visibleItemsCount-1); |     itemsSumSize += layoutSpacingMM() * (visibleItemsCount - 1); | ||||||
|  |  | ||||||
|     if (itemMode() == DesignMode && !layoutsChildren().isEmpty()){ |     if (itemMode() == DesignMode && !layoutsChildren().isEmpty()) { | ||||||
|         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)) | ||||||
|         for (int i=0; i<layoutsChildren().size(); ++i){ |             / (visibleItemsCount != 0 ? visibleItemsCount : 1); | ||||||
|  |         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); | ||||||
|   | |||||||
| @@ -29,34 +29,32 @@ | |||||||
|  ****************************************************************************/ |  ****************************************************************************/ | ||||||
| #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: | ||||||
|     friend class LayoutMarker; |     friend class LayoutMarker; | ||||||
|     friend class BaseDesignIntf; |     friend class BaseDesignIntf; | ||||||
|  |  | ||||||
|     HorizontalLayout(QObject *owner = 0, QGraphicsItem *parent = 0); |     HorizontalLayout(QObject* owner = 0, QGraphicsItem* parent = 0); | ||||||
|     ~HorizontalLayout(); |     ~HorizontalLayout(); | ||||||
|     BaseDesignIntf *createSameTypeItem(QObject *owner = 0, QGraphicsItem *parent = 0); |     BaseDesignIntf* createSameTypeItem(QObject* owner = 0, QGraphicsItem* parent = 0); | ||||||
|     bool isSplittable() const { return true;} |     bool isSplittable() const { return true; } | ||||||
|     bool canContainChildren() const { return true;} |     bool canContainChildren() const { return true; } | ||||||
|  |  | ||||||
| protected: | protected: | ||||||
|     void updateLayoutSize(); |     void updateLayoutSize(); | ||||||
|     void relocateChildren(); |     void relocateChildren(); | ||||||
|     bool canBeSplitted(int height) const; |     bool canBeSplitted(int height) const; | ||||||
|     BaseDesignIntf* cloneUpperPart(int height, QObject* owner=0, QGraphicsItem* parent=0); |     BaseDesignIntf* cloneUpperPart(int height, QObject* owner = 0, QGraphicsItem* parent = 0); | ||||||
|     BaseDesignIntf* cloneBottomPart(int height, QObject *owner=0, QGraphicsItem *parent=0); |     BaseDesignIntf* cloneBottomPart(int height, QObject* owner = 0, QGraphicsItem* parent = 0); | ||||||
|     void setItemAlign(const ItemAlign &itemAlign); |     void setItemAlign(const ItemAlign& itemAlign); | ||||||
|  |  | ||||||
| private: | private: | ||||||
|     void sortChildren(); |     void sortChildren(); | ||||||
| @@ -64,5 +62,5 @@ private: | |||||||
|     void placeItemInLayout(BaseDesignIntf* item); |     void placeItemInLayout(BaseDesignIntf* item); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| } //namespace LimeReport | } // namespace LimeReport | ||||||
| #endif // LRHORIZONTALLAYOUT_H | #endif // LRHORIZONTALLAYOUT_H | ||||||
|   | |||||||
| @@ -28,47 +28,56 @@ | |||||||
|  *   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 { | ||||||
|  |  | ||||||
|  | ImageItem::ImageItem(QObject* owner, QGraphicsItem* parent): | ||||||
|  |     ItemDesignIntf(xmlTag, owner, parent), | ||||||
|  |     m_useExternalPainter(false), | ||||||
|  |     m_externalPainter(0), | ||||||
|  |     m_autoSize(false), | ||||||
|  |     m_scale(true), | ||||||
|  |     m_keepAspectRatio(true), | ||||||
|  |     m_center(true), | ||||||
|  |     m_format(Binary) | ||||||
|  | { | ||||||
| } | } | ||||||
|  |  | ||||||
| namespace LimeReport{ | BaseDesignIntf* ImageItem::createSameTypeItem(QObject* owner, QGraphicsItem* parent) | ||||||
|  |  | ||||||
| ImageItem::ImageItem(QObject* owner,QGraphicsItem* parent) |  | ||||||
|     :ItemDesignIntf(xmlTag,owner,parent), m_useExternalPainter(false), m_externalPainter(0), |  | ||||||
|      m_autoSize(false), m_scale(true), |  | ||||||
|      m_keepAspectRatio(true), m_center(true), m_format(Binary){} |  | ||||||
|  |  | ||||||
| BaseDesignIntf *ImageItem::createSameTypeItem(QObject *owner, QGraphicsItem *parent) |  | ||||||
| { | { | ||||||
|     ImageItem* result = new ImageItem(owner,parent); |     ImageItem* result = new ImageItem(owner, parent); | ||||||
|     result->setExternalPainter(m_externalPainter); |     result->setExternalPainter(m_externalPainter); | ||||||
|     return result; |     return result; | ||||||
| } | } | ||||||
|  |  | ||||||
| void ImageItem::loadPictureFromVariant(QVariant& data){ | void ImageItem::loadPictureFromVariant(QVariant& data) | ||||||
|     //TODO: Migrate to QMetaType | { | ||||||
|     if (data.isValid()){ |     // TODO: Migrate to QMetaType | ||||||
|  |     if (data.isValid()) { | ||||||
| #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) | #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) | ||||||
|         if (data.typeId() == QMetaType::QImage){ |         if (data.typeId() == QMetaType::QImage) { | ||||||
| #else | #else | ||||||
|         if (data.type() == QVariant::Image){ |         if (data.type() == QVariant::Image) { | ||||||
| #endif | #endif | ||||||
|           m_picture =  data.value<QImage>(); |             m_picture = data.value<QImage>(); | ||||||
|         } else { |         } else { | ||||||
|             switch (m_format) { |             switch (m_format) { | ||||||
|             default: |             default: | ||||||
| @@ -83,35 +92,34 @@ void ImageItem::loadPictureFromVariant(QVariant& data){ | |||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| void ImageItem::preparePopUpMenu(QMenu &menu) | void ImageItem::preparePopUpMenu(QMenu& menu) | ||||||
| { | { | ||||||
|     QAction* editAction = menu.addAction(QIcon(":/report/images/edit_pecil2.png"),tr("Edit")); |     QAction* editAction = menu.addAction(QIcon(":/report/images/edit_pecil2.png"), tr("Edit")); | ||||||
|     menu.insertAction(menu.actions().at(0),editAction); |     menu.insertAction(menu.actions().at(0), editAction); | ||||||
|     menu.insertSeparator(menu.actions().at(1)); |     menu.insertSeparator(menu.actions().at(1)); | ||||||
|  |  | ||||||
|     menu.addSeparator(); |     menu.addSeparator(); | ||||||
|     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) | ||||||
| { | { | ||||||
|     if (action->text().compare(tr("Watermark")) == 0){ |     if (action->text().compare(tr("Watermark")) == 0) { | ||||||
|         page()->setPropertyToSelectedItems("watermark",action->isChecked()); |         page()->setPropertyToSelectedItems("watermark", action->isChecked()); | ||||||
|     } |     } | ||||||
|     if (action->text().compare(tr("Edit")) == 0){ |     if (action->text().compare(tr("Edit")) == 0) { | ||||||
|         this->showEditorDialog(); |         this->showEditorDialog(); | ||||||
|     } |     } | ||||||
|     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,21 +133,18 @@ 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) | ||||||
| { | { | ||||||
|     if (m_useExternalPainter != value){ |     if (m_useExternalPainter != value) { | ||||||
|         m_useExternalPainter = value; |         m_useExternalPainter = value; | ||||||
|         notify("useExternalPainter",!value, value); |         notify("useExternalPainter", !value, value); | ||||||
|         update(); |         update(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| QWidget *ImageItem::defaultEditor() | QWidget* ImageItem::defaultEditor() | ||||||
| { | { | ||||||
|     ImageItemEditor* editor = new ImageItemEditor(this); |     ImageItemEditor* editor = new ImageItemEditor(this); | ||||||
|     editor->setAttribute(Qt::WA_DeleteOnClose); |     editor->setAttribute(Qt::WA_DeleteOnClose); | ||||||
| @@ -151,7 +156,7 @@ QByteArray ImageItem::imageAsByteArray() const | |||||||
|     QByteArray result; |     QByteArray result; | ||||||
|     QBuffer buffer(&result); |     QBuffer buffer(&result); | ||||||
|     buffer.open(QIODevice::WriteOnly); |     buffer.open(QIODevice::WriteOnly); | ||||||
|     m_picture.save(&buffer,"PNG"); |     m_picture.save(&buffer, "PNG"); | ||||||
|  |  | ||||||
|     return result; |     return result; | ||||||
| } | } | ||||||
| @@ -165,63 +170,59 @@ 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) | ||||||
| { | { | ||||||
|  |  | ||||||
|     if (m_picture.isNull()){ |     if (m_picture.isNull()) { | ||||||
|         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); | ||||||
|               loadPictureFromVariant(data); |                 loadPictureFromVariant(data); | ||||||
|            } |             } | ||||||
|        } else if (!m_resourcePath.isEmpty()){ |         } else if (!m_resourcePath.isEmpty()) { | ||||||
|            m_resourcePath = expandUserVariables(m_resourcePath, pass, NoEscapeSymbols, dataManager); |             m_resourcePath | ||||||
|            m_resourcePath = expandDataFields(m_resourcePath, NoEscapeSymbols, dataManager); |                 = expandUserVariables(m_resourcePath, pass, NoEscapeSymbols, dataManager); | ||||||
|            m_picture = QImage(m_resourcePath); |             m_resourcePath = expandDataFields(m_resourcePath, NoEscapeSymbols, dataManager); | ||||||
|        } else if (!m_variable.isEmpty()){ |             m_picture = QImage(m_resourcePath); | ||||||
|             //TODO: Migrate to QMetaType |         } else if (!m_variable.isEmpty()) { | ||||||
|            QVariant data = dataManager->variable(m_variable); |             // TODO: Migrate to QMetaType | ||||||
|  |             QVariant data = dataManager->variable(m_variable); | ||||||
| #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) | #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) | ||||||
|            if (data.typeId() == QMetaType::QString){ |             if (data.typeId() == QMetaType::QString) { | ||||||
| #else | #else | ||||||
|            if (data.type() == QVariant::String){ |             if (data.type() == QVariant::String) { | ||||||
| #endif | #endif | ||||||
|                 m_picture = QImage(data.toString()); |                 m_picture = QImage(data.toString()); | ||||||
|            } else { |             } else { | ||||||
| #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) | #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) | ||||||
|                if (data.typeId() == QMetaType::QImage){ |                 if (data.typeId() == QMetaType::QImage) { | ||||||
| #else | #else | ||||||
|                if (data.type() == QVariant::Image){ |                 if (data.type() == QVariant::Image) { | ||||||
| #endif | #endif | ||||||
|                     loadPictureFromVariant(data); |                     loadPictureFromVariant(data); | ||||||
|                } |                 } | ||||||
|            } |             } | ||||||
|        } |         } | ||||||
|    } |     } | ||||||
|    if (m_autoSize){ |     if (m_autoSize) { | ||||||
|        setWidth(m_picture.width()); |         setWidth(m_picture.width()); | ||||||
|        setHeight(m_picture.height()); |         setHeight(m_picture.height()); | ||||||
|    } |     } | ||||||
|    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; } | ||||||
|  |  | ||||||
|  | QString ImageItem::resourcePath() const { return m_resourcePath; } | ||||||
|  |  | ||||||
|  | qreal ImageItem::minHeight() const | ||||||
| { | { | ||||||
|     return m_picture.isNull() || m_autoSize; |     if (!m_picture.isNull() && autoSize()) { | ||||||
| } |  | ||||||
|  |  | ||||||
| QString ImageItem::resourcePath() const |  | ||||||
| { |  | ||||||
|     return m_resourcePath; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| qreal ImageItem::minHeight() const{ |  | ||||||
|     if (!m_picture.isNull() && autoSize()) |  | ||||||
|     { |  | ||||||
|         return m_picture.height(); |         return m_picture.height(); | ||||||
|     } else { |     } else { | ||||||
|         return 0; |         return 0; | ||||||
| @@ -230,65 +231,53 @@ qreal ImageItem::minHeight() const{ | |||||||
|  |  | ||||||
| void ImageItem::setVariable(const QString& content) | void ImageItem::setVariable(const QString& content) | ||||||
| { | { | ||||||
|     if (m_variable!=content){ |     if (m_variable != content) { | ||||||
|         QString oldValue = m_variable; |         QString oldValue = m_variable; | ||||||
|         m_variable=content; |         m_variable = content; | ||||||
|         update(); |         update(); | ||||||
|         notify("variable", oldValue, m_variable); |         notify("variable", oldValue, m_variable); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| bool ImageItem::center() const | bool ImageItem::center() const { return m_center; } | ||||||
| { |  | ||||||
|     return m_center; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void ImageItem::setCenter(bool center) | void ImageItem::setCenter(bool center) | ||||||
| { | { | ||||||
|     if (m_center != center){ |     if (m_center != center) { | ||||||
|         m_center = center; |         m_center = center; | ||||||
|         update(); |         update(); | ||||||
|         notify("center",!center,center); |         notify("center", !center, 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) | ||||||
| { | { | ||||||
|     if (m_keepAspectRatio != keepAspectRatio){ |     if (m_keepAspectRatio != keepAspectRatio) { | ||||||
|         m_keepAspectRatio = keepAspectRatio; |         m_keepAspectRatio = keepAspectRatio; | ||||||
|         update(); |         update(); | ||||||
|         notify("keepAspectRatio",!keepAspectRatio,keepAspectRatio); |         notify("keepAspectRatio", !keepAspectRatio, 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) | ||||||
| { | { | ||||||
|     if (m_scale != scale){ |     if (m_scale != scale) { | ||||||
|         m_scale = scale; |         m_scale = scale; | ||||||
|         update(); |         update(); | ||||||
|         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) | ||||||
| { | { | ||||||
|     if (m_autoSize != autoSize){ |     if (m_autoSize != autoSize) { | ||||||
|         m_autoSize = autoSize; |         m_autoSize = autoSize; | ||||||
|         if (m_autoSize && !m_picture.isNull()){ |         if (m_autoSize && !m_picture.isNull()) { | ||||||
|             setWidth(drawImage().width()); |             setWidth(drawImage().width()); | ||||||
|             setHeight(drawImage().height()); |             setHeight(drawImage().height()); | ||||||
|             setPossibleResizeDirectionFlags(Fixed); |             setPossibleResizeDirectionFlags(Fixed); | ||||||
| @@ -296,52 +285,49 @@ void ImageItem::setAutoSize(bool autoSize) | |||||||
|             setPossibleResizeDirectionFlags(AllDirections); |             setPossibleResizeDirectionFlags(AllDirections); | ||||||
|         } |         } | ||||||
|         update(); |         update(); | ||||||
|         notify("autoSize",!autoSize,autoSize); |         notify("autoSize", !autoSize, 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) | ||||||
| { | { | ||||||
|     if (m_field != field){ |     if (m_field != field) { | ||||||
|         QString oldValue = m_field; |         QString oldValue = m_field; | ||||||
|         m_field = field; |         m_field = field; | ||||||
|         update(); |         update(); | ||||||
|         notify("field",oldValue,field); |         notify("field", oldValue, 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) | ||||||
| { | { | ||||||
|     if (m_datasource != datasource){ |     if (m_datasource != datasource) { | ||||||
|         QString oldValue = m_datasource; |         QString oldValue = m_datasource; | ||||||
|         m_datasource = datasource; |         m_datasource = datasource; | ||||||
|         update(); |         update(); | ||||||
|         notify("datasource",oldValue,datasource); |         notify("datasource", oldValue, datasource); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void ImageItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) | ||||||
| void ImageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |  | ||||||
| { | { | ||||||
|     painter->save(); |     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(); | ||||||
|     } |     } | ||||||
| @@ -349,73 +335,75 @@ void ImageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, | |||||||
|     qreal shiftHeight = rect().height() - img.height(); |     qreal shiftHeight = rect().height() - img.height(); | ||||||
|     qreal shiftWidth = rect().width() - img.width(); |     qreal shiftWidth = rect().width() - img.width(); | ||||||
|  |  | ||||||
|     if (m_center){ |     if (m_center) { | ||||||
|         if (shiftHeight<0 || shiftWidth<0){ |         if (shiftHeight < 0 || shiftWidth < 0) { | ||||||
|             qreal cutX = 0; |             qreal cutX = 0; | ||||||
|             qreal cutY = 0; |             qreal cutY = 0; | ||||||
|             qreal cutWidth = img.width(); |             qreal cutWidth = img.width(); | ||||||
|             qreal cutHeigth = img.height(); |             qreal cutHeigth = img.height(); | ||||||
|  |  | ||||||
|             if (shiftWidth > 0){ |             if (shiftWidth > 0) { | ||||||
|                 point.setX(point.x()+shiftWidth/2); |                 point.setX(point.x() + shiftWidth / 2); | ||||||
|             } else { |             } else { | ||||||
|                 cutX = fabs(shiftWidth/2); |                 cutX = fabs(shiftWidth / 2); | ||||||
|                 cutWidth += shiftWidth; |                 cutWidth += shiftWidth; | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             if (shiftHeight > 0){ |             if (shiftHeight > 0) { | ||||||
|                 point.setY(point.y()+shiftHeight/2); |                 point.setY(point.y() + shiftHeight / 2); | ||||||
|             } else { |             } else { | ||||||
|                 cutY = fabs(shiftHeight/2); |                 cutY = fabs(shiftHeight / 2); | ||||||
|                 cutHeigth += shiftHeight; |                 cutHeigth += shiftHeight; | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             img = img.copy(cutX,cutY,cutWidth,cutHeigth); |             img = img.copy(cutX, cutY, cutWidth, cutHeigth); | ||||||
|         } else { |         } else { | ||||||
|             point.setX(point.x()+shiftWidth/2); |             point.setX(point.x() + shiftWidth / 2); | ||||||
|             point.setY(point.y()+shiftHeight/2); |             point.setY(point.y() + shiftHeight / 2); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (img.isNull() && itemMode() == DesignMode){ |     if (img.isNull() && itemMode() == DesignMode) { | ||||||
|         QString text; |         QString text; | ||||||
|         painter->setFont(transformToSceneFont(QFont("Arial",10))); |         painter->setFont(transformToSceneFont(QFont("Arial", 10))); | ||||||
|         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) | ||||||
|         painter->drawText(rect().adjusted(4,4,-4,-4), Qt::AlignCenter, text ); |             text = tr("Ext."); | ||||||
|  |         else | ||||||
|  |             text = tr("Image"); | ||||||
|  |         painter->drawText(rect().adjusted(4, 4, -4, -4), Qt::AlignCenter, text); | ||||||
|     } else { |     } else { | ||||||
|         if (m_externalPainter && m_useExternalPainter) |         if (m_externalPainter && m_useExternalPainter) | ||||||
|             m_externalPainter->paintByExternalPainter(this->patternName(), painter, option); |             m_externalPainter->paintByExternalPainter(this->patternName(), painter, option); | ||||||
|         else |         else | ||||||
|             painter->drawImage(point,img); |             painter->drawImage(point, img); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     ItemDesignIntf::paint(painter,option,widget); |     ItemDesignIntf::paint(painter, option, widget); | ||||||
|     painter->restore(); |     painter->restore(); | ||||||
| } | } | ||||||
|  |  | ||||||
| void ImageItem::setImage(QImage value) | void ImageItem::setImage(QImage value) | ||||||
| { | { | ||||||
|     if (m_picture != value){ |     if (m_picture != value) { | ||||||
|         QImage oldValue = m_picture; |         QImage oldValue = m_picture; | ||||||
|         m_picture = value; |         m_picture = value; | ||||||
|         if (m_autoSize){ |         if (m_autoSize) { | ||||||
|             setWidth(m_picture.width()); |             setWidth(m_picture.width()); | ||||||
|             setHeight(m_picture.height()); |             setHeight(m_picture.height()); | ||||||
|         } |         } | ||||||
|         update(); |         update(); | ||||||
|         notify("image",oldValue,value); |         notify("image", oldValue, 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; | ||||||
|         update(); |         update(); | ||||||
| @@ -423,24 +411,18 @@ 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) | ||||||
| { | { | ||||||
|     if (m_format!=format){ |     if (m_format != format) { | ||||||
|         Format oldValue = m_format; |         Format oldValue = m_format; | ||||||
|         m_format=format; |         m_format = format; | ||||||
|         update(); |         update(); | ||||||
|         notify("format",oldValue,format); |         notify("format", oldValue, format); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| } | } // namespace LimeReport | ||||||
|  |  | ||||||
| bool LimeReport::ImageItem::isEmpty() const | bool LimeReport::ImageItem::isEmpty() const { return drawImage().isNull(); } | ||||||
| { |  | ||||||
|   return drawImage().isNull(); |  | ||||||
| } |  | ||||||
|   | |||||||
| @@ -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) | ||||||
| @@ -54,9 +54,9 @@ class ImageItem : public ItemDesignIntf, public IPainterProxy, public IEditableI | |||||||
|  |  | ||||||
| public: | public: | ||||||
|     enum Format { |     enum Format { | ||||||
|         Binary  = 0, |         Binary = 0, | ||||||
|         Hex     = 1, |         Hex = 1, | ||||||
|         Base64  = 2 |         Base64 = 2 | ||||||
|     }; |     }; | ||||||
| #if QT_VERSION >= 0x050500 | #if QT_VERSION >= 0x050500 | ||||||
|     Q_ENUM(Format) |     Q_ENUM(Format) | ||||||
| @@ -64,16 +64,16 @@ public: | |||||||
|     Q_ENUMS(Format) |     Q_ENUMS(Format) | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|     ImageItem(QObject *owner, QGraphicsItem *parent); |     ImageItem(QObject* owner, QGraphicsItem* parent); | ||||||
|     void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); |     void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget); | ||||||
|     void setImage(QImage value); |     void setImage(QImage value); | ||||||
|     QImage image() const; |     QImage image() const; | ||||||
|     void setResourcePath(const QString &value); |     void setResourcePath(const QString& value); | ||||||
|     QString resourcePath() const; |     QString resourcePath() const; | ||||||
|     QString datasource() const; |     QString datasource() const; | ||||||
|     void setDatasource(const QString &datasource); |     void setDatasource(const QString& datasource); | ||||||
|     QString field() const; |     QString field() const; | ||||||
|     void setField(const QString &field); |     void setField(const QString& field); | ||||||
|  |  | ||||||
|     bool autoSize() const; |     bool autoSize() const; | ||||||
|     void setAutoSize(bool autoSize); |     void setAutoSize(bool autoSize); | ||||||
| @@ -87,10 +87,13 @@ public: | |||||||
|     void setFormat(Format format); |     void setFormat(Format format); | ||||||
|     qreal minHeight() const; |     qreal minHeight() const; | ||||||
|  |  | ||||||
|     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,34 +103,35 @@ 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); | ||||||
|     bool isNeedUpdateSize(RenderPass) const; |     bool isNeedUpdateSize(RenderPass) const; | ||||||
|     bool drawDesignBorders() const {return m_picture.isNull();} |     bool drawDesignBorders() const { return m_picture.isNull(); } | ||||||
|     void loadPictureFromVariant(QVariant& data); |     void loadPictureFromVariant(QVariant& data); | ||||||
|     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; | ||||||
|     IExternalPainter* m_externalPainter; |     IExternalPainter* m_externalPainter; | ||||||
|     QString m_resourcePath; |     QString m_resourcePath; | ||||||
|     QString m_datasource; |     QString m_datasource; | ||||||
|     QString m_field; |     QString m_field; | ||||||
|     bool    m_autoSize; |     bool m_autoSize; | ||||||
|     bool    m_scale; |     bool m_scale; | ||||||
|     bool    m_keepAspectRatio; |     bool m_keepAspectRatio; | ||||||
|     bool    m_center; |     bool m_center; | ||||||
|     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 | ||||||
|   | |||||||
| @@ -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,15 +17,12 @@ ImageItemEditor::ImageItemEditor(LimeReport::IEditableImageItem *item, QWidget * | |||||||
|     updateImage(); |     updateImage(); | ||||||
| } | } | ||||||
|  |  | ||||||
| ImageItemEditor::~ImageItemEditor() | ImageItemEditor::~ImageItemEditor() { delete ui; } | ||||||
| { |  | ||||||
|     delete ui; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| void ImageItemEditor::updateImage() | void ImageItemEditor::updateImage() | ||||||
| { | { | ||||||
|     QPixmap image; |     QPixmap image; | ||||||
|     if (m_image.isEmpty() && !ui->resourcePath->text().isEmpty()){ |     if (m_image.isEmpty() && !ui->resourcePath->text().isEmpty()) { | ||||||
|         image.load(ui->resourcePath->text()); |         image.load(ui->resourcePath->text()); | ||||||
|     } else { |     } else { | ||||||
|         image.loadFromData(m_image); |         image.loadFromData(m_image); | ||||||
| @@ -33,9 +32,10 @@ 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(); | ||||||
|     } |     } | ||||||
|     updateImage(); |     updateImage(); | ||||||
| @@ -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() | ||||||
| { | { | ||||||
|   | |||||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user