forked from keepassxreboot/keepassxc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create history-based merging that keeps older data in history instead of discarding or deleting it * Extract merge logic into the Merger class * Allows special merge behavior * Improve handling of deletion and changes on groups * Enable basic change tracking while merging * Prevent unintended timestamp changes while merging * Handle differences in timestamp precision * Introduce comparison operators to allow for more sophisticated comparisons (ignore special properties, ...) * Introduce Clock class to handle datetime across the app Merge Strategies: * Default (use inherited/fallback method) * Duplicate (duplicate conflicting nodes, apply all deletions) * KeepLocal (use local values, but apply all deletions) * KeepRemote (use remote values, but apply all deletions) * KeepNewer (merge history only) * Synchronize (merge history, newest value stays on top, apply all deletions)
- Loading branch information
1 parent
b40e568
commit c1e9f45
Showing
43 changed files
with
2,779 additions
and
587 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
* Copyright (C) 2018 KeePassXC Team <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 2 or (at your option) | ||
* version 3 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#include "Clock.h" | ||
|
||
QSharedPointer<Clock> Clock::m_instance = QSharedPointer<Clock>(); | ||
|
||
QDateTime Clock::currentDateTimeUtc() | ||
{ | ||
return instance().currentDateTimeUtcImpl(); | ||
} | ||
|
||
QDateTime Clock::currentDateTime() | ||
{ | ||
return instance().currentDateTimeImpl(); | ||
} | ||
|
||
uint Clock::currentSecondsSinceEpoch() | ||
{ | ||
return instance().currentDateTimeImpl().toTime_t(); | ||
} | ||
|
||
QDateTime Clock::serialized(const QDateTime& dateTime) | ||
{ | ||
auto time = dateTime.time(); | ||
if (time.isValid() && time.msec() != 0) { | ||
return dateTime.addMSecs(-time.msec()); | ||
} | ||
return dateTime; | ||
} | ||
|
||
QDateTime Clock::datetimeUtc(int year, int month, int day, int hour, int min, int second) | ||
{ | ||
return QDateTime(QDate(year, month, day), QTime(hour, min, second), Qt::UTC); | ||
} | ||
|
||
QDateTime Clock::datetime(int year, int month, int day, int hour, int min, int second) | ||
{ | ||
return QDateTime(QDate(year, month, day), QTime(hour, min, second), Qt::LocalTime); | ||
} | ||
|
||
QDateTime Clock::datetimeUtc(qint64 msecSinceEpoch) | ||
{ | ||
return QDateTime::fromMSecsSinceEpoch(msecSinceEpoch, Qt::UTC); | ||
} | ||
|
||
QDateTime Clock::datetime(qint64 msecSinceEpoch) | ||
{ | ||
return QDateTime::fromMSecsSinceEpoch(msecSinceEpoch, Qt::LocalTime); | ||
} | ||
|
||
QDateTime Clock::parse(const QString& text, Qt::DateFormat format) | ||
{ | ||
return QDateTime::fromString(text, format); | ||
} | ||
|
||
QDateTime Clock::parse(const QString& text, const QString& format) | ||
{ | ||
return QDateTime::fromString(text, format); | ||
} | ||
|
||
Clock::~Clock() | ||
{ | ||
} | ||
|
||
Clock::Clock() | ||
{ | ||
} | ||
|
||
QDateTime Clock::currentDateTimeUtcImpl() const | ||
{ | ||
return QDateTime::currentDateTimeUtc(); | ||
} | ||
|
||
QDateTime Clock::currentDateTimeImpl() const | ||
{ | ||
return QDateTime::currentDateTime(); | ||
} | ||
|
||
void Clock::resetInstance() | ||
{ | ||
m_instance.clear(); | ||
} | ||
|
||
void Clock::setInstance(Clock* clock) | ||
{ | ||
m_instance = QSharedPointer<Clock>(clock); | ||
} | ||
|
||
const Clock& Clock::instance() | ||
{ | ||
if (!m_instance) { | ||
m_instance = QSharedPointer<Clock>(new Clock()); | ||
} | ||
return *m_instance; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (C) 2018 KeePassXC Team <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 2 or (at your option) | ||
* version 3 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef KEEPASSXC_CLOCK_H | ||
#define KEEPASSXC_CLOCK_H | ||
|
||
#include <QDateTime> | ||
#include <QSharedPointer> | ||
|
||
class Clock | ||
{ | ||
public: | ||
static QDateTime currentDateTimeUtc(); | ||
static QDateTime currentDateTime(); | ||
|
||
static uint currentSecondsSinceEpoch(); | ||
|
||
static QDateTime serialized(const QDateTime& dateTime); | ||
|
||
static QDateTime datetimeUtc(int year, int month, int day, int hour, int min, int second); | ||
static QDateTime datetime(int year, int month, int day, int hour, int min, int second); | ||
|
||
static QDateTime datetimeUtc(qint64 msecSinceEpoch); | ||
static QDateTime datetime(qint64 msecSinceEpoch); | ||
|
||
static QDateTime parse(const QString& text, Qt::DateFormat format = Qt::TextDate); | ||
static QDateTime parse(const QString& text, const QString& format); | ||
|
||
virtual ~Clock(); | ||
|
||
protected: | ||
Clock(); | ||
virtual QDateTime currentDateTimeUtcImpl() const; | ||
virtual QDateTime currentDateTimeImpl() const; | ||
|
||
static void resetInstance(); | ||
static void setInstance(Clock* clock); | ||
static const Clock& instance(); | ||
|
||
private: | ||
static QSharedPointer<Clock> m_instance; | ||
}; | ||
|
||
#endif // KEEPASSX_ENTRY_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (C) 2018 KeePassXC Team <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 2 or (at your option) | ||
* version 3 of the License. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#include "Compare.h" | ||
|
||
#include <QColor> | ||
|
||
bool operator<(const QColor& lhs, const QColor& rhs) | ||
{ | ||
const QColor adaptedLhs = lhs.toCmyk(); | ||
const QColor adaptedRhs = rhs.toCmyk(); | ||
const int iCyan = compare(adaptedLhs.cyanF(), adaptedRhs.cyanF()); | ||
if (iCyan != 0) { | ||
return iCyan; | ||
} | ||
const int iMagenta = compare(adaptedLhs.magentaF(), adaptedRhs.magentaF()); | ||
if (iMagenta != 0) { | ||
return iMagenta; | ||
} | ||
const int iYellow = compare(adaptedLhs.yellowF(), adaptedRhs.yellowF()); | ||
if (iYellow != 0) { | ||
return iYellow; | ||
} | ||
return compare(adaptedLhs.blackF(), adaptedRhs.blackF()) < 0; | ||
} |
Oops, something went wrong.