summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/private/opimtodosortvector.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/private/opimtodosortvector.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/private/opimtodosortvector.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/libopie2/opiepim/private/opimtodosortvector.cpp b/libopie2/opiepim/private/opimtodosortvector.cpp
index 8d15710..1db20df 100644
--- a/libopie2/opiepim/private/opimtodosortvector.cpp
+++ b/libopie2/opiepim/private/opimtodosortvector.cpp
@@ -12,84 +12,86 @@
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "opimtodosortvector.h" 30#include "opimtodosortvector.h"
31#include <opie2/otodoaccess.h> 31#include <opie2/otodoaccess.h>
32 32
33namespace Opie { 33namespace Opie {
34namespace Internal { 34namespace Internal {
35 35
36namespace{
36inline QString string( const OPimTodo& todo) { 37inline QString string( const OPimTodo& todo) {
37 return todo.summary().isEmpty() ? 38 return todo.summary().isEmpty() ?
38 todo.description().left(20 ) : 39 todo.description().left(20 ) :
39 todo.summary(); 40 todo.summary();
40} 41}
41 42
42inline int completed( const OPimTodo& todo1, const OPimTodo& todo2) { 43inline int completed( const OPimTodo& todo1, const OPimTodo& todo2) {
43 int ret = 0; 44 int ret = 0;
44 if ( todo1.isCompleted() ) ret++; 45 if ( todo1.isCompleted() ) ret++;
45 if ( todo2.isCompleted() ) ret--; 46 if ( todo2.isCompleted() ) ret--;
46 return ret; 47 return ret;
47} 48}
48 49
49inline int priority( const OPimTodo& t1, const OPimTodo& t2) { 50inline int priority( const OPimTodo& t1, const OPimTodo& t2) {
50 return ( t1.priority() - t2.priority() ); 51 return ( t1.priority() - t2.priority() );
51} 52}
52 53
53inline int summary( const OPimTodo& t1, const OPimTodo& t2) { 54inline int summary( const OPimTodo& t1, const OPimTodo& t2) {
54 return QString::compare( string(t1), string(t2) ); 55 return QString::compare( string(t1), string(t2) );
55} 56}
56 57
57inline int deadline( const OPimTodo& t1, const OPimTodo& t2) { 58inline int deadline( const OPimTodo& t1, const OPimTodo& t2) {
58 int ret = 0; 59 int ret = 0;
59 if ( t1.hasDueDate() && 60 if ( t1.hasDueDate() &&
60 t2.hasDueDate() ) 61 t2.hasDueDate() )
61 ret = t2.dueDate().daysTo( t1.dueDate() ); 62 ret = t2.dueDate().daysTo( t1.dueDate() );
62 else if ( t1.hasDueDate() ) 63 else if ( t1.hasDueDate() )
63 ret = -1; 64 ret = -1;
64 else if ( t2.hasDueDate() ) 65 else if ( t2.hasDueDate() )
65 ret = 1; 66 ret = 1;
66 else 67 else
67 ret = 0; 68 ret = 0;
68 69
69 return ret; 70 return ret;
70} 71}
71 72
73}
72 74
73OPimTodoSortVector::OPimTodoSortVector( uint size, bool asc, int sort ) 75OPimTodoSortVector::OPimTodoSortVector( uint size, bool asc, int sort )
74 : OPimSortVector<OPimTodo>( size, asc, sort ) 76 : OPimSortVector<OPimTodo>( size, asc, sort )
75{} 77{}
76 78
77int OPimTodoSortVector::compareItems( const OPimTodo& con1, const OPimTodo& con2 ) { 79int OPimTodoSortVector::compareItems( const OPimTodo& con1, const OPimTodo& con2 ) {
78 bool seComp, sePrio, seSum, seDeadline; 80 bool seComp, sePrio, seSum, seDeadline;
79 seComp = sePrio = seDeadline = seSum = false; 81 seComp = sePrio = seDeadline = seSum = false;
80 int ret =0; 82 int ret =0;
81 bool asc = sortAscending(); 83 bool asc = sortAscending();
82 84
83 /* same item */ 85 /* same item */
84 if ( con1.uid() == con2.uid() ) 86 if ( con1.uid() == con2.uid() )
85 return 0; 87 return 0;
86 88
87 switch ( sortOrder() ) { 89 switch ( sortOrder() ) {
88 case OPimTodoAccess::Completed: { 90 case OPimTodoAccess::Completed: {
89 ret = completed( con1, con2 ); 91 ret = completed( con1, con2 );
90 seComp = TRUE; 92 seComp = TRUE;
91 break; 93 break;
92 } 94 }
93 case OPimTodoAccess::Priority: { 95 case OPimTodoAccess::Priority: {
94 ret = priority( con1, con2 ); 96 ret = priority( con1, con2 );
95 sePrio = TRUE; 97 sePrio = TRUE;