mirror of
https://github.com/fralx/LimeReport.git
synced 2025-10-30 21:07:12 +03:00
Qt6 support added
This commit is contained in:
@@ -62,9 +62,16 @@ DataBrowser::DataBrowser(QWidget *parent) :
|
||||
connect(ui->deleteDataSource,SIGNAL(clicked()),this,SLOT(slotDeleteDatasource()));
|
||||
connect(ui->changeConnection,SIGNAL(clicked()),this,SLOT(slotChangeConnection()));
|
||||
connect(ui->pbConnect,SIGNAL(clicked()),this,SLOT(slotChangeConnectionState()));
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
ui->verticalLayout_2->setContentsMargins(
|
||||
Const::DOCKWIDGET_MARGINS,
|
||||
Const::DOCKWIDGET_MARGINS,
|
||||
Const::DOCKWIDGET_MARGINS,
|
||||
Const::DOCKWIDGET_MARGINS
|
||||
);
|
||||
#else
|
||||
ui->verticalLayout_2->setMargin(Const::DOCKWIDGET_MARGINS);
|
||||
|
||||
#endif
|
||||
ui->dataTree->setHeaderLabel(tr("Datasources"));
|
||||
ui->pbConnect->setEnabled(false);
|
||||
}
|
||||
|
||||
@@ -50,18 +50,23 @@ FormResizer::FormResizer(QWidget *parent) :
|
||||
m_frame(new QFrame),
|
||||
m_formWindow(0)
|
||||
{
|
||||
// Make the resize grip of a mainwindow form find us as resizable window.
|
||||
setWindowFlags(windowFlags() | Qt::SubWindow);
|
||||
setBackgroundRole(QPalette::Base);
|
||||
|
||||
QVBoxLayout *handleLayout = new QVBoxLayout(this);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
handleLayout->setContentsMargins(
|
||||
SELECTION_MARGIN,
|
||||
SELECTION_MARGIN,
|
||||
SELECTION_MARGIN,
|
||||
SELECTION_MARGIN
|
||||
);
|
||||
#else
|
||||
handleLayout->setMargin(SELECTION_MARGIN);
|
||||
#endif
|
||||
handleLayout->addWidget(m_frame);
|
||||
|
||||
m_frame->setFrameStyle(QFrame::Panel | QFrame::Raised);
|
||||
QVBoxLayout *layout = new QVBoxLayout(m_frame);
|
||||
layout->setMargin(0);
|
||||
// handles
|
||||
m_handles.reserve(SizeHandleRect::Left);
|
||||
for (int i = SizeHandleRect::LeftTop; i <= SizeHandleRect::Left; ++i) {
|
||||
SizeHandleRect *shr = new SizeHandleRect(this, static_cast<SizeHandleRect::Direction>(i), this);
|
||||
|
||||
@@ -36,7 +36,11 @@ void HorizontalBarChart::paintHorizontalBars(QPainter *painter, QRectF barsRect)
|
||||
delta = genNextValue(delta);
|
||||
|
||||
qreal vStep = (barsRect.height()-painter->fontMetrics().height()) / valuesCount() / seriesCount();
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
qreal hStep = (barsRect.width()-painter->fontMetrics().horizontalAdvance(QString::number(maxValue()))) / delta;
|
||||
#else
|
||||
qreal hStep = (barsRect.width()-painter->fontMetrics().width(QString::number(maxValue()))) / delta;
|
||||
#endif
|
||||
|
||||
if (!m_chartItem->series().isEmpty() && (m_chartItem->itemMode() != DesignMode)){
|
||||
int curSeries = 0;
|
||||
|
||||
@@ -14,7 +14,13 @@ void PieChart::drawPercent(QPainter *painter, QRectF chartRect, qreal startAngle
|
||||
#ifdef HAVE_QT5
|
||||
qreal radAngle = qDegreesToRadians(angle/2+startAngle);
|
||||
#endif
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
qreal radius = painter->fontMetrics().horizontalAdvance("99,9%");
|
||||
#else
|
||||
qreal radius = painter->fontMetrics().width("99,9%");
|
||||
#endif
|
||||
|
||||
qreal border = chartRect.height()*0.02;
|
||||
qreal length = (chartRect.height())/2-(radius/2+border);
|
||||
qreal x,y;
|
||||
@@ -155,14 +161,24 @@ QSizeF PieChart::calcChartLegendSize(const QFont &font)
|
||||
SeriesItem* si = m_chartItem->series().at(0);
|
||||
foreach(QString label, si->data()->labels()){
|
||||
cw += fm.height();
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
if (maxWidth<fm.horizontalAdvance(label))
|
||||
maxWidth = fm.horizontalAdvance(label)+10;
|
||||
#else
|
||||
if (maxWidth<fm.width(label))
|
||||
maxWidth = fm.width(label)+10;
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
foreach(QString label, m_designLabels){
|
||||
cw += fm.height();
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
if (maxWidth<fm.horizontalAdvance(label))
|
||||
maxWidth = fm.horizontalAdvance(label)+10;
|
||||
#else
|
||||
if (maxWidth<fm.width(label))
|
||||
maxWidth = fm.width(label)+10;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
cw += fm.height();
|
||||
|
||||
@@ -63,7 +63,11 @@ void FontEditorWidget::initEditor()
|
||||
m_fontSizeEditor = new QComboBox(this);
|
||||
m_fontSizeEditor->setModel(&m_fontSizeModel);
|
||||
m_fontSizeEditor->setEditable(true);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
connect(m_fontSizeEditor,SIGNAL(currentTextChanged(QString)), this, SLOT(slotFontSizeChanged(QString)));
|
||||
#else
|
||||
connect(m_fontSizeEditor,SIGNAL(currentIndexChanged(QString)),this,SLOT(slotFontSizeChanged(QString)));
|
||||
#endif
|
||||
addWidget(m_fontSizeEditor);
|
||||
|
||||
addSeparator();
|
||||
|
||||
@@ -348,7 +348,11 @@ void ChartItem::paintChartTitle(QPainter *painter, QRectF titleRect)
|
||||
painter->save();
|
||||
QFont tmpFont = painter->font();
|
||||
QFontMetrics fm(tmpFont);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
while ((fm.height()>titleRect.height() || fm.horizontalAdvance(m_title) > titleRect.width())
|
||||
#else
|
||||
while ((fm.height()>titleRect.height() || fm.width(m_title)>titleRect.width())
|
||||
#endif
|
||||
&& tmpFont.pixelSize()>1) {
|
||||
tmpFont.setPixelSize(tmpFont.pixelSize()-1);
|
||||
fm = QFontMetrics(tmpFont);
|
||||
@@ -566,7 +570,21 @@ QSizeF AbstractSeriesChart::calcChartLegendSize(const QFont &font)
|
||||
|
||||
qreal cw = 0;
|
||||
qreal maxWidth = 0;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
if (!m_chartItem->series().isEmpty()){
|
||||
foreach(SeriesItem* series, m_chartItem->series()){
|
||||
cw += fm.height();
|
||||
if (maxWidth<fm.horizontalAdvance(series->name()))
|
||||
maxWidth = fm.horizontalAdvance(series->name())+10;
|
||||
}
|
||||
} else {
|
||||
foreach(QString label, m_designLabels){
|
||||
cw += fm.height();
|
||||
if (maxWidth<fm.horizontalAdvance(label))
|
||||
maxWidth = fm.horizontalAdvance(label)+10;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (!m_chartItem->series().isEmpty()){
|
||||
foreach(SeriesItem* series, m_chartItem->series()){
|
||||
cw += fm.height();
|
||||
@@ -580,6 +598,7 @@ QSizeF AbstractSeriesChart::calcChartLegendSize(const QFont &font)
|
||||
maxWidth = fm.width(label)+10;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
cw += fm.height();
|
||||
return QSizeF(maxWidth+fm.height()*2,cw);
|
||||
}
|
||||
@@ -591,9 +610,16 @@ bool AbstractSeriesChart::verticalLabels(QPainter* painter, QRectF labelsRect)
|
||||
qreal hStep = (labelsRect.width() / valuesCount());
|
||||
QFontMetrics fm = painter->fontMetrics();
|
||||
foreach(QString label, m_chartItem->labels()){
|
||||
if (fm.width(label) > hStep){
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
if (fm.horizontalAdvance(label) > hStep){
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
if (fm.width(label) > hStep){
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -656,7 +682,11 @@ void AbstractSeriesChart::paintHorizontalGrid(QPainter *painter, QRectF gridRect
|
||||
delta = genNextValue(delta);
|
||||
|
||||
painter->setRenderHint(QPainter::Antialiasing,false);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
qreal hStep = (gridRect.width() - painter->fontMetrics().horizontalAdvance(QString::number(maxValue()))) / 4;
|
||||
#else
|
||||
qreal hStep = (gridRect.width() - painter->fontMetrics().width(QString::number(maxValue()))) / 4;
|
||||
#endif
|
||||
|
||||
painter->setFont(adaptValuesFont(hStep-4, painter->font()));
|
||||
|
||||
@@ -708,7 +738,11 @@ qreal AbstractSeriesChart::valuesHMargin(QPainter *painter)
|
||||
{
|
||||
int delta = int(maxValue()-minValue());
|
||||
delta = genNextValue(delta);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
return painter->fontMetrics().horizontalAdvance(QString::number(delta))+4;
|
||||
#else
|
||||
return painter->fontMetrics().width(QString::number(delta))+4;
|
||||
#endif
|
||||
}
|
||||
|
||||
qreal AbstractSeriesChart::valuesVMargin(QPainter *painter)
|
||||
@@ -720,9 +754,23 @@ QFont AbstractSeriesChart::adaptLabelsFont(QRectF rect, QFont font)
|
||||
{
|
||||
QString maxWord;
|
||||
QFontMetrics fm(font);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
foreach(QString label, m_chartItem->labels()){
|
||||
foreach (QString currentWord, label.split(QRegExp("\\W+"))){
|
||||
foreach (QString currentWord, label.split(LRRegularExpression("\\W+"))){
|
||||
if (fm.horizontalAdvance(maxWord) < fm.horizontalAdvance(currentWord)) maxWord = currentWord;
|
||||
}
|
||||
}
|
||||
|
||||
qreal curWidth = fm.horizontalAdvance(maxWord);
|
||||
QFont tmpFont = font;
|
||||
while (curWidth>rect.width() && tmpFont.pixelSize() > 1){
|
||||
tmpFont.setPixelSize(tmpFont.pixelSize() - 1);
|
||||
QFontMetricsF tmpFM(tmpFont);
|
||||
curWidth = tmpFM.horizontalAdvance(maxWord);
|
||||
}
|
||||
#else
|
||||
foreach(QString label, m_chartItem->labels()){
|
||||
foreach (QString currentWord, label.split(LRRegularExpression("\\W+"))){
|
||||
if (fm.width(maxWord) < fm.width(currentWord)) maxWord = currentWord;
|
||||
}
|
||||
}
|
||||
@@ -734,6 +782,7 @@ QFont AbstractSeriesChart::adaptLabelsFont(QRectF rect, QFont font)
|
||||
QFontMetricsF tmpFM(tmpFont);
|
||||
curWidth = tmpFM.width(maxWord);
|
||||
}
|
||||
#endif
|
||||
return tmpFont;
|
||||
}
|
||||
|
||||
@@ -741,6 +790,15 @@ QFont AbstractSeriesChart::adaptValuesFont(qreal width, QFont font)
|
||||
{
|
||||
QString strValue = QString::number(maxValue());
|
||||
QFont tmpFont = font;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
QScopedPointer<QFontMetricsF> fm(new QFontMetricsF(tmpFont));
|
||||
qreal curWidth = fm->horizontalAdvance(strValue);
|
||||
while (curWidth > width && tmpFont.pixelSize() > 1){
|
||||
tmpFont.setPixelSize(tmpFont.pixelSize() - 1);
|
||||
fm.reset(new QFontMetricsF(tmpFont));
|
||||
curWidth = fm->horizontalAdvance(strValue);
|
||||
}
|
||||
#else
|
||||
QScopedPointer<QFontMetricsF> fm(new QFontMetricsF(tmpFont));
|
||||
qreal curWidth = fm->width(strValue);
|
||||
while (curWidth > width && tmpFont.pixelSize() > 1){
|
||||
@@ -748,6 +806,7 @@ QFont AbstractSeriesChart::adaptValuesFont(qreal width, QFont font)
|
||||
fm.reset(new QFontMetricsF(tmpFont));
|
||||
curWidth = fm->width(strValue);
|
||||
}
|
||||
#endif
|
||||
return tmpFont;
|
||||
}
|
||||
|
||||
@@ -801,11 +860,17 @@ void AbstractBarChart::paintChartLegend(QPainter *painter, QRectF legendRect)
|
||||
QRectF AbstractBarChart::verticalLabelsRect(QPainter *painter, QRectF labelsRect)
|
||||
{
|
||||
qreal maxWidth = 0;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
foreach (QString label, m_chartItem->labels()) {
|
||||
if (painter->fontMetrics().horizontalAdvance(label)>maxWidth)
|
||||
maxWidth = painter->fontMetrics().horizontalAdvance(label);
|
||||
}
|
||||
#else
|
||||
foreach (QString label, m_chartItem->labels()) {
|
||||
if (painter->fontMetrics().width(label)>maxWidth)
|
||||
maxWidth = painter->fontMetrics().width(label);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (maxWidth + hPadding(m_chartItem->rect()) * 2 < labelsRect.width())
|
||||
return labelsRect;
|
||||
@@ -816,12 +881,17 @@ QRectF AbstractBarChart::verticalLabelsRect(QPainter *painter, QRectF labelsRect
|
||||
QRectF AbstractBarChart::horizontalLabelsRect(QPainter *painter, QRectF labelsRect)
|
||||
{
|
||||
qreal maxWidth = 0;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
foreach (QString label, m_chartItem->labels()) {
|
||||
if (painter->fontMetrics().horizontalAdvance(label)>maxWidth)
|
||||
maxWidth = painter->fontMetrics().horizontalAdvance(label);
|
||||
}
|
||||
#else
|
||||
foreach (QString label, m_chartItem->labels()) {
|
||||
if (painter->fontMetrics().width(label)>maxWidth)
|
||||
maxWidth = painter->fontMetrics().width(label);
|
||||
}
|
||||
|
||||
#endif
|
||||
if ((maxWidth + vPadding(m_chartItem->rect()) < labelsRect.height()) || !verticalLabels(painter, labelsRect))
|
||||
return labelsRect;
|
||||
else
|
||||
|
||||
@@ -10,7 +10,11 @@ ChartItemEditor::ChartItemEditor(LimeReport::ChartItem *item, LimeReport::PageDe
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QHBoxLayout* colorLayout = new QHBoxLayout();
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
colorLayout->setContentsMargins(0, 0, 0, 0);
|
||||
#else
|
||||
colorLayout->setMargin(0);
|
||||
#endif
|
||||
m_colorButton = new QToolButton();
|
||||
m_colorButton->setText("...");
|
||||
m_colorButton->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include "lrdesignelementsfactory.h"
|
||||
#include "lrglobal.h"
|
||||
#include "lrdatasourcemanager.h"
|
||||
#include "lrsimpletagparser.h"
|
||||
//#include "lrsimpletagparser.h"
|
||||
#include "lrtextitemeditor.h"
|
||||
#include "lrreportengine_p.h"
|
||||
#include <QMenu>
|
||||
@@ -59,7 +59,7 @@ namespace LimeReport{
|
||||
TextItem::TextItem(QObject *owner, QGraphicsItem *parent)
|
||||
: ContentItemDesignIntf(xmlTag,owner,parent), m_angle(Angle0), m_trimValue(true), m_allowHTML(false),
|
||||
m_allowHTMLInFields(false), m_replaceCarriageReturns(false), m_followTo(""), m_follower(0), m_textIndent(0),
|
||||
m_textLayoutDirection(Qt::LayoutDirectionAuto), m_hideIfEmpty(false), m_fontLetterSpacing(0)
|
||||
m_textLayoutDirection(Qt::LayoutDirectionAuto), m_hideIfEmpty(false), m_fontLetterSpacing(0), m_adaptedFont(0)
|
||||
{
|
||||
PageItemDesignIntf* pageItem = dynamic_cast<PageItemDesignIntf*>(parent);
|
||||
BaseDesignIntf* parentItem = dynamic_cast<BaseDesignIntf*>(parent);
|
||||
@@ -75,7 +75,9 @@ TextItem::TextItem(QObject *owner, QGraphicsItem *parent)
|
||||
Init();
|
||||
}
|
||||
|
||||
TextItem::~TextItem(){}
|
||||
TextItem::~TextItem(){
|
||||
if (m_adaptedFont) delete m_adaptedFont;
|
||||
}
|
||||
|
||||
int TextItem::fakeMarginSize() const{
|
||||
return marginSize()+5;
|
||||
@@ -360,8 +362,14 @@ void TextItem::updateLayout()
|
||||
|
||||
bool TextItem::isNeedExpandContent() const
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
QRegularExpression rx("\\$[S|V|D]\\s*\\{[^{].*\\}");
|
||||
rx.setPatternOptions(QRegularExpression::DotMatchesEverythingOption);
|
||||
#else
|
||||
QRegExp rx("$*\\{[^{]*\\}");
|
||||
return content().contains(rx) || isContentBackedUp();
|
||||
#endif
|
||||
bool result = content().contains(rx) || isContentBackedUp();
|
||||
return result;
|
||||
}
|
||||
|
||||
QString TextItem::replaceBR(QString text) const
|
||||
@@ -448,7 +456,7 @@ QString TextItem::formatNumber(const double value)
|
||||
|
||||
if (m_format.contains("%"))
|
||||
{
|
||||
str.sprintf(m_format.toStdString().c_str(), value);
|
||||
str.asprintf(m_format.toStdString().c_str(), value);
|
||||
str = str.replace(",", QLocale::system().groupSeparator());
|
||||
str = str.replace(".", QLocale::system().decimalPoint());
|
||||
}
|
||||
@@ -522,7 +530,12 @@ TextItem::TextPtr TextItem::textDocument() const
|
||||
|
||||
QFont _font = transformToSceneFont(font());
|
||||
if (m_adaptFontToSize && (!(m_autoHeight || m_autoWidth))){
|
||||
adaptFontSize(text);
|
||||
if (!m_adaptedFont){
|
||||
adaptFontSize(text);
|
||||
m_adaptedFont = new QFont(text->defaultFont());
|
||||
} else {
|
||||
setTextFont(text, *m_adaptedFont);
|
||||
}
|
||||
} else {
|
||||
setTextFont(text,_font);
|
||||
}
|
||||
@@ -779,7 +792,12 @@ void TextItem::setTrimValue(bool value)
|
||||
|
||||
|
||||
void TextItem::geometryChangedEvent(QRectF , QRectF)
|
||||
{}
|
||||
{
|
||||
if (m_adaptedFont){
|
||||
delete m_adaptedFont;
|
||||
m_adaptedFont = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool TextItem::isNeedUpdateSize(RenderPass pass) const
|
||||
{
|
||||
@@ -813,7 +831,11 @@ void TextItem::expandContent(DataSourceManager* dataManager, RenderPass pass)
|
||||
{
|
||||
QString context=content();
|
||||
foreach (QString variableName, dataManager->variableNamesByRenderPass(SecondPass)) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
QRegularExpression rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName));
|
||||
#else
|
||||
QRegExp rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName));
|
||||
#endif
|
||||
if (context.contains(rx) && pass == FirstPass){
|
||||
backupContent();
|
||||
break;
|
||||
|
||||
@@ -232,6 +232,7 @@ private:
|
||||
Qt::LayoutDirection m_textLayoutDirection;
|
||||
bool m_hideIfEmpty;
|
||||
int m_fontLetterSpacing;
|
||||
QFont mutable *m_adaptedFont;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ SOURCES += \
|
||||
$$REPORT_PATH/items/editors/lrfonteditorwidget.cpp \
|
||||
$$REPORT_PATH/items/editors/lrtextalignmenteditorwidget.cpp \
|
||||
$$REPORT_PATH/items/editors/lritemsborderseditorwidget.cpp \
|
||||
$$REPORT_PATH/items/lrsimpletagparser.cpp \
|
||||
# $$REPORT_PATH/items/lrsimpletagparser.cpp \
|
||||
$$REPORT_PATH/items/lrimageitem.cpp \
|
||||
$$REPORT_PATH/items/lrimageitemeditor.cpp \
|
||||
$$REPORT_PATH/items/lrtextitemeditor.cpp \
|
||||
@@ -137,7 +137,7 @@ HEADERS += \
|
||||
$$REPORT_PATH/items/lrshapeitem.h \
|
||||
$$REPORT_PATH/items/lrimageitem.h \
|
||||
$$REPORT_PATH/items/lrimageitemeditor.h \
|
||||
$$REPORT_PATH/items/lrsimpletagparser.h \
|
||||
# $$REPORT_PATH/items/lrsimpletagparser.h \
|
||||
$$REPORT_PATH/items/lrverticallayout.h \
|
||||
$$REPORT_PATH/items/lrlayoutmarker.h \
|
||||
$$REPORT_PATH/items/lrabstractlayout.h \
|
||||
|
||||
@@ -260,7 +260,11 @@ void BandDesignIntf::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
|
||||
QFontMetrics fontMetrics(font);
|
||||
|
||||
QVector<QRectF> bandNameRects;
|
||||
bandNameRects.push_back(QRectF(8,8,fontMetrics.width(" "+bandText+" "),fontMetrics.height()));
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
bandNameRects.push_back(QRectF(8,8,fontMetrics.horizontalAdvance(" "+bandText+" "), fontMetrics.height()));
|
||||
#else
|
||||
bandNameRects.push_back(QRectF(8,8,fontMetrics.width(" "+bandText+" "), fontMetrics.height()));
|
||||
#endif
|
||||
//bandNameRects.push_back(QRectF(width()-fontMetrics.width(" "+bandText+" "),2,fontMetrics.width(" "+bandText+" "),fontMetrics.height()));
|
||||
//bandNameRects.push_back(QRectF(2,height()-fontMetrics.height(),fontMetrics.width(" "+bandText+" "),fontMetrics.height()));
|
||||
//bandNameRects.push_back(QRectF(width()-fontMetrics.width(" "+bandText+" "),height()-fontMetrics.height(),fontMetrics.width(" "+bandText+" "),fontMetrics.height()));
|
||||
@@ -1209,11 +1213,19 @@ void BandNameLabel::updateLabel(const QString& bandName)
|
||||
QFont font("Arial",7*Const::fontFACTOR,-1,true);
|
||||
QFontMetrics fontMetrics(font);
|
||||
prepareGeometryChange();
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
m_rect = QRectF(
|
||||
m_band->pos().x()+10,
|
||||
m_band->pos().y()-(fontMetrics.height()+10),
|
||||
fontMetrics.width(bandName)+20,fontMetrics.height()+10
|
||||
m_band->pos().x() + 10,
|
||||
m_band->pos().y() - (fontMetrics.height() + 10),
|
||||
fontMetrics.horizontalAdvance(bandName) + 20, fontMetrics.height() + 10
|
||||
);
|
||||
#else
|
||||
m_rect = QRectF(
|
||||
m_band->pos().x() + 10,
|
||||
m_band->pos().y() - (fontMetrics.height()+10),
|
||||
fontMetrics.width(bandName) + 20, fontMetrics.height() + 10
|
||||
);
|
||||
#endif
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@@ -421,8 +421,27 @@ QString DataSourceManager::extractField(QString source)
|
||||
}
|
||||
|
||||
QString DataSourceManager::replaceVariables(QString value){
|
||||
QRegExp rx(Const::VARIABLE_RX);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
QRegularExpression rx(Const::VARIABLE_RX);
|
||||
if (value.contains(rx)){
|
||||
int pos = -1;
|
||||
QRegularExpressionMatch match = rx.match(value);
|
||||
while ((pos=match.capturedStart())!=-1){
|
||||
QString var=match.captured(0);
|
||||
var.remove("$V{");
|
||||
var.remove("}");
|
||||
|
||||
if (variable(var).isValid()){
|
||||
value.replace(pos,match.captured(0).length(),variable(var).toString());
|
||||
} else {
|
||||
value.replace(pos,match.captured(0).length(),QString(tr("Variable \"%1\" not found!").arg(var)));
|
||||
}
|
||||
match = rx.match(value);
|
||||
}
|
||||
}
|
||||
#else
|
||||
QRegExp rx(Const::VARIABLE_RX);
|
||||
if (value.contains(rx)){
|
||||
int pos = -1;
|
||||
while ((pos=rx.indexIn(value))!=-1){
|
||||
@@ -437,11 +456,53 @@ QString DataSourceManager::replaceVariables(QString value){
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return value;
|
||||
}
|
||||
|
||||
QString DataSourceManager::replaceVariables(QString query, QMap<QString,QString> &aliasesToParam)
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
QRegularExpression rx(Const::VARIABLE_RX);
|
||||
int curentAliasIndex = 0;
|
||||
if (query.contains(rx)){
|
||||
int pos = -1;
|
||||
QRegularExpressionMatch match = rx.match(query);
|
||||
while ((pos=match.capturedStart())!=-1){
|
||||
|
||||
QString var=match.captured(0);
|
||||
var.remove("$V{");
|
||||
var.remove("}");
|
||||
if (!match.captured(1).isEmpty()){
|
||||
if (aliasesToParam.contains(var)){
|
||||
curentAliasIndex++;
|
||||
aliasesToParam.insert(var+"_v_alias"+QString::number(curentAliasIndex),var);
|
||||
var += "_v_alias"+QString::number(curentAliasIndex);
|
||||
} else {
|
||||
aliasesToParam.insert(var,var);
|
||||
}
|
||||
query.replace(pos,match.captured(0).length(),":"+var);
|
||||
} else {
|
||||
QString varName = match.captured(2).trimmed();
|
||||
QString varParam = match.captured(3).trimmed();
|
||||
if (!varName.isEmpty()){
|
||||
if (!varParam.isEmpty() && varParam.compare("nobind") == 0 ){
|
||||
query.replace(pos,match.captured(0).length(), variable(varName).toString());
|
||||
} else {
|
||||
query.replace(pos,match.captured(0).length(),
|
||||
QString(tr("Unknown parameter \"%1\" for variable \"%2\" found!")
|
||||
.arg(varName)
|
||||
.arg(varParam))
|
||||
);
|
||||
}
|
||||
} else {
|
||||
query.replace(pos,match.captured(0).length(),QString(tr("Variable \"%1\" not found!").arg(var)));
|
||||
}
|
||||
}
|
||||
match = rx.match(query);
|
||||
}
|
||||
}
|
||||
#else
|
||||
QRegExp rx(Const::VARIABLE_RX);
|
||||
int curentAliasIndex = 0;
|
||||
if (query.contains(rx)){
|
||||
@@ -479,9 +540,44 @@ QString DataSourceManager::replaceVariables(QString query, QMap<QString,QString>
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return query;
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
QString DataSourceManager::replaceFields(QString query, QMap<QString,QString> &aliasesToParam, QString masterDatasource)
|
||||
{
|
||||
QRegularExpression rx(Const::FIELD_RX);
|
||||
if (query.contains(rx)){
|
||||
int curentAliasIndex = 0;
|
||||
int pos=-1;
|
||||
QRegularExpressionMatch match = rx.match(query);
|
||||
while (match.hasMatch()){
|
||||
pos = match.capturedStart();
|
||||
QString field=match.captured(0);
|
||||
field.remove("$D{");
|
||||
field.remove("}");
|
||||
|
||||
if (!aliasesToParam.contains(field)){
|
||||
if (field.contains("."))
|
||||
aliasesToParam.insert(field, field);
|
||||
else
|
||||
aliasesToParam.insert(field, masterDatasource + "." + field);
|
||||
} else {
|
||||
curentAliasIndex++;
|
||||
if (field.contains("."))
|
||||
aliasesToParam.insert(field + "_f_alias" + QString::number(curentAliasIndex), field);
|
||||
else
|
||||
aliasesToParam.insert(field + "_f_alias" + QString::number(curentAliasIndex), masterDatasource + "." + field);
|
||||
field += "_f_alias" + QString::number(curentAliasIndex);
|
||||
}
|
||||
query.replace(pos, match.captured(0).length(), ":" + extractField(field));
|
||||
match = rx.match(query);
|
||||
}
|
||||
}
|
||||
return query;
|
||||
}
|
||||
#else
|
||||
QString DataSourceManager::replaceFields(QString query, QMap<QString,QString> &aliasesToParam, QString masterDatasource)
|
||||
{
|
||||
QRegExp rx(Const::FIELD_RX);
|
||||
@@ -511,6 +607,7 @@ QString DataSourceManager::replaceFields(QString query, QMap<QString,QString> &a
|
||||
}
|
||||
return query;
|
||||
}
|
||||
#endif
|
||||
|
||||
void DataSourceManager::setReportVariable(const QString &name, const QVariant &value)
|
||||
{
|
||||
@@ -1012,7 +1109,7 @@ void DataSourceManager::disconnectConnection(const QString& connectionName)
|
||||
if (isQuery(datasourceName) || isSubQuery(datasourceName)){
|
||||
QueryHolder* qh = dynamic_cast<QueryHolder*>(dataSourceHolder(datasourceName));
|
||||
if (qh && qh->connectionName().compare(connectionName,Qt::CaseInsensitive)==0){
|
||||
qh->invalidate(designTime()?IDataSource::DESIGN_MODE:IDataSource::RENDER_MODE);
|
||||
qh->invalidate(designTime() ? IDataSource::DESIGN_MODE : IDataSource::RENDER_MODE, true);
|
||||
qh->setLastError(tr("invalid connection"));
|
||||
}
|
||||
}
|
||||
@@ -1392,7 +1489,7 @@ void DataSourceManager::invalidateQueriesContainsVariable(const QString& variabl
|
||||
foreach (const QString& datasourceName, dataSourceNames()){
|
||||
QueryHolder* holder = dynamic_cast<QueryHolder*>(m_datasources.value(datasourceName));
|
||||
if (holder){
|
||||
QRegExp rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName));
|
||||
LRRegularExpression rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName));
|
||||
if (holder->queryText().contains(rx)){
|
||||
holder->invalidate(designTime() ? IDataSource::DESIGN_MODE : IDataSource::RENDER_MODE);
|
||||
datasources.append(datasourceName);
|
||||
@@ -1437,13 +1534,13 @@ void DataSourceManager::clear(ClearMethod method)
|
||||
case All:
|
||||
invalidateLinkedDatasources(dit.key());
|
||||
delete dit.value();
|
||||
m_datasources.erase(dit++);
|
||||
dit = m_datasources.erase(dit);
|
||||
break;
|
||||
default:
|
||||
if (owned){
|
||||
invalidateLinkedDatasources(dit.key());
|
||||
delete dit.value();
|
||||
m_datasources.erase(dit++);
|
||||
dit = m_datasources.erase(dit);
|
||||
} else {
|
||||
++dit;
|
||||
}
|
||||
@@ -1467,8 +1564,7 @@ void DataSourceManager::clear(ClearMethod method)
|
||||
m_queries.clear();
|
||||
m_subqueries.clear();
|
||||
m_proxies.clear();
|
||||
// if (method == All)
|
||||
// clearUserVariables();
|
||||
|
||||
clearReportVariables();
|
||||
|
||||
emit cleared();
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <QString>
|
||||
#include <QStyleOptionViewItem>
|
||||
#include <QtGlobal>
|
||||
#include <QRegExp>
|
||||
|
||||
#if defined(LIMEREPORT_EXPORTS)
|
||||
# define LIMEREPORT_EXPORT Q_DECL_EXPORT
|
||||
@@ -51,6 +52,12 @@ namespace LimeReport {
|
||||
#define VARIABLE_IS_NOT_USED
|
||||
#endif
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
typedef QRegularExpression LRRegularExpression;
|
||||
#else
|
||||
typedef QRegExp LRRegularExpression;
|
||||
#endif
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
|
||||
Q_NAMESPACE
|
||||
#endif
|
||||
|
||||
@@ -53,12 +53,21 @@ bool GraphicsViewZoomer::eventFilter(QObject *object, QEvent *event) {
|
||||
} else if (event->type() == QEvent::Wheel) {
|
||||
QWheelEvent* wheel_event = static_cast<QWheelEvent*>(event);
|
||||
if (QApplication::keyboardModifiers() == m_modifiers) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
if (wheel_event->angleDelta().x() != 0) {
|
||||
double angle = wheel_event->angleDelta().x();
|
||||
double factor = qPow(m_zoomFactorBase, angle);
|
||||
gentleZoom(factor);
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
if (wheel_event->orientation() == Qt::Vertical) {
|
||||
double angle = wheel_event->delta();
|
||||
double factor = qPow(m_zoomFactorBase, angle);
|
||||
gentleZoom(factor);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Q_UNUSED(object)
|
||||
|
||||
@@ -770,7 +770,7 @@ void PageDesignIntf::dropEvent(QGraphicsSceneDragDropEvent* event)
|
||||
BaseDesignIntf* item = addReportItem("TextItem",event->scenePos(),QSize(250, 50));
|
||||
TextItem* ti = dynamic_cast<TextItem*>(item);
|
||||
QString data = event->mimeData()->text().remove(0,event->mimeData()->text().indexOf(":")+1);
|
||||
if (isVar) data = data.remove(QRegExp(" \\[.*\\]"));
|
||||
if (isVar) data = data.remove(LRRegularExpression(" \\[.*\\]"));
|
||||
ti->setContent(data);
|
||||
if (!isVar){
|
||||
BandDesignIntf* parentBand = dynamic_cast<BandDesignIntf*>(ti->parentItem());
|
||||
|
||||
@@ -143,7 +143,11 @@ void PreviewReportWidget::initPreview()
|
||||
{
|
||||
if (ui->graphicsView->scene()!=d_ptr->m_previewPage)
|
||||
ui->graphicsView->setScene(d_ptr->m_previewPage);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
ui->graphicsView->resetTransform();
|
||||
#else
|
||||
ui->graphicsView->resetMatrix();
|
||||
#endif
|
||||
ui->graphicsView->centerOn(0, 0);
|
||||
ui->graphicsView->scene()->setBackgroundBrush(QColor(m_previewPageBackgroundColor));
|
||||
setScalePercent(d_ptr->m_scalePercent);
|
||||
@@ -309,7 +313,11 @@ void PreviewReportWidget::saveToFile()
|
||||
|
||||
void PreviewReportWidget::setScalePercent(int percent)
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
ui->graphicsView->resetTransform();
|
||||
#else
|
||||
ui->graphicsView->resetMatrix();
|
||||
#endif
|
||||
d_ptr->m_scalePercent = percent;
|
||||
qreal scaleSize = percent/100.0;
|
||||
ui->graphicsView->scale(scaleSize, scaleSize);
|
||||
@@ -469,7 +477,11 @@ void PreviewReportWidget::reportEngineDestroyed(QObject *object)
|
||||
|
||||
void PreviewReportWidget::slotZoomed(double )
|
||||
{
|
||||
d_ptr->m_scalePercent = ui->graphicsView->matrix().m11()*100;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
d_ptr->m_scalePercent = ui->graphicsView->transform().m11() * 100;
|
||||
#else
|
||||
d_ptr->m_scalePercent = ui->graphicsView->matrix().m11() * 100;
|
||||
#endif
|
||||
emit scalePercentChanged(d_ptr->m_scalePercent);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,9 @@
|
||||
#include <QPrintDialog>
|
||||
#include <QFileDialog>
|
||||
#include <QScrollBar>
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 3)
|
||||
#include <QDesktopWidget>
|
||||
#endif
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
#include <QToolButton>
|
||||
@@ -57,7 +59,11 @@ PreviewReportWindow::PreviewReportWindow(ReportEngine *report, QWidget *parent,
|
||||
|
||||
m_progressWidget = new QWidget(ui->statusbar);
|
||||
QHBoxLayout* progressLayout = new QHBoxLayout();
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
progressLayout->setContentsMargins(0, 0, 0, 0);
|
||||
#else
|
||||
progressLayout->setMargin(0);
|
||||
#endif
|
||||
progressLayout->addWidget(new QLabel(tr("Printing")));
|
||||
m_progressBar = new QProgressBar(ui->statusbar);
|
||||
m_progressBar->setMaximumWidth(100);
|
||||
@@ -139,10 +145,14 @@ void PreviewReportWindow::restoreSetting()
|
||||
if (v.isValid()){
|
||||
restoreGeometry(v.toByteArray());
|
||||
} else {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
int screenWidth = QGuiApplication::primaryScreen()->geometry().width();
|
||||
int screenHeight = QGuiApplication::primaryScreen()->geometry().height();
|
||||
#else
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
|
||||
int screenWidth = desktop->screenGeometry().width();
|
||||
int screenHeight = desktop->screenGeometry().height();
|
||||
#endif
|
||||
|
||||
int x = static_cast<int>(screenWidth*0.1);
|
||||
int y = static_cast<int>(screenHeight*0.1);
|
||||
|
||||
@@ -1057,9 +1057,14 @@ bool ReportDesignWidget::eventFilter(QObject *target, QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::Wheel){
|
||||
QWheelEvent* we = dynamic_cast<QWheelEvent*>(event);
|
||||
if (QApplication::keyboardModifiers()==Qt::ControlModifier){
|
||||
if(we->delta()<0) scale(1.2,1.2);
|
||||
if (QApplication::keyboardModifiers()==Qt::ControlModifier){
|
||||
#if QT_VERSION >= 0x060000
|
||||
if (we->pixelDelta().x()<0) scale(1.2,1.2);
|
||||
else scale(1/1.2,1/1.2);
|
||||
#else
|
||||
if (we->delta()<0) scale(1.2,1.2);
|
||||
else scale(1/1.2,1/1.2);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return QWidget::eventFilter(target,event);
|
||||
@@ -1134,8 +1139,14 @@ void Ruler::paintEvent(QPaintEvent *event){
|
||||
painter.setBrush(palette().background());
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.drawRect(event->rect());
|
||||
// painter.setPen(palette().foreground().color());
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
QColor foregroundColor = palette().windowText().color();
|
||||
QColor backgroundColor = palette().window().color();
|
||||
#else
|
||||
QColor foregroundColor = palette().foreground().color();
|
||||
QColor backgroundColor = palette().background().color();
|
||||
#endif
|
||||
if (m_page){
|
||||
qreal rulerWidth = m_page->geometry().width() / m_page->unitFactor();
|
||||
qreal rulerHeight = m_page->geometry().height() / m_page->unitFactor();
|
||||
@@ -1153,13 +1164,13 @@ void Ruler::paintEvent(QPaintEvent *event){
|
||||
case Horizontal:
|
||||
painter.setPen(Qt::NoPen);
|
||||
|
||||
if (isColorDark(palette().background().color()))
|
||||
if (isColorDark(backgroundColor))
|
||||
painter.setBrush(QColor("#64893d"));
|
||||
else
|
||||
painter.setBrush(QColor("#b5da91"));
|
||||
|
||||
drawItemWithChildren(&painter, m_page);
|
||||
painter.setPen(palette().foreground().color());
|
||||
painter.setPen(foregroundColor);
|
||||
|
||||
for (int i = 0; i < rulerWidth / 10; ++i){
|
||||
int hs10 = view->mapFromScene(QPointF(m_page->geometry().topLeft().x() + i * 10 * m_page->unitFactor(), 0)).x();
|
||||
@@ -1172,24 +1183,31 @@ void Ruler::paintEvent(QPaintEvent *event){
|
||||
painter.drawLine(hs10, 15, hs10, 20);
|
||||
painter.drawLine(hs5, 10, hs5, 20);
|
||||
if ( i > 0)
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
painter.drawText(QPoint(hs10 - (painter.fontMetrics().horizontalAdvance(QString::number(i))/2), 12),
|
||||
QString::number(i));
|
||||
#else
|
||||
painter.drawText(QPoint(hs10 - (painter.fontMetrics().width(QString::number(i))/2), 12),
|
||||
QString::number(i));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
painter.setPen(palette().foreground().color());
|
||||
|
||||
painter.setPen(foregroundColor);
|
||||
painter.drawLine(m_mousePos.x() - (hStartPos > 0 ? hStartPos : 0) , 0,
|
||||
m_mousePos.x() - (hStartPos > 0 ? hStartPos : 0) , 20);
|
||||
break;
|
||||
case Vertical:
|
||||
painter.setPen(Qt::NoPen);
|
||||
|
||||
if (isColorDark(palette().background().color()))
|
||||
if (isColorDark(backgroundColor))
|
||||
painter.setBrush(QColor("#64893d"));
|
||||
else
|
||||
painter.setBrush(QColor("#b5da91"));
|
||||
|
||||
drawItemWithChildren(&painter, m_page);
|
||||
painter.setPen(palette().foreground().color());
|
||||
painter.setPen(foregroundColor);
|
||||
|
||||
for (int i = 0; i < rulerHeight / 10; ++i){
|
||||
int vs10 = view->mapFromScene(QPointF(0, m_page->geometry().topLeft().y()+i * 10 * m_page->unitFactor())).y();
|
||||
int vs5 = view->mapFromScene(QPointF(0, m_page->geometry().topLeft().y()+i * 10 * m_page->unitFactor() + 5 * m_page->unitFactor())).y();
|
||||
@@ -1199,13 +1217,19 @@ void Ruler::paintEvent(QPaintEvent *event){
|
||||
vs5 -= vStartPos;
|
||||
}
|
||||
painter.drawLine(15, vs10, 20, vs10);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
if ( i > 0 )
|
||||
painter.drawText(QPoint( (15 - painter.fontMetrics().horizontalAdvance(QString::number(i))) / 2 ,
|
||||
vs10 + (painter.fontMetrics().height()/2)), QString::number(i));
|
||||
#else
|
||||
if ( i > 0 )
|
||||
painter.drawText(QPoint( (15 - painter.fontMetrics().width(QString::number(i))) / 2 ,
|
||||
vs10 + (painter.fontMetrics().height()/2)), QString::number(i));
|
||||
#endif
|
||||
painter.drawLine(10, vs5, 20, vs5);
|
||||
}
|
||||
}
|
||||
painter.setPen(palette().foreground().color());
|
||||
painter.setPen(foregroundColor);
|
||||
painter.drawLine(0, m_mousePos.y() - (vStartPos > 0 ? vStartPos : 0),
|
||||
20, m_mousePos.y() - (vStartPos > 0 ? vStartPos : 0));
|
||||
break;
|
||||
|
||||
@@ -39,7 +39,9 @@
|
||||
#include <QMenuBar>
|
||||
#include <QCheckBox>
|
||||
#include <QVBoxLayout>
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 3)
|
||||
#include <QDesktopWidget>
|
||||
#endif
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
@@ -69,7 +71,12 @@ void ReportDesignWindow::createProgressBar()
|
||||
{
|
||||
m_progressWidget = new QWidget(m_statusBar);
|
||||
QHBoxLayout* progressLayout = new QHBoxLayout();
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
progressLayout->setContentsMargins(0, 0, 0, 0);
|
||||
#else
|
||||
progressLayout->setMargin(0);
|
||||
#endif
|
||||
|
||||
m_progressLabel = new QLabel(tr("Rendered %1 pages").arg(0));
|
||||
progressLayout->addWidget(m_progressLabel);
|
||||
m_progressBar = new QProgressBar(m_statusBar);
|
||||
@@ -497,8 +504,11 @@ void ReportDesignWindow::createBandsButton()
|
||||
connect(m_newTearOffBand,SIGNAL(triggered()),m_bandsAddSignalsMap,SLOT(map()));
|
||||
m_bandsAddSignalsMap->setMapping(m_newTearOffBand,BandDesignIntf::TearOffBand);
|
||||
m_newBandButton->addAction(m_newTearOffBand);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
connect(m_bandsAddSignalsMap,SIGNAL(mappedInt(int)),this,SLOT(slotNewBand(int)));
|
||||
#else
|
||||
connect(m_bandsAddSignalsMap,SIGNAL(mapped(int)),this,SLOT(slotNewBand(int)));
|
||||
#endif
|
||||
}
|
||||
|
||||
void ReportDesignWindow::createMainMenu()
|
||||
@@ -525,7 +535,11 @@ void ReportDesignWindow::createMainMenu()
|
||||
m_infoMenu->addAction(m_aboutAction);
|
||||
m_recentFilesMenu = m_fileMenu->addMenu(tr("Recent Files"));
|
||||
m_recentFilesSignalMap = new QSignalMapper(this);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
connect(m_recentFilesSignalMap,SIGNAL(mappedString(QString)),this,SLOT(slotLoadRecentFile(QString)));
|
||||
#else
|
||||
connect(m_recentFilesSignalMap,SIGNAL(mapped(QString)),this,SLOT(slotLoadRecentFile(QString)));
|
||||
#endif
|
||||
m_recentFilesMenu->setDisabled(m_recentFiles.isEmpty());
|
||||
}
|
||||
|
||||
@@ -566,7 +580,11 @@ void ReportDesignWindow::createObjectInspector()
|
||||
QWidget* w = new QWidget(objectDoc);
|
||||
QVBoxLayout* l = new QVBoxLayout(w);
|
||||
l->addWidget(m_objectInspector);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
l->setContentsMargins(0, 0, 0, 0);
|
||||
#else
|
||||
l->setMargin(0);
|
||||
#endif
|
||||
w->setLayout(l);
|
||||
objectDoc->setWindowTitle(tr("Object Inspector"));
|
||||
objectDoc->setWidget(w);
|
||||
@@ -832,10 +850,14 @@ void ReportDesignWindow::restoreSetting()
|
||||
if (v.isValid()){
|
||||
restoreGeometry(v.toByteArray());
|
||||
} else {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
int screenWidth = QGuiApplication::primaryScreen()->geometry().width();
|
||||
int screenHeight = QGuiApplication::primaryScreen()->geometry().height();
|
||||
#else
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
|
||||
int screenWidth = desktop->screenGeometry().width();
|
||||
int screenHeight = desktop->screenGeometry().height();
|
||||
int screenWidth = desktop->screen()->geometry().width();
|
||||
int screenHeight = desktop->screen()->geometry().height();
|
||||
#endif
|
||||
|
||||
int x = screenWidth * 0.1;
|
||||
int y = screenHeight * 0.1;
|
||||
@@ -1527,7 +1549,12 @@ void ReportDesignWindow::slotPageDeleted()
|
||||
|
||||
void ReportDesignWindow::slotFilterTextChanged(const QString& filter)
|
||||
{
|
||||
#if QT_VERSION >= 0x060000
|
||||
m_filterModel->setFilterRegularExpression(QRegularExpression(filter, QRegularExpression::CaseInsensitiveOption));
|
||||
#else
|
||||
m_filterModel->setFilterRegExp(QRegExp(filter, Qt::CaseInsensitive, QRegExp::FixedString));
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#ifdef HAVE_QTDESIGNER_INTEGRATION
|
||||
|
||||
@@ -32,7 +32,9 @@
|
||||
#include <QPrinterInfo>
|
||||
#include <QMessageBox>
|
||||
#include <QApplication>
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 3)
|
||||
#include <QDesktopWidget>
|
||||
#endif
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QPluginLoader>
|
||||
#include <QFileDialog>
|
||||
|
||||
@@ -370,7 +370,7 @@ bool ReportRender::containsGroupFunctions(BandDesignIntf *band){
|
||||
}
|
||||
|
||||
void ReportRender::extractGroupFuntionsFromItem(ContentItemDesignIntf* contentItem, BandDesignIntf* band){
|
||||
if ( contentItem && contentItem->content().contains(QRegExp("\\$S\\s*\\{.*\\}"))){
|
||||
if ( contentItem && contentItem->content().contains(LRRegularExpression("\\$S\\s*\\{.*\\}"))){
|
||||
foreach(const QString &functionName, m_datasources->groupFunctionNames()){
|
||||
QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
|
||||
rx.setMinimal(true);
|
||||
|
||||
@@ -352,6 +352,60 @@ void ScriptEngineManager::setDataManager(DataSourceManager *dataManager){
|
||||
}
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
QString ScriptEngineManager::expandUserVariables(QString context, RenderPass /* pass */, ExpandType expandType, QVariant &varValue)
|
||||
{
|
||||
LRRegularExpression rx(Const::VARIABLE_RX);
|
||||
if (context.contains(rx)){
|
||||
int pos = 0;
|
||||
QRegularExpressionMatch match = rx.match(context, pos);
|
||||
while (match.hasMatch()){
|
||||
|
||||
QString variable=match.captured(1);
|
||||
pos = match.capturedEnd();
|
||||
|
||||
if (dataManager()->containsVariable(variable) ){
|
||||
try {
|
||||
|
||||
varValue = dataManager()->variable(variable);
|
||||
switch (expandType){
|
||||
case EscapeSymbols:
|
||||
context.replace(match.captured(0), escapeSimbols(varValue.toString()));
|
||||
break;
|
||||
case NoEscapeSymbols:
|
||||
context.replace(match.captured(0), varValue.toString());
|
||||
break;
|
||||
case ReplaceHTMLSymbols:
|
||||
context.replace(match.captured(0), replaceHTMLSymbols(varValue.toString()));
|
||||
break;
|
||||
}
|
||||
|
||||
pos = 0;
|
||||
|
||||
} catch (ReportError &e){
|
||||
dataManager()->putError(e.what());
|
||||
if (!dataManager()->reportSettings() || dataManager()->reportSettings()->suppressAbsentFieldsAndVarsWarnings())
|
||||
context.replace(match.captured(0), e.what());
|
||||
else
|
||||
context.replace(match.captured(0), "");
|
||||
}
|
||||
} else {
|
||||
|
||||
QString error;
|
||||
error = tr("Variable %1 not found").arg(variable);
|
||||
dataManager()->putError(error);
|
||||
if (!dataManager()->reportSettings() || dataManager()->reportSettings()->suppressAbsentFieldsAndVarsWarnings())
|
||||
context.replace(match.captured(0), error);
|
||||
else
|
||||
context.replace(match.captured(0), "");
|
||||
}
|
||||
|
||||
match = rx.match(context, pos);
|
||||
}
|
||||
}
|
||||
return context;
|
||||
}
|
||||
#else
|
||||
QString ScriptEngineManager::expandUserVariables(QString context, RenderPass /* pass */, ExpandType expandType, QVariant &varValue)
|
||||
{
|
||||
QRegExp rx(Const::VARIABLE_RX);
|
||||
@@ -397,7 +451,67 @@ QString ScriptEngineManager::expandUserVariables(QString context, RenderPass /*
|
||||
}
|
||||
return context;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
QString ScriptEngineManager::expandDataFields(QString context, ExpandType expandType, QVariant &varValue, QObject *reportItem)
|
||||
{
|
||||
QRegularExpression rx(Const::FIELD_RX);
|
||||
|
||||
if (context.contains(rx)){
|
||||
QRegularExpressionMatch match = rx.match(context);
|
||||
while (match.hasMatch()){
|
||||
|
||||
QString field=match.captured(1);
|
||||
|
||||
if (dataManager()->containsField(field)) {
|
||||
QString fieldValue;
|
||||
varValue = dataManager()->fieldData(field);
|
||||
if (expandType == EscapeSymbols) {
|
||||
if (varValue.isNull()) {
|
||||
fieldValue="\"\"";
|
||||
} else {
|
||||
fieldValue = escapeSimbols(varValue.toString());
|
||||
switch (dataManager()->fieldData(field).type()) {
|
||||
case QVariant::Char:
|
||||
case QVariant::String:
|
||||
case QVariant::StringList:
|
||||
case QVariant::Date:
|
||||
case QVariant::DateTime:
|
||||
fieldValue = "\""+fieldValue+"\"";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (expandType == ReplaceHTMLSymbols)
|
||||
fieldValue = replaceHTMLSymbols(varValue.toString());
|
||||
else fieldValue = varValue.toString();
|
||||
}
|
||||
|
||||
context.replace(match.captured(0),fieldValue);
|
||||
|
||||
} else {
|
||||
QString error;
|
||||
if (reportItem){
|
||||
error = tr("Field %1 not found in %2!").arg(field).arg(reportItem->objectName());
|
||||
dataManager()->putError(error);
|
||||
}
|
||||
varValue = QVariant();
|
||||
if (!dataManager()->reportSettings() || !dataManager()->reportSettings()->suppressAbsentFieldsAndVarsWarnings())
|
||||
context.replace(match.captured(0), error);
|
||||
else
|
||||
context.replace(match.captured(0), "");
|
||||
}
|
||||
match = rx.match(context);
|
||||
}
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
#else
|
||||
QString ScriptEngineManager::expandDataFields(QString context, ExpandType expandType, QVariant &varValue, QObject *reportItem)
|
||||
{
|
||||
QRegExp rx(Const::FIELD_RX);
|
||||
@@ -451,10 +565,16 @@ QString ScriptEngineManager::expandDataFields(QString context, ExpandType expand
|
||||
|
||||
return context;
|
||||
}
|
||||
#endif
|
||||
|
||||
QString ScriptEngineManager::expandScripts(QString context, QVariant& varValue, QObject *reportItem)
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
QRegularExpression rx(Const::SCRIPT_RX);
|
||||
rx.setPatternOptions(QRegularExpression::DotMatchesEverythingOption);
|
||||
#else
|
||||
QRegExp rx(Const::SCRIPT_RX);
|
||||
#endif
|
||||
|
||||
if (context.contains(rx)){
|
||||
|
||||
@@ -517,7 +637,7 @@ QString ScriptEngineManager::replaceScripts(QString context, QVariant &varValue,
|
||||
|
||||
QVariant ScriptEngineManager::evaluateScript(const QString& script){
|
||||
|
||||
QRegExp rx(Const::SCRIPT_RX);
|
||||
LRRegularExpression rx(Const::SCRIPT_RX);
|
||||
QVariant varValue;
|
||||
|
||||
if (script.contains(rx)){
|
||||
|
||||
@@ -34,7 +34,11 @@
|
||||
#include <QFocusEvent>
|
||||
#include <QApplication>
|
||||
#include <QStyle>
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
#include <QScreen>
|
||||
#else
|
||||
#include <QDesktopWidget>
|
||||
#endif
|
||||
#include "lrtextitempropertyeditor.h"
|
||||
|
||||
namespace LimeReport{
|
||||
@@ -66,7 +70,18 @@ void ButtonLineEditor::editButtonClicked()
|
||||
{
|
||||
TextItemPropertyEditor* editor = new TextItemPropertyEditor(QApplication::activeWindow());
|
||||
editor->setAttribute(Qt::WA_DeleteOnClose);
|
||||
editor->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, editor->size(), QApplication::desktop()->availableGeometry()));
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
editor->setGeometry(
|
||||
QStyle::alignedRect(
|
||||
Qt::LeftToRight,
|
||||
Qt::AlignCenter,
|
||||
editor->size(),
|
||||
QGuiApplication::primaryScreen()->geometry()
|
||||
)
|
||||
);
|
||||
#else
|
||||
editor->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, editor->size(), QApplication::desktop()->geometry()));
|
||||
#endif
|
||||
editor->setWindowTitle(m_propertyName);
|
||||
editor->setText(m_lineEdit->text());
|
||||
connect(editor,SIGNAL(accepted()),this,SLOT(editingByEditorFinished()));
|
||||
|
||||
@@ -168,7 +168,11 @@ bool PropertyFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sou
|
||||
{
|
||||
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
|
||||
if (sourceParent.isValid()) return true;
|
||||
#if QT_VERSION >= 0x060000
|
||||
return sourceModel()->data(index).toString().contains(filterRegularExpression());
|
||||
#else
|
||||
return sourceModel()->data(index).toString().contains(filterRegExp());
|
||||
#endif
|
||||
}
|
||||
|
||||
ObjectInspectorWidget::ObjectInspectorWidget(QWidget *parent)
|
||||
@@ -178,7 +182,11 @@ ObjectInspectorWidget::ObjectInspectorWidget(QWidget *parent)
|
||||
m_propertyModel = new BaseDesignPropertyModel(this);
|
||||
m_filterModel = new PropertyFilterModel(this);
|
||||
m_filterModel->setSourceModel(m_propertyModel);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
m_filterModel->setFilterRegularExpression(QRegularExpression("", QRegularExpression::CaseInsensitiveOption));
|
||||
#else
|
||||
m_filterModel->setFilterRegExp(QRegExp("", Qt::CaseInsensitive, QRegExp::FixedString));
|
||||
#endif
|
||||
m_objectInspectorView->setModel(m_filterModel);
|
||||
QVBoxLayout* l = new QVBoxLayout();
|
||||
QLineEdit* le = new QLineEdit(this);
|
||||
@@ -209,7 +217,16 @@ ObjectInspectorWidget::ObjectInspectorWidget(QWidget *parent)
|
||||
h->addWidget(settingButton);
|
||||
l->addLayout(h);
|
||||
l->addWidget(m_objectInspectorView);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
l->setContentsMargins(
|
||||
Const::DOCKWIDGET_MARGINS,
|
||||
Const::DOCKWIDGET_MARGINS,
|
||||
Const::DOCKWIDGET_MARGINS,
|
||||
Const::DOCKWIDGET_MARGINS
|
||||
);
|
||||
#else
|
||||
l->setMargin(Const::DOCKWIDGET_MARGINS);
|
||||
#endif
|
||||
l->setSpacing(2);
|
||||
this->setLayout(l);
|
||||
}
|
||||
@@ -305,7 +322,11 @@ void ObjectInspectorWidget::updateProperty(const QString &propertyName)
|
||||
void ObjectInspectorWidget::slotFilterTextChanged(const QString &filter)
|
||||
{
|
||||
if (m_filterModel)
|
||||
#if QT_VERSION >= 0x060000
|
||||
m_filterModel->setFilterRegularExpression(QRegularExpression(filter, QRegularExpression::CaseInsensitiveOption));
|
||||
#else
|
||||
m_filterModel->setFilterRegExp(QRegExp(filter, Qt::CaseInsensitive, QRegExp::FixedString));
|
||||
#endif
|
||||
}
|
||||
|
||||
void ObjectInspectorWidget::slotTranslatePropertiesChecked(bool value)
|
||||
|
||||
@@ -38,11 +38,20 @@ ObjectBrowser::ObjectBrowser(QWidget *parent)
|
||||
:QWidget(parent), m_designerWidget(NULL), m_mainWindow(NULL),
|
||||
m_changingItemSelection(false), m_movingItem(false)
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
setLayout(layout);
|
||||
layout->setMargin(Const::DOCKWIDGET_MARGINS);
|
||||
QVBoxLayout *l = new QVBoxLayout(this);
|
||||
setLayout(l);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
l->setContentsMargins(
|
||||
Const::DOCKWIDGET_MARGINS,
|
||||
Const::DOCKWIDGET_MARGINS,
|
||||
Const::DOCKWIDGET_MARGINS,
|
||||
Const::DOCKWIDGET_MARGINS
|
||||
);
|
||||
#else
|
||||
l->setMargin(Const::DOCKWIDGET_MARGINS);
|
||||
#endif
|
||||
m_treeView = new QTreeWidget(this);
|
||||
layout->addWidget(m_treeView);
|
||||
l->addWidget(m_treeView);
|
||||
m_treeView->headerItem()->setText(0,tr("Objects"));
|
||||
m_treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,16 @@ ScriptBrowser::ScriptBrowser(QWidget *parent) :
|
||||
ui(new Ui::ScriptBrowser)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
ui->verticalLayout->setContentsMargins(
|
||||
Const::DOCKWIDGET_MARGINS,
|
||||
Const::DOCKWIDGET_MARGINS,
|
||||
Const::DOCKWIDGET_MARGINS,
|
||||
Const::DOCKWIDGET_MARGINS
|
||||
);
|
||||
#else
|
||||
ui->verticalLayout->setMargin(Const::DOCKWIDGET_MARGINS);
|
||||
#endif
|
||||
#ifndef HAVE_UI_LOADER
|
||||
ui->tpDialogs->setVisible(false);
|
||||
ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tpDialogs));
|
||||
|
||||
@@ -47,7 +47,11 @@ void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent* event)
|
||||
QStyleOption option;
|
||||
option.initFrom(this);
|
||||
//painter.fillRect(event->rect(), QPalette().background().color());
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
QColor bg = option.palette.window().color().darker(150);
|
||||
#else
|
||||
QColor bg = option.palette.background().color().darker(150);
|
||||
#endif
|
||||
painter.fillRect(event->rect(), bg);
|
||||
|
||||
QTextBlock block = firstVisibleBlock();
|
||||
@@ -78,8 +82,11 @@ int CodeEditor::lineNumberAreaWidth()
|
||||
max /= 10;
|
||||
++digits;
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
int space = fontMetrics().horizontalAdvance(QLatin1Char('9')) * 2 + fontMetrics().horizontalAdvance(QLatin1Char('9')) * digits;
|
||||
#else
|
||||
int space = fontMetrics().width(QLatin1Char('9'))*2 + fontMetrics().width(QLatin1Char('9')) * digits;
|
||||
#endif
|
||||
|
||||
return space;
|
||||
}
|
||||
@@ -299,8 +306,11 @@ void CodeEditor::highlightCurrentLine()
|
||||
|
||||
if (!isReadOnly()) {
|
||||
QTextEdit::ExtraSelection selection;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
QColor lineColor = QColor(QPalette().window().color()).darker(100);
|
||||
#else
|
||||
QColor lineColor = QColor(QPalette().background().color()).darker(100);
|
||||
#endif
|
||||
|
||||
selection.format.setBackground(lineColor);
|
||||
selection.format.setProperty(QTextFormat::FullWidthSelection, true);
|
||||
|
||||
@@ -20,7 +20,11 @@ ScriptEditor::ScriptEditor(QWidget *parent) :
|
||||
setFocusProxy(ui->textEdit);
|
||||
m_completer = new ReportStructureCompleater(this);
|
||||
ui->textEdit->setCompleter(m_completer);
|
||||
ui->textEdit->setTabStopWidth(ui->textEdit->fontMetrics().width("0")*m_tabIndention);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
ui->textEdit->setTabStopDistance(ui->textEdit->fontMetrics().horizontalAdvance("0") * m_tabIndention);
|
||||
#else
|
||||
ui->textEdit->setTabStopWidth(ui->textEdit->fontMetrics().width("0") * m_tabIndention);
|
||||
#endif
|
||||
connect(ui->splitter, SIGNAL(splitterMoved(int,int)), this, SIGNAL(splitterMoved(int,int)));
|
||||
connect(ui->textEdit, SIGNAL(textChanged()), this, SIGNAL(textChanged()));
|
||||
}
|
||||
@@ -86,7 +90,11 @@ void ScriptEditor::setPageBand(BandDesignIntf* band)
|
||||
void ScriptEditor::setTabIndention(int charCount)
|
||||
{
|
||||
if (m_tabIndention != charCount){
|
||||
ui->textEdit->setTabStopWidth(ui->textEdit->fontMetrics().width("W")*charCount);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
|
||||
ui->textEdit->setTabStopDistance(ui->textEdit->fontMetrics().horizontalAdvance("W") * charCount);
|
||||
#else
|
||||
ui->textEdit->setTabStopWidth(ui->textEdit->fontMetrics().width("W") * charCount);
|
||||
#endif
|
||||
m_tabIndention = charCount;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user