From 6bda9c4c1be730e8a6ac7ab8b4f5297a94cf52b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20L=C3=B3pez=20Zubieta?= Date: Sat, 4 Nov 2017 13:02:27 -0600 Subject: [PATCH] Fix wrong date texts in the UI. --- src/CredentialModel.cpp | 16 ++++++++-------- src/CredentialModel.h | 2 +- src/CredentialsManagement.cpp | 4 ++-- src/CredentialsManagement.ui | 4 ++-- src/LoginItem.cpp | 6 +++--- src/TreeItem.cpp | 20 ++++++++++---------- src/TreeItem.h | 6 +++--- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/CredentialModel.cpp b/src/CredentialModel.cpp index fc9e98cd..e4121b95 100644 --- a/src/CredentialModel.cpp +++ b/src/CredentialModel.cpp @@ -187,11 +187,11 @@ void CredentialModel::load(const QJsonArray &json) // Update login item created date QDate dCreatedDate = QDate::fromString(cnode["date_created"].toString(), Qt::ISODate); - pLoginItem->setCreatedDate(dCreatedDate); + pLoginItem->setUpdatedDate(dCreatedDate); // Update login item updated date QDate dUpdatedDate = QDate::fromString(cnode["date_last_used"].toString(), Qt::ISODate); - pLoginItem->setUpdatedDate(dUpdatedDate); + pLoginItem->setAccessedDate(dUpdatedDate); QJsonArray a = cnode["address"].toArray(); if (a.size() < 2) @@ -301,22 +301,22 @@ void CredentialModel::updateLoginItem(const QModelIndex &idx, const ItemRole &ro } break; } - case DateCreatedRole: + case DateUpdatedRole: { QDate dDate = vValue.toDate(); - if (dDate != pLoginItem->createdDate()) + if (dDate != pLoginItem->updatedDate()) { - pLoginItem->setCreatedDate(dDate); + pLoginItem->setUpdatedDate(dDate); bChanged = true; } break; } - case DateUpdatedRole: + case DateAccessedRole: { QDate dDate = vValue.toDate(); - if (dDate != pLoginItem->updatedDate()) + if (dDate != pLoginItem->accessedDate()) { - pLoginItem->setUpdatedDate(dDate); + pLoginItem->setAccessedDate(dDate); bChanged = true; } break; diff --git a/src/CredentialModel.h b/src/CredentialModel.h index ad4d42af..9639c7c4 100644 --- a/src/CredentialModel.h +++ b/src/CredentialModel.h @@ -24,8 +24,8 @@ class CredentialModel : public QAbstractItemModel ItemNameRole=Qt::UserRole+1, PasswordRole, DescriptionRole, - DateCreatedRole, DateUpdatedRole, + DateAccessedRole, FavoriteRole }; diff --git a/src/CredentialsManagement.cpp b/src/CredentialsManagement.cpp index b31478e0..382d0327 100644 --- a/src/CredentialsManagement.cpp +++ b/src/CredentialsManagement.cpp @@ -605,8 +605,8 @@ void CredentialsManagement::updateLoginDescription(LoginItem *pLoginItem) ui->credDisplayLoginInput->setText(pLoginItem->name()); ui->credDisplayPasswordInput->setText(pLoginItem->password()); ui->credDisplayDescriptionInput->setText(pLoginItem->description()); - ui->credDisplayCreationDateInput->setText(pLoginItem->createdDate().toString(Qt::DefaultLocaleShortDate)); - ui->credDisplayModificationDateInput->setText(pLoginItem->updatedDate().toString(Qt::DefaultLocaleShortDate)); + ui->credDisplayCreationDateInput->setText(pLoginItem->updatedDate().toString(Qt::DefaultLocaleShortDate)); + ui->credDisplayModificationDateInput->setText(pLoginItem->accessedDate().toString(Qt::DefaultLocaleShortDate)); ui->credDisplayPasswordInput->setLocked(pLoginItem->passwordLocked()); } } diff --git a/src/CredentialsManagement.ui b/src/CredentialsManagement.ui index c001f181..46e57325 100644 --- a/src/CredentialsManagement.ui +++ b/src/CredentialsManagement.ui @@ -534,7 +534,7 @@ border-right: none; - Creation Date: + Last Modified: @@ -568,7 +568,7 @@ border-right: none; - Last Modified: + Last Accessed: diff --git a/src/LoginItem.cpp b/src/LoginItem.cpp index 81fae300..16faec5c 100644 --- a/src/LoginItem.cpp +++ b/src/LoginItem.cpp @@ -84,9 +84,9 @@ QJsonObject LoginItem::toJson() const QString LoginItem::itemLabel() const { - QString sTargetDate = createdDate().toString(Qt::DefaultLocaleShortDate); - if (!updatedDate().isNull()) - sTargetDate = updatedDate().toString(Qt::DefaultLocaleShortDate); + QString sTargetDate = updatedDate().toString(Qt::DefaultLocaleShortDate); + if (!accessedDate().isNull()) + sTargetDate = accessedDate().toString(Qt::DefaultLocaleShortDate); return m_sName + QString(" (") + sTargetDate + QString(")"); } diff --git a/src/TreeItem.cpp b/src/TreeItem.cpp index a5c8aa09..a7a52acf 100644 --- a/src/TreeItem.cpp +++ b/src/TreeItem.cpp @@ -9,8 +9,8 @@ TreeItem::TreeItem(const QString &sName, const QDate &dCreatedDate, const QDate m_pParentItem(nullptr), m_eStatus(UNUSED), m_sName(sName), - m_dCreatedDate(dCreatedDate), - m_dUpdatedDate(dUpdatedDate), + m_dUpdatedDate(dCreatedDate), + m_dAccessedDate(dUpdatedDate), m_sDescription(sDescription) { } @@ -70,24 +70,24 @@ void TreeItem::setStatus(const Status &eStatus) m_eStatus = eStatus; } -const QDate &TreeItem::createdDate() const +const QDate &TreeItem::updatedDate() const { - return m_dCreatedDate; + return m_dUpdatedDate; } -void TreeItem::setCreatedDate(const QDate &dDate) +void TreeItem::setUpdatedDate(const QDate &dDate) { - m_dCreatedDate = dDate; + m_dUpdatedDate = dDate; } -const QDate &TreeItem::updatedDate() const +const QDate &TreeItem::accessedDate() const { - return m_dUpdatedDate; + return m_dAccessedDate; } -void TreeItem::setUpdatedDate(const QDate &dDate) +void TreeItem::setAccessedDate(const QDate &dDate) { - m_dUpdatedDate = dDate; + m_dAccessedDate = dDate; } const QString &TreeItem::description() const diff --git a/src/TreeItem.h b/src/TreeItem.h index 0e832f53..fb55042d 100644 --- a/src/TreeItem.h +++ b/src/TreeItem.h @@ -19,10 +19,10 @@ class TreeItem void setParentItem(TreeItem *pParentItem); const Status &status() const; void setStatus(const Status &eStatus); - const QDate &createdDate() const; - void setCreatedDate(const QDate &dDate); const QDate &updatedDate() const; void setUpdatedDate(const QDate &dDate); + const QDate &accessedDate() const; + void setAccessedDate(const QDate &dDate); const QString &description() const; void setDescription(const QString &sDescription); TreeItem *child(int iIndex); @@ -47,8 +47,8 @@ class TreeItem TreeItem *m_pParentItem; Status m_eStatus; QString m_sName; - QDate m_dCreatedDate; QDate m_dUpdatedDate; + QDate m_dAccessedDate; QString m_sDescription; };