0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-27 18:08:10 +03:00
LimeReport/limereport/lrglobal.h

164 lines
7.2 KiB
C
Raw Normal View History

2016-02-17 10:11:00 +03:00
/***************************************************************************
* This file is part of the Lime Report project *
* Copyright (C) 2015 by Alexander Arin *
* 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. *
****************************************************************************/
#ifndef GLOBAL_H
#define GLOBAL_H
#include "qglobal.h"
#include <stdexcept>
#include <QString>
#include <QStyleOptionViewItem>
2016-02-17 10:11:00 +03:00
#if defined(LIMEREPORT_EXPORTS)
# define LIMEREPORT_EXPORT Q_DECL_EXPORT
#elif defined (LIMEREPORT_IMPORTS)
# define LIMEREPORT_EXPORT Q_DECL_IMPORT
#else
# define LIMEREPORT_EXPORT /**/
#endif
2016-11-01 20:42:45 +03:00
#ifdef USE_QJSENGINE
2017-02-11 00:21:03 +03:00
//#include <QJSEngine>
#include <QQmlEngine>
2016-11-01 20:42:45 +03:00
#else
#include <QScriptEngine>
#endif
2016-02-17 10:11:00 +03:00
namespace LimeReport {
2016-02-17 10:19:50 +03:00
2016-10-18 15:00:26 +03:00
#ifdef __GNUC__
#define VARIABLE_IS_NOT_USED __attribute__ ((unused))
#else
#define VARIABLE_IS_NOT_USED
#endif
2016-02-17 10:19:50 +03:00
namespace Const{
int const RESIZE_HANDLE_SIZE = 10;
int const SELECTION_PEN_SIZE = 4;
int const MINIMUM_ITEM_WIDTH = 2*RESIZE_HANDLE_SIZE;
int const MINIMUM_ITEM_HEIGHT = 2*RESIZE_HANDLE_SIZE;
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*\\}";
const QString VARIABLE_RX = "\\$V\\s*\\{\\s*([^{}]*)\\s*\\}";
2016-02-17 10:11:00 +03:00
const QString SCRIPT_RX = "\\$S\\s*\\{(.*)\\}";
//const QString GROUP_FUNCTION_PARAM_RX = "\\(\\s*(((?:\\\"?\\$D\\s*\\{\\s*)|(?:\\\"?\\$V\\s*\\{\\s*)|(?:\\\"))(\\w+\\.?\\w+)((?:\\\")|(?:\\s*\\}\\\"?\\s*)))\\s*,\\s*\\\"(\\w+)\\\"\\s*\\)";
//const int DATASOURCE_INDEX = 6;
//const int VALUE_INDEX = 2;
//const QString GROUP_FUNCTION_PARAM_RX = "\\(\\s*(?:(?:((?:(?:\\\"?\\$D\\s*\\{\\s*)|(?:\\\"?\\$V\\s*\\{\\s*)|(?:\\\"?\\$S\\s*\\{\\s*)|(?:\\\"))((?:\\w+\\.?\\w+)|(?:\\w+))(?:(?:\\\")|(?:\\s*\\}\\\"?\\s*)))\\s*,)|(?:))\\s*\\\"(\\w+)\\\"\\s*\\)";
2017-03-07 19:09:13 +03:00
//const QString GROUP_FUNCTION_PARAM_RX = "\\((?:(.+),(.+))|(?:\\\"(\\w+)\\\")\\)";
2017-06-07 23:47:43 +03:00
//const QString GROUP_FUNCTION_PARAM_RX = "\\(\\s*(?:(?:(?:(?:\\\")|(?:))(\\w+)(?:(?:\\\")|(?:)))|(?:(?:(?:\\\")|(?:))(\\s*\\$\\w\\s*\\{.+\\}\\s*)(?:(?:\\\")|(?:))\\s*,\\s*(?:(?:\\\")|(?:))(\\w+)(?:(?:\\\")|(?:))))\\)";
const QString GROUP_FUNCTION_PARAM_RX = "\\(\\s*((?:(?:\\\")|(?:))(?:(?:\\$(?:(?:D\\{\\s*\\w*.\\w*\\s*\\})|(?:V\\{\\s*\\w*\\s*\\})|(?:S\\{.+\\})))|(?:\\w*))(?:(?:\\\")|(?:)))(?:(?:\\s*,\\s*(?:\\\"(\\w*)\\\"))|(?:))\\)";
const int DATASOURCE_INDEX = 3;//4;
const int VALUE_INDEX = 2; //2;
const int EXPRESSION_ARGUMENT_INDEX = 1;//3;
2016-02-17 10:11:00 +03:00
const QString GROUP_FUNCTION_RX = "(%1\\s*"+GROUP_FUNCTION_PARAM_RX+")";
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";
2016-02-17 10:19:50 +03:00
}
QString extractClassName(QString className);
QString escapeSimbols(const QString& value);
QString replaceHTMLSymbols(const QString &value);
2017-03-07 19:09:13 +03:00
QVector<QString> normalizeCaptures(const QRegExp &reg);
enum ExpandType {EscapeSymbols, NoEscapeSymbols, ReplaceHTMLSymbols};
2016-02-17 10:19:50 +03:00
enum RenderPass {FirstPass, SecondPass};
enum ArrangeType {AsNeeded, Force};
enum PreviewHint{ShowAllPreviewBars = 0,
HidePreviewToolBar = 1,
HidePreviewMenuBar = 2,
HidePreviewStatusBar = 4,
HideAllPreviewBar = 7,
PreviewBarsUserSetting = 8};
Q_DECLARE_FLAGS(PreviewHints, PreviewHint)
Q_FLAGS(PreviewHints)
2016-02-17 10:11:00 +03:00
class ReportError : public std::runtime_error{
public:
ReportError(const QString& message):std::runtime_error(message.toStdString()){}
};
class ReportSettings{
public:
ReportSettings():m_suppressAbsentFieldsAndVarsWarnings(false){}
void setDefaultValues(){m_suppressAbsentFieldsAndVarsWarnings = false;}
bool suppressAbsentFieldsAndVarsWarnings() const;
void setSuppressAbsentFieldsAndVarsWarnings(bool suppressAbsentFieldsAndVarsWarnings);
private:
bool m_suppressAbsentFieldsAndVarsWarnings;
};
#ifdef HAVE_QT4
typedef QStyleOptionViewItemV4 StyleOptionViewItem;
#else
typedef QStyleOptionViewItem StyleOptionViewItem;
#endif
2016-11-01 20:42:45 +03:00
#ifdef USE_QJSENGINE
2017-02-11 00:21:03 +03:00
typedef QQmlEngine ScriptEngineType;
2016-11-01 20:42:45 +03:00
typedef QJSValue ScriptValueType;
2017-02-11 00:21:03 +03:00
template <typename T>
static inline QJSValue getCppOwnedJSValue(QJSEngine &e, T *p)
{
QJSValue res = e.newQObject(p);
QQmlEngine::setObjectOwnership(p, QQmlEngine::CppOwnership);
return res;
}
2016-11-01 20:42:45 +03:00
#else
typedef QScriptEngine ScriptEngineType;
typedef QScriptValue ScriptValueType;
#endif
2016-02-17 10:11:00 +03:00
} // namespace LimeReport
Q_DECLARE_OPERATORS_FOR_FLAGS(LimeReport::PreviewHints)
2016-02-17 10:11:00 +03:00
#endif // GLOBAL_H