Fix some shadow warnings

This commit is contained in:
Martin Kleusberg
2018-11-15 15:24:00 +01:00
parent c91009c7f3
commit 37a5645bf5
6 changed files with 32 additions and 34 deletions

View File

@@ -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<QModelIndex> i(indices);
while (i.hasNext()) {
if (isColumnHidden(i.next().column()))
i.remove();
QMutableListIterator<QModelIndex> it(indices);
while (it.hasNext()) {
if (isColumnHidden(it.next().column()))
it.remove();
}
// Abort if there's nothing to copy

View File

@@ -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++)
{

View File

@@ -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("<td><h2>%1</h2></td>").arg((!data.isEmpty()) ? data : QString("&nbsp;"));
out << QString("<td><h2>%1</h2></td>").arg((!header_data.isEmpty()) ? header_data : QString("&nbsp;"));
else
out << QString("<td><pre>%1</pre></td>").arg((!data.isEmpty()) ? data : QString("&nbsp;"));
out << QString("<td><pre>%1</pre></td>").arg((!header_data.isEmpty()) ? header_data : QString("&nbsp;"));
}
}
out << "</tr>";
@@ -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("<td>%1</td>").arg((!data.isEmpty()) ? data : QString("&nbsp;"));
QString field_data = model->data(fieldIndex).toString().toHtmlEscaped();
out << QString("<td>%1</td>").arg((!field_data.isEmpty()) ? field_data : QString("&nbsp;"));
}
}
out << "</tr>";

View File

@@ -308,50 +308,50 @@ void PlotDock::updatePlot(SqliteTableModel* model, BrowseDataTableSettings* sett
QVector<double> xdata(nrows), ydata(nrows), tdata(nrows);
QVector<QString> 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();

View File

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

View File

@@ -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<sqlb::ObjectPtr> tables = objMap.values("table");
QMutableListIterator<sqlb::ObjectPtr> it(tables);
while(it.hasNext())
for(QMutableListIterator<sqlb::ObjectPtr> it(tables);it.hasNext();)
{
it.next();