mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
for loop pre-increment optimization's and a slight syntax style change
This commit is contained in:
@@ -15,7 +15,7 @@ CreateIndexDialog::CreateIndexDialog(DBBrowserDB* db, QWidget* parent)
|
||||
|
||||
// Fill table combobox
|
||||
QList<DBBrowserObject> tables = pdb->objMap.values("table");
|
||||
for(int i=0;i<tables.count();i++)
|
||||
for(int i=0; i < tables.count(); ++i)
|
||||
ui->comboTableName->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;i<fields.size();i++)
|
||||
for(int i=0; i < fields.size(); ++i)
|
||||
{
|
||||
// Put the name of the field in the first column
|
||||
QTableWidgetItem* name = new QTableWidgetItem(fields.at(i));
|
||||
@@ -59,7 +59,7 @@ void CreateIndexDialog::checkInput()
|
||||
valid = false;
|
||||
|
||||
int num_columns = 0;
|
||||
for(int i=0;i<ui->tableIndexColumns->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;i<ui->tableIndexColumns->rowCount();i++)
|
||||
for(int i=0; i < ui->tableIndexColumns->rowCount(); ++i)
|
||||
{
|
||||
if(ui->tableIndexColumns->item(i, 1)->data(Qt::CheckStateRole) == Qt::Checked)
|
||||
{
|
||||
|
||||
@@ -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;i<tableModel.rowCount();i++)
|
||||
for(int i=0; i < tableModel.rowCount(); ++i)
|
||||
{
|
||||
QString insertStatement = "INSERT INTO `" + data(index.sibling(index.row(), 0), Qt::DisplayRole).toString() + "` VALUES(";
|
||||
for(int j=1;j<tableModel.columnCount();j++)
|
||||
for(int j=1; j < tableModel.columnCount(); ++j)
|
||||
insertStatement += QString("'%1',").arg(tableModel.data(tableModel.index(i, j)).toString());
|
||||
insertStatement.chop(1);
|
||||
insertStatement += ");\n";
|
||||
|
||||
@@ -169,7 +169,7 @@ void EditTableDialog::updateTypes()
|
||||
QString column = sender()->property("column").toString();
|
||||
|
||||
int index;
|
||||
for(index=0;index<m_table.fields().size();index++)
|
||||
for(index=0; index < m_table.fields().size(); ++index)
|
||||
{
|
||||
if(m_table.fields().at(index)->name() == 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;i<oldCombo->count();i++)
|
||||
for(int i=0; i < oldCombo->count(); ++i)
|
||||
newCombo->addItem(oldCombo->itemText(i));
|
||||
newCombo->setCurrentIndex(oldCombo->currentIndex());
|
||||
|
||||
|
||||
@@ -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;i<tableModel.columnCount();i++)
|
||||
for(int i=first_column; i < tableModel.columnCount(); ++i)
|
||||
{
|
||||
stream << quoteChar << tableModel.headerData(i, Qt::Horizontal).toString() << quoteChar;
|
||||
if(i < tableModel.columnCount() - 1)
|
||||
@@ -92,9 +92,9 @@ void ExportCsvDialog::accept()
|
||||
}
|
||||
|
||||
// Get and write actual data
|
||||
for(int i=0;i<tableModel.totalRowCount();i++)
|
||||
for(int i=0;i < tableModel.totalRowCount(); ++i)
|
||||
{
|
||||
for(int j=first_column;j<tableModel.columnCount();j++)
|
||||
for(int j=first_column; j < tableModel.columnCount(); ++j)
|
||||
{
|
||||
QString content = tableModel.data(tableModel.index(i, j)).toString();
|
||||
stream << quoteChar << content.replace(quoteChar, quotequoteChar) << quoteChar;
|
||||
|
||||
@@ -19,12 +19,12 @@ FilterTableHeader::FilterTableHeader(QTableView* parent) :
|
||||
void FilterTableHeader::generateFilters(int number)
|
||||
{
|
||||
// Delete all the current filter widgets
|
||||
for(int i=0;i<filterWidgets.size();i++)
|
||||
for(int i=0;i < filterWidgets.size(); ++i)
|
||||
delete filterWidgets.at(i);
|
||||
filterWidgets.clear();
|
||||
|
||||
// And generate a bunch of new ones
|
||||
for(int i=0;i<number;i++)
|
||||
for(int i=0;i < number; ++i)
|
||||
{
|
||||
QLineEdit* l = new QLineEdit(this);
|
||||
l->setPlaceholderText(tr("Filter"));
|
||||
@@ -63,7 +63,7 @@ void FilterTableHeader::updateGeometries()
|
||||
void FilterTableHeader::adjustPositions()
|
||||
{
|
||||
// Loop through all widgets
|
||||
for(int i=0;i<filterWidgets.size();++i)
|
||||
for(int i=0;i < filterWidgets.size(); ++i)
|
||||
{
|
||||
// Get the current widget, move it and reisize it
|
||||
QWidget* w = filterWidgets.at(i);
|
||||
|
||||
@@ -72,7 +72,7 @@ void ImportCsvDialog::accept()
|
||||
curList.pop_front();
|
||||
}
|
||||
} else {
|
||||
for(int i=0;i<numfields;i++)
|
||||
for(int i=0; i < numfields; ++i)
|
||||
fieldList.push_back(sqlb::FieldPtr(new sqlb::Field(QString("field%1").arg(i+1), "")));
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ void ImportCsvDialog::updatePreview()
|
||||
ui->tablePreview->setHorizontalHeaderLabels(curList);
|
||||
|
||||
// Remove this row to not show it in the data section
|
||||
for(int e=0;e<numfields;e++)
|
||||
for(int e=0;e < numfields; ++e)
|
||||
curList.pop_front();
|
||||
}
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ void MainWindow::populateStructure()
|
||||
tablefieldmodel->setColumnCount(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;i<ui->tabSqlAreas->count();i++)
|
||||
for(int i=0; i < ui->tabSqlAreas->count(); ++i)
|
||||
{
|
||||
SqlExecutionArea* sqlarea = qobject_cast<SqlExecutionArea*>(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;i<ui->tabSqlAreas->count();i++)
|
||||
for(int i=0; i < ui->tabSqlAreas->count(); ++i)
|
||||
{
|
||||
SqlExecutionArea* sqlArea = qobject_cast<SqlExecutionArea*>(ui->tabSqlAreas->widget(i));
|
||||
sqlArea->getModel()->setChunkSize(PreferencesDialog::getSettingsValue("db", "prefetchsize").toInt());
|
||||
|
||||
@@ -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;i<ui->treeSyntaxHighlighting->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;i<ui->treeSyntaxHighlighting->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));
|
||||
|
||||
@@ -54,7 +54,7 @@ QString removeComments(QString s)
|
||||
|
||||
QChar lastChar = 0;
|
||||
QList<QChar> stringChars;
|
||||
for(int i=0;i<s.length();i++)
|
||||
for(int i=0; i < s.length(); ++i)
|
||||
{
|
||||
if(lastChar != '\\' && (s.at(i) == '\'' || s.at(i) == '"' || s.at(i) == '`'))
|
||||
{
|
||||
@@ -284,10 +284,10 @@ bool SqliteTableModel::insertRows(int row, int count, const QModelIndex& parent)
|
||||
beginInsertRows(parent, row, row + count - 1);
|
||||
|
||||
QByteArrayList blank_data;
|
||||
for(int i=0;i<m_headers.size();i++)
|
||||
for(int i=0; i < m_headers.size(); ++i)
|
||||
blank_data.push_back("");
|
||||
|
||||
for(int i=0;i<count;i++)
|
||||
for(int i=0; i < count; ++i)
|
||||
{
|
||||
m_data.insert(row, blank_data);
|
||||
m_data[row].replace(0, QByteArray::number(m_db->addRecord(m_sTable)));
|
||||
|
||||
Reference in New Issue
Block a user