From f68a8fff65957675d8f9e0ab467fd7107c6b10f1 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Sat, 19 Aug 2017 01:16:57 +0300 Subject: [PATCH] addTableOfContensItem function has been modified --- limereport/lrpageitemdesignintf.cpp | 15 ------------- limereport/lrpageitemdesignintf.h | 5 ----- limereport/lrreportdesignwidget.cpp | 5 +++++ limereport/lrscriptenginemanager.cpp | 32 ++++++++++++++-------------- limereport/lrscriptenginemanager.h | 6 +++--- 5 files changed, 24 insertions(+), 39 deletions(-) diff --git a/limereport/lrpageitemdesignintf.cpp b/limereport/lrpageitemdesignintf.cpp index 72c4327..95b9144 100644 --- a/limereport/lrpageitemdesignintf.cpp +++ b/limereport/lrpageitemdesignintf.cpp @@ -331,21 +331,6 @@ void PageItemDesignIntf::initColumnsPos(QVector &posByColumns, qreal pos, } } -QString PageItemDesignIntf::initScript() const -{ - return m_initScript; -} - -void PageItemDesignIntf::setInitScript(const QString& value) -{ - if (m_initScript.compare(value) != 0){ - QString old_value = m_initScript; - m_initScript = value; - if (!isLoading()) - notify("initScript", old_value, value); - } -} - bool PageItemDesignIntf::getIsTOC() const { return m_isTOC; diff --git a/limereport/lrpageitemdesignintf.h b/limereport/lrpageitemdesignintf.h index 3910d75..c39788a 100644 --- a/limereport/lrpageitemdesignintf.h +++ b/limereport/lrpageitemdesignintf.h @@ -56,7 +56,6 @@ class PageItemDesignIntf : public LimeReport::ItemsContainerDesignInft Q_PROPERTY(bool isExtendedInDesignMode READ isExtendedInDesignMode WRITE setExtendedInDesignMode) Q_PROPERTY(int extendedHeight READ extendedHeight WRITE setExtendedHeight) Q_PROPERTY(bool pageIsTOC READ getIsTOC WRITE setIsTOC) - Q_PROPERTY(QString initScript READ initScript WRITE setInitScript) friend class ReportRender; public: enum Orientation { Portrait, Landscape }; @@ -130,9 +129,6 @@ public: bool getIsTOC() const; void setIsTOC(bool isTOC); - - QString initScript() const; - void setInitScript(const QString& value); signals: void beforeFirstPageRendered(); void afterLastPageRendered(); @@ -167,7 +163,6 @@ private: bool m_isExtendedInDesignMode; int m_extendedHeight; bool m_isTOC; - QString m_initScript; }; typedef QList ReportPages; diff --git a/limereport/lrreportdesignwidget.cpp b/limereport/lrreportdesignwidget.cpp index 738dedc..285622f 100644 --- a/limereport/lrreportdesignwidget.cpp +++ b/limereport/lrreportdesignwidget.cpp @@ -237,6 +237,8 @@ void ReportDesignWidget::createTabs(){ connectPage(m_report->pageAt(i)); pageIndex = m_tabWidget->addTab(view,QIcon(),m_report->pageAt(i)->pageItem()->objectName()); m_tabWidget->setTabWhatsThis(pageIndex, "page"); + connect(m_report->pageAt(i)->pageItem(), SIGNAL(propertyObjectNameChanged(QString,QString)), + this, SLOT(slotPagePropertyObjectNameChanged(QString,QString))); } m_scriptEditor = new QTextEdit(this); @@ -827,6 +829,9 @@ void ReportDesignWidget::slotPagePropertyObjectNameChanged(const QString &oldVal void ReportDesignWidget::slotTabMoved(int from, int to) { + Q_UNUSED(from) + Q_UNUSED(to) + QList pages; for ( int i = 0; i < m_tabWidget->tabBar()->count(); ++i){ diff --git a/limereport/lrscriptenginemanager.cpp b/limereport/lrscriptenginemanager.cpp index 5f18bc8..b0ca34c 100644 --- a/limereport/lrscriptenginemanager.cpp +++ b/limereport/lrscriptenginemanager.cpp @@ -538,9 +538,9 @@ QVariant ScriptEngineManager::evaluateScript(const QString& script){ return QVariant(); } -void ScriptEngineManager::addTableOfContensItem(const QString& content, int pageNumber, int indent) +void ScriptEngineManager::addTableOfContensItem(const QString& uniqKey, const QString& content, int pageNumber, int indent) { - m_tableOfContens->setItem(content, pageNumber, indent); + m_tableOfContens->setItem(uniqKey, content, pageNumber, indent); } void ScriptEngineManager::updateModel() @@ -756,9 +756,9 @@ bool ScriptEngineManager::createAddTableOfContensItemFunction() fd.setManagerName(LimeReport::Const::FUNCTION_MANAGER_NAME); fd.setCategory(tr("GENERAL")); fd.setName("addTableOfContensItem"); - fd.setDescription("addTableOfContensItem(\""+tr("Content")+"\", \""+tr("Page Number")+", \""+tr("Indent")+"\")"); - fd.setScriptWrapper(QString("function addTableOfContensItem(content, pageNumber, indent){" - "return %1.addTableOfContensItem(content, pageNumber, indent);}" + fd.setDescription("addTableOfContensItem(\""+tr("Unique identifier")+" \""+tr("Content")+"\", \""+tr("Page Number")+", \""+tr("Indent")+"\")"); + fd.setScriptWrapper(QString("function addTableOfContensItem(uniqKey, content, pageNumber, indent){" + "return %1.addTableOfContensItem(uniqKey, content, pageNumber, indent);}" ).arg(LimeReport::Const::FUNCTION_MANAGER_NAME) ); return addFunction(fd); @@ -1418,9 +1418,9 @@ QVariant ScriptFunctionsManager::getField(const QString &field) return dm->fieldData(field); } -void ScriptFunctionsManager::addTableOfContensItem(const QString& content, int pageNumber, int indent) +void ScriptFunctionsManager::addTableOfContensItem(const QString& uniqKey, const QString& content, int pageNumber, int indent) { - scriptEngineManager()->addTableOfContensItem(content, pageNumber, indent); + scriptEngineManager()->addTableOfContensItem(uniqKey, content, pageNumber, indent); } void ScriptFunctionsManager::clearTableOfContens() @@ -1470,21 +1470,21 @@ TableOfContens::~TableOfContens() clear(); } -void TableOfContens::setItem(const QString& content, int pageNumber, int indent) +void TableOfContens::setItem(const QString& uniqKey, const QString& content, int pageNumber, int indent) { ContentItem * item = 0; - if (m_hash.contains(content)){ - ContentItem* item = m_hash.value(content); - item->pageNumber = pageNumber; - item->indent = indent; - } else { - ContentItem* item = new ContentItem; + if (m_hash.contains(uniqKey)){ + item = m_hash.value(uniqKey); + item->content = content; + item->pageNumber = pageNumber; + item->indent = indent; + } else { + item = new ContentItem; item->content = content; item->pageNumber = pageNumber; item->indent = indent; - m_tableOfContens.append(item); - m_hash.insert(content, item); + m_hash.insert(uniqKey, item); } } diff --git a/limereport/lrscriptenginemanager.h b/limereport/lrscriptenginemanager.h index 7e46490..fa55a45 100644 --- a/limereport/lrscriptenginemanager.h +++ b/limereport/lrscriptenginemanager.h @@ -67,7 +67,7 @@ class TableOfContens : public QObject{ Q_OBJECT public: ~TableOfContens(); - void setItem(const QString& content, int pageNumber, int indent = 0); + void setItem(const QString& uniqKey, const QString& content, int pageNumber, int indent = 0); void clear(); private slots: void slotOneSlotDS(LimeReport::CallbackInfo info, QVariant &data); @@ -264,7 +264,7 @@ public: Q_INVOKABLE QVariant getVariable(const QString& name); Q_INVOKABLE QVariant getField(const QString& field); Q_INVOKABLE QVariant color(const QString& color){ return QColor(color);} - Q_INVOKABLE void addTableOfContensItem(const QString& content, int pageNumber, int indent = 0); + Q_INVOKABLE void addTableOfContensItem(const QString& uniqKey, const QString& content, int pageNumber, int indent = 0); Q_INVOKABLE void clearTableOfContens(); #ifdef USE_QJSENGINE Q_INVOKABLE QFont font(const QString& family, int pointSize = -1, bool bold = false, bool italic = false, bool underLine = false); @@ -305,7 +305,7 @@ public: QString expandDataFields(QString context, ExpandType expandType, QVariant &varValue, QObject* reportItem); QString expandScripts(QString context, QVariant &varValue, QObject* reportItem); QVariant evaluateScript(const QString &script); - void addTableOfContensItem(const QString& content, int pageNumber, int indent); + void addTableOfContensItem(const QString& uniqKey, const QString& content, int pageNumber, int indent); void clearTableOfContens(){ m_tableOfContens->clear(); } protected: