• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

messagelist

  • sources
  • kde-4.12
  • kdepim
  • messagelist
  • core
aggregation.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * Copyright 2008 Szymon Tomasz Stefanek <pragma@kvirc.net>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  *
19  *******************************************************************************/
20 
21 #include "core/aggregation.h"
22 
23 #include <QDataStream>
24 
25 #include <klocale.h>
26 
27 using namespace MessageList::Core;
28 
29 static const int gAggregationCurrentVersion = 0x1009; // increase if you add new fields of change the meaning of some
30 
31 
32 Aggregation::Aggregation(
33  const QString &name,
34  const QString &description,
35  Grouping grouping,
36  GroupExpandPolicy groupExpandPolicy,
37  Threading threading,
38  ThreadLeader threadLeader,
39  ThreadExpandPolicy threadExpandPolicy,
40  FillViewStrategy fillViewStrategy, bool readOnly
41  )
42  : OptionSet( name, description, readOnly ),
43  mGrouping( grouping ),
44  mGroupExpandPolicy( groupExpandPolicy ),
45  mThreading( threading ),
46  mThreadLeader( threadLeader ),
47  mThreadExpandPolicy( threadExpandPolicy ),
48  mFillViewStrategy( fillViewStrategy )
49 {
50 }
51 
52 Aggregation::Aggregation(
53  const Aggregation &opt
54  )
55  : OptionSet( opt ),
56  mGrouping( opt.mGrouping ),
57  mGroupExpandPolicy( opt.mGroupExpandPolicy ),
58  mThreading( opt.mThreading ),
59  mThreadLeader( opt.mThreadLeader ),
60  mThreadExpandPolicy( opt.mThreadExpandPolicy ),
61  mFillViewStrategy( opt.mFillViewStrategy )
62 {
63 }
64 
65 Aggregation::Aggregation()
66  : OptionSet(),
67  mGrouping( NoGrouping ),
68  mGroupExpandPolicy( NeverExpandGroups ),
69  mThreading( NoThreading ),
70  mThreadLeader( TopmostMessage ),
71  mThreadExpandPolicy( NeverExpandThreads ),
72  mFillViewStrategy( FavorInteractivity )
73 {
74 }
75 
76 bool Aggregation::load( QDataStream &stream )
77 {
78  int val;
79 
80  stream >> val;
81  if ( val != gAggregationCurrentVersion )
82  return false; // b0rken (invalid version)
83 
84  stream >> val;
85  mGrouping = (Grouping)val;
86  switch( mGrouping )
87  {
88  case NoGrouping:
89  case GroupByDate:
90  case GroupByDateRange:
91  case GroupBySenderOrReceiver:
92  case GroupBySender:
93  case GroupByReceiver:
94  // ok
95  break;
96  default:
97  // b0rken
98  return false;
99  break;
100  }
101 
102  stream >> val; // Formerly contained group sorting
103  stream >> val; // Formerly contained group sorting direction
104 
105  stream >> val;
106  mGroupExpandPolicy = (GroupExpandPolicy)val;
107  switch( mGroupExpandPolicy )
108  {
109  case NeverExpandGroups:
110  case ExpandRecentGroups:
111  case AlwaysExpandGroups:
112  // ok
113  break;
114  default:
115  // b0rken
116  return false;
117  break;
118  }
119 
120  stream >> val;
121  mThreading = (Threading)val;
122  switch( mThreading )
123  {
124  case NoThreading:
125  case PerfectOnly:
126  case PerfectAndReferences:
127  case PerfectReferencesAndSubject:
128  // ok
129  break;
130  default:
131  // b0rken
132  return false;
133  break;
134  }
135 
136  stream >> val;
137  mThreadLeader = (ThreadLeader)val;
138  switch( mThreadLeader )
139  {
140  case MostRecentMessage:
141  case TopmostMessage:
142  // ok
143  // FIXME: Should check that thread leaders setting matches grouping and threading settings.
144  break;
145  default:
146  // b0rken
147  return false;
148  break;
149  }
150 
151  stream >> val;
152  mThreadExpandPolicy = (ThreadExpandPolicy)val;
153  switch( mThreadExpandPolicy )
154  {
155  case NeverExpandThreads:
156  case ExpandThreadsWithNewMessages:
157  case ExpandThreadsWithUnreadMessages:
158  case ExpandThreadsWithUnreadOrImportantMessages:
159  case AlwaysExpandThreads:
160  // ok
161  break;
162  default:
163  // b0rken
164  return false;
165  break;
166  }
167 
168  stream >> val; // Formely contained message sorting
169  stream >> val; // Formely contained message sort direction
170 
171  stream >> val;
172  mFillViewStrategy = (FillViewStrategy)val;
173  switch( mFillViewStrategy )
174  {
175  case FavorSpeed:
176  case FavorInteractivity:
177  case BatchNoInteractivity:
178  // ok
179  break;
180  default:
181  // b0rken
182  return false;
183  break;
184  }
185 
186  return true;
187 }
188 
189 void Aggregation::save( QDataStream &stream ) const
190 {
191  stream << (int)gAggregationCurrentVersion;
192  stream << (int)mGrouping;
193  stream << 0; // Formerly group sorting
194  stream << 0; // Formerly group sort direction
195  stream << (int)mGroupExpandPolicy;
196  stream << (int)mThreading;
197  stream << (int)mThreadLeader;
198  stream << (int)mThreadExpandPolicy;
199  stream << 0; // Formerly message sorting
200  stream << 0; // Formerly message sort direction
201  stream << (int)mFillViewStrategy;
202 }
203 
204 QList< QPair< QString, int > > Aggregation::enumerateGroupingOptions()
205 {
206  QList< QPair< QString, int > > ret;
207  ret.append( QPair< QString, int >( i18nc( "No grouping of messages", "None" ), NoGrouping ) );
208  ret.append( QPair< QString, int >( i18n( "By Exact Date (of Thread Leaders)" ), GroupByDate ) );
209  ret.append( QPair< QString, int >( i18n( "By Smart Date Ranges (of Thread Leaders)" ), GroupByDateRange ) );
210  ret.append( QPair< QString, int >( i18n( "By Smart Sender/Receiver" ), GroupBySenderOrReceiver ) );
211  ret.append( QPair< QString, int >( i18n( "By Sender" ), GroupBySender ) );
212  ret.append( QPair< QString, int >( i18n( "By Receiver" ), GroupByReceiver ) );
213  return ret;
214 }
215 
216 
217 QList< QPair< QString, int > > Aggregation::enumerateGroupExpandPolicyOptions( Grouping g )
218 {
219  QList< QPair< QString, int > > ret;
220  if ( g == NoGrouping )
221  return ret;
222  ret.append( QPair< QString, int >( i18n( "Never Expand Groups" ), NeverExpandGroups ) );
223  if ( ( g == GroupByDate ) || ( g == GroupByDateRange ) )
224  ret.append( QPair< QString, int >( i18n( "Expand Recent Groups" ), ExpandRecentGroups ) );
225  ret.append( QPair< QString, int >( i18n( "Always Expand Groups" ), AlwaysExpandGroups ) );
226  return ret;
227 }
228 
229 QList< QPair< QString, int > > Aggregation::enumerateThreadingOptions()
230 {
231  QList< QPair< QString, int > > ret;
232  ret.append( QPair< QString, int >( i18nc( "No threading of messages", "None" ), NoThreading ) );
233  ret.append( QPair< QString, int >( i18n( "Perfect Only" ), PerfectOnly ) );
234  ret.append( QPair< QString, int >( i18n( "Perfect and by References" ), PerfectAndReferences ) );
235  ret.append( QPair< QString, int >( i18n( "Perfect, by References and by Subject" ), PerfectReferencesAndSubject ) );
236  return ret;
237 }
238 
239 QList< QPair< QString, int > > Aggregation::enumerateThreadLeaderOptions( Grouping g, Threading t )
240 {
241  QList< QPair< QString, int > > ret;
242  if ( t == NoThreading )
243  return ret;
244  ret.append( QPair< QString, int >( i18n( "Topmost Message" ), TopmostMessage ) );
245  if ( ( g != GroupByDate ) && ( g != GroupByDateRange ) )
246  return ret;
247  ret.append( QPair< QString, int >( i18n( "Most Recent Message" ), MostRecentMessage ) );
248  return ret;
249 }
250 
251 QList< QPair< QString, int > > Aggregation::enumerateThreadExpandPolicyOptions( Threading t )
252 {
253  QList< QPair< QString, int > > ret;
254  if ( t == NoThreading )
255  return ret;
256  ret.append( QPair< QString, int >( i18n( "Never Expand Threads" ), NeverExpandThreads ) );
257  ret.append( QPair< QString, int >( i18n( "Expand Threads With Unread Messages" ), ExpandThreadsWithUnreadMessages ) );
258  ret.append( QPair< QString, int >( i18n( "Expand Threads With Unread or Important Messages" ), ExpandThreadsWithUnreadOrImportantMessages ) );
259  ret.append( QPair< QString, int >( i18n( "Always Expand Threads" ), AlwaysExpandThreads ) );
260  return ret;
261 }
262 
263 QList< QPair< QString, int > > Aggregation::enumerateFillViewStrategyOptions()
264 {
265  QList< QPair< QString, int > > ret;
266  ret.append( QPair< QString, int >( i18n( "Favor Interactivity" ), FavorInteractivity ) );
267  ret.append( QPair< QString, int >( i18n( "Favor Speed" ), FavorSpeed ) );
268  ret.append( QPair< QString, int >( i18n( "Batch Job (No Interactivity)" ), BatchNoInteractivity ) );
269  return ret;
270 }
271 
MessageList::Core::Aggregation::PerfectAndReferences
Thread by "In-Reply-To" and "References" fields.
Definition: aggregation.h:87
MessageList::Core::Aggregation
A set of aggregation options that can be applied to the MessageList::Model in a single shot...
Definition: aggregation.h:43
MessageList::Core::OptionSet
A set of options that can be applied to the MessageList in one shot.
Definition: optionset.h:47
MessageList::Core::Aggregation::ThreadExpandPolicy
ThreadExpandPolicy
The available thread expand policies.
Definition: aggregation.h:109
MessageList::Core::Aggregation::save
virtual void save(QDataStream &stream) const
Pure virtual reimplemented from OptionSet.
Definition: aggregation.cpp:189
MessageList::Core::Aggregation::PerfectReferencesAndSubject
Thread by all of the above and try to match subjects too.
Definition: aggregation.h:88
MessageList::Core::Aggregation::enumerateFillViewStrategyOptions
static QList< QPair< QString, int > > enumerateFillViewStrategyOptions()
Enumerates the fill view strategies.
Definition: aggregation.cpp:263
MessageList::Core::Aggregation::NoThreading
Perform no threading at all.
Definition: aggregation.h:85
MessageList::Core::Aggregation::Aggregation
Aggregation()
Definition: aggregation.cpp:65
MessageList::Core::Aggregation::Threading
Threading
The available threading methods.
Definition: aggregation.h:83
MessageList::Core::Aggregation::GroupBySender
Group by sender, always.
Definition: aggregation.h:58
MessageList::Core::Aggregation::ExpandRecentGroups
Makes sense only with GroupByDate or GroupByDateRange.
Definition: aggregation.h:73
MessageList::Core::Aggregation::FillViewStrategy
FillViewStrategy
The available fill view strategies.
Definition: aggregation.h:124
MessageList::Core::Aggregation::GroupByDate
Group the messages by the date of the thread leader.
Definition: aggregation.h:55
MessageList::Core::Aggregation::PerfectOnly
Thread by "In-Reply-To" field only.
Definition: aggregation.h:86
MessageList::Core::Aggregation::load
virtual bool load(QDataStream &stream)
Pure virtual reimplemented from OptionSet.
Definition: aggregation.cpp:76
MessageList::Core::Aggregation::NeverExpandGroups
Never expand groups during a view fill algorithm.
Definition: aggregation.h:72
MessageList::Core::Aggregation::GroupByDateRange
Use smart (thread leader) date ranges ("Today","Yesterday","Last Week"...)
Definition: aggregation.h:56
MessageList::Core::Aggregation::enumerateThreadLeaderOptions
static QList< QPair< QString, int > > enumerateThreadLeaderOptions(Grouping g, Threading t)
Enumerates the thread leader determination methods compatible with the specified Threading and the sp...
Definition: aggregation.cpp:239
MessageList::Core::Aggregation::NoGrouping
Don't group messages at all.
Definition: aggregation.h:54
gAggregationCurrentVersion
static const int gAggregationCurrentVersion
Definition: aggregation.cpp:29
MessageList::Core::Aggregation::GroupExpandPolicy
GroupExpandPolicy
The available group expand policies.
Definition: aggregation.h:70
MessageList::Core::Aggregation::TopmostMessage
The thread grouping is computed from the topmost message (very similar to least recent, but might be different if timezones or machine clocks are screwed)
Definition: aggregation.h:99
MessageList::Core::Aggregation::AlwaysExpandThreads
Expand all threads (this might be very slow)
Definition: aggregation.h:114
MessageList::Core::Aggregation::ThreadLeader
ThreadLeader
The available thread leading options.
Definition: aggregation.h:97
MessageList::Core::Aggregation::ExpandThreadsWithUnreadMessages
Expand threads with unread messages (this includes new)
Definition: aggregation.h:113
MessageList::Core::Aggregation::GroupByReceiver
Group by receiver, always.
Definition: aggregation.h:59
MessageList::Core::Aggregation::AlwaysExpandGroups
All groups are expanded as they are inserted.
Definition: aggregation.h:74
MessageList::Core::Aggregation::enumerateThreadExpandPolicyOptions
static QList< QPair< QString, int > > enumerateThreadExpandPolicyOptions(Threading t)
Enumerates the thread expand policies compatible with the specified Threading option.
Definition: aggregation.cpp:251
aggregation.h
MessageList::Core::Aggregation::FavorSpeed
Do larger chunks of work, zero intervals between chunks.
Definition: aggregation.h:127
MessageList::Core::Aggregation::ExpandThreadsWithUnreadOrImportantMessages
Expand threads with "hot" messages (this includes new, unread, important, todo)
Definition: aggregation.h:115
MessageList::Core::Aggregation::NeverExpandThreads
Never expand any thread, this is fast.
Definition: aggregation.h:111
MessageList::Core::Aggregation::Grouping
Grouping
Message grouping.
Definition: aggregation.h:52
MessageList::Core::Aggregation::enumerateThreadingOptions
static QList< QPair< QString, int > > enumerateThreadingOptions()
Enumerates the available threading method options.
Definition: aggregation.cpp:229
MessageList::Core::Aggregation::MostRecentMessage
The thread grouping is computed from the most recent message.
Definition: aggregation.h:100
MessageList::Core::Aggregation::FavorInteractivity
Do small chunks of work, small intervals between chunks to allow for UI event processing.
Definition: aggregation.h:126
MessageList::Core::Aggregation::ExpandThreadsWithNewMessages
DEPRECATED. New message status no longer exists.
Definition: aggregation.h:112
MessageList::Core::Aggregation::enumerateGroupExpandPolicyOptions
static QList< QPair< QString, int > > enumerateGroupExpandPolicyOptions(Grouping g)
Enumerates the group sort direction options compatible with the specified Grouping.
Definition: aggregation.cpp:217
MessageList::Core::Aggregation::BatchNoInteractivity
Do one large chunk, no interactivity at all.
Definition: aggregation.h:128
MessageList::Core::Aggregation::GroupBySenderOrReceiver
Group by sender (incoming) or receiver (outgoing) field.
Definition: aggregation.h:57
MessageList::Core::Aggregation::enumerateGroupingOptions
static QList< QPair< QString, int > > enumerateGroupingOptions()
Enumerates the available grouping options as a QList of pairs in that the first item is the localized...
Definition: aggregation.cpp:204
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:32 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

messagelist

Skip menu "messagelist"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal