0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-25 00:54:39 +03:00

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){
if (m_children.count()<childItems().size()-1){
m_children.clear();
foreach (BaseDesignIntf* item, childBaseItems()) {
m_children.append(item);
foreach (BaseDesignIntf* childItem, childBaseItems()) {
m_children.append(childItem);
}
}
qSort(m_children.begin(),m_children.end(),lessThen);
@ -404,8 +404,8 @@ BaseDesignIntf* HorizontalLayout::findNext(BaseDesignIntf* item){
BaseDesignIntf* HorizontalLayout::findPrior(BaseDesignIntf* item){
if (m_children.count()<childItems().size()-1){
m_children.clear();
foreach (BaseDesignIntf* item, childBaseItems()) {
m_children.append(item);
foreach (BaseDesignIntf* childItem, childBaseItems()) {
m_children.append(childItem);
}
}
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('>');
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){

View File

@ -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<<dsName+"."+field;
}
}

View File

@ -299,7 +299,7 @@ int ModelToDataSource::columnCount()
QString ModelToDataSource::columnNameByIndex(int columnIndex)
{
if (isInvalid()) return "";
if (isInvalid()) return "";
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).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);

View File

@ -1306,7 +1306,7 @@ void PageDesignIntf::deleteSelected()
}
void PageDesignIntf::cut()
{
{
CommandIf::Ptr command = CutCommand::create(this);
saveCommand(command);
}
@ -1729,8 +1729,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);
}
@ -1847,7 +1847,7 @@ CommandIf::Ptr CutCommand::create(PageDesignIntf *page)
foreach(QGraphicsItem * item, page->selectedItems()) {
if (!dynamic_cast<PageItemDesignIntf*>(item)){
BaseDesignIntf *reportItem = dynamic_cast<BaseDesignIntf *>(item);
if (reportItem) {
command->m_itemNames.push_back(reportItem->objectName());
writer->putItem(reportItem);

View File

@ -254,7 +254,7 @@ void ReportRender::renderPage(PageDesignIntf* patternPage)
BandDesignIntf* lastRenderedBand = 0;
for (int i=0;i<m_patternPageItem->dataBandCount() && !m_renderCanceled;i++){
lastRenderedBand = m_patternPageItem->dataBandAt(i);
initDatasource(lastRenderedBand->datasourceName());
initDatasource(lastRenderedBand->datasourceName());
renderDataBand(lastRenderedBand);
if (i<m_patternPageItem->dataBandCount()-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<ContentItemDesignIntf*>(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<ContentItemDesignIntf*>(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;
@ -1234,7 +1234,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()){

View File

@ -106,7 +106,6 @@ bool XMLReader::readItem(QObject *item)
void XMLReader::readItemFromNode(QObject* item,QDomElement *node)
{
ObjectLoadingStateIntf* lf = dynamic_cast<ObjectLoadingStateIntf*>(item);
if(lf) lf->objectLoadStarted();
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);
if(baseObj) {
foreach(QGraphicsItem* item,baseObj->childItems()){
BaseDesignIntf* baseItem = dynamic_cast<BaseDesignIntf*>(item);
foreach(QGraphicsItem* childItem,baseObj->childItems()){
BaseDesignIntf* baseItem = dynamic_cast<BaseDesignIntf*>(childItem);
if (baseItem) baseItem->parentObjectLoadFinished();
}
}