Skip to content

Commit 35a68b0

Browse files
committed
Simplify code by removing unneeded 'QObject::' prefixes
Inside methods of the DBBrowserDB class 'QObject::' prefixes aren't needed anymore since it's a child of the QObject class.
1 parent 6d7b402 commit 35a68b0

File tree

1 file changed

+31
-32
lines changed

1 file changed

+31
-32
lines changed

src/sqlitedb.cpp

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ bool DBBrowserDB::open(const QString& db)
5252

5353
if (isOpen()) close();
5454

55-
lastErrorMessage = QObject::tr("no error");
55+
lastErrorMessage = tr("no error");
5656

5757
isEncrypted = false;
5858

@@ -218,7 +218,7 @@ bool DBBrowserDB::create ( const QString & db)
218218

219219
if (isOpen()) close();
220220

221-
lastErrorMessage = QObject::tr("no error");
221+
lastErrorMessage = tr("no error");
222222

223223
// read encoding from settings and open with sqlite3_open for utf8
224224
// and sqlite3_open16 for utf16
@@ -272,8 +272,8 @@ bool DBBrowserDB::close()
272272
{
273273
QMessageBox::StandardButton reply = QMessageBox::question(0,
274274
QApplication::applicationName(),
275-
QObject::tr("Do you want to save the changes "
276-
"made to the database file %1?").arg(curDBFilename),
275+
tr("Do you want to save the changes "
276+
"made to the database file %1?").arg(curDBFilename),
277277
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
278278

279279
// If the user clicked the cancel button stop here and return false
@@ -324,8 +324,8 @@ bool DBBrowserDB::dump(const QString& filename)
324324
}
325325
}
326326

