From e983f32e929cbe59bd37ff8b67cb0221c4ba2d66 Mon Sep 17 00:00:00 2001 From: znek Date: Wed, 2 Mar 2005 19:57:10 +0000 Subject: [PATCH] added sorting to fetchInfos... - this indirectly solves a few issues in UI git-svn-id: http://svn.opengroupware.org/SOGo/trunk@620 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/SOGo.xcode/project.pbxproj | 27 ++++++++- SOGo/SoObjects/Appointments/ChangeLog | 3 + .../Appointments/SOGoAppointmentFolder.m | 6 ++ SOGo/SoObjects/Appointments/Version | 2 +- SOGo/SoObjects/SOGo/ChangeLog | 7 ++- SOGo/SoObjects/SOGo/GNUmakefile | 44 +++++++------- SOGo/SoObjects/SOGo/NSObject+AptComparison.h | 34 +++++++++++ SOGo/SoObjects/SOGo/NSObject+AptComparison.m | 58 +++++++++++++++++++ SOGo/SoObjects/SOGo/Version | 2 +- 9 files changed, 158 insertions(+), 25 deletions(-) create mode 100644 SOGo/SoObjects/SOGo/NSObject+AptComparison.h create mode 100644 SOGo/SoObjects/SOGo/NSObject+AptComparison.m diff --git a/SOGo/SOGo.xcode/project.pbxproj b/SOGo/SOGo.xcode/project.pbxproj index 17025ebd..d9cfcb16 100644 --- a/SOGo/SOGo.xcode/project.pbxproj +++ b/SOGo/SOGo.xcode/project.pbxproj @@ -1430,11 +1430,14 @@ }; AD85C72807C4E8740036AC7A = { fileEncoding = 5; + indentWidth = 8; isa = PBXFileReference; lastKnownFileType = text; path = ChangeLog; refType = 4; sourceTree = ""; + tabWidth = 8; + usesTabs = 1; }; AD85C72907C4E8740036AC7A = { fileEncoding = 5; @@ -1541,12 +1544,14 @@ sourceTree = ""; }; AD85C73607C4E8740036AC7A = { + explicitFileType = sourcecode.make; fileEncoding = 5; + indentWidth = 8; isa = PBXFileReference; - lastKnownFileType = text; path = Version; refType = 4; sourceTree = ""; + tabWidth = 8; }; AD85C73907C4E8A30036AC7A = { children = ( @@ -2227,6 +2232,24 @@ tabWidth = 8; usesTabs = 1; }; + ADB7A0FC07D6389500CA782A = { + fileEncoding = 5; + indentWidth = 2; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = "NSObject+AptComparison.h"; + refType = 4; + sourceTree = ""; + }; + ADB7A0FD07D6389500CA782A = { + fileEncoding = 5; + indentWidth = 2; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.objc; + path = "NSObject+AptComparison.m"; + refType = 4; + sourceTree = ""; + }; ADBE3C490726AF4C000FEA6A = { fileEncoding = 5; indentWidth = 2; @@ -3018,6 +3041,8 @@ AD85C73107C4E8740036AC7A, AD85C72E07C4E8740036AC7A, AD85C72F07C4E8740036AC7A, + ADB7A0FC07D6389500CA782A, + ADB7A0FD07D6389500CA782A, ); isa = PBXGroup; name = Classes; diff --git a/SOGo/SoObjects/Appointments/ChangeLog b/SOGo/SoObjects/Appointments/ChangeLog index 5fef80a1..d7318eb8 100644 --- a/SOGo/SoObjects/Appointments/ChangeLog +++ b/SOGo/SoObjects/Appointments/ChangeLog @@ -1,5 +1,8 @@ 2005-03-02 Marcus Mueller + * SOGoAppointmentFolder.m: make sure fetchedInfos are sorted + ascending - this simplifies client code (v0.9.30) + * SOGoAppointmentFolder.m: changed debugLog to use NGLogging (v0.9.29) 2005-03-01 Marcus Mueller diff --git a/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m b/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m index e12afff2..082378c0 100644 --- a/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -349,6 +349,12 @@ static NSTimeZone *MET = nil; [self errorWithFormat:@"(%s): fetch failed!", __PRETTY_FUNCTION__]; return nil; } + /* NOTE: why do we sort here? + This probably belongs to UI but cannot be achieved as fast there as + we can do it here because we're operating on a mutable array - + having the apts sorted is never a bad idea, though + */ + [ma sortUsingSelector:@selector(compareAptsAscending:)]; if (logger) [self debugWithFormat:@"returning %i records", [ma count]]; return ma; diff --git a/SOGo/SoObjects/Appointments/Version b/SOGo/SoObjects/Appointments/Version index c161c04f..6eb8443a 100644 --- a/SOGo/SoObjects/Appointments/Version +++ b/SOGo/SoObjects/Appointments/Version @@ -1,6 +1,6 @@ # Version file -SUBMINOR_VERSION:=29 +SUBMINOR_VERSION:=30 # v0.9.28 requires NGiCal v4.5.47 # v0.9.26 requires libSOGo v0.9.30 diff --git a/SOGo/SoObjects/SOGo/ChangeLog b/SOGo/SoObjects/SOGo/ChangeLog index 91b1668f..62da83cd 100644 --- a/SOGo/SoObjects/SOGo/ChangeLog +++ b/SOGo/SoObjects/SOGo/ChangeLog @@ -1,3 +1,8 @@ +2005-03-02 Marcus Mueller + + * NSObject+AptComparison.[hm]: new comparison method. This is used + in SOGoAppointmentFolder currently. (v0.9.32) + 2005-02-20 Helge Hess * AgenorUserManager.m: refactoring of the LDAP fetch code, added the @@ -83,7 +88,7 @@ * v0.9.14 - * GNUmakefile.preamble: fixed for gsmake 1.9.2 build + * GNUmakefile.preamble: fixed for gsmake 1.9.2 build * GNUmakefile: include ../../Version also diff --git a/SOGo/SoObjects/SOGo/GNUmakefile b/SOGo/SoObjects/SOGo/GNUmakefile index 7f92ca8f..5ab35535 100644 --- a/SOGo/SoObjects/SOGo/GNUmakefile +++ b/SOGo/SoObjects/SOGo/GNUmakefile @@ -12,32 +12,34 @@ libSOGo_HEADER_FILES_DIR = . libSOGo_HEADER_FILES_INSTALL_DIR = /SOGo libSOGo_HEADER_FILES = \ - SOGoObject.h \ - SOGoFolder.h \ - SOGoContentObject.h \ - SOGoUserFolder.h \ - SOGoGroupsFolder.h \ - SOGoGroupFolder.h \ - SOGoCustomGroupFolder.h \ + SOGoObject.h \ + SOGoFolder.h \ + SOGoContentObject.h \ + SOGoUserFolder.h \ + SOGoGroupsFolder.h \ + SOGoGroupFolder.h \ + SOGoCustomGroupFolder.h \ \ - SOGoAppointment.h \ - AgenorUserManager.h \ - SOGoLRUCache.h \ - NSString+iCal.h + SOGoAppointment.h \ + AgenorUserManager.h \ + SOGoLRUCache.h \ + NSString+iCal.h \ + NSObject+AptComparison.h \ libSOGo_OBJC_FILES = \ - SOGoObject.m \ - SOGoFolder.m \ - SOGoContentObject.m \ - SOGoUserFolder.m \ - SOGoGroupsFolder.m \ - SOGoGroupFolder.m \ - SOGoCustomGroupFolder.m \ + SOGoObject.m \ + SOGoFolder.m \ + SOGoContentObject.m \ + SOGoUserFolder.m \ + SOGoGroupsFolder.m \ + SOGoGroupFolder.m \ + SOGoCustomGroupFolder.m \ \ - SOGoAppointment.m \ + SOGoAppointment.m \ SOGoAppointmentICalRenderer.m \ - SOGoLRUCache.m \ - AgenorUserManager.m \ + SOGoLRUCache.m \ + AgenorUserManager.m \ + NSObject+AptComparison.m \ -include GNUmakefile.preamble include $(GNUSTEP_MAKEFILES)/library.make diff --git a/SOGo/SoObjects/SOGo/NSObject+AptComparison.h b/SOGo/SoObjects/SOGo/NSObject+AptComparison.h new file mode 100644 index 00000000..ae50afda --- /dev/null +++ b/SOGo/SoObjects/SOGo/NSObject+AptComparison.h @@ -0,0 +1,34 @@ +/* + Copyright (C) 2004 SKYRIX Software AG + + This file is part of OpenGroupware.org. + + OGo is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + OGo is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with OGo; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ +// $Id$ + +#ifndef __SOGo_NSObject_AptComparison_H_ +#define __SOGo_NSObject_AptComparison_H_ + +#import + +@interface NSObject (SOGoAptComparison) + +- (NSComparisonResult)compareAptsAscending:(id)_other; + +@end + +#endif /* __SOGo_NSObject_AptComparison_H_ */ diff --git a/SOGo/SoObjects/SOGo/NSObject+AptComparison.m b/SOGo/SoObjects/SOGo/NSObject+AptComparison.m new file mode 100644 index 00000000..3c316272 --- /dev/null +++ b/SOGo/SoObjects/SOGo/NSObject+AptComparison.m @@ -0,0 +1,58 @@ +/* + Copyright (C) 2004 SKYRIX Software AG + + This file is part of OpenGroupware.org. + + OGo is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + OGo is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with OGo; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ +// $Id$ + +#include "NSObject+AptComparison.h" +#include +#include "common.h" + +@implementation NSObject (SOGoAptComparison) + +- (NSComparisonResult)compareAptsAscending:(id)_other { + NSCalendarDate *sd, *ed; + NGCalendarDateRange *r1, *r2; + NSComparisonResult result; + NSTimeInterval t1, t2; + + sd = [self valueForKey:@"startDate"]; + ed = [self valueForKey:@"endDate"]; + r1 = [NGCalendarDateRange calendarDateRangeWithStartDate:sd + endDate:ed]; + + sd = [_other valueForKey:@"startDate"]; + ed = [_other valueForKey:@"endDate"]; + r2 = [NGCalendarDateRange calendarDateRangeWithStartDate:sd + endDate:ed]; + + result = [r1 compare:r2]; + if (result != NSOrderedSame) + return result; + + t1 = [r1 duration]; + t2 = [r2 duration]; + if (t1 == t2) + return NSOrderedSame; + if (t1 > t2) + return NSOrderedDescending; + return NSOrderedAscending; +} + +@end diff --git a/SOGo/SoObjects/SOGo/Version b/SOGo/SoObjects/SOGo/Version index b259838b..2d0e88fb 100644 --- a/SOGo/SoObjects/SOGo/Version +++ b/SOGo/SoObjects/SOGo/Version @@ -1,5 +1,5 @@ # version file -SUBMINOR_VERSION:=31 +SUBMINOR_VERSION:=32 # v0.9.26 requires libOGoContentStore v0.9.13 -- 2.39.5