Messagelib

sortorder.h
1 /******************************************************************************
2  *
3  * SPDX-FileCopyrightText: 2009 Thomas McGuire <[email protected]>
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  *
7  *******************************************************************************/
8 #ifndef MESSAGELIST_CORE_SORTORDER_H
9 #define MESSAGELIST_CORE_SORTORDER_H
10 
11 #include <core/aggregation.h>
12 
13 #include <KConfigGroup>
14 
15 namespace MessageList {
16 namespace Core {
21 class SortOrder
22 {
23  Q_GADGET
24  Q_ENUMS(GroupSorting)
25  Q_ENUMS(SortDirection)
26  Q_ENUMS(MessageSorting)
27 
28 public:
29 
35  enum GroupSorting {
42  // Never add enum entries in the middle: always add them at the end (numeric values are stored in configuration)
43  };
44 
51  Ascending,
52  Descending
53  };
54 
71  SortMessagesByImportantStatus,
73  // Warning: Never add enum entries in the middle: always add them at the end (numeric values are stored in configuration)
74  };
75 
76  SortOrder();
77 
81  GroupSorting groupSorting() const;
82 
89 
94 
100 
105 
110 
115 
121 
128 
136 
144 
152 
158  bool validForAggregation(const Aggregation *aggregation) const;
159 
167  static SortOrder defaultForAggregation(const Aggregation *aggregation, SortOrder oldSortOrder);
168 
173 
183  void readConfig(KConfigGroup &conf, const QString &storageId, bool *storageUsesPrivateSortOrder);
184 
193  void writeConfig(KConfigGroup &conf, const QString &storageId, bool storageUsesPrivateSortOrder) const;
194 
195 private:
196 
197  // Helper function to convert an enum value to a string and back
198  static const QString nameForSortDirection(SortDirection sortDirection);
199  static const QString nameForMessageSorting(MessageSorting messageSorting);
200  static const QString nameForGroupSorting(GroupSorting groupSorting);
201  static SortDirection sortDirectionForName(const QString &name);
202  static MessageSorting messageSortingForName(const QString &name);
203  static GroupSorting groupSortingForName(const QString &name);
204 
205  bool readConfigHelper(KConfigGroup &conf, const QString &id);
206 
207  MessageSorting mMessageSorting;
208  SortDirection mMessageSortDirection;
209  GroupSorting mGroupSorting;
210  SortDirection mGroupSortDirection;
211 };
212 } // namespace Core
213 } // namespace MessageList
214 
215 #endif // MESSAGELIST_CORE_SORTORDER_H
Sort the messages by date and time of the most recent message in subtree.
Definition: sortorder.h:63
A class which holds information about sorting, e.g.
Definition: sortorder.h:21
A set of aggregation options that can be applied to the MessageList::Model in a single shot...
Definition: aggregation.h:27
Sort groups by date/time of the group.
Definition: sortorder.h:37
SortDirection messageSortDirection() const
Returns the current message SortDirection.
Definition: sortorder.cpp:57
static bool isValidMessageSorting(SortOrder::MessageSorting ms)
Returns true if the ms parameter specifies a valid MessageSorting option.
Definition: sortorder.cpp:298
MessageSorting messageSorting() const
Returns the current message sorting option.
Definition: sortorder.cpp:47
static QVector< QPair< QString, int > > enumerateMessageSortDirectionOptions(MessageSorting ms)
Enumerates the available message sorting directions for the specified MessageSorting option...
Definition: sortorder.cpp:87
Threading
The available threading methods.
Definition: aggregation.h:65
Sort groups by receiver (makes sense only with GroupByReceiver)
Definition: sortorder.h:41
SortDirection groupSortDirection() const
Returns the current group SortDirection.
Definition: sortorder.cpp:37
static QVector< QPair< QString, int > > enumerateMessageSortingOptions(Aggregation::Threading t)
Enumerates the message sorting options compatible with the specified Threading setting.
Definition: sortorder.cpp:67
SortDirection
The "generic" sort direction: used for groups and for messages If you add values here please look at ...
Definition: sortorder.h:50
void writeConfig(KConfigGroup &conf, const QString &storageId, bool storageUsesPrivateSortOrder) const
Writes the sort order to a config group.
Definition: sortorder.cpp:277
Don&#39;t sort the groups at all, add them as they come in.
Definition: sortorder.h:36
void setGroupSorting(GroupSorting gs)
Sets the GroupSorting option.
Definition: sortorder.cpp:32
MessageSorting
The available message sorting options.
Definition: sortorder.h:60
void setMessageSortDirection(SortDirection messageSortDirection)
Sets the SortDirection for the message.
Definition: sortorder.cpp:62
static QVector< QPair< QString, int > > enumerateGroupSortingOptions(Aggregation::Grouping g)
Enumerates the group sorting options compatible with the specified Grouping.
Definition: sortorder.cpp:108
void setMessageSorting(MessageSorting ms)
Sets the current message sorting option.
Definition: sortorder.cpp:52
Sort groups by sender (makes sense only with GroupBySender)
Definition: sortorder.h:40
void readConfig(KConfigGroup &conf, const QString &storageId, bool *storageUsesPrivateSortOrder)
Reads the sort order from a config group.
Definition: sortorder.cpp:265
Grouping
Message grouping.
Definition: aggregation.h:36
Don&#39;t sort the messages at all.
Definition: sortorder.h:61
GroupSorting
How to sort the groups If you add values here please look at the implementations of the enumerate* fu...
Definition: sortorder.h:35
Sort the messages by sender or receiver.
Definition: sortorder.h:64
void setGroupSortDirection(SortDirection groupSortDirection)
Sets the SortDirection for the groups.
Definition: sortorder.cpp:42
GroupSorting groupSorting() const
Returns the GroupSorting.
Definition: sortorder.cpp:27
static SortOrder defaultForAggregation(const Aggregation *aggregation, SortOrder oldSortOrder)
Returns the default sort order for the given aggregation.
Definition: sortorder.cpp:185
Sort groups by sender or receiver (makes sense only with GroupBySenderOrReceiver) ...
Definition: sortorder.h:39
Sort the messages by the "Unread" flags of status.
Definition: sortorder.h:70
Sort the messages by date and time.
Definition: sortorder.h:62
Sort the messages by the "Action Item" flag of status.
Definition: sortorder.h:69
static QVector< QPair< QString, int > > enumerateGroupSortDirectionOptions(Aggregation::Grouping g, GroupSorting groupSorting)
Enumerates the group sort direction options compatible with the specified Grouping and GroupSorting...
Definition: sortorder.cpp:132
bool validForAggregation(const Aggregation *aggregation) const
Checks if this sort order can be used in combination with the given aggregation.
Definition: sortorder.cpp:164
Sort groups by date/time of the most recent message.
Definition: sortorder.h:38
Sort the messages By "Important" flags of status.
Definition: sortorder.h:72
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Aug 3 2020 23:12:26 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.