Coding style improvements.
This commit is contained in:
@@ -362,43 +362,45 @@ void Entry::addHistoryItem(Entry* entry)
|
||||
|
||||
void Entry::truncateHistory() {
|
||||
const Database *db = database();
|
||||
if(db) {
|
||||
int histMaxItems = db->metadata()->historyMaxItems();
|
||||
if (histMaxItems > -1) {
|
||||
int historyCount = 0;
|
||||
QMutableListIterator<Entry*> i(m_history);
|
||||
i.toBack();
|
||||
while (i.hasPrevious()) {
|
||||
historyCount++;
|
||||
Entry* entry = i.previous();
|
||||
if (historyCount > histMaxItems) {
|
||||
delete entry;
|
||||
i.remove();
|
||||
}
|
||||
|
||||
if (!db) {
|
||||
return;
|
||||
}
|
||||
|
||||
int histMaxItems = db->metadata()->historyMaxItems();
|
||||
if (histMaxItems > -1) {
|
||||
int historyCount = 0;
|
||||
QMutableListIterator<Entry*> i(m_history);
|
||||
i.toBack();
|
||||
while (i.hasPrevious()) {
|
||||
historyCount++;
|
||||
Entry* entry = i.previous();
|
||||
if (historyCount > histMaxItems) {
|
||||
delete entry;
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int histMaxSize = db->metadata()->historyMaxSize();
|
||||
if (histMaxSize > -1) {
|
||||
int size = 0;
|
||||
QList<QByteArray>* foundAttachements = new QList<QByteArray>();
|
||||
attachments()->attachmentsSize(foundAttachements);
|
||||
int histMaxSize = db->metadata()->historyMaxSize();
|
||||
if (histMaxSize > -1) {
|
||||
int size = 0;
|
||||
QList<QByteArray>* foundAttachements = new QList<QByteArray>();
|
||||
attachments()->attachmentsSize(foundAttachements);
|
||||
|
||||
QMutableListIterator<Entry*> i(m_history);
|
||||
i.toBack();
|
||||
while (i.hasPrevious()) {
|
||||
Entry* entry = i.previous();
|
||||
if (size > histMaxSize) {
|
||||
delete entry;
|
||||
i.remove();
|
||||
}
|
||||
else {
|
||||
size += entry->getSize(foundAttachements);
|
||||
if (size > histMaxSize) {
|
||||
delete entry;
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
QMutableListIterator<Entry*> i(m_history);
|
||||
i.toBack();
|
||||
while (i.hasPrevious()) {
|
||||
Entry* entry = i.previous();
|
||||
|
||||
// don't calculate size if it's already above the maximum
|
||||
if (size <= histMaxSize) {
|
||||
size += entry->getSize(foundAttachements);
|
||||
}
|
||||
|
||||
if (size > histMaxSize) {
|
||||
delete entry;
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
void set(const QString& key, const QByteArray& value);
|
||||
void remove(const QString& key);
|
||||
void clear();
|
||||
int attachmentsSize(QList<QByteArray> *foundAttachements);
|
||||
int attachmentsSize(QList<QByteArray>* foundAttachements);
|
||||
bool operator==(const EntryAttachments& other) const;
|
||||
bool operator!=(const EntryAttachments& other) const;
|
||||
EntryAttachments& operator=(EntryAttachments& other);
|
||||
|
||||
@@ -92,7 +92,7 @@ bool readAllFromDevice(QIODevice* device, QByteArray& data)
|
||||
}
|
||||
}
|
||||
|
||||
QDateTime currentDateTimeUtc ()
|
||||
QDateTime currentDateTimeUtc()
|
||||
{
|
||||
#if QT_VERSION >= 0x040700
|
||||
return QDateTime::currentDateTimeUtc();
|
||||
|
||||
Reference in New Issue
Block a user