Merge pull request #70 from asmaloney/fix-shadows

Fixes some shadowed vars & avoids string copies using const refs
This commit is contained in:
fralx 2017-04-10 11:17:38 +03:00 committed by GitHub
commit a5231058ec
7 changed files with 19 additions and 21 deletions

View File

@ -390,8 +390,8 @@ void HorizontalLayout::slotOnChildDestroy(QObject* child)
BaseDesignIntf* HorizontalLayout::findNext(BaseDesignIntf* item){ BaseDesignIntf* HorizontalLayout::findNext(BaseDesignIntf* item){
if (m_children.count()<childItems().size()-1){ if (m_children.count()<childItems().size()-1){
m_children.clear(); m_children.clear();
foreach (BaseDesignIntf* item, childBaseItems()) { foreach (BaseDesignIntf* childItem, childBaseItems()) {
m_children.append(item); m_children.append(childItem);
} }
} }
qSort(m_children.begin(),m_children.end(),lessThen); qSort(m_children.begin(),m_children.end(),lessThen);
@ -404,8 +404,8 @@ BaseDesignIntf* HorizontalLayout::findNext(BaseDesignIntf* item){
BaseDesignIntf* HorizontalLayout::findPrior(BaseDesignIntf* item){ BaseDesignIntf* HorizontalLayout::findPrior(BaseDesignIntf* item){
if (m_children.count()<childItems().size()-1){ if (m_children.count()<childItems().size()-1){
m_children.clear(); m_children.clear();
foreach (BaseDesignIntf* item, childBaseItems()) { foreach (BaseDesignIntf* childItem, childBaseItems()) {
m_children.append(item); m_children.append(childItem);
} }
} }
qSort(m_children.begin(),m_children.end(),lessThen); qSort(m_children.begin(),m_children.end(),lessThen);

View File

@ -63,7 +63,7 @@ QString HtmlContext::parseTag(QVector<Tag *> &storage, QString text, int &curPos
tagName.remove('>'); tagName.remove('>');
while (buff.contains(rx)){ while (buff.contains(rx)){
int pos=rx.indexIn(buff); pos=rx.indexIn(buff);
buff=buff.right(buff.length()-pos); buff=buff.right(buff.length()-pos);
curPos+=pos; curPos+=pos;
if (extractWord(rx.cap(0),1).compare(extractWord(tagName,1),Qt::CaseInsensitive)==0){ if (extractWord(rx.cap(0),1).compare(extractWord(tagName,1),Qt::CaseInsensitive)==0){

View File

@ -124,8 +124,8 @@ void TextItemEditor::initUI()
ui->twData->setModel(dm->datasourcesModel()); ui->twData->setModel(dm->datasourcesModel());
ui->twScriptEngine->setModel(se.model()); ui->twScriptEngine->setModel(se.model());
foreach(QString dsName,dm->dataSourceNames()){ foreach(const QString &dsName,dm->dataSourceNames()){
foreach(QString field, dm->fieldNames(dsName)){ foreach(const QString &field, dm->fieldNames(dsName)){
dataWords<<dsName+"."+field; dataWords<<dsName+"."+field;
} }
} }

View File

@ -299,7 +299,7 @@ int ModelToDataSource::columnCount()
QString ModelToDataSource::columnNameByIndex(int columnIndex) QString ModelToDataSource::columnNameByIndex(int columnIndex)
{ {
if (isInvalid()) return ""; if (isInvalid()) return "";
QString result = m_model->headerData(columnIndex,Qt::Horizontal, Qt::UserRole).isValid()? QString result = m_model->headerData(columnIndex,Qt::Horizontal, Qt::UserRole).isValid()?
m_model->headerData(columnIndex,Qt::Horizontal, Qt::UserRole).toString(): m_model->headerData(columnIndex,Qt::Horizontal, Qt::UserRole).toString():
m_model->headerData(columnIndex,Qt::Horizontal).toString(); m_model->headerData(columnIndex,Qt::Horizontal).toString();
@ -704,7 +704,6 @@ int CallbackDatasource::columnCount(){
int currIndex = 0; int currIndex = 0;
do { do {
QVariant columnName; QVariant columnName;
CallbackInfo info;
info.dataType = CallbackInfo::ColumnHeaderData; info.dataType = CallbackInfo::ColumnHeaderData;
info.index = currIndex; info.index = currIndex;
emit getCallbackData(info,columnName); emit getCallbackData(info,columnName);

View File

@ -1306,7 +1306,7 @@ void PageDesignIntf::deleteSelected()
} }
void PageDesignIntf::cut() void PageDesignIntf::cut()
{ {
CommandIf::Ptr command = CutCommand::create(this); CommandIf::Ptr command = CutCommand::create(this);
saveCommand(command); saveCommand(command);
} }
@ -1729,8 +1729,8 @@ CommandIf::Ptr DeleteLayoutCommand::create(PageDesignIntf *page, LayoutDesignInt
DeleteLayoutCommand* command = new DeleteLayoutCommand(); DeleteLayoutCommand* command = new DeleteLayoutCommand();
command->setPage(page); command->setPage(page);
command->setItem(item); command->setItem(item);
foreach (BaseDesignIntf* item, item->childBaseItems()){ foreach (BaseDesignIntf* childItem, item->childBaseItems()){
command->m_childItems.append(item->objectName()); command->m_childItems.append(childItem->objectName());
} }
return CommandIf::Ptr(command); return CommandIf::Ptr(command);
} }
@ -1847,7 +1847,7 @@ CommandIf::Ptr CutCommand::create(PageDesignIntf *page)
foreach(QGraphicsItem * item, page->selectedItems()) { foreach(QGraphicsItem * item, page->selectedItems()) {
if (!dynamic_cast<PageItemDesignIntf*>(item)){ if (!dynamic_cast<PageItemDesignIntf*>(item)){
BaseDesignIntf *reportItem = dynamic_cast<BaseDesignIntf *>(item); BaseDesignIntf *reportItem = dynamic_cast<BaseDesignIntf *>(item);
if (reportItem) { if (reportItem) {
command->m_itemNames.push_back(reportItem->objectName()); command->m_itemNames.push_back(reportItem->objectName());
writer->putItem(reportItem); writer->putItem(reportItem);

View File

@ -254,7 +254,7 @@ void ReportRender::renderPage(PageDesignIntf* patternPage)
BandDesignIntf* lastRenderedBand = 0; BandDesignIntf* lastRenderedBand = 0;
for (int i=0;i<m_patternPageItem->dataBandCount() && !m_renderCanceled;i++){ for (int i=0;i<m_patternPageItem->dataBandCount() && !m_renderCanceled;i++){
lastRenderedBand = m_patternPageItem->dataBandAt(i); lastRenderedBand = m_patternPageItem->dataBandAt(i);
initDatasource(lastRenderedBand->datasourceName()); initDatasource(lastRenderedBand->datasourceName());
renderDataBand(lastRenderedBand); renderDataBand(lastRenderedBand);
if (i<m_patternPageItem->dataBandCount()-1) closeFooterGroup(lastRenderedBand); if (i<m_patternPageItem->dataBandCount()-1) closeFooterGroup(lastRenderedBand);
} }
@ -263,7 +263,7 @@ void ReportRender::renderPage(PageDesignIntf* patternPage)
renderBand(reportFooter, 0, StartNewPageAsNeeded); renderBand(reportFooter, 0, StartNewPageAsNeeded);
if (lastRenderedBand && lastRenderedBand->keepFooterTogether()) if (lastRenderedBand && lastRenderedBand->keepFooterTogether())
closeFooterGroup(lastRenderedBand); closeFooterGroup(lastRenderedBand);
BandDesignIntf* tearOffBand = m_patternPageItem->bandByType(BandDesignIntf::TearOffBand); BandDesignIntf* tearOffBand = m_patternPageItem->bandByType(BandDesignIntf::TearOffBand);
if (tearOffBand) if (tearOffBand)
renderBand(tearOffBand, 0, StartNewPageAsNeeded); renderBand(tearOffBand, 0, StartNewPageAsNeeded);
@ -335,7 +335,7 @@ void ReportRender::extractGroupsFunction(BandDesignIntf *band)
foreach(BaseDesignIntf* item,band->childBaseItems()){ foreach(BaseDesignIntf* item,band->childBaseItems()){
ContentItemDesignIntf* contentItem = dynamic_cast<ContentItemDesignIntf*>(item); ContentItemDesignIntf* contentItem = dynamic_cast<ContentItemDesignIntf*>(item);
if (contentItem&&(contentItem->content().contains(QRegExp("\\$S\\s*\\{.*\\}")))){ 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 rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
QRegExp rxName(QString(Const::GROUP_FUNCTION_NAME_RX).arg(functionName)); QRegExp rxName(QString(Const::GROUP_FUNCTION_NAME_RX).arg(functionName));
if (rx.indexIn(contentItem->content())>=0){ if (rx.indexIn(contentItem->content())>=0){
@ -373,7 +373,7 @@ void ReportRender::replaceGroupsFunction(BandDesignIntf *band)
ContentItemDesignIntf* contentItem = dynamic_cast<ContentItemDesignIntf*>(item); ContentItemDesignIntf* contentItem = dynamic_cast<ContentItemDesignIntf*>(item);
if (contentItem){ if (contentItem){
QString content = contentItem->content(); 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)); QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
if (rx.indexIn(content)>=0){ if (rx.indexIn(content)>=0){
int pos = 0; int pos = 0;
@ -1234,7 +1234,7 @@ void ReportRender::savePage(bool isLast)
m_renderedPages.append(PageItemDesignIntf::Ptr(m_renderPageItem)); m_renderedPages.append(PageItemDesignIntf::Ptr(m_renderPageItem));
m_pageCount++; m_pageCount++;
emit pageRendered(m_pageCount); emit pageRendered(m_pageCount);
if (isLast){ if (isLast){
BandDesignIntf* ph = m_renderPageItem->bandByType(BandDesignIntf::PageHeader); BandDesignIntf* ph = m_renderPageItem->bandByType(BandDesignIntf::PageHeader);
if (ph && !ph->property("printOnLastPage").toBool()){ if (ph && !ph->property("printOnLastPage").toBool()){

View File

@ -106,7 +106,6 @@ bool XMLReader::readItem(QObject *item)
void XMLReader::readItemFromNode(QObject* item,QDomElement *node) void XMLReader::readItemFromNode(QObject* item,QDomElement *node)
{ {
ObjectLoadingStateIntf* lf = dynamic_cast<ObjectLoadingStateIntf*>(item); ObjectLoadingStateIntf* lf = dynamic_cast<ObjectLoadingStateIntf*>(item);
if(lf) lf->objectLoadStarted(); if(lf) lf->objectLoadStarted();
for (int i=0;i<node->childNodes().count();i++){ for (int i=0;i<node->childNodes().count();i++){
@ -123,8 +122,8 @@ void XMLReader::readItemFromNode(QObject* item,QDomElement *node)
BaseDesignIntf* baseObj = dynamic_cast<BaseDesignIntf*>(item); BaseDesignIntf* baseObj = dynamic_cast<BaseDesignIntf*>(item);
if(baseObj) { if(baseObj) {
foreach(QGraphicsItem* item,baseObj->childItems()){ foreach(QGraphicsItem* childItem,baseObj->childItems()){
BaseDesignIntf* baseItem = dynamic_cast<BaseDesignIntf*>(item); BaseDesignIntf* baseItem = dynamic_cast<BaseDesignIntf*>(childItem);
if (baseItem) baseItem->parentObjectLoadFinished(); if (baseItem) baseItem->parentObjectLoadFinished();
} }
} }