mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
avoid useless string copies and fix a bug with logSQL because of that
This commit is contained in:
@@ -23,7 +23,7 @@ CreateIndexDialog::~CreateIndexDialog()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void CreateIndexDialog::tableChanged(QString new_table)
|
||||
void CreateIndexDialog::tableChanged(const QString& new_table)
|
||||
{
|
||||
// And fill the table again
|
||||
QStringList fields = pdb->getTableFields(new_table);
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
|
||||
private slots:
|
||||
void accept();
|
||||
void tableChanged(QString new_table);
|
||||
void tableChanged(const QString& new_table);
|
||||
void checkInput();
|
||||
|
||||
private:
|
||||
|
||||
@@ -57,7 +57,7 @@ void EditDialog::closeEvent(QCloseEvent*)
|
||||
emit goingAway();
|
||||
}
|
||||
|
||||
void EditDialog::loadText(QString text, int row, int col)
|
||||
void EditDialog::loadText(const QString& text, int row, int col)
|
||||
{
|
||||
ui->editData->setPlainText(text);
|
||||
ui->editData->setFocus();
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
|
||||
public slots:
|
||||
virtual void reset();
|
||||
virtual void loadText(QString text, int row, int col);
|
||||
virtual void loadText(const QString& text, int row, int col);
|
||||
|
||||
private slots:
|
||||
virtual void enableExport(bool enabled);
|
||||
@@ -37,7 +37,7 @@ private slots:
|
||||
|
||||
signals:
|
||||
void goingAway();
|
||||
void updateRecordText(int, int, QString);
|
||||
void updateRecordText(int, int, const QString&);
|
||||
|
||||
private:
|
||||
Ui::EditDialog* ui;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <QPushButton>
|
||||
#include <QMessageBox>
|
||||
|
||||
EditFieldDialog::EditFieldDialog(DBBrowserDB* db, bool new_field, QString table, QString fld_name, QString fld_type, QWidget* parent)
|
||||
EditFieldDialog::EditFieldDialog(DBBrowserDB* db, bool new_field, const QString& table, const QString& fld_name, const QString& fld_type, QWidget* parent)
|
||||
: QDialog(parent),
|
||||
ui(new Ui::EditFieldDialog),
|
||||
pdb(db),
|
||||
|
||||
@@ -14,7 +14,7 @@ class EditFieldDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EditFieldDialog(DBBrowserDB* db, bool new_field, QString table, QString fld_name, QString fld_type, QWidget* parent = 0);
|
||||
explicit EditFieldDialog(DBBrowserDB* db, bool new_field, const QString& table, const QString& fld_name, const QString& fld_type, QWidget* parent = 0);
|
||||
~EditFieldDialog();
|
||||
|
||||
QString getFieldName() { return field_name; }
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <QPushButton>
|
||||
#include "sqlitedb.h"
|
||||
|
||||
EditTableDialog::EditTableDialog(DBBrowserDB* db, QString tableName, QWidget* parent)
|
||||
EditTableDialog::EditTableDialog(DBBrowserDB* db, const QString& tableName, QWidget* parent)
|
||||
: QDialog(parent),
|
||||
ui(new Ui::EditTableDialog),
|
||||
pdb(db),
|
||||
|
||||
@@ -13,7 +13,7 @@ class EditTableDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EditTableDialog(DBBrowserDB* pdb, QString tableName, QWidget* parent = 0);
|
||||
explicit EditTableDialog(DBBrowserDB* pdb, const QString& tableName, QWidget* parent = 0);
|
||||
~EditTableDialog();
|
||||
|
||||
private slots:
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "ui_ExportCsvDialog.h"
|
||||
#include "sqlitedb.h"
|
||||
|
||||
ExportCsvDialog::ExportCsvDialog(DBBrowserDB* db, QString deflocation, QWidget* parent)
|
||||
ExportCsvDialog::ExportCsvDialog(DBBrowserDB* db, const QString& deflocation, QWidget* parent)
|
||||
: QDialog(parent),
|
||||
ui(new Ui::ExportCsvDialog),
|
||||
pdb(db),
|
||||
|
||||
@@ -13,7 +13,7 @@ class ExportCsvDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ExportCsvDialog(DBBrowserDB* db, QString deflocation, QWidget* parent = 0);
|
||||
explicit ExportCsvDialog(DBBrowserDB* db, const QString& deflocation, QWidget* parent = 0);
|
||||
~ExportCsvDialog();
|
||||
|
||||
private slots:
|
||||
|
||||
@@ -13,11 +13,11 @@ FindDialog::~FindDialog()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void FindDialog::showResults(resultMap rmap)
|
||||
void FindDialog::showResults(const resultMap& rmap)
|
||||
{
|
||||
ui->tableResults->setSortingEnabled(false);
|
||||
ui->tableResults->clearContents();
|
||||
resultMap::Iterator it;
|
||||
resultMap::const_iterator it;
|
||||
int rowNum;
|
||||
ui->tableResults->setRowCount(rmap.size());
|
||||
for(it=rmap.begin(),rowNum=0;it!=rmap.end();++it,rowNum++)
|
||||
@@ -36,7 +36,7 @@ void FindDialog::find()
|
||||
emit lookfor(ui->comboColumn->currentText(), ui->comboOperator->currentText(), ui->editSearchString->text());
|
||||
}
|
||||
|
||||
void FindDialog::resetFields(QStringList fieldlist)
|
||||
void FindDialog::resetFields(const QStringList& fieldlist)
|
||||
{
|
||||
ui->comboColumn->clear();
|
||||
ui->comboColumn->addItems(fieldlist);
|
||||
|
||||
@@ -18,8 +18,8 @@ public:
|
||||
~FindDialog();
|
||||
|
||||
public slots:
|
||||
virtual void showResults(resultMap rmap);
|
||||
virtual void resetFields(QStringList fieldlist = QStringList());
|
||||
virtual void showResults(const resultMap& rmap);
|
||||
virtual void resetFields(const QStringList& fieldlist = QStringList());
|
||||
|
||||
private slots:
|
||||
virtual void find();
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <QPushButton>
|
||||
#include "sqlitedb.h"
|
||||
|
||||
ImportCsvDialog::ImportCsvDialog(QString filename, DBBrowserDB* db, QWidget* parent)
|
||||
ImportCsvDialog::ImportCsvDialog(const QString& filename, DBBrowserDB* db, QWidget* parent)
|
||||
: QDialog(parent),
|
||||
ui(new Ui::ImportCsvDialog),
|
||||
csvFilename(filename),
|
||||
|
||||
@@ -13,7 +13,7 @@ class ImportCsvDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ImportCsvDialog(QString filename, DBBrowserDB* db, QWidget* parent = 0);
|
||||
explicit ImportCsvDialog(const QString& filename, DBBrowserDB* db, QWidget* parent = 0);
|
||||
~ImportCsvDialog();
|
||||
|
||||
private slots:
|
||||
|
||||
@@ -640,7 +640,7 @@ void MainWindow::helpAbout()
|
||||
dialog.exec();
|
||||
}
|
||||
|
||||
void MainWindow::updateRecordText(int row, int col, QString newtext)
|
||||
void MainWindow::updateRecordText(int row, int col, const QString& newtext)
|
||||
{
|
||||
if (!db.updateRecord(row, col, newtext)){
|
||||
QMessageBox::information( this, QApplication::applicationName(), tr("Data could not be updated"));
|
||||
|
||||
@@ -122,7 +122,7 @@ private slots:
|
||||
virtual void editTable();
|
||||
virtual void helpWhatsThis();
|
||||
virtual void helpAbout();
|
||||
virtual void updateRecordText( int row, int col, QString newtext );
|
||||
virtual void updateRecordText( int row, int col, const QString& newtext );
|
||||
virtual void editWinAway();
|
||||
virtual void editText( int row, int col );
|
||||
virtual void doubleClickTable( int row, int col );
|
||||
|
||||
@@ -471,7 +471,7 @@ bool DBBrowserDB::browseTable( const QString & tablename, const QString& orderby
|
||||
return hasValidBrowseSet;
|
||||
}
|
||||
|
||||
bool DBBrowserDB::createTable(QString name, const QList<DBBrowserField>& structure)
|
||||
bool DBBrowserDB::createTable(const QString& name, const QList<DBBrowserField>& structure)
|
||||
{
|
||||
// Build SQL statement
|
||||
QString sql = QString("CREATE TABLE `%1` (").arg(name);
|
||||
@@ -484,13 +484,13 @@ bool DBBrowserDB::createTable(QString name, const QList<DBBrowserField>& structu
|
||||
return executeSQL(sql);
|
||||
}
|
||||
|
||||
bool DBBrowserDB::createColumn(QString tablename, QString fieldname, QString fieldtype)
|
||||
bool DBBrowserDB::createColumn(const QString& tablename, const QString& fieldname, const QString& fieldtype)
|
||||
{
|
||||
QString sql = QString("ALTER TABLE `%1` ADD COLUMN `%2` %3").arg(tablename).arg(fieldname).arg(fieldtype);
|
||||
return executeSQL(sql);
|
||||
}
|
||||
|
||||
bool DBBrowserDB::renameColumn(QString tablename, QString from, QString to, QString type)
|
||||
bool DBBrowserDB::renameColumn(const QString& tablename, const QString& from, const QString& to, const QString& type)
|
||||
{
|
||||
// NOTE: This function is working around the incomplete ALTER TABLE command in SQLite. If SQLite should fully support this command one day, this entire
|
||||
// function can be changed to executing something like this:
|
||||
@@ -570,7 +570,7 @@ bool DBBrowserDB::renameColumn(QString tablename, QString from, QString to, QStr
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DBBrowserDB::dropColumn(QString tablename, QString column)
|
||||
bool DBBrowserDB::dropColumn(const QString& tablename, const QString& column)
|
||||
{
|
||||
// NOTE: This function is working around the incomplete ALTER TABLE command in SQLite. If SQLite should fully support this command one day, this entire
|
||||
// function can be changed to executing something like this:
|
||||
@@ -653,7 +653,7 @@ bool DBBrowserDB::dropColumn(QString tablename, QString column)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DBBrowserDB::renameTable(QString from_table, QString to_table)
|
||||
bool DBBrowserDB::renameTable(const QString& from_table, const QString& to_table)
|
||||
{
|
||||
QString sql = QString("ALTER TABLE `%1` RENAME TO `%2`").arg(from_table, to_table);
|
||||
if(!executeSQL(sql))
|
||||
@@ -850,7 +850,7 @@ int DBBrowserDB::getRecordCount()
|
||||
return browseRecs.count();
|
||||
}
|
||||
|
||||
void DBBrowserDB::logSQL(QString statement, int msgtype)
|
||||
void DBBrowserDB::logSQL(const QString& statement, int msgtype)
|
||||
{
|
||||
if(mainWindow)
|
||||
{
|
||||
@@ -858,8 +858,10 @@ void DBBrowserDB::logSQL(QString statement, int msgtype)
|
||||
int loglimit = 300;
|
||||
if ((statement.length() > loglimit)&&(msgtype==kLogMsg_App))
|
||||
{
|
||||
statement.truncate(32);
|
||||
statement.append(QObject::tr("... <string too wide to log, probably contains binary data> ..."));
|
||||
QString logst = statement;
|
||||
logst.truncate(32);
|
||||
logst.append(QObject::tr("... <string too wide to log, probably contains binary data> ..."));
|
||||
mainWindow->logSql(logst, msgtype);
|
||||
}
|
||||
mainWindow->logSql(statement, msgtype);
|
||||
}
|
||||
|
||||
@@ -99,11 +99,11 @@ public:
|
||||
bool updateRecord(int wrow, int wcol, const QString & wtext);
|
||||
bool browseTable( const QString & tablename, const QString& orderby = "rowid" );
|
||||
|
||||
bool createTable(QString name, const QList<DBBrowserField>& structure);
|
||||
bool renameTable(QString from_table, QString to_table);
|
||||
bool createColumn(QString table, QString field, QString type);
|
||||
bool renameColumn(QString tablename, QString from, QString to, QString type);
|
||||
bool dropColumn(QString tablename, QString column);
|
||||
bool createTable(const QString& name, const QList<DBBrowserField>& structure);
|
||||
bool renameTable(const QString& from_table, const QString& to_table);
|
||||
bool createColumn(const QString& table, const QString& field, const QString& type);
|
||||
bool renameColumn(const QString& tablename, const QString& from, const QString& to, const QString& type);
|
||||
bool dropColumn(const QString& tablename, const QString& column);
|
||||
|
||||
QStringList getTableFields(const QString & tablename);
|
||||
QStringList getTableTypes(const QString & tablename);
|
||||
@@ -116,7 +116,7 @@ public:
|
||||
bool isOpen();
|
||||
void setDirty(bool dirtyval);
|
||||
bool getDirty();
|
||||
void logSQL(QString statement, int msgtype);
|
||||
void logSQL(const QString& statement, int msgtype);
|
||||
void setEncoding( int encoding );
|
||||
void setDefaultNewData( const QString & data );
|
||||
char * GetEncodedQStringAsPointer( const QString & input);
|
||||
|
||||
Reference in New Issue
Block a user