compile with QT < 4.7 (RHEL6 an clones)

This commit is contained in:
Andreas Piesk 2012-05-09 20:29:21 +02:00 committed by Florian Geyer
parent 93a868a571
commit 7568582b05
9 changed files with 33 additions and 15 deletions

View File

@ -15,7 +15,7 @@
project(KeePassX) project(KeePassX)
cmake_minimum_required(VERSION 2.8.0) cmake_minimum_required(VERSION 2.6.4)
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake ) set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake )

View File

@ -22,6 +22,7 @@
#include "core/Group.h" #include "core/Group.h"
#include "core/Metadata.h" #include "core/Metadata.h"
#include "core/Tools.h"
#include "crypto/Random.h" #include "crypto/Random.h"
#include "format/KeePass2.h" #include "format/KeePass2.h"
@ -133,7 +134,7 @@ void Database::addDeletedObject(const DeletedObject& delObj)
void Database::addDeletedObject(const Uuid& uuid) void Database::addDeletedObject(const Uuid& uuid)
{ {
DeletedObject delObj; DeletedObject delObj;
delObj.deletionTime = QDateTime::currentDateTimeUtc(); delObj.deletionTime = Tools::currentDateTimeUtc();
delObj.uuid = uuid; delObj.uuid = uuid;
addDeletedObject(delObj); addDeletedObject(delObj);
@ -190,7 +191,7 @@ void Database::setKey(const CompositeKey& key, const QByteArray& transformSeed,
m_transformedMasterKey = key.transform(transformSeed, transformRounds()); m_transformedMasterKey = key.transform(transformSeed, transformRounds());
m_hasKey = true; m_hasKey = true;
if (updateChangedTime) { if (updateChangedTime) {
m_metadata->setMasterKeyChanged(QDateTime::currentDateTimeUtc()); m_metadata->setMasterKeyChanged(Tools::currentDateTimeUtc());
} }
Q_EMIT modified(); Q_EMIT modified();
} }
@ -205,7 +206,7 @@ void Database::updateKey(quint64 rounds)
if (m_transformRounds != rounds) { if (m_transformRounds != rounds) {
m_transformRounds = rounds; m_transformRounds = rounds;
m_transformedMasterKey = m_key.transform(m_transformSeed, transformRounds()); m_transformedMasterKey = m_key.transform(m_transformSeed, transformRounds());
m_metadata->setMasterKeyChanged(QDateTime::currentDateTimeUtc()); m_metadata->setMasterKeyChanged(Tools::currentDateTimeUtc());
Q_EMIT modified(); Q_EMIT modified();
} }
} }

View File

@ -21,6 +21,7 @@
#include "core/DatabaseIcons.h" #include "core/DatabaseIcons.h"
#include "core/Group.h" #include "core/Group.h"
#include "core/Metadata.h" #include "core/Metadata.h"
#include "core/Tools.h"
Entry::Entry() Entry::Entry()
{ {
@ -70,8 +71,8 @@ template <class T> bool Entry::set(T& property, const T& value)
void Entry::updateTimeinfo() void Entry::updateTimeinfo()
{ {
if (m_updateTimeinfo) { if (m_updateTimeinfo) {
m_data.timeInfo.setLastModificationTime(QDateTime::currentDateTimeUtc()); m_data.timeInfo.setLastModificationTime(Tools::currentDateTimeUtc());
m_data.timeInfo.setLastAccessTime(QDateTime::currentDateTimeUtc()); m_data.timeInfo.setLastAccessTime(Tools::currentDateTimeUtc());
} }
} }
@ -419,7 +420,7 @@ void Entry::setGroup(Group* group)
QObject::setParent(group); QObject::setParent(group);
if (m_updateTimeinfo) { if (m_updateTimeinfo) {
m_data.timeInfo.setLocationChanged(QDateTime::currentDateTimeUtc()); m_data.timeInfo.setLocationChanged(Tools::currentDateTimeUtc());
} }
} }

View File

@ -19,6 +19,7 @@
#include "core/DatabaseIcons.h" #include "core/DatabaseIcons.h"
#include "core/Metadata.h" #include "core/Metadata.h"
#include "core/Tools.h"
Group::Group() Group::Group()
{ {
@ -48,7 +49,7 @@ Group::~Group()
} }
DeletedObject delGroup; DeletedObject delGroup;
delGroup.deletionTime = QDateTime::currentDateTimeUtc(); delGroup.deletionTime = Tools::currentDateTimeUtc();
delGroup.uuid = m_uuid; delGroup.uuid = m_uuid;
m_db->addDeletedObject(delGroup); m_db->addDeletedObject(delGroup);
} }
@ -69,8 +70,8 @@ template <class P, class V> bool Group::set(P& property, const V& value) {
void Group::updateTimeinfo() void Group::updateTimeinfo()
{ {
if (m_updateTimeinfo) { if (m_updateTimeinfo) {
m_timeInfo.setLastModificationTime(QDateTime::currentDateTimeUtc()); m_timeInfo.setLastModificationTime(Tools::currentDateTimeUtc());
m_timeInfo.setLastAccessTime(QDateTime::currentDateTimeUtc()); m_timeInfo.setLastAccessTime(Tools::currentDateTimeUtc());
} }
} }
@ -302,7 +303,7 @@ void Group::setParent(Group* parent, int index)
} }
if (m_updateTimeinfo) { if (m_updateTimeinfo) {
m_timeInfo.setLocationChanged(QDateTime::currentDateTimeUtc()); m_timeInfo.setLocationChanged(Tools::currentDateTimeUtc());
} }
Q_EMIT modified(); Q_EMIT modified();

