From d73cbafb8e83f2c9f15449b9e7f69adc95a52b22 Mon Sep 17 00:00:00 2001 From: Florian Geyer Date: Tue, 17 Apr 2012 22:43:21 +0200 Subject: [PATCH] Add slot to update the timeinfo of a group and connect it on modified signal. Connect modified signal of entries directly to database, so timeinfo of group is not updated. --- src/core/Group.cpp | 16 +++++++++++----- src/core/Group.h | 3 +++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/core/Group.cpp b/src/core/Group.cpp index dd08bf8a5..4e8292164 100644 --- a/src/core/Group.cpp +++ b/src/core/Group.cpp @@ -35,6 +35,8 @@ Group::Group() m_searchingEnabled = Inherit; m_updateTimeinfo = true; + + connect(this, SIGNAL(modified()), this, SLOT(updateTimeinfo())); } Group::~Group() @@ -45,10 +47,6 @@ Group::~Group() template bool Group::set(T& property, const T& value) { if (property != value) { property = value; - if (m_updateTimeinfo) { - m_timeInfo.setLastModificationTime(QDateTime::currentDateTimeUtc()); - m_timeInfo.setLastAccessTime(QDateTime::currentDateTimeUtc()); - } Q_EMIT modified(); return true; } @@ -57,6 +55,14 @@ template bool Group::set(T& property, const T& value) { } } +void Group::updateTimeinfo() +{ + if (m_updateTimeinfo) { + m_timeInfo.setLastModificationTime(QDateTime::currentDateTimeUtc()); + m_timeInfo.setLastAccessTime(QDateTime::currentDateTimeUtc()); + } +} + void Group::setUpdateTimeinfo(bool value) { m_updateTimeinfo = value; } @@ -304,7 +310,7 @@ void Group::addEntry(Entry *entry) m_entries << entry; connect(entry, SIGNAL(dataChanged(Entry*)), SIGNAL(entryDataChanged(Entry*))); - connect(entry, SIGNAL(modified()), this, SIGNAL(modified())); + connect(entry, SIGNAL(modified()), m_db, SIGNAL(modified())); Q_EMIT modified(); Q_EMIT entryAdded(); diff --git a/src/core/Group.h b/src/core/Group.h index af674bcee..1207cebf6 100644 --- a/src/core/Group.h +++ b/src/core/Group.h @@ -92,6 +92,9 @@ Q_SIGNALS: void modified(); +private Q_SLOTS: + void updateTimeinfo(); + private: template inline bool set(T& property, const T& value);