Skip to content

Commit

Permalink
Merge branch 'omp-jb6059' into 'master'
Browse files Browse the repository at this point in the history
[nemo-qml-plugin-email] Add trimmedSubject role without Re: and Fwd: prefixes....

See merge request mer-core/nemo-qml-plugin-email!79
  • Loading branch information
pvuorela committed May 7, 2021
2 parents b0beb9a + d545f11 commit dbb3961
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/emailmessagelistmodel.cpp
Expand Up @@ -64,6 +64,7 @@ EmailMessageListModel::EmailMessageListModel(QObject *parent)
roles[MessageSizeSectionRole] = "sizeSection";
roles[MessageFolderIdRole] = "folderId";
roles[MessageParsedSubject] = "parsedSubject";
roles[MessageTrimmedSubject] = "trimmedSubject";
roles[MessageHasCalendarCancellationRole] = "hasCalendarCancellation";

m_key = key();
Expand Down Expand Up @@ -236,6 +237,9 @@ QVariant EmailMessageListModel::data(const QModelIndex & index, int role) const
subject.replace(QRegExp("<\\s*img", Qt::CaseInsensitive), "<no-img");
subject.replace(QRegExp("<\\s*a", Qt::CaseInsensitive), "<no-a");
return subject;
} else if (role == MessageTrimmedSubject) {
QString subject = QMailMessageListModel::data(index, QMailMessageModelBase::MessageSubjectTextRole).toString();
return subject.replace(QRegExp(QStringLiteral("^(re:|fw:|fwd:|\\s*)*"), Qt::CaseInsensitive), QString());
} else if (role == MessageHasCalendarCancellationRole) {
return (messageMetaData.status() & QMailMessageMetaData::CalendarCancellation) != 0;
}
Expand Down
1 change: 1 addition & 0 deletions src/emailmessagelistmodel.h
Expand Up @@ -71,6 +71,7 @@ class Q_DECL_EXPORT EmailMessageListModel : public QMailMessageListModel
MessageSizeSectionRole, // returns size section (0-2)
MessageFolderIdRole, // returns parent folder id for the message
MessageParsedSubject, // returns the message subject parsed against a pre-defined regular expression
MessageTrimmedSubject, // returns the message subject without Re: and Fwd: prefixes
MessageHasCalendarCancellationRole, // returns 1 if message has a calendar cancellation, 0 otherwise
};

Expand Down

0 comments on commit dbb3961

Please sign in to comment.