Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nemo-qml-plugin-email] Add OriginalSubject sorting order. Contributes… #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/emailmessagelistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ EmailMessageListModel::EmailMessageListModel(QObject *parent)
roles[MessageSizeSectionRole] = "sizeSection";
roles[MessageFolderIdRole] = "folderId";
roles[MessageParsedSubject] = "parsedSubject";
roles[MessageTrimmedSubject] = "trimmedSubject";
roles[MessageOriginalSubject] = "originalSubject";
roles[MessageHasCalendarCancellationRole] = "hasCalendarCancellation";

m_key = key();
Expand Down Expand Up @@ -237,9 +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) {
} else if (role == MessageOriginalSubject) {
QString subject = QMailMessageListModel::data(index, QMailMessageModelBase::MessageSubjectTextRole).toString();
return subject.replace(QRegExp(QStringLiteral("^(re:|fw:|fwd:|\\s*)*"), Qt::CaseInsensitive), QString());
return subject.replace(QRegExp(QStringLiteral("^(re:|fw:|fwd:|\\s*|\\\")*"), Qt::CaseInsensitive), QString());
} else if (role == MessageHasCalendarCancellationRole) {
return (messageMetaData.status() & QMailMessageMetaData::CalendarCancellation) != 0;
}
Expand Down Expand Up @@ -446,6 +446,9 @@ void EmailMessageListModel::sortByOrder(Qt::SortOrder sortOrder, EmailMessageLis
case Subject:
m_sortKey = QMailMessageSortKey::subject(sortOrder);
break;
case OriginalSubject:
m_sortKey = QMailMessageSortKey::originalSubject(sortOrder);
break;
case Time:
m_sortKey = QMailMessageSortKey::timeStamp(sortOrder);
break;
Expand Down
4 changes: 2 additions & 2 deletions src/emailmessagelistmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ 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
MessageOriginalSubject, // returns the message subject without Re: and Fwd: prefixes
MessageHasCalendarCancellationRole, // returns 1 if message has a calendar cancellation, 0 otherwise
};

enum Priority { LowPriority, NormalPriority, HighPriority };

enum Sort { Time, Sender, Size, ReadStatus, Priority, Attachments, Subject, Recipients };
enum Sort { Time, Sender, Size, ReadStatus, Priority, Attachments, Subject, Recipients, OriginalSubject };

enum SearchOn { LocalAndRemote, Local, Remote };

Expand Down