From 37a5645bf5757fe296c1c5510c6db314e215d3b9 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Thu, 15 Nov 2018 15:24:00 +0100 Subject: [PATCH] Fix some shadow warnings --- src/ExtendedTableWidget.cpp | 8 ++++---- src/ImportCsvDialog.cpp | 3 +-- src/MainWindow.cpp | 16 ++++++++-------- src/PlotDock.cpp | 22 +++++++++++----------- src/RemoteDatabase.cpp | 14 +++++++------- src/sqlitedb.cpp | 3 +-- 6 files changed, 32 insertions(+), 34 deletions(-) diff --git a/src/ExtendedTableWidget.cpp b/src/ExtendedTableWidget.cpp index 1cbe1363..0a3dfe0e 100644 --- a/src/ExtendedTableWidget.cpp +++ b/src/ExtendedTableWidget.cpp @@ -343,10 +343,10 @@ void ExtendedTableWidget::copyMimeData(const QModelIndexList& fromIndices, QMime // Remove all indices from hidden columns, because if we don't we might copy data from hidden columns as well which is very // unintuitive; especially copying the rowid column when selecting all columns of a table is a problem because pasting the data // won't work as expected. - QMutableListIterator i(indices); - while (i.hasNext()) { - if (isColumnHidden(i.next().column())) - i.remove(); + QMutableListIterator it(indices); + while (it.hasNext()) { + if (isColumnHidden(it.next().column())) + it.remove(); } // Abort if there's nothing to copy diff --git a/src/ImportCsvDialog.cpp b/src/ImportCsvDialog.cpp index 23ede69d..e61f7115 100644 --- a/src/ImportCsvDialog.cpp +++ b/src/ImportCsvDialog.cpp @@ -340,8 +340,7 @@ void ImportCsvDialog::updateSelection(bool selected) void ImportCsvDialog::matchSimilar() { - auto item = ui->filePicker->currentItem(); - auto selectedHeader = generateFieldList(item->data(Qt::DisplayRole).toString()); + auto selectedHeader = generateFieldList(ui->filePicker->currentItem()->data(Qt::DisplayRole).toString()); for (int i = 0; i < ui->filePicker->count(); i++) { diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 0594a621..0e6543a9 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -573,11 +573,11 @@ void MainWindow::populateStructure(const QString& old_table) { SqlUiLexer::TablesAndColumnsMap tablesToColumnsMap; objectMap tab = db.getBrowsableObjects(it.key()); - for(auto it : tab) + for(auto jt : tab) { - QString objectname = it->name(); + QString objectname = jt->name(); - sqlb::FieldInfoList fi = it->fieldInformation(); + sqlb::FieldInfoList fi = jt->fieldInformation(); for(const sqlb::FieldInfo& f : fi) tablesToColumnsMap[objectname].append(f.name); } @@ -3670,11 +3670,11 @@ void MainWindow::printDbStructure () for (int column2 = 0; column2 < columnCount; column2++) { if (!treeView->isColumnHidden(column2)) { QModelIndex cellIndex = model->index(rowChild, column2, groupIndex); - QString data = model->data(cellIndex).toString().toHtmlEscaped(); + QString header_data = model->data(cellIndex).toString().toHtmlEscaped(); if (column2 != DbStructureModel::ColumnSQL) - out << QString("

%1

").arg((!data.isEmpty()) ? data : QString(" ")); + out << QString("

%1

").arg((!header_data.isEmpty()) ? header_data : QString(" ")); else - out << QString("
%1
").arg((!data.isEmpty()) ? data : QString(" ")); + out << QString("
%1
").arg((!header_data.isEmpty()) ? header_data : QString(" ")); } } out << ""; @@ -3685,8 +3685,8 @@ void MainWindow::printDbStructure () for (int column2 = 0; column2 < columnCount; column2++) { if (!treeView->isColumnHidden(column2)) { QModelIndex fieldIndex = model->index(rowChild2, column2, objectIndex); - QString data = model->data(fieldIndex).toString().toHtmlEscaped(); - out << QString("%1").arg((!data.isEmpty()) ? data : QString(" ")); + QString field_data = model->data(fieldIndex).toString().toHtmlEscaped(); + out << QString("%1").arg((!field_data.isEmpty()) ? field_data : QString(" ")); } } out << ""; diff --git a/src/PlotDock.cpp b/src/PlotDock.cpp index f4189be9..7b3d5c8b 100644 --- a/src/PlotDock.cpp +++ b/src/PlotDock.cpp @@ -308,50 +308,50 @@ void PlotDock::updatePlot(SqliteTableModel* model, BrowseDataTableSettings* sett QVector xdata(nrows), ydata(nrows), tdata(nrows); QVector labels; - for(int i = 0; i < nrows; ++i) + for(int j = 0; j < nrows; ++j) { - tdata[i] = i; + tdata[i] = j; // convert x type axis if it's datetime switch (xtype) { case QVariant::DateTime: case QVariant::Date: { - QString s = model->data(model->index(i, x)).toString(); + QString s = model->data(model->index(j, x)).toString(); QDateTime d = QDateTime::fromString(s, Qt::ISODate); xdata[i] = d.toMSecsSinceEpoch() / 1000.0; break; } case QVariant::Time: { - QString s = model->data(model->index(i, x)).toString(); + QString s = model->data(model->index(j, x)).toString(); QTime t = QTime::fromString(s); xdata[i] = t.msecsSinceStartOfDay() / 1000.0; break; } case QVariant::String: { - xdata[i] = i+1; - labels << model->data(model->index(i, x)).toString(); + xdata[i] = j+1; + labels << model->data(model->index(j, x)).toString(); break; } default: { // Get the x value for this point. If the selected column is -1, i.e. the row number, just use the current row number from the loop // instead of retrieving some value from the model. if(x == RowNumId) - xdata[i] = i+1; + xdata[i] = j+1; else - xdata[i] = model->data(model->index(i, x)).toDouble(); + xdata[i] = model->data(model->index(j, x)).toDouble(); } } - if (i != 0) + if (j != 0) isSorted &= (xdata[i-1] <= xdata[i]); // Get the y value for this point. If the selected column is -1, i.e. the row number, just use the current row number from the loop // instead of retrieving some value from the model. QVariant pointdata; if(column == RowNumId) - pointdata = i+1; + pointdata = j+1; else - pointdata = model->data(model->index(i, column), Qt::EditRole); + pointdata = model->data(model->index(j, column), Qt::EditRole); if(pointdata.isNull()) ydata[i] = qQNaN(); diff --git a/src/RemoteDatabase.cpp b/src/RemoteDatabase.cpp index a79459b5..a67c989b 100644 --- a/src/RemoteDatabase.cpp +++ b/src/RemoteDatabase.cpp @@ -769,17 +769,17 @@ QString RemoteDatabase::localExists(const QUrl& url, QString identity) // Remove the old entry from the local clones database to enforce a redownload. The file column should be unique for the entire table because the // files are all in the same directory and their names need to be unique because of this. - QString sql = QString("DELETE FROM local WHERE file=?"); - sqlite3_stmt* stmt; - if(sqlite3_prepare_v2(m_dbLocal, sql.toUtf8(), -1, &stmt, nullptr) != SQLITE_OK) + QString delete_sql = QString("DELETE FROM local WHERE file=?"); + sqlite3_stmt* delete_stmt; + if(sqlite3_prepare_v2(m_dbLocal, delete_sql.toUtf8(), -1, &delete_stmt, nullptr) != SQLITE_OK) return QString(); - if(sqlite3_bind_text(stmt, 1, local_file.toUtf8(), local_file.toUtf8().length(), SQLITE_TRANSIENT)) + if(sqlite3_bind_text(delete_stmt, 1, local_file.toUtf8(), local_file.toUtf8().length(), SQLITE_TRANSIENT)) { - sqlite3_finalize(stmt); + sqlite3_finalize(delete_stmt); return QString(); } - sqlite3_step(stmt); - sqlite3_finalize(stmt); + sqlite3_step(delete_stmt); + sqlite3_finalize(delete_stmt); // Return an empty string to indicate a redownload request return QString(); diff --git a/src/sqlitedb.cpp b/src/sqlitedb.cpp index 5eef81d3..73677f9d 100644 --- a/src/sqlitedb.cpp +++ b/src/sqlitedb.cpp @@ -663,8 +663,7 @@ bool DBBrowserDB::dump(const QString& filePath, size_t numRecordsTotal = 0, numRecordsCurrent = 0; objectMap objMap = schemata["main"]; // We only always export the main database, not the attached databases QList tables = objMap.values("table"); - QMutableListIterator it(tables); - while(it.hasNext()) + for(QMutableListIterator it(tables);it.hasNext();) { it.next();