diff --git a/src/core/DatabaseIcons.cpp b/src/core/DatabaseIcons.cpp index a2301e060..e89f31310 100644 --- a/src/core/DatabaseIcons.cpp +++ b/src/core/DatabaseIcons.cpp @@ -60,6 +60,11 @@ int DatabaseIcons::iconCount() return 69; } +int DatabaseIcons::expiredIconIndex() +{ + return 45; +} + DatabaseIcons::DatabaseIcons() { m_indexToName.reserve(iconCount()); diff --git a/src/core/DatabaseIcons.h b/src/core/DatabaseIcons.h index fc9a88001..935e77585 100644 --- a/src/core/DatabaseIcons.h +++ b/src/core/DatabaseIcons.h @@ -29,6 +29,7 @@ public: QImage icon(int index); QPixmap iconPixmap(int index); int iconCount(); + int expiredIconIndex(); private: DatabaseIcons(); diff --git a/src/core/Entry.cpp b/src/core/Entry.cpp index 77235fecc..9877b73c9 100644 --- a/src/core/Entry.cpp +++ b/src/core/Entry.cpp @@ -196,6 +196,11 @@ QString Entry::notes() const return m_attributes->value("Notes"); } +bool Entry::isExpired() const +{ + return m_data.timeInfo.expires() && m_data.timeInfo.expiryTime() < Tools::currentDateTimeUtc(); +} + EntryAttributes* Entry::attributes() { return m_attributes; diff --git a/src/core/Entry.h b/src/core/Entry.h index 696e3606b..24e58610f 100644 --- a/src/core/Entry.h +++ b/src/core/Entry.h @@ -84,6 +84,7 @@ public: QString username() const; QString password() const; QString notes() const; + bool isExpired() const; EntryAttributes* attributes(); const EntryAttributes* attributes() const; EntryAttachments* attachments(); diff --git a/src/core/Group.cpp b/src/core/Group.cpp index 8cb9bda5d..280e0ca21 100644 --- a/src/core/Group.cpp +++ b/src/core/Group.cpp @@ -164,6 +164,11 @@ Entry* Group::lastTopVisibleEntry() const return m_lastTopVisibleEntry; } +bool Group::isExpired() const +{ + return m_timeInfo.expires() && m_timeInfo.expiryTime() < Tools::currentDateTimeUtc(); +} + void Group::setUuid(const Uuid& uuid) { set(m_uuid, uuid); diff --git a/src/core/Group.h b/src/core/Group.h index 13142c662..3689ed94d 100644 --- a/src/core/Group.h +++ b/src/core/Group.h @@ -50,6 +50,7 @@ public: Group::TriState autoTypeEnabled() const; Group::TriState searchingEnabled() const; Entry* lastTopVisibleEntry() const; + bool isExpired() const; static const int DefaultIconNumber; diff --git a/src/gui/EntryModel.cpp b/src/gui/EntryModel.cpp index 15f3f5054..90e4f450b 100644 --- a/src/gui/EntryModel.cpp +++ b/src/gui/EntryModel.cpp @@ -18,7 +18,9 @@ #include "EntryModel.h" #include +#include +#include "core/DatabaseIcons.h" #include "core/Entry.h" #include "core/Group.h" @@ -131,9 +133,21 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const } break; case 1: - return entry->iconPixmap(); + if (entry->isExpired()) { + return databaseIcons()->iconPixmap(databaseIcons()->expiredIconIndex()); + } + else { + return entry->iconPixmap(); + } } } + else if (role == Qt::FontRole) { + QFont font; + if (entry->isExpired()) { + font.setStrikeOut(true); + } + return font; + } return QVariant(); } diff --git a/src/gui/GroupModel.cpp b/src/gui/GroupModel.cpp index d9e1678e7..f79f9d009 100644 --- a/src/gui/GroupModel.cpp +++ b/src/gui/GroupModel.cpp @@ -18,8 +18,10 @@ #include "GroupModel.h" #include +#include #include "core/Database.h" +#include "core/DatabaseIcons.h" #include "core/Group.h" #include "core/Tools.h" @@ -114,7 +116,19 @@ QVariant GroupModel::data(const QModelIndex& index, int role) const return group->name(); } else if (role == Qt::DecorationRole) { - return group->iconPixmap(); + if (group->isExpired()) { + return databaseIcons()->iconPixmap(databaseIcons()->expiredIconIndex()); + } + else { + return group->iconPixmap(); + } + } + else if (role == Qt::FontRole) { + QFont font; + if (group->isExpired()) { + font.setStrikeOut(true); + } + return font; } else { return QVariant();