mirror of
				https://github.com/fralx/LimeReport.git
				synced 2025-11-04 07:01:26 +03:00 
			
		
		
		
	Finish 1.6.0
This commit is contained in:
		@@ -140,8 +140,8 @@ OBJECTS_DIR    = $${ARCH_DIR}/$${BUILD_TYPE}/obj
 | 
			
		||||
RCC_DIR        = $${ARCH_DIR}/$${BUILD_TYPE}/rcc
 | 
			
		||||
 | 
			
		||||
LIMEREPORT_VERSION_MAJOR = 1
 | 
			
		||||
LIMEREPORT_VERSION_MINOR = 5
 | 
			
		||||
LIMEREPORT_VERSION_RELEASE = 90
 | 
			
		||||
LIMEREPORT_VERSION_MINOR = 6
 | 
			
		||||
LIMEREPORT_VERSION_RELEASE = 0
 | 
			
		||||
 | 
			
		||||
LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}'
 | 
			
		||||
DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\"
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@
 | 
			
		||||
#include <QSqlDatabase>
 | 
			
		||||
#include <QDir>
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
#include <QDesktopWidget>
 | 
			
		||||
#else
 | 
			
		||||
#include <QScreen>
 | 
			
		||||
@@ -44,7 +44,7 @@ MainWindow::MainWindow(QWidget *parent) :
 | 
			
		||||
    connect(ui->actionOne_to_One, SIGNAL(triggered()), this, SLOT(slotOneToOne()));
 | 
			
		||||
    initPercentCombobox();
 | 
			
		||||
    enableUI(false);
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
    QDesktopWidget *desktop = QApplication::desktop();
 | 
			
		||||
 | 
			
		||||
    int screenWidth = desktop->screenGeometry().width();
 | 
			
		||||
 
 | 
			
		||||
@@ -67,7 +67,7 @@ QString replaceHTMLSymbols(const QString &value)
 | 
			
		||||
    return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
