Code formatting

This commit is contained in:
Jonathan White 2019-05-12 17:42:55 -04:00
parent 96438a45b4
commit 2ee97ed191
28 changed files with 65 additions and 63 deletions

View File

@ -619,9 +619,8 @@ bool AutoType::windowMatches(const QString& windowTitle, const QString& windowPa
if (windowPattern.startsWith("//") && windowPattern.endsWith("//") && windowPattern.size() >= 4) {
QRegExp regExp(windowPattern.mid(2, windowPattern.size() - 4), Qt::CaseInsensitive, QRegExp::RegExp2);
return (regExp.indexIn(windowTitle) != -1);
}
return WildcardMatcher(windowTitle).match(windowPattern);
}
return WildcardMatcher(windowTitle).match(windowPattern);
}
/**

View File

@ -18,7 +18,7 @@
#include "AutoTypeFilterLineEdit.h"
#include <QKeyEvent>
void AutoTypeFilterLineEdit::keyPressEvent(QKeyEvent *event)
void AutoTypeFilterLineEdit::keyPressEvent(QKeyEvent* event)
{
if (event->key() == Qt::Key_Up) {
emit keyUpPressed();
@ -29,7 +29,7 @@ void AutoTypeFilterLineEdit::keyPressEvent(QKeyEvent *event)
}
}
void AutoTypeFilterLineEdit::keyReleaseEvent(QKeyEvent *event)
void AutoTypeFilterLineEdit::keyReleaseEvent(QKeyEvent* event)
{
if (event->key() == Qt::Key_Escape) {
emit escapeReleased();

View File

@ -25,10 +25,14 @@ class AutoTypeFilterLineEdit : public QLineEdit
Q_OBJECT
public:
AutoTypeFilterLineEdit(QWidget* widget) : QLineEdit(widget) {}
AutoTypeFilterLineEdit(QWidget* widget)
: QLineEdit(widget)
{
}
protected:
virtual void keyPressEvent(QKeyEvent *event);
virtual void keyReleaseEvent(QKeyEvent *event);
virtual void keyPressEvent(QKeyEvent* event);
virtual void keyReleaseEvent(QKeyEvent* event);
signals:
void keyUpPressed();
void keyDownPressed();

View File

@ -27,9 +27,9 @@
#include <QDialogButtonBox>
#include <QHeaderView>
#include <QLabel>
#include <QVBoxLayout>
#include <QLineEdit>
#include <QSortFilterProxyModel>
#include <QVBoxLayout>
#include "autotype/AutoTypeSelectView.h"
#include "core/AutoTypeMatch.h"
@ -77,7 +77,7 @@ AutoTypeSelectDialog::AutoTypeSelectDialog(QWidget* parent)
connect(m_view, SIGNAL(rejected()), SLOT(reject()));
// clang-format on
QSortFilterProxyModel *proxy = qobject_cast<QSortFilterProxyModel*>(m_view->model());
QSortFilterProxyModel* proxy = qobject_cast<QSortFilterProxyModel*>(m_view->model());
if (proxy) {
proxy->setFilterKeyColumn(-1);
proxy->setFilterCaseSensitivity(Qt::CaseInsensitive);
@ -146,10 +146,9 @@ void AutoTypeSelectDialog::matchRemoved()
}
}
void AutoTypeSelectDialog::filterList(QString filterString)
{
QSortFilterProxyModel *proxy = qobject_cast<QSortFilterProxyModel*>(m_view->model());
QSortFilterProxyModel* proxy = qobject_cast<QSortFilterProxyModel*>(m_view->model());
if (proxy) {
proxy->setFilterWildcard(filterString);
if (!m_view->currentIndex().isValid()) {

View File

@ -739,7 +739,7 @@ QList<Entry*> BrowserService::sortEntries(QList<Entry*>& pwEntries, const QStrin
|| ((QString::localeAwareCompare(left->attributes()->value(field),
right->attributes()->value(field))
== 0)
&& (QString::localeAwareCompare(left->attributes()->value("UserName"),
&& (QString::localeAwareCompare(left->attributes()->value("UserName"),
right->attributes()->value("UserName"))
< 0));
});

View File

@ -240,13 +240,13 @@ void BrowserSettings::setVivaldiSupport(bool enabled)
bool BrowserSettings::braveSupport()
{
return m_hostInstaller.checkIfInstalled(HostInstaller::SupportedBrowsers::BRAVE);
return m_hostInstaller.checkIfInstalled(HostInstaller::SupportedBrowsers::BRAVE);
}
void BrowserSettings::setBraveSupport(bool enabled)
{
m_hostInstaller.installBrowser(
HostInstaller::SupportedBrowsers::BRAVE, enabled, supportBrowserProxy(), customProxyLocation());
m_hostInstaller.installBrowser(
HostInstaller::SupportedBrowsers::BRAVE, enabled, supportBrowserProxy(), customProxyLocation());
}
bool BrowserSettings::torBrowserSupport()

View File

@ -171,7 +171,7 @@ QString HostInstaller::getTargetPath(SupportedBrowsers browser) const
case SupportedBrowsers::TOR_BROWSER:
return TARGET_DIR_TOR_BROWSER;
case SupportedBrowsers::BRAVE:
return TARGET_DIR_BRAVE;
return TARGET_DIR_BRAVE;
default:
return QString();
}
@ -194,11 +194,11 @@ QString HostInstaller::getBrowserName(SupportedBrowsers browser) const
case SupportedBrowsers::FIREFOX:
return "firefox";
case SupportedBrowsers::VIVALDI:
return "vivaldi";
return "vivaldi";
case SupportedBrowsers::TOR_BROWSER:
return "tor-browser";
case SupportedBrowsers::BRAVE:
return "brave";
return "brave";
default:
return QString();
}

View File

@ -47,8 +47,7 @@ const QCommandLineOption Command::KeyFileOption = QCommandLineOption(QStringList
QObject::tr("path"));
const QCommandLineOption Command::NoPasswordOption =
QCommandLineOption(QStringList() << "no-password",
QObject::tr("Deactivate password key for the database."));
QCommandLineOption(QStringList() << "no-password", QObject::tr("Deactivate password key for the database."));
QMap<QString, Command*> commands;

View File

@ -56,7 +56,7 @@ int Extract::execute(const QStringList& arguments)
errorTextStream << parser.helpText().replace("[options]", "extract [options]");
return EXIT_FAILURE;
}
auto compositeKey = QSharedPointer<CompositeKey>::create();
auto db = Utils::unlockDatabase(args.at(0),

View File

@ -61,8 +61,7 @@ int main(int argc, char** argv)
parser.addPositionalArgument("command", QObject::tr("Name of the command to execute."));
QCommandLineOption debugInfoOption(QStringList() << "debug-info",
QObject::tr("Displays debugging information."));
QCommandLineOption debugInfoOption(QStringList() << "debug-info", QObject::tr("Displays debugging information."));
parser.addOption(debugInfoOption);
parser.addHelpOption();
parser.addVersionOption();

View File

@ -78,7 +78,7 @@ void operator delete[](void* ptr) noexcept
* Custom insecure delete operator that does not zero out memory before
* freeing a buffer. Can be used for better performance.
*/
void operator delete(void* ptr, bool) noexcept
void operator delete(void* ptr, bool)noexcept
{
std::free(ptr);
}

