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
89361b3bea
commit
b88a0d8de3
@ -362,43 +362,45 @@ void Entry::addHistoryItem(Entry* entry)
|
|||||||
|
|
||||||
void Entry::truncateHistory() {
|
void Entry::truncateHistory() {
|
||||||
const Database *db = database();
|
const Database *db = database();
|
||||||
if(db) {
|
|
||||||
int histMaxItems = db->metadata()->historyMaxItems();
|
if (!db) {
|
||||||
if (histMaxItems > -1) {
|
return;
|
||||||
int historyCount = 0;
|
}
|
||||||
QMutableListIterator<Entry*> i(m_history);
|
|
||||||
i.toBack();
|
int histMaxItems = db->metadata()->historyMaxItems();
|
||||||
while (i.hasPrevious()) {
|
if (histMaxItems > -1) {
|
||||||
historyCount++;
|
int historyCount = 0;
|
||||||
Entry* entry = i.previous();
|
QMutableListIterator<Entry*> i(m_history);
|
||||||
if (historyCount > histMaxItems) {
|
i.toBack();
|
||||||
delete entry;
|
while (i.hasPrevious()) {
|
||||||
i.remove();
|
historyCount++;
|
||||||
}
|
Entry* entry = i.previous();
|
||||||
|
if (historyCount > histMaxItems) {
|
||||||
|
delete entry;
|
||||||
|
i.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int histMaxSize = db->metadata()->historyMaxSize();
|
int histMaxSize = db->metadata()->historyMaxSize();
|
||||||
if (histMaxSize > -1) {
|
if (histMaxSize > -1) {
|
||||||
int size = 0;
|
int size = 0;
|
||||||
QList<QByteArray>* foundAttachements = new QList<QByteArray>();
|
QList<QByteArray>* foundAttachements = new QList<QByteArray>();
|
||||||
attachments()->attachmentsSize(foundAttachements);
|
attachments()->attachmentsSize(foundAttachements);
|
||||||
|
|
||||||
QMutableListIterator<Entry*> i(m_history);
|
QMutableListIterator<Entry*> i(m_history);
|
||||||
i.toBack();
|
i.toBack();
|
||||||
while (i.hasPrevious()) {
|
while (i.hasPrevious()) {
|
||||||
Entry* entry = i.previous();
|
Entry* entry = i.previous();
|
||||||
if (size > histMaxSize) {
|
|
||||||
delete entry;
|
// don't calculate size if it's already above the maximum
|
||||||
i.remove();
|
if (size <= histMaxSize) {
|
||||||
}
|
size += entry->getSize(foundAttachements);
|
||||||
else {
|
}
|
||||||
size += entry->getSize(foundAttachements);
|
|
||||||
if (size > histMaxSize) {
|
if (size > histMaxSize) {
|
||||||
delete entry;
|
delete entry;
|
||||||
i.remove();
|
i.remove();
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public:
|
|||||||
void set(const QString& key, const QByteArray& value);
|
void set(const QString& key, const QByteArray& value);
|
||||||
void remove(const QString& key);
|
void remove(const QString& key);
|
||||||
void clear();
|
void clear();
|
||||||
int attachmentsSize(QList<QByteArray> *foundAttachements);
|
int attachmentsSize(QList<QByteArray>* foundAttachements);
|
||||||
bool operator==(const EntryAttachments& other) const;
|
bool operator==(const EntryAttachments& other) const;
|
||||||
bool operator!=(const EntryAttachments& other) const;
|
bool operator!=(const EntryAttachments& other) const;
|
||||||
EntryAttachments& operator=(EntryAttachments& other);
|
EntryAttachments& operator=(EntryAttachments& other);
|
||||||
|
@ -92,7 +92,7 @@ bool readAllFromDevice(QIODevice* device, QByteArray& data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QDateTime currentDateTimeUtc ()
|
QDateTime currentDateTimeUtc()
|
||||||
{
|
{
|
||||||
#if QT_VERSION >= 0x040700
|
#if QT_VERSION >= 0x040700
|
||||||
return QDateTime::currentDateTimeUtc();
|
return QDateTime::currentDateTimeUtc();
|
||||||
|
@ -40,8 +40,8 @@ DatabaseSettingsWidget::~DatabaseSettingsWidget()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseSettingsWidget::setForms(QString dbName, QString dbDescription,
|
void DatabaseSettingsWidget::setForms(const QString& dbName, const QString& dbDescription,
|
||||||
QString defaultUsername, bool recylceBinEnabled,
|
const QString& defaultUsername, bool recylceBinEnabled,
|
||||||
int transformRounds, int historyMaxItems,
|
int transformRounds, int historyMaxItems,
|
||||||
int historyMaxSize)
|
int historyMaxSize)
|
||||||
{
|
{
|
||||||
@ -162,7 +162,6 @@ void DatabaseSettingsWidget::toggleHistoryMaxSizeSpinBox(int state)
|
|||||||
else {
|
else {
|
||||||
m_ui->historyMaxSizeSpinBox->setEnabled(false);
|
m_ui->historyMaxSizeSpinBox->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseSettingsWidget::transformRoundsBenchmark()
|
void DatabaseSettingsWidget::transformRoundsBenchmark()
|
||||||
|
@ -36,8 +36,8 @@ public:
|
|||||||
explicit DatabaseSettingsWidget(QWidget* parent = 0);
|
explicit DatabaseSettingsWidget(QWidget* parent = 0);
|
||||||
~DatabaseSettingsWidget();
|
~DatabaseSettingsWidget();
|
||||||
|
|
||||||
void setForms(QString dbName, QString dbDescription,
|
void setForms(const QString& dbName, const QString& dbDescription,
|
||||||
QString defaultUsername, bool recylceBinEnabled,
|
const QString& defaultUsername, bool recylceBinEnabled,
|
||||||
int transformRounds, int historyMaxItems,
|
int transformRounds, int historyMaxItems,
|
||||||
int historyMaxSize);
|
int historyMaxSize);
|
||||||
quint64 transformRounds();
|
quint64 transformRounds();
|
||||||
|
@ -79,6 +79,8 @@ private Q_SLOTS:
|
|||||||
void emitCurrentModeChanged();
|
void emitCurrentModeChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void truncateHistories();
|
||||||
|
|
||||||
Database* const m_db;
|
Database* const m_db;
|
||||||
QWidget* m_mainWidget;
|
QWidget* m_mainWidget;
|
||||||
EditEntryWidget* m_editEntryWidget;
|
EditEntryWidget* m_editEntryWidget;
|
||||||
@ -91,8 +93,6 @@ private:
|
|||||||
Entry* m_newEntry;
|
Entry* m_newEntry;
|
||||||
Group* m_newParent;
|
Group* m_newParent;
|
||||||
QLineEdit* m_searchEdit;
|
QLineEdit* m_searchEdit;
|
||||||
|
|
||||||
void truncateHistories();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEEPASSX_DATABASEWIDGET_H
|
#endif // KEEPASSX_DATABASEWIDGET_H
|
||||||
|
@ -61,7 +61,7 @@ void EntryModel::setGroup(Group* group)
|
|||||||
Q_EMIT switchedToView();
|
Q_EMIT switchedToView();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntryModel::setEntries(QList<Entry*> entries)
|
void EntryModel::setEntries(const QList<Entry*>& entries)
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ public:
|
|||||||
QStringList mimeTypes() const;
|
QStringList mimeTypes() const;
|
||||||
QMimeData* mimeData(const QModelIndexList& indexes) const;
|
QMimeData* mimeData(const QModelIndexList& indexes) const;
|
||||||
|
|
||||||
void setEntries(QList<Entry*> entries);
|
void setEntries(const QList<Entry*>& entries);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void switchedToSearch();
|
void switchedToSearch();
|
||||||
@ -58,12 +58,12 @@ private Q_SLOTS:
|
|||||||
void entryDataChanged(Entry* entry);
|
void entryDataChanged(Entry* entry);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void severConnections();
|
||||||
|
void makeConnections(const Group* group);
|
||||||
|
|
||||||
Group* m_group;
|
Group* m_group;
|
||||||
QList<Entry*> m_entries;
|
QList<Entry*> m_entries;
|
||||||
QList<const Group*> m_allGroups;
|
QList<const Group*> m_allGroups;
|
||||||
|
|
||||||
void severConnections();
|
|
||||||
void makeConnections(const Group* group);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEEPASSX_ENTRYMODEL_H
|
#endif // KEEPASSX_ENTRYMODEL_H
|
||||||
|
@ -53,7 +53,7 @@ void EntryView::setGroup(Group* group)
|
|||||||
Q_EMIT entrySelectionChanged();
|
Q_EMIT entrySelectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntryView::search(QList<Entry*> entries)
|
void EntryView::search(const QList<Entry*>& entries)
|
||||||
{
|
{
|
||||||
m_model->setEntries(entries);
|
m_model->setEntries(entries);
|
||||||
Q_EMIT entrySelectionChanged();
|
Q_EMIT entrySelectionChanged();
|
||||||
|
@ -36,7 +36,7 @@ public:
|
|||||||
bool isSingleEntrySelected();
|
bool isSingleEntrySelected();
|
||||||
void setCurrentEntry(Entry* entry);
|
void setCurrentEntry(Entry* entry);
|
||||||
Entry* entryFromIndex(const QModelIndex& index);
|
Entry* entryFromIndex(const QModelIndex& index);
|
||||||
void search(QList<Entry *> entries);
|
void search(const QList<Entry*>& entries);
|
||||||
bool inSearch();
|
bool inSearch();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
|
@ -54,7 +54,7 @@ CustomIconModel::CustomIconModel(QObject* parent) :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomIconModel::setIcons(QHash<Uuid, QImage> icons, QList<Uuid> iconsOrder)
|
void CustomIconModel::setIcons(const QHash<Uuid, QImage>& icons, const QList<Uuid>& iconsOrder)
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public:
|
|||||||
|
|
||||||
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
||||||
virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
||||||
void setIcons(QHash<Uuid, QImage> icons, QList<Uuid> iconsOrder);
|
void setIcons(const QHash<Uuid, QImage>& icons, const QList<Uuid>& iconsOrder);
|
||||||
Uuid uuidFromIndex(const QModelIndex& index) const;
|
Uuid uuidFromIndex(const QModelIndex& index) const;
|
||||||
QModelIndex indexFromUuid(const Uuid& uuid) const;
|
QModelIndex indexFromUuid(const Uuid& uuid) const;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user