QVector<QString> normalizeCaptures(const QRegExp& reg){
 | 
			
		||||
#else
 | 
			
		||||
QVector<QString> normalizeCaptures(const QRegularExpressionMatch ®){
 | 
			
		||||
 
 | 
			
		||||
@@ -104,10 +104,10 @@ namespace Const{
 | 
			
		||||
    QString extractClassName(QString className);
 | 
			
		||||
    QString escapeSimbols(const QString& value);
 | 
			
		||||
    QString replaceHTMLSymbols(const QString &value);
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
    QVector<QString> normalizeCaptures(const QRegExp ®);
 | 
			
		||||
#else
 | 
			
		||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
 | 
			
		||||
    QVector<QString> normalizeCaptures(const QRegularExpressionMatch ®);
 | 
			
		||||
#else
 | 
			
		||||
    QVector<QString> normalizeCaptures(const QRegExp ®);    
 | 
			
		||||
#endif
 | 
			
		||||
    bool isColorDark(QColor color);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -17,9 +17,14 @@ SUBDIRS += \
 | 
			
		||||
 | 
			
		||||
if(equals(QT_MAJOR_VERSION, 5) : greaterThan(QT_MINOR_VERSION, 1)) | equals(QT_MAJOR_VERSION, 6) {
 | 
			
		||||
    SUBDIRS += console \
 | 
			
		||||
            lrdview
 | 
			
		||||
        lrdview
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if(equals(QT_MAJOR_VERSION, 5) : greaterThan(QT_MINOR_VERSION, 1)) {
 | 
			
		||||
#    SUBDIRS += lrdview
 | 
			
		||||
#}
 | 
			
		||||
 | 
			
		||||
!CONFIG(embedded_designer) : !CONFIG(static_build) {
 | 
			
		||||
    SUBDIRS += designer_plugin
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -46,6 +46,7 @@ public:
 | 
			
		||||
    void setPrintOnFirstPage(bool printOnFirstPage);
 | 
			
		||||
    bool printOnLastPage() const;
 | 
			
		||||
    void setPrintOnLastPage(bool printOnLastPage);
 | 
			
		||||
    bool isHeader() const{return true;}
 | 
			
		||||
protected:
 | 
			
		||||
    virtual BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
 | 
			
		||||
    QColor bandColor() const;
 | 
			
		||||
 
 | 
			
		||||
@@ -45,6 +45,7 @@ public:
 | 
			
		||||
    virtual BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
 | 
			
		||||
    bool printBeforePageHeader() const;
 | 
			
		||||
    void setPrintBeforePageHeader(bool printBeforePageHeader);
 | 
			
		||||
    bool isHeader() const {return true;}
 | 
			
		||||
protected:
 | 
			
		||||
    QColor bandColor() const;
 | 
			
		||||
    bool m_printBeforePageHeader;
 | 
			
		||||
 
 | 
			
		||||
@@ -103,9 +103,11 @@ void SizeHandleRect::mousePressEvent(QMouseEvent *e)
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    m_startSize = m_curSize = m_resizable->size();
 | 
			
		||||
#if QT_VERSION < QT_VERSION_CHECK(5,15,3)
 | 
			
		||||
    m_startPos = m_curPos = m_resizable->mapFromGlobal(e->globalPos());
 | 
			
		||||
    if (debugSizeHandle)
 | 
			
		||||
        qDebug() << "SizeHandleRect::mousePressEvent" << m_startSize << m_startPos << m_curPos;
 | 
			
		||||
#else
 | 
			
		||||
    m_startPos = m_curPos = m_resizable->mapFromGlobal(e->globalPosition());
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -136,7 +138,7 @@ void SizeHandleRect::mouseMoveEvent(QMouseEvent *e)
 | 
			
		||||
        delta = QSize(0, 0);
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
    if (delta != QSize(0, 0))
 | 
			
		||||
    if (delta != QSizeF(0, 0))
 | 
			
		||||
        tryResize(delta);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -66,8 +66,15 @@ private:
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    const Direction m_dir;
 | 
			
		||||
#if QT_VERSION < QT_VERSION_CHECK(5,12,3)
 | 
			
		||||
    QPoint m_startPos;    
 | 
			
		||||
    QPoint m_curPos;
 | 
			
		||||
#else
 | 
			
		||||
    QPointF m_startPos;
 | 
			
		||||
    QPointF m_curPos;
 | 
			
		||||
//    QSizeF m_startSize;
 | 
			
		||||
//    QSizeF m_curSize;
 | 
			
		||||
#endif
 | 
			
		||||
    QSize m_startSize;
 | 
			
		||||
    QSize m_curSize;
 | 
			
		||||
    QWidget *m_resizable;
 | 
			
		||||
 
 | 
			
		||||
@@ -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();
 | 
			
		||||
 
 | 
			
		||||
@@ -722,7 +722,7 @@ QFont AbstractSeriesChart::adaptLabelsFont(QRectF rect, QFont font)
 | 
			
		||||
    QFontMetrics fm(font);
 | 
			
		||||
 | 
			
		||||
    foreach(QString label, m_chartItem->labels()){
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
        foreach (QString currentWord, label.split(QRegExp("\\W+"))){
 | 
			
		||||
#else
 | 
			
		||||
        foreach (QString currentWord, label.split(QRegularExpression("\\W+"))){
 | 
			
		||||
 
 | 
			
		||||
@@ -110,7 +110,7 @@ void HtmlContext::parseSymbs(QString text)
 | 
			
		||||
        text.remove(pos,rx.matchedLength());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    foreach(QString pattern,m_symbPatterns){
 | 
			
		||||
    foreach(QString pattern, m_symbPatterns){
 | 
			
		||||
        rx.setPattern(pattern);
 | 
			
		||||
        while (text.contains(rx)){
 | 
			
		||||
            int pos=rx.indexIn(text);
 | 
			
		||||
@@ -120,6 +120,13 @@ void HtmlContext::parseSymbs(QString text)
 | 
			
		||||
    }
 | 
			
		||||
#else
 | 
			
		||||
    QRegularExpression rx("<[^<]*>");
 | 
			
		||||
 | 
			
		||||
    while (text.contains(rx)){
 | 
			
		||||
        int pos=text.indexOf(rx); //rx.indexIn(text);
 | 
			
		||||
        if (rx.cap().compare("<br>",Qt::CaseInsensitive)==0)
 | 
			
		||||
            m_symbs.append(new Symb(rx.cap(),pos));
 | 
			
		||||
        text.remove(pos,rx.matchedLength());
 | 
			
		||||
    }
 | 
			
		||||
    // TODO: Qt6 port
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
@@ -191,43 +198,43 @@ bool HtmlContext::isVectorEqual(QVector<Tag *> source, QVector<Tag *> dest)
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString HtmlContext::extendTextByTags(QString text, int pos)
 | 
			
		||||
{
 | 
			
		||||
    QString curText="";
 | 
			
		||||
    QVector<Tag*> curTags=tagsAt(pos);
 | 
			
		||||
    for(int i=0;i<curTags.count();i++){
 | 
			
		||||
        curText+='<'+curTags.at(i)->tagText()+'>';
 | 
			
		||||
    }
 | 
			
		||||
//QString HtmlContext::extendTextByTags(QString text, int pos)
 | 
			
		||||
//{
 | 
			
		||||
//    QString curText="";
 | 
			
		||||
//    QVector<Tag*> curTags=tagsAt(pos);
 | 
			
		||||
//    for(int i=0;i<curTags.count();i++){
 | 
			
		||||
//        curText+='<'+curTags.at(i)->tagText()+'>';
 | 
			
		||||
//    }
 | 
			
		||||
 | 
			
		||||
    for(int i=0;i<text.length();i++,pos++){
 | 
			
		||||
        QVector<Tag*> tagsAtPos=tagsAt(pos);
 | 
			
		||||
        if (!HtmlContext::isVectorEqual(curTags,tagsAtPos)){
 | 
			
		||||
            QVector<TagDiff> diffs=HtmlContext::tagVectDiff(curTags,tagsAtPos);
 | 
			
		||||
            foreach(TagDiff diff,diffs){
 | 
			
		||||
                if (diff.direction==TagDiff::Inner){
 | 
			
		||||
                    curText+='<'+diff.tag->tagText()+'>';
 | 
			
		||||
                    curTags.append(diff.tag);
 | 
			
		||||
                }
 | 
			
		||||
                else{
 | 
			
		||||
                    curText+="</"+HtmlContext::extractWord(diff.tag->tagText(),1)+'>';
 | 
			
		||||
                    curTags.remove(curTags.indexOf(diff.tag));
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        Symb s=symbAt(pos);
 | 
			
		||||
        if (s.isValid()){
 | 
			
		||||
            if (s.isTag()) curText+=s.text()+text.at(i);
 | 
			
		||||
            else curText+=s.text();
 | 
			
		||||
        } else curText+=text.at(i);
 | 
			
		||||
    }
 | 
			
		||||
//    for(int i=0;i<text.length();i++,pos++){
 | 
			
		||||
//        QVector<Tag*> tagsAtPos=tagsAt(pos);
 | 
			
		||||
//        if (!HtmlContext::isVectorEqual(curTags,tagsAtPos)){
 | 
			
		||||
//            QVector<TagDiff> diffs=HtmlContext::tagVectDiff(curTags,tagsAtPos);
 | 
			
		||||
//            foreach(TagDiff diff,diffs){
 | 
			
		||||
//                if (diff.direction==TagDiff::Inner){
 | 
			
		||||
//                    curText+='<'+diff.tag->tagText()+'>';
 | 
			
		||||
//                    curTags.append(diff.tag);
 | 
			
		||||
//                }
 | 
			
		||||
//                else{
 | 
			
		||||
//                    curText+="</"+HtmlContext::extractWord(diff.tag->tagText(),1)+'>';
 | 
			
		||||
//                    curTags.remove(curTags.indexOf(diff.tag));
 | 
			
		||||
//                }
 | 
			
		||||
//            }
 | 
			
		||||
//        }
 | 
			
		||||
//        Symb s=symbAt(pos);
 | 
			
		||||
//        if (s.isValid()){
 | 
			
		||||
//            if (s.isTag()) curText+=s.text()+text.at(i);
 | 
			
		||||
//            else curText+=s.text();
 | 
			
		||||
//        } else curText+=text.at(i);
 | 
			
		||||
//    }
 | 
			
		||||
 | 
			
		||||
    curTags=tagsAt(pos);
 | 
			
		||||
    for(int i=0;i<curTags.count();i++){
 | 
			
		||||
        curText+="</"+HtmlContext::extractWord(curTags.at(i)->tagText(),1)+'>';
 | 
			
		||||
    }
 | 
			
		||||
//    curTags=tagsAt(pos);
 | 
			
		||||
//    for(int i=0;i<curTags.count();i++){
 | 
			
		||||
//        curText+="</"+HtmlContext::extractWord(curTags.at(i)->tagText(),1)+'>';
 | 
			
		||||
//    }
 | 
			
		||||
 | 
			
		||||
    return curText;
 | 
			
		||||
}
 | 
			
		||||
//    return curText;
 | 
			
		||||
//}
 | 
			
		||||
 | 
			
		||||
QVector<Tag *> HtmlContext::tagsAt(int pos)
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -82,7 +82,7 @@ public:
 | 
			
		||||
    static QVector<TagDiff> tagVectDiff(QVector<Tag*> source, QVector<Tag*> dest);
 | 
			
		||||
    static bool isVectorEqual(QVector<Tag*> source, QVector<Tag*> dest);
 | 
			
		||||
    void fillTagVector(QString html);
 | 
			
		||||
    QString extendTextByTags(QString text, int pos);
 | 
			
		||||
    //QString extendTextByTags(QString text, int pos);
 | 
			
		||||
    QVector<Tag *> tagsAt(int pos);
 | 
			
		||||
    Symb symbAt(int pos);
 | 
			
		||||
    void clearTags();
 | 
			
		||||
 
 | 
			
		||||
@@ -360,10 +360,13 @@ void TextItem::updateLayout()
 | 
			
		||||
 | 
			
		||||
bool TextItem::isNeedExpandContent() const
 | 
			
		||||
{   
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
    QRegExp rx("$*\\{[^{]*\\}");
 | 
			
		||||
#else
 | 
			
		||||
    QRegularExpression rx("$*\\{[^{]*\\}");
 | 
			
		||||
    bool result = false;
 | 
			
		||||
    QRegularExpression rx("\\$*\\{[^{]*\\}");
 | 
			
		||||
    result = content().contains(rx) || isContentBackedUp();
 | 
			
		||||
    return result;
 | 
			
		||||
#endif
 | 
			
		||||
    return content().contains(rx) || isContentBackedUp();
 | 
			
		||||
}
 | 
			
		||||
@@ -821,7 +824,7 @@ void TextItem::expandContent(DataSourceManager* dataManager, RenderPass pass)
 | 
			
		||||
{
 | 
			
		||||
    QString context=content();
 | 
			
		||||
    foreach (QString variableName, dataManager->variableNamesByRenderPass(SecondPass)) {
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
        QRegExp rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName));
 | 
			
		||||
#else
 | 
			
		||||
        QRegularExpression rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName));
 | 
			
		||||
 
 | 
			
		||||
@@ -88,9 +88,6 @@
 | 
			
		||||
       <property name="text">
 | 
			
		||||
        <string>Cancel</string>
 | 
			
		||||
       </property>
 | 
			
		||||
       <property name="shortcut">
 | 
			
		||||
        <string>Esc</string>
 | 
			
		||||
       </property>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
    </layout>
 | 
			
		||||
 
 | 
			
		||||
@@ -15,6 +15,7 @@ INCLUDEPATH += \
 | 
			
		||||
    $$REPORT_PATH/scripteditor
 | 
			
		||||
 | 
			
		||||
SOURCES += \
 | 
			
		||||
    $$PWD/scripteditor/lrcompletermodel.cpp \
 | 
			
		||||
    $$REPORT_PATH/bands/lrpageheader.cpp \
 | 
			
		||||
    $$REPORT_PATH/bands/lrpagefooter.cpp \
 | 
			
		||||
    $$REPORT_PATH/bands/lrreportheader.cpp \
 | 
			
		||||
@@ -35,7 +36,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 \
 | 
			
		||||
@@ -90,6 +91,7 @@ CONFIG(svg) {
 | 
			
		||||
 | 
			
		||||
HEADERS += \
 | 
			
		||||
    $$PWD/items/lreditableimageitemintf.h \
 | 
			
		||||
    $$PWD/scripteditor/lrcompletermodel.h \
 | 
			
		||||
    $$REPORT_PATH/base/lrsingleton.h \
 | 
			
		||||
    $$REPORT_PATH/base/lrsimpleabstractfactory.h \
 | 
			
		||||
    $$REPORT_PATH/base/lrattribsabstractfactory.h \
 | 
			
		||||
@@ -121,7 +123,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 \
 | 
			
		||||
 
 | 
			
		||||
@@ -64,7 +64,7 @@ BaseDesignIntf::BaseDesignIntf(const QString &storageTypeName, QObject *owner, Q
 | 
			
		||||
    m_borderLineSize(1),
 | 
			
		||||
    m_BGMode(OpaqueMode),
 | 
			
		||||
    m_opacity(100),
 | 
			
		||||
    m_borderLinesFlags(0),
 | 
			
		||||
    m_borderLinesFlags(BorderLines()),
 | 
			
		||||
    m_storageTypeName(storageTypeName),
 | 
			
		||||
    m_itemMode(DesignMode),
 | 
			
		||||
    m_objectState(ObjectCreated),
 | 
			
		||||
 
 | 
			
		||||
@@ -31,7 +31,7 @@
 | 
			
		||||
#include "lrdatadesignintf.h"
 | 
			
		||||
#include <QStringList>
 | 
			
		||||
#include <QSqlQuery>
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
#include <QRegExp>
 | 
			
		||||
#endif
 | 
			
		||||
#include <QSqlError>
 | 
			
		||||
@@ -423,7 +423,28 @@ QString DataSourceManager::extractField(QString source)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString DataSourceManager::replaceVariables(QString value){
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
 | 
			
		||||
    QRegularExpression rx(Const::VARIABLE_RX);
 | 
			
		||||
    QRegularExpressionMatchIterator iter = rx.globalMatch(value);
 | 
			
		||||
    qsizetype pos = 0;
 | 
			
		||||
    QString result;
 | 
			
		||||
    while (iter.hasNext()) {
 | 
			
		||||
        QRegularExpressionMatch match = iter.next();
 | 
			
		||||
        QString var = match.captured(0);
 | 
			
		||||
        var.remove("$V{");
 | 
			
		||||
        var.remove("}");
 | 
			
		||||
        result += value.mid(pos, match.capturedStart(0));
 | 
			
		||||
        if (variable(var).isValid()){
 | 
			
		||||
            result += variable(var).toString();
 | 
			
		||||
        } else {
 | 
			
		||||
            result += QString(tr("Variable \"%1\" not found!").arg(var));
 | 
			
		||||
        }
 | 
			
		||||
        pos = match.capturedEnd(0);
 | 
			
		||||
    }
 | 
			
		||||
    result += value.mid(pos);
 | 
			
		||||
    return result;
 | 
			
		||||
    // TODO: Qt6 port - done
 | 
			
		||||
#else
 | 
			
		||||
    QRegExp rx(Const::VARIABLE_RX);
 | 
			
		||||
 | 
			
		||||
    if (value.contains(rx)){
 | 
			
		||||
@@ -441,16 +462,54 @@ QString DataSourceManager::replaceVariables(QString value){
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return value;    
 | 
			
		||||
#else
 | 
			
		||||
    QRegularExpression rx(Const::VARIABLE_RX);
 | 
			
		||||
    // TODO: Qt6 port
 | 
			
		||||
#endif
 | 
			
		||||
    return QString();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString DataSourceManager::replaceVariables(QString query, QMap<QString,QString> &aliasesToParam)
 | 
			
		||||
{
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#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);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    // TODO: Qt6 port - done
 | 
			
		||||
#else
 | 
			
		||||
    QRegExp rx(Const::VARIABLE_RX);
 | 
			
		||||
    int curentAliasIndex = 0;
 | 
			
		||||
    if (query.contains(rx)){
 | 
			
		||||
@@ -488,17 +547,44 @@ QString DataSourceManager::replaceVariables(QString query, QMap<QString,QString>
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return query;
 | 
			
		||||
#else
 | 
			
		||||
    QRegularExpression rx(Const::VARIABLE_RX);
 | 
			
		||||
    // TODO: Qt6 port
 | 
			
		||||
#endif
 | 
			
		||||
    return QString();
 | 
			
		||||
    return query;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString DataSourceManager::replaceFields(QString query, QMap<QString,QString> &aliasesToParam, QString masterDatasource)
 | 
			
		||||
{
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
 | 
			
		||||
 | 
			
		||||
    QRegularExpression rx(Const::FIELD_RX);
 | 
			
		||||
    int curentAliasIndex = 0;
 | 
			
		||||
    if (query.contains(rx)){
 | 
			
		||||
        int pos = -1;
 | 
			
		||||
        QRegularExpressionMatch match = rx.match(query);
 | 
			
		||||
        while ((pos=match.capturedStart())!=-1){
 | 
			
		||||
 | 
			
		||||
            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.capturedLength(),":"+extractField(field));
 | 
			
		||||
            match = rx.match(query);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    // TODO: Qt6 port - done
 | 
			
		||||
#else
 | 
			
		||||
    QRegExp rx(Const::FIELD_RX);
 | 
			
		||||
    if (query.contains(rx)){
 | 
			
		||||
        int curentAliasIndex=0;
 | 
			
		||||
@@ -525,11 +611,8 @@ QString DataSourceManager::replaceFields(QString query, QMap<QString,QString> &a
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return query;    
 | 
			
		||||
#else
 | 
			
		||||
    QRegularExpression rx(Const::FIELD_RX);
 | 
			
		||||
    // TODO: Qt6 port
 | 
			
		||||
#endif
 | 
			
		||||
    return QString();
 | 
			
		||||
    return query;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DataSourceManager::setReportVariable(const QString &name, const QVariant &value)
 | 
			
		||||
@@ -1412,7 +1495,7 @@ void DataSourceManager::invalidateQueriesContainsVariable(const QString& variabl
 | 
			
		||||
            foreach (const QString& datasourceName, dataSourceNames()){
 | 
			
		||||
                QueryHolder* holder = dynamic_cast<QueryHolder*>(m_datasources.value(datasourceName));
 | 
			
		||||
                if (holder){
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
                    QRegExp rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName));
 | 
			
		||||
#else
 | 
			
		||||
                    QRegularExpression rx(QString(Const::NAMED_VARIABLE_RX).arg(variableName));
 | 
			
		||||
 
 | 
			
		||||
@@ -67,10 +67,10 @@ QString replaceHTMLSymbols(const QString &value)
 | 
			
		||||
    return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
QVector<QString> normalizeCaptures(const QRegExp& reg){
 | 
			
		||||
#else
 | 
			
		||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
 | 
			
		||||
QVector<QString> normalizeCaptures(const QRegularExpressionMatch& reg){
 | 
			
		||||
#else
 | 
			
		||||
QVector<QString> normalizeCaptures(const QRegExp& reg){
 | 
			
		||||
#endif
 | 
			
		||||
    QVector<QString> result;
 | 
			
		||||
    foreach (QString cap, reg.capturedTexts()) {
 | 
			
		||||
 
 | 
			
		||||
@@ -104,10 +104,10 @@ namespace Const{
 | 
			
		||||
    QString extractClassName(QString className);
 | 
			
		||||
    QString escapeSimbols(const QString& value);
 | 
			
		||||
    QString replaceHTMLSymbols(const QString &value);
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
    QVector<QString> normalizeCaptures(const QRegExp ®);
 | 
			
		||||
#else
 | 
			
		||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
 | 
			
		||||
    QVector<QString> normalizeCaptures(const QRegularExpressionMatch ®);
 | 
			
		||||
#else
 | 
			
		||||
    QVector<QString> normalizeCaptures(const QRegExp ®);    
 | 
			
		||||
#endif
 | 
			
		||||
    bool isColorDark(QColor color);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -53,7 +53,7 @@ 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 < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
      if (wheel_event->orientation() == Qt::Vertical) {
 | 
			
		||||
        double angle = wheel_event->delta();
 | 
			
		||||
        double factor = qPow(m_zoomFactorBase, angle);
 | 
			
		||||
 
 | 
			
		||||
@@ -34,7 +34,7 @@
 | 
			
		||||
#include "lrscriptenginemanager.h"
 | 
			
		||||
#include "lrpageitemdesignintf.h"
 | 
			
		||||
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
#include <QRegExp>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@@ -44,7 +44,7 @@ void GroupFunction::slotBandRendered(BandDesignIntf *band)
 | 
			
		||||
{
 | 
			
		||||
    ScriptEngineManager& sm = ScriptEngineManager::instance();
 | 
			
		||||
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
    QRegExp rxField(Const::FIELD_RX);
 | 
			
		||||
    QRegExp rxVar(Const::VARIABLE_RX);
 | 
			
		||||
#else
 | 
			
		||||
@@ -54,7 +54,7 @@ void GroupFunction::slotBandRendered(BandDesignIntf *band)
 | 
			
		||||
 | 
			
		||||
    switch (m_dataType){
 | 
			
		||||
    case Field:{
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
        if (rxField.indexIn(m_data) != -1){
 | 
			
		||||
            QString field = rxField.cap(1);
 | 
			
		||||
#else
 | 
			
		||||
@@ -72,7 +72,7 @@ void GroupFunction::slotBandRendered(BandDesignIntf *band)
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
    case Variable:{
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
        if (rxVar.indexIn(m_data) != -1){
 | 
			
		||||
            QString var = rxVar.cap(1);
 | 
			
		||||
#else
 | 
			
		||||
@@ -149,7 +149,7 @@ QVariant GroupFunction::multiplication(QVariant value1, QVariant value2)
 | 
			
		||||
GroupFunction::GroupFunction(const QString &expression, const QString &dataBandName, DataSourceManager* dataManager)
 | 
			
		||||
    :m_data(expression), m_dataBandName(dataBandName), m_dataManager(dataManager), m_isValid(true), m_errorMessage("")
 | 
			
		||||
{
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
    QRegExp rxField(Const::FIELD_RX,Qt::CaseInsensitive);
 | 
			
		||||
    QRegExp rxVariable(Const::VARIABLE_RX,Qt::CaseInsensitive);
 | 
			
		||||
    QRegExp rxScript(Const::SCRIPT_RX,Qt::CaseInsensitive);
 | 
			
		||||
@@ -158,7 +158,7 @@ GroupFunction::GroupFunction(const QString &expression, const QString &dataBandN
 | 
			
		||||
    QRegularExpression rxVariable(Const::VARIABLE_RX, QRegularExpression::CaseInsensitiveOption);
 | 
			
		||||
    QRegularExpression rxScript(Const::SCRIPT_RX, QRegularExpression::CaseInsensitiveOption);
 | 
			
		||||
#endif
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
    if (rxScript.indexIn(expression) != -1){
 | 
			
		||||
#else
 | 
			
		||||
    QRegularExpressionMatch matchScript = rxScript.match(expression);
 | 
			
		||||
@@ -168,7 +168,7 @@ GroupFunction::GroupFunction(const QString &expression, const QString &dataBandN
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
    if (rxField.indexIn(expression) != -1){
 | 
			
		||||
#else
 | 
			
		||||
    QRegularExpressionMatch matchField = rxField.match(expression);
 | 
			
		||||
@@ -178,7 +178,7 @@ GroupFunction::GroupFunction(const QString &expression, const QString &dataBandN
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
    if (rxVariable.indexIn(expression) != -1){
 | 
			
		||||
#else
 | 
			
		||||
    QRegularExpressionMatch matchVariable = rxVariable.match(expression);
 | 
			
		||||
 
 | 
			
		||||
@@ -35,7 +35,7 @@
 | 
			
		||||
#include "lrglobal.h"
 | 
			
		||||
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
#include <QRegExp>
 | 
			
		||||
#endif
 | 
			
		||||
#include <QVariant>
 | 
			
		||||
 
 | 
			
		||||
@@ -753,7 +753,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 QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
        if (isVar) data = data.remove(QRegExp("  \\[.*\\]"));
 | 
			
		||||
#else
 | 
			
		||||
        if (isVar) data = data.remove(QRegularExpression("  \\[.*\\]"));
 | 
			
		||||
@@ -762,7 +762,7 @@ void PageDesignIntf::dropEvent(QGraphicsSceneDragDropEvent* event)
 | 
			
		||||
        if (!isVar){
 | 
			
		||||
            BandDesignIntf* parentBand = dynamic_cast<BandDesignIntf*>(ti->parentItem());
 | 
			
		||||
            if (parentBand && parentBand->datasourceName().isEmpty()){
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
                QRegExp dataSource("(?:\\$D\\{\\s*(.*)\\..*\\})");
 | 
			
		||||
                if (dataSource.indexIn(data) != -1){
 | 
			
		||||
                    parentBand->setProperty("datasource",dataSource.cap(1));
 | 
			
		||||
 
 | 
			
		||||
@@ -711,7 +711,7 @@ QSizeF PageItemDesignIntf::getRectByPageSize(const PageSize& size)
 | 
			
		||||
    if (size != Custom) {
 | 
			
		||||
        QPrinter printer;
 | 
			
		||||
        printer.setOutputFormat(QPrinter::PdfFormat);
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
        printer.setOrientation((QPrinter::Orientation)pageOrientation());
 | 
			
		||||
        printer.setPaperSize((QPrinter::PageSize)size);
 | 
			
		||||
        return QSizeF(printer.paperSize(QPrinter::Millimeter).width() * 10,
 | 
			
		||||
 
 | 
			
		||||
@@ -66,7 +66,7 @@ class PageItemDesignIntf : public ItemsContainerDesignInft
 | 
			
		||||
    Q_PROPERTY(bool mixWithPriorPage READ mixWithPriorPage WRITE setMixWithPriorPage)
 | 
			
		||||
    friend class ReportRender;
 | 
			
		||||
public:
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
    enum Orientation { Portrait = QPrinter::Portrait, Landscape = QPrinter::Landscape };
 | 
			
		||||
 | 
			
		||||
    enum PrintBehavior {Scale, Split};
 | 
			
		||||
 
 | 
			
		||||
@@ -143,7 +143,7 @@ void PreviewReportWidget::initPreview()
 | 
			
		||||
{
 | 
			
		||||
    if (ui->graphicsView->scene()!=d_ptr->m_previewPage)
 | 
			
		||||
        ui->graphicsView->setScene(d_ptr->m_previewPage);
 | 
			
		||||
    #if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
    ui->graphicsView->resetMatrix();
 | 
			
		||||
#else
 | 
			
		||||
    ui->graphicsView->resetTransform();
 | 
			
		||||
@@ -299,7 +299,7 @@ void PreviewReportWidget::saveToFile()
 | 
			
		||||
void PreviewReportWidget::setScalePercent(int percent)
 | 
			
		||||
{
 | 
			
		||||
    m_scaleChanging = true;
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
    ui->graphicsView->resetMatrix();
 | 
			
		||||
#else
 | 
			
		||||
    ui->graphicsView->resetTransform();
 | 
			
		||||
@@ -482,7 +482,7 @@ void PreviewReportWidget::reportEngineDestroyed(QObject *object)
 | 
			
		||||
 | 
			
		||||
void PreviewReportWidget::slotZoomed(double )
 | 
			
		||||
{
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
    d_ptr->m_scalePercent = ui->graphicsView->matrix().m11()*100;
 | 
			
		||||
#else
 | 
			
		||||
    d_ptr->m_scalePercent = ui->graphicsView->transform().m11()*100;
 | 
			
		||||
 
 | 
			
		||||
@@ -41,7 +41,7 @@
 | 
			
		||||
#include <QPrintDialog>
 | 
			
		||||
#include <QFileDialog>
 | 
			
		||||
#include <QScrollBar>
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
#include <QDesktopWidget>
 | 
			
		||||
#else
 | 
			
		||||
#include <QScreen>
 | 
			
		||||
@@ -119,7 +119,11 @@ PreviewReportWindow::PreviewReportWindow(ReportEngine *report, QWidget *parent,
 | 
			
		||||
    
 | 
			
		||||
    connect(ui->actionShowMessages, SIGNAL(triggered()), this, SLOT(slotShowErrors()));
 | 
			
		||||
    connect(m_previewReportWidget, SIGNAL(scalePercentChanged(int)), this, SLOT(slotScalePercentChanged(int)));
 | 
			
		||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
 | 
			
		||||
    connect(m_scalePercent, SIGNAL(currentTextChanged(QString)), this, SLOT(scaleComboboxChanged(QString)));
 | 
			
		||||
#else
 | 
			
		||||
    connect(m_scalePercent, SIGNAL(currentIndexChanged(QString)), this, SLOT(scaleComboboxChanged(QString)));
 | 
			
		||||
#endif
 | 
			
		||||
    connect(m_previewReportWidget, SIGNAL(pageChanged(int)), this, SLOT(slotCurrentPageChanged(int)));
 | 
			
		||||
    connect(m_previewReportWidget, SIGNAL(itemInserted(LimeReport::PageDesignIntf*, QPointF, QString)),
 | 
			
		||||
            this, SLOT(slotItemInserted(LimeReport::PageDesignIntf*, QPointF, QString)));
 | 
			
		||||
@@ -143,7 +147,7 @@ void PreviewReportWindow::restoreSetting()
 | 
			
		||||
    if (v.isValid()){
 | 
			
		||||
        restoreGeometry(v.toByteArray());
 | 
			
		||||
    } else {
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
        QDesktopWidget *desktop = QApplication::desktop();
 | 
			
		||||
 | 
			
		||||
        int screenWidth = desktop->screenGeometry().width();
 | 
			
		||||
 
 | 
			
		||||
@@ -1058,7 +1058,7 @@ bool ReportDesignWidget::eventFilter(QObject *target, QEvent *event)
 | 
			
		||||
    if (event->type() == QEvent::Wheel){
 | 
			
		||||
        QWheelEvent* we = dynamic_cast<QWheelEvent*>(event);
 | 
			
		||||
        if (QApplication::keyboardModifiers()==Qt::ControlModifier){
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if QT_VERSION < QT_VERSION_CHECK(5,12,3)
 | 
			
		||||
            if(we->delta()<0) scale(1.2,1.2);
 | 
			
		||||
            else scale(1/1.2,1/1.2);
 | 
			
		||||
#else
 | 
			
		||||
 
 | 
			
		||||
@@ -39,7 +39,7 @@
 | 
			
		||||
#include <QMenuBar>
 | 
			
		||||
#include <QCheckBox>
 | 
			
		||||
#include <QVBoxLayout>
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
#include <QDesktopWidget>
 | 
			
		||||
#else
 | 
			
		||||
#include <QScreen>
 | 
			
		||||
@@ -169,7 +169,7 @@ void ReportDesignWindow::createActions()
 | 
			
		||||
    m_editModeAction->setIcon(QIcon(":/report/images/editMode"));
 | 
			
		||||
    m_editModeAction->setCheckable(true);
 | 
			
		||||
    m_editModeAction->setChecked(true);
 | 
			
		||||
    m_editModeAction->setShortcut(QKeySequence(Qt::Key_Escape));
 | 
			
		||||
    //m_editModeAction->setShortcut(QKeySequence(Qt::Key_Escape));
 | 
			
		||||
    connect(m_editModeAction,SIGNAL(triggered()),this,SLOT(slotEditMode()));
 | 
			
		||||
 | 
			
		||||
    m_undoAction = new QAction(tr("Undo"),this);
 | 
			
		||||
@@ -502,8 +502,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()
 | 
			
		||||
@@ -530,7 +533,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());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -744,6 +751,11 @@ void ReportDesignWindow::setDocWidgetsVisibility(bool visible)
 | 
			
		||||
        hideDockWidgets(Qt::RightDockWidgetArea,!visible);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ReportDesignWindow::keyPressEvent(QKeyEvent *event)
 | 
			
		||||
{
 | 
			
		||||
    if (event->key()==Qt::Key_Escape){m_editModeAction->trigger();}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ReportDesignWindow::writeState()
 | 
			
		||||
{
 | 
			
		||||
    settings()->beginGroup("DesignerWindow");
 | 
			
		||||
@@ -837,16 +849,16 @@ void ReportDesignWindow::restoreSetting()
 | 
			
		||||
    if (v.isValid()){
 | 
			
		||||
        restoreGeometry(v.toByteArray());
 | 
			
		||||
    } else {
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
        QDesktopWidget *desktop = QApplication::desktop();
 | 
			
		||||
 | 
			
		||||
        int screenWidth = desktop->screenGeometry().width();
 | 
			
		||||
        int screenHeight = desktop->screenGeometry().height();
 | 
			
		||||
#else
 | 
			
		||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
 | 
			
		||||
        QScreen *screen = QGuiApplication::primaryScreen();
 | 
			
		||||
 | 
			
		||||
        int screenWidth = screen->geometry().width();
 | 
			
		||||
        int screenHeight = screen->geometry().height();
 | 
			
		||||
#else
 | 
			
		||||
        QDesktopWidget *desktop = QApplication::desktop();
 | 
			
		||||
 | 
			
		||||
        int screenWidth = desktop->screenGeometry().width();
 | 
			
		||||
        int screenHeight = desktop->screenGeometry().height();        
 | 
			
		||||
#endif
 | 
			
		||||
        int x = screenWidth * 0.1;
 | 
			
		||||
        int y = screenHeight * 0.1;
 | 
			
		||||
@@ -1540,7 +1552,7 @@ void ReportDesignWindow::slotPageDeleted()
 | 
			
		||||
 | 
			
		||||
void ReportDesignWindow::slotFilterTextChanged(const QString& filter)
 | 
			
		||||
{
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
    m_filterModel->setFilterRegExp(QRegExp(filter, Qt::CaseInsensitive, QRegExp::FixedString));
 | 
			
		||||
#else
 | 
			
		||||
    m_filterModel->setFilterRegularExpression(QRegularExpression(filter, QRegularExpression::CaseInsensitiveOption));
 | 
			
		||||
 
 | 
			
		||||
@@ -138,6 +138,7 @@ protected:
 | 
			
		||||
    void hideDockWidgets(Qt::DockWidgetArea area, bool value);
 | 
			
		||||
    bool isDockAreaVisible(Qt::DockWidgetArea area);
 | 
			
		||||
    void setDocWidgetsVisibility(bool visible);
 | 
			
		||||
    void keyPressEvent(QKeyEvent *event);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    void initReportEditor(ReportEnginePrivate* report);
 | 
			
		||||
 
 | 
			
		||||
@@ -32,7 +32,7 @@
 | 
			
		||||
#include <QPrinterInfo>
 | 
			
		||||
#include <QMessageBox>
 | 
			
		||||
#include <QApplication>
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
#include <QDesktopWidget>
 | 
			
		||||
#else
 | 
			
		||||
#include <QScreen>
 | 
			
		||||
@@ -1324,7 +1324,7 @@ ReportPages ReportEnginePrivate::renderToPages()
 | 
			
		||||
                                m_reportRender->renderPageToPages(page),
 | 
			
		||||
                                page->mixWithPriorPage() ? MixPages : AppendPages
 | 
			
		||||
                             );
 | 
			
		||||
                } else {
 | 
			
		||||
                } else if (page->isTOC()){
 | 
			
		||||
                    startTOCPage = result.count();
 | 
			
		||||
                    pageAfterTOCIndex = i+1;
 | 
			
		||||
                    m_reportRender->createTOCMarker(page->resetPageNumber());
 | 
			
		||||
@@ -1818,7 +1818,7 @@ PrintProcessor::PrintProcessor(QPrinter* printer)
 | 
			
		||||
 | 
			
		||||
bool PrintProcessor::printPage(PageItemDesignIntf::Ptr page)
 | 
			
		||||
{
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
    if (!m_firstPage && !m_painter->isActive()) return false;
 | 
			
		||||
    PageDesignIntf* backupPage = dynamic_cast<PageDesignIntf*>(page->scene());
 | 
			
		||||
 | 
			
		||||
@@ -1949,7 +1949,7 @@ bool PrintProcessor::printPage(PageItemDesignIntf::Ptr page)
 | 
			
		||||
 | 
			
		||||
void PrintProcessor::initPrinter(PageItemDesignIntf* page)
 | 
			
		||||
{
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
    if (page->oldPrintMode()){
 | 
			
		||||
        m_printer->setPageMargins(page->leftMargin(),
 | 
			
		||||
                              page->topMargin(),
 | 
			
		||||
 
 | 
			
		||||
@@ -196,14 +196,19 @@ void ReportRender::analizeItem(ContentItemDesignIntf* contentItem, BandDesignInt
 | 
			
		||||
        QString content = contentItem->content();
 | 
			
		||||
        QVector<QString> functions;
 | 
			
		||||
        foreach(const QString &functionName, m_datasources->groupFunctionNames()){
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
 | 
			
		||||
            QRegularExpression rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
 | 
			
		||||
            rx.setPatternOptions(rx.InvertedGreedinessOption);
 | 
			
		||||
            if(content.indexOf(rx)>=0){
 | 
			
		||||
                functions.append(functionName);
 | 
			
		||||
            }
 | 
			
		||||
            // TODO: Qt6 port - done
 | 
			
		||||
#else
 | 
			
		||||
            QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
 | 
			
		||||
            rx.setMinimal(true);
 | 
			
		||||
            if (rx.indexIn(content)>=0){
 | 
			
		||||
                functions.append(functionName);
 | 
			
		||||
            }            
 | 
			
		||||
#else
 | 
			
		||||
            // TODO: Qt6 port
 | 
			
		||||
#endif
 | 
			
		||||
        }
 | 
			
		||||
        if (functions.size()>0)
 | 
			
		||||
@@ -363,13 +368,18 @@ void ReportRender::clearPageMap()
 | 
			
		||||
bool checkContentItem(ContentItemDesignIntf* item, DataSourceManager* datasources){
 | 
			
		||||
    QString content = item->content();
 | 
			
		||||
    foreach(QString functionName, datasources->groupFunctionNames()){
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
 | 
			
		||||
        QRegularExpression rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
 | 
			
		||||
        rx.setPatternOptions(rx.InvertedGreedinessOption);
 | 
			
		||||
        if(content.indexOf(rx)>=0){
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        // TODO: Qt6 port - done
 | 
			
		||||
#else
 | 
			
		||||
        QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
 | 
			
		||||
        if (rx.indexIn(content)>=0){
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
#else
 | 
			
		||||
        // TODO: Qt6 port
 | 
			
		||||
#endif
 | 
			
		||||
    }
 | 
			
		||||
    return false;
 | 
			
		||||
@@ -390,7 +400,78 @@ bool ReportRender::containsGroupFunctions(BaseDesignIntf *container){
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ReportRender::extractGroupFuntionsFromItem(ContentItemDesignIntf* contentItem, BandDesignIntf* band){
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
 | 
			
		||||
 | 
			
		||||
    if ( contentItem && contentItem->content().contains(QRegularExpression("\\$S\\s*\\{.*\\}"))){
 | 
			
		||||
        foreach(const QString &functionName, m_datasources->groupFunctionNames()){
 | 
			
		||||
            QRegularExpression rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
 | 
			
		||||
            rx.setPatternOptions(rx.InvertedGreedinessOption);
 | 
			
		||||
            QRegularExpression rxName(QString(Const::GROUP_FUNCTION_NAME_RX).arg(functionName));
 | 
			
		||||
            rxName.setPatternOptions(rx.InvertedGreedinessOption);
 | 
			
		||||
 | 
			
		||||
            QRegularExpressionMatch match = rx.match(contentItem->content());
 | 
			
		||||
            if (match.hasMatch()){
 | 
			
		||||
 | 
			
		||||
                QRegularExpressionMatchIterator iter = rx.globalMatch(contentItem->content());
 | 
			
		||||
                while(iter.hasNext()){
 | 
			
		||||
                    match = iter.next();
 | 
			
		||||
                    QVector<QString> captures = normalizeCaptures(match);
 | 
			
		||||
                    if (captures.size() >= 3){
 | 
			
		||||
                        int dsIndex = captures.size() == 3 ? Const::DATASOURCE_INDEX - 1 : Const::DATASOURCE_INDEX;
 | 
			
		||||
                        BandDesignIntf* dataBand = m_patternPageItem->bandByName(captures.at(dsIndex));
 | 
			
		||||
                        if (dataBand){
 | 
			
		||||
                            GroupFunction* gf = datasources()->addGroupFunction(
 | 
			
		||||
                                functionName, captures.at(Const::VALUE_INDEX), band->objectName(), dataBand->objectName()
 | 
			
		||||
                            );
 | 
			
		||||
                            if (gf){
 | 
			
		||||
                                connect(dataBand, SIGNAL(bandRendered(BandDesignIntf*)),
 | 
			
		||||
                                        gf, SLOT(slotBandRendered(BandDesignIntf*)));
 | 
			
		||||
                                connect(dataBand, SIGNAL(bandReRendered(BandDesignIntf*, BandDesignIntf*)),
 | 
			
		||||
                                        gf, SLOT(slotBandReRendered(BandDesignIntf*, BandDesignIntf*)));
 | 
			
		||||
                            }
 | 
			
		||||
                        } else {
 | 
			
		||||
                            GroupFunction* gf = datasources()->addGroupFunction(
 | 
			
		||||
                                functionName, captures.at(Const::VALUE_INDEX), band->objectName(), captures.at(dsIndex)
 | 
			
		||||
                            );
 | 
			
		||||
                            gf->setInvalid(tr("Databand \"%1\" not found").arg(captures.at(dsIndex)));
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
//                int pos = 0;
 | 
			
		||||
//                while ( (pos = match.capturedStart()) != -1){
 | 
			
		||||
//                    QVector<QString> captures = normalizeCaptures(match);
 | 
			
		||||
//                    if (captures.size() >= 3){
 | 
			
		||||
//                        int dsIndex = captures.size() == 3 ? Const::DATASOURCE_INDEX - 1 : Const::DATASOURCE_INDEX;
 | 
			
		||||
//                        BandDesignIntf* dataBand = m_patternPageItem->bandByName(captures.at(dsIndex));
 | 
			
		||||
//                        if (dataBand){
 | 
			
		||||
//                            GroupFunction* gf = datasources()->addGroupFunction(
 | 
			
		||||
//                                functionName, captures.at(Const::VALUE_INDEX), band->objectName(), dataBand->objectName()
 | 
			
		||||
//                            );
 | 
			
		||||
//                            if (gf){
 | 
			
		||||
//                                connect(dataBand, SIGNAL(bandRendered(BandDesignIntf*)),
 | 
			
		||||
//                                        gf, SLOT(slotBandRendered(BandDesignIntf*)));
 | 
			
		||||
//                                connect(dataBand, SIGNAL(bandReRendered(BandDesignIntf*, BandDesignIntf*)),
 | 
			
		||||
//                                        gf, SLOT(slotBandReRendered(BandDesignIntf*, BandDesignIntf*)));
 | 
			
		||||
//                            }
 | 
			
		||||
//                        } else {
 | 
			
		||||
//                            GroupFunction* gf = datasources()->addGroupFunction(
 | 
			
		||||
//                                functionName, captures.at(Const::VALUE_INDEX), band->objectName(), captures.at(dsIndex)
 | 
			
		||||
//                            );
 | 
			
		||||
//                            gf->setInvalid(tr("Databand \"%1\" not found").arg(captures.at(dsIndex)));
 | 
			
		||||
//                        }
 | 
			
		||||
//                    }
 | 
			
		||||
//                    match = rx.match(contentItem->content(), pos + match.capturedLength());
 | 
			
		||||
//                }
 | 
			
		||||
            } else if (contentItem->content().indexOf(rxName)>=0){
 | 
			
		||||
                match = rxName.match(contentItem->content());
 | 
			
		||||
                GroupFunction* gf = datasources()->addGroupFunction(functionName, match.captured(1), band->objectName(), "");
 | 
			
		||||
                gf->setInvalid(tr("Wrong using function %1").arg(functionName));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // TODO: Qt6 port - done
 | 
			
		||||
#else
 | 
			
		||||
    if ( contentItem && contentItem->content().contains(QRegExp("\\$S\\s*\\{.*\\}"))){
 | 
			
		||||
        foreach(const QString &functionName, m_datasources->groupFunctionNames()){
 | 
			
		||||
            QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
 | 
			
		||||
@@ -425,8 +506,6 @@ void ReportRender::extractGroupFuntionsFromItem(ContentItemDesignIntf* contentIt
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }    
 | 
			
		||||
#else
 | 
			
		||||
    // TODO: Qt6 port
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -450,7 +529,35 @@ void ReportRender::replaceGroupFunctionsInItem(ContentItemDesignIntf* contentIte
 | 
			
		||||
        if (m_groupfunctionItems.contains(contentItem->patternName())){
 | 
			
		||||
            QString content = contentItem->content();
 | 
			
		||||
            foreach(QString functionName, m_groupfunctionItems.value(contentItem->patternName())){
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 3)
 | 
			
		||||
 | 
			
		||||
                QRegularExpression rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
 | 
			
		||||
                rx.setPatternOptions(rx.InvertedGreedinessOption);
 | 
			
		||||
                QRegularExpressionMatch match = rx.match(content);
 | 
			
		||||
 | 
			
		||||
                if (match.capturedStart() != -1){
 | 
			
		||||
                    int pos = 0;
 | 
			
		||||
                    while ( (pos = match.capturedStart()) != -1 ){
 | 
			
		||||
                        QVector<QString> captures = normalizeCaptures(match);
 | 
			
		||||
                        if (captures.size() >= 3){
 | 
			
		||||
                            QString expressionIndex = datasources()->putGroupFunctionsExpressions(captures.at(Const::VALUE_INDEX));
 | 
			
		||||
                            if (captures.size()<5){
 | 
			
		||||
                                content.replace(captures.at(0), QString("%1(%2,%3)")
 | 
			
		||||
                                    .arg(functionName).arg('"'+expressionIndex+'"').arg('"'+band->objectName()+'"'));
 | 
			
		||||
                            } else {
 | 
			
		||||
                                content.replace(captures.at(0), QString("%1(%2,%3,%4)").arg(
 | 
			
		||||
                                                    functionName,
 | 
			
		||||
                                                    '"'+expressionIndex+'"',
 | 
			
		||||
                                                    '"'+band->objectName()+'"',
 | 
			
		||||
                                                    captures.at(4)
 | 
			
		||||
                                                ));
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        match = rx.match(content, pos + match.capturedLength());
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                // TODO: Qt6 port - done
 | 
			
		||||
#else
 | 
			
		||||
                QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
 | 
			
		||||
                rx.setMinimal(true);
 | 
			
		||||
                if (rx.indexIn(content)>=0){
 | 
			
		||||
@@ -470,11 +577,9 @@ void ReportRender::replaceGroupFunctionsInItem(ContentItemDesignIntf* contentIte
 | 
			
		||||
                                                ));
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        pos += rx.matchedLength();
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
#else
 | 
			
		||||
                // TODO: Qt6 port
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
            }
 | 
			
		||||
            contentItem->setContent(content);
 | 
			
		||||
@@ -747,11 +852,13 @@ void ReportRender::renderPageHeader(PageItemDesignIntf *patternPage)
 | 
			
		||||
void ReportRender::renderReportHeader(PageItemDesignIntf *patternPage, PageRenderStage stage)
 | 
			
		||||
{
 | 
			
		||||
    BandDesignIntf* band = patternPage->bandByType(BandDesignIntf::ReportHeader);
 | 
			
		||||
    BandDesignIntf* resBand = 0;
 | 
			
		||||
    if (band){
 | 
			
		||||
        if (band->property("printBeforePageHeader").toBool() && stage == BeforePageHeader )
 | 
			
		||||
            renderBand(band, 0, StartNewPageAsNeeded);
 | 
			
		||||
            resBand = renderBand(band, 0, StartNewPageAsNeeded);
 | 
			
		||||
        if (!band->property("printBeforePageHeader").toBool() && stage == AfterPageHeader )
 | 
			
		||||
            renderBand(band, 0, StartNewPageAsNeeded);
 | 
			
		||||
            resBand = renderBand(band, 0, StartNewPageAsNeeded);
 | 
			
		||||
        if (resBand && containsGroupFunctions(band)) m_recalcBands.append(resBand);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -64,6 +64,7 @@ private:
 | 
			
		||||
    PageTranslation* createPageTranslation(PageDesignIntf* page);
 | 
			
		||||
private:
 | 
			
		||||
    QLocale::Language m_language;
 | 
			
		||||
    QLocale::Script m_script;
 | 
			
		||||
    QList<PageTranslation*> m_pagesTranslation;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -354,7 +354,7 @@ void ScriptEngineManager::setDataManager(DataSourceManager *dataManager){
 | 
			
		||||
 | 
			
		||||
QString ScriptEngineManager::expandUserVariables(QString context, RenderPass /* pass */, ExpandType expandType, QVariant &varValue)
 | 
			
		||||
{
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
    QRegExp rx(Const::VARIABLE_RX);
 | 
			
		||||
    if (context.contains(rx)){
 | 
			
		||||
        int pos = 0;
 | 
			
		||||
@@ -452,7 +452,7 @@ QString ScriptEngineManager::expandUserVariables(QString context, RenderPass /*
 | 
			
		||||
 | 
			
		||||
QString ScriptEngineManager::expandDataFields(QString context, ExpandType expandType, QVariant &varValue, QObject *reportItem)
 | 
			
		||||
{
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
    QRegExp rx(Const::FIELD_RX);
 | 
			
		||||
 | 
			
		||||
    if (context.contains(rx)){
 | 
			
		||||
@@ -562,7 +562,7 @@ QString ScriptEngineManager::expandDataFields(QString context, ExpandType expand
 | 
			
		||||
 | 
			
		||||
QString ScriptEngineManager::expandScripts(QString context, QVariant& varValue, QObject *reportItem)
 | 
			
		||||
{
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
    QRegExp rx(Const::SCRIPT_RX);
 | 
			
		||||
 | 
			
		||||
    if (context.contains(rx)){
 | 
			
		||||
@@ -631,7 +631,7 @@ QString ScriptEngineManager::replaceScripts(QString context, QVariant &varValue,
 | 
			
		||||
 | 
			
		||||
QVariant ScriptEngineManager::evaluateScript(const QString& script){
 | 
			
		||||
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
    QRegExp rx(Const::SCRIPT_RX);
 | 
			
		||||
    QVariant varValue;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -34,7 +34,7 @@
 | 
			
		||||
#include <QFocusEvent>
 | 
			
		||||
#include <QApplication>
 | 
			
		||||
#include <QStyle>
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if QT_VERSION < QT_VERSION_CHECK(5,12,3)
 | 
			
		||||
#include <QDesktopWidget>
 | 
			
		||||
#else
 | 
			
		||||
#include <QScreen>
 | 
			
		||||
@@ -70,7 +70,7 @@ void ButtonLineEditor::editButtonClicked()
 | 
			
		||||
{
 | 
			
		||||
    TextItemPropertyEditor* editor = new TextItemPropertyEditor(QApplication::activeWindow());
 | 
			
		||||
    editor->setAttribute(Qt::WA_DeleteOnClose);
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if QT_VERSION < QT_VERSION_CHECK(5,12,3)
 | 
			
		||||
    editor->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, editor->size(), QApplication::desktop()->availableGeometry()));
 | 
			
		||||
#else
 | 
			
		||||
    editor->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, editor->size(), QGuiApplication::screens().first()->availableGeometry()));
 | 
			
		||||
 
 | 
			
		||||
@@ -168,7 +168,7 @@ bool PropertyFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sou
 | 
			
		||||
{
 | 
			
		||||
    QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
 | 
			
		||||
    if (sourceParent.isValid()) return true;    
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
    return sourceModel()->data(index).toString().contains(filterRegExp());
 | 
			
		||||
#else
 | 
			
		||||
    return sourceModel()->data(index).toString().contains(filterRegularExpression());
 | 
			
		||||
@@ -182,7 +182,7 @@ ObjectInspectorWidget::ObjectInspectorWidget(QWidget *parent)
 | 
			
		||||
    m_propertyModel = new BaseDesignPropertyModel(this);
 | 
			
		||||
    m_filterModel = new PropertyFilterModel(this);
 | 
			
		||||
    m_filterModel->setSourceModel(m_propertyModel);
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
    m_filterModel->setFilterRegExp(QRegExp("", Qt::CaseInsensitive, QRegExp::FixedString));
 | 
			
		||||
#else
 | 
			
		||||
    m_filterModel->setFilterRegularExpression(QRegularExpression("", QRegularExpression::CaseInsensitiveOption));
 | 
			
		||||
@@ -314,7 +314,7 @@ void ObjectInspectorWidget::updateProperty(const QString &propertyName)
 | 
			
		||||
void ObjectInspectorWidget::slotFilterTextChanged(const QString &filter)
 | 
			
		||||
{
 | 
			
		||||
    if (m_filterModel)
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
        m_filterModel->setFilterRegExp(QRegExp(filter, Qt::CaseInsensitive, QRegExp::FixedString));
 | 
			
		||||
#else
 | 
			
		||||
        m_filterModel->setFilterRegularExpression(QRegularExpression(filter, QRegularExpression::CaseInsensitiveOption));
 | 
			
		||||
 
 | 
			
		||||
@@ -15,7 +15,7 @@
 | 
			
		||||
namespace LimeReport{
 | 
			
		||||
 | 
			
		||||
CodeEditor::CodeEditor(QWidget *parent)
 | 
			
		||||
    : QPlainTextEdit(parent), m_compleater(0)
 | 
			
		||||
    : QPlainTextEdit(parent), m_completer(0)
 | 
			
		||||
{
 | 
			
		||||
    lineNumberArea = new LineNumberArea(this);
 | 
			
		||||
 | 
			
		||||
@@ -33,12 +33,13 @@ CodeEditor::CodeEditor(QWidget *parent)
 | 
			
		||||
void CodeEditor::setCompleter(QCompleter *value)
 | 
			
		||||
{
 | 
			
		||||
    if (value) disconnect(value,0,this,0);
 | 
			
		||||
    m_compleater = value;
 | 
			
		||||
    if (!m_compleater) return;
 | 
			
		||||
    m_compleater->setWidget(this);
 | 
			
		||||
    m_compleater->setCompletionMode(QCompleter::PopupCompletion);
 | 
			
		||||
    m_compleater->setCaseSensitivity(Qt::CaseInsensitive);
 | 
			
		||||
    connect(m_compleater,SIGNAL(activated(QString)),this,SLOT(insertCompletion(QString)));
 | 
			
		||||
    m_completer = value;
 | 
			
		||||
    if (!m_completer) return;
 | 
			
		||||
    m_completer->setWidget(this);
 | 
			
		||||
    m_completer->setCompletionMode(QCompleter::PopupCompletion);
 | 
			
		||||
    m_completer->setCaseSensitivity(Qt::CaseInsensitive);
 | 
			
		||||
 | 
			
		||||
    connect(m_completer,SIGNAL(activated(QString)),this,SLOT(insertCompletion(QString)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent* event)
 | 
			
		||||
@@ -86,7 +87,7 @@ int CodeEditor::lineNumberAreaWidth()
 | 
			
		||||
 | 
			
		||||
void CodeEditor::keyPressEvent(QKeyEvent *e)
 | 
			
		||||
{
 | 
			
		||||
    if (m_compleater && m_compleater->popup()->isVisible()) {
 | 
			
		||||
    if (m_completer && m_completer->popup()->isVisible()) {
 | 
			
		||||
        switch (e->key()) {
 | 
			
		||||
        case Qt::Key_Enter:
 | 
			
		||||
        case Qt::Key_Return:
 | 
			
		||||
@@ -105,10 +106,10 @@ void CodeEditor::keyPressEvent(QKeyEvent *e)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    bool isShortcut = ((e->modifiers() & Qt::ControlModifier) && e->key() == Qt::Key_Space);
 | 
			
		||||
    if (!m_compleater || !isShortcut) QPlainTextEdit::keyPressEvent(e);
 | 
			
		||||
    if (!m_completer || !isShortcut) QPlainTextEdit::keyPressEvent(e);
 | 
			
		||||
 | 
			
		||||
    const bool ctrlOrShift = e->modifiers() & (Qt::ControlModifier | Qt::ShiftModifier);
 | 
			
		||||
    if (!m_compleater || (ctrlOrShift && e->text().isEmpty()))
 | 
			
		||||
    if (!m_completer || (ctrlOrShift && e->text().isEmpty()))
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    bool hasModifier = (e->modifiers() != Qt::NoModifier) && !ctrlOrShift;
 | 
			
		||||
@@ -119,36 +120,36 @@ void CodeEditor::keyPressEvent(QKeyEvent *e)
 | 
			
		||||
            || Const::EOW.contains(e->text().right(1)))
 | 
			
		||||
       )
 | 
			
		||||
    {
 | 
			
		||||
        m_compleater->popup()->hide();
 | 
			
		||||
        m_completer->popup()->hide();
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (completionPrefix != m_compleater->completionPrefix()) {
 | 
			
		||||
        m_compleater->setCompletionPrefix(completionPrefix);
 | 
			
		||||
        m_compleater->popup()->setCurrentIndex(m_compleater->completionModel()->index(0, 0));
 | 
			
		||||
    if (completionPrefix != m_completer->completionPrefix()) {
 | 
			
		||||
        m_completer->setCompletionPrefix(completionPrefix);
 | 
			
		||||
        m_completer->popup()->setCurrentIndex(m_completer->completionModel()->index(0, 0));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QModelIndex ci = m_compleater->completionModel()->index(0,0);
 | 
			
		||||
    if (ci.isValid() && m_compleater->completionModel()->data(ci).toString().compare(completionPrefix) == 0){
 | 
			
		||||
        m_compleater->popup()->hide();
 | 
			
		||||
    QModelIndex ci = m_completer->completionModel()->index(0,0);
 | 
			
		||||
    if (ci.isValid() && m_completer->completionModel()->data(ci).toString().compare(completionPrefix) == 0){
 | 
			
		||||
        m_completer->popup()->hide();
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QRect cr = cursorRect();
 | 
			
		||||
    cr.setWidth(m_compleater->popup()->sizeHintForColumn(0)
 | 
			
		||||
                + m_compleater->popup()->verticalScrollBar()->sizeHint().width());
 | 
			
		||||
    m_compleater->complete(cr);
 | 
			
		||||
    cr.setWidth(m_completer->popup()->sizeHintForColumn(0)
 | 
			
		||||
                + m_completer->popup()->verticalScrollBar()->sizeHint().width());
 | 
			
		||||
    m_completer->complete(cr);
 | 
			
		||||
 | 
			
		||||
    if (!completionPrefix.isEmpty() &&
 | 
			
		||||
            completionPrefix.at(completionPrefix.length()-1) == '.')
 | 
			
		||||
    {
 | 
			
		||||
        m_compleater->popup();
 | 
			
		||||
        m_completer->popup();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CodeEditor::focusInEvent(QFocusEvent *e)
 | 
			
		||||
{
 | 
			
		||||
    if (m_compleater) m_compleater->setWidget(this);
 | 
			
		||||
    if (m_completer) m_completer->setWidget(this);
 | 
			
		||||
    QPlainTextEdit::focusInEvent(e);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -278,13 +279,16 @@ QChar CodeEditor::getParenthesisReverceChar(QChar parenthesisChar)
 | 
			
		||||
 | 
			
		||||
void CodeEditor::insertCompletion(const QString &completion)
 | 
			
		||||
{
 | 
			
		||||
    if (m_compleater->widget() != this)
 | 
			
		||||
    if (m_completer->widget() != this)
 | 
			
		||||
             return;
 | 
			
		||||
    QTextCursor tc = textCursor();
 | 
			
		||||
    int extra = completion.length() - m_compleater->completionPrefix().length();
 | 
			
		||||
    //tc.movePosition(QTextCursor::Left);
 | 
			
		||||
    //tc.movePosition(QTextCursor::EndOfWord);
 | 
			
		||||
    tc.insertText(completion.right(extra));
 | 
			
		||||
//    QString prefix = m_completer->completionPrefix();
 | 
			
		||||
//    int extra = completion.length() - prefix.length();
 | 
			
		||||
    for (int i=0; i < m_completer->completionPrefix().length(); ++i ) {
 | 
			
		||||
        tc.deletePreviousChar();
 | 
			
		||||
    }
 | 
			
		||||
    tc.insertText(completion);
 | 
			
		||||
//    tc.insertText(completion.right(extra));
 | 
			
		||||
    setTextCursor(tc);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -20,7 +20,7 @@ class CodeEditor :public QPlainTextEdit
 | 
			
		||||
public:
 | 
			
		||||
    CodeEditor(QWidget* parent=0);
 | 
			
		||||
    void setCompleter(QCompleter* value);
 | 
			
		||||
    QCompleter* compleater() const{ return m_compleater;}
 | 
			
		||||
    QCompleter* compleater() const{ return m_completer;}
 | 
			
		||||
    void lineNumberAreaPaintEvent(QPaintEvent *event);
 | 
			
		||||
    int lineNumberAreaWidth();
 | 
			
		||||
protected:
 | 
			
		||||
@@ -41,7 +41,7 @@ private slots:
 | 
			
		||||
    void updateLineNumberArea(const QRect &rect, int dy);
 | 
			
		||||
    void matchParentheses();
 | 
			
		||||
private:
 | 
			
		||||
    QCompleter* m_compleater;
 | 
			
		||||
    QCompleter* m_completer;
 | 
			
		||||
    QWidget *lineNumberArea;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										142
									
								
								limereport/scripteditor/lrcompletermodel.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										142
									
								
								limereport/scripteditor/lrcompletermodel.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,142 @@
 | 
			
		||||
#include "lrcompletermodel.h"
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
 | 
			
		||||
CompleterModel::CompleterModel(QObject *parent) : QAbstractItemModel(parent){m_root.setModel(this);}
 | 
			
		||||
 | 
			
		||||
QModelIndex CompleterModel::index(int row, int column, const QModelIndex &parent) const
 | 
			
		||||
{
 | 
			
		||||
    CompleterItem const *parentItem;
 | 
			
		||||
    if (!parent.isValid())
 | 
			
		||||
        parentItem = &m_root;
 | 
			
		||||
    else
 | 
			
		||||
        parentItem = static_cast<CompleterItem*>(parent.internalPointer());
 | 
			
		||||
 | 
			
		||||
    if ((parentItem == nullptr)
 | 
			
		||||
        || (row < 0)
 | 
			
		||||
        || (column < 0)
 | 
			
		||||
        || (row >= parentItem->rowCount())
 | 
			
		||||
        || (column >= 1))
 | 
			
		||||
    {
 | 
			
		||||
        return QModelIndex();
 | 
			
		||||
    }
 | 
			
		||||
    return createIndex(row, column, parentItem->child(row));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QModelIndex CompleterModel::parent(const QModelIndex &child) const
 | 
			
		||||
{
 | 
			
		||||
    if (child.isValid()){
 | 
			
		||||
        CompleterItem *childItem = static_cast<CompleterItem*>(child.internalPointer());
 | 
			
		||||
        CompleterItem *parentItem = childItem->parent();
 | 
			
		||||
        if (parentItem != &m_root) {
 | 
			
		||||
            return indexFromItem(parentItem);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return QModelIndex();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int CompleterModel::rowCount(const QModelIndex &parent) const
 | 
			
		||||
{
 | 
			
		||||
   if (parent.isValid()){
 | 
			
		||||
        CompleterItem *parentItem = static_cast<CompleterItem*>(parent.internalPointer());
 | 
			
		||||
        return parentItem->rowCount();
 | 
			
		||||
    }
 | 
			
		||||
    return m_root.rowCount();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int CompleterModel::columnCount(const QModelIndex &parent) const
 | 
			
		||||
{
 | 
			
		||||
    Q_UNUSED(parent)
 | 
			
		||||
    return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QVariant CompleterModel::data(const QModelIndex &index, int role) const
 | 
			
		||||
{
 | 
			
		||||
    if (index.isValid()){
 | 
			
		||||
        CompleterItem* item = static_cast<CompleterItem*>(index.internalPointer());
 | 
			
		||||
        switch (role) {
 | 
			
		||||
        case Qt::DisplayRole:
 | 
			
		||||
        case Qt::EditRole:
 | 
			
		||||
            if (!item) return QVariant();
 | 
			
		||||
 | 
			
		||||
            if (index.column()==0){
 | 
			
		||||
                return item->text();
 | 
			
		||||
            } else {
 | 
			
		||||
                return "";
 | 
			
		||||
            }
 | 
			
		||||
        case Qt::DecorationRole :
 | 
			
		||||
            if (!item) return QIcon();
 | 
			
		||||
            if (index.column()==0){
 | 
			
		||||
                return item->icon();
 | 
			
		||||
            } else return QIcon();
 | 
			
		||||
        default:
 | 
			
		||||
            return QVariant();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return QVariant();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QList<CompleterItem *> CompleterModel::findItems(const QString &text, Qt::MatchFlags flags, int column) const
 | 
			
		||||
{
 | 
			
		||||
    QModelIndexList indexes = match(index(0, column, QModelIndex()),
 | 
			
		||||
                                        Qt::DisplayRole, text, -1, flags);
 | 
			
		||||
    QList<CompleterItem*> items;
 | 
			
		||||
    const int numIndexes = indexes.size();
 | 
			
		||||
    items.reserve(numIndexes);
 | 
			
		||||
    for (int i = 0; i < numIndexes; ++i)
 | 
			
		||||
        items.append(itemFromIndex(indexes.at(i)));
 | 
			
		||||
    return items;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CompleterModel::clear()
 | 
			
		||||
{
 | 
			
		||||
    beginResetModel();
 | 
			
		||||
    m_root.clear();
 | 
			
		||||
    endResetModel();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CompleterItem *CompleterModel::itemFromIndex(const QModelIndex index) const
 | 
			
		||||
{
 | 
			
		||||
    if ((index.row() < 0) || (index.column() < 0) || (index.model() != this))
 | 
			
		||||
            return nullptr;
 | 
			
		||||
    CompleterItem *parent = static_cast<CompleterItem*>(index.internalPointer());
 | 
			
		||||
    if (parent == nullptr)
 | 
			
		||||
            return nullptr;
 | 
			
		||||
    CompleterItem *item = parent->child(index.row());
 | 
			
		||||
    return item;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QModelIndex CompleterModel::indexFromItem(CompleterItem *item) const
 | 
			
		||||
{
 | 
			
		||||
    if (item && item->parent()){
 | 
			
		||||
        return createIndex(item->row(), 0, item);
 | 
			
		||||
    }
 | 
			
		||||
    return QModelIndex();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CompleterItem::~CompleterItem(){}
 | 
			
		||||
 | 
			
		||||
void CompleterItem::setIcon(const QIcon &newIcon)
 | 
			
		||||
{
 | 
			
		||||
    m_icon = newIcon;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CompleterItem::setText(const QString &newText)
 | 
			
		||||
{
 | 
			
		||||
    m_text = newText;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CompleterItem::appendRow(CompleterItem *child){
 | 
			
		||||
    child->m_parent = this;
 | 
			
		||||
    child->m_model = this->m_model;
 | 
			
		||||
    m_children.append(QSharedPointer<CompleterItem>(child));
 | 
			
		||||
    if (m_model){
 | 
			
		||||
        QModelIndex start = m_model->indexFromItem(child);
 | 
			
		||||
        emit m_model->dataChanged(start, start);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CompleterItem::appendRows(const QList<CompleterItem*> &children){
 | 
			
		||||
    foreach(CompleterItem* item, children){
 | 
			
		||||
        appendRow(item);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										71
									
								
								limereport/scripteditor/lrcompletermodel.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								limereport/scripteditor/lrcompletermodel.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,71 @@
 | 
			
		||||
#ifndef COMPLETERMODEL_H
 | 
			
		||||
#define COMPLETERMODEL_H
 | 
			
		||||
 | 
			
		||||
#include <QAbstractItemModel>
 | 
			
		||||
#include <QIcon>
 | 
			
		||||
 | 
			
		||||
class CompleterModel;
 | 
			
		||||
 | 
			
		||||
class CompleterItem {
 | 
			
		||||
public:
 | 
			
		||||
    CompleterItem():m_parent(0), m_model(0){}
 | 
			
		||||
    CompleterItem(QString text, QIcon icon):m_parent(0), m_text(text), m_icon(icon), m_model(0){}
 | 
			
		||||
    ~CompleterItem();
 | 
			
		||||
    int rowCount() const {return m_children.count();}
 | 
			
		||||
    CompleterItem* child(int row) const {return m_children.at(row).data();}
 | 
			
		||||
    CompleterItem* parent() const {return m_parent;}
 | 
			
		||||
    int row() const{
 | 
			
		||||
        if (m_parent){
 | 
			
		||||
            for(int i=0; i <  m_parent->m_children.count(); ++i){
 | 
			
		||||
                CompleterItem* c = m_parent->m_children.at(i).data();
 | 
			
		||||
                if (c == this) return i;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return -1;
 | 
			
		||||
    }
 | 
			
		||||
    QString text(){return m_text;}
 | 
			
		||||
    QIcon icon() {return m_icon;}
 | 
			
		||||
 | 
			
		||||
    void setIcon(const QIcon &newIcon);
 | 
			
		||||
    void setText(const QString &newText);
 | 
			
		||||
    void setModel(CompleterModel* model){m_model=model;}
 | 
			
		||||
    void clear(){m_children.clear();}
 | 
			
		||||
    void appendRow(CompleterItem* child);
 | 
			
		||||
    void appendRows(const QList<CompleterItem *> &children);
 | 
			
		||||
private:
 | 
			
		||||
    CompleterItem* m_parent;
 | 
			
		||||
    QVector<QSharedPointer<CompleterItem> > m_children;
 | 
			
		||||
    QString m_text;
 | 
			
		||||
    QIcon m_icon;
 | 
			
		||||
    CompleterModel* m_model;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CompleterModel : public QAbstractItemModel
 | 
			
		||||
{
 | 
			
		||||
    friend CompleterItem;
 | 
			
		||||
public:
 | 
			
		||||
    explicit CompleterModel(QObject *parent = nullptr);
 | 
			
		||||
 | 
			
		||||
    // QAbstractItemModel interface
 | 
			
		||||
public:
 | 
			
		||||
    QModelIndex index(int row, int column, const QModelIndex &parent) const;
 | 
			
		||||
    QModelIndex parent(const QModelIndex &child) const;
 | 
			
		||||
    int rowCount(const QModelIndex &parent) const;
 | 
			
		||||
    int columnCount(const QModelIndex &parent) const;
 | 
			
		||||
    QVariant data(const QModelIndex &index, int role) const;
 | 
			
		||||
    CompleterItem* invisibleRootItem(){return &m_root;}
 | 
			
		||||
    QList<CompleterItem*> findItems(const QString &text,
 | 
			
		||||
                                    Qt::MatchFlags flags = Qt::MatchExactly,
 | 
			
		||||
                                    int column = 0) const;
 | 
			
		||||
    void clear();
 | 
			
		||||
private:
 | 
			
		||||
    CompleterItem *itemFromIndex(const QModelIndex index) const;
 | 
			
		||||
    QModelIndex indexFromItem(CompleterItem *item) const;
 | 
			
		||||
private:
 | 
			
		||||
    CompleterItem m_root;
 | 
			
		||||
public:
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // COMPLETERMODEL_H
 | 
			
		||||
@@ -20,7 +20,7 @@ ScriptEditor::ScriptEditor(QWidget *parent) :
 | 
			
		||||
    setFocusProxy(ui->textEdit);
 | 
			
		||||
    m_completer = new ReportStructureCompleater(this);
 | 
			
		||||
    ui->textEdit->setCompleter(m_completer);
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if QT_VERSION < QT_VERSION_CHECK(5,12,3)
 | 
			
		||||
    ui->textEdit->setTabStopWidth(ui->textEdit->fontMetrics().boundingRect("0").width()*m_tabIndention);
 | 
			
		||||
#else
 | 
			
		||||
    ui->textEdit->setTabStopDistance(ui->textEdit->fontMetrics().boundingRect("0").width()*m_tabIndention);
 | 
			
		||||
@@ -90,7 +90,7 @@ void ScriptEditor::setPageBand(BandDesignIntf* band)
 | 
			
		||||
void ScriptEditor::setTabIndention(int charCount)
 | 
			
		||||
{
 | 
			
		||||
    if (m_tabIndention != charCount){
 | 
			
		||||
#if QT_VERSION < 0x060000
 | 
			
		||||
#if QT_VERSION < QT_VERSION_CHECK(5,12,3)
 | 
			
		||||
        ui->textEdit->setTabStopWidth(ui->textEdit->fontMetrics().boundingRect("W").width()*charCount);
 | 
			
		||||
#else
 | 
			
		||||
        ui->textEdit->setTabStopDistance(ui->textEdit->fontMetrics().boundingRect("W").width()*charCount);
 | 
			
		||||
@@ -182,21 +182,21 @@ QStringList ReportStructureCompleater::splitPath(const QString &path) const
 | 
			
		||||
    return path.split(".");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ReportStructureCompleater::addAdditionalDatawords(QStandardItemModel* model, DataSourceManager* dataManager){
 | 
			
		||||
void ReportStructureCompleater::addAdditionalDatawords(CompleterModel* model, DataSourceManager* dataManager){
 | 
			
		||||
 | 
			
		||||
    foreach(const QString &dsName,dataManager->dataSourceNames()){
 | 
			
		||||
        QStandardItem* dsNode = new QStandardItem;
 | 
			
		||||
        CompleterItem* dsNode = new CompleterItem;
 | 
			
		||||
        dsNode->setText(dsName);
 | 
			
		||||
        model->invisibleRootItem()->appendRow(dsNode);
 | 
			
		||||
        foreach(const QString &field, dataManager->fieldNames(dsName)){
 | 
			
		||||
            QStandardItem* fieldNode = new QStandardItem;
 | 
			
		||||
            CompleterItem* fieldNode = new CompleterItem;
 | 
			
		||||
            fieldNode->setText(field);
 | 
			
		||||
            dsNode->appendRow(fieldNode);
 | 
			
		||||
        }
 | 
			
		||||
        model->invisibleRootItem()->appendRow(dsNode);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    foreach (QString varName, dataManager->variableNames()) {
 | 
			
		||||
        QStandardItem* varNode = new QStandardItem;
 | 
			
		||||
        CompleterItem* varNode = new CompleterItem;
 | 
			
		||||
        varNode->setText(varName.remove("#"));
 | 
			
		||||
        model->invisibleRootItem()->appendRow(varNode);
 | 
			
		||||
    }
 | 
			
		||||
@@ -208,19 +208,20 @@ void ReportStructureCompleater::addAdditionalDatawords(QStandardItemModel* model
 | 
			
		||||
    while (it.hasNext()){
 | 
			
		||||
        it.next();
 | 
			
		||||
        if (it.value().isCallable() ){
 | 
			
		||||
            QStandardItem* itemNode = new QStandardItem;
 | 
			
		||||
            CompleterItem* itemNode = new CompleterItem;
 | 
			
		||||
            itemNode->setText(it.name()+"()");
 | 
			
		||||
            model->invisibleRootItem()->appendRow(itemNode);
 | 
			
		||||
        }
 | 
			
		||||
        if (it.value().isQObject()){
 | 
			
		||||
            if (it.value().toQObject()){
 | 
			
		||||
                if (model->findItems(it.name()).isEmpty()){
 | 
			
		||||
                    QStandardItem* objectNode = new QStandardItem;
 | 
			
		||||
                    CompleterItem* objectNode = new CompleterItem;
 | 
			
		||||
                    objectNode->setText(it.name());
 | 
			
		||||
                    objectNode->setIcon(QIcon(":/report/images/object"));
 | 
			
		||||
 | 
			
		||||
                    for (int i = 0; i< it.value().toQObject()->metaObject()->methodCount();++i){
 | 
			
		||||
                        if (it.value().toQObject()->metaObject()->method(i).methodType() == QMetaMethod::Method){
 | 
			
		||||
                            QStandardItem* methodNode = new QStandardItem;
 | 
			
		||||
                            CompleterItem* methodNode = new CompleterItem;
 | 
			
		||||
                            QMetaMethod m = it.value().toQObject()->metaObject()->method(i);
 | 
			
		||||
                            QString methodSignature = m.name() + "(";
 | 
			
		||||
                            bool isFirst = true;
 | 
			
		||||
@@ -245,46 +246,49 @@ void ReportStructureCompleater::addAdditionalDatawords(QStandardItemModel* model
 | 
			
		||||
void ReportStructureCompleater::updateCompleaterModel(ReportEnginePrivateInterface* report)
 | 
			
		||||
{
 | 
			
		||||
    if (report){
 | 
			
		||||
        m_model.clear();
 | 
			
		||||
        m_newModel.clear();
 | 
			
		||||
 | 
			
		||||
        QIcon signalIcon(":/report/images/signal");
 | 
			
		||||
        QIcon propertyIcon(":/report/images/property");
 | 
			
		||||
 | 
			
		||||
        for ( int i = 0; i < report->pageCount(); ++i){
 | 
			
		||||
            PageDesignIntf* page = report->pageAt(i);
 | 
			
		||||
 | 
			
		||||
            QStandardItem* itemNode = new QStandardItem;
 | 
			
		||||
            CompleterItem* itemNode = new CompleterItem;
 | 
			
		||||
            itemNode->setText(page->pageItem()->objectName());
 | 
			
		||||
            itemNode->setIcon(QIcon(":/report/images/object"));
 | 
			
		||||
            m_model.invisibleRootItem()->appendRow(itemNode);
 | 
			
		||||
 | 
			
		||||
            QStringList items = extractSignalNames(page->pageItem());
 | 
			
		||||
            foreach(QString slotName, items){
 | 
			
		||||
                QStandardItem* slotItem = new QStandardItem;
 | 
			
		||||
                CompleterItem* slotItem = new CompleterItem;
 | 
			
		||||
                slotItem->setText(slotName);
 | 
			
		||||
                slotItem->setIcon(signalIcon);
 | 
			
		||||
                itemNode->appendRow(slotItem);
 | 
			
		||||
            }
 | 
			
		||||
            items = extractProperties(page->pageItem());
 | 
			
		||||
            foreach(QString propertyName, items){
 | 
			
		||||
                QStandardItem* properyItem = new QStandardItem;
 | 
			
		||||
                CompleterItem* properyItem = new CompleterItem;
 | 
			
		||||
                properyItem->setText(propertyName);
 | 
			
		||||
                properyItem->setIcon(propertyIcon);
 | 
			
		||||
                itemNode->appendRow(properyItem);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            foreach (BaseDesignIntf* item, page->pageItem()->childBaseItems()){
 | 
			
		||||
                addChildItem(item, itemNode->text(), m_model.invisibleRootItem());
 | 
			
		||||
                addChildItem(item, itemNode->text(), m_newModel.invisibleRootItem());
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            m_newModel.invisibleRootItem()->appendRow(itemNode);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        addAdditionalDatawords(&m_model, report->dataManager());
 | 
			
		||||
        m_model.sort(0);
 | 
			
		||||
        addAdditionalDatawords(&m_newModel, report->dataManager());
 | 
			
		||||
        m_newModel.sort(0);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ReportStructureCompleater::updateCompleaterModel(DataSourceManager *dataManager)
 | 
			
		||||
{
 | 
			
		||||
    m_model.clear();
 | 
			
		||||
    addAdditionalDatawords(&m_model, dataManager);
 | 
			
		||||
    m_newModel.clear();
 | 
			
		||||
    addAdditionalDatawords(&m_newModel, dataManager);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QStringList ReportStructureCompleater::extractSignalNames(BaseDesignIntf *item)
 | 
			
		||||
@@ -325,46 +329,64 @@ QStringList ReportStructureCompleater::extractProperties(BaseDesignIntf *item)
 | 
			
		||||
    return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ReportStructureCompleater::addChildItem(BaseDesignIntf *item, const QString &pageName, QStandardItem *parent)
 | 
			
		||||
void ReportStructureCompleater::addChildItem(BaseDesignIntf *item, const QString &pageName, CompleterItem *parent)
 | 
			
		||||
{
 | 
			
		||||
    if (!item) return;
 | 
			
		||||
 | 
			
		||||
    QIcon signalIcon(":/report/images/signal");
 | 
			
		||||
    QIcon propertyIcon(":/report/images/property");
 | 
			
		||||
 | 
			
		||||
    QStandardItem* itemNode = new QStandardItem;
 | 
			
		||||
    CompleterItem* itemNode = new CompleterItem;
 | 
			
		||||
    itemNode->setText(pageName+"_"+item->objectName());
 | 
			
		||||
    itemNode->setIcon(QIcon(":/report/images/object"));
 | 
			
		||||
    parent->appendRow(itemNode);
 | 
			
		||||
    QStringList items;
 | 
			
		||||
 | 
			
		||||
    if (!m_signals.contains(item->metaObject()->className())){
 | 
			
		||||
        items = extractSignalNames(item);
 | 
			
		||||
        m_signals.insert(item->metaObject()->className(),items);
 | 
			
		||||
    } else {
 | 
			
		||||
        items = m_signals.value(item->metaObject()->className());
 | 
			
		||||
    }
 | 
			
		||||
//    if (m_cache.contains(item->metaObject()->className())){
 | 
			
		||||
 | 
			
		||||
    foreach(QString slotName, items){
 | 
			
		||||
        QStandardItem* slotItem = new QStandardItem;
 | 
			
		||||
        slotItem->setText(slotName);
 | 
			
		||||
        slotItem->setIcon(signalIcon);
 | 
			
		||||
        itemNode->appendRow(slotItem);
 | 
			
		||||
    }
 | 
			
		||||
//        QSharedPointer<CacheItem> cacheItem = m_cache.value(item->metaObject()->className());
 | 
			
		||||
//        itemNode->appendRows(cacheItem->slotsItems);
 | 
			
		||||
//        itemNode->appendRows(cacheItem->propsItems);
 | 
			
		||||
 | 
			
		||||
    if (!m_properties.contains(item->metaObject()->className())){
 | 
			
		||||
        items = extractProperties(item);
 | 
			
		||||
        m_properties.insert(item->metaObject()->className(),items);
 | 
			
		||||
    } else {
 | 
			
		||||
        items = m_properties.value(item->metaObject()->className());
 | 
			
		||||
    }
 | 
			
		||||
//    } else {
 | 
			
		||||
 | 
			
		||||
    foreach(QString propertyName, items){
 | 
			
		||||
        QStandardItem* properyItem = new QStandardItem;
 | 
			
		||||
        properyItem->setText(propertyName);
 | 
			
		||||
        properyItem->setIcon(propertyIcon);
 | 
			
		||||
        itemNode->appendRow(properyItem);
 | 
			
		||||
    }
 | 
			
		||||
//        QSharedPointer<CacheItem> cacheItem = QSharedPointer<CacheItem>(new CacheItem);
 | 
			
		||||
 | 
			
		||||
        QStringList items;
 | 
			
		||||
        if (!m_signals.contains(item->metaObject()->className())){
 | 
			
		||||
            items = extractSignalNames(item);
 | 
			
		||||
            m_signals.insert(item->metaObject()->className(),items);
 | 
			
		||||
        } else {
 | 
			
		||||
            items = m_signals.value(item->metaObject()->className());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        foreach(QString slotName, items){
 | 
			
		||||
            CompleterItem* slotItem = new CompleterItem;
 | 
			
		||||
            slotItem->setText(slotName);
 | 
			
		||||
            slotItem->setIcon(signalIcon);
 | 
			
		||||
            //cacheItem->slotsItems.append(QSharedPointer<CompleterItem>(slotItem));
 | 
			
		||||
            itemNode->appendRow(slotItem);
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!m_properties.contains(item->metaObject()->className())){
 | 
			
		||||
            items = extractProperties(item);
 | 
			
		||||
            m_properties.insert(item->metaObject()->className(),items);
 | 
			
		||||
        } else {
 | 
			
		||||
            items = m_properties.value(item->metaObject()->className());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        foreach(QString propertyName, items){
 | 
			
		||||
            CompleterItem* properyItem = new CompleterItem;
 | 
			
		||||
            properyItem->setText(propertyName);
 | 
			
		||||
            properyItem->setIcon(propertyIcon);
 | 
			
		||||
            itemNode->appendRow(properyItem);
 | 
			
		||||
            //cacheItem->propsItems.append(QSharedPointer<CompleterItem>(properyItem));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //m_cache.insert(item->metaObject()->className(), cacheItem);
 | 
			
		||||
        //itemNode->appendRows(cacheItem->slotsItems);
 | 
			
		||||
        //itemNode->appendRows(cacheItem->propsItems);
 | 
			
		||||
    //}
 | 
			
		||||
 | 
			
		||||
    foreach (BaseDesignIntf* child, item->childBaseItems()){
 | 
			
		||||
        addChildItem(child, pageName, parent);
 | 
			
		||||
 
 | 
			
		||||
@@ -7,6 +7,7 @@
 | 
			
		||||
#include <QKeyEvent>
 | 
			
		||||
#include <QScrollBar>
 | 
			
		||||
#include <QStandardItemModel>
 | 
			
		||||
#include "lrcompletermodel.h"
 | 
			
		||||
 | 
			
		||||
namespace LimeReport{
 | 
			
		||||
 | 
			
		||||
@@ -20,12 +21,17 @@ namespace Ui {
 | 
			
		||||
class ScriptEditor;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct CacheItem {
 | 
			
		||||
    QList<QSharedPointer<CompleterItem>> propsItems;
 | 
			
		||||
    QList<QSharedPointer<CompleterItem>> slotsItems;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class ReportStructureCompleater : public QCompleter{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
public:
 | 
			
		||||
    explicit ReportStructureCompleater(QObject* parent = 0): QCompleter(parent){ setModel(&m_model);}
 | 
			
		||||
    explicit ReportStructureCompleater(QObject* parent = 0): QCompleter(parent){ setModel(&m_newModel);}
 | 
			
		||||
    explicit ReportStructureCompleater(QAbstractItemModel* model, QObject* parent = 0)
 | 
			
		||||
        :QCompleter(model, parent){ setModel(&m_model);}
 | 
			
		||||
        :QCompleter(model, parent){ setModel(&m_newModel);}
 | 
			
		||||
public:
 | 
			
		||||
    // QCompleter interface
 | 
			
		||||
    QString pathFromIndex(const QModelIndex& index) const;
 | 
			
		||||
@@ -35,10 +41,10 @@ public:
 | 
			
		||||
protected:
 | 
			
		||||
    QStringList extractSignalNames(BaseDesignIntf* item);
 | 
			
		||||
    QStringList extractProperties(BaseDesignIntf* item);
 | 
			
		||||
    void addChildItem(BaseDesignIntf *item, const QString &pageName, QStandardItem *parent);
 | 
			
		||||
    void addAdditionalDatawords(QStandardItemModel* model, DataSourceManager *dataManager);
 | 
			
		||||
    void addChildItem(BaseDesignIntf *item, const QString &pageName, CompleterItem *parent);
 | 
			
		||||
    void addAdditionalDatawords(CompleterModel *model, DataSourceManager *dataManager);
 | 
			
		||||
private:
 | 
			
		||||
    QStandardItemModel m_model;
 | 
			
		||||
    CompleterModel m_newModel;
 | 
			
		||||
    QMap<QString, QStringList> m_properties;
 | 
			
		||||
    QMap<QString, QStringList> m_signals;
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -197,7 +197,8 @@ QVariant XmlFontSerializator::loadValue()
 | 
			
		||||
//#if QT_VERSION>0x040800
 | 
			
		||||
//    font.setStyleName(node()->attribute("stylename"));
 | 
			
		||||
//#endif
 | 
			
		||||
    font.setWeight(static_cast<QFont::Weight>(node()->attribute("weight").toInt()));
 | 
			
		||||
    if (node()->attribute("weight").toInt() > 0)
 | 
			
		||||
        font.setWeight(static_cast<QFont::Weight>(node()->attribute("weight").toInt()));
 | 
			
		||||
    if (!node()->attribute("bold").isEmpty())
 | 
			
		||||
      font.setBold(node()->attribute("bold").toInt());
 | 
			
		||||
    font.setItalic(node()->attribute("italic").toInt());
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,9 @@
 | 
			
		||||
#include <private/qzipreader_p.h>
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
#include <QtCore/qabstractanimation.h>
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
#include <QDesktopWidget>
 | 
			
		||||
#endif
 | 
			
		||||
#include "XmlModel.h"
 | 
			
		||||
#include "SettingDialog.h"
 | 
			
		||||
#include "lrreportengine.h"
 | 
			
		||||
@@ -15,11 +17,22 @@
 | 
			
		||||
//#endif
 | 
			
		||||
 | 
			
		||||
void centerWindow(QWidget* widget, double widthFactor, double heightFactor) {
 | 
			
		||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
 | 
			
		||||
    QDesktopWidget desk;
 | 
			
		||||
    int ww = desk.width() * widthFactor;
 | 
			
		||||
    int wh = desk.height() * heightFactor;
 | 
			
		||||
    widget->resize(ww, wh);
 | 
			
		||||
    widget->move((desk.width() - ww) / 2, (desk.height() - wh) / 2);
 | 
			
		||||
    widget->resize(ww, wh);
 | 
			
		||||
#else
 | 
			
		||||
    QScreen* desk = QGuiApplication::primaryScreen();
 | 
			
		||||
    int ww = desk->geometry().width() * widthFactor;
 | 
			
		||||
    int wh = desk->geometry().height() * heightFactor;
 | 
			
		||||
 | 
			
		||||
    widget->resize(ww, wh);
 | 
			
		||||
    widget->move((desk->geometry().width() - ww) / 2, (desk->geometry().height() - wh) / 2);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MainWindow::MainWindow(QWidget *parent) :
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user