Add slot to update the timeinfo of an entry and connect it on modified signal.

This commit is contained in:
Florian Geyer 2012-04-17 01:02:02 +02:00 committed by Felix Geyer
parent 900420630d
commit ad865774d1
2 changed files with 15 additions and 6 deletions

View File

@ -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 <class T> bool Entry::set(T& property, const T& value) {
template <class T> 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 <class T> 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;
}

View File

@ -109,6 +109,7 @@ Q_SIGNALS:
private Q_SLOTS:
void emitDataChanged();
void updateTimeinfo();
private:
const Database* database() const;