View File

@ -257,7 +257,7 @@ namespace Bootstrap
nullptr, // do not change owner or group
pACL, // DACL specified
nullptr // do not change SACL
);
);
Cleanup:

View File

@ -625,9 +625,9 @@ Merger::ChangeList Merger::mergeMetadata(const MergeContext& context)
// Merge Custom Data if source is newer
const auto targetCustomDataModificationTime = sourceMetadata->customData()->getLastModified();
const auto sourceCustomDataModificationTime = targetMetadata->customData()->getLastModified();
if (!targetMetadata->customData()->contains(CustomData::LastModified) ||
(targetCustomDataModificationTime.isValid() && sourceCustomDataModificationTime.isValid() &&
targetCustomDataModificationTime > sourceCustomDataModificationTime)) {
if (!targetMetadata->customData()->contains(CustomData::LastModified)
|| (targetCustomDataModificationTime.isValid() && sourceCustomDataModificationTime.isValid()
&& targetCustomDataModificationTime > sourceCustomDataModificationTime)) {
const auto sourceCustomDataKeys = sourceMetadata->customData()->keys();
const auto targetCustomDataKeys = targetMetadata->customData()->keys();

View File

@ -23,6 +23,7 @@
#include "core/Config.h"
#include "core/Translator.h"
#include "git-info.h"
#include <QCoreApplication>
#include <QElapsedTimer>
#include <QIODevice>
@ -33,7 +34,6 @@
#include <QSysInfo>
#include <QUuid>
#include <cctype>
#include "git-info.h"
#ifdef Q_OS_WIN
#include <windows.h> // for Sleep()
@ -75,7 +75,6 @@ namespace Tools
#endif
debugInfo.append("\n");
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
debugInfo.append(QObject::tr("Operating system: %1\nCPU architecture: %2\nKernel: %3 %4")
.arg(QSysInfo::prettyProductName(),

View File

@ -18,9 +18,9 @@
#ifndef KEEPASSX_TRANSLATOR_H
#define KEEPASSX_TRANSLATOR_H
#include <QLocale>
#include <QPair>
#include <QString>
#include <QLocale>
class Translator
{

View File

@ -157,8 +157,8 @@ namespace FdoSecrets
if (ret.isError()) {
return ret;
}
return static_cast<qulonglong>(
m_backend->database()->rootGroup()->timeInfo().creationTime().toMSecsSinceEpoch() / 1000);
return static_cast<qulonglong>(m_backend->database()->rootGroup()->timeInfo().creationTime().toMSecsSinceEpoch()
/ 1000);
}
DBusReturn<qulonglong> Collection::modified() const

View File

@ -354,12 +354,12 @@ namespace FdoSecrets
return pathComponents.join('/');
}
QString Item::encodeAttributeKey(const QString &key)
QString Item::encodeAttributeKey(const QString& key)
{
return QUrl::toPercentEncoding(key, "", "_:").replace('%', '_');
}
QString Item::decodeAttributeKey(const QString &key)
QString Item::decodeAttributeKey(const QString& key)
{
return QString::fromUtf8(QByteArray::fromPercentEncoding(key.toLatin1(), '_'));
}

View File

@ -66,8 +66,10 @@ namespace FdoSecrets
// Connect to service unregistered signal
m_serviceWatcher.reset(new QDBusServiceWatcher());
connect(
m_serviceWatcher.data(), &QDBusServiceWatcher::serviceUnregistered, this, &Service::dbusServiceUnregistered);
connect(m_serviceWatcher.data(),
&QDBusServiceWatcher::serviceUnregistered,
this,
&Service::dbusServiceUnregistered);
m_serviceWatcher->setConnection(QDBusConnection::sessionBus());

View File

@ -26,7 +26,6 @@
#include <QClipboard>
static const QString aboutMaintainers = R"(
<p><ul>
<li>Jonathan White (<a href="https://github.com/droidmonkey">droidmonkey</a>)</li>

View File

@ -97,7 +97,7 @@ ApplicationSettingsWidget::ApplicationSettingsWidget(QWidget* parent)
#else
m_generalUi->checkForUpdatesOnStartupCheckBox->setVisible(false);
m_generalUi->checkForUpdatesIncludeBetasCheckBox->setVisible(false);
m_generalUi->checkUpdatesSpacer->changeSize(0,0, QSizePolicy::Fixed, QSizePolicy::Fixed);
m_generalUi->checkUpdatesSpacer->changeSize(0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
#endif
#ifndef WITH_XC_NETWORKING

View File

@ -242,12 +242,12 @@ void DatabaseSettingsWidgetBrowser::convertAttributesToCustomData()
{
if (MessageBox::Yes
!= MessageBox::question(
this,
tr("Move KeePassHTTP attributes to custom data"),
tr("Do you really want to move all legacy browser integration data to the latest standard?\n"
"This is necessary to maintain compatibility with the browser plugin."),
MessageBox::Yes | MessageBox::Cancel,
MessageBox::Cancel)) {
this,
tr("Move KeePassHTTP attributes to custom data"),
tr("Do you really want to move all legacy browser integration data to the latest standard?\n"
"This is necessary to maintain compatibility with the browser plugin."),
MessageBox::Yes | MessageBox::Cancel,
MessageBox::Cancel)) {
return;
}

View File

@ -18,9 +18,9 @@
#ifndef KEEPASSXC_KEYCOMPONENTWIDGET_H
#define KEEPASSXC_KEYCOMPONENTWIDGET_H
#include <QPointer>
#include <QScopedPointer>
#include <QWidget>
#include <QPointer>
namespace Ui
{
@ -111,7 +111,7 @@ signals:
void componentRemovalRequested();
protected:
void showEvent(QShowEvent* event) override ;
void showEvent(QShowEvent* event) override;
private slots:
void updateComponentName(const QString& name);

View File

@ -24,10 +24,10 @@
#include <QFile>
#include <sodium.h>
#include <gcrypt.h>
#include <algorithm>
#include <cstring>
#include <gcrypt.h>
#include <sodium.h>
QUuid FileKey::UUID("a584cbc4-c9b4-437e-81bb-362ca9709273");

View File

@ -19,9 +19,9 @@
#include "core/Tools.h"
#include "crypto/CryptoHash.h"
#include <gcrypt.h>
#include <algorithm>
#include <cstring>
#include <gcrypt.h>
QUuid PasswordKey::UUID("77e90411-303a-43f2-b773-853b05635ead");

View File

@ -32,9 +32,9 @@
#include <QXmlStreamReader>
#include <QtConcurrent>
#include <cstring>
#include <gcrypt.h>
#include <sodium.h>
#include <cstring>
QUuid YkChallengeResponseKey::UUID("e092495c-e77d-498b-84a1-05ae0d955508");

View File

@ -82,8 +82,7 @@ int main(int argc, char** argv)
QCommandLineOption helpOption = parser.addHelpOption();
QCommandLineOption versionOption = parser.addVersionOption();
QCommandLineOption debugInfoOption(QStringList() << "debug-info",
QObject::tr("Displays debugging information."));
QCommandLineOption debugInfoOption(QStringList() << "debug-info", QObject::tr("Displays debugging information."));
parser.addOption(configOption);
parser.addOption(keyfileOption);
parser.addOption(pwstdinOption);

View File

@ -690,8 +690,9 @@ void TestCli::testKeyFileOption()
listCmd.execute({"ls", "-k", keyFilePath, m_keyFileProtectedDbFile->fileName()});
m_stdoutFile->reset();
m_stdoutFile->readLine(); // skip password prompt
QCOMPARE(m_stdoutFile->readAll(), QByteArray("entry1\n"
"entry2\n"));
QCOMPARE(m_stdoutFile->readAll(),
QByteArray("entry1\n"
"entry2\n"));
// Should raise an error with no key file.
qint64 pos = m_stdoutFile->pos();
@ -713,8 +714,7 @@ void TestCli::testKeyFileOption()
m_stdoutFile->readLine(); // skip password prompt
m_stderrFile->seek(posErr);
QCOMPARE(m_stdoutFile->readAll(), QByteArray(""));
QCOMPARE(m_stderrFile->readAll().split(':').at(0),
QByteArray("Failed to load key file invalidpath"));
QCOMPARE(m_stderrFile->readAll().split(':').at(0), QByteArray("Failed to load key file invalidpath"));
}
void TestCli::testNoPasswordOption()
@ -724,8 +724,9 @@ void TestCli::testNoPasswordOption()
QString keyFilePath(QString(KEEPASSX_TEST_DATA_DIR).append("/KeyFileProtectedNoPassword.key"));
listCmd.execute({"ls", "-k", keyFilePath, "--no-password", m_keyFileProtectedNoPasswordDbFile->fileName()});
m_stdoutFile->reset();
QCOMPARE(m_stdoutFile->readAll(), QByteArray("entry1\n"
"entry2\n"));
QCOMPARE(m_stdoutFile->readAll(),
QByteArray("entry1\n"
"entry2\n"));
// Should raise an error with no key file.
qint64 pos = m_stdoutFile->pos();

View File

@ -1172,7 +1172,7 @@ void TestMerge::testCustomdata()
QScopedPointer<Database> dbSource2(createTestDatabase());
m_clock->advanceSecond(1);
dbDestination->metadata()->customData()->set("toBeDeleted", "value");
dbDestination->metadata()->customData()->set("key3", "oldValue");
@ -1212,7 +1212,8 @@ void TestMerge::testCustomdata()
QCOMPARE(dbDestination->metadata()->customData()->value("key1"), QString("value1"));
QCOMPARE(dbDestination->metadata()->customData()->value("key2"), QString("value2"));
QCOMPARE(dbDestination->metadata()->customData()->value("Browser"), QString("n'8=3W@L^6d->d.]St_>]"));
QCOMPARE(dbDestination->metadata()->customData()->value("key3"), QString("newValue")); // Old value should be replaced
QCOMPARE(dbDestination->metadata()->customData()->value("key3"),
QString("newValue")); // Old value should be replaced
// Target is newer, no data is merged
QVERIFY(!dbDestination2->metadata()->customData()->isEmpty());
@ -1220,7 +1221,8 @@ void TestMerge::testCustomdata()
QVERIFY(!dbDestination2->metadata()->customData()->contains("key2"));
QVERIFY(!dbDestination2->metadata()->customData()->contains("Browser"));
QVERIFY(dbDestination2->metadata()->customData()->contains("notToBeDeleted"));
QCOMPARE(dbDestination2->metadata()->customData()->value("key3"), QString("oldValue")); // Old value should not be replaced
QCOMPARE(dbDestination2->metadata()->customData()->value("key3"),
QString("oldValue")); // Old value should not be replaced
}
void TestMerge::testDeletedEntry()