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. *
|
|
|
|
****************************************************************************/
|
2017-09-27 13:04:56 +03:00
|
|
|
#ifndef LRGLOBAL_H
|
|
|
|
#define LRGLOBAL_H
|
2016-02-17 10:11:00 +03:00
|
|
|
#include "qglobal.h"
|
2024-09-04 17:31:16 +03:00
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
#include <QString>
|
2016-07-07 23:48:03 +03:00
|
|
|
#include <QStyleOptionViewItem>
|
2020-03-03 05:19:59 +03:00
|
|
|
#include <QtGlobal>
|
2016-02-17 10:11:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
#include <stdexcept>
|
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
#if defined(LIMEREPORT_EXPORTS)
|
2024-09-04 17:31:16 +03:00
|
|
|
#define LIMEREPORT_EXPORT Q_DECL_EXPORT
|
|
|
|
#elif defined(LIMEREPORT_IMPORTS)
|
|
|
|
#define LIMEREPORT_EXPORT Q_DECL_IMPORT
|
2016-02-17 10:11:00 +03:00
|
|
|
#else
|
2024-09-04 17:31:16 +03:00
|
|
|
#define LIMEREPORT_EXPORT /**/
|
2016-02-17 10:11:00 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace LimeReport {
|
2016-02-17 10:19:50 +03:00
|
|
|
|
2016-10-18 15:00:26 +03:00
|
|
|
#ifdef __GNUC__
|
2024-09-04 17:31:16 +03:00
|
|
|
#define VARIABLE_IS_NOT_USED __attribute__((unused))
|
2016-10-18 15:00:26 +03:00
|
|
|
#else
|
|
|
|
#define VARIABLE_IS_NOT_USED
|
|
|
|
#endif
|
|
|
|
|
2021-08-24 10:22:30 +03:00
|
|
|
#if QT_VERSION >= 0x050800
|
2020-04-17 12:28:59 +03:00
|
|
|
Q_NAMESPACE
|
|
|
|
#endif
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
namespace Const {
|
2019-10-12 22:31:35 +03:00
|
|
|
int const DEFAULT_GRID_STEP = 1;
|
2019-02-25 16:22:10 +03:00
|
|
|
int const RESIZE_HANDLE_SIZE = 5;
|
|
|
|
int const SELECTION_PEN_SIZE = 1;
|
2024-09-04 17:31:16 +03:00
|
|
|
int const MINIMUM_ITEM_WIDTH = 2 * RESIZE_HANDLE_SIZE;
|
|
|
|
int const MINIMUM_ITEM_HEIGHT = 2 * RESIZE_HANDLE_SIZE;
|
2016-02-17 10:19:50 +03:00
|
|
|
double const RESIZE_ZONE_OPACITY = 0.5;
|
|
|
|
double const SELECTED_RESIZE_ZONE_OPACITY = 0.6;
|
|
|
|
Qt::GlobalColor const RESIZE_ZONE_COLOR = Qt::green;
|
|
|
|
Qt::GlobalColor const SELECTION_COLOR = Qt::red;
|
2016-02-21 01:08:54 +03:00
|
|
|
Qt::GlobalColor const JOIN_COLOR = Qt::blue;
|
2016-02-17 10:39:17 +03:00
|
|
|
double const SELECTION_COLOR_OPACITY = 0.6;
|
2016-02-17 10:11:00 +03:00
|
|
|
const qreal fontFACTOR = 3.5;
|
|
|
|
const int mmFACTOR = 10;
|
|
|
|
const int itemPaleteIconSize = 24;
|
|
|
|
const qreal minSpaceBorder = 10;
|
|
|
|
const QString bandTAG = "band";
|
2016-02-17 10:19:50 +03:00
|
|
|
const Qt::GlobalColor BAND_NAME_LABEL_COLOR = Qt::yellow;
|
|
|
|
const Qt::GlobalColor BAND_NAME_BORDER_COLOR = Qt::darkYellow;
|
2016-02-17 10:11:00 +03:00
|
|
|
const qreal BAND_MARKER_OPACITY = 1;
|
|
|
|
const qreal LAYOUT_MARKER_OPACITY = 0.3;
|
|
|
|
const qreal BAND_NAME_AREA_OPACITY = 0.3;
|
|
|
|
const qreal BAND_NAME_TEXT_OPACITY = 0.6;
|
|
|
|
const qreal SELECTION_OPACITY = 0.3;
|
2016-02-17 10:39:17 +03:00
|
|
|
const QString FIELD_RX = "\\$D\\s*\\{\\s*([^{}]*)\\s*\\}";
|
2024-09-04 17:31:16 +03:00
|
|
|
const QString VARIABLE_RX = "\\$V\\s*\\{\\s*(?:([^\\{\\},]*)|(?:([^\\{\\}]*)\\s*,\\s*([^\\{"
|
|
|
|
"\\}]*)))\\s*\\}";
|
|
|
|
const QString NAMED_VARIABLE_RX
|
|
|
|
= "\\$V\\s*\\{\\s*(?:(%1)|(?:(%1)\\s*,\\s*([^\\{\\}]*)))\\s*\\}";
|
|
|
|
const QString SCRIPT_RX = "\\$S\\s*\\{(.*)\\}";
|
|
|
|
const QString GROUP_FUNCTION_PARAM_RX
|
|
|
|
= "\\(\\s*((?:(?:\\\")|(?:))(?:(?:\\$(?:(?:D\\{\\s*\\w*..*\\})|"
|
|
|
|
"(?:V\\{\\s*\\w*\\s*\\})|(?:S\\{.+\\})))|(?:\\w*))(?:(?:\\\")"
|
|
|
|
"|(?:)))(?:(?:\\s*,\\s*(?:\\\"(\\w*)\\\"))|(?:))(?:(?:\\s*,"
|
|
|
|
"\\s*(?:(\\w*)))|(?:))\\)";
|
2018-02-15 02:21:00 +03:00
|
|
|
const int DATASOURCE_INDEX = 3;
|
|
|
|
const int VALUE_INDEX = 2;
|
|
|
|
const int EXPRESSION_ARGUMENT_INDEX = 1;
|
2016-12-24 14:01:35 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
const QString GROUP_FUNCTION_RX = "(%1\\s*" + GROUP_FUNCTION_PARAM_RX + ")";
|
2016-02-17 10:11:00 +03:00
|
|
|
const QString GROUP_FUNCTION_NAME_RX = "%1\\s*\\((.*[^\\)])\\)";
|
|
|
|
const int SCENE_MARGIN = 50;
|
2016-11-01 20:42:45 +03:00
|
|
|
const QString FUNCTION_MANAGER_NAME = "LimeReport";
|
2019-01-30 22:49:20 +03:00
|
|
|
const QString DATAFUNCTIONS_MANAGER_NAME = "DatasourceFunctions";
|
2018-02-15 02:21:00 +03:00
|
|
|
const QString EOW("~!@#$%^&*()+{}|:\"<>?,/;'[]\\-=");
|
2019-01-29 23:18:24 +03:00
|
|
|
const int DEFAULT_TAB_INDENTION = 4;
|
2019-05-26 15:15:06 +03:00
|
|
|
const int DOCKWIDGET_MARGINS = 4;
|
2019-09-09 21:25:08 +03:00
|
|
|
|
|
|
|
const char SCRIPT_SIGN = 'S';
|
|
|
|
const char FIELD_SIGN = 'D';
|
|
|
|
const char VARIABLE_SIGN = 'V';
|
2024-09-04 17:31:16 +03:00
|
|
|
} // namespace Const
|
|
|
|
QString extractClassName(QString className);
|
|
|
|
QString escapeSimbols(const QString& value);
|
|
|
|
QString replaceHTMLSymbols(const QString& value);
|
2022-08-23 01:31:12 +03:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1)
|
2024-09-04 17:31:16 +03:00
|
|
|
QVector<QString> normalizeCaptures(const QRegularExpressionMatch& reg);
|
2021-11-02 22:30:29 +03:00
|
|
|
#else
|
2024-09-04 17:31:16 +03:00
|
|
|
QVector<QString> normalizeCaptures(const QRegExp& reg);
|
2021-08-23 08:07:08 +03:00
|
|
|
#endif
|
2024-09-04 17:31:16 +03:00
|
|
|
bool isColorDark(QColor color);
|
|
|
|
|
|
|
|
enum ExpandType {
|
|
|
|
EscapeSymbols,
|
|
|
|
NoEscapeSymbols,
|
|
|
|
ReplaceHTMLSymbols
|
|
|
|
};
|
|
|
|
enum RenderPass {
|
|
|
|
FirstPass = 1,
|
|
|
|
SecondPass = 2
|
|
|
|
};
|
|
|
|
enum ArrangeType {
|
|
|
|
AsNeeded,
|
|
|
|
Force
|
|
|
|
};
|
|
|
|
enum ScaleType {
|
|
|
|
FitWidth,
|
|
|
|
FitPage,
|
|
|
|
OneToOne,
|
|
|
|
Percents
|
|
|
|
};
|
|
|
|
enum PreviewHint {
|
|
|
|
ShowAllPreviewBars = 0,
|
|
|
|
HidePreviewToolBar = 1,
|
|
|
|
HidePreviewMenuBar = 2,
|
|
|
|
HidePreviewStatusBar = 4,
|
|
|
|
HideAllPreviewBar = 7,
|
|
|
|
PreviewBarsUserSetting = 8
|
|
|
|
};
|
|
|
|
|
|
|
|
Q_DECLARE_FLAGS(PreviewHints, PreviewHint)
|
|
|
|
Q_FLAGS(PreviewHints)
|
|
|
|
|
|
|
|
class LIMEREPORT_EXPORT ReportError: public std::runtime_error {
|
|
|
|
public:
|
|
|
|
ReportError(const QString& message);
|
|
|
|
};
|
|
|
|
|
|
|
|
class LIMEREPORT_EXPORT ReportSettings {
|
|
|
|
public:
|
2024-07-24 22:44:58 +03:00
|
|
|
#ifdef DEFAULT_ITEM_PADDING
|
2024-09-04 17:31:16 +03:00
|
|
|
ReportSettings():
|
|
|
|
m_suppressAbsentFieldsAndVarsWarnings(false),
|
|
|
|
m_baseItemPadding(DEFAULT_ITEM_PADDING)
|
|
|
|
{
|
|
|
|
}
|
2024-07-24 22:44:58 +03:00
|
|
|
#else
|
2024-09-04 17:31:16 +03:00
|
|
|
ReportSettings(): m_suppressAbsentFieldsAndVarsWarnings(false), m_baseItemPadding(0) { }
|
2024-07-24 22:44:58 +03:00
|
|
|
#endif
|
2024-09-04 17:31:16 +03:00
|
|
|
void setDefaultValues()
|
|
|
|
{
|
|
|
|
m_suppressAbsentFieldsAndVarsWarnings = false;
|
2024-07-24 22:44:58 +03:00
|
|
|
#ifdef DEFAULT_ITEM_PADDING
|
2024-09-04 17:31:16 +03:00
|
|
|
m_baseItemPadding = DEFAULT_ITEM_PADDING;
|
2024-07-24 22:44:58 +03:00
|
|
|
#else
|
2024-09-04 17:31:16 +03:00
|
|
|
m_baseItemPadding = 0;
|
2024-07-24 22:44:58 +03:00
|
|
|
#endif
|
2024-09-04 17:31:16 +03:00
|
|
|
}
|
|
|
|
bool suppressAbsentFieldsAndVarsWarnings() const;
|
|
|
|
void setSuppressAbsentFieldsAndVarsWarnings(bool suppressAbsentFieldsAndVarsWarnings);
|
|
|
|
int baseItemPadding() const;
|
|
|
|
void setBaseItemPadding(int newBaseTextItemPadding);
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_suppressAbsentFieldsAndVarsWarnings;
|
|
|
|
int m_baseItemPadding;
|
|
|
|
};
|
|
|
|
|
|
|
|
class LIMEREPORT_EXPORT IExternalPainter {
|
|
|
|
public:
|
|
|
|
virtual void paintByExternalPainter(const QString& objectName, QPainter* painter,
|
|
|
|
const QStyleOptionGraphicsItem* options)
|
|
|
|
= 0;
|
|
|
|
virtual ~IExternalPainter();
|
|
|
|
};
|
|
|
|
|
|
|
|
class LIMEREPORT_EXPORT IPainterProxy {
|
|
|
|
public:
|
|
|
|
virtual void setExternalPainter(IExternalPainter* externalPainter) = 0;
|
|
|
|
virtual ~IPainterProxy();
|
|
|
|
};
|
2018-12-12 22:55:03 +03:00
|
|
|
|
2021-08-23 08:07:08 +03:00
|
|
|
#if QT_VERSION < 0x050000
|
2024-09-04 17:31:16 +03:00
|
|
|
typedef QStyleOptionViewItemV4 StyleOptionViewItem;
|
2016-07-07 23:48:03 +03:00
|
|
|
#else
|
2024-09-04 17:31:16 +03:00
|
|
|
typedef QStyleOptionViewItem StyleOptionViewItem;
|
2016-07-07 23:48:03 +03:00
|
|
|
#endif
|
2022-07-16 02:33:39 +03:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 1)
|
2024-09-04 17:31:16 +03:00
|
|
|
QRegularExpression getRegEx(QString expression);
|
|
|
|
QRegularExpression getVariableRegEx();
|
|
|
|
QRegularExpression getFieldRegEx();
|
|
|
|
QRegularExpression getScriptRegEx();
|
|
|
|
QRegularExpression getGroupFunctionRegEx(QString functionName);
|
|
|
|
QRegularExpression getGroupFunctionNameRegEx(QString functionName);
|
|
|
|
QRegularExpression getNamedVariableRegEx(QString variableName);
|
2022-07-16 02:33:39 +03:00
|
|
|
#endif
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
class LIMEREPORT_EXPORT Enums {
|
|
|
|
public:
|
|
|
|
enum VariableDataType {
|
|
|
|
Undefined,
|
|
|
|
String,
|
|
|
|
Bool,
|
|
|
|
Int,
|
|
|
|
Real,
|
|
|
|
Date,
|
|
|
|
Time,
|
|
|
|
DateTime
|
|
|
|
};
|
2021-08-24 10:22:30 +03:00
|
|
|
#if QT_VERSION >= 0x050500
|
2024-09-04 17:31:16 +03:00
|
|
|
Q_ENUM(VariableDataType)
|
2020-03-03 05:19:59 +03:00
|
|
|
#else
|
2024-09-04 17:31:16 +03:00
|
|
|
Q_ENUMS(VariableDataType)
|
2020-03-03 05:19:59 +03:00
|
|
|
#endif
|
2024-09-04 17:31:16 +03:00
|
|
|
private:
|
|
|
|
Enums() { }
|
|
|
|
Q_GADGET
|
|
|
|
};
|
2017-12-11 16:48:00 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
typedef Enums::VariableDataType VariableDataType;
|
2017-09-26 00:19:59 +03:00
|
|
|
|
2016-02-17 10:11:00 +03:00
|
|
|
} // namespace LimeReport
|
|
|
|
|
2016-08-02 22:33:33 +03:00
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(LimeReport::PreviewHints)
|
2016-02-17 10:11:00 +03:00
|
|
|
|
|
|
|
#endif // GLOBAL_H
|