From ad865774d19516ee7366113c8e8dc4479cd5c142 Mon Sep 17 00:00:00 2001 From: Florian Geyer Date: Tue, 17 Apr 2012 01:02:02 +0200 Subject: [PATCH] Add slot to update the timeinfo of an entry and connect it on modified signal. --- src/core/Entry.cpp | 20 ++++++++++++++------ src/core/Entry.h | 1 + 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/core/Entry.cpp b/src/core/Entry.cpp index 2fc482682..5d21623bd 100644 --- a/src/core/Entry.cpp +++ b/src/core/Entry.cpp @@ -37,6 +37,7 @@ Entry::Entry() m_attachments = new EntryAttachments(this); connect(m_attachments, SIGNAL(modified()), this, SIGNAL(modified())); + connect(this, SIGNAL(modified()), this, SLOT(updateTimeinfo())); } Entry::~Entry() @@ -48,13 +49,10 @@ Entry::~Entry() qDeleteAll(m_history); } -template bool Entry::set(T& property, const T& value) { +template bool Entry::set(T& property, const T& value) +{ if (property != value) { property = value; - if (m_updateTimeinfo) { - m_timeInfo.setLastModificationTime(QDateTime::currentDateTime()); - m_timeInfo.setLastAccessTime(QDateTime::currentDateTime()); - } Q_EMIT modified(); return true; } @@ -63,7 +61,17 @@ template bool Entry::set(T& property, const T& value) { } } -void Entry::setUpdateTimeinfo(bool value) { +void Entry::updateTimeinfo() +{ + if (m_updateTimeinfo) { + m_timeInfo.setLastModificationTime(QDateTime::currentDateTime()); + m_timeInfo.setLastAccessTime(QDateTime::currentDateTime()); + } +} + + +void Entry::setUpdateTimeinfo(bool value) +{ m_updateTimeinfo = value; } diff --git a/src/core/Entry.h b/src/core/Entry.h index 36df4c080..bcfa10dc9 100644 --- a/src/core/Entry.h +++ b/src/core/Entry.h @@ -109,6 +109,7 @@ Q_SIGNALS: private Q_SLOTS: void emitDataChanged(); + void updateTimeinfo(); private: const Database* database() const;