From 6789b01e7913f56f315f69f6bf6c5204c96f2a9f Mon Sep 17 00:00:00 2001 From: Andy Maloney Date: Sat, 8 Apr 2017 18:41:42 -0400 Subject: [PATCH] Fixes some shadowed vars & avoids string copies using const refs --- limereport/items/lrhorizontallayout.cpp | 8 ++++---- limereport/items/lrsimpletagparser.cpp | 2 +- limereport/items/lrtextitemeditor.cpp | 4 ++-- limereport/lrdatadesignintf.cpp | 3 +-- limereport/lrpagedesignintf.cpp | 8 ++++---- limereport/lrreportrender.cpp | 10 +++++----- limereport/serializators/lrxmlreader.cpp | 5 ++--- 7 files changed, 19 insertions(+), 21 deletions(-) diff --git a/limereport/items/lrhorizontallayout.cpp b/limereport/items/lrhorizontallayout.cpp index 3269844..9ca4b0a 100644 --- a/limereport/items/lrhorizontallayout.cpp +++ b/limereport/items/lrhorizontallayout.cpp @@ -390,8 +390,8 @@ void HorizontalLayout::slotOnChildDestroy(QObject* child) BaseDesignIntf* HorizontalLayout::findNext(BaseDesignIntf* item){ if (m_children.count() &storage, QString text, int &curPos tagName.remove('>'); while (buff.contains(rx)){ - int pos=rx.indexIn(buff); + pos=rx.indexIn(buff); buff=buff.right(buff.length()-pos); curPos+=pos; if (extractWord(rx.cap(0),1).compare(extractWord(tagName,1),Qt::CaseInsensitive)==0){ diff --git a/limereport/items/lrtextitemeditor.cpp b/limereport/items/lrtextitemeditor.cpp index e2b6778..09a0e3a 100644 --- a/limereport/items/lrtextitemeditor.cpp +++ b/limereport/items/lrtextitemeditor.cpp @@ -124,8 +124,8 @@ void TextItemEditor::initUI() ui->twData->setModel(dm->datasourcesModel()); ui->twScriptEngine->setModel(se.model()); - foreach(QString dsName,dm->dataSourceNames()){ - foreach(QString field, dm->fieldNames(dsName)){ + foreach(const QString &dsName,dm->dataSourceNames()){ + foreach(const QString &field, dm->fieldNames(dsName)){ dataWords<headerData(columnIndex,Qt::Horizontal, Qt::UserRole).isValid()? m_model->headerData(columnIndex,Qt::Horizontal, Qt::UserRole).toString(): m_model->headerData(columnIndex,Qt::Horizontal).toString(); @@ -704,7 +704,6 @@ int CallbackDatasource::columnCount(){ int currIndex = 0; do { QVariant columnName; - CallbackInfo info; info.dataType = CallbackInfo::ColumnHeaderData; info.index = currIndex; emit getCallbackData(info,columnName); diff --git a/limereport/lrpagedesignintf.cpp b/limereport/lrpagedesignintf.cpp index 2178d43..201403e 100644 --- a/limereport/lrpagedesignintf.cpp +++ b/limereport/lrpagedesignintf.cpp @@ -1304,7 +1304,7 @@ void PageDesignIntf::deleteSelected() } void PageDesignIntf::cut() -{ +{ CommandIf::Ptr command = CutCommand::create(this); saveCommand(command); } @@ -1727,8 +1727,8 @@ CommandIf::Ptr DeleteLayoutCommand::create(PageDesignIntf *page, LayoutDesignInt DeleteLayoutCommand* command = new DeleteLayoutCommand(); command->setPage(page); command->setItem(item); - foreach (BaseDesignIntf* item, item->childBaseItems()){ - command->m_childItems.append(item->objectName()); + foreach (BaseDesignIntf* childItem, item->childBaseItems()){ + command->m_childItems.append(childItem->objectName()); } return CommandIf::Ptr(command); } @@ -1845,7 +1845,7 @@ CommandIf::Ptr CutCommand::create(PageDesignIntf *page) foreach(QGraphicsItem * item, page->selectedItems()) { if (!dynamic_cast(item)){ BaseDesignIntf *reportItem = dynamic_cast(item); - + if (reportItem) { command->m_itemNames.push_back(reportItem->objectName()); writer->putItem(reportItem); diff --git a/limereport/lrreportrender.cpp b/limereport/lrreportrender.cpp index 8d2ccb6..ba678c9 100644 --- a/limereport/lrreportrender.cpp +++ b/limereport/lrreportrender.cpp @@ -254,7 +254,7 @@ void ReportRender::renderPage(PageDesignIntf* patternPage) BandDesignIntf* lastRenderedBand = 0; for (int i=0;idataBandCount() && !m_renderCanceled;i++){ lastRenderedBand = m_patternPageItem->dataBandAt(i); - initDatasource(lastRenderedBand->datasourceName()); + initDatasource(lastRenderedBand->datasourceName()); renderDataBand(lastRenderedBand); if (idataBandCount()-1) closeFooterGroup(lastRenderedBand); } @@ -263,7 +263,7 @@ void ReportRender::renderPage(PageDesignIntf* patternPage) renderBand(reportFooter, 0, StartNewPageAsNeeded); if (lastRenderedBand && lastRenderedBand->keepFooterTogether()) closeFooterGroup(lastRenderedBand); - + BandDesignIntf* tearOffBand = m_patternPageItem->bandByType(BandDesignIntf::TearOffBand); if (tearOffBand) renderBand(tearOffBand, 0, StartNewPageAsNeeded); @@ -335,7 +335,7 @@ void ReportRender::extractGroupsFunction(BandDesignIntf *band) foreach(BaseDesignIntf* item,band->childBaseItems()){ ContentItemDesignIntf* contentItem = dynamic_cast(item); if (contentItem&&(contentItem->content().contains(QRegExp("\\$S\\s*\\{.*\\}")))){ - foreach(QString functionName, m_datasources->groupFunctionNames()){ + foreach(const QString &functionName, m_datasources->groupFunctionNames()){ QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName)); QRegExp rxName(QString(Const::GROUP_FUNCTION_NAME_RX).arg(functionName)); if (rx.indexIn(contentItem->content())>=0){ @@ -373,7 +373,7 @@ void ReportRender::replaceGroupsFunction(BandDesignIntf *band) ContentItemDesignIntf* contentItem = dynamic_cast(item); if (contentItem){ QString content = contentItem->content(); - foreach(QString functionName, m_datasources->groupFunctionNames()){ + foreach(const QString &functionName, m_datasources->groupFunctionNames()){ QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName)); if (rx.indexIn(content)>=0){ int pos = 0; @@ -1229,7 +1229,7 @@ void ReportRender::savePage(bool isLast) m_renderedPages.append(PageItemDesignIntf::Ptr(m_renderPageItem)); m_pageCount++; emit pageRendered(m_pageCount); - + if (isLast){ BandDesignIntf* ph = m_renderPageItem->bandByType(BandDesignIntf::PageHeader); if (ph && !ph->property("printOnLastPage").toBool()){ diff --git a/limereport/serializators/lrxmlreader.cpp b/limereport/serializators/lrxmlreader.cpp index bee2ff8..2e791cd 100644 --- a/limereport/serializators/lrxmlreader.cpp +++ b/limereport/serializators/lrxmlreader.cpp @@ -106,7 +106,6 @@ bool XMLReader::readItem(QObject *item) void XMLReader::readItemFromNode(QObject* item,QDomElement *node) { - ObjectLoadingStateIntf* lf = dynamic_cast(item); if(lf) lf->objectLoadStarted(); for (int i=0;ichildNodes().count();i++){ @@ -123,8 +122,8 @@ void XMLReader::readItemFromNode(QObject* item,QDomElement *node) BaseDesignIntf* baseObj = dynamic_cast(item); if(baseObj) { - foreach(QGraphicsItem* item,baseObj->childItems()){ - BaseDesignIntf* baseItem = dynamic_cast(item); + foreach(QGraphicsItem* childItem,baseObj->childItems()){ + BaseDesignIntf* baseItem = dynamic_cast(childItem); if (baseItem) baseItem->parentObjectLoadFinished(); } }