2
* Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation, either version 2 or (at your option)
7
* version 3 of the License.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
24
QDateTime now = Clock::currentDateTimeUtc();
25
m_lastModificationTime = now;
27
m_lastAccessTime = now;
29
m_locationChanged = now;
32
QDateTime TimeInfo::lastModificationTime() const
34
return m_lastModificationTime;
37
QDateTime TimeInfo::creationTime() const
39
return m_creationTime;
42
QDateTime TimeInfo::lastAccessTime() const
44
return m_lastAccessTime;
47
QDateTime TimeInfo::expiryTime() const
52
bool TimeInfo::expires() const
57
int TimeInfo::usageCount() const
62
QDateTime TimeInfo::locationChanged() const
64
return m_locationChanged;
67
void TimeInfo::setLastModificationTime(const QDateTime& dateTime)
69
Q_ASSERT(dateTime.timeSpec() == Qt::UTC);
70
m_lastModificationTime = dateTime;
73
void TimeInfo::setCreationTime(const QDateTime& dateTime)
75
Q_ASSERT(dateTime.timeSpec() == Qt::UTC);
76
m_creationTime = dateTime;
79
void TimeInfo::setLastAccessTime(const QDateTime& dateTime)
81
Q_ASSERT(dateTime.timeSpec() == Qt::UTC);
82
m_lastAccessTime = dateTime;
85
void TimeInfo::setExpiryTime(const QDateTime& dateTime)
87
Q_ASSERT(dateTime.timeSpec() == Qt::UTC);
88
m_expiryTime = dateTime;
91
void TimeInfo::setExpires(bool expires)
96
void TimeInfo::setUsageCount(int count)
101
void TimeInfo::setLocationChanged(const QDateTime& dateTime)
103
Q_ASSERT(dateTime.timeSpec() == Qt::UTC);
104
m_locationChanged = dateTime;
107
bool TimeInfo::operator==(const TimeInfo& other) const
109
return equals(other, CompareItemDefault);
112
bool TimeInfo::operator!=(const TimeInfo& other) const
114
return !this->operator==(other);
117
bool TimeInfo::equals(const TimeInfo& other, CompareItemOptions options) const
120
if (::compare(m_lastModificationTime, other.m_lastModificationTime, options) != 0) {
123
if (::compare(m_creationTime, other.m_creationTime, options) != 0) {
126
if (::compare(!options.testFlag(CompareItemIgnoreStatistics), m_lastAccessTime, other.m_lastAccessTime, options) != 0) {
129
if (::compare(m_expires, m_expiryTime, other.m_expires, other.expiryTime(), options) != 0) {
132
if (::compare(!options.testFlag(CompareItemIgnoreStatistics), m_usageCount, other.m_usageCount, options) != 0) {
135
if (::compare(!options.testFlag(CompareItemIgnoreLocation), m_locationChanged, other.m_locationChanged, options) != 0) {