-rw-r--r-- | libopie2/opiepim/private/opimeventsortvector.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/libopie2/opiepim/private/opimeventsortvector.cpp b/libopie2/opiepim/private/opimeventsortvector.cpp index 4220c63..b85f848 100644 --- a/libopie2/opiepim/private/opimeventsortvector.cpp +++ b/libopie2/opiepim/private/opimeventsortvector.cpp | |||
@@ -24,69 +24,66 @@ | |||
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 "opimeventsortvector.h" | 30 | #include "opimeventsortvector.h" |
31 | #include <opie2/ocontactaccess.h> | 31 | #include <opie2/ocontactaccess.h> |
32 | #include <opie2/opimnotifymanager.h> | 32 | #include <opie2/opimnotifymanager.h> |
33 | #include <opie2/odatebookaccess.h> | 33 | #include <opie2/odatebookaccess.h> |
34 | 34 | ||
35 | #include <qvaluelist.h> | 35 | #include <qvaluelist.h> |
36 | 36 | ||
37 | namespace Opie { | 37 | namespace Opie { |
38 | namespace Internal { | 38 | namespace Internal { |
39 | 39 | ||
40 | namespace{ | 40 | int testAlarmNotifiers( const OPimNotifyManager& leftnotifiers, const OPimNotifyManager& rightnotifiers ){ |
41 | |||
42 | inline int testAlarmNotifiers( const OPimNotifyManager& leftnotifiers, const OPimNotifyManager& rightnotifiers ){ | ||
43 | OPimNotifyManager::Alarms left_alarms = leftnotifiers.alarms(); | 41 | OPimNotifyManager::Alarms left_alarms = leftnotifiers.alarms(); |
44 | OPimNotifyManager::Alarms right_alarms = rightnotifiers.alarms(); | 42 | OPimNotifyManager::Alarms right_alarms = rightnotifiers.alarms(); |
45 | 43 | ||
46 | // Well.. How could we compare two lists of alarms? I think we should find the most early datetimes | 44 | // Well.. How could we compare two lists of alarms? I think we should find the most early datetimes |
47 | // and compare them.. (se) | 45 | // and compare them.. (se) |
48 | // Find the first alarm of the left list | 46 | // Find the first alarm of the left list |
49 | OPimNotifyManager::Alarms::Iterator it; | 47 | OPimNotifyManager::Alarms::Iterator it; |
50 | QDateTime left_earliest; // This datetime is initialized as invalid!! | 48 | QDateTime left_earliest; // This datetime is initialized as invalid!! |
51 | for ( it = left_alarms.begin(); it != left_alarms.end(); ++it ){ | 49 | for ( it = left_alarms.begin(); it != left_alarms.end(); ++it ){ |
52 | if ( !left_earliest.isValid() || left_earliest > (*it).dateTime() ){ | 50 | if ( !left_earliest.isValid() || left_earliest > (*it).dateTime() ){ |
53 | left_earliest = (*it).dateTime(); | 51 | left_earliest = (*it).dateTime(); |
54 | } | 52 | } |
55 | } | 53 | } |
56 | QDateTime right_earliest; // This datetime is initialized as invalid!! | 54 | QDateTime right_earliest; // This datetime is initialized as invalid!! |
57 | for ( it = right_alarms.begin(); it != right_alarms.end(); ++it ){ | 55 | for ( it = right_alarms.begin(); it != right_alarms.end(); ++it ){ |
58 | if ( !right_earliest.isValid() || right_earliest > (*it).dateTime() ){ | 56 | if ( !right_earliest.isValid() || right_earliest > (*it).dateTime() ){ |
59 | right_earliest = (*it).dateTime(); | 57 | right_earliest = (*it).dateTime(); |
60 | } | 58 | } |
61 | } | 59 | } |
62 | 60 | ||
63 | int ret; | 61 | int ret = 0; |
64 | 62 | ||
65 | // Now compare this found alarms | 63 | // Now compare this found alarms |
66 | if ( !left_earliest .isValid() ) ret++; | 64 | if ( !left_earliest .isValid() ) ret++; |
67 | if ( !right_earliest.isValid() ) ret--; | 65 | if ( !right_earliest.isValid() ) ret--; |
68 | 66 | ||
69 | if ( left_earliest.isValid() && right_earliest.isValid() ){ | 67 | if ( left_earliest.isValid() && right_earliest.isValid() ){ |
70 | ret += left_earliest < right_earliest ? -1 : 1; | 68 | left_earliest < right_earliest ? ret-- : ret++; |
71 | } | 69 | } |
72 | 70 | ||
73 | return ret; | 71 | return ret; |
74 | 72 | ||
75 | } | 73 | } |
76 | } | ||
77 | 74 | ||
78 | OPimEventSortVector::OPimEventSortVector( uint size, bool asc, int sort ) | 75 | OPimEventSortVector::OPimEventSortVector( uint size, bool asc, int sort ) |
79 | : OPimSortVector<OPimEvent>( size, asc, sort ) {} | 76 | : OPimSortVector<OPimEvent>( size, asc, sort ) {} |
80 | 77 | ||
81 | int OPimEventSortVector::compareItems( const OPimEvent& left, | 78 | int OPimEventSortVector::compareItems( const OPimEvent& left, |
82 | const OPimEvent& right ) { | 79 | const OPimEvent& right ) { |
83 | if ( left.uid() == right.uid() ) | 80 | if ( left.uid() == right.uid() ) |
84 | return 0; | 81 | return 0; |
85 | 82 | ||
86 | int ret = 0; | 83 | int ret = 0; |
87 | bool asc = sortAscending(); | 84 | bool asc = sortAscending(); |
88 | 85 | ||
89 | switch( sortOrder() ) { | 86 | switch( sortOrder() ) { |
90 | case ODateBookAccess::SortDescription: | 87 | case ODateBookAccess::SortDescription: |
91 | ret = testString( left.description(), right.description() ); | 88 | ret = testString( left.description(), right.description() ); |
92 | break; | 89 | break; |