2016-02-17 10:11:00 +03:00
|
|
|
/***************************************************************************
|
|
|
|
* This file is part of the Lime Report project *
|
2021-08-18 20:21:36 +03:00
|
|
|
* Copyright (C) 2021 by Alexander Arin *
|
2016-02-17 10:11:00 +03:00
|
|
|
* arin_a@bk.ru *
|
|
|
|
* *
|
|
|
|
** GNU General Public License Usage **
|
|
|
|
* *
|
|
|
|
* This library is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
|
|
* *
|
|
|
|
** GNU Lesser General Public License **
|
|
|
|
* *
|
|
|
|
* This library is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU Lesser General Public License as *
|
|
|
|
* published by the Free Software Foundation, either version 3 of the *
|
|
|
|
* License, or (at your option) any later version. *
|
|
|
|
* You should have received a copy of the GNU Lesser General Public *
|
|
|
|
* License along with this library. *
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>. *
|
|
|
|
* *
|
|
|
|
* This library is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
****************************************************************************/
|
|
|
|
#include "lrpreviewreportwindow.h"
|
|
|
|
#include "ui_lrpreviewreportwindow.h"
|
2024-09-04 17:31:16 +03:00
|
|
|
|
2017-03-22 14:42:09 +03:00
|
|
|
#include "items/editors/lrfonteditorwidget.h"
|
|
|
|
#include "items/editors/lrtextalignmenteditorwidget.h"
|
2024-09-04 17:31:16 +03:00
|
|
|
#include "lrpreviewreportwidget.h"
|
|
|
|
#include "lrpreviewreportwidget_p.h"
|
|
|
|
#include "lrreportengine_p.h"
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
#include <QFileDialog>
|
2024-09-04 17:31:16 +03:00
|
|
|
#include <QPrintDialog>
|
|
|
|
#include <QPrinter>
|
2016-02-17 10:11:00 +03:00
|
|
|
#include <QScrollBar>
|
2021-12-16 00:13:39 +03:00
|
|
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
|
2016-02-17 10:39:17 +03:00
|
|
|
#include <QDesktopWidget>
|
2021-08-23 08:07:08 +03:00
|
|
|
#else
|
|
|
|
#include <QScreen>
|
|
|
|
#endif
|
2019-10-16 02:08:45 +03:00
|
|
|
#include <QLabel>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QToolButton>
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
namespace LimeReport {
|
2016-03-03 03:08:36 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
PreviewReportWindow::PreviewReportWindow(ReportEngine* report, QWidget* parent, QSettings* settings,
|
|
|
|
Qt::WindowFlags flags):
|
|
|
|
QMainWindow(parent, flags),
|
|
|
|
ui(new Ui::PreviewReportWindow),
|
|
|
|
m_settings(settings),
|
|
|
|
m_ownedSettings(false),
|
2019-02-18 15:16:55 +03:00
|
|
|
m_scalePercentChanging(false)
|
2016-02-17 10:11:00 +03:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2019-10-16 02:08:45 +03:00
|
|
|
|
|
|
|
m_progressWidget = new QWidget(ui->statusbar);
|
|
|
|
QHBoxLayout* progressLayout = new QHBoxLayout();
|
2021-08-23 08:07:08 +03:00
|
|
|
progressLayout->setContentsMargins(0, 0, 0, 0);
|
2019-10-16 02:08:45 +03:00
|
|
|
progressLayout->addWidget(new QLabel(tr("Printing")));
|
|
|
|
m_progressBar = new QProgressBar(ui->statusbar);
|
|
|
|
m_progressBar->setMaximumWidth(100);
|
|
|
|
m_progressBar->setMaximumHeight(ui->statusbar->fontMetrics().height());
|
|
|
|
progressLayout->addWidget(m_progressBar);
|
|
|
|
QToolButton* tbCancel = new QToolButton();
|
|
|
|
tbCancel->setIcon(QIcon(":/report/images/closebox"));
|
|
|
|
tbCancel->setAutoRaise(true);
|
|
|
|
connect(tbCancel, SIGNAL(clicked(bool)), this, SLOT(slotCancelPrinting(bool)));
|
|
|
|
progressLayout->addWidget(tbCancel);
|
|
|
|
progressLayout->setSizeConstraint(QLayout::SetFixedSize);
|
|
|
|
m_progressWidget->setLayout(progressLayout);
|
|
|
|
m_progressWidget->setVisible(false);
|
|
|
|
ui->statusbar->addPermanentWidget(m_progressWidget);
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
setWindowTitle("Lime Report Preview");
|
|
|
|
m_pagesNavigator = new QSpinBox(this);
|
|
|
|
m_pagesNavigator->setMaximum(10000000);
|
2016-02-18 22:24:53 +03:00
|
|
|
m_pagesNavigator->setPrefix(tr("Page: "));
|
2016-02-17 10:11:00 +03:00
|
|
|
m_pagesNavigator->setMinimumWidth(120);
|
2024-09-04 17:31:16 +03:00
|
|
|
ui->toolBar->insertWidget(ui->actionNextPage, m_pagesNavigator);
|
2019-02-21 03:20:26 +03:00
|
|
|
ui->editModeTools->hide();
|
2016-02-17 10:11:00 +03:00
|
|
|
ui->actionShowMessages->setVisible(false);
|
2016-03-30 23:19:05 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_pagesNavigator, SIGNAL(valueChanged(int)), this, SLOT(slotPageNavigatorChanged(int)));
|
|
|
|
m_previewReportWidget = new PreviewReportWidget(report, this);
|
2016-03-30 23:19:05 +03:00
|
|
|
setCentralWidget(m_previewReportWidget);
|
2024-09-04 17:31:16 +03:00
|
|
|
layout()->setContentsMargins(1, 1, 1, 1);
|
|
|
|
connect(m_previewReportWidget, SIGNAL(pageChanged(int)), this, SLOT(slotPageChanged(int)));
|
|
|
|
connect(m_previewReportWidget->d_ptr->m_previewPage, SIGNAL(selectionChanged()), this,
|
|
|
|
SLOT(slotSelectionChanged()));
|
|
|
|
connect(m_pagesNavigator, SIGNAL(valueChanged(int)), this, SLOT(slotPageNavigatorChanged(int)));
|
|
|
|
connect(m_previewReportWidget, SIGNAL(onSave(bool&, LimeReport::IPreparedPages*)), this,
|
|
|
|
SIGNAL(onSave(bool&, LimeReport::IPreparedPages*)));
|
|
|
|
|
|
|
|
connect(m_previewReportWidget->d_ptr->m_report, SIGNAL(printingStarted(int)), this,
|
|
|
|
SLOT(slotPrintingStarted(int)));
|
|
|
|
connect(m_previewReportWidget->d_ptr->m_report, SIGNAL(pagePrintingFinished(int)), this,
|
|
|
|
SLOT(slotPagePrintingFinished(int)));
|
|
|
|
connect(m_previewReportWidget->d_ptr->m_report, SIGNAL(printingFinished()), this,
|
|
|
|
SLOT(slotPrintingFinished()));
|
|
|
|
|
|
|
|
m_fontEditor = new FontEditorWidgetForPage(m_previewReportWidget->d_ptr->m_previewPage,
|
|
|
|
tr("Font"), this);
|
2016-06-10 18:05:18 +03:00
|
|
|
m_fontEditor->setObjectName("fontTools");
|
|
|
|
m_fontEditor->setIconSize(ui->toolBar->iconSize());
|
2024-09-04 17:31:16 +03:00
|
|
|
m_textAlignmentEditor = new TextAlignmentEditorWidgetForPage(
|
|
|
|
m_previewReportWidget->d_ptr->m_previewPage, tr("Text align"), this);
|
2016-06-10 18:05:18 +03:00
|
|
|
m_textAlignmentEditor->setObjectName("textAlignmentTools");
|
|
|
|
m_textAlignmentEditor->setIconSize(ui->toolBar->iconSize());
|
2024-09-04 17:31:16 +03:00
|
|
|
addToolBar(Qt::TopToolBarArea, m_fontEditor);
|
|
|
|
addToolBar(Qt::TopToolBarArea, m_textAlignmentEditor);
|
2016-04-02 16:07:01 +03:00
|
|
|
|
|
|
|
m_scalePercent = new QComboBox(this);
|
2016-04-05 23:06:11 +03:00
|
|
|
m_scalePercent->setEditable(true);
|
2016-04-02 16:07:01 +03:00
|
|
|
ui->toolBar->insertWidget(ui->actionZoomOut, m_scalePercent);
|
|
|
|
initPercentCombobox();
|
2024-09-04 17:31:16 +03:00
|
|
|
|
2016-06-10 18:05:18 +03:00
|
|
|
connect(ui->actionShowMessages, SIGNAL(triggered()), this, SLOT(slotShowErrors()));
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_previewReportWidget, SIGNAL(scalePercentChanged(int)), this,
|
|
|
|
SLOT(slotScalePercentChanged(int)));
|
2021-11-02 22:30:29 +03:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_scalePercent, SIGNAL(currentTextChanged(QString)), this,
|
|
|
|
SLOT(scaleComboboxChanged(QString)));
|
2021-11-02 22:30:29 +03:00
|
|
|
#else
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_scalePercent, SIGNAL(currentIndexChanged(QString)), this,
|
|
|
|
SLOT(scaleComboboxChanged(QString)));
|
2021-11-02 22:30:29 +03:00
|
|
|
#endif
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_previewReportWidget, SIGNAL(pageChanged(int)), this,
|
|
|
|
SLOT(slotCurrentPageChanged(int)));
|
|
|
|
connect(m_previewReportWidget,
|
|
|
|
SIGNAL(itemInserted(LimeReport::PageDesignIntf*, QPointF, QString)), this,
|
|
|
|
SLOT(slotItemInserted(LimeReport::PageDesignIntf*, QPointF, QString)));
|
2019-03-01 23:48:28 +03:00
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
restoreSetting();
|
2016-08-08 15:50:04 +03:00
|
|
|
selectStateIcon();
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewReportWindow::writeSetting()
|
|
|
|
{
|
|
|
|
settings()->beginGroup("PreviewWindow");
|
2024-09-04 17:31:16 +03:00
|
|
|
settings()->setValue("Geometry", saveGeometry());
|
|
|
|
settings()->setValue("State", saveState());
|
2016-02-17 10:11:00 +03:00
|
|
|
settings()->endGroup();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewReportWindow::restoreSetting()
|
|
|
|
{
|
|
|
|
settings()->beginGroup("PreviewWindow");
|
|
|
|
QVariant v = settings()->value("Geometry");
|
2024-09-04 17:31:16 +03:00
|
|
|
if (v.isValid()) {
|
2016-02-17 10:11:00 +03:00
|
|
|
restoreGeometry(v.toByteArray());
|
2016-02-17 10:39:17 +03:00
|
|
|
} else {
|
2021-12-16 00:13:39 +03:00
|
|
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
|
2024-09-04 17:31:16 +03:00
|
|
|
QDesktopWidget* desktop = QApplication::desktop();
|
2016-02-17 10:39:17 +03:00
|
|
|
|
2016-03-24 02:14:09 +03:00
|
|
|
int screenWidth = desktop->screenGeometry().width();
|
|
|
|
int screenHeight = desktop->screenGeometry().height();
|
2021-08-23 08:07:08 +03:00
|
|
|
#else
|
2024-09-04 17:31:16 +03:00
|
|
|
QScreen* screen = QGuiApplication::primaryScreen();
|
2016-02-17 10:39:17 +03:00
|
|
|
|
2021-08-23 08:07:08 +03:00
|
|
|
int screenWidth = screen->geometry().width();
|
|
|
|
int screenHeight = screen->geometry().height();
|
|
|
|
#endif
|
2024-09-04 17:31:16 +03:00
|
|
|
int x = static_cast<int>(screenWidth * 0.1);
|
|
|
|
int y = static_cast<int>(screenHeight * 0.1);
|
2016-02-17 10:39:17 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
resize(static_cast<int>(screenWidth * 0.8), static_cast<int>(screenHeight * 0.8));
|
2016-02-17 10:39:17 +03:00
|
|
|
move(x, y);
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
v = settings()->value("State");
|
2024-09-04 17:31:16 +03:00
|
|
|
if (v.isValid()) {
|
2016-02-17 10:11:00 +03:00
|
|
|
restoreState(v.toByteArray());
|
|
|
|
}
|
|
|
|
settings()->endGroup();
|
|
|
|
}
|
|
|
|
|
|
|
|
PreviewReportWindow::~PreviewReportWindow()
|
|
|
|
{
|
|
|
|
if (m_ownedSettings)
|
|
|
|
delete m_settings;
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewReportWindow::initPreview(int pagesCount)
|
|
|
|
{
|
|
|
|
m_pagesNavigator->setSuffix(tr(" of %1").arg(pagesCount));
|
|
|
|
m_pagesNavigator->setMinimum(1);
|
|
|
|
m_pagesNavigator->setMaximum(pagesCount);
|
2016-03-30 23:19:05 +03:00
|
|
|
m_pagesNavigator->setValue(1);
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void PreviewReportWindow::reloadPreview() { m_previewReportWidget->refreshPages(); }
|
2017-04-20 05:43:48 +03:00
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
void PreviewReportWindow::setSettings(QSettings* value)
|
|
|
|
{
|
|
|
|
if (m_ownedSettings)
|
|
|
|
delete m_settings;
|
2024-09-04 17:31:16 +03:00
|
|
|
m_settings = value;
|
|
|
|
m_ownedSettings = false;
|
2016-02-17 10:11:00 +03:00
|
|
|
restoreSetting();
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void PreviewReportWindow::setErrorMessages(const QStringList& value)
|
|
|
|
{
|
2016-02-17 10:11:00 +03:00
|
|
|
ui->actionShowMessages->setVisible(true);
|
2016-03-30 23:19:05 +03:00
|
|
|
m_previewReportWidget->setErrorMessages(value);
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
2016-08-02 22:33:33 +03:00
|
|
|
void PreviewReportWindow::setToolBarVisible(bool value)
|
|
|
|
{
|
2016-08-08 15:50:04 +03:00
|
|
|
ui->toolBar->setHidden(value);
|
|
|
|
selectStateIcon();
|
2016-08-02 22:33:33 +03:00
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void PreviewReportWindow::setStatusBarVisible(bool value) { ui->statusbar->setVisible(value); }
|
2016-08-02 22:33:33 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void PreviewReportWindow::setMenuVisible(bool value) { ui->menubar->setVisible(value); }
|
2017-02-03 14:20:30 +03:00
|
|
|
|
|
|
|
void PreviewReportWindow::setHideResultEditButton(bool value)
|
|
|
|
{
|
|
|
|
ui->actionEdit_Mode->setVisible(value);
|
2019-07-09 12:28:58 +03:00
|
|
|
if (!value && ui->editModeTools) {
|
|
|
|
delete ui->editModeTools;
|
|
|
|
ui->editModeTools = 0;
|
|
|
|
}
|
2016-08-02 22:33:33 +03:00
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void PreviewReportWindow::setHidePrintButton(bool value) { ui->actionPrint->setVisible(value); }
|
2019-04-10 16:23:50 +03:00
|
|
|
|
|
|
|
void PreviewReportWindow::setHideSaveToFileButton(bool value)
|
|
|
|
{
|
|
|
|
ui->actionSaveToFile->setVisible(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewReportWindow::setHidePrintToPdfButton(bool value)
|
|
|
|
{
|
|
|
|
ui->actionPrint_To_PDF->setVisible(value);
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void PreviewReportWindow::setEnablePrintMenu(bool value) { ui->menuReport->setEnabled(value); }
|
2019-04-10 16:23:50 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
QSettings* PreviewReportWindow::settings()
|
2016-02-17 10:11:00 +03:00
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
if (m_settings) {
|
2016-02-17 10:11:00 +03:00
|
|
|
return m_settings;
|
|
|
|
} else {
|
2024-09-04 17:31:16 +03:00
|
|
|
m_settings = new QSettings("LimeReport", QCoreApplication::applicationName());
|
2016-02-17 10:11:00 +03:00
|
|
|
m_ownedSettings = true;
|
|
|
|
return m_settings;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewReportWindow::setPages(ReportPages pages)
|
|
|
|
{
|
2016-03-30 23:19:05 +03:00
|
|
|
m_previewReportWidget->d_ptr->setPages(pages);
|
2024-09-04 17:31:16 +03:00
|
|
|
if (!pages.isEmpty()) {
|
2016-03-30 23:19:05 +03:00
|
|
|
initPreview(pages.count());
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void PreviewReportWindow::setDefaultPrinter(QPrinter* printer)
|
2019-02-20 13:54:26 +03:00
|
|
|
{
|
|
|
|
m_previewReportWidget->setDefaultPrinter(printer);
|
|
|
|
}
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
void PreviewReportWindow::exec()
|
|
|
|
{
|
|
|
|
bool deleteOnClose = testAttribute(Qt::WA_DeleteOnClose);
|
2024-09-04 17:31:16 +03:00
|
|
|
setAttribute(Qt::WA_DeleteOnClose, false);
|
|
|
|
setAttribute(Qt::WA_ShowModal, true);
|
2016-02-17 10:11:00 +03:00
|
|
|
show();
|
|
|
|
m_eventLoop.exec();
|
2024-09-04 17:31:16 +03:00
|
|
|
if (deleteOnClose)
|
|
|
|
delete this;
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
2019-10-16 02:08:45 +03:00
|
|
|
void PreviewReportWindow::closeEvent(QCloseEvent* e)
|
2016-02-17 10:11:00 +03:00
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
if (m_progressBar->isVisible()) {
|
2019-10-16 02:08:45 +03:00
|
|
|
QMessageBox::critical(this, tr("Attention"), tr("The printing is in process"));
|
|
|
|
e->setAccepted(false);
|
|
|
|
}
|
2016-02-17 10:11:00 +03:00
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
writeSetting();
|
|
|
|
#endif
|
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
writeSetting();
|
|
|
|
#endif
|
|
|
|
m_eventLoop.exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewReportWindow::resizeEvent(QResizeEvent* e)
|
|
|
|
{
|
|
|
|
#ifdef Q_OS_UNIX
|
2024-09-04 17:31:16 +03:00
|
|
|
if (e->oldSize() != e->size()) {
|
2016-02-17 10:11:00 +03:00
|
|
|
writeSetting();
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
Q_UNUSED(e)
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewReportWindow::moveEvent(QMoveEvent* e)
|
|
|
|
{
|
|
|
|
#ifdef Q_OS_UNIX
|
2024-09-04 17:31:16 +03:00
|
|
|
if (e->oldPos() != e->pos()) {
|
2016-02-17 10:11:00 +03:00
|
|
|
writeSetting();
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
Q_UNUSED(e)
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void PreviewReportWindow::showEvent(QShowEvent*)
|
2016-06-10 18:05:18 +03:00
|
|
|
{
|
|
|
|
m_fontEditor->setVisible(ui->actionEdit_Mode->isChecked());
|
2019-07-09 12:28:58 +03:00
|
|
|
if (ui->editModeTools)
|
|
|
|
ui->editModeTools->setVisible(false);
|
2016-06-10 18:05:18 +03:00
|
|
|
m_textAlignmentEditor->setVisible(ui->actionEdit_Mode->isChecked());
|
2018-07-11 02:42:43 +03:00
|
|
|
switch (m_previewScaleType) {
|
|
|
|
case FitWidth:
|
|
|
|
m_previewReportWidget->fitWidth();
|
|
|
|
break;
|
|
|
|
case FitPage:
|
|
|
|
m_previewReportWidget->fitPage();
|
|
|
|
break;
|
|
|
|
case OneToOne:
|
|
|
|
m_previewReportWidget->setScalePercent(100);
|
|
|
|
break;
|
|
|
|
case Percents:
|
|
|
|
m_previewReportWidget->setScalePercent(m_previewScalePercent);
|
|
|
|
}
|
2016-06-10 18:05:18 +03:00
|
|
|
}
|
2018-07-11 02:42:43 +03:00
|
|
|
|
2016-08-08 15:50:04 +03:00
|
|
|
void PreviewReportWindow::selectStateIcon()
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
if (ui->toolBar->isHidden()) {
|
2016-08-08 15:50:04 +03:00
|
|
|
ui->actionShow_Toolbar->setIcon(QIcon(":/report/images/not_checked.png"));
|
|
|
|
} else {
|
|
|
|
ui->actionShow_Toolbar->setIcon(QIcon(":/report/images/checked.png"));
|
|
|
|
}
|
|
|
|
}
|
2016-06-10 18:05:18 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void PreviewReportWindow::slotPrint() { m_previewReportWidget->print(); }
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void PreviewReportWindow::slotPriorPage() { m_previewReportWidget->priorPage(); }
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void PreviewReportWindow::slotNextPage() { m_previewReportWidget->nextPage(); }
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void PreviewReportWindow::slotZoomIn() { m_previewReportWidget->zoomIn(); }
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void PreviewReportWindow::slotZoomOut() { m_previewReportWidget->zoomOut(); }
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
void PreviewReportWindow::slotPageNavigatorChanged(int value)
|
|
|
|
{
|
2016-04-02 03:38:23 +03:00
|
|
|
m_previewReportWidget->pageNavigatorChanged(value);
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewReportWindow::slotShowErrors()
|
|
|
|
{
|
2016-03-30 23:19:05 +03:00
|
|
|
m_previewReportWidget->setErrorsMesagesVisible(ui->actionShowMessages->isChecked());
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
2016-06-10 18:05:18 +03:00
|
|
|
void PreviewReportWindow::on_actionEdit_Mode_triggered(bool checked)
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
m_previewReportWidget->d_ptr->m_previewPage->setItemMode((checked) ? ItemModes(DesignMode)
|
|
|
|
: PreviewMode);
|
2016-06-10 18:05:18 +03:00
|
|
|
m_textAlignmentEditor->setVisible(checked);
|
|
|
|
m_fontEditor->setVisible(checked);
|
2019-02-21 03:20:26 +03:00
|
|
|
if (checked)
|
|
|
|
ui->editModeTools->show();
|
2024-09-04 17:31:16 +03:00
|
|
|
else
|
|
|
|
ui->editModeTools->hide();
|
2016-06-10 18:05:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewReportWindow::slotSelectionChanged()
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
QGraphicsScene* page = dynamic_cast<QGraphicsScene*>(sender());
|
|
|
|
if (page) {
|
|
|
|
if (page->selectedItems().count() == 1) {
|
2016-06-10 18:05:18 +03:00
|
|
|
BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(page->selectedItems().at(0));
|
|
|
|
if (item) {
|
|
|
|
m_fontEditor->setItem(item);
|
|
|
|
m_textAlignmentEditor->setItem(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
ItemsReaderIntf* PreviewReportWindow::reader() { return m_reader.data(); }
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2016-04-02 16:07:01 +03:00
|
|
|
void PreviewReportWindow::initPercentCombobox()
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
for (int i = 10; i < 310; i += 10) {
|
2016-04-02 16:07:01 +03:00
|
|
|
m_scalePercent->addItem(QString("%1%").arg(i));
|
|
|
|
}
|
|
|
|
m_scalePercent->setCurrentIndex(4);
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
ScaleType PreviewReportWindow::previewScaleType() const { return m_previewScaleType; }
|
2018-07-11 02:42:43 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void PreviewReportWindow::setPreviewScaleType(const ScaleType& previewScaleType, int percent)
|
2018-07-11 02:42:43 +03:00
|
|
|
{
|
|
|
|
m_previewScaleType = previewScaleType;
|
|
|
|
m_previewScalePercent = percent;
|
|
|
|
m_previewReportWidget->setScaleType(previewScaleType, percent);
|
|
|
|
}
|
|
|
|
|
2019-02-18 15:16:55 +03:00
|
|
|
QColor PreviewReportWindow::previewPageBackgroundColor()
|
|
|
|
{
|
|
|
|
return m_previewReportWidget->previewPageBackgroundColor();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewReportWindow::setPreviewPageBackgroundColor(QColor color)
|
|
|
|
{
|
|
|
|
m_previewReportWidget->setPreviewPageBackgroundColor(color);
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void PreviewReportWindow::on_actionSaveToFile_triggered() { m_previewReportWidget->saveToFile(); }
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void PreviewReportWindow::slotFirstPage() { m_previewReportWidget->firstPage(); }
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void PreviewReportWindow::slotLastPage() { m_previewReportWidget->lastPage(); }
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void PreviewReportWindow::slotPrintToPDF() { m_previewReportWidget->printToPDF(); }
|
2016-02-17 10:19:50 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void PreviewReportWindow::slotPageChanged(int pageIndex) { m_pagesNavigator->setValue(pageIndex); }
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2019-02-21 03:20:26 +03:00
|
|
|
void PreviewReportWindow::slotInsertNewTextItem()
|
|
|
|
{
|
|
|
|
m_previewReportWidget->startInsertTextItem();
|
2019-03-01 23:48:28 +03:00
|
|
|
ui->actionSelection_Mode->setChecked(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewReportWindow::slotActivateItemSelectionMode()
|
|
|
|
{
|
|
|
|
m_previewReportWidget->activateItemSelectionMode();
|
|
|
|
ui->actionSelection_Mode->setChecked(true);
|
|
|
|
ui->actionInsertTextItem->setChecked(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewReportWindow::slotDeleteSelectedItems()
|
|
|
|
{
|
|
|
|
m_previewReportWidget->deleteSelectedItems();
|
2019-02-21 03:20:26 +03:00
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void PreviewReportWindow::on_actionFit_page_width_triggered() { m_previewReportWidget->fitWidth(); }
|
2016-04-02 16:07:01 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void PreviewReportWindow::on_actionFit_page_triggered() { m_previewReportWidget->fitPage(); }
|
2016-04-02 16:07:01 +03:00
|
|
|
|
|
|
|
void PreviewReportWindow::on_actionOne_to_one_triggered()
|
|
|
|
{
|
|
|
|
m_previewReportWidget->setScalePercent(100);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewReportWindow::scaleComboboxChanged(QString text)
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
if (m_scalePercentChanging)
|
|
|
|
return;
|
2018-08-07 23:30:40 +03:00
|
|
|
m_scalePercentChanging = true;
|
2024-09-04 17:31:16 +03:00
|
|
|
m_previewReportWidget->setScalePercent(text.remove(text.count() - 1, 1).toInt());
|
2018-08-07 23:30:40 +03:00
|
|
|
m_scalePercentChanging = false;
|
2016-04-02 16:07:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewReportWindow::slotScalePercentChanged(int percent)
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
if (m_scalePercentChanging)
|
|
|
|
return;
|
2018-08-07 23:30:40 +03:00
|
|
|
m_scalePercentChanging = true;
|
|
|
|
if (m_scalePercent->findText(QString("%1%").arg(percent)) == -1)
|
|
|
|
m_scalePercent->setCurrentIndex(-1);
|
2016-04-05 23:06:11 +03:00
|
|
|
m_scalePercent->setEditText(QString("%1%").arg(percent));
|
2018-08-07 23:30:40 +03:00
|
|
|
m_scalePercentChanging = false;
|
2016-04-02 16:07:01 +03:00
|
|
|
}
|
|
|
|
|
2016-04-21 12:25:16 +03:00
|
|
|
void PreviewReportWindow::on_actionShowMessages_toggled(bool value)
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
m_previewReportWidget->setErrorsMesagesVisible(value);
|
2016-04-21 12:25:16 +03:00
|
|
|
}
|
|
|
|
|
2016-08-08 15:50:04 +03:00
|
|
|
void PreviewReportWindow::on_actionShow_Toolbar_triggered()
|
|
|
|
{
|
|
|
|
setToolBarVisible(!ui->toolBar->isHidden());
|
|
|
|
writeSetting();
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void PreviewReportWindow::slotCurrentPageChanged(int /*page*/) { slotActivateItemSelectionMode(); }
|
2019-03-01 23:48:28 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void PreviewReportWindow::slotItemInserted(PageDesignIntf*, QPointF, const QString&)
|
2019-03-01 23:48:28 +03:00
|
|
|
{
|
|
|
|
slotActivateItemSelectionMode();
|
|
|
|
}
|
|
|
|
|
2019-10-16 02:08:45 +03:00
|
|
|
void PreviewReportWindow::slotPrintingStarted(int pageCount)
|
|
|
|
{
|
|
|
|
m_progressBar->setMinimum(1);
|
|
|
|
m_progressBar->setMaximum(pageCount);
|
|
|
|
m_progressWidget->setVisible(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PreviewReportWindow::slotPagePrintingFinished(int pageIndex)
|
|
|
|
{
|
|
|
|
m_progressBar->setValue(pageIndex);
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void PreviewReportWindow::slotPrintingFinished() { m_progressWidget->setVisible(false); }
|
2019-10-16 02:08:45 +03:00
|
|
|
|
|
|
|
void PreviewReportWindow::slotCancelPrinting(bool)
|
|
|
|
{
|
|
|
|
m_previewReportWidget->d_ptr->m_report->cancelPrinting();
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
} // namespace LimeReport
|