Skip to content

Commit

Permalink
[libcommhistory] Expose some Event data in Q_PROPERTY macros. Contrib…
Browse files Browse the repository at this point in the history
…utes to JB#47116
  • Loading branch information
Timur Kristóf committed Oct 24, 2019
1 parent a9b915b commit 099be0b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/event.cpp
Expand Up @@ -550,6 +550,12 @@ QString Event::localUid() const
return d->localUid;
}

QString Event::dateAndAccountGrouping() const
{
QString dateString = startTime().date().toString("yyyy-MM-dd");
return dateString + QStringLiteral(" ") + localUid();
}

const RecipientList &Event::recipients() const
{
return d->recipients;
Expand Down
11 changes: 11 additions & 0 deletions src/event.h
Expand Up @@ -48,6 +48,13 @@ class EventPrivate;
*/
class LIBCOMMHISTORY_EXPORT Event
{
Q_GADGET
Q_PROPERTY(int id READ id CONSTANT)
Q_PROPERTY(QDateTime startTime READ startTime CONSTANT)
Q_PROPERTY(CommHistory::Event::EventDirection direction READ direction CONSTANT)
Q_PROPERTY(QString localUid READ localUid CONSTANT)
Q_PROPERTY(QString dateAndAccountGrouping READ dateAndAccountGrouping CONSTANT)

public:
enum EventType {
UnknownType = 0,
Expand Down Expand Up @@ -81,6 +88,7 @@ class LIBCOMMHISTORY_EXPORT Event
Inbound,
Outbound
};
Q_ENUM(EventDirection)

enum EventStatus {
ManualNotificationStatus = -4,
Expand Down Expand Up @@ -255,6 +263,8 @@ class LIBCOMMHISTORY_EXPORT Event

QString localUid() const;

QString dateAndAccountGrouping() const;

const RecipientList &recipients() const;
RecipientList contactRecipients() const;

Expand Down Expand Up @@ -455,5 +465,6 @@ Q_DECLARE_METATYPE(CommHistory::Event)
Q_DECLARE_METATYPE(QList<CommHistory::Event>)
Q_DECLARE_METATYPE(CommHistory::Event::Contact)
Q_DECLARE_METATYPE(QList<CommHistory::Event::Contact>)
Q_DECLARE_METATYPE(CommHistory::Event::EventDirection)

#endif
3 changes: 1 addition & 2 deletions src/eventmodel.cpp
Expand Up @@ -296,8 +296,7 @@ QVariant EventModel::data(const QModelIndex &index, int role) const
return QVariant::fromValue(localUid);
}
case DateAndAccountGroupingRole: {
QString dateString = event.startTime().date().toString("yyyy-MM-dd");
return dateString + QStringLiteral(" ") + event.localUid();
return event.dateAndAccountGrouping();
}
default:
break;
Expand Down

0 comments on commit 099be0b

Please sign in to comment.