View File

@ -20,6 +20,7 @@
#include "core/Database.h" #include "core/Database.h"
#include "core/Entry.h" #include "core/Entry.h"
#include "core/Group.h" #include "core/Group.h"
#include "core/Tools.h"
Metadata::Metadata(Database* parent) Metadata::Metadata(Database* parent)
: QObject(parent) : QObject(parent)
@ -33,7 +34,7 @@ Metadata::Metadata(Database* parent)
m_historyMaxItems = 10; m_historyMaxItems = 10;
m_historyMaxSize = 6291456; m_historyMaxSize = 6291456;
QDateTime now = QDateTime::currentDateTimeUtc(); QDateTime now = Tools::currentDateTimeUtc();
m_nameChanged = now; m_nameChanged = now;
m_descriptionChanged = now; m_descriptionChanged = now;
m_defaultUserNameChanged = now; m_defaultUserNameChanged = now;
@ -67,7 +68,7 @@ template <class P, class V> bool Metadata::set(P& property, const V& value, QDat
if (property != value) { if (property != value) {
property = value; property = value;
if (m_updateDatetime) { if (m_updateDatetime) {
dateTime = QDateTime::currentDateTimeUtc(); dateTime = Tools::currentDateTimeUtc();
} }
Q_EMIT modified(); Q_EMIT modified();
return true; return true;

View File

@ -17,12 +17,14 @@
#include "TimeInfo.h" #include "TimeInfo.h"
#include "core/Tools.h"
TimeInfo::TimeInfo() TimeInfo::TimeInfo()
{ {
m_expires = false; m_expires = false;
m_usageCount = 0; m_usageCount = 0;
QDateTime now = QDateTime::currentDateTimeUtc(); QDateTime now = Tools::currentDateTimeUtc();
m_lastModificationTime = now; m_lastModificationTime = now;
m_creationTime = now; m_creationTime = now;
m_lastAccessTime = now; m_lastAccessTime = now;

View File

@ -75,4 +75,13 @@ bool readAllFromDevice(QIODevice* device, QByteArray& data)
} }
} }
QDateTime currentDateTimeUtc ()
{
#if QT_VERSION >= 0x040700
return QDateTime::currentDateTimeUtc();
#else
return QDateTime::currentDateTime().toUTC();
#endif
}
} // namespace Tools } // namespace Tools

View File

@ -20,6 +20,7 @@
#include <QtCore/QObject> #include <QtCore/QObject>
#include <QtCore/QString> #include <QtCore/QString>
#include <QtCore/QDateTime>
class QIODevice; class QIODevice;
@ -28,6 +29,7 @@ namespace Tools {
QString humanReadableFileSize(qint64 bytes); QString humanReadableFileSize(qint64 bytes);
bool hasChild(const QObject* parent, const QObject* child); bool hasChild(const QObject* parent, const QObject* child);
bool readAllFromDevice(QIODevice* device, QByteArray& data); bool readAllFromDevice(QIODevice* device, QByteArray& data);
QDateTime currentDateTimeUtc();
} // namespace Tools } // namespace Tools

View File

@ -23,6 +23,7 @@
#include "tests.h" #include "tests.h"
#include "core/Database.h" #include "core/Database.h"
#include "core/Group.h" #include "core/Group.h"
#include "core/Tools.h"
#include "crypto/Crypto.h" #include "crypto/Crypto.h"
void TestModified::initTestCase() void TestModified::initTestCase()
@ -233,7 +234,7 @@ void TestModified::testEntrySets()
entry->setExpires(entry->timeInfo().expires()); entry->setExpires(entry->timeInfo().expires());
QCOMPARE(spyModified.count(), spyCount); QCOMPARE(spyModified.count(), spyCount);
entry->setExpiryTime(QDateTime::currentDateTimeUtc().addYears(1)); entry->setExpiryTime(Tools::currentDateTimeUtc().addYears(1));
QCOMPARE(spyModified.count(), ++spyCount); QCOMPARE(spyModified.count(), ++spyCount);
entry->setExpiryTime(entry->timeInfo().expiryTime()); entry->setExpiryTime(entry->timeInfo().expiryTime());
QCOMPARE(spyModified.count(), spyCount); QCOMPARE(spyModified.count(), spyCount);