diff --git a/demo_r2/mainwindow.cpp b/demo_r2/mainwindow.cpp index f95b5a5..47c7149 100644 --- a/demo_r2/mainwindow.cpp +++ b/demo_r2/mainwindow.cpp @@ -3,7 +3,7 @@ #include #include #include -#if QT_VERSION < 0x060000 +#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) #include #else #include @@ -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(); diff --git a/include/lrglobal.cpp b/include/lrglobal.cpp index e8a31bb..07c5d8e 100644 --- a/include/lrglobal.cpp +++ b/include/lrglobal.cpp @@ -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 normalizeCaptures(const QRegExp& reg){ #else QVector normalizeCaptures(const QRegularExpressionMatch ®){ diff --git a/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/sizehandlerect.cpp b/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/sizehandlerect.cpp index 4247769..78d2748 100644 --- a/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/sizehandlerect.cpp +++ b/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/sizehandlerect.cpp @@ -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); } diff --git a/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/sizehandlerect.h b/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/sizehandlerect.h index c916b00..d7980ca 100644 --- a/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/sizehandlerect.h +++ b/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/sizehandlerect.h @@ -66,8 +66,15 @@ private: private: const Direction m_dir; - QPoint m_startPos; +#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; diff --git a/limereport/items/lrchartitem.cpp b/limereport/items/lrchartitem.cpp index a0f6488..086ed3e 100644 --- a/limereport/items/lrchartitem.cpp +++ b/limereport/items/lrchartitem.cpp @@ -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+"))){ diff --git a/limereport/items/lrtextitem.cpp b/limereport/items/lrtextitem.cpp index 658aadb..086adca 100644 --- a/limereport/items/lrtextitem.cpp +++ b/limereport/items/lrtextitem.cpp @@ -359,11 +359,11 @@ void TextItem::updateLayout() } bool TextItem::isNeedExpandContent() const -{ - bool result = false; -#if QT_VERSION < 0x060000 +{ +#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) QRegExp rx("$*\\{[^{]*\\}"); #else + bool result = false; QRegularExpression rx("\\$*\\{[^{]*\\}"); result = content().contains(rx) || isContentBackedUp(); return result; @@ -824,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)); diff --git a/limereport/limereport.pri b/limereport/limereport.pri index 6e5b5ca..6615978 100644 --- a/limereport/limereport.pri +++ b/limereport/limereport.pri @@ -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 \ @@ -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 \ diff --git a/limereport/lrbasedesignintf.cpp b/limereport/lrbasedesignintf.cpp index 97660f6..8d35fab 100644 --- a/limereport/lrbasedesignintf.cpp +++ b/limereport/lrbasedesignintf.cpp @@ -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), diff --git a/limereport/lrdatasourcemanager.cpp b/limereport/lrdatasourcemanager.cpp index 1d7b913..b3e3738 100644 --- a/limereport/lrdatasourcemanager.cpp +++ b/limereport/lrdatasourcemanager.cpp @@ -31,7 +31,7 @@ #include "lrdatadesignintf.h" #include #include -#if QT_VERSION < 0x060000 +#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) #include #endif #include @@ -1495,7 +1495,7 @@ void DataSourceManager::invalidateQueriesContainsVariable(const QString& variabl foreach (const QString& datasourceName, dataSourceNames()){ QueryHolder* holder = dynamic_cast(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)); diff --git a/limereport/lrgraphicsviewzoom.cpp b/limereport/lrgraphicsviewzoom.cpp index ead08cd..54fac03 100644 --- a/limereport/lrgraphicsviewzoom.cpp +++ b/limereport/lrgraphicsviewzoom.cpp @@ -53,7 +53,7 @@ bool GraphicsViewZoomer::eventFilter(QObject *object, QEvent *event) { } else if (event->type() == QEvent::Wheel) { QWheelEvent* wheel_event = static_cast(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); diff --git a/limereport/lrgroupfunctions.cpp b/limereport/lrgroupfunctions.cpp index 30db2d2..3130832 100644 --- a/limereport/lrgroupfunctions.cpp +++ b/limereport/lrgroupfunctions.cpp @@ -34,7 +34,7 @@ #include "lrscriptenginemanager.h" #include "lrpageitemdesignintf.h" -#if QT_VERSION < 0x060000 +#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) #include #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); diff --git a/limereport/lritemdesignintf.cpp b/limereport/lritemdesignintf.cpp index 86e029b..b3f41a6 100644 --- a/limereport/lritemdesignintf.cpp +++ b/limereport/lritemdesignintf.cpp @@ -35,7 +35,7 @@ #include "lrglobal.h" #include -#if QT_VERSION < 0x060000 +#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) #include #endif #include diff --git a/limereport/lrpagedesignintf.cpp b/limereport/lrpagedesignintf.cpp index d4db356..785b4a4 100644 --- a/limereport/lrpagedesignintf.cpp +++ b/limereport/lrpagedesignintf.cpp @@ -753,7 +753,7 @@ void PageDesignIntf::dropEvent(QGraphicsSceneDragDropEvent* event) BaseDesignIntf* item = addReportItem("TextItem",event->scenePos(),QSize(250, 50)); TextItem* ti = dynamic_cast(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(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)); diff --git a/limereport/lrpageitemdesignintf.cpp b/limereport/lrpageitemdesignintf.cpp index 0d57563..f22eede 100644 --- a/limereport/lrpageitemdesignintf.cpp +++ b/limereport/lrpageitemdesignintf.cpp @@ -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, diff --git a/limereport/lrpageitemdesignintf.h b/limereport/lrpageitemdesignintf.h index 97d5118..365c87d 100644 --- a/limereport/lrpageitemdesignintf.h +++ b/limereport/lrpageitemdesignintf.h @@ -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}; diff --git a/limereport/lrpreviewreportwidget.cpp b/limereport/lrpreviewreportwidget.cpp index 71b4d35..bed200e 100644 --- a/limereport/lrpreviewreportwidget.cpp +++ b/limereport/lrpreviewreportwidget.cpp @@ -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; diff --git a/limereport/lrpreviewreportwindow.cpp b/limereport/lrpreviewreportwindow.cpp index 33691bd..e5c3ddc 100644 --- a/limereport/lrpreviewreportwindow.cpp +++ b/limereport/lrpreviewreportwindow.cpp @@ -41,7 +41,7 @@ #include #include #include -#if QT_VERSION < 0x060000 +#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) #include #else #include @@ -147,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(); diff --git a/limereport/lrreportdesignwidget.cpp b/limereport/lrreportdesignwidget.cpp index b59ca70..6b7c608 100644 --- a/limereport/lrreportdesignwidget.cpp +++ b/limereport/lrreportdesignwidget.cpp @@ -1058,7 +1058,7 @@ bool ReportDesignWidget::eventFilter(QObject *target, QEvent *event) if (event->type() == QEvent::Wheel){ QWheelEvent* we = dynamic_cast(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 diff --git a/limereport/lrreportdesignwindow.cpp b/limereport/lrreportdesignwindow.cpp index b7a2b89..2fbd9be 100644 --- a/limereport/lrreportdesignwindow.cpp +++ b/limereport/lrreportdesignwindow.cpp @@ -39,7 +39,7 @@ #include #include #include -#if QT_VERSION < 0x060000 +#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) #include #else #include @@ -1552,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)); diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index ba0e8d7..3ff5d34 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -32,7 +32,7 @@ #include #include #include -#if QT_VERSION < 0x060000 +#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) #include #else #include @@ -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(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(), diff --git a/limereport/lrreporttranslation.h b/limereport/lrreporttranslation.h index c9b82a2..8fb6e1e 100644 --- a/limereport/lrreporttranslation.h +++ b/limereport/lrreporttranslation.h @@ -64,6 +64,7 @@ private: PageTranslation* createPageTranslation(PageDesignIntf* page); private: QLocale::Language m_language; + QLocale::Script m_script; QList m_pagesTranslation; }; diff --git a/limereport/lrscriptenginemanager.cpp b/limereport/lrscriptenginemanager.cpp index b027c2c..2abc084 100644 --- a/limereport/lrscriptenginemanager.cpp +++ b/limereport/lrscriptenginemanager.cpp @@ -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; diff --git a/limereport/objectinspector/editors/lrbuttonlineeditor.cpp b/limereport/objectinspector/editors/lrbuttonlineeditor.cpp index 4eead43..294e384 100644 --- a/limereport/objectinspector/editors/lrbuttonlineeditor.cpp +++ b/limereport/objectinspector/editors/lrbuttonlineeditor.cpp @@ -34,7 +34,7 @@ #include #include #include -#if QT_VERSION < 0x060000 +#if QT_VERSION < QT_VERSION_CHECK(5,12,3) #include #else #include @@ -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())); diff --git a/limereport/objectinspector/lrobjectinspectorwidget.cpp b/limereport/objectinspector/lrobjectinspectorwidget.cpp index 413c403..2baa105 100644 --- a/limereport/objectinspector/lrobjectinspectorwidget.cpp +++ b/limereport/objectinspector/lrobjectinspectorwidget.cpp @@ -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)); diff --git a/limereport/scripteditor/lrcodeeditor.cpp b/limereport/scripteditor/lrcodeeditor.cpp index cd73ef4..c70c20b 100644 --- a/limereport/scripteditor/lrcodeeditor.cpp +++ b/limereport/scripteditor/lrcodeeditor.cpp @@ -282,14 +282,13 @@ void CodeEditor::insertCompletion(const QString &completion) if (m_completer->widget() != this) return; QTextCursor tc = textCursor(); - int extra = completion.length() - m_completer->completionPrefix().length(); - //tc.movePosition(QTextCursor::Left); - //tc.movePosition(QTextCursor::EndOfWord); +// 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)); +// tc.insertText(completion.right(extra)); setTextCursor(tc); } diff --git a/limereport/scripteditor/lrcompletermodel.cpp b/limereport/scripteditor/lrcompletermodel.cpp new file mode 100644 index 0000000..29c7116 --- /dev/null +++ b/limereport/scripteditor/lrcompletermodel.cpp @@ -0,0 +1,142 @@ +#include "lrcompletermodel.h" +#include + +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(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(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(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(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 CompleterModel::findItems(const QString &text, Qt::MatchFlags flags, int column) const +{ + QModelIndexList indexes = match(index(0, column, QModelIndex()), + Qt::DisplayRole, text, -1, flags); + QList 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(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(child)); + if (m_model){ + QModelIndex start = m_model->indexFromItem(child); + emit m_model->dataChanged(start, start); + } +} + +void CompleterItem::appendRows(const QList &children){ + foreach(CompleterItem* item, children){ + appendRow(item); + } +} diff --git a/limereport/scripteditor/lrcompletermodel.h b/limereport/scripteditor/lrcompletermodel.h new file mode 100644 index 0000000..862437a --- /dev/null +++ b/limereport/scripteditor/lrcompletermodel.h @@ -0,0 +1,71 @@ +#ifndef COMPLETERMODEL_H +#define COMPLETERMODEL_H + +#include +#include + +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 &children); +private: + CompleterItem* m_parent; + QVector > 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 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 diff --git a/limereport/scripteditor/lrscripteditor.cpp b/limereport/scripteditor/lrscripteditor.cpp index 34e2c74..916739e 100644 --- a/limereport/scripteditor/lrscripteditor.cpp +++ b/limereport/scripteditor/lrscripteditor.cpp @@ -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 = 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 = QSharedPointer(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(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(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); diff --git a/limereport/scripteditor/lrscripteditor.h b/limereport/scripteditor/lrscripteditor.h index 10dcd5a..ea0a433 100644 --- a/limereport/scripteditor/lrscripteditor.h +++ b/limereport/scripteditor/lrscripteditor.h @@ -7,6 +7,7 @@ #include #include #include +#include "lrcompletermodel.h" namespace LimeReport{ @@ -20,12 +21,17 @@ namespace Ui { class ScriptEditor; } +struct CacheItem { + QList> propsItems; + QList> 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 m_properties; QMap m_signals; }; diff --git a/lrdview/MainWindow.cpp b/lrdview/MainWindow.cpp index b90d9e3..1a26d00 100644 --- a/lrdview/MainWindow.cpp +++ b/lrdview/MainWindow.cpp @@ -5,7 +5,7 @@ #include #include #include -#if QT_VERSION < 0x060000 +#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) #include #endif #include "XmlModel.h" @@ -17,7 +17,7 @@ //#endif void centerWindow(QWidget* widget, double widthFactor, double heightFactor) { -#if QT_VERSION < 0x060000 +#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) QDesktopWidget desk; int ww = desk.width() * widthFactor; int wh = desk.height() * heightFactor;