mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-19 18:40:13 -06:00
Replace 'foreach' by range-based for loop from C++11
This commit is contained in:
@@ -128,7 +128,7 @@ Application::Application(int& argc, char** argv) :
|
||||
if(m_mainWindow->fileOpen(fileToOpen))
|
||||
{
|
||||
// If database could be opened run the SQL scripts
|
||||
foreach(const QString& f, sqlToExecute)
|
||||
for(const QString& f : sqlToExecute)
|
||||
{
|
||||
QFile file(f);
|
||||
if(file.open(QIODevice::ReadOnly))
|
||||
|
||||
@@ -192,7 +192,7 @@ QMimeData* DbStructureModel::mimeData(const QModelIndexList& indices) const
|
||||
{
|
||||
// Loop through selected indices
|
||||
QByteArray d;
|
||||
foreach(QModelIndex index, indices)
|
||||
for(const QModelIndex& index : indices)
|
||||
{
|
||||
// Only export data for valid indices and only for the SQL column, i.e. only once per row
|
||||
if(index.isValid() && index.column() == ColumnSQL)
|
||||
@@ -306,11 +306,11 @@ void DbStructureModel::buildTree(QTreeWidgetItem* parent, const QString& schema)
|
||||
if((*it)->type() == sqlb::Object::Types::Table)
|
||||
{
|
||||
sqlb::FieldVector pk = (*it).dynamicCast<sqlb::Table>()->primaryKey();
|
||||
foreach(sqlb::FieldPtr pk_col, pk)
|
||||
for(const sqlb::FieldPtr& pk_col : pk)
|
||||
pk_columns.push_back(pk_col->name());
|
||||
|
||||
}
|
||||
foreach(const sqlb::FieldInfo& field, fieldList)
|
||||
for(const sqlb::FieldInfo& field : fieldList)
|
||||
{
|
||||
QTreeWidgetItem *fldItem = new QTreeWidgetItem(item);
|
||||
fldItem->setText(ColumnName, field.name);
|
||||
|
||||
@@ -525,7 +525,7 @@ QString EditDialog::humanReadableSize(double byteCount) const
|
||||
QStringList units;
|
||||
units << "" << "Ki" << "Mi" << "Gi" << "Ti" << "Pi" << "Ei" << "Zi";
|
||||
|
||||
foreach(const QString& unit, units)
|
||||
for(const QString& unit : units)
|
||||
{
|
||||
if(fabs(byteCount) < 1024.0)
|
||||
{
|
||||
|
||||
@@ -105,7 +105,7 @@ void EditTableDialog::populateFields()
|
||||
ui->treeWidget->clear();
|
||||
sqlb::FieldVector fields = m_table.fields();
|
||||
sqlb::FieldVector pk = m_table.primaryKey();
|
||||
foreach(sqlb::FieldPtr f, fields)
|
||||
for(const sqlb::FieldPtr& f : fields)
|
||||
{
|
||||
QTreeWidgetItem *tbitem = new QTreeWidgetItem(ui->treeWidget);
|
||||
tbitem->setFlags(tbitem->flags() | Qt::ItemIsEditable);
|
||||
@@ -211,7 +211,7 @@ void EditTableDialog::checkInput()
|
||||
|
||||
// update fk's that refer to table itself recursively
|
||||
sqlb::FieldVector fields = m_table.fields();
|
||||
foreach(sqlb::FieldPtr f, fields) {
|
||||
for(const sqlb::FieldPtr& f : fields) {
|
||||
QSharedPointer<sqlb::ForeignKeyClause> fk = m_table.constraint({f}, sqlb::Constraint::ForeignKeyConstraintType).dynamicCast<sqlb::ForeignKeyClause>();
|
||||
if(!fk.isNull()) {
|
||||
if (oldTableName == fk->table()) {
|
||||
@@ -300,10 +300,10 @@ void EditTableDialog::itemChanged(QTreeWidgetItem *item, int column)
|
||||
if(!m_bNewTable)
|
||||
{
|
||||
sqlb::FieldVector pk = m_table.primaryKey();
|
||||
foreach(const sqlb::ObjectPtr& fkobj, pdb.schemata[curTable.schema()].values("table"))
|
||||
for(const sqlb::ObjectPtr& fkobj : pdb.schemata[curTable.schema()].values("table"))
|
||||
{
|
||||
QList<sqlb::ConstraintPtr> fks = fkobj.dynamicCast<sqlb::Table>()->constraints(sqlb::FieldVector(), sqlb::Constraint::ForeignKeyConstraintType);
|
||||
foreach(sqlb::ConstraintPtr fkptr, fks)
|
||||
for(const sqlb::ConstraintPtr& fkptr : fks)
|
||||
{
|
||||
QSharedPointer<sqlb::ForeignKeyClause> fk = fkptr.dynamicCast<sqlb::ForeignKeyClause>();
|
||||
if(fk->table() == m_table.name())
|
||||
|
||||
@@ -324,7 +324,7 @@ void ExportDataDialog::accept()
|
||||
return;
|
||||
}
|
||||
|
||||
foreach(QListWidgetItem* item, selectedItems)
|
||||
for(const QListWidgetItem* item : selectedItems)
|
||||
filenames << QDir(exportfolder).filePath(item->text() + default_file_extension);
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ void ExportSqlDialog::accept()
|
||||
settings.endGroup();
|
||||
|
||||
QStringList tables;
|
||||
foreach (const QListWidgetItem * item, ui->listTables->selectedItems())
|
||||
for(const QListWidgetItem* item : ui->listTables->selectedItems())
|
||||
tables.push_back(item->text());
|
||||
|
||||
// Check what to export. The indices here depend on the order of the items in the combobox in the ui file
|
||||
|
||||
@@ -109,7 +109,7 @@ ExtendedTableWidget::ExtendedTableWidget(QWidget* parent) :
|
||||
useAsFilter();
|
||||
});
|
||||
connect(nullAction, &QAction::triggered, [&]() {
|
||||
foreach(const QModelIndex& index, selectedIndexes())
|
||||
for(const QModelIndex& index : selectedIndexes())
|
||||
model()->setData(index, QVariant());
|
||||
});
|
||||
connect(copyAction, &QAction::triggered, [&]() {
|
||||
@@ -172,11 +172,13 @@ void ExtendedTableWidget::copy()
|
||||
|
||||
// If any of the cells contain binary data - we use inner buffer
|
||||
bool containsBinary = false;
|
||||
foreach (const QModelIndex& index, indices)
|
||||
for(const QModelIndex& index : indices)
|
||||
{
|
||||
if (m->isBinary(index)) {
|
||||
containsBinary = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (containsBinary) {
|
||||
qApp->clipboard()->clear();
|
||||
@@ -198,7 +200,7 @@ void ExtendedTableWidget::copy()
|
||||
QString result;
|
||||
int currentRow = 0;
|
||||
|
||||
foreach(const QModelIndex& index, indices) {
|
||||
for(const QModelIndex& index : indices) {
|
||||
if (first == index) { /* first index */ }
|
||||
else if (index.row() != currentRow)
|
||||
result.append("\r\n");
|
||||
@@ -259,9 +261,9 @@ void ExtendedTableWidget::paste()
|
||||
|
||||
int row = firstRow;
|
||||
|
||||
foreach(const QByteArrayList& lst, m_buffer) {
|
||||
for(const QByteArrayList& lst : m_buffer) {
|
||||
int column = firstColumn;
|
||||
foreach(const QByteArray& ba, lst) {
|
||||
for(const QByteArray& ba : lst) {
|
||||
m->setData(m->index(row, column), ba);
|
||||
|
||||
column++;
|
||||
@@ -315,10 +317,10 @@ void ExtendedTableWidget::paste()
|
||||
int lastColumn = qMin(firstColumn + clipboardColumns - 1, m->columnCount() - 1);
|
||||
|
||||
int row = firstRow;
|
||||
foreach(const QStringList& clipboardRow, clipboardTable)
|
||||
for(const QStringList& clipboardRow : clipboardTable)
|
||||
{
|
||||
int column = firstColumn;
|
||||
foreach(const QString& cell, clipboardRow)
|
||||
for(const QString& cell : clipboardRow)
|
||||
{
|
||||
if (cell.isEmpty())
|
||||
m->setData(m->index(row, column), QVariant());
|
||||
@@ -383,11 +385,11 @@ void ExtendedTableWidget::keyPressEvent(QKeyEvent* event)
|
||||
if(event->modifiers().testFlag(Qt::AltModifier))
|
||||
{
|
||||
// When pressing Alt+Delete set the value to NULL
|
||||
foreach(const QModelIndex& index, selectedIndexes())
|
||||
for(const QModelIndex& index : selectedIndexes())
|
||||
model()->setData(index, QVariant());
|
||||
} else {
|
||||
// When pressing Delete only set the value to empty string
|
||||
foreach(const QModelIndex& index, selectedIndexes())
|
||||
for(const QModelIndex& index : selectedIndexes())
|
||||
model()->setData(index, "");
|
||||
}
|
||||
} else if(event->modifiers().testFlag(Qt::ControlModifier) && (event->key() == Qt::Key_PageUp || event->key() == Qt::Key_PageDown)) {
|
||||
@@ -442,7 +444,7 @@ int ExtendedTableWidget::numVisibleRows()
|
||||
QSet<int> ExtendedTableWidget::selectedCols()
|
||||
{
|
||||
QSet<int> selectedCols;
|
||||
foreach(const QModelIndex & idx, selectedIndexes())
|
||||
for(const QModelIndex & idx : selectedIndexes())
|
||||
selectedCols.insert(idx.column());
|
||||
return selectedCols;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ void FilterTableHeader::inputChanged(const QString& new_value)
|
||||
|
||||
void FilterTableHeader::clearFilters()
|
||||
{
|
||||
foreach (FilterLineEdit* filterLineEdit, filterWidgets)
|
||||
for(FilterLineEdit* filterLineEdit : filterWidgets)
|
||||
filterLineEdit->clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ ImportCsvDialog::ImportCsvDialog(const QStringList &filenames, DBBrowserDB* db,
|
||||
|
||||
// Create a list of all available encodings and create an auto completion list from them
|
||||
QStringList encodingList;
|
||||
foreach(QString enc, QTextCodec::availableCodecs())
|
||||
for(const QString& enc : QTextCodec::availableCodecs())
|
||||
encodingList.push_back(enc);
|
||||
encodingCompleter = new QCompleter(encodingList, this);
|
||||
encodingCompleter->setCaseSensitivity(Qt::CaseInsensitive);
|
||||
@@ -237,7 +237,7 @@ void ImportCsvDialog::updatePreview()
|
||||
|
||||
// Set horizontal header data
|
||||
QStringList horizontalHeader;
|
||||
foreach(const sqlb::FieldPtr& field, fieldList)
|
||||
for(const sqlb::FieldPtr& field : fieldList)
|
||||
horizontalHeader.push_back(field->name());
|
||||
ui->tablePreview->setHorizontalHeaderLabels(horizontalHeader);
|
||||
|
||||
@@ -557,7 +557,7 @@ bool ImportCsvDialog::importCsv(const QString& fileName, const QString& name)
|
||||
sqlb::TablePtr tbl = pdb->getObjectByName(sqlb::ObjectIdentifier("main", tableName)).dynamicCast<sqlb::Table>();
|
||||
if(tbl)
|
||||
{
|
||||
foreach(const sqlb::FieldPtr& f, tbl->fields())
|
||||
for(const sqlb::FieldPtr& f : tbl->fields())
|
||||
{
|
||||
if(f->isInteger() && f->notnull()) // If this is an integer column but NULL isn't allowed, insert 0
|
||||
nullValues << "0";
|
||||
|
||||
@@ -412,7 +412,7 @@ void MainWindow::populateStructure()
|
||||
QString objectname = (*it)->name();
|
||||
|
||||
sqlb::FieldInfoList fi = (*it)->fieldInformation();
|
||||
foreach(const sqlb::FieldInfo& f, fi)
|
||||
for(const sqlb::FieldInfo& f : fi)
|
||||
tablesToColumnsMap[objectname].append(f.name);
|
||||
}
|
||||
}
|
||||
@@ -1182,7 +1182,7 @@ void MainWindow::importTableFromCSV()
|
||||
tr("Text files(*.csv *.txt);;All files(*)"));
|
||||
|
||||
QStringList validFiles;
|
||||
foreach(auto file, wFiles) {
|
||||
for(const auto& file : wFiles) {
|
||||
if (QFile::exists(file))
|
||||
validFiles.append(file);
|
||||
}
|
||||
@@ -1481,7 +1481,7 @@ void MainWindow::addToRecentFilesMenu(const QString& filename)
|
||||
|
||||
Settings::setValue("General", "recentFileList", files);
|
||||
|
||||
foreach (QWidget *widget, QApplication::topLevelWidgets()) {
|
||||
for(QWidget* widget : QApplication::topLevelWidgets()) {
|
||||
MainWindow *mainWin = qobject_cast<MainWindow *>(widget);
|
||||
if (mainWin)
|
||||
mainWin->updateRecentFileActions();
|
||||
@@ -1833,7 +1833,7 @@ void MainWindow::loadExtensionsFromSettings()
|
||||
return;
|
||||
|
||||
QStringList list = Settings::getValue("extensions", "list").toStringList();
|
||||
foreach(QString ext, list)
|
||||
for(const QString& ext : list)
|
||||
{
|
||||
if(db.loadExtension(ext) == false)
|
||||
QMessageBox::warning(this, QApplication::applicationName(), tr("Error loading extension: %1").arg(db.lastError()));
|
||||
@@ -1972,7 +1972,7 @@ void MainWindow::updateBrowseDataColumnWidth(int section, int /*old_size*/, int
|
||||
else
|
||||
{
|
||||
ui->dataTable->blockSignals(true);
|
||||
foreach (int col, selectedCols)
|
||||
for(int col : selectedCols)
|
||||
{
|
||||
ui->dataTable->setColumnWidth(col, new_size);
|
||||
browseTableSettings[tableName].columnWidths[col] = new_size;
|
||||
@@ -2583,7 +2583,7 @@ void MainWindow::hideColumns(int column, bool hide)
|
||||
}
|
||||
|
||||
// (Un)hide requested column(s)
|
||||
foreach(int col, columns)
|
||||
for(int col : columns)
|
||||
{
|
||||
ui->dataTable->setColumnHidden(col, hide);
|
||||
if(!hide)
|
||||
|
||||
@@ -143,10 +143,10 @@ void PreferencesDialog::loadSettings()
|
||||
}
|
||||
{
|
||||
QStringList client_certs = Settings::getValue("remote", "client_certificates").toStringList();
|
||||
foreach(const QString& file, client_certs)
|
||||
for(const QString& file : client_certs)
|
||||
{
|
||||
auto certs = QSslCertificate::fromPath(file);
|
||||
foreach(const QSslCertificate& cert, certs)
|
||||
for(const QSslCertificate& cert : certs)
|
||||
addClientCertToTable(file, cert);
|
||||
}
|
||||
}
|
||||
@@ -214,7 +214,7 @@ void PreferencesDialog::saveSettings()
|
||||
Settings::setValue("editor", "horizontal_tiling", ui->checkHorizontalTiling->isChecked());
|
||||
|
||||
QStringList extList;
|
||||
foreach(QListWidgetItem* item, ui->listExtensions->findItems(QString("*"), Qt::MatchWrap | Qt::MatchWildcard))
|
||||
for(const QListWidgetItem* item : ui->listExtensions->findItems(QString("*"), Qt::MatchWrap | Qt::MatchWildcard))
|
||||
extList.append(item->text());
|
||||
Settings::setValue("extensions", "list", extList);
|
||||
Settings::setValue("extensions", "disableregex", ui->checkRegexDisabled->isChecked());
|
||||
@@ -254,7 +254,7 @@ void PreferencesDialog::saveSettings()
|
||||
new_client_certs.push_back(copy_to);
|
||||
}
|
||||
}
|
||||
foreach(const QString& file, old_client_certs)
|
||||
for(const QString& file : old_client_certs)
|
||||
{
|
||||
// Now only the deleted client certs are still in the old list. Delete the cert files associated with them.
|
||||
QFile::remove(file);
|
||||
@@ -368,7 +368,7 @@ void PreferencesDialog::fillLanguageBox()
|
||||
// Get available *.qm files from translation dir near executable as well as from resources
|
||||
QFileInfoList file_infos = translationsDir.entryInfoList();
|
||||
file_infos += QDir(":/translations").entryInfoList();
|
||||
foreach(const QFileInfo &file, file_infos)
|
||||
for(const QFileInfo& file : file_infos)
|
||||
{
|
||||
QLocale locale(file.baseName().remove("sqlb_"));
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ RemoteDatabase::RemoteDatabase() :
|
||||
QDir dirCaCerts(":/certs");
|
||||
QStringList caCertsList = dirCaCerts.entryList();
|
||||
QList<QSslCertificate> caCerts;
|
||||
foreach(const QString& caCertName, caCertsList)
|
||||
for(const QString& caCertName : caCertsList)
|
||||
caCerts += QSslCertificate::fromPath(":/certs/" + caCertName);
|
||||
m_sslConfiguration.setCaCertificates(caCerts);
|
||||
|
||||
@@ -60,7 +60,7 @@ void RemoteDatabase::reloadSettings()
|
||||
// Load all configured client certificates
|
||||
m_clientCertFiles.clear();
|
||||
auto client_certs = Settings::getValue("remote", "client_certificates").toStringList();
|
||||
foreach(const QString& path, client_certs)
|
||||
for(const QString& path : client_certs)
|
||||
{
|
||||
QFile file(path);
|
||||
file.open(QFile::ReadOnly);
|
||||
@@ -240,7 +240,7 @@ void RemoteDatabase::gotError(QNetworkReply* reply, const QList<QSslError>& erro
|
||||
{
|
||||
// Are there any errors in here that aren't about self-signed certificates and non-matching hostnames?
|
||||
bool serious_errors = false;
|
||||
foreach(const QSslError& error, errors)
|
||||
for(const QSslError& error : errors)
|
||||
{
|
||||
if(error.error() != QSslError::SelfSignedCertificate)
|
||||
{
|
||||
|
||||
@@ -41,10 +41,10 @@ void RemoteDock::reloadSettings()
|
||||
// Load list of client certs
|
||||
ui->comboUser->clear();
|
||||
QStringList client_certs = Settings::getValue("remote", "client_certificates").toStringList();
|
||||
foreach(const QString& file, client_certs)
|
||||
for(const QString& file : client_certs)
|
||||
{
|
||||
auto certs = QSslCertificate::fromPath(file);
|
||||
foreach(const QSslCertificate& cert, certs)
|
||||
for(const QSslCertificate& cert : certs)
|
||||
ui->comboUser->addItem(cert.subjectInfo(QSslCertificate::CommonName).at(0), file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ void RemoteModel::parseDirectoryListing(const QString& json, const QVariant& use
|
||||
// Insert data
|
||||
beginInsertRows(parent, 0, array.size());
|
||||
QList<RemoteModelItem*> items = RemoteModelItem::loadArray(QJsonValue(array), parentItem);
|
||||
foreach(RemoteModelItem* item, items)
|
||||
for(RemoteModelItem* item : items)
|
||||
parentItem->appendChild(item);
|
||||
endInsertRows();
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ void RemotePushDialog::fillInBranches(const QStringList& branches, const QString
|
||||
ui->comboBranch->addItem(default_branch);
|
||||
|
||||
// Add rest of the branch list to the combo box
|
||||
foreach(const QString& branch, branches)
|
||||
for(const QString& branch : branches)
|
||||
{
|
||||
if(branch != default_branch)
|
||||
ui->comboBranch->addItem(branch);
|
||||
|
||||
@@ -47,7 +47,7 @@ void SqlUiLexer::setupAutoCompletion()
|
||||
<< "WHERE" << "WITH" << "WITHOUT"
|
||||
// Data types
|
||||
<< "INT" << "INTEGER" << "REAL" << "TEXT" << "BLOB" << "NUMERIC" << "CHAR";
|
||||
foreach(const QString& keyword, keywordPatterns)
|
||||
for(const QString& keyword : keywordPatterns)
|
||||
{
|
||||
autocompleteApi->add(keyword + "?" + QString::number(ApiCompleterIconIdKeyword));
|
||||
autocompleteApi->add(keyword.toLower() + "?" + QString::number(ApiCompleterIconIdKeyword));
|
||||
@@ -113,7 +113,7 @@ void SqlUiLexer::setupAutoCompletion()
|
||||
<< "total" + tr("(X) The sum() and total() aggregate functions return sum of all non-NULL values in the group.");
|
||||
|
||||
listFunctions.clear();
|
||||
foreach(const QString& keyword, functionPatterns)
|
||||
for(const QString& keyword : functionPatterns)
|
||||
{
|
||||
QString fn = keyword.left(keyword.indexOf('('));
|
||||
QString descr = keyword.mid(keyword.indexOf('('));
|
||||
@@ -134,7 +134,7 @@ void SqlUiLexer::setTableNames(const TablesAndColumnsMap& tables)
|
||||
setupAutoCompletion();
|
||||
for(auto it=tables.constBegin();it!=tables.constEnd();++it)
|
||||
{
|
||||
foreach(const QString& field, it.value())
|
||||
for(const QString& field : it.value())
|
||||
autocompleteApi->add(it.key() + "?" + QString::number(SqlUiLexer::ApiCompleterIconIdTable) + "." +
|
||||
field + "?" + QString::number(SqlUiLexer::ApiCompleterIconIdColumn));
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ void VacuumDialog::accept()
|
||||
|
||||
// Loop through all selected databases and vacuum them individually
|
||||
QList<QTreeWidgetItem*> selection = ui->treeDatabases->selectedItems();
|
||||
foreach(QTreeWidgetItem* item, selection)
|
||||
for(const QTreeWidgetItem* item : selection)
|
||||
db->executeSQL(QString("VACUUM %1;").arg(sqlb::escapeIdentifier(item->text(0))), false);
|
||||
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
@@ -371,7 +371,7 @@ bool DBBrowserDB::revertToSavepoint(const QString& pointname)
|
||||
|
||||
bool DBBrowserDB::releaseAllSavepoints()
|
||||
{
|
||||
foreach(const QString& point, savepointList)
|
||||
for(const QString& point : savepointList)
|
||||
{
|
||||
if(!releaseSavepoint(point))
|
||||
return false;
|
||||
@@ -386,7 +386,7 @@ bool DBBrowserDB::releaseAllSavepoints()
|
||||
|
||||
bool DBBrowserDB::revertAll()
|
||||
{
|
||||
foreach(const QString& point, savepointList)
|
||||
for(const QString& point : savepointList)
|
||||
{
|
||||
if(!revertToSavepoint(point))
|
||||
return false;
|
||||
@@ -890,7 +890,7 @@ QString DBBrowserDB::emptyInsertStmt(const QString& schemaName, const sqlb::Tabl
|
||||
|
||||
QStringList vals;
|
||||
QStringList fields;
|
||||
foreach(sqlb::FieldPtr f, t.fields())
|
||||
for(const sqlb::FieldPtr& f : t.fields())
|
||||
{
|
||||
sqlb::ConstraintPtr pk = t.constraint({f}, sqlb::Constraint::PrimaryKeyConstraintType);
|
||||
if(pk)
|
||||
@@ -932,7 +932,7 @@ QString DBBrowserDB::emptyInsertStmt(const QString& schemaName, const sqlb::Tabl
|
||||
stmt.append(" DEFAULT VALUES;");
|
||||
} else {
|
||||
stmt.append("(");
|
||||
foreach(const QString& f, fields)
|
||||
for(const QString& f : fields)
|
||||
stmt.append(sqlb::escapeIdentifier(f) + ",");
|
||||
stmt.chop(1);
|
||||
stmt.append(") VALUES (");
|
||||
@@ -978,7 +978,7 @@ bool DBBrowserDB::deleteRecords(const sqlb::ObjectIdentifier& table, const QStri
|
||||
if (!isOpen()) return false;
|
||||
|
||||
QStringList quoted_rowids;
|
||||
foreach(QString rowid, rowids)
|
||||
for(const QString& rowid : rowids)
|
||||
quoted_rowids.append("'" + rowid + "'");
|
||||
|
||||
QString statement = QString("DELETE FROM %1 WHERE %2 IN (%3);")
|
||||
@@ -1267,7 +1267,7 @@ bool DBBrowserDB::renameColumn(const sqlb::ObjectIdentifier& tablename, const sq
|
||||
|
||||
// Restore the saved triggers, views and indices
|
||||
QString errored_sqls;
|
||||
foreach(const QString& sql, otherObjectsSql)
|
||||
for(const QString& sql : otherObjectsSql)
|
||||
{
|
||||
if(!executeSQL(sql, true, true))
|
||||
errored_sqls += sql + "\n";
|
||||
@@ -1430,11 +1430,11 @@ void DBBrowserDB::updateSchema()
|
||||
if(type == sqlb::Object::Types::Table)
|
||||
{
|
||||
sqlb::TablePtr tab = object.dynamicCast<sqlb::Table>();
|
||||
foreach(const auto& column, columns)
|
||||
for(const auto& column : columns)
|
||||
tab->addField(sqlb::FieldPtr(new sqlb::Field(column.first, column.second)));
|
||||
} else {
|
||||
sqlb::ViewPtr view = object.dynamicCast<sqlb::View>();
|
||||
foreach(const auto& column, columns)
|
||||
for(const auto& column : columns)
|
||||
view->addField(sqlb::FieldPtr(new sqlb::Field(column.first, column.second)));
|
||||
}
|
||||
} else if(type == sqlb::Object::Types::Trigger) {
|
||||
|
||||
@@ -77,7 +77,7 @@ void SqliteTableModel::setTable(const sqlb::ObjectIdentifier& table, int sortCol
|
||||
<< "REAL"
|
||||
<< "TEXT"
|
||||
<< "BLOB";
|
||||
foreach(const sqlb::FieldPtr fld, t->fields())
|
||||
for(const sqlb::FieldPtr& fld : t->fields())
|
||||
{
|
||||
QString name(fld->type().toUpper());
|
||||
int colType = dataTypes.indexOf(name);
|
||||
|
||||
@@ -19,7 +19,7 @@ QString escapeIdentifier(QString id)
|
||||
QStringList fieldVectorToFieldNames(const FieldVector& vector)
|
||||
{
|
||||
QStringList result;
|
||||
foreach(const FieldPtr& field, vector)
|
||||
for(const FieldPtr& field : vector)
|
||||
result.append(escapeIdentifier(field->name()));
|
||||
return result;
|
||||
}
|
||||
@@ -175,7 +175,7 @@ QString ForeignKeyClause::toString() const
|
||||
if(m_columns.size())
|
||||
{
|
||||
result += "(";
|
||||
foreach(const QString& column, m_columns)
|
||||
for(const QString& column : m_columns)
|
||||
result += escapeIdentifier(column) + ',';
|
||||
result.chop(1); // Remove last comma
|
||||
result += ")";
|
||||
@@ -306,13 +306,13 @@ Table& Table::operator=(const Table& rhs)
|
||||
|
||||
// Make copies of the fields and the constraints. This is necessary in order to avoid any unwanted changes to the application's main database
|
||||
// schema representation just modifying a reference to the fields or constraints and thinking it operates on a copy.
|
||||
foreach(FieldPtr f, rhs.m_fields)
|
||||
for(const FieldPtr& f : rhs.m_fields)
|
||||
addField(FieldPtr(new Field(*f)));
|
||||
for(auto it=rhs.m_constraints.constBegin();it!=rhs.m_constraints.constEnd();++it) // TODO This is so ugly, it should be replaced really by anything else
|
||||
{
|
||||
FieldVector key;
|
||||
ConstraintPtr constraint;
|
||||
foreach(FieldPtr f, it.key())
|
||||
for(const FieldPtr& f : it.key())
|
||||
key.push_back(m_fields.at(findField(f->name())));
|
||||
if(it.value()->type() == Constraint::ConstraintTypes::PrimaryKeyConstraintType)
|
||||
constraint = ConstraintPtr(new PrimaryKeyConstraint(*(it.value().dynamicCast<PrimaryKeyConstraint>())));
|
||||
@@ -415,9 +415,8 @@ QStringList Table::fieldList() const
|
||||
{
|
||||
QStringList sl;
|
||||
|
||||
foreach(const FieldPtr& f, m_fields) {
|
||||
for(const FieldPtr& f : m_fields)
|
||||
sl << f->toString();
|
||||
}
|
||||
|
||||
return sl;
|
||||
}
|
||||
@@ -426,7 +425,7 @@ QStringList Table::fieldNames() const
|
||||
{
|
||||
QStringList sl;
|
||||
|
||||
foreach(FieldPtr f, m_fields)
|
||||
for(const FieldPtr& f : m_fields)
|
||||
sl << f->name();
|
||||
|
||||
return sl;
|
||||
@@ -435,14 +434,14 @@ QStringList Table::fieldNames() const
|
||||
FieldInfoList Table::fieldInformation() const
|
||||
{
|
||||
FieldInfoList result;
|
||||
foreach(FieldPtr f, m_fields)
|
||||
for(const FieldPtr& f : m_fields)
|
||||
result.append({f->name(), f->type(), f->toString(" ", " ")});
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Table::hasAutoIncrement() const
|
||||
{
|
||||
foreach(FieldPtr f, m_fields) {
|
||||
for(const FieldPtr& f : m_fields) {
|
||||
if(f->autoIncrement())
|
||||
return true;
|
||||
}
|
||||
@@ -567,7 +566,7 @@ QList<ConstraintPtr> Table::constraints(FieldVector fields, Constraint::Constrai
|
||||
return clist;
|
||||
} else {
|
||||
QList<ConstraintPtr> clist_typed;
|
||||
foreach(const ConstraintPtr& ptr, clist)
|
||||
for(const ConstraintPtr& ptr : clist)
|
||||
{
|
||||
if(ptr->type() == type)
|
||||
clist_typed.push_back(ptr);
|
||||
@@ -1128,7 +1127,7 @@ void CreateTableWalker::parsecolumn(Table* table, antlr::RefAST c)
|
||||
f->setAutoIncrement(autoincrement);
|
||||
table->addField(f);
|
||||
|
||||
foreach(sqlb::ForeignKeyClause* fk, foreignKeys)
|
||||
for(sqlb::ForeignKeyClause* fk : foreignKeys)
|
||||
table->addConstraint({f}, ConstraintPtr(fk));
|
||||
if(primaryKey)
|
||||
{
|
||||
@@ -1171,7 +1170,7 @@ Index& Index::operator=(const Index& rhs)
|
||||
m_whereExpr = rhs.m_whereExpr;
|
||||
|
||||
// Make copies of the column
|
||||
foreach(IndexedColumnPtr c, rhs.m_columns)
|
||||
for(const IndexedColumnPtr& c : rhs.m_columns)
|
||||
addColumn(IndexedColumnPtr(new IndexedColumn(*c)));
|
||||
|
||||
return *this;
|
||||
@@ -1216,7 +1215,7 @@ QStringList Index::columnSqlList() const
|
||||
{
|
||||
QStringList sl;
|
||||
|
||||
foreach(const IndexedColumnPtr& c, m_columns)
|
||||
for(const IndexedColumnPtr& c : m_columns)
|
||||
sl << c->toString();
|
||||
|
||||
return sl;
|
||||
@@ -1245,7 +1244,7 @@ QString Index::sql(const QString& schema, bool ifNotExists) const
|
||||
FieldInfoList Index::fieldInformation() const
|
||||
{
|
||||
FieldInfoList result;
|
||||
foreach(IndexedColumnPtr c, m_columns)
|
||||
for(const IndexedColumnPtr& c : m_columns)
|
||||
result.append({c->name(), c->order(), c->toString(" ", " ")});
|
||||
return result;
|
||||
}
|
||||
@@ -1437,7 +1436,7 @@ QStringList View::fieldNames() const
|
||||
{
|
||||
QStringList sl;
|
||||
|
||||
foreach(FieldPtr f, m_fields)
|
||||
for(const FieldPtr& f : m_fields)
|
||||
sl << f->name();
|
||||
|
||||
return sl;
|
||||
@@ -1446,7 +1445,7 @@ QStringList View::fieldNames() const
|
||||
FieldInfoList View::fieldInformation() const
|
||||
{
|
||||
FieldInfoList result;
|
||||
foreach(FieldPtr f, m_fields)
|
||||
for(const FieldPtr& f : m_fields)
|
||||
result.append({f->name(), f->type(), f->toString(" ", " ")});
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user