зеркало из https://github.com/nextcloud/desktop.git
Add datetime msecs property to datefieldbackend
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Родитель
3717558cf0
Коммит
eb66f51a92
|
@ -33,5 +33,21 @@ void DateFieldBackend::setDateTime(const QDateTime &dateTime)
|
|||
m_dateTime = dateTime;
|
||||
Q_EMIT dateTimeChanged();
|
||||
}
|
||||
|
||||
qint64 DateFieldBackend::dateTimeMsecs() const
|
||||
{
|
||||
return m_dateTime.toMSecsSinceEpoch();
|
||||
}
|
||||
|
||||
void DateFieldBackend::setDateTimeMsecs(const qint64 dateTimeMsecs)
|
||||
{
|
||||
if (m_dateTime.toMSecsSinceEpoch() == dateTimeMsecs) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto dt = QDateTime::fromMSecsSinceEpoch(dateTimeMsecs);
|
||||
setDateTime(dt);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -27,14 +27,17 @@ class DateFieldBackend : public QObject
|
|||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QDateTime dateTime READ dateTime WRITE setDateTime NOTIFY dateTimeChanged)
|
||||
Q_PROPERTY(qint64 dateTimeMsecs READ dateTimeMsecs WRITE setDateTimeMsecs NOTIFY dateTimeChanged)
|
||||
|
||||
public:
|
||||
explicit DateFieldBackend() = default;
|
||||
|
||||
[[nodiscard]] QDateTime dateTime() const;
|
||||
[[nodiscard]] qint64 dateTimeMsecs() const;
|
||||
|
||||
public slots:
|
||||
void setDateTime(const QDateTime &dateTime);
|
||||
void setDateTimeMsecs(const qint64 dateTimeMsecs);
|
||||
|
||||
signals:
|
||||
void dateTimeChanged();
|
||||
|
|
Загрузка…
Ссылка в новой задаче