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

@ -621,7 +621,6 @@ bool AutoType::windowMatches(const QString& windowTitle, const QString& windowPa
return (regExp.indexIn(windowTitle) != -1); 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 "AutoTypeFilterLineEdit.h"
#include <QKeyEvent> #include <QKeyEvent>
void AutoTypeFilterLineEdit::keyPressEvent(QKeyEvent *event) void AutoTypeFilterLineEdit::keyPressEvent(QKeyEvent* event)
{ {
if (event->key() == Qt::Key_Up) { if (event->key() == Qt::Key_Up) {
emit keyUpPressed(); 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) { if (event->key() == Qt::Key_Escape) {
emit escapeReleased(); emit escapeReleased();

View file

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

View file

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

View file

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

View file

@ -61,8 +61,7 @@ int main(int argc, char** argv)
parser.addPositionalArgument("command", QObject::tr("Name of the command to execute.")); parser.addPositionalArgument("command", QObject::tr("Name of the command to execute."));
QCommandLineOption debugInfoOption(QStringList() << "debug-info", QCommandLineOption debugInfoOption(QStringList() << "debug-info", QObject::tr("Displays debugging information."));
QObject::tr("Displays debugging information."));
parser.addOption(debugInfoOption); parser.addOption(debugInfoOption);
parser.addHelpOption(); parser.addHelpOption();
parser.addVersionOption(); 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 * Custom insecure delete operator that does not zero out memory before
* freeing a buffer. Can be used for better performance. * 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); std::free(ptr);
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -97,7 +97,7 @@ ApplicationSettingsWidget::ApplicationSettingsWidget(QWidget* parent)
#else #else
m_generalUi->checkForUpdatesOnStartupCheckBox->setVisible(false); m_generalUi->checkForUpdatesOnStartupCheckBox->setVisible(false);
m_generalUi->checkForUpdatesIncludeBetasCheckBox->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 #endif
#ifndef WITH_XC_NETWORKING #ifndef WITH_XC_NETWORKING

View file

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

View file

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

View file

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

View file

@ -32,9 +32,9 @@
#include <QXmlStreamReader> #include <QXmlStreamReader>
#include <QtConcurrent> #include <QtConcurrent>
#include <cstring>
#include <gcrypt.h> #include <gcrypt.h>
#include <sodium.h> #include <sodium.h>
#include <cstring>
QUuid YkChallengeResponseKey::UUID("e092495c-e77d-498b-84a1-05ae0d955508"); 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 helpOption = parser.addHelpOption();
QCommandLineOption versionOption = parser.addVersionOption(); QCommandLineOption versionOption = parser.addVersionOption();
QCommandLineOption debugInfoOption(QStringList() << "debug-info", QCommandLineOption debugInfoOption(QStringList() << "debug-info", QObject::tr("Displays debugging information."));
QObject::tr("Displays debugging information."));
parser.addOption(configOption); parser.addOption(configOption);
parser.addOption(keyfileOption); parser.addOption(keyfileOption);
parser.addOption(pwstdinOption); parser.addOption(pwstdinOption);

View file

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

View file

@ -1212,7 +1212,8 @@ void TestMerge::testCustomdata()
QCOMPARE(dbDestination->metadata()->customData()->value("key1"), QString("value1")); QCOMPARE(dbDestination->metadata()->customData()->value("key1"), QString("value1"));
QCOMPARE(dbDestination->metadata()->customData()->value("key2"), QString("value2")); 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("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 // Target is newer, no data is merged
QVERIFY(!dbDestination2->metadata()->customData()->isEmpty()); QVERIFY(!dbDestination2->metadata()->customData()->isEmpty());
@ -1220,7 +1221,8 @@ void TestMerge::testCustomdata()
QVERIFY(!dbDestination2->metadata()->customData()->contains("key2")); QVERIFY(!dbDestination2->metadata()->customData()->contains("key2"));
QVERIFY(!dbDestination2->metadata()->customData()->contains("Browser")); QVERIFY(!dbDestination2->metadata()->customData()->contains("Browser"));
QVERIFY(dbDestination2->metadata()->customData()->contains("notToBeDeleted")); 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() void TestMerge::testDeletedEntry()