From 09fbb6d35a404b659e3adc4561178678eb1527f3 Mon Sep 17 00:00:00 2001 From: Gianluca Recchia Date: Sat, 27 Oct 2018 21:39:50 +0200 Subject: [PATCH 01/13] Remove redundant headers from the build system Headers are not to be placed amongst the source files in the CMake script. The preprocessor and the linker will take care of glue all the files together. Also, the "include_directories()" statement at the top of the file already tells CMake where to look for all the needed header files. --- src/CMakeLists.txt | 21 +-------------------- src/cli/CMakeLists.txt | 15 +-------------- 2 files changed, 2 insertions(+), 34 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1e7d64a1f..4c7620063 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -38,7 +38,6 @@ configure_file(version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/version.h @ONLY) set(keepassx_SOURCES core/AutoTypeAssociations.cpp - core/AsyncTask.h core/AutoTypeMatch.cpp core/Compare.cpp core/Config.cpp @@ -52,18 +51,14 @@ set(keepassx_SOURCES core/EntrySearcher.cpp core/FilePath.cpp core/Bootstrap.cpp - core/Global.h core/Group.cpp core/InactivityTimer.cpp - core/ListDeleter.h core/Merger.cpp core/Metadata.cpp core/PasswordGenerator.cpp core/PassphraseGenerator.cpp core/SignalMultiplexer.cpp core/ScreenLockListener.cpp - core/ScreenLockListener.h - core/ScreenLockListenerPrivate.h core/ScreenLockListenerPrivate.cpp core/TimeDelta.cpp core/TimeInfo.cpp @@ -77,14 +72,11 @@ set(keepassx_SOURCES crypto/CryptoHash.cpp crypto/Random.cpp crypto/SymmetricCipher.cpp - crypto/SymmetricCipherBackend.h crypto/SymmetricCipherGcrypt.cpp crypto/kdf/Kdf.cpp - crypto/kdf/Kdf_p.h crypto/kdf/AesKdf.cpp crypto/kdf/Argon2Kdf.cpp format/CsvExporter.cpp - format/KeePass1.h format/KeePass1Reader.cpp format/KeePass2.cpp format/KeePass2RandomStream.cpp @@ -142,7 +134,6 @@ set(keepassx_SOURCES gui/entry/AutoTypeMatchModel.cpp gui/entry/AutoTypeMatchView.cpp gui/entry/EditEntryWidget.cpp - gui/entry/EditEntryWidget_p.h gui/entry/EntryAttachmentsModel.cpp gui/entry/EntryAttachmentsWidget.cpp gui/entry/EntryAttributesModel.cpp @@ -168,11 +159,8 @@ set(keepassx_SOURCES gui/wizard/NewDatabaseWizardPageMetaData.cpp gui/wizard/NewDatabaseWizardPageEncryption.cpp gui/wizard/NewDatabaseWizardPageMasterKey.cpp - keys/ChallengeResponseKey.h keys/CompositeKey.cpp - keys/drivers/YubiKey.h keys/FileKey.cpp - keys/Key.h keys/PasswordKey.cpp keys/YkChallengeResponseKey.cpp streams/HashedBlockStream.cpp @@ -181,27 +169,22 @@ set(keepassx_SOURCES streams/qtiocompressor.cpp streams/StoreDataStream.cpp streams/SymmetricCipherStream.cpp - totp/totp.h totp/totp.cpp) if(APPLE) set(keepassx_SOURCES ${keepassx_SOURCES} - core/ScreenLockListenerMac.h core/ScreenLockListenerMac.cpp - core/MacPasteboard.h core/MacPasteboard.cpp) endif() if(UNIX AND NOT APPLE) set(keepassx_SOURCES ${keepassx_SOURCES} - core/ScreenLockListenerDBus.h core/ScreenLockListenerDBus.cpp gui/MainWindowAdaptor.cpp) endif() if(MINGW) set(keepassx_SOURCES ${keepassx_SOURCES} - core/ScreenLockListenerWin.h core/ScreenLockListenerWin.cpp) endif() if(MINGW OR (UNIX AND NOT APPLE)) @@ -243,13 +226,11 @@ set(autotype_SOURCES core/Tools.cpp autotype/AutoType.cpp autotype/AutoTypeAction.cpp - autotype/AutoTypePlatformPlugin.h autotype/AutoTypeSelectDialog.cpp autotype/AutoTypeSelectView.cpp autotype/ShortcutWidget.cpp autotype/WildcardMatcher.cpp - autotype/WindowSelectComboBox.cpp - autotype/test/AutoTypeTestInterface.h) + autotype/WindowSelectComboBox.cpp) if(MINGW) set(keepassx_SOURCES_MAINEXE ${keepassx_SOURCES_MAINEXE} ${CMAKE_SOURCE_DIR}/share/windows/icon.rc) diff --git a/src/cli/CMakeLists.txt b/src/cli/CMakeLists.txt index f6377aa07..37a085ad3 100644 --- a/src/cli/CMakeLists.txt +++ b/src/cli/CMakeLists.txt @@ -15,31 +15,18 @@ set(cli_SOURCES Add.cpp - Add.h Clip.cpp - Clip.h Command.cpp - Command.h Diceware.cpp - Diceware.h Edit.cpp - Edit.h Estimate.cpp - Estimate.h Extract.cpp - Extract.h Generate.cpp - Generate.h List.cpp - List.h Locate.cpp - Locate.h Merge.cpp - Merge.h Remove.cpp - Remove.h - Show.cpp - Show.h) + Show.cpp) add_library(cli STATIC ${cli_SOURCES}) target_link_libraries(cli Qt5::Core Qt5::Widgets) From 7a823e8dc7d2f149b51036dd918e66deef9affd9 Mon Sep 17 00:00:00 2001 From: Gianluca Recchia Date: Sat, 27 Oct 2018 04:38:10 +0200 Subject: [PATCH 02/13] Pin AutoTypeAction's vtable to a translation unit AutoTypeAction class had no out-of-line definitions and because of this the compiler would place its vtable everywhere the class is used. By simply defining the virtual destructor in the .cpp file, the issue goes away. Also, a few classes derived from AutoTypeAction had missing 'override' qualifiers, which have now been added. --- src/autotype/AutoTypeAction.cpp | 6 ++++++ src/autotype/AutoTypeAction.h | 20 +++++++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/autotype/AutoTypeAction.cpp b/src/autotype/AutoTypeAction.cpp index 0beb19b39..f9d928f0d 100644 --- a/src/autotype/AutoTypeAction.cpp +++ b/src/autotype/AutoTypeAction.cpp @@ -87,3 +87,9 @@ void AutoTypeExecutor::execClearField(AutoTypeClearField* action) { Q_UNUSED(action); } + +AutoTypeAction::~AutoTypeAction() +{ + // This makes sure that AutoTypeAction's vtable is placed + // in this translation unit. +} diff --git a/src/autotype/AutoTypeAction.h b/src/autotype/AutoTypeAction.h index 263566dd8..e598b1dcc 100644 --- a/src/autotype/AutoTypeAction.h +++ b/src/autotype/AutoTypeAction.h @@ -29,19 +29,17 @@ class AutoTypeExecutor; class KEEPASSX_EXPORT AutoTypeAction { public: - virtual ~AutoTypeAction() - { - } virtual AutoTypeAction* clone() = 0; virtual void accept(AutoTypeExecutor* executor) = 0; + virtual ~AutoTypeAction(); }; class KEEPASSX_EXPORT AutoTypeChar : public AutoTypeAction { public: explicit AutoTypeChar(const QChar& character); - AutoTypeAction* clone(); - void accept(AutoTypeExecutor* executor); + AutoTypeAction* clone() override; + void accept(AutoTypeExecutor* executor) override; const QChar character; }; @@ -50,8 +48,8 @@ class KEEPASSX_EXPORT AutoTypeKey : public AutoTypeAction { public: explicit AutoTypeKey(Qt::Key key); - AutoTypeAction* clone(); - void accept(AutoTypeExecutor* executor); + AutoTypeAction* clone() override; + void accept(AutoTypeExecutor* executor) override; const Qt::Key key; }; @@ -60,8 +58,8 @@ class KEEPASSX_EXPORT AutoTypeDelay : public AutoTypeAction { public: explicit AutoTypeDelay(int delayMs); - AutoTypeAction* clone(); - void accept(AutoTypeExecutor* executor); + AutoTypeAction* clone() override; + void accept(AutoTypeExecutor* executor) override; const int delayMs; }; @@ -70,8 +68,8 @@ class KEEPASSX_EXPORT AutoTypeClearField : public AutoTypeAction { public: AutoTypeClearField(); - AutoTypeAction* clone(); - void accept(AutoTypeExecutor* executor); + AutoTypeAction* clone() override; + void accept(AutoTypeExecutor* executor) override; }; class KEEPASSX_EXPORT AutoTypeExecutor From e2ee82169c3b2edc75bb424e7ab3d292411cd67e Mon Sep 17 00:00:00 2001 From: Gianluca Recchia Date: Sat, 27 Oct 2018 15:58:50 +0200 Subject: [PATCH 03/13] Remove redundant check for the version flag Just a couple lines above, the application would already exit if the version option is set. This extra check is not needed. --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 0b5e0b1cb..9764c52d1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -88,7 +88,7 @@ int main(int argc, char** argv) const QStringList fileNames = parser.positionalArguments(); - if (app.isAlreadyRunning() && !parser.isSet(versionOption)) { + if (app.isAlreadyRunning()) { if (!fileNames.isEmpty()) { app.sendFileNamesToRunningInstance(fileNames); } From 4876beabedb4f7d40a71820428d44e612805d65e Mon Sep 17 00:00:00 2001 From: Gianluca Recchia Date: Sat, 27 Oct 2018 23:23:34 +0200 Subject: [PATCH 04/13] Improve performance of a few for-loops Some for-loops needlessly copied the collection they were looping over. --- src/browser/BrowserService.cpp | 2 +- src/core/Group.cpp | 8 ++++---- src/core/Group.h | 2 +- src/sshagent/OpenSSHKey.cpp | 8 ++++---- src/sshagent/SSHAgent.cpp | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/browser/BrowserService.cpp b/src/browser/BrowserService.cpp index 9917ded3c..456028632 100644 --- a/src/browser/BrowserService.cpp +++ b/src/browser/BrowserService.cpp @@ -421,7 +421,7 @@ QList BrowserService::searchEntries(const QString& url, const StringPair if (DatabaseWidget* dbWidget = qobject_cast(m_dbTabWidget->widget(i))) { if (Database* db = dbWidget->database()) { // Check if database is connected with KeePassXC-Browser - for (const StringPair keyPair : keyList) { + for (const StringPair& keyPair : keyList) { QString key = db->metadata()->customData()->value(QLatin1String(ASSOCIATE_KEY_PREFIX) + keyPair.first); if (!key.isEmpty() && keyPair.second == key) { databases << db; diff --git a/src/core/Group.cpp b/src/core/Group.cpp index dab48ebd1..05cac41e9 100644 --- a/src/core/Group.cpp +++ b/src/core/Group.cpp @@ -926,7 +926,7 @@ bool Group::resolveAutoTypeEnabled() const } } -QStringList Group::locate(QString locateTerm, QString currentPath) +QStringList Group::locate(QString locateTerm, QString currentPath) const { // TODO: Replace with EntrySearcher QStringList response; @@ -934,15 +934,15 @@ QStringList Group::locate(QString locateTerm, QString currentPath) return response; } - for (Entry* entry : asConst(m_entries)) { + for (const Entry* entry : asConst(m_entries)) { QString entryPath = currentPath + entry->title(); if (entryPath.toLower().contains(locateTerm.toLower())) { response << entryPath; } } - for (Group* group : asConst(m_children)) { - for (QString path : group->locate(locateTerm, currentPath + group->name() + QString("/"))) { + for (const Group* group : asConst(m_children)) { + for (const QString& path : group->locate(locateTerm, currentPath + group->name() + QString("/"))) { response << path; } } diff --git a/src/core/Group.h b/src/core/Group.h index e2b55cbd4..3a9332c8e 100644 --- a/src/core/Group.h +++ b/src/core/Group.h @@ -118,7 +118,7 @@ public: Entry* findEntryByPath(QString entryPath); Group* findGroupByUuid(const QUuid& uuid); Group* findGroupByPath(QString groupPath); - QStringList locate(QString locateTerm, QString currentPath = {"/"}); + QStringList locate(QString locateTerm, QString currentPath = {"/"}) const; Entry* addEntryWithPath(QString entryPath); void setUuid(const QUuid& uuid); void setName(const QString& name); diff --git a/src/sshagent/OpenSSHKey.cpp b/src/sshagent/OpenSSHKey.cpp index 44684d620..9d1301a05 100644 --- a/src/sshagent/OpenSSHKey.cpp +++ b/src/sshagent/OpenSSHKey.cpp @@ -101,7 +101,7 @@ const QString OpenSSHKey::fingerprint(QCryptographicHash::Algorithm algo) const stream.writeString(m_type); - for (QByteArray ba : m_publicData) { + for (const QByteArray& ba : m_publicData) { stream.writeString(ba); } @@ -137,7 +137,7 @@ const QString OpenSSHKey::publicKey() const stream.writeString(m_type); - for (QByteArray ba : m_publicData) { + for (const QByteArray& ba : m_publicData) { stream.writeString(ba); } @@ -544,7 +544,7 @@ bool OpenSSHKey::writePublic(BinaryStream& stream) return false; } - for (QByteArray t : m_publicData) { + for (const QByteArray& t : m_publicData) { if (!stream.writeString(t)) { m_error = tr("Unexpected EOF when writing public key"); return false; @@ -566,7 +566,7 @@ bool OpenSSHKey::writePrivate(BinaryStream& stream) return false; } - for (QByteArray t : m_privateData) { + for (const QByteArray& t : m_privateData) { if (!stream.writeString(t)) { m_error = tr("Unexpected EOF when writing private key"); return false; diff --git a/src/sshagent/SSHAgent.cpp b/src/sshagent/SSHAgent.cpp index 758c86851..487398238 100644 --- a/src/sshagent/SSHAgent.cpp +++ b/src/sshagent/SSHAgent.cpp @@ -38,7 +38,7 @@ SSHAgent::SSHAgent(QObject* parent) SSHAgent::~SSHAgent() { - for (QSet keys : m_keys.values()) { + for (const QSet& keys : m_keys.values()) { for (OpenSSHKey key : keys) { removeIdentity(key); } From 4ac1601696577361b0309797d23cc0208891abe4 Mon Sep 17 00:00:00 2001 From: Gianluca Recchia Date: Sat, 27 Oct 2018 23:54:57 +0200 Subject: [PATCH 05/13] Replace old for-loops with range-based for-loops --- src/core/Tools.cpp | 4 ++-- src/gui/ApplicationSettingsWidget.cpp | 4 ++-- src/gui/DialogyWidget.cpp | 3 +-- src/gui/entry/EntryModel.cpp | 6 +++--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/core/Tools.cpp b/src/core/Tools.cpp index 8467fb416..ded3a1651 100644 --- a/src/core/Tools.cpp +++ b/src/core/Tools.cpp @@ -121,8 +121,8 @@ QString imageReaderFilter() QStringList formatsStringList; for (const QByteArray& format : formats) { - for (int i = 0; i < format.size(); i++) { - if (!QChar(format.at(i)).isLetterOrNumber()) { + for (char codePoint : format) { + if (!QChar(codePoint).isLetterOrNumber()) { continue; } } diff --git a/src/gui/ApplicationSettingsWidget.cpp b/src/gui/ApplicationSettingsWidget.cpp index c23e2bfa5..a0293ce8d 100644 --- a/src/gui/ApplicationSettingsWidget.cpp +++ b/src/gui/ApplicationSettingsWidget.cpp @@ -146,8 +146,8 @@ void ApplicationSettingsWidget::loadSettings() m_generalUi->languageComboBox->clear(); QList> languages = Translator::availableLanguages(); - for (int i = 0; i < languages.size(); i++) { - m_generalUi->languageComboBox->addItem(languages[i].second, languages[i].first); + for (const auto& language : languages) { + m_generalUi->languageComboBox->addItem(language.second, language.first); } int defaultIndex = m_generalUi->languageComboBox->findData(config()->get("GUI/Language")); if (defaultIndex > 0) { diff --git a/src/gui/DialogyWidget.cpp b/src/gui/DialogyWidget.cpp index 89e114f10..858d2949b 100644 --- a/src/gui/DialogyWidget.cpp +++ b/src/gui/DialogyWidget.cpp @@ -71,8 +71,7 @@ bool DialogyWidget::clickButton(QDialogButtonBox::StandardButton standardButton) } QList buttonBoxes = findChildren(); - for (int i = 0; i < buttonBoxes.size(); ++i) { - QDialogButtonBox* buttonBox = buttonBoxes.at(i); + for (auto buttonBox : buttonBoxes) { pb = buttonBox->button(standardButton); if (pb && pb->isVisible() && pb->isEnabled()) { pb->click(); diff --git a/src/gui/entry/EntryModel.cpp b/src/gui/entry/EntryModel.cpp index 0616374ac..fa3db177b 100644 --- a/src/gui/entry/EntryModel.cpp +++ b/src/gui/entry/EntryModel.cpp @@ -208,12 +208,12 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const case Attachments: { // Display comma-separated list of attachments QList attachments = entry->attachments()->keys(); - for (int i = 0; i < attachments.size(); ++i) { + for (const auto& attachment : attachments) { if (result.isEmpty()) { - result.append(attachments.at(i)); + result.append(attachment); continue; } - result.append(QString(", ") + attachments.at(i)); + result.append(QString(", ") + attachment); } return result; } From 18fd20f898681126e6014c092047ca2ed1aa5f0a Mon Sep 17 00:00:00 2001 From: Gianluca Recchia Date: Sun, 28 Oct 2018 11:39:15 +0100 Subject: [PATCH 06/13] Remove redundant null-checks for pointer deletion Deleting a null pointer is defined behavior and results in a no-op at the assembly level, so it's perfectly safe. --- src/gui/DatabaseOpenWidget.cpp | 10 +++++----- src/gui/KeePass1OpenWidget.cpp | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/gui/DatabaseOpenWidget.cpp b/src/gui/DatabaseOpenWidget.cpp index 67af3ff13..892c41d3e 100644 --- a/src/gui/DatabaseOpenWidget.cpp +++ b/src/gui/DatabaseOpenWidget.cpp @@ -143,7 +143,7 @@ void DatabaseOpenWidget::load(const QString& filename) QHash useTouchID = config()->get("UseTouchID").toHash(); m_ui->checkTouchID->setChecked(useTouchID.value(m_filename, false).toBool()); - + m_ui->editPassword->setFocus(); } @@ -195,9 +195,9 @@ void DatabaseOpenWidget::openDatabase() MessageWidget::Error); return; } - if (m_db) { - delete m_db; - } + + delete m_db; + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); m_db = reader.readDatabase(&file, masterKey); QApplication::restoreOverrideCursor(); @@ -254,7 +254,7 @@ QSharedPointer DatabaseOpenWidget::databaseKey() // check if the user cancelled the operation if (passwordKey.isNull()) return QSharedPointer(); - + masterKey->addKey(PasswordKey::fromRawKey(*passwordKey)); } } diff --git a/src/gui/KeePass1OpenWidget.cpp b/src/gui/KeePass1OpenWidget.cpp index 4a54aaf3a..8123d239f 100644 --- a/src/gui/KeePass1OpenWidget.cpp +++ b/src/gui/KeePass1OpenWidget.cpp @@ -53,9 +53,9 @@ void KeePass1OpenWidget::openDatabase() MessageWidget::Error); return; } - if (m_db) { - delete m_db; - } + + delete m_db; + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); m_db = reader.readDatabase(&file, password, keyFileName); QApplication::restoreOverrideCursor(); From a67a574b89ae1e12de158d6fdc5b51fdec6f13f3 Mon Sep 17 00:00:00 2001 From: Gianluca Recchia Date: Sun, 28 Oct 2018 12:23:06 +0100 Subject: [PATCH 07/13] Reduce function call overhead The arg() function of the QString class has a variable length argument which allows to reduce the number of chained calls to the same function. With proper formatting, readability is not affected. --- src/browser/BrowserService.cpp | 2 +- src/cli/Extract.cpp | 2 +- src/core/Group.cpp | 2 +- src/core/Merger.cpp | 38 ++++++++++------------------ src/gui/AboutDialog.cpp | 6 ++--- src/gui/KMessageWidget.cpp | 8 +++--- src/gui/csvImport/CsvParserModel.cpp | 6 ++--- src/totp/totp.cpp | 6 ++--- 8 files changed, 30 insertions(+), 40 deletions(-) diff --git a/src/browser/BrowserService.cpp b/src/browser/BrowserService.cpp index 456028632..824cc94b6 100644 --- a/src/browser/BrowserService.cpp +++ b/src/browser/BrowserService.cpp @@ -362,7 +362,7 @@ void BrowserService::updateEntry(const QString& id, if (!browserSettings()->alwaysAllowUpdate()) { QMessageBox msgBox; msgBox.setWindowTitle(tr("KeePassXC: Update Entry")); - msgBox.setText(tr("Do you want to update the information in %1 - %2?").arg(QUrl(url).host()).arg(username)); + msgBox.setText(tr("Do you want to update the information in %1 - %2?").arg(QUrl(url).host(), username)); msgBox.setStandardButtons(QMessageBox::Yes); msgBox.addButton(QMessageBox::No); msgBox.setDefaultButton(QMessageBox::No); diff --git a/src/cli/Extract.cpp b/src/cli/Extract.cpp index 32b1bc028..c0b1b1119 100644 --- a/src/cli/Extract.cpp +++ b/src/cli/Extract.cpp @@ -77,7 +77,7 @@ int Extract::execute(const QStringList& arguments) auto fileKey = QSharedPointer::create(); QString errorMsg; if (!fileKey->load(keyFilePath, &errorMsg)) { - err << QObject::tr("Failed to load key file %1: %2").arg(keyFilePath).arg(errorMsg) << endl; + err << QObject::tr("Failed to load key file %1: %2").arg(keyFilePath, errorMsg) << endl; return EXIT_FAILURE; } diff --git a/src/core/Group.cpp b/src/core/Group.cpp index 05cac41e9..72f2490a0 100644 --- a/src/core/Group.cpp +++ b/src/core/Group.cpp @@ -811,7 +811,7 @@ void Group::removeEntry(Entry* entry) { Q_ASSERT_X(m_entries.contains(entry), Q_FUNC_INFO, - QString("Group %1 does not contain %2").arg(this->name()).arg(entry->title()).toLatin1()); + QString("Group %1 does not contain %2").arg(this->name(), entry->title()).toLatin1()); emit entryAboutToRemove(entry); diff --git a/src/core/Merger.cpp b/src/core/Merger.cpp index 9b87a6ac3..2bdff7377 100644 --- a/src/core/Merger.cpp +++ b/src/core/Merger.cpp @@ -95,7 +95,7 @@ Merger::ChangeList Merger::mergeGroup(const MergeContext& context) // Entry is already present in the database. Update it. const bool locationChanged = targetEntry->timeInfo().locationChanged() < sourceEntry->timeInfo().locationChanged(); if (locationChanged && targetEntry->group() != context.m_targetGroup) { - changes << tr("Relocating %1 [%2]").arg(sourceEntry->title()).arg(sourceEntry->uuidToHex()); + changes << tr("Relocating %1 [%2]").arg(sourceEntry->title(), sourceEntry->uuidToHex()); moveEntry(targetEntry, context.m_targetGroup); } changes << resolveEntryConflict(context, sourceEntry, targetEntry); @@ -107,7 +107,7 @@ Merger::ChangeList Merger::mergeGroup(const MergeContext& context) for (Group* sourceChildGroup : sourceChildGroups) { Group* targetChildGroup = context.m_targetRootGroup->findGroupByUuid(sourceChildGroup->uuid()); if (!targetChildGroup) { - changes << tr("Creating missing %1 [%2]").arg(sourceChildGroup->name()).arg(sourceChildGroup->uuidToHex()); + changes << tr("Creating missing %1 [%2]").arg(sourceChildGroup->name(), sourceChildGroup->uuidToHex()); targetChildGroup = sourceChildGroup->clone(Entry::CloneNoFlags, Group::CloneNoFlags); moveGroup(targetChildGroup, context.m_targetGroup); TimeInfo timeinfo = targetChildGroup->timeInfo(); @@ -117,7 +117,7 @@ Merger::ChangeList Merger::mergeGroup(const MergeContext& context) bool locationChanged = targetChildGroup->timeInfo().locationChanged() < sourceChildGroup->timeInfo().locationChanged(); if (locationChanged && targetChildGroup->parent() != context.m_targetGroup) { - changes << tr("Relocating %1 [%2]").arg(sourceChildGroup->name()).arg(sourceChildGroup->uuidToHex()); + changes << tr("Relocating %1 [%2]").arg(sourceChildGroup->name(), sourceChildGroup->uuidToHex()); moveGroup(targetChildGroup, context.m_targetGroup); TimeInfo timeinfo = targetChildGroup->timeInfo(); timeinfo.setLocationChanged(sourceChildGroup->timeInfo().locationChanged()); @@ -146,7 +146,7 @@ Merger::ChangeList Merger::resolveGroupConflict(const MergeContext& context, con // only if the other group is newer, update the existing one. if (timeExisting < timeOther) { - changes << tr("Overwriting %1 [%2]").arg(sourceChildGroup->name()).arg(sourceChildGroup->uuidToHex()); + changes << tr("Overwriting %1 [%2]").arg(sourceChildGroup->name(), sourceChildGroup->uuidToHex()); targetChildGroup->setName(sourceChildGroup->name()); targetChildGroup->setNotes(sourceChildGroup->notes()); if (sourceChildGroup->iconNumber() == 0) { @@ -270,16 +270,12 @@ Merger::ChangeList Merger::resolveEntryConflict_Duplicate(const MergeContext& co Entry* clonedEntry = sourceEntry->clone(Entry::CloneNewUuid | Entry::CloneIncludeHistory); moveEntry(clonedEntry, context.m_targetGroup); markOlderEntry(targetEntry); - changes << tr("Adding backup for older target %1 [%2]") - .arg(targetEntry->title()) - .arg(targetEntry->uuidToHex()); + changes << tr("Adding backup for older target %1 [%2]").arg(targetEntry->title(), targetEntry->uuidToHex()); } else if (comparison > 0) { Entry* clonedEntry = sourceEntry->clone(Entry::CloneNewUuid | Entry::CloneIncludeHistory); moveEntry(clonedEntry, context.m_targetGroup); markOlderEntry(clonedEntry); - changes << tr("Adding backup for older source %1 [%2]") - .arg(sourceEntry->title()) - .arg(sourceEntry->uuidToHex()); + changes << tr("Adding backup for older source %1 [%2]").arg(sourceEntry->title(), sourceEntry->uuidToHex()); } return changes; } @@ -297,8 +293,7 @@ Merger::ChangeList Merger::resolveEntryConflict_KeepLocal(const MergeContext& co // this type of merge changes the database timestamp since reapplying the // old entry is an active change of the database! changes << tr("Reapplying older target entry on top of newer source %1 [%2]") - .arg(targetEntry->title()) - .arg(targetEntry->uuidToHex()); + .arg(targetEntry->title(), targetEntry->uuidToHex()); Entry* agedTargetEntry = targetEntry->clone(Entry::CloneNoFlags); targetEntry->addHistoryItem(agedTargetEntry); } @@ -318,8 +313,7 @@ Merger::ChangeList Merger::resolveEntryConflict_KeepRemote(const MergeContext& c // this type of merge changes the database timestamp since reapplying the // old entry is an active change of the database! changes << tr("Reapplying older source entry on top of newer target %1 [%2]") - .arg(targetEntry->title()) - .arg(targetEntry->uuidToHex()); + .arg(targetEntry->title(), targetEntry->uuidToHex()); targetEntry->beginUpdate(); targetEntry->copyDataFrom(sourceEntry); targetEntry->endUpdate(); @@ -342,9 +336,7 @@ Merger::ChangeList Merger::resolveEntryConflict_MergeHistories(const MergeContex qPrintable(targetEntry->title()), qPrintable(sourceEntry->title()), qPrintable(currentGroup->name())); - changes << tr("Synchronizing from newer source %1 [%2]") - .arg(targetEntry->title()) - .arg(targetEntry->uuidToHex()); + changes << tr("Synchronizing from newer source %1 [%2]").arg(targetEntry->title(), targetEntry->uuidToHex()); moveEntry(clonedEntry, currentGroup); mergeHistory(targetEntry, clonedEntry, mergeMethod); eraseEntry(targetEntry); @@ -355,9 +347,7 @@ Merger::ChangeList Merger::resolveEntryConflict_MergeHistories(const MergeContex qPrintable(targetEntry->group()->name())); const bool changed = mergeHistory(sourceEntry, targetEntry, mergeMethod); if (changed) { - changes << tr("Synchronizing from older source %1 [%2]") - .arg(targetEntry->title()) - .arg(targetEntry->uuidToHex()); + changes << tr("Synchronizing from older source %1 [%2]").arg(targetEntry->title(), targetEntry->uuidToHex()); } } return changes; @@ -550,9 +540,9 @@ Merger::ChangeList Merger::mergeDeletions(const MergeContext& context) } deletions << object; if (entry->group()) { - changes << tr("Deleting child %1 [%2]").arg(entry->title()).arg(entry->uuidToHex()); + changes << tr("Deleting child %1 [%2]").arg(entry->title(), entry->uuidToHex()); } else { - changes << tr("Deleting orphan %1 [%2]").arg(entry->title()).arg(entry->uuidToHex()); + changes << tr("Deleting orphan %1 [%2]").arg(entry->title(), entry->uuidToHex()); } // Entry is inserted into deletedObjects after deletions are processed eraseEntry(entry); @@ -576,9 +566,9 @@ Merger::ChangeList Merger::mergeDeletions(const MergeContext& context) } deletions << object; if (group->parentGroup()) { - changes << tr("Deleting child %1 [%2]").arg(group->name()).arg(group->uuidToHex()); + changes << tr("Deleting child %1 [%2]").arg(group->name(), group->uuidToHex()); } else { - changes << tr("Deleting orphan %1 [%2]").arg(group->name()).arg(group->uuidToHex()); + changes << tr("Deleting orphan %1 [%2]").arg(group->name(), group->uuidToHex()); } eraseGroup(group); } diff --git a/src/gui/AboutDialog.cpp b/src/gui/AboutDialog.cpp index f6a9d15f9..483e4dd2b 100644 --- a/src/gui/AboutDialog.cpp +++ b/src/gui/AboutDialog.cpp @@ -65,9 +65,9 @@ AboutDialog::AboutDialog(QWidget* parent) #endif debugInfo.append("\n").append(QString("%1\n- Qt %2\n- %3\n\n") - .arg(tr("Libraries:")) - .arg(QString::fromLocal8Bit(qVersion())) - .arg(Crypto::backendVersion())); + .arg(tr("Libraries:"), + QString::fromLocal8Bit(qVersion()), + Crypto::backendVersion())); #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) debugInfo.append(tr("Operating system: %1\nCPU architecture: %2\nKernel: %3 %4") diff --git a/src/gui/KMessageWidget.cpp b/src/gui/KMessageWidget.cpp index 3d0500708..2e68975e3 100644 --- a/src/gui/KMessageWidget.cpp +++ b/src/gui/KMessageWidget.cpp @@ -309,10 +309,10 @@ void KMessageWidget::setMessageType(KMessageWidget::MessageType type) "}" ".QLabel { color: %6; }" )) - .arg(bg0.name()) - .arg(bg1.name()) - .arg(bg2.name()) - .arg(border.name()) + .arg(bg0.name(), + bg1.name(), + bg2.name(), + border.name()) // DefaultFrameWidth returns the size of the external margin + border width. We know our border is 1px, // so we subtract this from the frame normal QStyle FrameWidth to get our margin .arg(style()->pixelMetric(QStyle::PM_DefaultFrameWidth, nullptr, this) - 1) diff --git a/src/gui/csvImport/CsvParserModel.cpp b/src/gui/csvImport/CsvParserModel.cpp index e69ea1853..8f7d98ec4 100644 --- a/src/gui/csvImport/CsvParserModel.cpp +++ b/src/gui/csvImport/CsvParserModel.cpp @@ -36,9 +36,9 @@ void CsvParserModel::setFilename(const QString& filename) QString CsvParserModel::getFileInfo() { QString a(tr("%1, %2, %3", "file info: bytes, rows, columns") - .arg(tr("%n byte(s)", nullptr, getFileSize())) - .arg(tr("%n row(s)", nullptr, getCsvRows())) - .arg(tr("%n column(s)", nullptr, qMax(0, getCsvCols() - 1)))); + .arg(tr("%n byte(s)", nullptr, getFileSize()), + tr("%n row(s)", nullptr, getCsvRows()), + tr("%n column(s)", nullptr, qMax(0, getCsvCols() - 1)))); return a; } diff --git a/src/totp/totp.cpp b/src/totp/totp.cpp index 4140993c7..bc66fffa4 100644 --- a/src/totp/totp.cpp +++ b/src/totp/totp.cpp @@ -106,9 +106,9 @@ QString Totp::writeSettings(const QSharedPointer settings, const // OTP Url output if (settings->otpUrl || forceOtp) { auto urlstring = QString("otpauth://totp/%1:%2?secret=%3&period=%4&digits=%5&issuer=%1") - .arg(title.isEmpty() ? "KeePassXC" : QString(QUrl::toPercentEncoding(title))) - .arg(username.isEmpty() ? "none" : QString(QUrl::toPercentEncoding(username))) - .arg(QString(Base32::sanitizeInput(settings->key.toLatin1()))) + .arg(title.isEmpty() ? "KeePassXC" : QString(QUrl::toPercentEncoding(title)), + username.isEmpty() ? "none" : QString(QUrl::toPercentEncoding(username)), + QString(Base32::sanitizeInput(settings->key.toLatin1()))) .arg(settings->step) .arg(settings->digits); From da9afd3f6fcb7b7c3c5c02112ffe49c1ee34ba43 Mon Sep 17 00:00:00 2001 From: Gianluca Recchia Date: Sun, 28 Oct 2018 12:49:32 +0100 Subject: [PATCH 08/13] Reduce number of unneeded copies This patch aims at reducing the number of copies for obejcts that could be referenced rather than copied, because they're not modified during the computation. --- src/browser/BrowserAction.cpp | 8 ++++---- src/browser/BrowserAction.h | 8 ++++---- src/browser/BrowserSettings.cpp | 8 ++++---- src/browser/BrowserSettings.h | 8 ++++---- src/cli/Clip.cpp | 2 +- src/cli/Clip.h | 2 +- src/cli/Command.cpp | 2 +- src/cli/Command.h | 2 +- src/core/CsvParser.cpp | 6 +++--- src/core/CsvParser.h | 4 ++-- src/core/Database.cpp | 12 ++++++------ src/core/Database.h | 12 ++++++------ src/core/EntrySearcher.cpp | 4 ++-- src/core/Group.cpp | 12 ++++++------ src/core/Group.h | 12 ++++++------ src/core/PasswordGenerator.cpp | 2 +- src/core/PasswordGenerator.h | 2 +- src/format/CsvExporter.cpp | 4 ++-- src/format/KeePass2.cpp | 4 ++-- src/format/KeePass2.h | 4 ++-- src/gui/EditWidgetIcons.cpp | 4 ++-- src/gui/FileDialog.cpp | 2 +- src/gui/FileDialog.h | 2 +- src/gui/MainWindow.cpp | 2 +- src/gui/MainWindow.h | 2 +- src/gui/PasswordEdit.cpp | 2 +- src/gui/PasswordEdit.h | 2 +- src/gui/csvImport/CsvImportWidget.cpp | 4 ++-- src/gui/csvImport/CsvImportWidget.h | 4 ++-- src/gui/entry/AutoTypeMatchModel.cpp | 2 +- src/gui/entry/AutoTypeMatchModel.h | 2 +- src/gui/entry/AutoTypeMatchView.cpp | 2 +- src/gui/entry/AutoTypeMatchView.h | 2 +- src/gui/entry/EntryHistoryModel.cpp | 2 +- src/keys/CompositeKey.cpp | 4 ++-- src/keys/CompositeKey.h | 4 ++-- src/streams/HmacBlockStream.cpp | 2 +- src/streams/HmacBlockStream.h | 2 +- src/totp/totp.cpp | 8 ++++---- src/totp/totp.h | 8 ++++---- 40 files changed, 90 insertions(+), 90 deletions(-) diff --git a/src/browser/BrowserAction.cpp b/src/browser/BrowserAction.cpp index fcbc318ee..ccd17c5fd 100644 --- a/src/browser/BrowserAction.cpp +++ b/src/browser/BrowserAction.cpp @@ -468,7 +468,7 @@ QJsonObject BrowserAction::decryptMessage(const QString& message, const QString& return getErrorReply(action, ERROR_KEEPASS_CANNOT_DECRYPT_MESSAGE); } -QString BrowserAction::encrypt(const QString plaintext, const QString nonce) +QString BrowserAction::encrypt(const QString& plaintext, const QString& nonce) { QMutexLocker locker(&m_mutex); const QByteArray ma = plaintext.toUtf8(); @@ -496,7 +496,7 @@ QString BrowserAction::encrypt(const QString plaintext, const QString nonce) return QString(); } -QByteArray BrowserAction::decrypt(const QString encrypted, const QString nonce) +QByteArray BrowserAction::decrypt(const QString& encrypted, const QString& nonce) { QMutexLocker locker(&m_mutex); const QByteArray ma = base64Decode(encrypted); @@ -546,14 +546,14 @@ QJsonObject BrowserAction::getJsonObject(const uchar* pArray, const uint len) co return doc.object(); } -QJsonObject BrowserAction::getJsonObject(const QByteArray ba) const +QJsonObject BrowserAction::getJsonObject(const QByteArray& ba) const { QJsonParseError err; QJsonDocument doc(QJsonDocument::fromJson(ba, &err)); return doc.object(); } -QByteArray BrowserAction::base64Decode(const QString str) +QByteArray BrowserAction::base64Decode(const QString& str) { return QByteArray::fromBase64(str.toUtf8()); } diff --git a/src/browser/BrowserAction.h b/src/browser/BrowserAction.h index 5a7c83bf8..b7a60938f 100644 --- a/src/browser/BrowserAction.h +++ b/src/browser/BrowserAction.h @@ -73,14 +73,14 @@ private: QString encryptMessage(const QJsonObject& message, const QString& nonce); QJsonObject decryptMessage(const QString& message, const QString& nonce, const QString& action = QString()); - QString encrypt(const QString plaintext, const QString nonce); - QByteArray decrypt(const QString encrypted, const QString nonce); + QString encrypt(const QString& plaintext, const QString& nonce); + QByteArray decrypt(const QString& encrypted, const QString& nonce); QString getBase64FromKey(const uchar* array, const uint len); QByteArray getQByteArray(const uchar* array, const uint len) const; QJsonObject getJsonObject(const uchar* pArray, const uint len) const; - QJsonObject getJsonObject(const QByteArray ba) const; - QByteArray base64Decode(const QString str); + QJsonObject getJsonObject(const QByteArray& ba) const; + QByteArray base64Decode(const QString& str); QString incrementNonce(const QString& nonce); private: diff --git a/src/browser/BrowserSettings.cpp b/src/browser/BrowserSettings.cpp index 630d0ff18..646c6c4d3 100644 --- a/src/browser/BrowserSettings.cpp +++ b/src/browser/BrowserSettings.cpp @@ -169,7 +169,7 @@ QString BrowserSettings::customProxyLocation() return config()->get("Browser/CustomProxyLocation", "").toString(); } -void BrowserSettings::setCustomProxyLocation(QString location) +void BrowserSettings::setCustomProxyLocation(const QString& location) { config()->set("Browser/CustomProxyLocation", location); } @@ -364,7 +364,7 @@ QString BrowserSettings::passwordExcludedChars() return config()->get("generator/ExcludedChars", PasswordGenerator::DefaultExcludedChars).toString(); } -void BrowserSettings::setPasswordExcludedChars(QString chars) +void BrowserSettings::setPasswordExcludedChars(const QString& chars) { config()->set("generator/ExcludedChars", chars); } @@ -384,7 +384,7 @@ QString BrowserSettings::passPhraseWordSeparator() return config()->get("generator/WordSeparator", PassphraseGenerator::DefaultSeparator).toString(); } -void BrowserSettings::setPassPhraseWordSeparator(QString separator) +void BrowserSettings::setPassPhraseWordSeparator(const QString& separator) { config()->set("generator/WordSeparator", separator); } @@ -496,7 +496,7 @@ QString BrowserSettings::generatePassword() } } -void BrowserSettings::updateBinaryPaths(QString customProxyLocation) +void BrowserSettings::updateBinaryPaths(const QString& customProxyLocation) { bool isProxy = supportBrowserProxy(); m_hostInstaller.updateBinaryPaths(isProxy, customProxyLocation); diff --git a/src/browser/BrowserSettings.h b/src/browser/BrowserSettings.h index 2e7c55ec6..92cdcd16d 100644 --- a/src/browser/BrowserSettings.h +++ b/src/browser/BrowserSettings.h @@ -59,7 +59,7 @@ public: bool useCustomProxy(); void setUseCustomProxy(bool enabled); QString customProxyLocation(); - void setCustomProxyLocation(QString location); + void setCustomProxyLocation(const QString& location); bool updateBinaryPath(); void setUpdateBinaryPath(bool enabled); bool chromeSupport(); @@ -98,11 +98,11 @@ public: bool advancedMode(); void setAdvancedMode(bool advancedMode); QString passwordExcludedChars(); - void setPasswordExcludedChars(QString chars); + void setPasswordExcludedChars(const QString& chars); int passPhraseWordCount(); void setPassPhraseWordCount(int wordCount); QString passPhraseWordSeparator(); - void setPassPhraseWordSeparator(QString separator); + void setPassPhraseWordSeparator(const QString& separator); int generatorType(); void setGeneratorType(int type); bool passwordEveryGroup(); @@ -114,7 +114,7 @@ public: PasswordGenerator::CharClasses passwordCharClasses(); PasswordGenerator::GeneratorFlags passwordGeneratorFlags(); QString generatePassword(); - void updateBinaryPaths(QString customProxyLocation = QString()); + void updateBinaryPaths(const QString& customProxyLocation = QString()); bool checkIfProxyExists(QString& path); private: diff --git a/src/cli/Clip.cpp b/src/cli/Clip.cpp index 2268c6624..a9135eff4 100644 --- a/src/cli/Clip.cpp +++ b/src/cli/Clip.cpp @@ -71,7 +71,7 @@ int Clip::execute(const QStringList& arguments) return clipEntry(db, args.at(1), args.value(2)); } -int Clip::clipEntry(Database* database, QString entryPath, QString timeout) +int Clip::clipEntry(Database* database, const QString& entryPath, const QString& timeout) { TextStream err(Utils::STDERR); diff --git a/src/cli/Clip.h b/src/cli/Clip.h index e94231236..929ddf678 100644 --- a/src/cli/Clip.h +++ b/src/cli/Clip.h @@ -26,7 +26,7 @@ public: Clip(); ~Clip(); int execute(const QStringList& arguments); - int clipEntry(Database* database, QString entryPath, QString timeout); + int clipEntry(Database* database, const QString& entryPath, const QString& timeout); }; #endif // KEEPASSXC_CLIP_H diff --git a/src/cli/Command.cpp b/src/cli/Command.cpp index c85e5d95d..a95676ff0 100644 --- a/src/cli/Command.cpp +++ b/src/cli/Command.cpp @@ -71,7 +71,7 @@ void populateCommands() } } -Command* Command::getCommand(QString commandName) +Command* Command::getCommand(const QString& commandName) { populateCommands(); if (commands.contains(commandName)) { diff --git a/src/cli/Command.h b/src/cli/Command.h index 7ad49440a..4e4e076de 100644 --- a/src/cli/Command.h +++ b/src/cli/Command.h @@ -35,7 +35,7 @@ public: QString getDescriptionLine(); static QList getCommands(); - static Command* getCommand(QString commandName); + static Command* getCommand(const QString& commandName); }; #endif // KEEPASSXC_COMMAND_H diff --git a/src/core/CsvParser.cpp b/src/core/CsvParser.cpp index a66c919b2..e545d1db4 100644 --- a/src/core/CsvParser.cpp +++ b/src/core/CsvParser.cpp @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2016 Enrico Mariotti * Copyright (C) 2017 KeePassXC Team * @@ -327,7 +327,7 @@ bool CsvParser::isText(QChar c) const return !((isCRLF(c)) || (isSeparator(c))); } -bool CsvParser::isEmptyRow(CsvRow row) const +bool CsvParser::isEmptyRow(const CsvRow& row) const { CsvRow::const_iterator it = row.constBegin(); for (; it != row.constEnd(); ++it) @@ -414,7 +414,7 @@ int CsvParser::getCsvRows() const return m_table.size(); } -void CsvParser::appendStatusMsg(QString s, bool isCritical) +void CsvParser::appendStatusMsg(const QString& s, bool isCritical) { m_statusMsg += QObject::tr("%1: (row, col) %2,%3").arg(s, m_currRow, m_currCol).append("\n"); m_isGood = !isCritical; diff --git a/src/core/CsvParser.h b/src/core/CsvParser.h index 323023114..d90e8300a 100644 --- a/src/core/CsvParser.h +++ b/src/core/CsvParser.h @@ -83,7 +83,7 @@ private: bool isCRLF(const QChar& c) const; bool isSpace(const QChar& c) const; bool isTab(const QChar& c) const; - bool isEmptyRow(CsvRow row) const; + bool isEmptyRow(const CsvRow& row) const; bool parseFile(); void parseRecord(); void parseField(CsvRow& row); @@ -96,7 +96,7 @@ private: void clear(); bool skipEndline(); void skipLine(); - void appendStatusMsg(QString s, bool isCritical = false); + void appendStatusMsg(const QString& s, bool isCritical = false); }; #endif // CSVPARSER_H diff --git a/src/core/Database.cpp b/src/core/Database.cpp index 5116fd199..693b9c549 100644 --- a/src/core/Database.cpp +++ b/src/core/Database.cpp @@ -315,7 +315,7 @@ void Database::setCompressionAlgo(Database::CompressionAlgorithm algo) * @param updateTransformSalt true to update the transform salt * @return true on success */ -bool Database::setKey(QSharedPointer key, bool updateChangedTime, bool updateTransformSalt) +bool Database::setKey(const QSharedPointer& key, bool updateChangedTime, bool updateTransformSalt) { if (!key) { m_data.key.reset(); @@ -354,7 +354,7 @@ bool Database::hasKey() const return m_data.hasKey; } -bool Database::verifyKey(QSharedPointer key) const +bool Database::verifyKey(const QSharedPointer& key) const { Q_ASSERT(hasKey()); @@ -501,7 +501,7 @@ Database* Database::openDatabaseFile(const QString& fileName, QSharedPointer::create(); QTextStream out(outputDescriptor); @@ -553,7 +553,7 @@ Database* Database::unlockFromStdin(QString databaseFilename, QString keyFilenam * @param backup Backup the existing database file, if exists * @return error string, if any */ -QString Database::saveToFile(QString filePath, bool atomic, bool backup) +QString Database::saveToFile(const QString& filePath, bool atomic, bool backup) { QString error; if (atomic) { @@ -633,7 +633,7 @@ QString Database::writeDatabase(QIODevice* device) * @param filePath Path to the file to backup * @return */ -bool Database::backupDatabase(QString filePath) +bool Database::backupDatabase(const QString& filePath) { QString backupFilePath = filePath; auto re = QRegularExpression("\\.kdbx$|(? kdf) m_data.kdf = std::move(kdf); } -bool Database::changeKdf(QSharedPointer kdf) +bool Database::changeKdf(const QSharedPointer& kdf) { kdf->randomizeSeed(); QByteArray transformedMasterKey; diff --git a/src/core/Database.h b/src/core/Database.h index 7108ded31..692444f4d 100644 --- a/src/core/Database.h +++ b/src/core/Database.h @@ -110,9 +110,9 @@ public: void setCipher(const QUuid& cipher); void setCompressionAlgo(Database::CompressionAlgorithm algo); void setKdf(QSharedPointer kdf); - bool setKey(QSharedPointer key, bool updateChangedTime = true, bool updateTransformSalt = false); + bool setKey(const QSharedPointer& key, bool updateChangedTime = true, bool updateTransformSalt = false); bool hasKey() const; - bool verifyKey(QSharedPointer key) const; + bool verifyKey(const QSharedPointer& key) const; QVariantMap& publicCustomData(); const QVariantMap& publicCustomData() const; void setPublicCustomData(const QVariantMap& customData); @@ -121,17 +121,17 @@ public: void emptyRecycleBin(); void setEmitModified(bool value); void markAsModified(); - QString saveToFile(QString filePath, bool atomic = true, bool backup = false); + QString saveToFile(const QString& filePath, bool atomic = true, bool backup = false); /** * Returns a unique id that is only valid as long as the Database exists. */ const QUuid& uuid(); - bool changeKdf(QSharedPointer kdf); + bool changeKdf(const QSharedPointer& kdf); static Database* databaseByUuid(const QUuid& uuid); static Database* openDatabaseFile(const QString& fileName, QSharedPointer key); - static Database* unlockFromStdin(QString databaseFilename, QString keyFilename = {}, + static Database* unlockFromStdin(const QString& databaseFilename, const QString& keyFilename = {}, FILE* outputDescriptor = stdout, FILE* errorDescriptor = stderr); signals: @@ -156,7 +156,7 @@ private: void createRecycleBin(); QString writeDatabase(QIODevice* device); - bool backupDatabase(QString filePath); + bool backupDatabase(const QString& filePath); Metadata* const m_metadata; Group* m_rootGroup; diff --git a/src/core/EntrySearcher.cpp b/src/core/EntrySearcher.cpp index 820646a98..3413f1cd0 100644 --- a/src/core/EntrySearcher.cpp +++ b/src/core/EntrySearcher.cpp @@ -34,12 +34,12 @@ EntrySearcher::searchEntries(const QString& searchTerm, const Group* group, Qt:: { QList searchResult; - const QList entryList = group->entries(); + const QList& entryList = group->entries(); for (Entry* entry : entryList) { searchResult.append(matchEntry(searchTerm, entry, caseSensitivity)); } - const QList children = group->children(); + const QList& children = group->children(); for (Group* childGroup : children) { if (childGroup->searchingEnabled() != Group::Disable) { if (matchGroup(searchTerm, childGroup, caseSensitivity)) { diff --git a/src/core/Group.cpp b/src/core/Group.cpp index 72f2490a0..4b1d11ab0 100644 --- a/src/core/Group.cpp +++ b/src/core/Group.cpp @@ -563,7 +563,7 @@ Entry* Group::findEntryByUuid(const QUuid& uuid) const return nullptr; } -Entry* Group::findEntryByPath(QString entryPath) +Entry* Group::findEntryByPath(const QString& entryPath) { if (entryPath.isEmpty()) { return nullptr; @@ -578,7 +578,7 @@ Entry* Group::findEntryByPath(QString entryPath) return findEntryByPathRecursive(normalizedEntryPath, "/"); } -Entry* Group::findEntryByPathRecursive(QString entryPath, QString basePath) +Entry* Group::findEntryByPathRecursive(const QString& entryPath, const QString& basePath) { // Return the first entry that matches the full path OR if there is no leading // slash, return the first entry title that matches @@ -599,7 +599,7 @@ Entry* Group::findEntryByPathRecursive(QString entryPath, QString basePath) return nullptr; } -Group* Group::findGroupByPath(QString groupPath) +Group* Group::findGroupByPath(const QString& groupPath) { // normalize the groupPath by adding missing front and rear slashes. once. QString normalizedGroupPath; @@ -614,7 +614,7 @@ Group* Group::findGroupByPath(QString groupPath) return findGroupByPathRecursive(normalizedGroupPath, "/"); } -Group* Group::findGroupByPathRecursive(QString groupPath, QString basePath) +Group* Group::findGroupByPathRecursive(const QString& groupPath, const QString& basePath) { // paths must be normalized Q_ASSERT(groupPath.startsWith("/") && groupPath.endsWith("/")); @@ -926,7 +926,7 @@ bool Group::resolveAutoTypeEnabled() const } } -QStringList Group::locate(QString locateTerm, QString currentPath) const +QStringList Group::locate(const QString& locateTerm, const QString& currentPath) const { // TODO: Replace with EntrySearcher QStringList response; @@ -950,7 +950,7 @@ QStringList Group::locate(QString locateTerm, QString currentPath) const return response; } -Entry* Group::addEntryWithPath(QString entryPath) +Entry* Group::addEntryWithPath(const QString& entryPath) { if (entryPath.isEmpty() || findEntryByPath(entryPath)) { return nullptr; diff --git a/src/core/Group.h b/src/core/Group.h index 3a9332c8e..da6994d2a 100644 --- a/src/core/Group.h +++ b/src/core/Group.h @@ -115,11 +115,11 @@ public: Group* findChildByName(const QString& name); Entry* findEntryByUuid(const QUuid& uuid) const; - Entry* findEntryByPath(QString entryPath); + Entry* findEntryByPath(const QString& entryPath); Group* findGroupByUuid(const QUuid& uuid); - Group* findGroupByPath(QString groupPath); - QStringList locate(QString locateTerm, QString currentPath = {"/"}) const; - Entry* addEntryWithPath(QString entryPath); + Group* findGroupByPath(const QString& groupPath); + QStringList locate(const QString& locateTerm, const QString& currentPath = {"/"}) const; + Entry* addEntryWithPath(const QString& entryPath); void setUuid(const QUuid& uuid); void setName(const QString& name); void setNotes(const QString& notes); @@ -190,8 +190,8 @@ private: void cleanupParent(); void recCreateDelObjects(); - Entry* findEntryByPathRecursive(QString entryPath, QString basePath); - Group* findGroupByPathRecursive(QString groupPath, QString basePath); + Entry* findEntryByPathRecursive(const QString& entryPath, const QString& basePath); + Group* findGroupByPathRecursive(const QString& groupPath, const QString& basePath); QPointer m_db; QUuid m_uuid; diff --git a/src/core/PasswordGenerator.cpp b/src/core/PasswordGenerator.cpp index 3dbcdaad8..124b99896 100644 --- a/src/core/PasswordGenerator.cpp +++ b/src/core/PasswordGenerator.cpp @@ -31,7 +31,7 @@ PasswordGenerator::PasswordGenerator() { } -double PasswordGenerator::calculateEntropy(QString password) +double PasswordGenerator::calculateEntropy(const QString& password) { return ZxcvbnMatch(password.toLatin1(), 0, 0); } diff --git a/src/core/PasswordGenerator.h b/src/core/PasswordGenerator.h index cb6402d0f..7bfdddd69 100644 --- a/src/core/PasswordGenerator.h +++ b/src/core/PasswordGenerator.h @@ -57,7 +57,7 @@ public: public: PasswordGenerator(); - double calculateEntropy(QString password); + double calculateEntropy(const QString& password); void setLength(int length); void setCharClasses(const CharClasses& classes); void setFlags(const GeneratorFlags& flags); diff --git a/src/format/CsvExporter.cpp b/src/format/CsvExporter.cpp index c444afe23..67e6a44fc 100644 --- a/src/format/CsvExporter.cpp +++ b/src/format/CsvExporter.cpp @@ -64,7 +64,7 @@ bool CsvExporter::writeGroup(QIODevice* device, const Group* group, QString grou } groupPath.append(group->name()); - const QList entryList = group->entries(); + const QList& entryList = group->entries(); for (const Entry* entry : entryList) { QString line; @@ -83,7 +83,7 @@ bool CsvExporter::writeGroup(QIODevice* device, const Group* group, QString grou } } - const QList children = group->children(); + const QList& children = group->children(); for (const Group* child : children) { if (!writeGroup(device, child, groupPath)) { return false; diff --git a/src/format/KeePass2.cpp b/src/format/KeePass2.cpp index 9c0714484..639255d27 100644 --- a/src/format/KeePass2.cpp +++ b/src/format/KeePass2.cpp @@ -59,7 +59,7 @@ const QList> KeePass2::KDFS{ qMakePair(KeePass2::KDF_AES_KDBX3, QObject::tr("AES-KDF (KDBX 3.1)")) }; -QByteArray KeePass2::hmacKey(QByteArray masterSeed, QByteArray transformedMasterKey) +QByteArray KeePass2::hmacKey(const QByteArray& masterSeed, const QByteArray& transformedMasterKey) { CryptoHash hmacKeyHash(CryptoHash::Sha512); hmacKeyHash.addData(masterSeed); @@ -98,7 +98,7 @@ QSharedPointer KeePass2::kdfFromParameters(const QVariantMap& p) return kdf; } -QVariantMap KeePass2::kdfToParameters(QSharedPointer kdf) +QVariantMap KeePass2::kdfToParameters(const QSharedPointer& kdf) { return kdf->writeParameters(); } diff --git a/src/format/KeePass2.h b/src/format/KeePass2.h index 02fe635ca..195ce8c2b 100644 --- a/src/format/KeePass2.h +++ b/src/format/KeePass2.h @@ -126,9 +126,9 @@ extern const QList> KDFS; ByteArray = 0x42 }; -QByteArray hmacKey(QByteArray masterSeed, QByteArray transformedMasterKey); +QByteArray hmacKey(const QByteArray& masterSeed, const QByteArray& transformedMasterKey); QSharedPointer kdfFromParameters(const QVariantMap& p); -QVariantMap kdfToParameters(QSharedPointer kdf); +QVariantMap kdfToParameters(const QSharedPointer& kdf); QSharedPointer uuidToKdf(const QUuid& uuid); ProtectedStreamAlgo idToProtectedStreamAlgo(quint32 id); diff --git a/src/gui/EditWidgetIcons.cpp b/src/gui/EditWidgetIcons.cpp index 0555359d8..f2c320dc9 100644 --- a/src/gui/EditWidgetIcons.cpp +++ b/src/gui/EditWidgetIcons.cpp @@ -176,7 +176,7 @@ namespace { // Try to get the 2nd level domain of the host part of a QUrl. For example, // "foo.bar.example.com" would become "example.com", and "foo.bar.example.co.uk" // would become "example.co.uk". - QString getSecondLevelDomain(QUrl url) + QString getSecondLevelDomain(const QUrl& url) { QString fqdn = url.host(); fqdn.truncate(fqdn.length() - url.topLevelDomain().length()); @@ -185,7 +185,7 @@ namespace { return newdom; } - QUrl convertVariantToUrl(QVariant var) + QUrl convertVariantToUrl(const QVariant& var) { QUrl url; if (var.canConvert()) diff --git a/src/gui/FileDialog.cpp b/src/gui/FileDialog.cpp index 5bccc4af3..b063d62f3 100644 --- a/src/gui/FileDialog.cpp +++ b/src/gui/FileDialog.cpp @@ -178,7 +178,7 @@ FileDialog::FileDialog() { } -void FileDialog::saveLastDir(QString dir) +void FileDialog::saveLastDir(const QString& dir) { if (!dir.isEmpty() && !m_forgetLastDir) { config()->set("LastDir", QFileInfo(dir).absolutePath()); diff --git a/src/gui/FileDialog.h b/src/gui/FileDialog.h index 4862dcfda..83b151ec9 100644 --- a/src/gui/FileDialog.h +++ b/src/gui/FileDialog.h @@ -65,7 +65,7 @@ private: QString m_nextDirName; bool m_forgetLastDir = false; - void saveLastDir(QString); + void saveLastDir(const QString&); static FileDialog* m_instance; diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 9efe0c273..8f0c23044 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -673,7 +673,7 @@ void MainWindow::switchToOpenDatabase() switchToDatabases(); } -void MainWindow::switchToDatabaseFile(QString file) +void MainWindow::switchToDatabaseFile(const QString& file) { m_ui->tabWidget->openDatabase(file); switchToDatabases(); diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h index d83b4a1ff..174e47564 100644 --- a/src/gui/MainWindow.h +++ b/src/gui/MainWindow.h @@ -90,7 +90,7 @@ private slots: void switchToPasswordGen(bool enabled); void switchToNewDatabase(); void switchToOpenDatabase(); - void switchToDatabaseFile(QString file); + void switchToDatabaseFile(const QString& file); void switchToKeePass1Database(); void switchToCsvImport(); void closePasswordGen(); diff --git a/src/gui/PasswordEdit.cpp b/src/gui/PasswordEdit.cpp index 33d022176..02067ccc4 100644 --- a/src/gui/PasswordEdit.cpp +++ b/src/gui/PasswordEdit.cpp @@ -98,7 +98,7 @@ void PasswordEdit::updateStylesheet() setStyleSheet(stylesheet); } -void PasswordEdit::autocompletePassword(QString password) +void PasswordEdit::autocompletePassword(const QString& password) { if (config()->get("security/passwordsrepeat").toBool() && echoMode() == QLineEdit::Normal) { setText(password); diff --git a/src/gui/PasswordEdit.h b/src/gui/PasswordEdit.h index 5976347e6..222376d09 100644 --- a/src/gui/PasswordEdit.h +++ b/src/gui/PasswordEdit.h @@ -41,7 +41,7 @@ signals: private slots: void updateStylesheet(); - void autocompletePassword(QString password); + void autocompletePassword(const QString& password); private: bool passwordsEqual() const; diff --git a/src/gui/csvImport/CsvImportWidget.cpp b/src/gui/csvImport/CsvImportWidget.cpp index 4cb219a77..3b623f73d 100644 --- a/src/gui/csvImport/CsvImportWidget.cpp +++ b/src/gui/csvImport/CsvImportWidget.cpp @@ -315,7 +315,7 @@ void CsvImportWidget::setRootGroup() m_db->rootGroup()->setName("Root"); } -Group* CsvImportWidget::splitGroups(QString label) +Group* CsvImportWidget::splitGroups(const QString& label) { // extract group names from nested path provided in "label" Group* current = m_db->rootGroup(); @@ -345,7 +345,7 @@ Group* CsvImportWidget::splitGroups(QString label) return current; } -Group* CsvImportWidget::hasChildren(Group* current, QString groupName) +Group* CsvImportWidget::hasChildren(Group* current, const QString& groupName) { // returns the group whose name is "groupName" and is child of "current" group for (Group* group : current->children()) { diff --git a/src/gui/csvImport/CsvImportWidget.h b/src/gui/csvImport/CsvImportWidget.h index cd13836f0..a5807eefd 100644 --- a/src/gui/csvImport/CsvImportWidget.h +++ b/src/gui/csvImport/CsvImportWidget.h @@ -68,8 +68,8 @@ private: QStringList m_fieldSeparatorList; void configParser(); void updateTableview(); - Group* splitGroups(QString label); - Group* hasChildren(Group* current, QString groupName); + Group* splitGroups(const QString& label); + Group* hasChildren(Group* current, const QString& groupName); QString formatStatusText() const; }; diff --git a/src/gui/entry/AutoTypeMatchModel.cpp b/src/gui/entry/AutoTypeMatchModel.cpp index 1a6a6ba3b..197b3cd96 100644 --- a/src/gui/entry/AutoTypeMatchModel.cpp +++ b/src/gui/entry/AutoTypeMatchModel.cpp @@ -37,7 +37,7 @@ AutoTypeMatch AutoTypeMatchModel::matchFromIndex(const QModelIndex& index) const return m_matches.at(index.row()); } -QModelIndex AutoTypeMatchModel::indexFromMatch(AutoTypeMatch match) const +QModelIndex AutoTypeMatchModel::indexFromMatch(const AutoTypeMatch& match) const { int row = m_matches.indexOf(match); Q_ASSERT(row != -1); diff --git a/src/gui/entry/AutoTypeMatchModel.h b/src/gui/entry/AutoTypeMatchModel.h index 791dbc3df..58b89465b 100644 --- a/src/gui/entry/AutoTypeMatchModel.h +++ b/src/gui/entry/AutoTypeMatchModel.h @@ -41,7 +41,7 @@ public: explicit AutoTypeMatchModel(QObject* parent = nullptr); AutoTypeMatch matchFromIndex(const QModelIndex& index) const; - QModelIndex indexFromMatch(AutoTypeMatch match) const; + QModelIndex indexFromMatch(const AutoTypeMatch& match) const; int rowCount(const QModelIndex& parent = QModelIndex()) const override; int columnCount(const QModelIndex& parent = QModelIndex()) const override; diff --git a/src/gui/entry/AutoTypeMatchView.cpp b/src/gui/entry/AutoTypeMatchView.cpp index 2750082d8..0eb257237 100644 --- a/src/gui/entry/AutoTypeMatchView.cpp +++ b/src/gui/entry/AutoTypeMatchView.cpp @@ -98,7 +98,7 @@ AutoTypeMatch AutoTypeMatchView::currentMatch() return AutoTypeMatch(); } -void AutoTypeMatchView::setCurrentMatch(AutoTypeMatch match) +void AutoTypeMatchView::setCurrentMatch(const AutoTypeMatch& match) { selectionModel()->setCurrentIndex(m_sortModel->mapFromSource(m_model->indexFromMatch(match)), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); diff --git a/src/gui/entry/AutoTypeMatchView.h b/src/gui/entry/AutoTypeMatchView.h index 14ad9ea2a..b9f3f3aa5 100644 --- a/src/gui/entry/AutoTypeMatchView.h +++ b/src/gui/entry/AutoTypeMatchView.h @@ -34,7 +34,7 @@ class AutoTypeMatchView : public QTreeView public: explicit AutoTypeMatchView(QWidget* parent = nullptr); AutoTypeMatch currentMatch(); - void setCurrentMatch(AutoTypeMatch match); + void setCurrentMatch(const AutoTypeMatch& match); AutoTypeMatch matchFromIndex(const QModelIndex& index); void setMatchList(const QList& matches); void setFirstMatchActive(); diff --git a/src/gui/entry/EntryHistoryModel.cpp b/src/gui/entry/EntryHistoryModel.cpp index aaec3de62..2506e06d7 100644 --- a/src/gui/entry/EntryHistoryModel.cpp +++ b/src/gui/entry/EntryHistoryModel.cpp @@ -54,7 +54,7 @@ QVariant EntryHistoryModel::data(const QModelIndex& index, int role) const if (role == Qt::DisplayRole || role == Qt::UserRole) { Entry* entry = entryFromIndex(index); - TimeInfo timeInfo = entry->timeInfo(); + const TimeInfo& timeInfo = entry->timeInfo(); QDateTime lastModificationLocalTime = timeInfo.lastModificationTime().toLocalTime(); switch (index.column()) { case 0: diff --git a/src/keys/CompositeKey.cpp b/src/keys/CompositeKey.cpp index 4fca7d320..10e86318b 100644 --- a/src/keys/CompositeKey.cpp +++ b/src/keys/CompositeKey.cpp @@ -153,7 +153,7 @@ bool CompositeKey::challenge(const QByteArray& seed, QByteArray& result) const * * @param key the key */ -void CompositeKey::addKey(QSharedPointer key) +void CompositeKey::addKey(const QSharedPointer& key) { m_keys.append(key); } @@ -173,7 +173,7 @@ const QList>& CompositeKey::keys() const * * @param key the key */ -void CompositeKey::addChallengeResponseKey(QSharedPointer key) +void CompositeKey::addChallengeResponseKey(const QSharedPointer& key) { m_challengeResponseKeys.append(key); } diff --git a/src/keys/CompositeKey.h b/src/keys/CompositeKey.h index 43c624acb..f32f3a1a1 100644 --- a/src/keys/CompositeKey.h +++ b/src/keys/CompositeKey.h @@ -42,10 +42,10 @@ public: Q_REQUIRED_RESULT bool transform(const Kdf& kdf, QByteArray& result) const; bool challenge(const QByteArray& seed, QByteArray& result) const; - void addKey(QSharedPointer key); + void addKey(const QSharedPointer& key); const QList>& keys() const; - void addChallengeResponseKey(QSharedPointer key);\ + void addChallengeResponseKey(const QSharedPointer& key);\ const QList>& challengeResponseKeys() const; private: diff --git a/src/streams/HmacBlockStream.cpp b/src/streams/HmacBlockStream.cpp index 780db98c1..01d9ba7cd 100644 --- a/src/streams/HmacBlockStream.cpp +++ b/src/streams/HmacBlockStream.cpp @@ -245,7 +245,7 @@ QByteArray HmacBlockStream::getCurrentHmacKey() const return getHmacKey(m_blockIndex, m_key); } -QByteArray HmacBlockStream::getHmacKey(quint64 blockIndex, QByteArray key) +QByteArray HmacBlockStream::getHmacKey(quint64 blockIndex, const QByteArray& key) { Q_ASSERT(key.size() == 64); QByteArray indexBytes = Endian::sizedIntToBytes(blockIndex, ByteOrder); diff --git a/src/streams/HmacBlockStream.h b/src/streams/HmacBlockStream.h index c10c96746..a2ad062e3 100644 --- a/src/streams/HmacBlockStream.h +++ b/src/streams/HmacBlockStream.h @@ -34,7 +34,7 @@ public: bool reset() override; void close() override; - static QByteArray getHmacKey(quint64 blockIndex, QByteArray key); + static QByteArray getHmacKey(quint64 blockIndex, const QByteArray& key); bool atEnd() const override; diff --git a/src/totp/totp.cpp b/src/totp/totp.cpp index bc66fffa4..f1146441a 100644 --- a/src/totp/totp.cpp +++ b/src/totp/totp.cpp @@ -97,7 +97,7 @@ QSharedPointer Totp::createSettings(const QString& key, const ui }); } -QString Totp::writeSettings(const QSharedPointer settings, const QString& title, const QString& username, bool forceOtp) +QString Totp::writeSettings(const QSharedPointer& settings, const QString& title, const QString& username, bool forceOtp) { if (settings.isNull()) { return {}; @@ -127,7 +127,7 @@ QString Totp::writeSettings(const QSharedPointer settings, const return QString("%1;%2").arg(settings->step).arg(settings->digits); } -QString Totp::generateTotp(const QSharedPointer settings, const quint64 time) +QString Totp::generateTotp(const QSharedPointer& settings, const quint64 time) { Q_ASSERT(!settings.isNull()); if (settings.isNull()) { @@ -194,7 +194,7 @@ Totp::Encoder& Totp::steamEncoder() return getEncoderByShortName("S"); } -Totp::Encoder& Totp::getEncoderByShortName(QString shortName) +Totp::Encoder& Totp::getEncoderByShortName(const QString& shortName) { for (auto& encoder : encoders) { if (encoder.shortName == shortName) { @@ -204,7 +204,7 @@ Totp::Encoder& Totp::getEncoderByShortName(QString shortName) return defaultEncoder(); } -Totp::Encoder& Totp::getEncoderByName(QString name) +Totp::Encoder& Totp::getEncoderByName(const QString& name) { for (auto& encoder : encoders) { if (encoder.name == name) { diff --git a/src/totp/totp.h b/src/totp/totp.h index ba11ba2b0..0697281bf 100644 --- a/src/totp/totp.h +++ b/src/totp/totp.h @@ -60,15 +60,15 @@ static const QString ATTRIBUTE_SETTINGS = "TOTP Settings"; QSharedPointer parseSettings(const QString& rawSettings, const QString& key = {}); QSharedPointer createSettings(const QString& key, const uint digits, const uint step, const QString& encoderShortName = {}); -QString writeSettings(const QSharedPointer settings, const QString& title = {}, +QString writeSettings(const QSharedPointer& settings, const QString& title = {}, const QString& username = {}, bool forceOtp = false); -QString generateTotp(const QSharedPointer settings, const quint64 time = 0ull); +QString generateTotp(const QSharedPointer& settings, const quint64 time = 0ull); Encoder& defaultEncoder(); Encoder& steamEncoder(); -Encoder& getEncoderByShortName(QString shortName); -Encoder& getEncoderByName(QString name); +Encoder& getEncoderByShortName(const QString& shortName); +Encoder& getEncoderByName(const QString& name); } #endif // QTOTP_H From 7208635502a21e565b1b613504709e1d161a39a0 Mon Sep 17 00:00:00 2001 From: Gianluca Recchia Date: Sun, 28 Oct 2018 14:29:57 +0100 Subject: [PATCH 09/13] Enhance readability when accessing static members The sole purpose of a few objects was calling a static member of the class they belonged to. This is not needed, as you can access a static member with the :: notation. --- src/autotype/AutoType.cpp | 3 +-- src/gui/entry/EditEntryWidget.cpp | 3 +-- src/sshagent/BinaryStream.cpp | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/autotype/AutoType.cpp b/src/autotype/AutoType.cpp index c2c16bc75..eee93c52c 100644 --- a/src/autotype/AutoType.cpp +++ b/src/autotype/AutoType.cpp @@ -731,8 +731,7 @@ bool AutoType::checkHighRepetition(const QString& string) bool AutoType::verifyAutoTypeSyntax(const QString& sequence) { if (!AutoType::checkSyntax(sequence)) { - QMessageBox messageBox; - messageBox.critical(nullptr, tr("Auto-Type"), tr("The Syntax of your Auto-Type statement is incorrect!")); + QMessageBox::critical(nullptr, tr("Auto-Type"), tr("The Syntax of your Auto-Type statement is incorrect!")); return false; } else if (AutoType::checkHighDelay(sequence)) { QMessageBox::StandardButton reply; diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp index e8a450026..26bb419ce 100644 --- a/src/gui/entry/EditEntryWidget.cpp +++ b/src/gui/entry/EditEntryWidget.cpp @@ -1311,8 +1311,7 @@ void EditEntryWidget::pickColor() oldColor = QColor(m_advancedUi->bgColorButton->property("color").toString()); } - QColorDialog colorDialog(this); - QColor newColor = colorDialog.getColor(oldColor); + QColor newColor = QColorDialog::getColor(oldColor); if (newColor.isValid()) { setupColorButton(isForeground, newColor); setUnsavedChanges(true); diff --git a/src/sshagent/BinaryStream.cpp b/src/sshagent/BinaryStream.cpp index 2aa8ac1c7..2af04cee5 100644 --- a/src/sshagent/BinaryStream.cpp +++ b/src/sshagent/BinaryStream.cpp @@ -151,7 +151,7 @@ bool BinaryStream::readString(QString& str) return false; } - str = str.fromLatin1(ba); + str = QString::fromLatin1(ba); return true; } From 896a66e6d815e9122d5f26831a193226076feb9e Mon Sep 17 00:00:00 2001 From: Gianluca Recchia Date: Sun, 28 Oct 2018 15:47:24 +0100 Subject: [PATCH 10/13] Improve readability and type-safety Use nullptr instead of 0 or NULL to initialize a null pointer. In some cases, readability was enhanced by replacing 0 with more meaningful values according to the type of the pointer being initialized. --- src/autotype/AutoType.cpp | 2 +- src/autotype/ShortcutWidget.cpp | 4 ++-- src/autotype/xcb/AutoTypeXCB.cpp | 6 +++--- src/browser/BrowserEntryConfig.h | 2 +- src/browser/BrowserService.cpp | 6 +++--- src/browser/HostInstaller.cpp | 2 +- src/browser/NativeMessagingHost.h | 2 +- src/core/PasswordGenerator.cpp | 6 +++--- src/core/ScreenLockListenerPrivate.h | 4 ++-- src/core/ScreenLockListenerWin.h | 2 +- src/crypto/Crypto.cpp | 2 +- src/gui/CategoryListWidget.h | 4 ++-- src/gui/DatabaseOpenWidget.cpp | 2 +- src/gui/DatabaseTabWidget.cpp | 4 ++-- src/gui/KMessageWidget.cpp | 4 ++-- src/gui/MessageWidget.h | 2 +- src/gui/SearchWidget.h | 4 ++-- src/gui/entry/EditEntryWidget.cpp | 12 ++++++------ src/gui/entry/EditEntryWidget_p.h | 2 +- src/gui/entry/EntryModel.cpp | 2 +- src/keys/drivers/YubiKey.cpp | 16 ++++++++-------- src/streams/qtiocompressor.cpp | 4 ++-- 22 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/autotype/AutoType.cpp b/src/autotype/AutoType.cpp index eee93c52c..9d6b75557 100644 --- a/src/autotype/AutoType.cpp +++ b/src/autotype/AutoType.cpp @@ -43,7 +43,7 @@ AutoType::AutoType(QObject* parent, bool test) : QObject(parent) , m_autoTypeDelay(0) , m_currentGlobalKey(static_cast(0)) - , m_currentGlobalModifiers(0) + , m_currentGlobalModifiers(nullptr) , m_pluginLoader(new QPluginLoader(this)) , m_plugin(nullptr) , m_executor(nullptr) diff --git a/src/autotype/ShortcutWidget.cpp b/src/autotype/ShortcutWidget.cpp index 95174e430..3dcc669d9 100644 --- a/src/autotype/ShortcutWidget.cpp +++ b/src/autotype/ShortcutWidget.cpp @@ -24,7 +24,7 @@ ShortcutWidget::ShortcutWidget(QWidget* parent) : QLineEdit(parent) , m_key(static_cast(0)) - , m_modifiers(0) + , m_modifiers(nullptr) , m_locked(false) { setReadOnly(true); @@ -58,7 +58,7 @@ void ShortcutWidget::setShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers) void ShortcutWidget::resetShortcut() { m_key = static_cast(0); - m_modifiers = 0; + m_modifiers = nullptr; m_locked = false; autoType()->unregisterGlobalShortcut(); } diff --git a/src/autotype/xcb/AutoTypeXCB.cpp b/src/autotype/xcb/AutoTypeXCB.cpp index d2030b771..5198468cf 100644 --- a/src/autotype/xcb/AutoTypeXCB.cpp +++ b/src/autotype/xcb/AutoTypeXCB.cpp @@ -50,7 +50,7 @@ AutoTypePlatformX11::AutoTypePlatformX11() << "xfce4-panel"; // Xfce 4 m_currentGlobalKey = static_cast(0); - m_currentGlobalModifiers = 0; + m_currentGlobalModifiers = nullptr; m_keysymTable = nullptr; m_xkb = nullptr; @@ -197,7 +197,7 @@ void AutoTypePlatformX11::unregisterGlobalShortcut(Qt::Key key, Qt::KeyboardModi XUngrabKey(m_dpy, keycode, nativeModifiers | Mod2Mask | LockMask, m_rootWindow); m_currentGlobalKey = static_cast(0); - m_currentGlobalModifiers = 0; + m_currentGlobalModifiers = nullptr; m_currentGlobalKeycode = 0; m_currentGlobalNativeModifiers = 0; } @@ -496,7 +496,7 @@ void AutoTypePlatformX11::updateKeymap() m_xkb = getKeyboard(); XDisplayKeycodes(m_dpy, &m_minKeycode, &m_maxKeycode); - if (m_keysymTable != NULL) + if (m_keysymTable != nullptr) XFree(m_keysymTable); m_keysymTable = XGetKeyboardMapping(m_dpy, m_minKeycode, m_maxKeycode - m_minKeycode + 1, &m_keysymPerKeycode); diff --git a/src/browser/BrowserEntryConfig.h b/src/browser/BrowserEntryConfig.h index 3b808b7e0..f1363f421 100644 --- a/src/browser/BrowserEntryConfig.h +++ b/src/browser/BrowserEntryConfig.h @@ -35,7 +35,7 @@ class BrowserEntryConfig : public QObject Q_PROPERTY(QString Realm READ realm WRITE setRealm) public: - BrowserEntryConfig(QObject* object = 0); + BrowserEntryConfig(QObject* object = nullptr); bool load(const Entry* entry); void save(Entry* entry); diff --git a/src/browser/BrowserService.cpp b/src/browser/BrowserService.cpp index 824cc94b6..8128ee14f 100644 --- a/src/browser/BrowserService.cpp +++ b/src/browser/BrowserService.cpp @@ -481,16 +481,16 @@ void BrowserService::convertAttributesToCustomData(Database *currentDb) progress.reset(); if (counter > 0) { - QMessageBox::information(0, tr("KeePassXC: Converted KeePassHTTP attributes"), + QMessageBox::information(nullptr, tr("KeePassXC: Converted KeePassHTTP attributes"), tr("Successfully converted attributes from %1 entry(s).\n" "Moved %2 keys to custom data.", "").arg(counter).arg(keyCounter), QMessageBox::Ok); } else if (counter == 0 && keyCounter > 0) { - QMessageBox::information(0, tr("KeePassXC: Converted KeePassHTTP attributes"), + QMessageBox::information(nullptr, tr("KeePassXC: Converted KeePassHTTP attributes"), tr("Successfully moved %n keys to custom data.", "", keyCounter), QMessageBox::Ok); } else { - QMessageBox::information(0, tr("KeePassXC: No entry with KeePassHTTP attributes found!"), + QMessageBox::information(nullptr, tr("KeePassXC: No entry with KeePassHTTP attributes found!"), tr("The active database does not contain an entry with KeePassHTTP attributes."), QMessageBox::Ok); } diff --git a/src/browser/HostInstaller.cpp b/src/browser/HostInstaller.cpp index a3ad608d4..f4585febe 100644 --- a/src/browser/HostInstaller.cpp +++ b/src/browser/HostInstaller.cpp @@ -111,7 +111,7 @@ void HostInstaller::installBrowser(SupportedBrowsers browser, // Always create the script file QJsonObject script = constructFile(browser, proxy, location); if (!saveFile(browser, script)) { - QMessageBox::critical(0, + QMessageBox::critical(nullptr, tr("KeePassXC: Cannot save file!"), tr("Cannot save the native messaging script file."), QMessageBox::Ok); diff --git a/src/browser/NativeMessagingHost.h b/src/browser/NativeMessagingHost.h index 869af9e24..da9ac5346 100644 --- a/src/browser/NativeMessagingHost.h +++ b/src/browser/NativeMessagingHost.h @@ -31,7 +31,7 @@ class NativeMessagingHost : public NativeMessagingBase typedef QList SocketList; public: - explicit NativeMessagingHost(DatabaseTabWidget* parent = 0, const bool enabled = false); + explicit NativeMessagingHost(DatabaseTabWidget* parent = nullptr, const bool enabled = false); ~NativeMessagingHost(); int init(); void run(); diff --git a/src/core/PasswordGenerator.cpp b/src/core/PasswordGenerator.cpp index 124b99896..69a0dfb3e 100644 --- a/src/core/PasswordGenerator.cpp +++ b/src/core/PasswordGenerator.cpp @@ -25,15 +25,15 @@ const char* PasswordGenerator::DefaultExcludedChars = ""; PasswordGenerator::PasswordGenerator() : m_length(0) - , m_classes(0) - , m_flags(0) + , m_classes(nullptr) + , m_flags(nullptr) , m_excluded(PasswordGenerator::DefaultExcludedChars) { } double PasswordGenerator::calculateEntropy(const QString& password) { - return ZxcvbnMatch(password.toLatin1(), 0, 0); + return ZxcvbnMatch(password.toLatin1(), nullptr, nullptr); } void PasswordGenerator::setLength(int length) diff --git a/src/core/ScreenLockListenerPrivate.h b/src/core/ScreenLockListenerPrivate.h index 8ecad17d8..a7c080687 100644 --- a/src/core/ScreenLockListenerPrivate.h +++ b/src/core/ScreenLockListenerPrivate.h @@ -24,10 +24,10 @@ class ScreenLockListenerPrivate : public QObject { Q_OBJECT public: - static ScreenLockListenerPrivate* instance(QWidget* parent = 0); + static ScreenLockListenerPrivate* instance(QWidget* parent = nullptr); protected: - ScreenLockListenerPrivate(QWidget* parent = 0); + ScreenLockListenerPrivate(QWidget* parent = nullptr); signals: void screenLocked(); diff --git a/src/core/ScreenLockListenerWin.h b/src/core/ScreenLockListenerWin.h index 0778c99d8..523ae5d0b 100644 --- a/src/core/ScreenLockListenerWin.h +++ b/src/core/ScreenLockListenerWin.h @@ -27,7 +27,7 @@ class ScreenLockListenerWin : public ScreenLockListenerPrivate, public QAbstract { Q_OBJECT public: - explicit ScreenLockListenerWin(QWidget* parent = 0); + explicit ScreenLockListenerWin(QWidget* parent = nullptr); ~ScreenLockListenerWin(); virtual bool nativeEventFilter(const QByteArray& eventType, void* message, long*) override; diff --git a/src/crypto/Crypto.cpp b/src/crypto/Crypto.cpp index 0ed6f003a..fffcddfbd 100644 --- a/src/crypto/Crypto.cpp +++ b/src/crypto/Crypto.cpp @@ -336,4 +336,4 @@ bool Crypto::testChaCha20() } return true; -} \ No newline at end of file +} diff --git a/src/gui/CategoryListWidget.h b/src/gui/CategoryListWidget.h index 3f08fe384..7873a3d3e 100644 --- a/src/gui/CategoryListWidget.h +++ b/src/gui/CategoryListWidget.h @@ -35,7 +35,7 @@ class CategoryListWidget : public QWidget Q_OBJECT public: - CategoryListWidget(QWidget* parent = 0); + CategoryListWidget(QWidget* parent = nullptr); ~CategoryListWidget(); int currentCategory(); @@ -90,4 +90,4 @@ private: Q_DISABLE_COPY(CategoryListWidgetDelegate) }; -#endif \ No newline at end of file +#endif diff --git a/src/gui/DatabaseOpenWidget.cpp b/src/gui/DatabaseOpenWidget.cpp index 892c41d3e..4d906db35 100644 --- a/src/gui/DatabaseOpenWidget.cpp +++ b/src/gui/DatabaseOpenWidget.cpp @@ -122,7 +122,7 @@ void DatabaseOpenWidget::hideEvent(QHideEvent* event) #ifdef WITH_XC_YUBIKEY // Don't listen to any Yubikey events if we are hidden - disconnect(YubiKey::instance(), 0, this, 0); + disconnect(YubiKey::instance(), nullptr, this, nullptr); m_yubiKeyBeingPolled = false; #endif } diff --git a/src/gui/DatabaseTabWidget.cpp b/src/gui/DatabaseTabWidget.cpp index dd36ddae4..b502c116b 100644 --- a/src/gui/DatabaseTabWidget.cpp +++ b/src/gui/DatabaseTabWidget.cpp @@ -419,7 +419,7 @@ bool DatabaseTabWidget::saveDatabaseAs(Database* db) oldFilePath, tr("KeePass 2 Database").append(" (*.kdbx)"), nullptr, - 0, + nullptr, "kdbx"); if (!newFilePath.isEmpty()) { // Ensure we don't recurse back into this function @@ -488,7 +488,7 @@ void DatabaseTabWidget::exportToCsv() } QString fileName = fileDialog()->getSaveFileName( - this, tr("Export database to CSV file"), QString(), tr("CSV file").append(" (*.csv)"), nullptr, 0, "csv"); + this, tr("Export database to CSV file"), QString(), tr("CSV file").append(" (*.csv)"), nullptr, nullptr, "csv"); if (fileName.isEmpty()) { return; } diff --git a/src/gui/KMessageWidget.cpp b/src/gui/KMessageWidget.cpp index 2e68975e3..3de1a15b6 100644 --- a/src/gui/KMessageWidget.cpp +++ b/src/gui/KMessageWidget.cpp @@ -411,7 +411,7 @@ void KMessageWidget::removeAction(QAction *action) void KMessageWidget::animatedShow() { - if (!style()->styleHint(QStyle::SH_Widget_Animate, 0, this)) { + if (!style()->styleHint(QStyle::SH_Widget_Animate, nullptr, this)) { show(); emit showAnimationFinished(); return; @@ -436,7 +436,7 @@ void KMessageWidget::animatedShow() void KMessageWidget::animatedHide() { - if (!style()->styleHint(QStyle::SH_Widget_Animate, 0, this)) { + if (!style()->styleHint(QStyle::SH_Widget_Animate, nullptr, this)) { hide(); emit hideAnimationFinished(); return; diff --git a/src/gui/MessageWidget.h b/src/gui/MessageWidget.h index 73f0b2108..eac506014 100644 --- a/src/gui/MessageWidget.h +++ b/src/gui/MessageWidget.h @@ -28,7 +28,7 @@ class MessageWidget : public KMessageWidget Q_OBJECT public: - explicit MessageWidget(QWidget* parent = 0); + explicit MessageWidget(QWidget* parent = nullptr); int autoHideTimeout() const; diff --git a/src/gui/SearchWidget.h b/src/gui/SearchWidget.h index 1d95c664b..0ec3287c1 100644 --- a/src/gui/SearchWidget.h +++ b/src/gui/SearchWidget.h @@ -35,7 +35,7 @@ class SearchWidget : public QWidget Q_OBJECT public: - explicit SearchWidget(QWidget* parent = 0); + explicit SearchWidget(QWidget* parent = nullptr); ~SearchWidget(); void connectSignals(SignalMultiplexer& mx); @@ -55,7 +55,7 @@ signals: void enterPressed(); public slots: - void databaseChanged(DatabaseWidget* dbWidget = 0); + void databaseChanged(DatabaseWidget* dbWidget = nullptr); private slots: void startSearchTimer(); diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp index 26bb419ce..49c19280a 100644 --- a/src/gui/entry/EditEntryWidget.cpp +++ b/src/gui/entry/EditEntryWidget.cpp @@ -1269,13 +1269,13 @@ QMenu* EditEntryWidget::createPresetsMenu() QMenu* expirePresetsMenu = new QMenu(this); expirePresetsMenu->addAction(tr("Tomorrow"))->setData(QVariant::fromValue(TimeDelta::fromDays(1))); expirePresetsMenu->addSeparator(); - expirePresetsMenu->addAction(tr("%n week(s)", 0, 1))->setData(QVariant::fromValue(TimeDelta::fromDays(7))); - expirePresetsMenu->addAction(tr("%n week(s)", 0, 2))->setData(QVariant::fromValue(TimeDelta::fromDays(14))); - expirePresetsMenu->addAction(tr("%n week(s)", 0, 3))->setData(QVariant::fromValue(TimeDelta::fromDays(21))); + expirePresetsMenu->addAction(tr("%n week(s)", nullptr, 1))->setData(QVariant::fromValue(TimeDelta::fromDays(7))); + expirePresetsMenu->addAction(tr("%n week(s)", nullptr, 2))->setData(QVariant::fromValue(TimeDelta::fromDays(14))); + expirePresetsMenu->addAction(tr("%n week(s)", nullptr, 3))->setData(QVariant::fromValue(TimeDelta::fromDays(21))); expirePresetsMenu->addSeparator(); - expirePresetsMenu->addAction(tr("%n month(s)", 0, 1))->setData(QVariant::fromValue(TimeDelta::fromMonths(1))); - expirePresetsMenu->addAction(tr("%n month(s)", 0, 3))->setData(QVariant::fromValue(TimeDelta::fromMonths(3))); - expirePresetsMenu->addAction(tr("%n month(s)", 0, 6))->setData(QVariant::fromValue(TimeDelta::fromMonths(6))); + expirePresetsMenu->addAction(tr("%n month(s)", nullptr, 1))->setData(QVariant::fromValue(TimeDelta::fromMonths(1))); + expirePresetsMenu->addAction(tr("%n month(s)", nullptr, 3))->setData(QVariant::fromValue(TimeDelta::fromMonths(3))); + expirePresetsMenu->addAction(tr("%n month(s)", nullptr, 6))->setData(QVariant::fromValue(TimeDelta::fromMonths(6))); expirePresetsMenu->addSeparator(); expirePresetsMenu->addAction(tr("%n year(s)", 0, 1))->setData(QVariant::fromValue(TimeDelta::fromYears(1))); expirePresetsMenu->addAction(tr("%n year(s)", 0, 2))->setData(QVariant::fromValue(TimeDelta::fromYears(2))); diff --git a/src/gui/entry/EditEntryWidget_p.h b/src/gui/entry/EditEntryWidget_p.h index 0ba01cd51..dd0bac8b8 100644 --- a/src/gui/entry/EditEntryWidget_p.h +++ b/src/gui/entry/EditEntryWidget_p.h @@ -24,7 +24,7 @@ class AttributesListView : public QListView { public: - explicit AttributesListView(QWidget* parent = 0) + explicit AttributesListView(QWidget* parent = nullptr) : QListView(parent) { setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); diff --git a/src/gui/entry/EntryModel.cpp b/src/gui/entry/EntryModel.cpp index fa3db177b..8cbf4bfe4 100644 --- a/src/gui/entry/EntryModel.cpp +++ b/src/gui/entry/EntryModel.cpp @@ -331,7 +331,7 @@ QVariant EntryModel::headerData(int section, Qt::Orientation orientation, int ro Qt::DropActions EntryModel::supportedDropActions() const { - return 0; + return Qt::IgnoreAction; } Qt::DropActions EntryModel::supportedDragActions() const diff --git a/src/keys/drivers/YubiKey.cpp b/src/keys/drivers/YubiKey.cpp index b94916197..b6905fc38 100644 --- a/src/keys/drivers/YubiKey.cpp +++ b/src/keys/drivers/YubiKey.cpp @@ -37,8 +37,8 @@ #define m_ykds (static_cast(m_ykds_void)) YubiKey::YubiKey() - : m_yk_void(NULL) - , m_ykds_void(NULL) + : m_yk_void(nullptr) + , m_ykds_void(nullptr) , m_mutex(QMutex::Recursive) { } @@ -59,7 +59,7 @@ bool YubiKey::init() m_mutex.lock(); // previously initialized - if (m_yk != NULL && m_ykds != NULL) { + if (m_yk != nullptr && m_ykds != nullptr) { if (yk_get_status(m_yk, m_ykds)) { // Still connected @@ -78,15 +78,15 @@ bool YubiKey::init() // TODO: handle multiple attached hardware devices m_yk_void = static_cast(yk_open_first_key()); - if (m_yk == NULL) { + if (m_yk == nullptr) { m_mutex.unlock(); return false; } m_ykds_void = static_cast(ykds_alloc()); - if (m_ykds == NULL) { + if (m_ykds == nullptr) { yk_close_key(m_yk); - m_yk_void = NULL; + m_yk_void = nullptr; m_mutex.unlock(); return false; } @@ -101,12 +101,12 @@ bool YubiKey::deinit() if (m_yk) { yk_close_key(m_yk); - m_yk_void = NULL; + m_yk_void = nullptr; } if (m_ykds) { ykds_free(m_ykds); - m_ykds_void = NULL; + m_ykds_void = nullptr; } m_mutex.unlock(); diff --git a/src/streams/qtiocompressor.cpp b/src/streams/qtiocompressor.cpp index 97955e472..6e3c69ffc 100644 --- a/src/streams/qtiocompressor.cpp +++ b/src/streams/qtiocompressor.cpp @@ -116,7 +116,7 @@ QtIOCompressorPrivate::~QtIOCompressorPrivate() void QtIOCompressorPrivate::flushZlib(int flushMode) { // No input. - zlibStream.next_in = 0; + zlibStream.next_in = nullptr; zlibStream.avail_in = 0; int status; do { @@ -387,7 +387,7 @@ bool QtIOCompressor::open(OpenMode mode) if (read) { d->state = QtIOCompressorPrivate::NotReadFirstByte; d->zlibStream.avail_in = 0; - d->zlibStream.next_in = 0; + d->zlibStream.next_in = nullptr; if (d->streamFormat == QtIOCompressor::ZlibFormat) { status = inflateInit(&d->zlibStream); } else { From 379c41d20c1cb25bfa599efc0ea89ae47d197173 Mon Sep 17 00:00:00 2001 From: Gianluca Recchia Date: Sun, 28 Oct 2018 16:13:58 +0100 Subject: [PATCH 11/13] Reduce unnecessary copies using move semantics --- src/autotype/WildcardMatcher.cpp | 5 +++-- src/autotype/WildcardMatcher.h | 2 +- src/core/AutoTypeMatch.cpp | 4 +++- src/core/Database.cpp | 3 ++- src/core/Entry.cpp | 3 ++- src/format/KdbxXmlReader.cpp | 5 +++-- src/format/KdbxXmlReader.h | 2 +- src/format/KeePass2Reader.cpp | 3 ++- src/gui/csvImport/CsvParserModel.cpp | 4 +++- src/streams/HmacBlockStream.cpp | 6 ++++-- 10 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/autotype/WildcardMatcher.cpp b/src/autotype/WildcardMatcher.cpp index bac785897..6afd10cee 100644 --- a/src/autotype/WildcardMatcher.cpp +++ b/src/autotype/WildcardMatcher.cpp @@ -18,12 +18,13 @@ #include "WildcardMatcher.h" #include +#include const QChar WildcardMatcher::Wildcard = '*'; const Qt::CaseSensitivity WildcardMatcher::Sensitivity = Qt::CaseInsensitive; -WildcardMatcher::WildcardMatcher(const QString& text) - : m_text(text) +WildcardMatcher::WildcardMatcher(QString text) + : m_text(std::move(text)) { } diff --git a/src/autotype/WildcardMatcher.h b/src/autotype/WildcardMatcher.h index 6ef48743b..5be6f5e40 100644 --- a/src/autotype/WildcardMatcher.h +++ b/src/autotype/WildcardMatcher.h @@ -23,7 +23,7 @@ class WildcardMatcher { public: - explicit WildcardMatcher(const QString& text); + explicit WildcardMatcher(QString text); bool match(const QString& pattern); static const QChar Wildcard; diff --git a/src/core/AutoTypeMatch.cpp b/src/core/AutoTypeMatch.cpp index 9b7940f4d..13b037bb6 100644 --- a/src/core/AutoTypeMatch.cpp +++ b/src/core/AutoTypeMatch.cpp @@ -18,6 +18,8 @@ #include "AutoTypeMatch.h" +#include + AutoTypeMatch::AutoTypeMatch() : entry(nullptr) , sequence() @@ -26,7 +28,7 @@ AutoTypeMatch::AutoTypeMatch() AutoTypeMatch::AutoTypeMatch(Entry* entry, QString sequence) : entry(entry) - , sequence(sequence) + , sequence(std::move(sequence)) { } diff --git a/src/core/Database.cpp b/src/core/Database.cpp index 693b9c549..fe9ef600b 100644 --- a/src/core/Database.cpp +++ b/src/core/Database.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include "cli/Utils.h" #include "core/Clock.h" @@ -492,7 +493,7 @@ Database* Database::openDatabaseFile(const QString& fileName, QSharedPointer #include #include +#include const int Entry::DefaultIconNumber = 0; const int Entry::ResolveMaximumDepth = 10; @@ -367,7 +368,7 @@ QString Entry::totp() const void Entry::setTotp(QSharedPointer settings) { beginUpdate(); - m_data.totpSettings = settings; + m_data.totpSettings = std::move(settings); auto text = Totp::writeSettings(m_data.totpSettings, title(), username()); if (m_attributes->hasKey(Totp::ATTRIBUTE_OTP)) { diff --git a/src/format/KdbxXmlReader.cpp b/src/format/KdbxXmlReader.cpp index c9e5c31af..ec556dd85 100644 --- a/src/format/KdbxXmlReader.cpp +++ b/src/format/KdbxXmlReader.cpp @@ -28,6 +28,7 @@ #include #include +#include #define UUID_LENGTH 16 @@ -43,9 +44,9 @@ KdbxXmlReader::KdbxXmlReader(quint32 version) * @param version KDBX version * @param binaryPool binary pool */ -KdbxXmlReader::KdbxXmlReader(quint32 version, const QHash& binaryPool) +KdbxXmlReader::KdbxXmlReader(quint32 version, QHash binaryPool) : m_kdbxVersion(version) - , m_binaryPool(binaryPool) + , m_binaryPool(std::move(binaryPool)) { } diff --git a/src/format/KdbxXmlReader.h b/src/format/KdbxXmlReader.h index 566fbfc7e..4ab82cc0e 100644 --- a/src/format/KdbxXmlReader.h +++ b/src/format/KdbxXmlReader.h @@ -42,7 +42,7 @@ class KdbxXmlReader public: explicit KdbxXmlReader(quint32 version); - explicit KdbxXmlReader(quint32 version, const QHash& binaryPool); + explicit KdbxXmlReader(quint32 version, QHash binaryPool); virtual ~KdbxXmlReader() = default; virtual Database* readDatabase(const QString& filename); diff --git a/src/format/KeePass2Reader.cpp b/src/format/KeePass2Reader.cpp index 8cdb8ff43..f727f274d 100644 --- a/src/format/KeePass2Reader.cpp +++ b/src/format/KeePass2Reader.cpp @@ -21,6 +21,7 @@ #include "format/KeePass1.h" #include +#include /** * Read database from file and detect correct file format. @@ -37,7 +38,7 @@ Database* KeePass2Reader::readDatabase(const QString& filename, QSharedPointer db(readDatabase(&file, key)); + QScopedPointer db(readDatabase(&file, std::move(key))); if (file.error() != QFile::NoError) { raiseError(file.errorString()); diff --git a/src/gui/csvImport/CsvParserModel.cpp b/src/gui/csvImport/CsvParserModel.cpp index 8f7d98ec4..269fbdd62 100644 --- a/src/gui/csvImport/CsvParserModel.cpp +++ b/src/gui/csvImport/CsvParserModel.cpp @@ -18,6 +18,8 @@ #include "CsvParserModel.h" +#include + CsvParserModel::CsvParserModel(QObject* parent) : QAbstractTableModel(parent) , m_skipped(0) @@ -92,7 +94,7 @@ void CsvParserModel::setSkippedRows(int skipped) void CsvParserModel::setHeaderLabels(QStringList l) { - m_columnHeader = l; + m_columnHeader = std::move(l); } int CsvParserModel::rowCount(const QModelIndex& parent) const diff --git a/src/streams/HmacBlockStream.cpp b/src/streams/HmacBlockStream.cpp index 01d9ba7cd..30c7bac5e 100644 --- a/src/streams/HmacBlockStream.cpp +++ b/src/streams/HmacBlockStream.cpp @@ -17,6 +17,8 @@ #include "HmacBlockStream.h" +#include + #include "core/Endian.h" #include "crypto/CryptoHash.h" @@ -25,7 +27,7 @@ const QSysInfo::Endian HmacBlockStream::ByteOrder = QSysInfo::LittleEndian; HmacBlockStream::HmacBlockStream(QIODevice* baseDevice, QByteArray key) : LayeredStream(baseDevice) , m_blockSize(1024 * 1024) - , m_key(key) + , m_key(std::move(key)) { init(); } @@ -33,7 +35,7 @@ HmacBlockStream::HmacBlockStream(QIODevice* baseDevice, QByteArray key) HmacBlockStream::HmacBlockStream(QIODevice* baseDevice, QByteArray key, qint32 blockSize) : LayeredStream(baseDevice) , m_blockSize(blockSize) - , m_key(key) + , m_key(std::move(key)) { init(); } From 0f604aa8c7ce47ce504f5a9d72acd9871802bebd Mon Sep 17 00:00:00 2001 From: Gianluca Recchia Date: Sun, 28 Oct 2018 23:06:27 +0100 Subject: [PATCH 12/13] Normalize signature of SIGNAL() and SLOT() See https://stackoverflow.com/q/18091058/6335279 --- src/autotype/AutoTypeSelectDialog.cpp | 2 +- src/browser/BrowserService.cpp | 36 +++++++++---------- src/core/Group.cpp | 4 +-- src/gui/CategoryListWidget.cpp | 2 +- src/gui/DatabaseOpenWidget.cpp | 2 +- src/gui/DatabaseTabWidget.cpp | 2 +- src/gui/DatabaseWidget.cpp | 8 ++--- src/gui/EditWidgetIcons.cpp | 4 +-- src/gui/EditWidgetProperties.cpp | 2 +- src/gui/MainWindow.cpp | 8 ++--- .../DatabaseSettingsWidgetBrowser.cpp | 2 +- src/gui/entry/AutoTypeMatchView.cpp | 2 +- src/gui/entry/EditEntryWidget.cpp | 36 +++++++++---------- src/gui/entry/EntryAttachmentsWidget.cpp | 2 +- src/gui/entry/EntryAttributesModel.cpp | 4 +-- src/gui/entry/EntryView.cpp | 10 +++--- src/gui/group/EditGroupWidget.cpp | 4 +-- src/gui/group/GroupModel.cpp | 4 +-- src/gui/group/GroupView.cpp | 4 +-- src/gui/masterkey/KeyComponentWidget.cpp | 4 +-- src/gui/masterkey/PasswordEditWidget.cpp | 2 +- src/gui/masterkey/YubiKeyEditWidget.cpp | 2 +- 22 files changed, 73 insertions(+), 73 deletions(-) diff --git a/src/autotype/AutoTypeSelectDialog.cpp b/src/autotype/AutoTypeSelectDialog.cpp index 7178c70f9..fe0ba811e 100644 --- a/src/autotype/AutoTypeSelectDialog.cpp +++ b/src/autotype/AutoTypeSelectDialog.cpp @@ -69,7 +69,7 @@ AutoTypeSelectDialog::AutoTypeSelectDialog(QWidget* parent) connect(m_view, SIGNAL(activated(QModelIndex)), SLOT(emitMatchActivated(QModelIndex))); connect(m_view, SIGNAL(clicked(QModelIndex)), SLOT(emitMatchActivated(QModelIndex))); - connect(m_view->model(), SIGNAL(rowsRemoved(QModelIndex, int, int)), SLOT(matchRemoved())); + connect(m_view->model(), SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(matchRemoved())); connect(m_view, SIGNAL(rejected()), SLOT(reject())); layout->addWidget(m_view); diff --git a/src/browser/BrowserService.cpp b/src/browser/BrowserService.cpp index 8128ee14f..cca76c15f 100644 --- a/src/browser/BrowserService.cpp +++ b/src/browser/BrowserService.cpp @@ -145,7 +145,7 @@ QString BrowserService::storeKey(const QString& key) if (thread() != QThread::currentThread()) { QMetaObject::invokeMethod( - this, "storeKey", Qt::BlockingQueuedConnection, Q_RETURN_ARG(QString, id), Q_ARG(const QString&, key)); + this, "storeKey", Qt::BlockingQueuedConnection, Q_RETURN_ARG(QString, id), Q_ARG(QString, key)); return id; } @@ -213,11 +213,11 @@ QJsonArray BrowserService::findMatchingEntries(const QString& id, "findMatchingEntries", Qt::BlockingQueuedConnection, Q_RETURN_ARG(QJsonArray, result), - Q_ARG(const QString&, id), - Q_ARG(const QString&, url), - Q_ARG(const QString&, submitUrl), - Q_ARG(const QString&, realm), - Q_ARG(const StringPairList&, keyList)); + Q_ARG(QString, id), + Q_ARG(QString, url), + Q_ARG(QString, submitUrl), + Q_ARG(QString, realm), + Q_ARG(StringPairList, keyList)); return result; } @@ -279,12 +279,12 @@ void BrowserService::addEntry(const QString& id, QMetaObject::invokeMethod(this, "addEntry", Qt::BlockingQueuedConnection, - Q_ARG(const QString&, id), - Q_ARG(const QString&, login), - Q_ARG(const QString&, password), - Q_ARG(const QString&, url), - Q_ARG(const QString&, submitUrl), - Q_ARG(const QString&, realm), + Q_ARG(QString, id), + Q_ARG(QString, login), + Q_ARG(QString, password), + Q_ARG(QString, url), + Q_ARG(QString, submitUrl), + Q_ARG(QString, realm), Q_ARG(Database*, selectedDb)); } @@ -332,12 +332,12 @@ void BrowserService::updateEntry(const QString& id, QMetaObject::invokeMethod(this, "updateEntry", Qt::BlockingQueuedConnection, - Q_ARG(const QString&, id), - Q_ARG(const QString&, uuid), - Q_ARG(const QString&, login), - Q_ARG(const QString&, password), - Q_ARG(const QString&, url), - Q_ARG(const QString&, submitUrl)); + Q_ARG(QString, id), + Q_ARG(QString, uuid), + Q_ARG(QString, login), + Q_ARG(QString, password), + Q_ARG(QString, url), + Q_ARG(QString, submitUrl)); } Database* db = selectedDatabase(); diff --git a/src/core/Group.cpp b/src/core/Group.cpp index 4b1d11ab0..fcb8fe8a8 100644 --- a/src/core/Group.cpp +++ b/src/core/Group.cpp @@ -850,9 +850,9 @@ void Group::recSetDatabase(Database* db) connect(this, SIGNAL(dataChanged(Group*)), db, SIGNAL(groupDataChanged(Group*))); connect(this, SIGNAL(aboutToRemove(Group*)), db, SIGNAL(groupAboutToRemove(Group*))); connect(this, SIGNAL(removed()), db, SIGNAL(groupRemoved())); - connect(this, SIGNAL(aboutToAdd(Group*, int)), db, SIGNAL(groupAboutToAdd(Group*, int))); + connect(this, SIGNAL(aboutToAdd(Group*,int)), db, SIGNAL(groupAboutToAdd(Group*,int))); connect(this, SIGNAL(added()), db, SIGNAL(groupAdded())); - connect(this, SIGNAL(aboutToMove(Group*, Group*, int)), db, SIGNAL(groupAboutToMove(Group*, Group*, int))); + connect(this, SIGNAL(aboutToMove(Group*,Group*,int)), db, SIGNAL(groupAboutToMove(Group*,Group*,int))); connect(this, SIGNAL(moved()), db, SIGNAL(groupMoved())); connect(this, SIGNAL(modified()), db, SIGNAL(modifiedImmediate())); } diff --git a/src/gui/CategoryListWidget.cpp b/src/gui/CategoryListWidget.cpp index 14429083b..50b02da81 100644 --- a/src/gui/CategoryListWidget.cpp +++ b/src/gui/CategoryListWidget.cpp @@ -39,7 +39,7 @@ CategoryListWidget::CategoryListWidget(QWidget* parent) connect(m_ui->scrollDown, SIGNAL(clicked()), SLOT(scrollCategoriesDown())); connect(m_ui->categoryList->verticalScrollBar(), SIGNAL(valueChanged(int)), SLOT(updateCategoryScrollButtons())); connect( - m_ui->categoryList->verticalScrollBar(), SIGNAL(rangeChanged(int, int)), SLOT(updateCategoryScrollButtons())); + m_ui->categoryList->verticalScrollBar(), SIGNAL(rangeChanged(int,int)), SLOT(updateCategoryScrollButtons())); } CategoryListWidget::~CategoryListWidget() diff --git a/src/gui/DatabaseOpenWidget.cpp b/src/gui/DatabaseOpenWidget.cpp index 4d906db35..d872ca68d 100644 --- a/src/gui/DatabaseOpenWidget.cpp +++ b/src/gui/DatabaseOpenWidget.cpp @@ -106,7 +106,7 @@ void DatabaseOpenWidget::showEvent(QShowEvent* event) // showEvent() may be called twice, so make sure we are only polling once if (!m_yubiKeyBeingPolled) { connect( - YubiKey::instance(), SIGNAL(detected(int, bool)), SLOT(yubikeyDetected(int, bool)), Qt::QueuedConnection); + YubiKey::instance(), SIGNAL(detected(int,bool)), SLOT(yubikeyDetected(int,bool)), Qt::QueuedConnection); connect(YubiKey::instance(), SIGNAL(detectComplete()), SLOT(yubikeyDetectComplete()), Qt::QueuedConnection); connect(YubiKey::instance(), SIGNAL(notFound()), SLOT(noYubikeyFound()), Qt::QueuedConnection); diff --git a/src/gui/DatabaseTabWidget.cpp b/src/gui/DatabaseTabWidget.cpp index b502c116b..fcd4f954b 100644 --- a/src/gui/DatabaseTabWidget.cpp +++ b/src/gui/DatabaseTabWidget.cpp @@ -693,7 +693,7 @@ void DatabaseTabWidget::insertDatabase(Database* db, const DatabaseManagerStruct setCurrentIndex(index); connectDatabase(db); connect(dbStruct.dbWidget, SIGNAL(closeRequest()), SLOT(closeDatabaseFromSender())); - connect(dbStruct.dbWidget, SIGNAL(databaseChanged(Database*, bool)), SLOT(changeDatabase(Database*, bool))); + connect(dbStruct.dbWidget, SIGNAL(databaseChanged(Database*,bool)), SLOT(changeDatabase(Database*,bool))); connect(dbStruct.dbWidget, SIGNAL(unlockedDatabase()), SLOT(updateTabNameFromDbWidgetSender())); connect(dbStruct.dbWidget, SIGNAL(unlockedDatabase()), SLOT(emitDatabaseUnlockedFromDbWidgetSender())); } diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 7b36f4668..388919952 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -175,14 +175,14 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent) addWidget(m_keepass1OpenWidget); addWidget(m_unlockDatabaseWidget); - connect(m_mainSplitter, SIGNAL(splitterMoved(int, int)), SIGNAL(mainSplitterSizesChanged())); - connect(m_previewSplitter, SIGNAL(splitterMoved(int, int)), SIGNAL(previewSplitterSizesChanged())); + connect(m_mainSplitter, SIGNAL(splitterMoved(int,int)), SIGNAL(mainSplitterSizesChanged())); + connect(m_previewSplitter, SIGNAL(splitterMoved(int,int)), SIGNAL(previewSplitterSizesChanged())); connect(m_entryView, SIGNAL(viewStateChanged()), SIGNAL(entryViewStateChanged())); connect(m_groupView, SIGNAL(groupChanged(Group*)), this, SLOT(onGroupChanged(Group*))); connect(m_groupView, SIGNAL(groupChanged(Group*)), SIGNAL(groupChanged())); connect(m_entryView, - SIGNAL(entryActivated(Entry*, EntryModel::ModelColumn)), - SLOT(entryActivationSignalReceived(Entry*, EntryModel::ModelColumn))); + SIGNAL(entryActivated(Entry*,EntryModel::ModelColumn)), + SLOT(entryActivationSignalReceived(Entry*,EntryModel::ModelColumn))); connect(m_entryView, SIGNAL(entrySelectionChanged()), SIGNAL(entrySelectionChanged())); connect(m_editEntryWidget, SIGNAL(editFinished(bool)), SLOT(switchToView(bool))); connect(m_editEntryWidget, SIGNAL(historyEntryActivated(Entry*)), SLOT(switchToHistoryView(Entry*))); diff --git a/src/gui/EditWidgetIcons.cpp b/src/gui/EditWidgetIcons.cpp index f2c320dc9..e26966df6 100644 --- a/src/gui/EditWidgetIcons.cpp +++ b/src/gui/EditWidgetIcons.cpp @@ -84,11 +84,11 @@ EditWidgetIcons::EditWidgetIcons(QWidget* parent) connect(m_ui->defaultIconsRadio, SIGNAL(toggled(bool)), this, SIGNAL(widgetUpdated())); connect(m_ui->defaultIconsRadio, SIGNAL(toggled(bool)), this, SIGNAL(widgetUpdated())); connect(m_ui->defaultIconsView->selectionModel(), - SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), + SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SIGNAL(widgetUpdated())); connect(m_ui->customIconsView->selectionModel(), - SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), + SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SIGNAL(widgetUpdated())); diff --git a/src/gui/EditWidgetProperties.cpp b/src/gui/EditWidgetProperties.cpp index 93e3b0ae8..b2de9d778 100644 --- a/src/gui/EditWidgetProperties.cpp +++ b/src/gui/EditWidgetProperties.cpp @@ -33,7 +33,7 @@ EditWidgetProperties::EditWidgetProperties(QWidget* parent) m_ui->customDataTable->setModel(m_customDataModel); connect(m_ui->customDataTable->selectionModel(), - SIGNAL(selectionChanged(QItemSelection, QItemSelection)), + SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(toggleRemoveButton(QItemSelection))); connect(m_ui->removeCustomDataButton, SIGNAL(clicked()), SLOT(removeSelectedPluginData())); } diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 8f0c23044..ac26dd879 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -319,14 +319,14 @@ MainWindow::MainWindow() #endif connect(m_ui->tabWidget, - SIGNAL(messageGlobal(QString, MessageWidget::MessageType)), + SIGNAL(messageGlobal(QString,MessageWidget::MessageType)), this, - SLOT(displayGlobalMessage(QString, MessageWidget::MessageType))); + SLOT(displayGlobalMessage(QString,MessageWidget::MessageType))); connect(m_ui->tabWidget, SIGNAL(messageDismissGlobal()), this, SLOT(hideGlobalMessage())); connect(m_ui->tabWidget, - SIGNAL(messageTab(QString, MessageWidget::MessageType)), + SIGNAL(messageTab(QString,MessageWidget::MessageType)), this, - SLOT(displayTabMessage(QString, MessageWidget::MessageType))); + SLOT(displayTabMessage(QString,MessageWidget::MessageType))); connect(m_ui->tabWidget, SIGNAL(messageDismissTab()), this, SLOT(hideTabMessage())); m_screenLockListener = new ScreenLockListener(this); diff --git a/src/gui/dbsettings/DatabaseSettingsWidgetBrowser.cpp b/src/gui/dbsettings/DatabaseSettingsWidgetBrowser.cpp index 0dae1486d..a91744cdb 100644 --- a/src/gui/dbsettings/DatabaseSettingsWidgetBrowser.cpp +++ b/src/gui/dbsettings/DatabaseSettingsWidgetBrowser.cpp @@ -38,7 +38,7 @@ DatabaseSettingsWidgetBrowser::DatabaseSettingsWidgetBrowser(QWidget* parent) m_ui->customDataTable->setModel(m_customDataModel); settingsWarning(); - connect(m_ui->customDataTable->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), + connect(m_ui->customDataTable->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(toggleRemoveButton(QItemSelection))); connect(m_ui->removeCustomDataButton, SIGNAL(clicked()), SLOT(removeSelectedKey())); connect(m_ui->convertToCustomData, SIGNAL(clicked()), this, SLOT(convertAttributesToCustomData())); diff --git a/src/gui/entry/AutoTypeMatchView.cpp b/src/gui/entry/AutoTypeMatchView.cpp index 0eb257237..087f2cc64 100644 --- a/src/gui/entry/AutoTypeMatchView.cpp +++ b/src/gui/entry/AutoTypeMatchView.cpp @@ -44,7 +44,7 @@ AutoTypeMatchView::AutoTypeMatchView(QWidget* parent) connect(this, SIGNAL(doubleClicked(QModelIndex)), SLOT(emitMatchActivated(QModelIndex))); connect( - selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), SIGNAL(matchSelectionChanged())); + selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SIGNAL(matchSelectionChanged())); } void AutoTypeMatchView::keyPressEvent(QKeyEvent* event) diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp index 49c19280a..8a54b23e3 100644 --- a/src/gui/entry/EditEntryWidget.cpp +++ b/src/gui/entry/EditEntryWidget.cpp @@ -103,8 +103,8 @@ EditEntryWidget::EditEntryWidget(QWidget* parent) connect(this, SIGNAL(rejected()), SLOT(cancel())); connect(this, SIGNAL(apply()), SLOT(commitEntry())); connect(m_iconsWidget, - SIGNAL(messageEditEntry(QString, MessageWidget::MessageType)), - SLOT(showMessage(QString, MessageWidget::MessageType))); + SIGNAL(messageEditEntry(QString,MessageWidget::MessageType)), + SLOT(showMessage(QString,MessageWidget::MessageType))); connect(m_iconsWidget, SIGNAL(messageEditEntryDismiss()), SLOT(hideMessage())); m_mainUi->passwordGenerator->layout()->setContentsMargins(0, 0, 0, 0); @@ -161,7 +161,7 @@ void EditEntryWidget::setupAdvanced() connect(m_advancedUi->protectAttributeButton, SIGNAL(toggled(bool)), SLOT(protectCurrentAttribute(bool))); connect(m_advancedUi->revealAttributeButton, SIGNAL(clicked(bool)), SLOT(revealCurrentAttribute())); connect(m_advancedUi->attributesView->selectionModel(), - SIGNAL(currentChanged(QModelIndex, QModelIndex)), + SIGNAL(currentChanged(QModelIndex,QModelIndex)), SLOT(updateCurrentAttribute())); connect(m_advancedUi->fgColorButton, SIGNAL(clicked()), SLOT(pickColor())); connect(m_advancedUi->bgColorButton, SIGNAL(clicked()), SLOT(pickColor())); @@ -192,11 +192,11 @@ void EditEntryWidget::setupAutoType() connect(m_autoTypeUi->assocAddButton, SIGNAL(clicked()), SLOT(insertAutoTypeAssoc())); connect(m_autoTypeUi->assocRemoveButton, SIGNAL(clicked()), SLOT(removeAutoTypeAssoc())); connect(m_autoTypeUi->assocView->selectionModel(), - SIGNAL(currentRowChanged(QModelIndex, QModelIndex)), + SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), SLOT(updateAutoTypeEnabled())); connect(m_autoTypeAssocModel, SIGNAL(modelReset()), SLOT(updateAutoTypeEnabled())); connect(m_autoTypeUi->assocView->selectionModel(), - SIGNAL(currentRowChanged(QModelIndex, QModelIndex)), + SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), SLOT(loadCurrentAssoc(QModelIndex))); connect(m_autoTypeAssocModel, SIGNAL(modelReset()), SLOT(clearCurrentAssoc())); connect(m_autoTypeUi->windowTitleCombo, SIGNAL(editTextChanged(QString)), SLOT(applyCurrentAssoc())); @@ -225,8 +225,8 @@ void EditEntryWidget::setupHistory() connect(m_historyUi->historyView, SIGNAL(activated(QModelIndex)), SLOT(histEntryActivated(QModelIndex))); connect(m_historyUi->historyView->selectionModel(), - SIGNAL(currentChanged(QModelIndex, QModelIndex)), - SLOT(updateHistoryButtons(QModelIndex, QModelIndex))); + SIGNAL(currentChanged(QModelIndex,QModelIndex)), + SLOT(updateHistoryButtons(QModelIndex,QModelIndex))); connect(m_historyUi->showButton, SIGNAL(clicked()), SLOT(showHistoryEntry())); connect(m_historyUi->restoreButton, SIGNAL(clicked()), SLOT(restoreHistoryEntry())); connect(m_historyUi->deleteButton, SIGNAL(clicked()), SLOT(deleteHistoryEntry())); @@ -236,14 +236,14 @@ void EditEntryWidget::setupHistory() void EditEntryWidget::setupEntryUpdate() { // Entry tab - connect(m_mainUi->titleEdit, SIGNAL(textChanged(const QString&)), this, SLOT(setUnsavedChanges())); - connect(m_mainUi->usernameEdit, SIGNAL(textChanged(const QString&)), this, SLOT(setUnsavedChanges())); - connect(m_mainUi->passwordEdit, SIGNAL(textChanged(const QString&)), this, SLOT(setUnsavedChanges())); - connect(m_mainUi->passwordRepeatEdit, SIGNAL(textChanged(const QString&)), this, SLOT(setUnsavedChanges())); - connect(m_mainUi->urlEdit, SIGNAL(textChanged(const QString&)), this, SLOT(setUnsavedChanges())); + connect(m_mainUi->titleEdit, SIGNAL(textChanged(QString)), this, SLOT(setUnsavedChanges())); + connect(m_mainUi->usernameEdit, SIGNAL(textChanged(QString)), this, SLOT(setUnsavedChanges())); + connect(m_mainUi->passwordEdit, SIGNAL(textChanged(QString)), this, SLOT(setUnsavedChanges())); + connect(m_mainUi->passwordRepeatEdit, SIGNAL(textChanged(QString)), this, SLOT(setUnsavedChanges())); + connect(m_mainUi->urlEdit, SIGNAL(textChanged(QString)), this, SLOT(setUnsavedChanges())); connect(m_mainUi->expireCheck, SIGNAL(stateChanged(int)), this, SLOT(setUnsavedChanges())); connect(m_mainUi->notesEnabled, SIGNAL(stateChanged(int)), this, SLOT(setUnsavedChanges())); - connect(m_mainUi->expireDatePicker, SIGNAL(dateTimeChanged(const QDateTime&)), this, SLOT(setUnsavedChanges())); + connect(m_mainUi->expireDatePicker, SIGNAL(dateTimeChanged(QDateTime)), this, SLOT(setUnsavedChanges())); connect(m_mainUi->notesEdit, SIGNAL(textChanged()), this, SLOT(setUnsavedChanges())); // Advanced tab @@ -261,10 +261,10 @@ void EditEntryWidget::setupEntryUpdate() connect(m_autoTypeUi->customWindowSequenceButton, SIGNAL(stateChanged(int)), this, SLOT(setUnsavedChanges())); connect(m_autoTypeUi->inheritSequenceButton, SIGNAL(toggled(bool)), this, SLOT(setUnsavedChanges())); connect(m_autoTypeUi->customSequenceButton, SIGNAL(toggled(bool)), this, SLOT(setUnsavedChanges())); - connect(m_autoTypeUi->windowSequenceEdit, SIGNAL(textChanged(const QString&)), this, SLOT(setUnsavedChanges())); - connect(m_autoTypeUi->sequenceEdit, SIGNAL(textChanged(const QString&)), this, SLOT(setUnsavedChanges())); + connect(m_autoTypeUi->windowSequenceEdit, SIGNAL(textChanged(QString)), this, SLOT(setUnsavedChanges())); + connect(m_autoTypeUi->sequenceEdit, SIGNAL(textChanged(QString)), this, SLOT(setUnsavedChanges())); connect(m_autoTypeUi->windowTitleCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setUnsavedChanges())); - connect(m_autoTypeUi->windowTitleCombo, SIGNAL(editTextChanged(const QString&)), this, SLOT(setUnsavedChanges())); + connect(m_autoTypeUi->windowTitleCombo, SIGNAL(editTextChanged(QString)), this, SLOT(setUnsavedChanges())); // Properties and History tabs don't need extra connections @@ -275,8 +275,8 @@ void EditEntryWidget::setupEntryUpdate() connect(m_sshAgentUi->externalFileRadioButton, SIGNAL(toggled(bool)), this, SLOT(setUnsavedChanges())); connect(m_sshAgentUi->attachmentComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setUnsavedChanges())); connect( - m_sshAgentUi->attachmentComboBox, SIGNAL(editTextChanged(const QString&)), this, SLOT(setUnsavedChanges())); - connect(m_sshAgentUi->externalFileEdit, SIGNAL(textChanged(const QString&)), this, SLOT(setUnsavedChanges())); + m_sshAgentUi->attachmentComboBox, SIGNAL(editTextChanged(QString)), this, SLOT(setUnsavedChanges())); + connect(m_sshAgentUi->externalFileEdit, SIGNAL(textChanged(QString)), this, SLOT(setUnsavedChanges())); connect(m_sshAgentUi->addKeyToAgentCheckBox, SIGNAL(stateChanged(int)), this, SLOT(setUnsavedChanges())); connect(m_sshAgentUi->removeKeyFromAgentCheckBox, SIGNAL(stateChanged(int)), this, SLOT(setUnsavedChanges())); connect( diff --git a/src/gui/entry/EntryAttachmentsWidget.cpp b/src/gui/entry/EntryAttachmentsWidget.cpp index c1897d898..6f42a1994 100644 --- a/src/gui/entry/EntryAttachmentsWidget.cpp +++ b/src/gui/entry/EntryAttachmentsWidget.cpp @@ -44,7 +44,7 @@ EntryAttachmentsWidget::EntryAttachmentsWidget(QWidget* parent) connect(this, SIGNAL(readOnlyChanged(bool)), SLOT(updateButtonsEnabled())); connect(m_attachmentsModel, SIGNAL(modelReset()), SLOT(updateButtonsEnabled())); connect(m_ui->attachmentsView->selectionModel(), - SIGNAL(selectionChanged(QItemSelection, QItemSelection)), + SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(updateButtonsEnabled())); connect(m_ui->attachmentsView, SIGNAL(doubleClicked(QModelIndex)), SLOT(openAttachment(QModelIndex))); diff --git a/src/gui/entry/EntryAttributesModel.cpp b/src/gui/entry/EntryAttributesModel.cpp index ddb31d624..373fcc6c7 100644 --- a/src/gui/entry/EntryAttributesModel.cpp +++ b/src/gui/entry/EntryAttributesModel.cpp @@ -47,8 +47,8 @@ void EntryAttributesModel::setEntryAttributes(EntryAttributes* entryAttributes) connect(m_entryAttributes, SIGNAL(aboutToBeRemoved(QString)), SLOT(attributeAboutToRemove(QString))); connect(m_entryAttributes, SIGNAL(removed(QString)), SLOT(attributeRemove())); connect( - m_entryAttributes, SIGNAL(aboutToRename(QString, QString)), SLOT(attributeAboutToRename(QString, QString))); - connect(m_entryAttributes, SIGNAL(renamed(QString, QString)), SLOT(attributeRename(QString, QString))); + m_entryAttributes, SIGNAL(aboutToRename(QString,QString)), SLOT(attributeAboutToRename(QString,QString))); + connect(m_entryAttributes, SIGNAL(renamed(QString,QString)), SLOT(attributeRename(QString,QString))); connect(m_entryAttributes, SIGNAL(aboutToBeReset()), SLOT(aboutToReset())); connect(m_entryAttributes, SIGNAL(reset()), SLOT(reset())); } diff --git a/src/gui/entry/EntryView.cpp b/src/gui/entry/EntryView.cpp index 05c55ad82..d63260c39 100644 --- a/src/gui/entry/EntryView.cpp +++ b/src/gui/entry/EntryView.cpp @@ -51,7 +51,7 @@ EntryView::EntryView(QWidget* parent) connect(this, SIGNAL(doubleClicked(QModelIndex)), SLOT(emitEntryActivated(QModelIndex))); connect( - selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), SIGNAL(entrySelectionChanged())); + selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SIGNAL(entrySelectionChanged())); connect(m_model, SIGNAL(switchedToListMode()), SLOT(switchToListMode())); connect(m_model, SIGNAL(switchedToSearchMode()), SLOT(switchToSearchMode())); connect(m_model, SIGNAL(usernamesHiddenChanged()), SIGNAL(viewStateChanged())); @@ -97,10 +97,10 @@ EntryView::EntryView(QWidget* parent) header()->setContextMenuPolicy(Qt::CustomContextMenu); connect(header(), SIGNAL(customContextMenuRequested(QPoint)), SLOT(showHeaderMenu(QPoint))); - connect(header(), SIGNAL(sectionCountChanged(int, int)), SIGNAL(viewStateChanged())); - connect(header(), SIGNAL(sectionMoved(int, int, int)), SIGNAL(viewStateChanged())); - connect(header(), SIGNAL(sectionResized(int, int, int)), SIGNAL(viewStateChanged())); - connect(header(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), SIGNAL(viewStateChanged())); + connect(header(), SIGNAL(sectionCountChanged(int,int)), SIGNAL(viewStateChanged())); + connect(header(), SIGNAL(sectionMoved(int,int,int)), SIGNAL(viewStateChanged())); + connect(header(), SIGNAL(sectionResized(int,int,int)), SIGNAL(viewStateChanged())); + connect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), SIGNAL(viewStateChanged())); resetFixedColumns(); diff --git a/src/gui/group/EditGroupWidget.cpp b/src/gui/group/EditGroupWidget.cpp index 2abfa5544..44276a9f3 100644 --- a/src/gui/group/EditGroupWidget.cpp +++ b/src/gui/group/EditGroupWidget.cpp @@ -49,8 +49,8 @@ EditGroupWidget::EditGroupWidget(QWidget* parent) connect(this, SIGNAL(rejected()), SLOT(cancel())); connect(m_editGroupWidgetIcons, - SIGNAL(messageEditEntry(QString, MessageWidget::MessageType)), - SLOT(showMessage(QString, MessageWidget::MessageType))); + SIGNAL(messageEditEntry(QString,MessageWidget::MessageType)), + SLOT(showMessage(QString,MessageWidget::MessageType))); connect(m_editGroupWidgetIcons, SIGNAL(messageEditEntryDismiss()), SLOT(hideMessage())); } diff --git a/src/gui/group/GroupModel.cpp b/src/gui/group/GroupModel.cpp index a3c72b792..791f6ce33 100644 --- a/src/gui/group/GroupModel.cpp +++ b/src/gui/group/GroupModel.cpp @@ -44,11 +44,11 @@ void GroupModel::changeDatabase(Database* newDb) m_db = newDb; connect(m_db, SIGNAL(groupDataChanged(Group*)), SLOT(groupDataChanged(Group*))); - connect(m_db, SIGNAL(groupAboutToAdd(Group*, int)), SLOT(groupAboutToAdd(Group*, int))); + connect(m_db, SIGNAL(groupAboutToAdd(Group*,int)), SLOT(groupAboutToAdd(Group*,int))); connect(m_db, SIGNAL(groupAdded()), SLOT(groupAdded())); connect(m_db, SIGNAL(groupAboutToRemove(Group*)), SLOT(groupAboutToRemove(Group*))); connect(m_db, SIGNAL(groupRemoved()), SLOT(groupRemoved())); - connect(m_db, SIGNAL(groupAboutToMove(Group*, Group*, int)), SLOT(groupAboutToMove(Group*, Group*, int))); + connect(m_db, SIGNAL(groupAboutToMove(Group*,Group*,int)), SLOT(groupAboutToMove(Group*,Group*,int))); connect(m_db, SIGNAL(groupMoved()), SLOT(groupMoved())); endResetModel(); diff --git a/src/gui/group/GroupView.cpp b/src/gui/group/GroupView.cpp index fd6748006..ee3913948 100644 --- a/src/gui/group/GroupView.cpp +++ b/src/gui/group/GroupView.cpp @@ -36,10 +36,10 @@ GroupView::GroupView(Database* db, QWidget* parent) connect(this, SIGNAL(expanded(QModelIndex)), this, SLOT(expandedChanged(QModelIndex))); connect(this, SIGNAL(collapsed(QModelIndex)), this, SLOT(expandedChanged(QModelIndex))); - connect(m_model, SIGNAL(rowsInserted(QModelIndex, int, int)), SLOT(syncExpandedState(QModelIndex, int, int))); + connect(m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), SLOT(syncExpandedState(QModelIndex,int,int))); connect(m_model, SIGNAL(modelReset()), SLOT(modelReset())); - connect(selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), SLOT(emitGroupChanged())); + connect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), SLOT(emitGroupChanged())); connect(this, SIGNAL(clicked(QModelIndex)), SLOT(emitGroupPressed(QModelIndex))); diff --git a/src/gui/masterkey/KeyComponentWidget.cpp b/src/gui/masterkey/KeyComponentWidget.cpp index 45f133b44..72367ecbe 100644 --- a/src/gui/masterkey/KeyComponentWidget.cpp +++ b/src/gui/masterkey/KeyComponentWidget.cpp @@ -38,8 +38,8 @@ KeyComponentWidget::KeyComponentWidget(const QString& name, QWidget* parent) connect(m_ui->stackedWidget, SIGNAL(currentChanged(int)), SLOT(reset())); - connect(this, SIGNAL(nameChanged(const QString&)), SLOT(updateComponentName(const QString&))); - connect(this, SIGNAL(descriptionChanged(const QString&)), SLOT(updateComponentDescription(const QString&))); + connect(this, SIGNAL(nameChanged(QString)), SLOT(updateComponentName(QString))); + connect(this, SIGNAL(descriptionChanged(QString)), SLOT(updateComponentDescription(QString))); connect(this, SIGNAL(componentAddRequested()), SLOT(doAdd())); connect(this, SIGNAL(componentEditRequested()), SLOT(doEdit())); connect(this, SIGNAL(componentRemovalRequested()), SLOT(doRemove())); diff --git a/src/gui/masterkey/PasswordEditWidget.cpp b/src/gui/masterkey/PasswordEditWidget.cpp index dc43f9159..4006a0b1e 100644 --- a/src/gui/masterkey/PasswordEditWidget.cpp +++ b/src/gui/masterkey/PasswordEditWidget.cpp @@ -107,7 +107,7 @@ void PasswordEditWidget::showPasswordGenerator() layout->addWidget(pwGenerator); pwGenerator->setStandaloneMode(false); - connect(pwGenerator, SIGNAL(appliedPassword(const QString&)), SLOT(setPassword(const QString&))); + connect(pwGenerator, SIGNAL(appliedPassword(QString)), SLOT(setPassword(QString))); connect(pwGenerator, SIGNAL(dialogTerminated()), &pwDialog, SLOT(close())); pwGenerator->setPasswordVisible(isPasswordVisible()); diff --git a/src/gui/masterkey/YubiKeyEditWidget.cpp b/src/gui/masterkey/YubiKeyEditWidget.cpp index bae3a3d1e..27e0a4cf0 100644 --- a/src/gui/masterkey/YubiKeyEditWidget.cpp +++ b/src/gui/masterkey/YubiKeyEditWidget.cpp @@ -75,7 +75,7 @@ QWidget* YubiKeyEditWidget::componentEditWidget() #ifdef WITH_XC_YUBIKEY connect(m_compUi->buttonRedetectYubikey, SIGNAL(clicked()), SLOT(pollYubikey())); - connect(YubiKey::instance(), SIGNAL(detected(int, bool)), SLOT(yubikeyDetected(int, bool)), Qt::QueuedConnection); + connect(YubiKey::instance(), SIGNAL(detected(int,bool)), SLOT(yubikeyDetected(int,bool)), Qt::QueuedConnection); connect(YubiKey::instance(), SIGNAL(notFound()), SLOT(noYubikeyFound()), Qt::QueuedConnection); pollYubikey(); From e06eae423e0d90deb71da232a57bd9862bcd3588 Mon Sep 17 00:00:00 2001 From: Gianluca Recchia Date: Mon, 29 Oct 2018 21:14:35 +0100 Subject: [PATCH 13/13] Add missing 'override' for overridden functions --- src/browser/NativeMessagingHost.h | 4 ++-- src/cli/Add.h | 2 +- src/cli/Clip.h | 2 +- src/cli/Diceware.h | 2 +- src/cli/Edit.h | 2 +- src/cli/Estimate.h | 2 +- src/cli/Extract.h | 2 +- src/cli/Generate.h | 2 +- src/cli/List.h | 2 +- src/cli/Locate.h | 2 +- src/cli/Merge.h | 2 +- src/cli/Remove.h | 2 +- src/cli/Show.h | 2 +- src/format/KeePass1Reader.cpp | 2 +- 14 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/browser/NativeMessagingHost.h b/src/browser/NativeMessagingHost.h index da9ac5346..774306d30 100644 --- a/src/browser/NativeMessagingHost.h +++ b/src/browser/NativeMessagingHost.h @@ -41,8 +41,8 @@ signals: void quit(); private: - void readLength(); - bool readStdIn(const quint32 length); + void readLength() override; + bool readStdIn(const quint32 length) override; void sendReplyToAllClients(const QJsonObject& json); private slots: diff --git a/src/cli/Add.h b/src/cli/Add.h index 5769249c9..dd0c3d8b5 100644 --- a/src/cli/Add.h +++ b/src/cli/Add.h @@ -25,7 +25,7 @@ class Add : public Command public: Add(); ~Add(); - int execute(const QStringList& arguments); + int execute(const QStringList& arguments) override; }; #endif // KEEPASSXC_ADD_H diff --git a/src/cli/Clip.h b/src/cli/Clip.h index 929ddf678..e5e6390ae 100644 --- a/src/cli/Clip.h +++ b/src/cli/Clip.h @@ -25,7 +25,7 @@ class Clip : public Command public: Clip(); ~Clip(); - int execute(const QStringList& arguments); + int execute(const QStringList& arguments) override; int clipEntry(Database* database, const QString& entryPath, const QString& timeout); }; diff --git a/src/cli/Diceware.h b/src/cli/Diceware.h index 61fe724ca..f439681b7 100644 --- a/src/cli/Diceware.h +++ b/src/cli/Diceware.h @@ -25,7 +25,7 @@ class Diceware : public Command public: Diceware(); ~Diceware(); - int execute(const QStringList& arguments); + int execute(const QStringList& arguments) override; }; #endif // KEEPASSXC_DICEWARE_H diff --git a/src/cli/Edit.h b/src/cli/Edit.h index 2c413bea0..001b5abaf 100644 --- a/src/cli/Edit.h +++ b/src/cli/Edit.h @@ -25,7 +25,7 @@ class Edit : public Command public: Edit(); ~Edit(); - int execute(const QStringList& arguments); + int execute(const QStringList& arguments) override; }; #endif // KEEPASSXC_EDIT_H diff --git a/src/cli/Estimate.h b/src/cli/Estimate.h index 15f922752..c15fed9b3 100644 --- a/src/cli/Estimate.h +++ b/src/cli/Estimate.h @@ -25,7 +25,7 @@ class Estimate : public Command public: Estimate(); ~Estimate(); - int execute(const QStringList& arguments); + int execute(const QStringList& arguments) override; }; #endif // KEEPASSXC_ESTIMATE_H diff --git a/src/cli/Extract.h b/src/cli/Extract.h index 2939afddb..1a4f6288b 100644 --- a/src/cli/Extract.h +++ b/src/cli/Extract.h @@ -25,7 +25,7 @@ class Extract : public Command public: Extract(); ~Extract(); - int execute(const QStringList& arguments); + int execute(const QStringList& arguments) override; }; #endif // KEEPASSXC_EXTRACT_H diff --git a/src/cli/Generate.h b/src/cli/Generate.h index 607fc105c..64ef81623 100644 --- a/src/cli/Generate.h +++ b/src/cli/Generate.h @@ -25,7 +25,7 @@ class Generate : public Command public: Generate(); ~Generate(); - int execute(const QStringList& arguments); + int execute(const QStringList& arguments) override; }; #endif // KEEPASSXC_GENERATE_H diff --git a/src/cli/List.h b/src/cli/List.h index 5697d9390..92ade262b 100644 --- a/src/cli/List.h +++ b/src/cli/List.h @@ -25,7 +25,7 @@ class List : public Command public: List(); ~List(); - int execute(const QStringList& arguments); + int execute(const QStringList& arguments) override; int listGroup(Database* database, bool recursive, const QString& groupPath = {}); }; diff --git a/src/cli/Locate.h b/src/cli/Locate.h index 3355d41ec..ae32951b9 100644 --- a/src/cli/Locate.h +++ b/src/cli/Locate.h @@ -25,7 +25,7 @@ class Locate : public Command public: Locate(); ~Locate(); - int execute(const QStringList& arguments); + int execute(const QStringList& arguments) override; int locateEntry(Database* database, const QString& searchTerm); }; diff --git a/src/cli/Merge.h b/src/cli/Merge.h index 496c66b86..1f138b65f 100644 --- a/src/cli/Merge.h +++ b/src/cli/Merge.h @@ -25,7 +25,7 @@ class Merge : public Command public: Merge(); ~Merge(); - int execute(const QStringList& arguments); + int execute(const QStringList& arguments) override; }; #endif // KEEPASSXC_MERGE_H diff --git a/src/cli/Remove.h b/src/cli/Remove.h index 33d62f4bd..d45e04af2 100644 --- a/src/cli/Remove.h +++ b/src/cli/Remove.h @@ -27,7 +27,7 @@ class Remove : public Command public: Remove(); ~Remove(); - int execute(const QStringList& arguments); + int execute(const QStringList& arguments) override; int removeEntry(Database* database, const QString& databasePath, const QString& entryPath); }; diff --git a/src/cli/Show.h b/src/cli/Show.h index fe16546c3..6d49d1207 100644 --- a/src/cli/Show.h +++ b/src/cli/Show.h @@ -25,7 +25,7 @@ class Show : public Command public: Show(); ~Show(); - int execute(const QStringList& arguments); + int execute(const QStringList& arguments) override; int showEntry(Database* database, QStringList attributes, const QString& entryPath); }; diff --git a/src/format/KeePass1Reader.cpp b/src/format/KeePass1Reader.cpp index 7c0ea652e..a991b572f 100644 --- a/src/format/KeePass1Reader.cpp +++ b/src/format/KeePass1Reader.cpp @@ -37,7 +37,7 @@ class KeePass1Key : public CompositeKey { public: - virtual QByteArray rawKey() const; + QByteArray rawKey() const override; virtual void clear(); void setPassword(const QByteArray& password); void setKeyfileData(const QByteArray& keyfileData);