addTableOfContensItem function has been modified

This commit is contained in:
Arin Alexander 2017-08-19 01:16:57 +03:00
parent c7a5646241
commit f68a8fff65
5 changed files with 24 additions and 39 deletions

View File

@ -331,21 +331,6 @@ void PageItemDesignIntf::initColumnsPos(QVector<qreal> &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;

View File

@ -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<PageItemDesignIntf::Ptr> ReportPages;

View File

@ -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<PageDesignIntf*> pages;
for ( int i = 0; i < m_tabWidget->tabBar()->count(); ++i){

View File

@ -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);
}
}

View File

@ -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: