File indexing completed on 2025-01-05 04:59:42
0001 /* 0002 * SPDX-FileCopyrightText: 2014 Kevin Ottens <ervin@kde.org> 0003 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 */ 0005 0006 #include "akonaditimestampattribute.h" 0007 0008 #include <QDateTime> 0009 0010 using namespace Akonadi; 0011 0012 TimestampAttribute::TimestampAttribute() 0013 : Attribute(), 0014 m_timestamp(0) 0015 { 0016 refreshTimestamp(); 0017 } 0018 0019 TimestampAttribute::~TimestampAttribute() 0020 { 0021 } 0022 0023 qint64 TimestampAttribute::timestamp() const 0024 { 0025 return m_timestamp; 0026 } 0027 0028 void TimestampAttribute::refreshTimestamp() 0029 { 0030 m_timestamp = QDateTime::currentMSecsSinceEpoch(); 0031 } 0032 0033 TimestampAttribute *TimestampAttribute::clone() const 0034 { 0035 auto attr = new TimestampAttribute(); 0036 attr->m_timestamp = m_timestamp; 0037 return attr; 0038 } 0039 0040 QByteArray TimestampAttribute::type() const 0041 { 0042 return "ZanshinTimestamp"; 0043 } 0044 0045 QByteArray TimestampAttribute::serialized() const 0046 { 0047 return QByteArray::number(m_timestamp); 0048 } 0049 0050 void TimestampAttribute::deserialize(const QByteArray &data) 0051 { 0052 m_timestamp = data.toLongLong(); 0053 }