From 94819f22e267d925a15df086c3d34abeac806091 Mon Sep 17 00:00:00 2001 From: Peinthor Rene Date: Fri, 20 Sep 2013 14:49:07 +0200 Subject: [PATCH] for loop pre-increment optimization's and a slight syntax style change --- src/CreateIndexDialog.cpp | 8 ++++---- src/DbStructureModel.cpp | 8 ++++---- src/EditTableDialog.cpp | 4 ++-- src/ExportCsvDialog.cpp | 6 +++--- src/FilterTableHeader.cpp | 6 +++--- src/ImportCsvDialog.cpp | 4 ++-- src/MainWindow.cpp | 6 +++--- src/PreferencesDialog.cpp | 4 ++-- src/sqlitetablemodel.cpp | 6 +++--- 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/CreateIndexDialog.cpp b/src/CreateIndexDialog.cpp index 259a67ed..c02e47e2 100644 --- a/src/CreateIndexDialog.cpp +++ b/src/CreateIndexDialog.cpp @@ -15,7 +15,7 @@ CreateIndexDialog::CreateIndexDialog(DBBrowserDB* db, QWidget* parent) // Fill table combobox QList tables = pdb->objMap.values("table"); - for(int i=0;icomboTableName->addItem(tables.at(i).getname()); } @@ -29,7 +29,7 @@ void CreateIndexDialog::tableChanged(const QString& new_table) // And fill the table again QStringList fields = pdb->getTableFields(new_table); ui->tableIndexColumns->setRowCount(fields.size()); - for(int i=0;itableIndexColumns->rowCount();i++) + for(int i=0; i < ui->tableIndexColumns->rowCount(); ++i) { if(ui->tableIndexColumns->item(i, 1) && ui->tableIndexColumns->item(i, 1)->data(Qt::CheckStateRole) == Qt::Checked) num_columns++; @@ -77,7 +77,7 @@ void CreateIndexDialog::accept() .arg(ui->editIndexName->text()) .arg(ui->comboTableName->currentText()); - for(int i=0;itableIndexColumns->rowCount();i++) + for(int i=0; i < ui->tableIndexColumns->rowCount(); ++i) { if(ui->tableIndexColumns->item(i, 1)->data(Qt::CheckStateRole) == Qt::Checked) { diff --git a/src/DbStructureModel.cpp b/src/DbStructureModel.cpp index 5cfd4978..082fd33a 100644 --- a/src/DbStructureModel.cpp +++ b/src/DbStructureModel.cpp @@ -143,7 +143,7 @@ void DbStructureModel::reloadData(DBBrowserDB* db) typeToParentItem.insert("trigger", itemTriggers); // Add the actual table objects - for(objectMap::ConstIterator it=db->objMap.begin();it!=db->objMap.end();++it) + for(objectMap::ConstIterator it=db->objMap.begin(); it != db->objMap.end(); ++it) { // Object node QTreeWidgetItem *tableItem = new QTreeWidgetItem(typeToParentItem.value((*it).gettype())); @@ -155,7 +155,7 @@ void DbStructureModel::reloadData(DBBrowserDB* db) // If it is a table or view add the field Nodes if((*it).gettype() == "table" || (*it).gettype() == "view") { - for(int i=0;i<(*it).fldmap.size();i++) + for(int i=0; i < it->fldmap.size(); ++i) { QTreeWidgetItem *fldItem = new QTreeWidgetItem(tableItem); fldItem->setText(0, (*it).fldmap.at(i)->name()); @@ -194,10 +194,10 @@ QMimeData* DbStructureModel::mimeData(const QModelIndexList& indices) const { SqliteTableModel tableModel(0, m_db); tableModel.setTable(data(index.sibling(index.row(), 0), Qt::DisplayRole).toString()); - for(int i=0;iproperty("column").toString(); int index; - for(index=0;indexname() == column) break; @@ -419,7 +419,7 @@ void EditTableDialog::moveCurrentField(bool down) newCombo->setProperty("column", oldCombo->property("column")); connect(newCombo, SIGNAL(activated(int)), this, SLOT(updateTypes())); newCombo->setEditable(false); - for(int i=0;icount();i++) + for(int i=0; i < oldCombo->count(); ++i) newCombo->addItem(oldCombo->itemText(i)); newCombo->setCurrentIndex(oldCombo->currentIndex()); diff --git a/src/ExportCsvDialog.cpp b/src/ExportCsvDialog.cpp index c4926ead..895b92d5 100644 --- a/src/ExportCsvDialog.cpp +++ b/src/ExportCsvDialog.cpp @@ -81,7 +81,7 @@ void ExportCsvDialog::accept() // Put field names in first row if user wants to have them if(ui->checkHeader->isChecked()) { - for(int i=first_column;isetPlaceholderText(tr("Filter")); @@ -63,7 +63,7 @@ void FilterTableHeader::updateGeometries() void FilterTableHeader::adjustPositions() { // Loop through all widgets - for(int i=0;itablePreview->setHorizontalHeaderLabels(curList); // Remove this row to not show it in the data section - for(int e=0;esetColumnCount(1); int fldrow = 0; - for(int i=0;i<(*it).fldmap.size();i++,fldrow++) + for(int i=0; i < (*it).fldmap.size(); ++i, ++fldrow) { QString fieldname = (*it).fldmap.at(i)->name(); QStandardItem* fldItem = new QStandardItem(fieldname); @@ -226,7 +226,7 @@ void MainWindow::populateStructure() } } - for(int i=0;itabSqlAreas->count();i++) + for(int i=0; i < ui->tabSqlAreas->count(); ++i) { SqlExecutionArea* sqlarea = qobject_cast(ui->tabSqlAreas->widget(i)); sqlarea->setTableNames(tblnames); @@ -1174,7 +1174,7 @@ void MainWindow::reloadSettings() { // Set prefetch sizes for lazy population of table models m_browseTableModel->setChunkSize(PreferencesDialog::getSettingsValue("db", "prefetchsize").toInt()); - for(int i=0;itabSqlAreas->count();i++) + for(int i=0; i < ui->tabSqlAreas->count(); ++i) { SqlExecutionArea* sqlArea = qobject_cast(ui->tabSqlAreas->widget(i)); sqlArea->getModel()->setChunkSize(PreferencesDialog::getSettingsValue("db", "prefetchsize").toInt()); diff --git a/src/PreferencesDialog.cpp b/src/PreferencesDialog.cpp index 77a049c1..69bcf345 100644 --- a/src/PreferencesDialog.cpp +++ b/src/PreferencesDialog.cpp @@ -46,7 +46,7 @@ void PreferencesDialog::loadSettings() ui->foreignKeysCheckBox->setChecked(getSettingsValue("db", "foreignkeys").toBool()); ui->spinPrefetchSize->setValue(getSettingsValue("db", "prefetchsize").toInt()); - for(int i=0;itreeSyntaxHighlighting->topLevelItemCount();i++) + for(int i=0; i < ui->treeSyntaxHighlighting->topLevelItemCount(); ++i) { QString name = ui->treeSyntaxHighlighting->topLevelItem(i)->text(0); QString colorname = getSettingsValue("syntaxhighlighter", name + "_colour").toString(); @@ -71,7 +71,7 @@ void PreferencesDialog::saveSettings() setSettingsValue("db", "foreignkeys", ui->foreignKeysCheckBox->isChecked()); setSettingsValue("db", "prefetchsize", ui->spinPrefetchSize->value()); - for(int i=0;itreeSyntaxHighlighting->topLevelItemCount();i++) + for(int i=0; i < ui->treeSyntaxHighlighting->topLevelItemCount(); ++i) { QString name = ui->treeSyntaxHighlighting->topLevelItem(i)->text(0); setSettingsValue("syntaxhighlighter", name + "_colour", ui->treeSyntaxHighlighting->topLevelItem(i)->text(2)); diff --git a/src/sqlitetablemodel.cpp b/src/sqlitetablemodel.cpp index 44d983d4..c14886cb 100644 --- a/src/sqlitetablemodel.cpp +++ b/src/sqlitetablemodel.cpp @@ -54,7 +54,7 @@ QString removeComments(QString s) QChar lastChar = 0; QList stringChars; - for(int i=0;iaddRecord(m_sTable)));