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 <QAction>
|
2024-09-04 17:31:16 +03:00
|
|
|
#include <QApplication>
|
|
|
|
#include <QCheckBox>
|
2016-02-17 10:11:00 +03:00
|
|
|
#include <QDebug>
|
|
|
|
#include <QDockWidget>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QMenuBar>
|
2024-09-04 17:31:16 +03:00
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QStatusBar>
|
|
|
|
#include <QToolBar>
|
|
|
|
#include <QToolButton>
|
2016-02-17 10:11:00 +03:00
|
|
|
#include <QVBoxLayout>
|
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
|
2024-09-04 17:31:16 +03:00
|
|
|
#include "lraboutdialog.h"
|
2016-02-17 10:11:00 +03:00
|
|
|
#include "lrbandsmanager.h"
|
2024-09-04 17:31:16 +03:00
|
|
|
#include "lrbasedesignintf.h"
|
2016-02-17 10:11:00 +03:00
|
|
|
#include "lrbasedesignobjectmodel.h"
|
|
|
|
#include "lrdatabrowser.h"
|
2024-09-04 17:31:16 +03:00
|
|
|
#include "lrobjectinspectorwidget.h"
|
2016-02-17 10:11:00 +03:00
|
|
|
#include "lrpagedesignintf.h"
|
|
|
|
#include "lrpreviewreportwindow.h"
|
2024-09-04 17:31:16 +03:00
|
|
|
#include "lrreportdesignwidget.h"
|
|
|
|
#include "lrreportdesignwindow.h"
|
|
|
|
#include "objectsbrowser/lrobjectbrowser.h"
|
|
|
|
#include "scriptbrowser/lrscriptbrowser.h"
|
2016-02-17 10:11:00 +03:00
|
|
|
#include "serializators/lrstorageintf.h"
|
|
|
|
#include "serializators/lrxmlreader.h"
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QSortFilterProxyModel>
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
namespace LimeReport {
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
ReportDesignWindow* ReportDesignWindow::m_instance = 0;
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2019-10-16 02:08:45 +03:00
|
|
|
void ReportDesignWindow::createProgressBar()
|
|
|
|
{
|
|
|
|
m_progressWidget = new QWidget(m_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
|
|
|
m_progressLabel = new QLabel(tr("Rendered %1 pages").arg(0));
|
|
|
|
progressLayout->addWidget(m_progressLabel);
|
|
|
|
m_progressBar = new QProgressBar(m_statusBar);
|
|
|
|
m_progressBar->setFormat("%v pages");
|
|
|
|
m_progressBar->setAlignment(Qt::AlignCenter);
|
|
|
|
m_progressBar->setMaximumWidth(100);
|
|
|
|
m_progressBar->setMaximumHeight(m_statusBar->fontMetrics().height());
|
|
|
|
m_progressBar->setMinimum(0);
|
|
|
|
m_progressBar->setMaximum(0);
|
|
|
|
m_progressBar->setTextVisible(true);
|
|
|
|
progressLayout->addWidget(m_progressBar);
|
|
|
|
QToolButton* tbCancel = new QToolButton();
|
|
|
|
tbCancel->setToolTip(tr("Cancel report rendering"));
|
|
|
|
tbCancel->setIcon(QIcon(":/report/images/closebox"));
|
|
|
|
tbCancel->setAutoRaise(true);
|
|
|
|
connect(tbCancel, SIGNAL(clicked(bool)), this, SLOT(slotCancelRendering(bool)));
|
|
|
|
progressLayout->addWidget(tbCancel);
|
|
|
|
progressLayout->setSizeConstraint(QLayout::SetFixedSize);
|
|
|
|
m_progressWidget->setLayout(progressLayout);
|
|
|
|
m_progressWidget->setVisible(false);
|
|
|
|
m_statusBar->addPermanentWidget(m_progressWidget);
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(dynamic_cast<QObject*>(m_reportDesignWidget->report()), SIGNAL(renderStarted()), this,
|
|
|
|
SLOT(renderStarted()));
|
|
|
|
connect(dynamic_cast<QObject*>(m_reportDesignWidget->report()), SIGNAL(renderPageFinished(int)),
|
|
|
|
this, SLOT(renderPageFinished(int)));
|
|
|
|
connect(dynamic_cast<QObject*>(m_reportDesignWidget->report()), SIGNAL(renderFinished()), this,
|
|
|
|
SLOT(renderFinished()));
|
|
|
|
}
|
|
|
|
|
|
|
|
ReportDesignWindow::ReportDesignWindow(ReportEnginePrivateInterface* report, QWidget* parent,
|
|
|
|
QSettings* settings):
|
|
|
|
ReportDesignWindowInterface(parent),
|
|
|
|
m_textAttibutesIsChanging(false),
|
|
|
|
m_settings(settings),
|
|
|
|
m_ownedSettings(false),
|
|
|
|
m_progressDialog(0),
|
|
|
|
m_showProgressDialog(true),
|
|
|
|
m_editorTabType(ReportDesignWidget::Page),
|
|
|
|
m_reportItemIsLocked(false)
|
2016-02-17 10:11:00 +03:00
|
|
|
{
|
|
|
|
initReportEditor(report);
|
|
|
|
createActions();
|
|
|
|
createMainMenu();
|
|
|
|
createToolBars();
|
|
|
|
createObjectInspector();
|
|
|
|
createDataWindow();
|
2016-06-10 18:05:18 +03:00
|
|
|
createScriptWindow();
|
2016-02-17 10:11:00 +03:00
|
|
|
createObjectsBrowser();
|
2019-10-16 02:08:45 +03:00
|
|
|
|
2017-04-07 21:01:51 +03:00
|
|
|
#ifdef HAVE_QTDESIGNER_INTEGRATION
|
|
|
|
createDialogWidgetBox();
|
|
|
|
createDialogPropertyEditor();
|
|
|
|
createDialogObjectInspector();
|
|
|
|
createDialogActionEditor();
|
|
|
|
createDialogSignalSlotEditor();
|
2017-04-18 20:00:59 +03:00
|
|
|
createDialogResourceEditor();
|
2017-04-11 11:23:34 +03:00
|
|
|
createDialogDesignerToolBar();
|
2017-04-07 21:01:51 +03:00
|
|
|
#endif
|
2024-09-04 17:31:16 +03:00
|
|
|
m_instance = this;
|
|
|
|
m_statusBar = new QStatusBar(this);
|
|
|
|
m_lblReportName = new QLabel(report->reportFileName(), this);
|
|
|
|
m_statusBar->insertWidget(0, m_lblReportName);
|
2016-02-17 10:11:00 +03:00
|
|
|
setStatusBar(m_statusBar);
|
2018-08-27 17:48:02 +03:00
|
|
|
|
2018-08-27 17:44:33 +03:00
|
|
|
QString windowTitle = "Lime Report Designer";
|
|
|
|
if (!report->reportName().isEmpty())
|
|
|
|
windowTitle = report->reportName() + " - " + windowTitle;
|
|
|
|
setWindowTitle(windowTitle);
|
2017-04-11 11:23:34 +03:00
|
|
|
showDefaultEditors();
|
|
|
|
showDefaultToolBars();
|
2016-02-17 10:11:00 +03:00
|
|
|
restoreSetting();
|
2016-02-17 10:19:50 +03:00
|
|
|
m_hideLeftPanel->setChecked(isDockAreaVisible(Qt::LeftDockWidgetArea));
|
2019-10-16 02:08:45 +03:00
|
|
|
m_hideRightPanel->setChecked(isDockAreaVisible(Qt::RightDockWidgetArea));
|
|
|
|
createProgressBar();
|
2024-09-04 17:31:16 +03:00
|
|
|
m_deletePageAction->setEnabled(report->pageCount() > 1);
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
ReportDesignWindow::~ReportDesignWindow()
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
m_instance = 0;
|
2016-02-17 10:11:00 +03:00
|
|
|
delete m_validator;
|
2024-09-04 17:31:16 +03:00
|
|
|
if (m_ownedSettings && m_settings)
|
|
|
|
delete m_settings;
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::createActions()
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
m_newReportAction = new QAction(tr("New Report"), this);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_newReportAction->setIcon(QIcon(":/report/images/newReport"));
|
2021-08-23 08:07:08 +03:00
|
|
|
m_newReportAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_N));
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_newReportAction, SIGNAL(triggered()), this, SLOT(slotNewReport()));
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_newPageAction = new QAction(tr("New Report Page"), this);
|
2016-06-10 18:05:18 +03:00
|
|
|
m_newPageAction->setIcon(QIcon(":/report/images/addPage"));
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_newPageAction, SIGNAL(triggered()), this, SLOT(slotNewPage()));
|
2016-06-10 18:05:18 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_deletePageAction = new QAction(tr("Delete Report Page"), this);
|
2016-06-10 18:05:18 +03:00
|
|
|
m_deletePageAction->setIcon(QIcon(":/report/images/deletePage"));
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_deletePageAction, SIGNAL(triggered()), this, SLOT(slotDeletePage()));
|
2016-06-10 18:05:18 +03:00
|
|
|
m_deletePageAction->setEnabled(false);
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_editModeAction = new QAction(tr("Edit Mode"), this);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_editModeAction->setIcon(QIcon(":/report/images/editMode"));
|
|
|
|
m_editModeAction->setCheckable(true);
|
|
|
|
m_editModeAction->setChecked(true);
|
2024-09-04 17:31:16 +03:00
|
|
|
// m_editModeAction->setShortcut(QKeySequence(Qt::Key_Escape));
|
|
|
|
connect(m_editModeAction, SIGNAL(triggered()), this, SLOT(slotEditMode()));
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_undoAction = new QAction(tr("Undo"), this);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_undoAction->setIcon(QIcon(":/report/images/undo"));
|
|
|
|
m_undoAction->setEnabled(false);
|
2021-08-23 08:07:08 +03:00
|
|
|
m_undoAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Z));
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_undoAction, SIGNAL(triggered()), this, SLOT(slotUndo()));
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_redoAction = new QAction(tr("Redo"), this);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_redoAction->setIcon(QIcon(":/report/images/redo"));
|
|
|
|
m_redoAction->setEnabled(false);
|
2021-08-23 08:07:08 +03:00
|
|
|
m_redoAction->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_Z));
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_redoAction, SIGNAL(triggered()), this, SLOT(slotRedo()));
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_copyAction = new QAction(tr("Copy"), this);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_copyAction->setIcon(QIcon(":/report/images/copy"));
|
2021-08-23 08:07:08 +03:00
|
|
|
m_copyAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_C));
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_copyAction, SIGNAL(triggered()), this, SLOT(slotCopy()));
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_pasteAction = new QAction(tr("Paste"), this);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_pasteAction->setIcon(QIcon(":/report/images/paste"));
|
2021-08-23 08:07:08 +03:00
|
|
|
m_pasteAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_V));
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_pasteAction, SIGNAL(triggered()), this, SLOT(slotPaste()));
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_cutAction = new QAction(tr("Cut"), this);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_cutAction->setIcon(QIcon(":/report/images/cut"));
|
2021-08-23 08:07:08 +03:00
|
|
|
m_cutAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_X));
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_cutAction, SIGNAL(triggered()), this, SLOT(slotCut()));
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_settingsAction = new QAction(tr("Settings"), this);
|
2016-02-18 21:11:59 +03:00
|
|
|
m_settingsAction->setIcon(QIcon(":/report/images/settings"));
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_settingsAction, SIGNAL(triggered()), this, SLOT(slotEditSettings()));
|
2016-02-18 21:11:59 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_useGridAction = new QAction(tr("Use grid"), this);
|
2016-02-18 21:11:59 +03:00
|
|
|
m_useGridAction->setIcon(QIcon(":/report/images/grid"));
|
|
|
|
m_useGridAction->setCheckable(true);
|
2021-08-23 08:07:08 +03:00
|
|
|
m_useGridAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_G));
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_useGridAction, SIGNAL(toggled(bool)), this, SLOT(slotUseGrid(bool)));
|
2016-02-21 01:08:54 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_useMagnetAction = new QAction(tr("Use magnet"), this);
|
2016-02-21 01:08:54 +03:00
|
|
|
m_useMagnetAction->setIcon(QIcon(":/report/images/magnet"));
|
|
|
|
m_useMagnetAction->setCheckable(true);
|
2021-08-23 08:07:08 +03:00
|
|
|
m_useMagnetAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_M));
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_useMagnetAction, SIGNAL(toggled(bool)), this, SLOT(slotUseMagnet(bool)));
|
2016-02-21 01:08:54 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_newTextItemAction = new QAction(tr("Text Item"), this);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_newTextItemAction->setIcon(QIcon(":/items/TextItem"));
|
2024-09-04 17:31:16 +03:00
|
|
|
m_actionMap.insert("TextItem", m_newTextItemAction);
|
|
|
|
connect(m_newTextItemAction, SIGNAL(triggered()), this, SLOT(slotNewTextItem()));
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_saveReportAction = new QAction(tr("Save Report"), this);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_saveReportAction->setIcon(QIcon(":/report/images/save"));
|
2021-08-23 08:07:08 +03:00
|
|
|
m_saveReportAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_S));
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_saveReportAction, SIGNAL(triggered()), this, SLOT(slotSaveReport()));
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_saveReportAsAction = new QAction(tr("Save Report As"), this);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_saveReportAsAction->setIcon(QIcon(":/report/images/saveas"));
|
2021-08-23 08:07:08 +03:00
|
|
|
m_saveReportAsAction->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_S));
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_saveReportAsAction, SIGNAL(triggered()), this, SLOT(slotSaveReportAs()));
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_loadReportAction = new QAction(tr("Load Report"), this);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_loadReportAction->setIcon(QIcon(":/report/images/folder"));
|
2021-08-23 08:07:08 +03:00
|
|
|
m_loadReportAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_O));
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_loadReportAction, SIGNAL(triggered()), this, SLOT(slotLoadReport()));
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_deleteItemAction = new QAction(tr("Delete item"), this);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_deleteItemAction->setShortcut(QKeySequence("Del"));
|
|
|
|
m_deleteItemAction->setIcon(QIcon(":/report/images/delete"));
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_deleteItemAction, SIGNAL(triggered()), this, SLOT(slotDelete()));
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_zoomInReportAction = new QAction(tr("Zoom In"), this);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_zoomInReportAction->setIcon(QIcon(":/report/images/zoomIn"));
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_zoomInReportAction, SIGNAL(triggered()), this, SLOT(slotZoomIn()));
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_zoomOutReportAction = new QAction(tr("Zoom Out"), this);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_zoomOutReportAction->setIcon(QIcon(":/report/images/zoomOut"));
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_zoomOutReportAction, SIGNAL(triggered()), this, SLOT(slotZoomOut()));
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_previewReportAction = new QAction(tr("Render Report"), this);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_previewReportAction->setIcon(QIcon(":/report/images/render"));
|
2021-08-23 08:07:08 +03:00
|
|
|
m_previewReportAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_P));
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_previewReportAction, SIGNAL(triggered()), this, SLOT(slotPreviewReport()));
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_testAction = new QAction("test", this);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_testAction->setIcon(QIcon(":/report/images/pin"));
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_testAction, SIGNAL(triggered()), this, SLOT(slotTest()));
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_editLayoutMode = new QAction(tr("Edit layouts mode"), this);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_editLayoutMode->setIcon(QIcon(":/report/images/editlayout"));
|
|
|
|
m_editLayoutMode->setCheckable(true);
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_editLayoutMode, SIGNAL(triggered()), this, SLOT(slotEditLayoutMode()));
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_addHLayout = new QAction(tr("Horizontal layout"), this);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_addHLayout->setIcon(QIcon(":/report/images/hlayout"));
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_addHLayout, SIGNAL(triggered()), this, SLOT(slotHLayout()));
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_addVLayout = new QAction(tr("Vertical layout"), this);
|
2018-06-21 14:29:00 +03:00
|
|
|
m_addVLayout->setIcon(QIcon(":/report/images/vlayout"));
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_addVLayout, SIGNAL(triggered()), this, SLOT(slotVLayout()));
|
2018-06-21 14:29:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_aboutAction = new QAction(tr("About"), this);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_aboutAction->setIcon(QIcon(":/report/images/copyright"));
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_aboutAction, SIGNAL(triggered()), this, SLOT(slotShowAbout()));
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_hideLeftPanel = new QAction(tr("Hide left panel | Alt+L"), this);
|
2016-02-17 10:19:50 +03:00
|
|
|
m_hideLeftPanel->setCheckable(true);
|
|
|
|
m_hideLeftPanel->setIcon(QIcon(":/report/images/hideLeftPanel"));
|
2021-08-23 08:07:08 +03:00
|
|
|
m_hideLeftPanel->setShortcut(QKeySequence(Qt::ALT | Qt::Key_L));
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_hideLeftPanel, SIGNAL(toggled(bool)), this, SLOT(slotHideLeftPanel(bool)));
|
2016-02-17 10:19:50 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_hideRightPanel = new QAction(tr("Hide right panel | Alt+R"), this);
|
2016-02-17 10:19:50 +03:00
|
|
|
m_hideRightPanel->setCheckable(true);
|
|
|
|
m_hideRightPanel->setIcon(QIcon(":/report/images/hideRightPanel"));
|
2021-08-23 08:07:08 +03:00
|
|
|
m_hideRightPanel->setShortcut(QKeySequence(Qt::ALT | Qt::Key_R));
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_hideRightPanel, SIGNAL(toggled(bool)), this, SLOT(slotHideRightPanel(bool)));
|
2017-04-14 02:43:34 +03:00
|
|
|
#ifdef HAVE_QTDESIGNER_INTEGRATION
|
|
|
|
m_deleteDialogAction = new QAction(tr("Delete dialog"), this);
|
|
|
|
m_deleteDialogAction->setIcon(QIcon(":/report//images/deleteDialog"));
|
|
|
|
connect(m_deleteDialogAction, SIGNAL(triggered()), this, SLOT(slotDeleteDialog()));
|
|
|
|
|
|
|
|
m_addNewDialogAction = new QAction(tr("Add new dialog"), this);
|
|
|
|
m_addNewDialogAction->setIcon(QIcon(":/report//images/addDialog"));
|
|
|
|
connect(m_addNewDialogAction, SIGNAL(triggered()), this, SLOT(slotAddNewDialog()));
|
|
|
|
#endif
|
2019-06-28 20:12:47 +03:00
|
|
|
|
|
|
|
m_lockSelectedItemsAction = new QAction(tr("Lock selected items"), this);
|
|
|
|
m_lockSelectedItemsAction->setIcon(QIcon(":/report/images/lock"));
|
2021-08-23 08:07:08 +03:00
|
|
|
m_lockSelectedItemsAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_L));
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_lockSelectedItemsAction, SIGNAL(triggered()), this, SLOT(slotLockSelectedItems()));
|
2019-06-28 20:12:47 +03:00
|
|
|
|
|
|
|
m_unlockSelectedItemsAction = new QAction(tr("Unlock selected items"), this);
|
|
|
|
m_unlockSelectedItemsAction->setIcon(QIcon(":/report/images/unlock"));
|
2021-08-23 08:07:08 +03:00
|
|
|
m_unlockSelectedItemsAction->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_L));
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_unlockSelectedItemsAction, SIGNAL(triggered()), this,
|
|
|
|
SLOT(slotUnlockSelectedItems()));
|
2019-06-28 20:12:47 +03:00
|
|
|
|
|
|
|
m_selectOneLevelItems = new QAction(tr("Select one level items"), this);
|
2024-09-04 17:31:16 +03:00
|
|
|
// m_unlockSelectedItemsAction->setIcon(QIcon(":/report/images/unlock"));
|
2021-08-23 08:07:08 +03:00
|
|
|
m_selectOneLevelItems->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_A));
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_selectOneLevelItems, SIGNAL(triggered()), this, SLOT(slotSelectOneLevelItems()));
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::createReportToolBar()
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
m_reportToolBar = new QToolBar(tr("Report Tools"), this);
|
|
|
|
m_reportToolBar->setIconSize(QSize(24, 24));
|
2016-02-17 10:11:00 +03:00
|
|
|
m_reportToolBar->addAction(m_editModeAction);
|
|
|
|
m_reportToolBar->addWidget(m_newBandButton);
|
|
|
|
m_reportToolBar->addAction(m_newTextItemAction);
|
|
|
|
m_reportToolBar->setObjectName("reportTools");
|
|
|
|
createItemsActions();
|
|
|
|
m_reportToolBar->addSeparator();
|
|
|
|
m_reportToolBar->addAction(m_addHLayout);
|
2018-06-21 14:29:00 +03:00
|
|
|
m_reportToolBar->addAction(m_addVLayout);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_reportToolBar->addSeparator();
|
|
|
|
m_reportToolBar->addAction(m_deleteItemAction);
|
2016-02-17 10:19:50 +03:00
|
|
|
|
|
|
|
QWidget* empty = new QWidget();
|
2024-09-04 17:31:16 +03:00
|
|
|
empty->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
2016-02-17 10:19:50 +03:00
|
|
|
m_reportToolBar->addWidget(empty);
|
|
|
|
|
|
|
|
m_reportToolBar->addAction(m_hideLeftPanel);
|
|
|
|
m_reportToolBar->addAction(m_hideRightPanel);
|
2024-09-04 17:31:16 +03:00
|
|
|
addToolBar(Qt::LeftToolBarArea, m_reportToolBar);
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::createToolBars()
|
|
|
|
{
|
|
|
|
createBandsButton();
|
|
|
|
|
2016-02-17 10:39:17 +03:00
|
|
|
m_mainToolBar = addToolBar(tr("Main Tools"));
|
2024-09-04 17:31:16 +03:00
|
|
|
m_mainToolBar->setIconSize(QSize(16, 16));
|
|
|
|
m_mainToolBar->setAllowedAreas(Qt::LeftToolBarArea | Qt::RightToolBarArea | Qt::TopToolBarArea);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_mainToolBar->setFloatable(false);
|
|
|
|
m_mainToolBar->setObjectName("mainTools");
|
|
|
|
|
|
|
|
m_mainToolBar->addAction(m_newReportAction);
|
|
|
|
m_mainToolBar->addAction(m_loadReportAction);
|
2016-02-17 10:39:17 +03:00
|
|
|
m_mainToolBar->addAction(m_saveReportAction);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_mainToolBar->addSeparator();
|
2016-02-18 21:11:59 +03:00
|
|
|
m_mainToolBar->addAction(m_settingsAction);
|
|
|
|
m_mainToolBar->addSeparator();
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2016-06-10 18:05:18 +03:00
|
|
|
m_mainToolBar->addAction(m_newPageAction);
|
|
|
|
m_mainToolBar->addAction(m_deletePageAction);
|
2017-04-14 02:43:34 +03:00
|
|
|
#ifdef HAVE_QTDESIGNER_INTEGRATION
|
|
|
|
m_mainToolBar->addAction(m_addNewDialogAction);
|
|
|
|
#endif
|
2016-06-10 18:05:18 +03:00
|
|
|
m_mainToolBar->addSeparator();
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
m_mainToolBar->addAction(m_copyAction);
|
|
|
|
m_mainToolBar->addAction(m_pasteAction);
|
|
|
|
m_mainToolBar->addAction(m_cutAction);
|
|
|
|
m_mainToolBar->addAction(m_undoAction);
|
|
|
|
m_mainToolBar->addAction(m_redoAction);
|
|
|
|
m_mainToolBar->addSeparator();
|
|
|
|
|
|
|
|
m_mainToolBar->addAction(m_zoomInReportAction);
|
2024-09-04 17:31:16 +03:00
|
|
|
m_mainToolBar->addAction(m_zoomOutReportAction);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_mainToolBar->addSeparator();
|
|
|
|
m_mainToolBar->addAction(m_previewReportAction);
|
2024-09-04 17:31:16 +03:00
|
|
|
// m_mainToolBar->addSeparator();
|
|
|
|
// m_mainToolBar->addAction(m_useGridAction);
|
2016-02-18 21:11:59 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
// m_mainToolBar->addAction(m_printReportAction);
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_fontEditorBar = new FontEditorWidgetForDesigner(m_reportDesignWidget, tr("Font"), this);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_fontEditorBar->setIconSize(m_mainToolBar->iconSize());
|
|
|
|
m_fontEditorBar->setObjectName("fontTools");
|
|
|
|
addToolBar(m_fontEditorBar);
|
2024-09-04 17:31:16 +03:00
|
|
|
m_textAlignmentEditorBar = new TextAlignmentEditorWidgetForDesigner(m_reportDesignWidget,
|
|
|
|
tr("Text alignment"), this);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_textAlignmentEditorBar->setIconSize(m_mainToolBar->iconSize());
|
|
|
|
m_textAlignmentEditorBar->setObjectName("textAlignmentTools");
|
|
|
|
addToolBar(m_textAlignmentEditorBar);
|
2024-09-04 17:31:16 +03:00
|
|
|
m_itemsAlignmentEditorBar
|
|
|
|
= new ItemsAlignmentEditorWidget(m_reportDesignWidget, tr("Items alignment"), this);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_itemsAlignmentEditorBar->setIconSize(m_mainToolBar->iconSize());
|
|
|
|
m_itemsAlignmentEditorBar->setObjectName("itemsAlignmentTools");
|
2024-09-04 17:31:16 +03:00
|
|
|
m_itemsAlignmentEditorBar->insertAction(m_itemsAlignmentEditorBar->actions().at(0),
|
|
|
|
m_useGridAction);
|
|
|
|
m_itemsAlignmentEditorBar->insertAction(m_itemsAlignmentEditorBar->actions().at(1),
|
|
|
|
m_useMagnetAction);
|
2016-02-21 01:08:54 +03:00
|
|
|
m_itemsAlignmentEditorBar->insertSeparator(m_itemsAlignmentEditorBar->actions().at(2));
|
2016-02-17 10:11:00 +03:00
|
|
|
addToolBar(m_itemsAlignmentEditorBar);
|
2024-09-04 17:31:16 +03:00
|
|
|
m_itemsBordersEditorBar
|
|
|
|
= new ItemsBordersEditorWidgetForDesigner(m_reportDesignWidget, tr("Borders"), this);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_itemsBordersEditorBar->setIconSize(m_mainToolBar->iconSize());
|
2016-02-18 21:11:59 +03:00
|
|
|
m_itemsBordersEditorBar->setObjectName("itemsBorderTools");
|
2016-02-17 10:11:00 +03:00
|
|
|
addToolBar(m_itemsBordersEditorBar);
|
|
|
|
|
|
|
|
createReportToolBar();
|
2017-04-11 11:23:34 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_pageTools << m_mainToolBar << m_reportToolBar << m_fontEditorBar << m_textAlignmentEditorBar
|
|
|
|
<< m_itemsAlignmentEditorBar << m_itemsBordersEditorBar;
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::createItemsActions()
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
foreach (ItemAttribs items, DesignElementsFactory::instance().attribsMap().values()) {
|
|
|
|
if (items.m_tag.compare("Item", Qt::CaseInsensitive) == 0) {
|
|
|
|
QAction* tmpAction = new QAction(QObject::tr(items.m_alias.toLatin1()), this);
|
2016-02-17 10:11:00 +03:00
|
|
|
tmpAction->setWhatsThis(DesignElementsFactory::instance().attribsMap().key(items));
|
2024-09-04 17:31:16 +03:00
|
|
|
tmpAction->setIcon(QIcon(":/items/" + tmpAction->whatsThis()));
|
|
|
|
connect(tmpAction, SIGNAL(triggered()), this, SLOT(slotItemActionCliked()));
|
2016-02-17 10:11:00 +03:00
|
|
|
m_reportToolBar->addAction(tmpAction);
|
2024-09-04 17:31:16 +03:00
|
|
|
m_actionMap.insert(tmpAction->whatsThis(), tmpAction);
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::createBandsButton()
|
|
|
|
{
|
|
|
|
m_newBandButton = new QToolButton(this);
|
|
|
|
m_newBandButton->setPopupMode(QToolButton::InstantPopup);
|
|
|
|
m_newBandButton->setIcon(QIcon(":/report/images/addBand"));
|
2016-02-17 10:39:17 +03:00
|
|
|
m_newBandButton->setToolTip(tr("Report bands"));
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
m_bandsAddSignalsMap = new QSignalMapper(this);
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_newReportHeader = new QAction(QIcon(), tr("Report Header"), this);
|
|
|
|
connect(m_newReportHeader, SIGNAL(triggered()), m_bandsAddSignalsMap, SLOT(map()));
|
|
|
|
m_bandsAddSignalsMap->setMapping(m_newReportHeader, BandDesignIntf::ReportHeader);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_newBandButton->addAction(m_newReportHeader);
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_newReportFooter = new QAction(QIcon(), tr("Report Footer"), this);
|
|
|
|
connect(m_newReportFooter, SIGNAL(triggered()), m_bandsAddSignalsMap, SLOT(map()));
|
|
|
|
m_bandsAddSignalsMap->setMapping(m_newReportFooter, BandDesignIntf::ReportFooter);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_newBandButton->addAction(m_newReportFooter);
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_newPageHeader = new QAction(QIcon(), tr("Page Header"), this);
|
|
|
|
connect(m_newPageHeader, SIGNAL(triggered()), m_bandsAddSignalsMap, SLOT(map()));
|
|
|
|
m_bandsAddSignalsMap->setMapping(m_newPageHeader, BandDesignIntf::PageHeader);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_newBandButton->addAction(m_newPageHeader);
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_newPageFooter = new QAction(QIcon(), tr("Page Footer"), this);
|
|
|
|
connect(m_newPageFooter, SIGNAL(triggered()), m_bandsAddSignalsMap, SLOT(map()));
|
|
|
|
m_bandsAddSignalsMap->setMapping(m_newPageFooter, BandDesignIntf::PageFooter);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_newBandButton->addAction(m_newPageFooter);
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_newData = new QAction(QIcon(), tr("Data"), this);
|
|
|
|
connect(m_newData, SIGNAL(triggered()), m_bandsAddSignalsMap, SLOT(map()));
|
|
|
|
m_bandsAddSignalsMap->setMapping(m_newData, BandDesignIntf::Data);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_newBandButton->addAction(m_newData);
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_newDataHeader = new QAction(QIcon(), tr("Data Header"), this);
|
2016-02-17 10:18:19 +03:00
|
|
|
m_newDataHeader->setEnabled(false);
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_newDataHeader, SIGNAL(triggered()), m_bandsAddSignalsMap, SLOT(map()));
|
|
|
|
m_bandsAddSignalsMap->setMapping(m_newDataHeader, BandDesignIntf::DataHeader);
|
2016-02-17 10:18:19 +03:00
|
|
|
m_newBandButton->addAction(m_newDataHeader);
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_newDataFooter = new QAction(QIcon(), tr("Data Footer"), this);
|
2016-02-17 10:18:19 +03:00
|
|
|
m_newDataFooter->setEnabled(false);
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_newDataFooter, SIGNAL(triggered()), m_bandsAddSignalsMap, SLOT(map()));
|
|
|
|
m_bandsAddSignalsMap->setMapping(m_newDataFooter, BandDesignIntf::DataFooter);
|
2016-02-17 10:18:19 +03:00
|
|
|
m_newBandButton->addAction(m_newDataFooter);
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_newSubDetail = new QAction(QIcon(), tr("SubDetail"), this);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_newSubDetail->setEnabled(false);
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_newSubDetail, SIGNAL(triggered()), m_bandsAddSignalsMap, SLOT(map()));
|
|
|
|
m_bandsAddSignalsMap->setMapping(m_newSubDetail, BandDesignIntf::SubDetailBand);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_newBandButton->addAction(m_newSubDetail);
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_newSubDetailHeader = new QAction(QIcon(), tr("SubDetailHeader"), this);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_newSubDetailHeader->setEnabled(false);
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_newSubDetailHeader, SIGNAL(triggered()), m_bandsAddSignalsMap, SLOT(map()));
|
|
|
|
m_bandsAddSignalsMap->setMapping(m_newSubDetailHeader, BandDesignIntf::SubDetailHeader);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_newBandButton->addAction(m_newSubDetailHeader);
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_newSubDetailFooter = new QAction(QIcon(), tr("SubDetailFooter"), this);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_newSubDetailFooter->setEnabled(false);
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_newSubDetailFooter, SIGNAL(triggered()), m_bandsAddSignalsMap, SLOT(map()));
|
|
|
|
m_bandsAddSignalsMap->setMapping(m_newSubDetailFooter, BandDesignIntf::SubDetailFooter);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_newBandButton->addAction(m_newSubDetailFooter);
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_newGroupHeader = new QAction(QIcon(), tr("GroupHeader"), this);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_newGroupHeader->setEnabled(false);
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_newGroupHeader, SIGNAL(triggered()), m_bandsAddSignalsMap, SLOT(map()));
|
|
|
|
m_bandsAddSignalsMap->setMapping(m_newGroupHeader, BandDesignIntf::GroupHeader);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_newBandButton->addAction(m_newGroupHeader);
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_newGroupFooter = new QAction(QIcon(), tr("GroupFooter"), this);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_newGroupFooter->setEnabled(false);
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_newGroupFooter, SIGNAL(triggered()), m_bandsAddSignalsMap, SLOT(map()));
|
|
|
|
m_bandsAddSignalsMap->setMapping(m_newGroupFooter, BandDesignIntf::GroupFooter);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_newBandButton->addAction(m_newGroupFooter);
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
m_newTearOffBand = new QAction(QIcon(), tr("Tear-off Band"), this);
|
|
|
|
connect(m_newTearOffBand, SIGNAL(triggered()), m_bandsAddSignalsMap, SLOT(map()));
|
|
|
|
m_bandsAddSignalsMap->setMapping(m_newTearOffBand, BandDesignIntf::TearOffBand);
|
2016-10-04 03:21:22 +03:00
|
|
|
m_newBandButton->addAction(m_newTearOffBand);
|
2021-12-26 13:40:55 +03:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1)
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_bandsAddSignalsMap, SIGNAL(mappedInt(int)), this, SLOT(slotNewBand(int)));
|
2021-11-02 22:30:29 +03:00
|
|
|
#else
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_bandsAddSignalsMap, SIGNAL(mapped(int)), this, SLOT(slotNewBand(int)));
|
2021-11-02 22:30:29 +03:00
|
|
|
#endif
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::createMainMenu()
|
|
|
|
{
|
|
|
|
m_fileMenu = menuBar()->addMenu(tr("File"));
|
|
|
|
m_fileMenu->addAction(m_newReportAction);
|
|
|
|
m_fileMenu->addAction(m_loadReportAction);
|
|
|
|
m_fileMenu->addAction(m_saveReportAction);
|
|
|
|
m_fileMenu->addAction(m_saveReportAsAction);
|
|
|
|
m_fileMenu->addAction(m_previewReportAction);
|
2024-09-04 17:31:16 +03:00
|
|
|
// m_fileMenu->addAction(m_printReportAction);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_editMenu = menuBar()->addMenu(tr("Edit"));
|
|
|
|
m_editMenu->addAction(m_redoAction);
|
|
|
|
m_editMenu->addAction(m_undoAction);
|
|
|
|
m_editMenu->addAction(m_copyAction);
|
|
|
|
m_editMenu->addAction(m_pasteAction);
|
|
|
|
m_editMenu->addAction(m_cutAction);
|
2016-02-18 21:11:59 +03:00
|
|
|
m_editMenu->addAction(m_settingsAction);
|
2019-06-28 20:12:47 +03:00
|
|
|
m_editMenu->addSeparator();
|
|
|
|
m_editMenu->addAction(m_lockSelectedItemsAction);
|
|
|
|
m_editMenu->addAction(m_unlockSelectedItemsAction);
|
|
|
|
m_editMenu->addAction(m_selectOneLevelItems);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_infoMenu = menuBar()->addMenu(tr("Info"));
|
|
|
|
m_infoMenu->addAction(m_aboutAction);
|
2016-02-19 04:03:48 +03:00
|
|
|
m_recentFilesMenu = m_fileMenu->addMenu(tr("Recent Files"));
|
|
|
|
m_recentFilesSignalMap = new QSignalMapper(this);
|
2021-12-26 13:40:55 +03:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1)
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_recentFilesSignalMap, SIGNAL(mappedString(QString)), this,
|
|
|
|
SLOT(slotLoadRecentFile(QString)));
|
2021-11-02 22:30:29 +03:00
|
|
|
#else
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_recentFilesSignalMap, SIGNAL(mapped(QString)), this,
|
|
|
|
SLOT(slotLoadRecentFile(QString)));
|
2021-11-02 22:30:29 +03:00
|
|
|
#endif
|
2016-02-19 04:03:48 +03:00
|
|
|
m_recentFilesMenu->setDisabled(m_recentFiles.isEmpty());
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
2017-11-24 00:13:47 +03:00
|
|
|
void ReportDesignWindow::initReportEditor(ReportEnginePrivateInterface* report)
|
2016-02-17 10:11:00 +03:00
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
m_reportDesignWidget = new ReportDesignWidget(report, m_settings, this, this);
|
2016-02-17 10:11:00 +03:00
|
|
|
setCentralWidget(m_reportDesignWidget);
|
2024-09-04 17:31:16 +03:00
|
|
|
connect(m_reportDesignWidget, SIGNAL(itemSelected(LimeReport::BaseDesignIntf*)), this,
|
|
|
|
SLOT(slotItemSelected(LimeReport::BaseDesignIntf*)));
|
|
|
|
connect(m_reportDesignWidget, SIGNAL(itemPropertyChanged(QString, QString, QVariant, QVariant)),
|
|
|
|
this, SLOT(slotItemPropertyChanged(QString, QString, QVariant, QVariant)));
|
|
|
|
connect(m_reportDesignWidget, SIGNAL(insertModeStarted()), this, SLOT(slotInsertModeStarted()));
|
|
|
|
connect(m_reportDesignWidget, SIGNAL(multiItemSelected()), this, SLOT(slotMultiItemSelected()));
|
|
|
|
connect(m_reportDesignWidget,
|
|
|
|
SIGNAL(itemInserted(LimeReport::PageDesignIntf*, QPointF, QString)), this,
|
|
|
|
SLOT(slotItemInserted(LimeReport::PageDesignIntf*, QPointF, QString)));
|
|
|
|
connect(m_reportDesignWidget, SIGNAL(itemInsertCanceled(QString)), this,
|
|
|
|
SLOT(slotItemInsertCanceled(QString)));
|
|
|
|
connect(dynamic_cast<QObject*>(report), SIGNAL(datasourceCollectionLoadFinished(QString)), this,
|
|
|
|
SLOT(slotUpdateDataBrowser(QString)));
|
|
|
|
connect(m_reportDesignWidget, SIGNAL(commandHistoryChanged()), this,
|
|
|
|
SLOT(slotCommandHistoryChanged()));
|
|
|
|
connect(m_reportDesignWidget, SIGNAL(activePageChanged()), this, SLOT(slotActivePageChanged()));
|
|
|
|
connect(m_reportDesignWidget,
|
|
|
|
SIGNAL(bandAdded(LimeReport::PageDesignIntf*, LimeReport::BandDesignIntf*)), this,
|
|
|
|
SLOT(slotBandAdded(LimeReport::PageDesignIntf*, LimeReport::BandDesignIntf*)));
|
|
|
|
connect(m_reportDesignWidget,
|
|
|
|
SIGNAL(bandDeleted(LimeReport::PageDesignIntf*, LimeReport::BandDesignIntf*)), this,
|
|
|
|
SLOT(slotBandDeleted(LimeReport::PageDesignIntf*, LimeReport::BandDesignIntf*)));
|
|
|
|
connect(m_reportDesignWidget, SIGNAL(pageAdded(PageDesignIntf*)), this,
|
|
|
|
SLOT(slotPageAdded(PageDesignIntf*)));
|
2016-06-10 18:05:18 +03:00
|
|
|
connect(m_reportDesignWidget, SIGNAL(pageDeleted()), this, SLOT(slotPageDeleted()));
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::createObjectInspector()
|
|
|
|
{
|
|
|
|
m_objectInspector = new ObjectInspectorWidget(this);
|
|
|
|
m_validator = new ObjectNameValidator();
|
2019-02-14 20:50:01 +03:00
|
|
|
m_objectInspector->setValidator(m_validator);
|
|
|
|
m_objectInspector->setSubclassesAsLevel(false);
|
2019-06-28 13:08:33 +03:00
|
|
|
m_objectInspector->setTranslateProperties(true);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_objectInspector->setAlternatingRowColors(true);
|
2019-02-14 20:50:01 +03:00
|
|
|
m_objectInspector->setRootIsDecorated(!m_objectInspector->subclassesAsLevel());
|
2024-09-04 17:31:16 +03:00
|
|
|
QDockWidget* objectDoc = new QDockWidget(this);
|
2016-02-17 10:11:00 +03:00
|
|
|
QWidget* w = new QWidget(objectDoc);
|
|
|
|
QVBoxLayout* l = new QVBoxLayout(w);
|
|
|
|
l->addWidget(m_objectInspector);
|
2021-08-23 08:07:08 +03:00
|
|
|
l->setContentsMargins(0, 0, 0, 0);
|
2016-02-17 10:11:00 +03:00
|
|
|
w->setLayout(l);
|
|
|
|
objectDoc->setWindowTitle(tr("Object Inspector"));
|
|
|
|
objectDoc->setWidget(w);
|
|
|
|
objectDoc->setObjectName("objectInspector");
|
2017-04-07 21:01:51 +03:00
|
|
|
m_pageEditors.append(objectDoc);
|
2024-09-04 17:31:16 +03:00
|
|
|
addDockWidget(Qt::LeftDockWidgetArea, objectDoc);
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::createObjectsBrowser()
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
QDockWidget* doc = new QDockWidget(this);
|
2016-02-17 10:11:00 +03:00
|
|
|
doc->setWindowTitle(tr("Report structure"));
|
|
|
|
m_objectsBrowser = new ObjectBrowser(doc);
|
|
|
|
doc->setWidget(m_objectsBrowser);
|
|
|
|
doc->setObjectName("structureDoc");
|
2024-09-04 17:31:16 +03:00
|
|
|
addDockWidget(Qt::RightDockWidgetArea, doc);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_objectsBrowser->setMainWindow(this);
|
2017-04-07 21:01:51 +03:00
|
|
|
m_pageEditors.append(doc);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_objectsBrowser->setReportEditor(m_reportDesignWidget);
|
|
|
|
}
|
|
|
|
|
2017-04-07 21:01:51 +03:00
|
|
|
#ifdef HAVE_QTDESIGNER_INTEGRATION
|
|
|
|
|
|
|
|
void ReportDesignWindow::createDialogWidgetBox()
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
QDockWidget* doc = new QDockWidget(this);
|
2017-04-07 21:01:51 +03:00
|
|
|
doc->setWindowTitle(tr("Widget Box"));
|
|
|
|
doc->setWidget(m_reportDesignWidget->toolWindow(ReportDesignWidget::WidgetBox));
|
|
|
|
doc->setObjectName("WidgetBox");
|
2024-09-04 17:31:16 +03:00
|
|
|
addDockWidget(Qt::LeftDockWidgetArea, doc);
|
2017-04-07 21:01:51 +03:00
|
|
|
m_dialogEditors.append(doc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::createDialogPropertyEditor()
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
QDockWidget* doc = new QDockWidget(this);
|
2017-04-07 21:01:51 +03:00
|
|
|
doc->setWindowTitle(tr("Property Editor"));
|
|
|
|
doc->setWidget(m_reportDesignWidget->toolWindow(ReportDesignWidget::PropertyEditor));
|
|
|
|
doc->setObjectName("PropertyEditor");
|
2024-09-04 17:31:16 +03:00
|
|
|
addDockWidget(Qt::RightDockWidgetArea, doc);
|
2017-04-07 21:01:51 +03:00
|
|
|
m_dialogEditors.append(doc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::createDialogObjectInspector()
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
QDockWidget* dock = new QDockWidget(this);
|
2017-04-18 20:00:59 +03:00
|
|
|
dock->setWindowTitle(tr("Object Inspector"));
|
|
|
|
dock->setWidget(m_reportDesignWidget->toolWindow(ReportDesignWidget::ObjectInspector));
|
|
|
|
dock->setObjectName("ObjectInspector");
|
2024-09-04 17:31:16 +03:00
|
|
|
addDockWidget(Qt::RightDockWidgetArea, dock);
|
2017-04-18 20:00:59 +03:00
|
|
|
m_dialogEditors.append(dock);
|
2017-04-07 21:01:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::createDialogActionEditor()
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
QDockWidget* dock = new QDockWidget(this);
|
2017-04-18 20:00:59 +03:00
|
|
|
dock->setWindowTitle(tr("Action Editor"));
|
|
|
|
dock->setWidget(m_reportDesignWidget->toolWindow(ReportDesignWidget::ActionEditor));
|
|
|
|
dock->setObjectName("ActionEditor");
|
2024-09-04 17:31:16 +03:00
|
|
|
addDockWidget(Qt::BottomDockWidgetArea, dock);
|
2017-04-18 20:00:59 +03:00
|
|
|
m_dialogEditors.append(dock);
|
|
|
|
m_docksToTabify.append(dock);
|
2017-04-07 21:01:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::createDialogResourceEditor()
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
QDockWidget* dock = new QDockWidget(this);
|
2017-04-18 20:00:59 +03:00
|
|
|
dock->setWindowTitle(tr("Resource Editor"));
|
|
|
|
dock->setWidget(m_reportDesignWidget->toolWindow(ReportDesignWidget::ResourceEditor));
|
|
|
|
dock->setObjectName("ResourceEditor");
|
2024-09-04 17:31:16 +03:00
|
|
|
addDockWidget(Qt::BottomDockWidgetArea, dock);
|
2017-04-18 20:00:59 +03:00
|
|
|
m_dialogEditors.append(dock);
|
|
|
|
m_docksToTabify.append(dock);
|
2017-04-07 21:01:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::createDialogSignalSlotEditor()
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
QDockWidget* dock = new QDockWidget(this);
|
2017-04-18 20:00:59 +03:00
|
|
|
dock->setWindowTitle(tr("SignalSlot Editor"));
|
|
|
|
dock->setWidget(m_reportDesignWidget->toolWindow(ReportDesignWidget::SignalSlotEditor));
|
|
|
|
dock->setObjectName("SignalSlotEditor");
|
2024-09-04 17:31:16 +03:00
|
|
|
addDockWidget(Qt::BottomDockWidgetArea, dock);
|
2017-04-18 20:00:59 +03:00
|
|
|
m_dialogEditors.append(dock);
|
|
|
|
m_docksToTabify.append(dock);
|
2017-04-07 21:01:51 +03:00
|
|
|
}
|
|
|
|
|
2017-04-11 11:23:34 +03:00
|
|
|
void ReportDesignWindow::createDialogDesignerToolBar()
|
|
|
|
{
|
|
|
|
m_dialogDesignerToolBar = addToolBar(tr("Dialog Designer Tools"));
|
|
|
|
m_dialogDesignerToolBar->setObjectName("DialogDesignerTools");
|
2017-04-14 02:43:34 +03:00
|
|
|
m_dialogDesignerToolBar->addAction(m_saveReportAction);
|
|
|
|
m_dialogDesignerToolBar->addAction(m_previewReportAction);
|
|
|
|
m_dialogDesignerToolBar->addSeparator();
|
|
|
|
m_dialogDesignerToolBar->addAction(m_deleteDialogAction);
|
|
|
|
m_dialogDesignerToolBar->addSeparator();
|
2017-04-11 11:23:34 +03:00
|
|
|
m_reportDesignWidget->initDialogDesignerToolBar(m_dialogDesignerToolBar);
|
|
|
|
m_dialogTools << m_dialogDesignerToolBar;
|
|
|
|
}
|
|
|
|
|
2017-04-07 21:01:51 +03:00
|
|
|
#endif
|
2019-02-14 20:51:30 +03:00
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
void ReportDesignWindow::createDataWindow()
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
QDockWidget* dataDoc = new QDockWidget(this);
|
2016-02-17 10:11:00 +03:00
|
|
|
dataDoc->setWindowTitle(tr("Data Browser"));
|
2024-09-04 17:31:16 +03:00
|
|
|
m_dataBrowser = new DataBrowser(dataDoc);
|
2016-02-17 10:11:00 +03:00
|
|
|
dataDoc->setWidget(m_dataBrowser);
|
|
|
|
dataDoc->setObjectName("dataDoc");
|
2024-09-04 17:31:16 +03:00
|
|
|
addDockWidget(Qt::LeftDockWidgetArea, dataDoc);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_dataBrowser->setSettings(settings());
|
|
|
|
m_dataBrowser->setMainWindow(this);
|
2017-04-07 21:01:51 +03:00
|
|
|
m_pageEditors.append(dataDoc);
|
2016-02-17 10:11:00 +03:00
|
|
|
m_dataBrowser->setReportEditor(m_reportDesignWidget);
|
|
|
|
}
|
|
|
|
|
2016-06-10 18:05:18 +03:00
|
|
|
void ReportDesignWindow::createScriptWindow()
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
QDockWidget* dataDoc = new QDockWidget(this);
|
2016-06-10 18:05:18 +03:00
|
|
|
dataDoc->setWindowTitle(tr("Script Browser"));
|
2024-09-04 17:31:16 +03:00
|
|
|
m_scriptBrowser = new ScriptBrowser(dataDoc);
|
2016-06-10 18:05:18 +03:00
|
|
|
dataDoc->setWidget(m_scriptBrowser);
|
|
|
|
dataDoc->setObjectName("scriptDoc");
|
2024-09-04 17:31:16 +03:00
|
|
|
addDockWidget(Qt::LeftDockWidgetArea, dataDoc);
|
2016-06-10 18:05:18 +03:00
|
|
|
m_scriptBrowser->setReportEditor(m_reportDesignWidget);
|
2017-04-07 21:01:51 +03:00
|
|
|
m_pageEditors.append(dataDoc);
|
2016-06-10 18:05:18 +03:00
|
|
|
#ifdef HAVE_UI_LOADER
|
|
|
|
m_scriptBrowser->updateDialogsTree();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
void ReportDesignWindow::updateRedoUndo()
|
|
|
|
{
|
|
|
|
m_undoAction->setEnabled(m_reportDesignWidget->isCanUndo());
|
|
|
|
m_redoAction->setEnabled(m_reportDesignWidget->isCanRedo());
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::startNewReport()
|
|
|
|
{
|
2019-02-12 22:28:16 +03:00
|
|
|
m_reportDesignWidget->saveState();
|
2016-02-17 10:11:00 +03:00
|
|
|
m_reportDesignWidget->clear();
|
|
|
|
m_reportDesignWidget->createStartPage();
|
2019-06-30 22:00:01 +03:00
|
|
|
m_reportDesignWidget->createTabs();
|
2016-02-17 10:11:00 +03:00
|
|
|
m_lblReportName->setText("");
|
|
|
|
updateRedoUndo();
|
2017-02-22 00:20:37 +03:00
|
|
|
m_reportDesignWidget->slotPagesLoadFinished();
|
2016-02-17 10:11:00 +03:00
|
|
|
m_newPageHeader->setEnabled(true);
|
|
|
|
m_newPageFooter->setEnabled(true);
|
|
|
|
m_newReportHeader->setEnabled(true);
|
|
|
|
m_newReportFooter->setEnabled(true);
|
2017-04-07 21:01:51 +03:00
|
|
|
m_editorTabType = ReportDesignWidget::Page;
|
2017-04-11 11:23:34 +03:00
|
|
|
showDefaultToolBars();
|
2019-01-31 21:01:55 +03:00
|
|
|
m_reportDesignWidget->report()->dataManager()->dropChanges();
|
2019-02-05 21:51:46 +03:00
|
|
|
m_reportDesignWidget->report()->scriptContext()->dropChanges();
|
2019-02-12 22:28:16 +03:00
|
|
|
m_reportDesignWidget->loadState();
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::writePosition()
|
|
|
|
{
|
|
|
|
settings()->beginGroup("DesignerWindow");
|
2024-09-04 17:31:16 +03:00
|
|
|
settings()->setValue("Geometry", saveGeometry());
|
2016-02-17 10:11:00 +03:00
|
|
|
settings()->endGroup();
|
|
|
|
}
|
|
|
|
|
2018-01-24 20:59:53 +03:00
|
|
|
void ReportDesignWindow::setDocWidgetsVisibility(bool visible)
|
|
|
|
{
|
|
|
|
if (!m_hideLeftPanel->isChecked())
|
2024-09-04 17:31:16 +03:00
|
|
|
hideDockWidgets(Qt::LeftDockWidgetArea, !visible);
|
2018-01-24 20:59:53 +03:00
|
|
|
if (!m_hideRightPanel->isChecked())
|
2024-09-04 17:31:16 +03:00
|
|
|
hideDockWidgets(Qt::RightDockWidgetArea, !visible);
|
2018-01-24 20:59:53 +03:00
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::keyPressEvent(QKeyEvent* event)
|
2021-11-02 22:30:29 +03:00
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
if (event->key() == Qt::Key_Escape) {
|
|
|
|
m_editModeAction->trigger();
|
|
|
|
}
|
2021-11-02 22:30:29 +03:00
|
|
|
}
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
void ReportDesignWindow::writeState()
|
|
|
|
{
|
|
|
|
settings()->beginGroup("DesignerWindow");
|
2017-09-20 22:25:50 +03:00
|
|
|
|
2018-01-24 20:59:53 +03:00
|
|
|
setDocWidgetsVisibility(true);
|
|
|
|
|
2017-09-20 22:25:50 +03:00
|
|
|
m_editorsStates[m_editorTabType] = saveState();
|
2024-09-04 17:31:16 +03:00
|
|
|
settings()->setValue("PageEditorsState", m_editorsStates[ReportDesignWidget::Page]);
|
|
|
|
settings()->setValue("DialogEditorsState", m_editorsStates[ReportDesignWidget::Dialog]);
|
|
|
|
settings()->setValue("ScriptEditorsState", m_editorsStates[ReportDesignWidget::Script]);
|
|
|
|
settings()->setValue("TranslationEditorsState",
|
|
|
|
m_editorsStates[ReportDesignWidget::Translations]);
|
2019-02-14 20:50:01 +03:00
|
|
|
settings()->setValue("InspectorFirsColumnWidth", m_objectInspector->columnWidth(0));
|
2019-06-28 13:08:33 +03:00
|
|
|
settings()->setValue("InspectorTranslateProperties", m_objectInspector->translateProperties());
|
2016-02-17 10:11:00 +03:00
|
|
|
settings()->endGroup();
|
2016-02-19 04:03:48 +03:00
|
|
|
settings()->beginGroup("RecentFiles");
|
2024-09-04 17:31:16 +03:00
|
|
|
settings()->setValue("filesCount", m_recentFiles.count());
|
2016-02-19 04:03:48 +03:00
|
|
|
QMap<QString, QDateTime>::const_iterator it = m_recentFiles.constBegin();
|
|
|
|
int count = 0;
|
|
|
|
while (it != m_recentFiles.constEnd()) {
|
2024-09-04 17:31:16 +03:00
|
|
|
settings()->setValue("fileName" + QString::number(count), it.key());
|
|
|
|
settings()->setValue("fileDate" + QString::number(count), it.value());
|
2016-02-19 04:03:48 +03:00
|
|
|
++count;
|
|
|
|
++it;
|
|
|
|
}
|
|
|
|
settings()->endGroup();
|
2019-02-12 22:28:16 +03:00
|
|
|
m_reportDesignWidget->saveState();
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
2016-02-19 04:03:48 +03:00
|
|
|
void ReportDesignWindow::createRecentFilesMenu()
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
if (m_recentFilesMenu) {
|
2016-02-19 04:03:48 +03:00
|
|
|
m_recentFilesMenu->clear();
|
2016-03-19 13:33:49 +03:00
|
|
|
removeNotExistedRecentFiles();
|
2024-09-04 17:31:16 +03:00
|
|
|
foreach (QString fileName, m_recentFiles.keys()) {
|
|
|
|
QAction* tmpAction = new QAction(QIcon(":/report/images/newReport"), fileName, this);
|
|
|
|
connect(tmpAction, SIGNAL(triggered()), m_recentFilesSignalMap, SLOT(map()));
|
|
|
|
m_recentFilesSignalMap->setMapping(tmpAction, fileName);
|
2016-02-19 04:03:48 +03:00
|
|
|
m_recentFilesMenu->addAction(tmpAction);
|
|
|
|
}
|
2016-03-19 13:33:49 +03:00
|
|
|
m_recentFilesMenu->setDisabled(m_recentFiles.isEmpty());
|
2016-02-19 04:03:48 +03:00
|
|
|
}
|
2016-03-19 13:33:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::removeNotExistedRecentFiles()
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
QMap<QString, QDateTime>::iterator it = m_recentFiles.begin();
|
|
|
|
while (it != m_recentFiles.end()) {
|
|
|
|
if (!QFile::exists(it.key())) {
|
2016-03-19 13:33:49 +03:00
|
|
|
it = m_recentFiles.erase(it);
|
|
|
|
} else {
|
|
|
|
++it;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::removeNotExistedRecentFilesFromMenu(const QString& fileName)
|
2016-03-19 13:33:49 +03:00
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
if (m_recentFilesMenu) {
|
|
|
|
foreach (QAction* action, m_recentFilesMenu->actions()) {
|
|
|
|
if (action->text().compare(fileName) == 0) {
|
2016-03-19 13:33:49 +03:00
|
|
|
m_recentFilesMenu->removeAction(action);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::addRecentFile(const QString& fileName)
|
2016-03-19 13:33:49 +03:00
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
if (!m_recentFiles.contains(fileName)) {
|
|
|
|
if (m_recentFiles.count() == 10) {
|
2016-03-19 13:33:49 +03:00
|
|
|
QMap<QString, QDateTime>::const_iterator it = m_recentFiles.constBegin();
|
|
|
|
QDateTime minDate = QDateTime::currentDateTime();
|
|
|
|
while (it != m_recentFiles.constEnd()) {
|
2024-09-04 17:31:16 +03:00
|
|
|
if (minDate > it.value())
|
|
|
|
minDate = it.value();
|
2016-03-19 13:33:49 +03:00
|
|
|
++it;
|
|
|
|
}
|
|
|
|
m_recentFiles.remove(m_recentFiles.key(minDate));
|
|
|
|
}
|
2024-09-04 17:31:16 +03:00
|
|
|
m_recentFiles.insert(fileName, QDateTime::currentDateTime());
|
2016-03-19 13:33:49 +03:00
|
|
|
} else {
|
|
|
|
m_recentFiles[fileName] = QDateTime::currentDateTime();
|
|
|
|
}
|
|
|
|
createRecentFilesMenu();
|
2016-02-19 04:03:48 +03:00
|
|
|
}
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
void ReportDesignWindow::restoreSetting()
|
|
|
|
{
|
|
|
|
settings()->beginGroup("DesignerWindow");
|
|
|
|
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-11-02 22:30:29 +03:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
2024-09-04 17:31:16 +03:00
|
|
|
QScreen* screen = QGuiApplication::primaryScreen();
|
2021-08-23 08:07:08 +03:00
|
|
|
|
|
|
|
int screenWidth = screen->geometry().width();
|
|
|
|
int screenHeight = screen->geometry().height();
|
2021-11-02 22:30:29 +03:00
|
|
|
#else
|
2024-09-04 17:31:16 +03:00
|
|
|
QDesktopWidget* desktop = QApplication::desktop();
|
2021-11-02 22:30:29 +03:00
|
|
|
|
|
|
|
int screenWidth = desktop->screenGeometry().width();
|
2024-09-04 17:31:16 +03:00
|
|
|
int screenHeight = desktop->screenGeometry().height();
|
2021-08-23 08:07:08 +03:00
|
|
|
#endif
|
2019-06-28 20:12:47 +03:00
|
|
|
int x = screenWidth * 0.1;
|
|
|
|
int y = screenHeight * 0.1;
|
2016-02-17 10:39:17 +03:00
|
|
|
|
2019-06-28 20:12:47 +03:00
|
|
|
resize(screenWidth * 0.8, screenHeight * 0.8);
|
2016-02-17 10:39:17 +03:00
|
|
|
move(x, y);
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
2017-04-07 21:01:51 +03:00
|
|
|
v = settings()->value("PageEditorsState");
|
2024-09-04 17:31:16 +03:00
|
|
|
if (v.isValid()) {
|
2017-09-20 22:25:50 +03:00
|
|
|
m_editorsStates[ReportDesignWidget::Page] = v.toByteArray();
|
2017-04-07 21:01:51 +03:00
|
|
|
m_editorTabType = ReportDesignWidget::Page;
|
|
|
|
}
|
|
|
|
v = settings()->value("DialogEditorsState");
|
2024-09-04 17:31:16 +03:00
|
|
|
if (v.isValid()) {
|
2017-09-20 22:25:50 +03:00
|
|
|
m_editorsStates[ReportDesignWidget::Dialog] = v.toByteArray();
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
2017-09-20 00:51:17 +03:00
|
|
|
v = settings()->value("ScriptEditorsState");
|
2024-09-04 17:31:16 +03:00
|
|
|
if (v.isValid()) {
|
2017-09-20 22:25:50 +03:00
|
|
|
m_editorsStates[ReportDesignWidget::Script] = v.toByteArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
v = settings()->value("TranslationEditorsState");
|
2024-09-04 17:31:16 +03:00
|
|
|
if (v.isValid()) {
|
2017-09-20 22:25:50 +03:00
|
|
|
m_editorsStates[ReportDesignWidget::Translations] = v.toByteArray();
|
2017-09-20 00:51:17 +03:00
|
|
|
}
|
2017-09-20 22:25:50 +03:00
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
v = settings()->value("InspectorFirsColumnWidth");
|
2024-09-04 17:31:16 +03:00
|
|
|
if (v.isValid()) {
|
|
|
|
m_objectInspector->setColumnWidth(0, v.toInt());
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
2016-02-19 04:03:48 +03:00
|
|
|
|
2019-06-28 13:08:33 +03:00
|
|
|
v = settings()->value("InspectorTranslateProperties");
|
2024-09-04 17:31:16 +03:00
|
|
|
if (v.isValid()) {
|
2019-06-28 13:08:33 +03:00
|
|
|
m_objectInspector->setTranslateProperties(v.toBool());
|
|
|
|
}
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
settings()->endGroup();
|
2016-02-19 04:03:48 +03:00
|
|
|
|
|
|
|
settings()->beginGroup("RecentFiles");
|
|
|
|
int filesCount = settings()->value("filesCount").toInt();
|
|
|
|
QStringList keys = settings()->childKeys();
|
2024-09-04 17:31:16 +03:00
|
|
|
for (int i = 0; i < filesCount; i++) {
|
|
|
|
if (keys.contains("fileName" + QString::number(i))) {
|
|
|
|
m_recentFiles[settings()->value("fileName" + QString::number(i)).toString()]
|
|
|
|
= settings()->value("fileData" + QString::number(i)).toDateTime();
|
2016-02-19 04:03:48 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
} else
|
|
|
|
break;
|
2016-02-19 04:03:48 +03:00
|
|
|
}
|
|
|
|
settings()->endGroup();
|
|
|
|
|
2019-01-29 23:18:24 +03:00
|
|
|
m_reportDesignWidget->loadState();
|
2016-02-18 21:11:59 +03:00
|
|
|
m_useGridAction->setChecked(m_reportDesignWidget->useGrid());
|
2016-02-19 04:03:48 +03:00
|
|
|
createRecentFilesMenu();
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ReportDesignWindow::checkNeedToSave()
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
if (m_reportDesignWidget->isNeedToSave()) {
|
2016-02-17 10:11:00 +03:00
|
|
|
QMessageBox::StandardButton button = QMessageBox::question(
|
2024-09-04 17:31:16 +03:00
|
|
|
this, "", tr("Report has been modified! Do you want save the report?"),
|
|
|
|
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Yes);
|
2016-02-17 10:11:00 +03:00
|
|
|
switch (button) {
|
|
|
|
case QMessageBox::Cancel:
|
|
|
|
break;
|
|
|
|
case QMessageBox::Yes:
|
2024-09-04 17:31:16 +03:00
|
|
|
if (!m_reportDesignWidget->save())
|
|
|
|
break;
|
2016-02-17 10:11:00 +03:00
|
|
|
default:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::showModal()
|
|
|
|
{
|
|
|
|
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
|
|
|
restoreSetting();
|
|
|
|
show();
|
|
|
|
m_eventLoop.exec();
|
2024-09-04 17:31:16 +03:00
|
|
|
if (deleteOnClose)
|
|
|
|
delete this;
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::showNonModal()
|
|
|
|
{
|
|
|
|
restoreSetting();
|
|
|
|
show();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::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
|
|
|
QSettings* ReportDesignWindow::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", QApplication::applicationName());
|
2016-02-17 10:11:00 +03:00
|
|
|
m_ownedSettings = true;
|
|
|
|
return m_settings;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::slotNewReport()
|
2024-09-04 17:31:16 +03:00
|
|
|
{
|
2016-06-10 18:05:18 +03:00
|
|
|
if (checkNeedToSave()) {
|
|
|
|
m_lblReportName->setText("");
|
|
|
|
startNewReport();
|
|
|
|
m_deletePageAction->setEnabled(false);
|
2018-08-27 17:44:33 +03:00
|
|
|
setWindowTitle("Lime Report Designer");
|
2016-06-10 18:05:18 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::slotNewPage()
|
|
|
|
{
|
|
|
|
if (m_reportDesignWidget) {
|
2016-06-10 18:05:18 +03:00
|
|
|
m_reportDesignWidget->addPage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::slotDeletePage()
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
if (m_reportDesignWidget && m_reportDesignWidget->report()->pageCount() > 1) {
|
2016-06-10 18:05:18 +03:00
|
|
|
m_reportDesignWidget->deleteCurrentPage();
|
|
|
|
}
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::slotNewTextItem()
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
if (m_newTextItemAction->isChecked()) {
|
|
|
|
m_newTextItemAction->setCheckable(false);
|
|
|
|
return;
|
|
|
|
}
|
2016-02-17 10:11:00 +03:00
|
|
|
if (m_reportDesignWidget) {
|
2017-10-02 16:37:38 +03:00
|
|
|
m_reportItemIsLocked = QApplication::keyboardModifiers() == Qt::SHIFT;
|
2016-02-17 10:11:00 +03:00
|
|
|
m_reportDesignWidget->startInsertMode("TextItem");
|
|
|
|
m_newTextItemAction->setCheckable(true);
|
|
|
|
m_newTextItemAction->setChecked(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::slotNewBand(const QString& bandType)
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
if (m_reportDesignWidget)
|
|
|
|
m_reportDesignWidget->addBand(bandType);
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::slotNewBand(int bandType)
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
if (m_reportDesignWidget)
|
|
|
|
m_reportDesignWidget->addBand(BandDesignIntf::BandsType(bandType));
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::slotItemSelected(LimeReport::BaseDesignIntf* item)
|
2016-02-17 10:11:00 +03:00
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
if (m_objectInspector->object() != item) {
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
m_newSubDetail->setEnabled(false);
|
|
|
|
m_newSubDetailHeader->setEnabled(false);
|
|
|
|
m_newSubDetailFooter->setEnabled(false);
|
|
|
|
m_newGroupHeader->setEnabled(false);
|
|
|
|
m_newGroupFooter->setEnabled(false);
|
2016-02-17 10:18:19 +03:00
|
|
|
m_newDataHeader->setEnabled(false);
|
|
|
|
m_newDataFooter->setEnabled(false);
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
m_objectInspector->commitActiveEditorData();
|
2019-02-14 20:50:01 +03:00
|
|
|
m_objectInspector->setObject(item);
|
2016-10-19 01:26:40 +03:00
|
|
|
|
2019-02-14 20:50:01 +03:00
|
|
|
if (m_objectInspector->subclassesAsLevel())
|
2024-09-04 17:31:16 +03:00
|
|
|
m_objectInspector->expandToDepth(0);
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
QSet<BandDesignIntf::BandsType> bs;
|
2024-09-04 17:31:16 +03:00
|
|
|
bs << BandDesignIntf::Data << BandDesignIntf::SubDetailBand;
|
2016-02-17 10:11:00 +03:00
|
|
|
BandDesignIntf* band = dynamic_cast<BandDesignIntf*>(item);
|
2024-09-04 17:31:16 +03:00
|
|
|
if (band) {
|
|
|
|
if (bs.contains(band->bandType())) {
|
2016-02-17 10:11:00 +03:00
|
|
|
m_newSubDetail->setEnabled(true);
|
|
|
|
}
|
2024-09-04 17:31:16 +03:00
|
|
|
if ((band->bandType() == BandDesignIntf::Data)
|
|
|
|
|| (band->bandType() == BandDesignIntf::SubDetailBand)) {
|
2016-02-17 10:11:00 +03:00
|
|
|
m_newGroupHeader->setEnabled(true);
|
|
|
|
}
|
2024-09-04 17:31:16 +03:00
|
|
|
if (band->bandType() == BandDesignIntf::GroupHeader) {
|
2016-02-17 10:11:00 +03:00
|
|
|
m_newGroupFooter->setEnabled(!band->isConnectedToBand(BandDesignIntf::GroupFooter));
|
2016-02-17 10:18:19 +03:00
|
|
|
m_newGroupHeader->setEnabled(!band->isConnectedToBand(BandDesignIntf::GroupHeader));
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
2024-09-04 17:31:16 +03:00
|
|
|
if (band->bandType() == BandDesignIntf::SubDetailBand) {
|
|
|
|
m_newSubDetailHeader->setEnabled(
|
|
|
|
!band->isConnectedToBand(BandDesignIntf::SubDetailHeader));
|
|
|
|
m_newSubDetailFooter->setEnabled(
|
|
|
|
!band->isConnectedToBand(BandDesignIntf::SubDetailFooter));
|
2016-02-17 10:18:19 +03:00
|
|
|
}
|
2024-09-04 17:31:16 +03:00
|
|
|
if (band->bandType() == BandDesignIntf::Data) {
|
2016-02-17 10:18:19 +03:00
|
|
|
m_newDataHeader->setEnabled(!band->isConnectedToBand(BandDesignIntf::DataHeader));
|
|
|
|
m_newDataFooter->setEnabled(!band->isConnectedToBand(BandDesignIntf::DataFooter));
|
|
|
|
m_newGroupHeader->setEnabled(!band->isConnectedToBand(BandDesignIntf::GroupHeader));
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_fontEditorBar->setItem(item);
|
|
|
|
m_textAlignmentEditorBar->setItem(item);
|
|
|
|
m_itemsBordersEditorBar->setItem(item);
|
2024-09-04 17:31:16 +03:00
|
|
|
} else {
|
|
|
|
m_objectInspector->clearObjectsList();
|
|
|
|
}
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::slotItemPropertyChanged(const QString& objectName,
|
|
|
|
const QString& propertyName,
|
|
|
|
const QVariant& oldValue, const QVariant& newValue)
|
2016-02-17 10:11:00 +03:00
|
|
|
{
|
|
|
|
Q_UNUSED(oldValue)
|
|
|
|
Q_UNUSED(newValue)
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
if (m_objectInspector->object() && (m_objectInspector->object()->objectName() == objectName)) {
|
2019-02-14 20:50:01 +03:00
|
|
|
m_objectInspector->updateProperty(propertyName);
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::slotMultiItemSelected()
|
|
|
|
{
|
|
|
|
m_objectInspector->commitActiveEditorData();
|
|
|
|
|
|
|
|
QList<QObject*> selectionList;
|
|
|
|
foreach (QGraphicsItem* gi, m_reportDesignWidget->activePage()->selectedItems()) {
|
|
|
|
QObject* oi = dynamic_cast<QObject*>(gi);
|
2024-09-04 17:31:16 +03:00
|
|
|
if (oi)
|
|
|
|
selectionList.append(oi);
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
2019-02-14 20:50:01 +03:00
|
|
|
m_objectInspector->setMultiObjects(&selectionList);
|
|
|
|
if (m_objectInspector->subclassesAsLevel())
|
2024-09-04 17:31:16 +03:00
|
|
|
m_objectInspector->expandToDepth(0);
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::slotInsertModeStarted() { m_editModeAction->setChecked(false); }
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::slotItemInserted(PageDesignIntf*, QPointF, const QString& ItemType)
|
2016-02-17 10:11:00 +03:00
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
if (!m_reportItemIsLocked) {
|
2017-10-02 16:37:38 +03:00
|
|
|
m_editModeAction->setChecked(true);
|
|
|
|
if (m_actionMap.value(ItemType))
|
|
|
|
m_actionMap.value(ItemType)->setCheckable(false);
|
|
|
|
} else {
|
|
|
|
m_reportDesignWidget->startInsertMode(ItemType);
|
|
|
|
}
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::slotItemInsertCanceled(const QString& ItemType)
|
2016-02-17 10:11:00 +03:00
|
|
|
{
|
|
|
|
m_editModeAction->setChecked(true);
|
2017-10-02 16:37:38 +03:00
|
|
|
m_reportItemIsLocked = false;
|
2016-02-17 10:11:00 +03:00
|
|
|
if (m_actionMap.value(ItemType))
|
|
|
|
m_actionMap.value(ItemType)->setCheckable(false);
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::slotUpdateDataBrowser(const QString& collectionName)
|
2016-02-17 10:11:00 +03:00
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
if (collectionName.compare("connections", Qt::CaseInsensitive) == 0) {
|
|
|
|
if (m_dataBrowser)
|
|
|
|
m_dataBrowser->initConnections();
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
2024-09-04 17:31:16 +03:00
|
|
|
if (collectionName.compare("queries", Qt::CaseInsensitive) == 0) {
|
|
|
|
if (m_dataBrowser)
|
|
|
|
m_dataBrowser->updateDataTree();
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
2024-09-04 17:31:16 +03:00
|
|
|
if (collectionName.compare("subqueries", Qt::CaseInsensitive) == 0) {
|
|
|
|
if (m_dataBrowser)
|
|
|
|
m_dataBrowser->updateDataTree();
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
2024-09-04 17:31:16 +03:00
|
|
|
if (collectionName.compare("subproxies", Qt::CaseInsensitive) == 0) {
|
|
|
|
if (m_dataBrowser)
|
|
|
|
m_dataBrowser->updateDataTree();
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
2024-09-04 17:31:16 +03:00
|
|
|
if (collectionName.compare("variables", Qt::CaseInsensitive) == 0) {
|
|
|
|
if (m_dataBrowser)
|
|
|
|
m_dataBrowser->updateVariablesTree();
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::slotCommandHistoryChanged() { updateRedoUndo(); }
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
void ReportDesignWindow::slotSaveReport()
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
if (m_reportDesignWidget->emitSaveReport())
|
|
|
|
return; // report save as'd via signal
|
2018-05-23 19:01:30 +03:00
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
m_reportDesignWidget->save();
|
2018-05-23 19:01:30 +03:00
|
|
|
|
|
|
|
QString filename = m_reportDesignWidget->reportFileName();
|
|
|
|
m_lblReportName->setText(filename);
|
2024-09-04 17:31:16 +03:00
|
|
|
if (!filename.isEmpty())
|
|
|
|
addRecentFile(filename);
|
2020-07-29 04:09:45 +03:00
|
|
|
setWindowTitle(m_reportDesignWidget->report()->reportName() + " - Lime Report Designer");
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::slotSaveReportAs()
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
if (m_reportDesignWidget->emitSaveReportAs())
|
|
|
|
return; // report save as'd via signal
|
2018-05-23 19:01:30 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
QString fileName = QFileDialog::getSaveFileName(this, tr("Report file name"), "",
|
|
|
|
"Report files(*.lrxml);; All files(*)");
|
|
|
|
if (!fileName.isEmpty()) {
|
2016-02-17 10:11:00 +03:00
|
|
|
m_reportDesignWidget->saveToFile(fileName);
|
|
|
|
m_lblReportName->setText(m_reportDesignWidget->reportFileName());
|
2016-03-19 13:33:49 +03:00
|
|
|
addRecentFile(fileName);
|
2020-07-29 04:09:45 +03:00
|
|
|
setWindowTitle(m_reportDesignWidget->report()->reportName() + " - Lime Report Designer");
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::slotLoadReport()
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
if (!checkNeedToSave())
|
|
|
|
return;
|
2018-05-23 19:01:30 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
if (m_reportDesignWidget->emitLoadReport())
|
|
|
|
return;
|
2018-05-23 19:01:30 +03:00
|
|
|
|
|
|
|
QString fileName = QFileDialog::getOpenFileName(
|
2024-09-04 17:31:16 +03:00
|
|
|
this, tr("Report file name"), m_reportDesignWidget->report()->currentReportsDir(),
|
|
|
|
"Report files(*.lrxml);; All files(*)");
|
2018-05-23 19:01:30 +03:00
|
|
|
if (!fileName.isEmpty()) {
|
|
|
|
QApplication::processEvents();
|
|
|
|
setCursor(Qt::WaitCursor);
|
|
|
|
m_reportDesignWidget->clear();
|
2024-09-04 17:31:16 +03:00
|
|
|
if (m_reportDesignWidget->loadFromFile(fileName)) {
|
2018-05-23 19:01:30 +03:00
|
|
|
m_lblReportName->setText(fileName);
|
2019-02-14 20:50:01 +03:00
|
|
|
m_objectInspector->setObject(0);
|
2018-05-23 19:01:30 +03:00
|
|
|
updateRedoUndo();
|
2024-09-04 17:31:16 +03:00
|
|
|
setWindowTitle(m_reportDesignWidget->report()->reportName()
|
|
|
|
+ " - Lime Report Designer");
|
|
|
|
if (!m_recentFiles.contains(fileName)) {
|
|
|
|
if (m_recentFiles.count() == 10) {
|
2018-05-23 19:01:30 +03:00
|
|
|
QMap<QString, QDateTime>::const_iterator it = m_recentFiles.constBegin();
|
|
|
|
QDateTime minDate = QDateTime::currentDateTime();
|
|
|
|
while (it != m_recentFiles.constEnd()) {
|
2024-09-04 17:31:16 +03:00
|
|
|
if (minDate > it.value())
|
|
|
|
minDate = it.value();
|
2018-05-23 19:01:30 +03:00
|
|
|
++it;
|
|
|
|
}
|
|
|
|
m_recentFiles.remove(m_recentFiles.key(minDate));
|
|
|
|
}
|
2024-09-04 17:31:16 +03:00
|
|
|
m_recentFiles.insert(fileName, QDateTime::currentDateTime());
|
2018-05-23 19:01:30 +03:00
|
|
|
} else {
|
|
|
|
m_recentFiles[fileName] = QDateTime::currentDateTime();
|
2016-02-17 10:39:17 +03:00
|
|
|
}
|
2018-05-23 19:01:30 +03:00
|
|
|
createRecentFilesMenu();
|
2024-09-04 17:31:16 +03:00
|
|
|
m_deletePageAction->setEnabled(m_reportDesignWidget->report()->pageCount() > 1);
|
2018-05-23 19:01:30 +03:00
|
|
|
} else {
|
|
|
|
slotNewReport();
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
2018-05-23 19:01:30 +03:00
|
|
|
unsetCursor();
|
|
|
|
setWindowTitle(m_reportDesignWidget->report()->reportName() + " - Lime Report Designer");
|
|
|
|
addRecentFile(fileName);
|
|
|
|
m_editorTabType = ReportDesignWidget::Page;
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::slotZoomIn() { m_reportDesignWidget->scale(1.2, 1.2); }
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::slotZoomOut() { m_reportDesignWidget->scale(1 / 1.2, 1 / 1.2); }
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
void ReportDesignWindow::slotEditMode()
|
|
|
|
{
|
|
|
|
m_editModeAction->setChecked(true);
|
|
|
|
m_reportDesignWidget->startEditMode();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::slotUndo()
|
|
|
|
{
|
|
|
|
m_reportDesignWidget->undo();
|
|
|
|
updateRedoUndo();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::slotRedo()
|
|
|
|
{
|
|
|
|
m_reportDesignWidget->redo();
|
|
|
|
updateRedoUndo();
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::slotCopy() { m_reportDesignWidget->copy(); }
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::slotPaste() { m_reportDesignWidget->paste(); }
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::slotCut() { m_reportDesignWidget->cut(); }
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::slotDelete() { m_reportDesignWidget->deleteSelectedItems(); }
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
void ReportDesignWindow::slotEditLayoutMode()
|
|
|
|
{
|
|
|
|
m_reportDesignWidget->editLayoutMode(m_editLayoutMode->isChecked());
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::slotHLayout() { m_reportDesignWidget->addHLayout(); }
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::slotVLayout() { m_reportDesignWidget->addVLayout(); }
|
2018-06-21 14:29:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::slotTest() { }
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
void ReportDesignWindow::slotPrintReport()
|
|
|
|
{
|
|
|
|
setCursor(Qt::WaitCursor);
|
2016-06-10 18:05:18 +03:00
|
|
|
m_reportDesignWidget->printReport();
|
2016-02-17 10:11:00 +03:00
|
|
|
setCursor(Qt::ArrowCursor);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::slotPreviewReport()
|
|
|
|
{
|
2020-02-03 21:50:28 +03:00
|
|
|
m_previewReportAction->setDisabled(true);
|
2016-06-10 18:05:18 +03:00
|
|
|
m_reportDesignWidget->previewReport();
|
2020-02-03 21:50:28 +03:00
|
|
|
m_previewReportAction->setDisabled(false);
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::slotItemActionCliked()
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
QAction* action = dynamic_cast<QAction*>(sender());
|
2016-02-17 10:11:00 +03:00
|
|
|
action->setCheckable(true);
|
|
|
|
action->setChecked(true);
|
2017-10-02 16:37:38 +03:00
|
|
|
m_reportItemIsLocked = QApplication::keyboardModifiers() == Qt::SHIFT;
|
2016-02-17 10:11:00 +03:00
|
|
|
m_reportDesignWidget->startInsertMode(action->whatsThis());
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::slotBandAdded(PageDesignIntf*, BandDesignIntf* band)
|
2016-02-17 10:11:00 +03:00
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
if (band->isUnique()) {
|
2016-02-17 10:11:00 +03:00
|
|
|
switch (band->bandType()) {
|
|
|
|
case BandDesignIntf::PageHeader:
|
|
|
|
m_newPageHeader->setDisabled(true);
|
|
|
|
break;
|
|
|
|
case BandDesignIntf::PageFooter:
|
|
|
|
m_newPageFooter->setDisabled(true);
|
|
|
|
break;
|
|
|
|
case BandDesignIntf::ReportHeader:
|
|
|
|
m_newReportHeader->setDisabled(true);
|
|
|
|
break;
|
|
|
|
case BandDesignIntf::ReportFooter:
|
|
|
|
m_newReportFooter->setDisabled(true);
|
2017-06-29 02:32:42 +03:00
|
|
|
break;
|
2016-10-04 03:21:22 +03:00
|
|
|
case BandDesignIntf::TearOffBand:
|
|
|
|
m_newTearOffBand->setDisabled(true);
|
2017-06-29 02:32:42 +03:00
|
|
|
break;
|
2016-02-17 10:11:00 +03:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::slotBandDeleted(PageDesignIntf*, BandDesignIntf* band)
|
2016-02-17 10:11:00 +03:00
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
if (band->isUnique()) {
|
2016-02-17 10:11:00 +03:00
|
|
|
switch (band->bandType()) {
|
|
|
|
case BandDesignIntf::PageHeader:
|
|
|
|
m_newPageHeader->setEnabled(true);
|
|
|
|
break;
|
|
|
|
case BandDesignIntf::PageFooter:
|
|
|
|
m_newPageFooter->setEnabled(true);
|
|
|
|
break;
|
|
|
|
case BandDesignIntf::ReportHeader:
|
|
|
|
m_newReportHeader->setEnabled(true);
|
|
|
|
break;
|
|
|
|
case BandDesignIntf::ReportFooter:
|
|
|
|
m_newReportFooter->setEnabled(true);
|
2016-10-04 03:21:22 +03:00
|
|
|
case BandDesignIntf::TearOffBand:
|
|
|
|
m_newTearOffBand->setEnabled(true);
|
2016-02-17 10:11:00 +03:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::updateAvaibleBands()
|
|
|
|
{
|
2016-09-16 01:59:56 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
if (!m_reportDesignWidget || !m_reportDesignWidget->activePage())
|
|
|
|
return;
|
2016-09-16 01:59:56 +03:00
|
|
|
m_newPageHeader->setEnabled(true);
|
|
|
|
m_newPageFooter->setEnabled(true);
|
|
|
|
m_newReportHeader->setEnabled(true);
|
|
|
|
m_newReportFooter->setEnabled(true);
|
2016-10-04 03:55:02 +03:00
|
|
|
m_newTearOffBand->setEnabled(true);
|
2016-09-16 01:59:56 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
foreach (BandDesignIntf* band, m_reportDesignWidget->activePage()->pageItem()->bands()) {
|
2016-09-16 01:59:56 +03:00
|
|
|
switch (band->bandType()) {
|
|
|
|
case BandDesignIntf::PageHeader:
|
|
|
|
m_newPageHeader->setEnabled(false);
|
|
|
|
break;
|
|
|
|
case BandDesignIntf::PageFooter:
|
|
|
|
m_newPageFooter->setEnabled(false);
|
|
|
|
break;
|
|
|
|
case BandDesignIntf::ReportHeader:
|
|
|
|
m_newReportHeader->setEnabled(false);
|
|
|
|
break;
|
|
|
|
case BandDesignIntf::ReportFooter:
|
|
|
|
m_newReportFooter->setEnabled(false);
|
2016-10-04 03:55:02 +03:00
|
|
|
case BandDesignIntf::TearOffBand:
|
|
|
|
m_newTearOffBand->setEnabled(false);
|
2016-09-16 01:59:56 +03:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::showDefaultToolBars()
|
|
|
|
{
|
|
|
|
foreach (QToolBar* tb, m_pageTools) {
|
2017-04-11 11:23:34 +03:00
|
|
|
tb->setVisible(m_editorTabType != ReportDesignWidget::Dialog);
|
|
|
|
}
|
2024-09-04 17:31:16 +03:00
|
|
|
foreach (QToolBar* tb, m_dialogTools) {
|
2017-04-11 11:23:34 +03:00
|
|
|
tb->setVisible(m_editorTabType == ReportDesignWidget::Dialog);
|
|
|
|
}
|
|
|
|
}
|
2017-04-07 21:01:51 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::showDefaultEditors()
|
|
|
|
{
|
2017-04-07 21:01:51 +03:00
|
|
|
foreach (QDockWidget* w, m_pageEditors) {
|
|
|
|
w->setVisible(m_editorTabType != ReportDesignWidget::Dialog);
|
|
|
|
}
|
2017-04-18 20:00:59 +03:00
|
|
|
#ifdef HAVE_QTDESIGNER_INTEGRATION
|
2017-04-07 21:01:51 +03:00
|
|
|
foreach (QDockWidget* w, m_dialogEditors) {
|
|
|
|
w->setVisible(m_editorTabType == ReportDesignWidget::Dialog);
|
|
|
|
}
|
2024-09-04 17:31:16 +03:00
|
|
|
for (int i = 0; i < m_docksToTabify.size() - 1; ++i) {
|
|
|
|
tabifyDockWidget(m_docksToTabify.at(i), m_docksToTabify.at(i + 1));
|
2017-04-18 20:00:59 +03:00
|
|
|
}
|
|
|
|
m_docksToTabify.at(0)->raise();
|
|
|
|
#endif
|
2017-04-07 21:01:51 +03:00
|
|
|
}
|
|
|
|
|
2016-06-10 18:05:18 +03:00
|
|
|
void ReportDesignWindow::slotActivePageChanged()
|
|
|
|
{
|
2019-02-14 20:50:01 +03:00
|
|
|
m_objectInspector->setObject(0);
|
2016-06-10 18:05:18 +03:00
|
|
|
updateRedoUndo();
|
2016-09-16 01:59:56 +03:00
|
|
|
updateAvaibleBands();
|
2017-04-07 21:01:51 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
if (m_editorTabType == ReportDesignWidget::Dialog) {
|
2017-04-20 23:34:32 +03:00
|
|
|
#ifdef HAVE_UI_LOADER
|
2017-09-20 22:25:50 +03:00
|
|
|
m_scriptBrowser->updateDialogsTree();
|
2017-04-20 23:34:32 +03:00
|
|
|
#endif
|
2017-04-07 21:01:51 +03:00
|
|
|
}
|
|
|
|
|
2018-01-24 20:59:53 +03:00
|
|
|
setDocWidgetsVisibility(true);
|
|
|
|
|
2017-09-20 22:25:50 +03:00
|
|
|
m_editorsStates[m_editorTabType] = saveState();
|
2017-04-07 21:01:51 +03:00
|
|
|
m_editorTabType = m_reportDesignWidget->activeTabType();
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
if (!m_editorsStates[m_editorTabType].isEmpty()) {
|
2017-09-20 22:25:50 +03:00
|
|
|
restoreState(m_editorsStates[m_editorTabType]);
|
|
|
|
} else {
|
|
|
|
showDefaultEditors();
|
|
|
|
showDefaultToolBars();
|
2017-04-07 21:01:51 +03:00
|
|
|
}
|
|
|
|
|
2018-01-24 20:59:53 +03:00
|
|
|
setDocWidgetsVisibility(false);
|
2016-06-10 18:05:18 +03:00
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::renderStarted() { m_progressWidget->setVisible(true); }
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
void ReportDesignWindow::renderPageFinished(int renderedPageCount)
|
|
|
|
{
|
2019-10-16 02:08:45 +03:00
|
|
|
m_progressLabel->setText(tr("Rendered %1 pages").arg(renderedPageCount));
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::renderFinished() { m_progressWidget->setVisible(false); }
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
void ReportDesignWindow::slotShowAbout()
|
|
|
|
{
|
|
|
|
AboutDialog* about = new AboutDialog(this);
|
|
|
|
about->exec();
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
bool ReportDesignWindow::isDockAreaVisible(Qt::DockWidgetArea area)
|
|
|
|
{
|
|
|
|
QList<QDockWidget*> dockWidgets = findChildren<QDockWidget*>();
|
|
|
|
foreach (QDockWidget* dw, dockWidgets) {
|
2016-02-17 10:19:50 +03:00
|
|
|
if ((dockWidgetArea(dw) == area) && !dw->isHidden())
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::hideDockWidgets(Qt::DockWidgetArea area, bool value)
|
|
|
|
{
|
|
|
|
QList<QDockWidget*> dockWidgets = findChildren<QDockWidget*>();
|
2018-01-24 20:59:53 +03:00
|
|
|
QMap<QDockWidget*, bool>* currentDocState = 0;
|
|
|
|
|
|
|
|
switch (area) {
|
|
|
|
case Qt::LeftDockWidgetArea:
|
|
|
|
if (value)
|
|
|
|
m_leftDocVisibleState.clear();
|
|
|
|
currentDocState = &m_leftDocVisibleState;
|
|
|
|
break;
|
|
|
|
case Qt::RightDockWidgetArea:
|
|
|
|
if (value)
|
|
|
|
m_rightDocVisibleState.clear();
|
|
|
|
currentDocState = &m_rightDocVisibleState;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-02-17 10:28:27 +03:00
|
|
|
foreach (QDockWidget* dw, dockWidgets) {
|
2024-09-04 17:31:16 +03:00
|
|
|
if (dockWidgetArea(dw) == area) {
|
|
|
|
if (!value) {
|
|
|
|
if (currentDocState->value(dw))
|
|
|
|
dw->show();
|
2018-01-24 20:59:53 +03:00
|
|
|
} else {
|
|
|
|
currentDocState->insert(dw, dw->isVisible());
|
|
|
|
dw->hide();
|
|
|
|
}
|
|
|
|
}
|
2016-02-17 10:28:27 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-17 10:19:50 +03:00
|
|
|
void ReportDesignWindow::slotHideLeftPanel(bool value)
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
hideDockWidgets(Qt::LeftDockWidgetArea, !value);
|
2016-02-17 10:19:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::slotHideRightPanel(bool value)
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
hideDockWidgets(Qt::RightDockWidgetArea, !value);
|
2016-02-17 10:19:50 +03:00
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::slotEditSettings() { m_reportDesignWidget->editSetting(); }
|
2016-02-18 21:11:59 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::slotUseGrid(bool value) { m_reportDesignWidget->setUseGrid(value); }
|
2016-02-18 21:11:59 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::slotUseMagnet(bool value) { m_reportDesignWidget->setUseMagnet(value); }
|
2016-02-21 01:08:54 +03:00
|
|
|
|
2016-02-19 04:03:48 +03:00
|
|
|
void ReportDesignWindow::slotLoadRecentFile(const QString fileName)
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
if (checkNeedToSave()) {
|
2016-02-19 04:03:48 +03:00
|
|
|
QApplication::processEvents();
|
2024-09-04 17:31:16 +03:00
|
|
|
if (QFile::exists(fileName)) {
|
2016-03-19 13:33:49 +03:00
|
|
|
setCursor(Qt::WaitCursor);
|
|
|
|
m_reportDesignWidget->clear();
|
|
|
|
m_reportDesignWidget->loadFromFile(fileName);
|
|
|
|
m_lblReportName->setText(fileName);
|
2019-02-14 20:50:01 +03:00
|
|
|
m_objectInspector->setObject(0);
|
2016-03-19 13:33:49 +03:00
|
|
|
updateRedoUndo();
|
|
|
|
unsetCursor();
|
2024-09-04 17:31:16 +03:00
|
|
|
setWindowTitle(m_reportDesignWidget->report()->reportName()
|
|
|
|
+ " - Lime Report Designer");
|
2016-03-19 13:33:49 +03:00
|
|
|
m_recentFiles[fileName] = QDateTime::currentDateTime();
|
|
|
|
} else {
|
|
|
|
m_recentFiles.remove(fileName);
|
|
|
|
removeNotExistedRecentFilesFromMenu(fileName);
|
2024-09-04 17:31:16 +03:00
|
|
|
QMessageBox::information(this, tr("Warning"),
|
|
|
|
tr("File \"%1\" not found!").arg(fileName));
|
2016-03-19 13:33:49 +03:00
|
|
|
}
|
2016-02-19 04:03:48 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::slotPageAdded(PageDesignIntf*)
|
2016-06-10 18:05:18 +03:00
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
m_deletePageAction->setEnabled(m_reportDesignWidget->report()->pageCount() > 1);
|
2016-06-10 18:05:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::slotPageDeleted()
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
m_deletePageAction->setEnabled(m_reportDesignWidget->report()->pageCount() > 1);
|
2016-06-10 18:05:18 +03:00
|
|
|
}
|
|
|
|
|
2019-02-14 00:21:57 +03:00
|
|
|
void ReportDesignWindow::slotFilterTextChanged(const QString& filter)
|
|
|
|
{
|
2021-12-16 00:13:39 +03:00
|
|
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
|
2019-02-14 00:21:57 +03:00
|
|
|
m_filterModel->setFilterRegExp(QRegExp(filter, Qt::CaseInsensitive, QRegExp::FixedString));
|
2021-08-24 08:37:40 +03:00
|
|
|
#else
|
2024-09-04 17:31:16 +03:00
|
|
|
m_filterModel->setFilterRegularExpression(
|
|
|
|
QRegularExpression(filter, QRegularExpression::CaseInsensitiveOption));
|
2021-08-24 08:37:40 +03:00
|
|
|
#endif
|
2019-02-14 00:21:57 +03:00
|
|
|
}
|
|
|
|
|
2017-04-14 02:43:34 +03:00
|
|
|
#ifdef HAVE_QTDESIGNER_INTEGRATION
|
|
|
|
void ReportDesignWindow::slotDeleteDialog()
|
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
if (m_editorTabType == ReportDesignWidget::Dialog) {
|
|
|
|
m_reportDesignWidget->report()->scriptContext()->deleteDialog(
|
|
|
|
m_reportDesignWidget->activeDialogName());
|
2017-04-14 02:43:34 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::slotAddNewDialog() { m_reportDesignWidget->addNewDialog(); }
|
2019-06-28 20:12:47 +03:00
|
|
|
|
2017-04-14 02:43:34 +03:00
|
|
|
#endif
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::slotLockSelectedItems() { m_reportDesignWidget->lockSelectedItems(); }
|
2019-06-28 20:12:47 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::slotUnlockSelectedItems() { m_reportDesignWidget->unlockSelectedItems(); }
|
2019-06-28 20:12:47 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::slotSelectOneLevelItems() { m_reportDesignWidget->selectOneLevelItems(); }
|
2019-06-28 20:12:47 +03:00
|
|
|
|
2019-10-16 02:08:45 +03:00
|
|
|
void ReportDesignWindow::slotCancelRendering(bool)
|
|
|
|
{
|
|
|
|
m_reportDesignWidget->report()->cancelRender();
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
void ReportDesignWindow::closeEvent(QCloseEvent* event)
|
2016-02-17 10:11:00 +03:00
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
if (m_progressWidget->isVisible()) {
|
2019-10-16 02:08:45 +03:00
|
|
|
QMessageBox::critical(this, tr("Attention"), tr("The rendering is in process"));
|
|
|
|
event->ignore();
|
|
|
|
return;
|
|
|
|
}
|
2024-09-04 17:31:16 +03:00
|
|
|
if (checkNeedToSave()) {
|
2016-02-17 10:11:00 +03:00
|
|
|
m_dataBrowser->closeAllDataWindows();
|
|
|
|
writeState();
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
writePosition();
|
|
|
|
#endif
|
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
writePosition();
|
|
|
|
#endif
|
|
|
|
m_eventLoop.exit();
|
|
|
|
event->accept();
|
2024-09-04 17:31:16 +03:00
|
|
|
} else
|
|
|
|
event->ignore();
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ReportDesignWindow::resizeEvent(QResizeEvent*)
|
|
|
|
{
|
|
|
|
#ifdef Q_OS_UNIX
|
|
|
|
writePosition();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-09-20 22:25:50 +03:00
|
|
|
void ReportDesignWindow::showEvent(QShowEvent* event)
|
|
|
|
{
|
|
|
|
QMainWindow::showEvent(event);
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
if (!m_editorsStates[m_editorTabType].isEmpty()) {
|
2017-09-20 22:25:50 +03:00
|
|
|
restoreState(m_editorsStates[m_editorTabType]);
|
|
|
|
} else {
|
|
|
|
showDefaultEditors();
|
|
|
|
showDefaultToolBars();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
void ReportDesignWindow::moveEvent(QMoveEvent*)
|
|
|
|
{
|
|
|
|
#ifdef Q_OS_UNIX
|
|
|
|
writePosition();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
bool ObjectNameValidator::validate(const QString& propName, const QVariant& propValue,
|
|
|
|
QObject* object, QString& msg)
|
2016-02-17 10:11:00 +03:00
|
|
|
{
|
2024-09-04 17:31:16 +03:00
|
|
|
if (propName.compare("objectName") == 0) {
|
2016-02-17 10:11:00 +03:00
|
|
|
BaseDesignIntf* bd = dynamic_cast<BaseDesignIntf*>(object);
|
2024-09-04 17:31:16 +03:00
|
|
|
if (bd) {
|
|
|
|
if (bd->page()->reportItemByName(propValue.toString())) {
|
|
|
|
msg = QString(
|
|
|
|
QObject::tr("Object with name %1 already exists!").arg(propValue.toString()));
|
2016-02-17 10:11:00 +03:00
|
|
|
return false;
|
2024-09-04 17:31:16 +03:00
|
|
|
} else
|
|
|
|
(bd->emitObjectNamePropertyChanged(object->objectName(), propValue.toString()));
|
2016-02-17 10:11:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
} // namespace LimeReport
|