327-
QProgressDialog progress(QObject::tr("Exporting database to SQL file..."),
328-
QObject::tr("Cancel"), 0, numRecordsTotal);
327+
QProgressDialog progress(tr("Exporting database to SQL file..."),
328+
tr("Cancel"), 0, numRecordsTotal);
329329
progress.setWindowModality(Qt::ApplicationModal);
330330
progress.show();
331331
qApp->processEvents();
@@ -470,8 +470,8 @@ bool DBBrowserDB::executeMultiSQL(const QString& statement, bool dirty, bool log
470470

471471
// Show progress dialog
472472
int statement_size = statement.size();
473-
QProgressDialog progress(QObject::tr("Executing SQL..."),
474-
QObject::tr("Cancel"), 0, statement_size);
473+
QProgressDialog progress(tr("Executing SQL..."),
474+
tr("Cancel"), 0, statement_size);
475475
progress.setWindowModality(Qt::ApplicationModal);
476476
progress.show();
477477

@@ -491,7 +491,7 @@ bool DBBrowserDB::executeMultiSQL(const QString& statement, bool dirty, bool log
491491
qApp->processEvents();
492492
if(progress.wasCanceled())
493493
{
494-
lastErrorMessage = QObject::tr("Action cancelled.");
494+
lastErrorMessage = tr("Action cancelled.");
495495
return false;
496496
}
497497

@@ -502,15 +502,15 @@ bool DBBrowserDB::executeMultiSQL(const QString& statement, bool dirty, bool log
502502
if(sqlite3_step(vm) == SQLITE_ERROR)
503503
{
504504
sqlite3_finalize(vm);
505-
lastErrorMessage = QObject::tr("Error in statement #%1: %2.\n"
505+
lastErrorMessage = tr("Error in statement #%1: %2.\n"
506506
"Aborting execution.").arg(line).arg(sqlite3_errmsg(_db));
507507
qWarning() << lastErrorMessage;
508508
return false;
509509
} else {
510510
sqlite3_finalize(vm);
511511
}
512512
} else {
513-
lastErrorMessage = QObject::tr("Error in statement #%1: %2.\n"
513+
lastErrorMessage = tr("Error in statement #%1: %2.\n"
514514
"Aborting execution.").arg(line).arg(sqlite3_errmsg(_db));
515515
qWarning() << lastErrorMessage;
516516
return false;
@@ -756,7 +756,7 @@ bool DBBrowserDB::renameColumn(const QString& tablename, const QString& name, sq
756756
QString tableSql = getObjectByName(tablename).getsql();
757757
if(tableSql.isEmpty())
758758
{
759-
lastErrorMessage = QObject::tr("renameColumn: cannot find table %1.").arg(tablename);
759+
lastErrorMessage = tr("renameColumn: cannot find table %1.").arg(tablename);
760760
qWarning() << lastErrorMessage;
761761
return false;
762762
}
@@ -767,15 +767,15 @@ bool DBBrowserDB::renameColumn(const QString& tablename, const QString& name, sq
767767
// Check if field actually exists
768768
if(oldSchema.findField(name) == -1)
769769
{
770-
lastErrorMessage = QObject::tr("renameColumn: cannot find column %1.").arg(name);
770+
lastErrorMessage = tr("renameColumn: cannot find column %1.").arg(name);
771771
qWarning() << lastErrorMessage;
772772
return false;
773773
}
774774

775775
// Create savepoint to be able to go back to it in case of any error
776776
if(!executeSQL("SAVEPOINT sqlitebrowser_rename_column"))
777777
{
778-
lastErrorMessage = QObject::tr("renameColumn: creating savepoint failed. DB says: %1").arg(lastErrorMessage);
778+
lastErrorMessage = tr("renameColumn: creating savepoint failed. DB says: %1").arg(lastErrorMessage);
779779
qWarning() << lastErrorMessage;
780780
return false;
781781
}
@@ -815,7 +815,7 @@ bool DBBrowserDB::renameColumn(const QString& tablename, const QString& name, sq
815815
// Create the new table
816816
if(!executeSQL(newSchema.sql()))
817817
{
818-
lastErrorMessage = QObject::tr("renameColumn: creating new table failed. DB says: %1").arg(lastErrorMessage);
818+
lastErrorMessage = tr("renameColumn: creating new table failed. DB says: %1").arg(lastErrorMessage);
819819
qWarning() << lastErrorMessage;
820820
executeSQL("ROLLBACK TO SAVEPOINT sqlitebrowser_rename_column;");
821821
return false;
@@ -824,8 +824,7 @@ bool DBBrowserDB::renameColumn(const QString& tablename, const QString& name, sq
824824
// Copy the data from the old table to the new one
825825
if(!executeSQL(QString("INSERT INTO sqlitebrowser_rename_column_new_table SELECT %1 FROM `%2`;").arg(select_cols).arg(tablename)))
826826
{
827-
lastErrorMessage = QObject::tr("renameColumn: copying data to new table failed. DB says:\n"
828-
"%1").arg(lastErrorMessage);
827+
lastErrorMessage = tr("renameColumn: copying data to new table failed. DB says:\n%1").arg(lastErrorMessage);
829828
qWarning() << lastErrorMessage;
830829
executeSQL("ROLLBACK TO SAVEPOINT sqlitebrowser_rename_column;");
831830
return false;
@@ -843,7 +842,7 @@ bool DBBrowserDB::renameColumn(const QString& tablename, const QString& name, sq
843842
// Delete the old table
844843
if(!executeSQL(QString("DROP TABLE `%1`;").arg(tablename)))
845844
{
846-
lastErrorMessage = QObject::tr("renameColumn: deleting old table failed. DB says: %1").arg(lastErrorMessage);
845+
lastErrorMessage = tr("renameColumn: deleting old table failed. DB says: %1").arg(lastErrorMessage);
847846
qWarning() << lastErrorMessage;
848847
executeSQL("ROLLBACK TO SAVEPOINT sqlitebrowser_rename_column;");
849848
return false;
@@ -859,16 +858,16 @@ bool DBBrowserDB::renameColumn(const QString& tablename, const QString& name, sq
859858
// Restore the saved triggers, views and indices
860859
if(!executeMultiSQL(otherObjectsSql, true, true))
861860
{
862-
QMessageBox::information(0, qApp->applicationName(), QObject::tr("Restoring some of the objects associated with this table failed. "
863-
"This is most likely because some column names changed. "
864-
"Here's the SQL statement which you might want to fix and execute manually:\n\n")
861+
QMessageBox::information(0, qApp->applicationName(), tr("Restoring some of the objects associated with this table failed. "
862+
"This is most likely because some column names changed. "
863+
"Here's the SQL statement which you might want to fix and execute manually:\n\n")
865864
+ otherObjectsSql);
866865
}
867866

868867
// Release the savepoint - everything went fine
869868
if(!executeSQL("RELEASE SAVEPOINT sqlitebrowser_rename_column;"))
870869
{
871-
lastErrorMessage = QObject::tr("renameColumn: releasing savepoint failed. DB says: %1").arg(lastErrorMessage);
870+
lastErrorMessage = tr("renameColumn: releasing savepoint failed. DB says: %1").arg(lastErrorMessage);
872871
qWarning() << lastErrorMessage;
873872
return false;
874873
}
@@ -883,7 +882,7 @@ bool DBBrowserDB::renameTable(const QString& from_table, const QString& to_table
883882
QString sql = QString("ALTER TABLE `%1` RENAME TO `%2`").arg(from_table, to_table);
884883
if(!executeSQL(sql))
885884
{
886-
QString error = QObject::tr("Error renaming table '%1' to '%2'."
885+
QString error = tr("Error renaming table '%1' to '%2'."
887886
"Message from database engine:\n%3").arg(from_table).arg(to_table).arg(lastErrorMessage);
888887
lastErrorMessage = error;
889888
qWarning() << lastErrorMessage;
@@ -940,7 +939,7 @@ void DBBrowserDB::logSQL(QString statement, int msgtype)
940939
if(statement.at(i) < 32 && statement.at(i) != '\n')
941940
{
942941
statement.truncate(32);
943-
statement.append(QObject::tr("... <string can not be logged, contains binary data> ..."));
942+
statement.append(tr("... <string can not be logged, contains binary data> ..."));
944943

945944
// early exit if we detect a binary character,
946945
// to prevent checking all characters in a potential big string
@@ -956,7 +955,7 @@ void DBBrowserDB::updateSchema( )
956955
sqlite3_stmt *vm;
957956
const char *tail;
958957
int err=0;
959-
lastErrorMessage = QObject::tr("no error");
958+
lastErrorMessage = tr("no error");
960959

961960
objMap.clear();
962961

@@ -981,11 +980,11 @@ void DBBrowserDB::updateSchema( )
981980
if(val1 == "table" || val1 == "index" || val1 == "view" || val1 == "trigger")
982981
objMap.insert(val1, DBBrowserObject(val2, val3, val1, val4));
983982
else
984-
qWarning() << QObject::tr("unknown object type %1").arg(val1);
983+
qWarning() << tr("unknown object type %1").arg(val1);
985984
}
986985
sqlite3_finalize(vm);
987986
}else{
988-
qWarning() << QObject::tr("could not get list of db objects: %1, %2").arg(err).arg(sqlite3_errmsg(_db));
987+
qWarning() << tr("could not get list of db objects: %1, %2").arg(err).arg(sqlite3_errmsg(_db));
989988
}
990989

991990
//now get the field list for each table
@@ -1015,7 +1014,7 @@ void DBBrowserDB::updateSchema( )
10151014
}
10161015
sqlite3_finalize(vm);
10171016
} else{
1018-
lastErrorMessage = QObject::tr("could not get types");
1017+
lastErrorMessage = tr("could not get types");
10191018
}
10201019
}
10211020
}
@@ -1038,11 +1037,11 @@ QString DBBrowserDB::getPragma(const QString& pragma)
10381037
if(sqlite3_step(vm) == SQLITE_ROW)
10391038
retval = QString::fromUtf8((const char *) sqlite3_column_text(vm, 0));
10401039
else
1041-
qWarning() << QObject::tr("didn't receive any output from pragma %1").arg(pragma);
1040+
qWarning() << tr("didn't receive any output from pragma %1").arg(pragma);
10421041

10431042
sqlite3_finalize(vm);
10441043
} else {
1045-
qWarning() << QObject::tr("could not execute pragma command: %1, %2").arg(err).arg(sqlite3_errmsg(_db));
1044+
qWarning() << tr("could not execute pragma command: %1, %2").arg(err).arg(sqlite3_errmsg(_db));
10461045
}
10471046

10481047
// Return it
@@ -1057,7 +1056,7 @@ bool DBBrowserDB::setPragma(const QString& pragma, const QString& value)
10571056
save();
10581057
bool res = executeSQL(sql, false, true); // PRAGMA statements are usually not transaction bound, so we can't revert
10591058
if( !res )
1060-
qWarning() << QObject::tr("Error setting pragma %1 to %2: %3").arg(pragma).arg(value).arg(lastErrorMessage);
1059+
qWarning() << tr("Error setting pragma %1 to %2: %3").arg(pragma).arg(value).arg(lastErrorMessage);
10611060
return res;
10621061
}
10631062

@@ -1096,7 +1095,7 @@ bool DBBrowserDB::loadExtension(const QString& filename)
10961095
// Check if file exists
10971096
if(!QFile::exists(filename))
10981097
{
1099-
lastErrorMessage = QObject::tr("File not found.");
1098+
lastErrorMessage = tr("File not found.");
11001099
return false;
11011100
}
11021101

0 commit comments

Comments
 (0)