diff --git a/common.pri b/common.pri index bb087dd..3a6d8d3 100644 --- a/common.pri +++ b/common.pri @@ -141,7 +141,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 5 -LIMEREPORT_VERSION_RELEASE = 87 +LIMEREPORT_VERSION_RELEASE = 88 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/limereport.pro b/limereport.pro index 20fbfb5..449d892 100644 --- a/limereport.pro +++ b/limereport.pro @@ -12,6 +12,7 @@ SUBDIRS += \ limereport \ demo_r1 \ demo_r2 \ + lrdview \ designer if(equals(QT_MAJOR_VERSION, 5) : greaterThan(QT_MINOR_VERSION, 1)) | equals(QT_MAJOR_VERSION, 6) { diff --git a/lrdview/MainWindow.cpp b/lrdview/MainWindow.cpp new file mode 100644 index 0000000..3619ab5 --- /dev/null +++ b/lrdview/MainWindow.cpp @@ -0,0 +1,217 @@ +#include "MainWindow.h" +#include "ui_MainWindow.h" +#include +#include +#include +#include +#include +#include +#include "XmlModel.h" +#include "SettingDialog.h" +#include "lrreportengine.h" + +//#ifndef QT_DEBUG +//Q_IMPORT_PLUGIN(adateeditorplugin) +//#endif + +void centerWindow(QWidget* widget, double widthFactor, double heightFactor) { + QDesktopWidget desk; + int ww = desk.width() * widthFactor; + int wh = desk.height() * heightFactor; + widget->resize(ww, wh); + widget->move((desk.width() - ww) / 2, (desk.height() - wh) / 2); +} + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow), + m_previewScene(0), m_isCert(false), m_deleteLastFile(false) +{ + ui->setupUi(this); + m_report.dataManager()->addModel("reportData",&m_model,false); + ui->graphicsView->scale(0.5,0.5); + centerWindow(this, 0.8, 0.8); + m_settings = new QSettings("OCKK Ltd","LRDView"); + m_report.setSettings(m_settings); + readSetting(); + setWindowTitle("LRDView ver 1.30"); + if (QCoreApplication::arguments().count()>1){ + loadReport(QCoreApplication::arguments().at(1)); + } + //ui->statusBar->addWidget(new QLabel(" Designed by Arin Alexander (arin_a@bk.ru) ",this)); +} + +bool isFileExists(QZipReader& reader, QString fileName){ + foreach( QZipReader::FileInfo fi, reader.fileInfoList()){ + if (fi.filePath.compare(fileName)==0) return true; + } + return false; +} +void MainWindow::loadReport(QString fileName){ + if (!fileName.isEmpty()){ + QZipReader reader(fileName); + QByteArray fileData = reader.fileData("report.xml"); + m_report.loadFromByteArray(&fileData); + m_reportData = reader.fileData("data.xml"); + m_model.setXMLData(&m_reportData); + if (m_previewScene) delete m_previewScene; + m_previewScene = dynamic_cast(m_report.createPreviewScene(ui->graphicsView)); + m_previewScene->setItemMode(LimeReport::PreviewMode); + ui->graphicsView->setScene(m_previewScene); + ui->graphicsView->centerOn(0, 0); + ui->actionEdit->setChecked(false); + m_isCert = isFileExists(reader,"CertFlag.sgn"); + //m_lastReport = fileName; + ui->action_PDF->setEnabled(true); + ui->actionPrint->setEnabled(true); + reader.close(); + if (m_deleteLastFile){ + QFile::remove(fileName); + } + } +} + +MainWindow::~MainWindow() +{ + delete m_settings; + delete ui; +} + +void MainWindow::on_actionEdit_triggered() +{ + if (m_previewScene){ + if (m_previewScene->itemMode()==LimeReport::PreviewMode){ + m_previewScene->setItemMode(LimeReport::DesignMode); + } else m_previewScene->setItemMode(LimeReport::PreviewMode); + } +} + +void MainWindow::on_actionOpen_triggered() +{ + QString fileName = QFileDialog::getOpenFileName(0,tr("Открыть файл отчета"),QString(),"*.lrd"); + if (!fileName.isEmpty()){ + loadReport(fileName); + } +} + +void MainWindow::on_actionDesign_triggered() +{ + m_report.designReport(); +} + +void MainWindow::closeEvent(QCloseEvent *event) +{ + writeSetting(); +} + +void MainWindow::writeSetting(){ + m_settings->setValue("geometry",saveGeometry()); +} + +void MainWindow::readSetting() +{ + QVariant v = m_settings->value("geometry"); + if (v.isValid()){ + restoreGeometry(v.toByteArray()); + } + m_certPrinterName = m_settings->value("certPrinterName","").value(); + m_otherPrinterName = m_settings->value("otherPrinterName","").value(); + m_deleteLastFile = m_settings->value("deleteLastFile",false).value(); +} + +void MainWindow::settingAccepted() +{ + m_certPrinterName=((SettingDialog*)sender())->certPrinterName(); + m_otherPrinterName=((SettingDialog*)sender())->othenPrinterName(); + m_deleteLastFile = ((SettingDialog*)sender())->deleteLastFile(); + m_settings->setValue("certPrinterName",m_certPrinterName); + m_settings->setValue("otherPrinterName",m_otherPrinterName); + m_settings->setValue("deleteLastFile",m_deleteLastFile); +} + +void MainWindow::on_actionZoomIn_triggered() +{ + ui->graphicsView->scale(1.2,1.2); +} + +void MainWindow::on_actionZoomOut_triggered() +{ + ui->graphicsView->scale(1/1.2,1/1.2); +} + +void MainWindow::on_actionPrint_triggered() +{ + QPrinterInfo pi; + if (m_isCert) + pi = getPrinterInfo(m_certPrinterName); + else { + pi = getPrinterInfo(m_otherPrinterName); + } + QPrinter printer(pi); + QPrintDialog dialog(&printer,QApplication::activeWindow()); + + + if (dialog.exec()){ + if (m_previewScene->pageItems().isEmpty()) + m_report.printReport(&printer); + else{ + printer.setPrintRange(QPrinter::PrintRange(dialog.printRange())); + printer.setFromTo(dialog.fromPage(), dialog.toPage()); + m_report.printPages( + m_previewScene->pageItems(), &printer + ); + foreach(LimeReport::PageItemDesignIntf::Ptr pageItem, m_previewScene->pageItems()){ + m_previewScene->reactivatePageItem(pageItem); + } + } + } + +} + +QPrinterInfo MainWindow::getPrinterInfo(QString printerName){ + foreach (QPrinterInfo pi, QPrinterInfo::availablePrinters()) { + if (pi.printerName().compare(printerName)==0) + return pi; + } + return QPrinterInfo::defaultPrinter(); +} + +void MainWindow::on_actionSetting_triggered() +{ + SettingDialog w(this); + w.setCertPrinterName(m_certPrinterName); + w.setOtherPrinterName(m_otherPrinterName); + w.setDeleteLastFile(m_deleteLastFile); + connect(&w, SIGNAL(accepted()), this, SLOT(settingAccepted())); + w.exec(); +} + + +void MainWindow::on_actionDelete_triggered() +{ + if (m_previewScene){ + m_previewScene->deleteSelected(); + } +} + +void MainWindow::on_action_PDF_triggered() +{ + QString fileName = QFileDialog::getSaveFileName(this,tr("Имя файла для экспорта"),"","*.pdf" ); + if (!fileName.isEmpty()){ + QPrinter printer; + printer.setOutputFileName(fileName); + printer.setOutputFormat(QPrinter::PdfFormat); + //m_report.printReport(&printer); + if (m_previewScene->pageItems().isEmpty()) + m_report.printReport(&printer); + else{ + m_report.printPages( + m_previewScene->pageItems(), + &printer + ); + foreach(LimeReport::PageItemDesignIntf::Ptr pageItem, m_previewScene->pageItems()){ + m_previewScene->reactivatePageItem(pageItem); + } + } + } +} diff --git a/lrdview/MainWindow.h b/lrdview/MainWindow.h new file mode 100644 index 0000000..31c0e59 --- /dev/null +++ b/lrdview/MainWindow.h @@ -0,0 +1,58 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include +#include "lrreportengine.h" +#include "lrpagedesignintf.h" +#include "XmlModel.h" + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private slots: + void on_actionEdit_triggered(); + void on_actionOpen_triggered(); + void on_actionDesign_triggered(); + void on_actionZoomIn_triggered(); + void on_actionZoomOut_triggered(); + void on_actionPrint_triggered(); + void on_actionSetting_triggered(); + +protected: + void closeEvent(QCloseEvent *event); +private: + void loadReport(QString fileName); + void writeSetting(); + void readSetting(); + QPrinterInfo getPrinterInfo(QString printerName); +private slots: + void settingAccepted(); + void on_actionDelete_triggered(); + + void on_action_PDF_triggered(); + +private: + Ui::MainWindow *ui; + LimeReport::PageDesignIntf* m_previewScene; + LimeReport::ReportEngine m_report; + XmlModel m_model; + QByteArray m_reportData; + QSettings* m_settings; + QString m_certPrinterName; + QString m_otherPrinterName; + bool m_isCert; + bool m_deleteLastFile; + QString m_lastReport; +}; + +#endif // MAINWINDOW_H diff --git a/lrdview/MainWindow.qrc b/lrdview/MainWindow.qrc new file mode 100644 index 0000000..46e191e --- /dev/null +++ b/lrdview/MainWindow.qrc @@ -0,0 +1,17 @@ + + + images/design.png + images/edit.png + images/print.png + images/folder_open_16.png + images/design_black.png + images/edit_page.png + images/edit_pattern.png + images/view.png + images/zoomin.png + images/zoomout.png + images/settings-24.png + images/delete.png + images/PDF1.png + + diff --git a/lrdview/MainWindow.ui b/lrdview/MainWindow.ui new file mode 100644 index 0000000..c81bc44 --- /dev/null +++ b/lrdview/MainWindow.ui @@ -0,0 +1,211 @@ + + + MainWindow + + + + 0 + 0 + 694 + 677 + + + + LRDView + + + + :/images/view.png:/images/view.png + + + + + + + + 2 + + + + + + + + + + 0 + 0 + 694 + 21 + + + + + + true + + + + 16 + 16 + + + + TopToolBarArea + + + false + + + + + + + + + + + + + + + + + + false + + + + :/images/print.png:/images/print.png + + + Печать + + + Печать документа + + + Ctrl+P + + + + + true + + + + :/images/edit.png:/images/edit.png + + + Редактировать + + + Редактировать + + + Ctrl+E + + + + + + :/images/folder_open_16.png:/images/folder_open_16.png + + + Открыть + + + Открыть файл + + + Ctrl+O + + + + + + :/images/edit_pattern.png:/images/edit_pattern.png + + + Редактировать шаблон + + + Редактировть шаблон + + + + + + :/images/zoomin.png:/images/zoomin.png + + + Увеличить + + + Увеличить + + + Ctrl+= + + + + + + :/images/zoomout.png:/images/zoomout.png + + + Уменьшить + + + Уменьшить + + + Ctrl+- + + + + + + :/images/settings-24.png:/images/settings-24.png + + + Настройки + + + Настройки + + + + + + :/images/delete.png:/images/delete.png + + + Удалить + + + Удалить выбранный элемент + + + Del + + + + + false + + + + :/images/PDF1.png:/images/PDF1.png + + + Экспорт в PDF + + + + + + + + + diff --git a/lrdview/SettingDialog.cpp b/lrdview/SettingDialog.cpp new file mode 100644 index 0000000..ee842c1 --- /dev/null +++ b/lrdview/SettingDialog.cpp @@ -0,0 +1,53 @@ +#include "SettingDialog.h" +#include "ui_SettingDialog.h" +#include + +SettingDialog::SettingDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::SettingDialog) +{ + ui->setupUi(this); + initPrinters(); +} + +SettingDialog::~SettingDialog() +{ + delete ui; +} + +void SettingDialog::initPrinters() +{ + foreach (QPrinterInfo pi, QPrinterInfo::availablePrinters()) { + ui->certPrinter->addItem(pi.printerName()); + ui->otherPrinter->addItem(pi.printerName()); + } +} + +void SettingDialog::setCertPrinterName(QString printerName){ + + ui->certPrinter->setCurrentIndex(ui->certPrinter->findText(printerName)); +} + +void SettingDialog::setOtherPrinterName(QString printerName) +{ + ui->otherPrinter->setCurrentIndex(ui->otherPrinter->findText(printerName)); +} + +QString SettingDialog::certPrinterName(){ + return ui->certPrinter->currentText(); +} + +QString SettingDialog::othenPrinterName() +{ + return ui->otherPrinter->currentText(); +} + +bool SettingDialog::deleteLastFile(){ + return ui->checkBox->isChecked(); +} + +void SettingDialog::setDeleteLastFile(bool value) +{ + ui->checkBox->setChecked(value); +} + diff --git a/lrdview/SettingDialog.h b/lrdview/SettingDialog.h new file mode 100644 index 0000000..b9eaa5b --- /dev/null +++ b/lrdview/SettingDialog.h @@ -0,0 +1,30 @@ +#ifndef SETTINGDIALOG_H +#define SETTINGDIALOG_H + +#include + +namespace Ui { +class SettingDialog; +} + +class SettingDialog : public QDialog +{ + Q_OBJECT + +public: + explicit SettingDialog(QWidget *parent = 0); + ~SettingDialog(); + void setCertPrinterName(QString printerName); + void setOtherPrinterName(QString printerName); + QString certPrinterName(); + QString othenPrinterName(); + bool deleteLastFile(); + void setDeleteLastFile(bool value); +private: + void initPrinters(); + +private: + Ui::SettingDialog *ui; +}; + +#endif // SETTINGDIALOG_H diff --git a/lrdview/SettingDialog.ui b/lrdview/SettingDialog.ui new file mode 100644 index 0000000..ff34f08 --- /dev/null +++ b/lrdview/SettingDialog.ui @@ -0,0 +1,114 @@ + + + SettingDialog + + + Qt::WindowModal + + + + 0 + 0 + 400 + 151 + + + + Настройки + + + true + + + + + + Принтер + + + + + + + + Сертификаты + + + + + + + + + + + + + + Остальное + + + + + + + + + + + + + + + Удалять файл + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + SettingDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + SettingDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/lrdview/XmlModel.cpp b/lrdview/XmlModel.cpp new file mode 100644 index 0000000..9942120 --- /dev/null +++ b/lrdview/XmlModel.cpp @@ -0,0 +1,73 @@ +#include "XmlModel.h" +#include + +XmlModel::XmlModel(QByteArray *data) { + if (data) { + m_doc.setContent(*data); + initModel(); + } +} + +void XmlModel::setXMLData(QByteArray *data) { + if (data) { + beginResetModel(); + m_doc.setContent(*data); + initModel(); + endResetModel(); + } +} + +void XmlModel::initModel(){ + m_items = m_doc.firstChildElement("items"); + parseHeaders(); +} + +void XmlModel::parseHeaders() +{ + m_fields.clear(); + QDomNode root = m_doc.firstChildElement("items"); + QDomNode item = root.firstChild(); + for (int i=0; i +#include +#include + +class XmlModel : public QAbstractItemModel +{ +public: + XmlModel(QByteArray* data = 0); + void setXMLData(QByteArray* data); + void parseHeaders(); + QModelIndex index(int row, int column, const QModelIndex &parent) const; + QModelIndex parent(const QModelIndex &child) const; + int rowCount(const QModelIndex &parent) const; + int columnCount(const QModelIndex &parent) const; + QVariant data(const QModelIndex &index, int role) const; + QVariant headerData(int section, Qt::Orientation orientation, int role) const; +private: + void initModel(); +private: + QDomDocument m_doc; + QDomNode m_items; + QVector m_fields; +}; + +#endif // XMLMODEL_H diff --git a/lrdview/images/PDF1.png b/lrdview/images/PDF1.png new file mode 100644 index 0000000..284dcee Binary files /dev/null and b/lrdview/images/PDF1.png differ diff --git a/lrdview/images/delete.png b/lrdview/images/delete.png new file mode 100644 index 0000000..148f047 Binary files /dev/null and b/lrdview/images/delete.png differ diff --git a/lrdview/images/design.png b/lrdview/images/design.png new file mode 100644 index 0000000..d2ecf05 Binary files /dev/null and b/lrdview/images/design.png differ diff --git a/lrdview/images/design_black.png b/lrdview/images/design_black.png new file mode 100644 index 0000000..3820adc Binary files /dev/null and b/lrdview/images/design_black.png differ diff --git a/lrdview/images/edit.png b/lrdview/images/edit.png new file mode 100644 index 0000000..1a46331 Binary files /dev/null and b/lrdview/images/edit.png differ diff --git a/lrdview/images/edit_page.png b/lrdview/images/edit_page.png new file mode 100644 index 0000000..b830886 Binary files /dev/null and b/lrdview/images/edit_page.png differ diff --git a/lrdview/images/edit_pattern.png b/lrdview/images/edit_pattern.png new file mode 100644 index 0000000..17c2114 Binary files /dev/null and b/lrdview/images/edit_pattern.png differ diff --git a/lrdview/images/folder_open.png b/lrdview/images/folder_open.png new file mode 100644 index 0000000..4c03fdd Binary files /dev/null and b/lrdview/images/folder_open.png differ diff --git a/lrdview/images/folder_open_16.png b/lrdview/images/folder_open_16.png new file mode 100644 index 0000000..1d2e71c Binary files /dev/null and b/lrdview/images/folder_open_16.png differ diff --git a/lrdview/images/print.png b/lrdview/images/print.png new file mode 100644 index 0000000..db008e2 Binary files /dev/null and b/lrdview/images/print.png differ diff --git a/lrdview/images/settings-24.png b/lrdview/images/settings-24.png new file mode 100644 index 0000000..1eafc53 Binary files /dev/null and b/lrdview/images/settings-24.png differ diff --git a/lrdview/images/view.ico b/lrdview/images/view.ico new file mode 100644 index 0000000..343474a Binary files /dev/null and b/lrdview/images/view.ico differ diff --git a/lrdview/images/view.png b/lrdview/images/view.png new file mode 100644 index 0000000..a23184f Binary files /dev/null and b/lrdview/images/view.png differ diff --git a/lrdview/images/zoomin.png b/lrdview/images/zoomin.png new file mode 100644 index 0000000..0229b6f Binary files /dev/null and b/lrdview/images/zoomin.png differ diff --git a/lrdview/images/zoomout.png b/lrdview/images/zoomout.png new file mode 100644 index 0000000..aa53d25 Binary files /dev/null and b/lrdview/images/zoomout.png differ diff --git a/lrdview/lrdview.pro b/lrdview/lrdview.pro new file mode 100644 index 0000000..df434d3 --- /dev/null +++ b/lrdview/lrdview.pro @@ -0,0 +1,43 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2014-03-24T20:29:50 +# +#------------------------------------------------- + +QT += core gui xml +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets gui-private + +CONFIG += uitools + +include(../common.pri) +include(../qzint.pri) +include(../limereport.pri) + +TARGET = lrdview +TEMPLATE = app + +win32 { + RC_FILE += mainicon.rc +} + +SOURCES += main.cpp\ + MainWindow.cpp \ + XmlModel.cpp \ + SettingDialog.cpp + +HEADERS += MainWindow.h \ + XmlModel.h \ + SettingDialog.h + +FORMS += MainWindow.ui \ + SettingDialog.ui + +RESOURCES += \ + MainWindow.qrc + +#win32:CONFIG(release, debug|release): { +# LIBS += -LD:/Work/C++/Projects/LRDView/libs -ladateeditorplugin +# QTPLUGIN += adateeditorplugin +# DEFINES += DEBUG +#} + diff --git a/lrdview/main.cpp b/lrdview/main.cpp new file mode 100644 index 0000000..da3fe56 --- /dev/null +++ b/lrdview/main.cpp @@ -0,0 +1,12 @@ +#include "MainWindow.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + //QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/lrdview/mainicon.rc b/lrdview/mainicon.rc new file mode 100644 index 0000000..790ecd0 --- /dev/null +++ b/lrdview/mainicon.rc @@ -0,0 +1 @@ +DI_ICON1 ICON "view.ico" diff --git a/lrdview/view.ico b/lrdview/view.ico new file mode 100644 index 0000000..343474a Binary files /dev/null and b/lrdview/view.ico differ