mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Coding style improvements.
This commit is contained in:
parent
924130e0fe
commit
a407e0082b
@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
#include "EntryAttributes.h"
|
#include "EntryAttributes.h"
|
||||||
|
|
||||||
const QStringList EntryAttributes::DEFAULT_ATTRIBUTES(QStringList() << "Title" << "URL"
|
const QStringList EntryAttributes::DefaultAttributes(QStringList() << "Title" << "URL"
|
||||||
<< "UserName" << "Password" << "Notes");
|
<< "UserName" << "Password" << "Notes");
|
||||||
|
|
||||||
EntryAttributes::EntryAttributes(QObject* parent)
|
EntryAttributes::EntryAttributes(QObject* parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
@ -215,7 +215,7 @@ void EntryAttributes::clear()
|
|||||||
m_attributes.clear();
|
m_attributes.clear();
|
||||||
m_protectedAttributes.clear();
|
m_protectedAttributes.clear();
|
||||||
|
|
||||||
Q_FOREACH (const QString& key, DEFAULT_ATTRIBUTES) {
|
Q_FOREACH (const QString& key, DefaultAttributes) {
|
||||||
m_attributes.insert(key, "");
|
m_attributes.insert(key, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,5 +236,5 @@ int EntryAttributes::attributesSize() {
|
|||||||
|
|
||||||
bool EntryAttributes::isDefaultAttribute(const QString& key)
|
bool EntryAttributes::isDefaultAttribute(const QString& key)
|
||||||
{
|
{
|
||||||
return DEFAULT_ATTRIBUTES.contains(key);
|
return DefaultAttributes.contains(key);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ public:
|
|||||||
bool operator==(const EntryAttributes& other) const;
|
bool operator==(const EntryAttributes& other) const;
|
||||||
bool operator!=(const EntryAttributes& other) const;
|
bool operator!=(const EntryAttributes& other) const;
|
||||||
|
|
||||||
static const QStringList DEFAULT_ATTRIBUTES;
|
static const QStringList DefaultAttributes;
|
||||||
static bool isDefaultAttribute(const QString& key);
|
static bool isDefaultAttribute(const QString& key);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
@ -114,6 +114,7 @@ private:
|
|||||||
void cleanupParent();
|
void cleanupParent();
|
||||||
void recCreateDelObjects();
|
void recCreateDelObjects();
|
||||||
void updateTimeinfo();
|
void updateTimeinfo();
|
||||||
|
bool includeInSearch(bool resolveInherit);
|
||||||
|
|
||||||
QPointer<Database> m_db;
|
QPointer<Database> m_db;
|
||||||
Uuid m_uuid;
|
Uuid m_uuid;
|
||||||
@ -138,8 +139,6 @@ private:
|
|||||||
friend void Database::setRootGroup(Group* group);
|
friend void Database::setRootGroup(Group* group);
|
||||||
friend Entry::~Entry();
|
friend Entry::~Entry();
|
||||||
friend void Entry::setGroup(Group* group);
|
friend void Entry::setGroup(Group* group);
|
||||||
|
|
||||||
bool includeInSearch(bool resolveInherit);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEEPASSX_GROUP_H
|
#endif // KEEPASSX_GROUP_H
|
||||||
|
@ -29,8 +29,8 @@ Metadata::Metadata(QObject* parent)
|
|||||||
m_recycleBinEnabled = true;
|
m_recycleBinEnabled = true;
|
||||||
m_masterKeyChangeRec = -1;
|
m_masterKeyChangeRec = -1;
|
||||||
m_masterKeyChangeForce = -1;
|
m_masterKeyChangeForce = -1;
|
||||||
m_historyMaxItems = defaultHistoryMaxItems;
|
m_historyMaxItems = DefaultHistoryMaxItems;
|
||||||
m_historyMaxSize = defaultHistoryMaxSize;
|
m_historyMaxSize = DefaultHistoryMaxSize;
|
||||||
|
|
||||||
QDateTime now = Tools::currentDateTimeUtc();
|
QDateTime now = Tools::currentDateTimeUtc();
|
||||||
m_nameChanged = now;
|
m_nameChanged = now;
|
||||||
@ -50,8 +50,8 @@ Metadata::Metadata(QObject* parent)
|
|||||||
m_updateDatetime = true;
|
m_updateDatetime = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int Metadata::defaultHistoryMaxItems = 10;
|
const int Metadata::DefaultHistoryMaxItems = 10;
|
||||||
const int Metadata::defaultHistoryMaxSize = 6291456;
|
const int Metadata::DefaultHistoryMaxSize = 6291456;
|
||||||
|
|
||||||
template <class P, class V> bool Metadata::set(P& property, const V& value)
|
template <class P, class V> bool Metadata::set(P& property, const V& value)
|
||||||
{
|
{
|
||||||
|
@ -70,8 +70,8 @@ public:
|
|||||||
int historyMaxSize() const;
|
int historyMaxSize() const;
|
||||||
QHash<QString, QString> customFields() const;
|
QHash<QString, QString> customFields() const;
|
||||||
|
|
||||||
static const int defaultHistoryMaxItems;
|
static const int DefaultHistoryMaxItems;
|
||||||
static const int defaultHistoryMaxSize;
|
static const int DefaultHistoryMaxSize;
|
||||||
|
|
||||||
void setGenerator(const QString& value);
|
void setGenerator(const QString& value);
|
||||||
void setName(const QString& value);
|
void setName(const QString& value);
|
||||||
|
@ -21,22 +21,22 @@
|
|||||||
|
|
||||||
#include "crypto/Random.h"
|
#include "crypto/Random.h"
|
||||||
|
|
||||||
const int Uuid::LENGTH = 16;
|
const int Uuid::Length = 16;
|
||||||
|
|
||||||
Uuid::Uuid()
|
Uuid::Uuid()
|
||||||
: m_data(LENGTH, 0)
|
: m_data(Length, 0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Uuid::Uuid(const QByteArray& data)
|
Uuid::Uuid(const QByteArray& data)
|
||||||
{
|
{
|
||||||
Q_ASSERT(data.size() == LENGTH);
|
Q_ASSERT(data.size() == Length);
|
||||||
|
|
||||||
m_data = data;
|
m_data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
Uuid Uuid::random() {
|
Uuid Uuid::random() {
|
||||||
return Uuid(Random::randomArray(LENGTH));
|
return Uuid(Random::randomArray(Length));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Uuid::toBase64() const
|
QString Uuid::toBase64() const
|
||||||
@ -97,7 +97,7 @@ QDataStream& operator>>(QDataStream& stream, Uuid& uuid)
|
|||||||
{
|
{
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
stream >> data;
|
stream >> data;
|
||||||
if (data.size() == Uuid::LENGTH) {
|
if (data.size() == Uuid::Length) {
|
||||||
uuid = Uuid(data);
|
uuid = Uuid(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ public:
|
|||||||
Uuid& operator=(const Uuid& other);
|
Uuid& operator=(const Uuid& other);
|
||||||
bool operator==(const Uuid& other) const;
|
bool operator==(const Uuid& other) const;
|
||||||
bool operator!=(const Uuid& other) const;
|
bool operator!=(const Uuid& other) const;
|
||||||
static const int LENGTH;
|
static const int Length;
|
||||||
static Uuid fromBase64(const QString& str);
|
static Uuid fromBase64(const QString& str);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -247,7 +247,7 @@ bool KeePass2Reader::readHeaderField()
|
|||||||
|
|
||||||
void KeePass2Reader::setCipher(const QByteArray& data)
|
void KeePass2Reader::setCipher(const QByteArray& data)
|
||||||
{
|
{
|
||||||
if (data.size() != Uuid::LENGTH) {
|
if (data.size() != Uuid::Length) {
|
||||||
raiseError("");
|
raiseError("");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -848,7 +848,7 @@ int KeePass2XmlReader::readNumber()
|
|||||||
Uuid KeePass2XmlReader::readUuid()
|
Uuid KeePass2XmlReader::readUuid()
|
||||||
{
|
{
|
||||||
QByteArray uuidBin = readBinary();
|
QByteArray uuidBin = readBinary();
|
||||||
if (uuidBin.length() != Uuid::LENGTH) {
|
if (uuidBin.length() != Uuid::Length) {
|
||||||
raiseError(15);
|
raiseError(15);
|
||||||
return Uuid();
|
return Uuid();
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ void DatabaseSettingsWidget::setForms(const QString& dbName, const QString& dbDe
|
|||||||
m_ui->historyMaxItemsCheckBox->setChecked(true);
|
m_ui->historyMaxItemsCheckBox->setChecked(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_ui->historyMaxItemsSpinBox->setValue(Metadata::defaultHistoryMaxItems);
|
m_ui->historyMaxItemsSpinBox->setValue(Metadata::DefaultHistoryMaxItems);
|
||||||
m_ui->historyMaxItemsCheckBox->setChecked(false);
|
m_ui->historyMaxItemsCheckBox->setChecked(false);
|
||||||
}
|
}
|
||||||
if (historyMaxSize > -1) {
|
if (historyMaxSize > -1) {
|
||||||
@ -68,7 +68,7 @@ void DatabaseSettingsWidget::setForms(const QString& dbName, const QString& dbDe
|
|||||||
m_ui->historyMaxSizeCheckBox->setChecked(true);
|
m_ui->historyMaxSizeCheckBox->setChecked(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_ui->historyMaxSizeSpinBox->setValue(Metadata::defaultHistoryMaxSize);
|
m_ui->historyMaxSizeSpinBox->setValue(Metadata::DefaultHistoryMaxSize);
|
||||||
m_ui->historyMaxSizeCheckBox->setChecked(false);
|
m_ui->historyMaxSizeCheckBox->setChecked(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,9 +125,9 @@ EditEntryWidget::~EditEntryWidget()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const QColor EditEntryWidget::normalColor = Qt::white;
|
const QColor EditEntryWidget::NormalColor = Qt::white;
|
||||||
const QColor EditEntryWidget::correctSoFarColor = QColor(255, 205, 15);
|
const QColor EditEntryWidget::CorrectSoFarColor = QColor(255, 205, 15);
|
||||||
const QColor EditEntryWidget::errorColor = QColor(255, 125, 125);
|
const QColor EditEntryWidget::ErrorColor = QColor(255, 125, 125);
|
||||||
|
|
||||||
void EditEntryWidget::loadEntry(Entry* entry, bool create, const QString& groupName,
|
void EditEntryWidget::loadEntry(Entry* entry, bool create, const QString& groupName,
|
||||||
Database* database)
|
Database* database)
|
||||||
@ -284,14 +284,14 @@ void EditEntryWidget::setPasswordCheckColors()
|
|||||||
{
|
{
|
||||||
QPalette pal;
|
QPalette pal;
|
||||||
if (passwordsEqual()) {
|
if (passwordsEqual()) {
|
||||||
pal.setColor(QPalette::Base, normalColor);
|
pal.setColor(QPalette::Base, NormalColor);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (m_mainUi->passwordEdit->text().startsWith(m_mainUi->passwordRepeatEdit->text())) {
|
if (m_mainUi->passwordEdit->text().startsWith(m_mainUi->passwordRepeatEdit->text())) {
|
||||||
pal.setColor(QPalette::Base, correctSoFarColor);
|
pal.setColor(QPalette::Base, CorrectSoFarColor);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pal.setColor(QPalette::Base, errorColor);
|
pal.setColor(QPalette::Base, ErrorColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_mainUi->passwordRepeatEdit->setPalette(pal);
|
m_mainUi->passwordRepeatEdit->setPalette(pal);
|
||||||
|
@ -52,9 +52,9 @@ public:
|
|||||||
|
|
||||||
void loadEntry(Entry* entry, bool create, const QString& groupName, Database* database);
|
void loadEntry(Entry* entry, bool create, const QString& groupName, Database* database);
|
||||||
|
|
||||||
static const QColor normalColor;
|
static const QColor NormalColor;
|
||||||
static const QColor correctSoFarColor;
|
static const QColor CorrectSoFarColor;
|
||||||
static const QColor errorColor;
|
static const QColor ErrorColor;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void editFinished(bool accepted);
|
void editFinished(bool accepted);
|
||||||
|
@ -87,7 +87,7 @@ void MainWindow::openDatabase(const QString& fileName, const QString& pw, const
|
|||||||
m_ui->tabWidget->openDatabase(fileName, pw, keyFile);
|
m_ui->tabWidget->openDatabase(fileName, pw, keyFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString MainWindow::m_baseWindowTitle = "KeePassX";
|
const QString MainWindow::BaseWindowTitle = "KeePassX";
|
||||||
|
|
||||||
void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
|
void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
|
||||||
{
|
{
|
||||||
@ -175,10 +175,10 @@ void MainWindow::updateWindowTitle()
|
|||||||
{
|
{
|
||||||
int index = m_ui->tabWidget->currentIndex();
|
int index = m_ui->tabWidget->currentIndex();
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
setWindowTitle(m_baseWindowTitle);
|
setWindowTitle(BaseWindowTitle);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setWindowTitle(m_ui->tabWidget->tabText(index).append(" - ").append(m_baseWindowTitle));
|
setWindowTitle(m_ui->tabWidget->tabText(index).append(" - ").append(BaseWindowTitle));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,8 +44,9 @@ private Q_SLOTS:
|
|||||||
void showAboutDialog();
|
void showAboutDialog();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static const QString BaseWindowTitle;
|
||||||
|
|
||||||
const QScopedPointer<Ui::MainWindow> m_ui;
|
const QScopedPointer<Ui::MainWindow> m_ui;
|
||||||
static const QString m_baseWindowTitle;
|
|
||||||
|
|
||||||
Q_DISABLE_COPY(MainWindow)
|
Q_DISABLE_COPY(MainWindow)
|
||||||
};
|
};
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include "core/Endian.h"
|
#include "core/Endian.h"
|
||||||
#include "crypto/CryptoHash.h"
|
#include "crypto/CryptoHash.h"
|
||||||
|
|
||||||
const QSysInfo::Endian HashedBlockStream::BYTEORDER = QSysInfo::LittleEndian;
|
const QSysInfo::Endian HashedBlockStream::ByteOrder = QSysInfo::LittleEndian;
|
||||||
|
|
||||||
HashedBlockStream::HashedBlockStream(QIODevice* baseDevice)
|
HashedBlockStream::HashedBlockStream(QIODevice* baseDevice)
|
||||||
: LayeredStream(baseDevice)
|
: LayeredStream(baseDevice)
|
||||||
@ -126,7 +126,7 @@ bool HashedBlockStream::readHashedBlock()
|
|||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
|
|
||||||
quint32 index = Endian::readUInt32(m_baseDevice, BYTEORDER, &ok);
|
quint32 index = Endian::readUInt32(m_baseDevice, ByteOrder, &ok);
|
||||||
if (!ok || index != m_blockIndex) {
|
if (!ok || index != m_blockIndex) {
|
||||||
m_error = true;
|
m_error = true;
|
||||||
return false;
|
return false;
|
||||||
@ -138,7 +138,7 @@ bool HashedBlockStream::readHashedBlock()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_blockSize = Endian::readInt32(m_baseDevice, BYTEORDER, &ok);
|
m_blockSize = Endian::readInt32(m_baseDevice, ByteOrder, &ok);
|
||||||
if (!ok || m_blockSize < 0) {
|
if (!ok || m_blockSize < 0) {
|
||||||
m_error = true;
|
m_error = true;
|
||||||
return false;
|
return false;
|
||||||
@ -207,7 +207,7 @@ qint64 HashedBlockStream::writeData(const char* data, qint64 maxSize)
|
|||||||
|
|
||||||
bool HashedBlockStream::writeHashedBlock()
|
bool HashedBlockStream::writeHashedBlock()
|
||||||
{
|
{
|
||||||
if (!Endian::writeInt32(m_blockIndex, m_baseDevice, BYTEORDER)) {
|
if (!Endian::writeInt32(m_blockIndex, m_baseDevice, ByteOrder)) {
|
||||||
m_error = true;
|
m_error = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -226,7 +226,7 @@ bool HashedBlockStream::writeHashedBlock()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Endian::writeInt32(m_buffer.size(), m_baseDevice, BYTEORDER)) {
|
if (!Endian::writeInt32(m_buffer.size(), m_baseDevice, ByteOrder)) {
|
||||||
m_error = true;
|
m_error = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ private:
|
|||||||
bool readHashedBlock();
|
bool readHashedBlock();
|
||||||
bool writeHashedBlock();
|
bool writeHashedBlock();
|
||||||
|
|
||||||
static const QSysInfo::Endian BYTEORDER;
|
static const QSysInfo::Endian ByteOrder;
|
||||||
qint32 m_blockSize;
|
qint32 m_blockSize;
|
||||||
QByteArray m_buffer;
|
QByteArray m_buffer;
|
||||||
int m_bufferPos;
|
int m_bufferPos;
|
||||||
|
Loading…
Reference in New Issue
Block a user