Monotone-Parent: 641127c41cfee5608e04c80873154e605d00e178

Monotone-Revision: fbb867d290fbac74eedd76bf137347b1886150c3

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2007-09-17T03:40:34
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2007-09-17 03:40:34 +00:00
parent 3556365e47
commit ba5f751a3b
2 changed files with 76 additions and 0 deletions

View File

@@ -1,5 +1,10 @@
2007-09-16 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* SoObjects/SOGo/SOGoFolder.m ([SOGoFolder -compare:otherFolder]):
new method for sorting folders. The folders are compared based on
their ownership, whether they are a main folder and finally
depending on their display name.
* SoObjects/SOGo/SOGoObject.m ([SOGoObject
-pathArrayToSOGoObject]): do not reorder the paths if the third
element is an instance of NSNull.

View File

@@ -685,6 +685,77 @@ static NSString *defaultUserID = @"<default>";
return obj;
}
- (NSComparisonResult) _compareByOrigin: (SOGoFolder *) otherFolder
{
NSArray *thisElements, *otherElements;
unsigned thisCount, otherCount;
NSComparisonResult comparison;
thisElements = [nameInContainer componentsSeparatedByString: @"_"];
otherElements = [[otherFolder nameInContainer]
componentsSeparatedByString: @"_"];
thisCount = [thisElements count];
otherCount = [otherElements count];
if (thisCount == otherCount)
{
if (thisCount == 1)
comparison = NSOrderedSame;
else
comparison = [[thisElements objectAtIndex: 0]
compare: [otherElements objectAtIndex: 0]];
}
else
{
if (thisCount > otherCount)
comparison = NSOrderedDescending;
else
comparison = NSOrderedAscending;
}
return comparison;
}
- (NSComparisonResult) _compareByNameInContainer: (SOGoFolder *) otherFolder
{
NSString *otherName;
NSComparisonResult comparison;
otherName = [otherFolder nameInContainer];
if ([nameInContainer hasSuffix: @"personal"])
{
if ([otherName hasSuffix: @"personal"])
comparison = [nameInContainer compare: otherName];
else
comparison = NSOrderedAscending;
}
else
{
if ([otherName hasSuffix: @"personal"])
comparison = NSOrderedDescending;
else
comparison = NSOrderedSame;
}
return comparison;
}
- (NSComparisonResult) compare: (SOGoFolder *) otherFolder
{
NSComparisonResult comparison;
comparison = [self _compareByOrigin: otherFolder];
if (comparison == NSOrderedSame)
{
comparison = [self _compareByNameInContainer: otherFolder];
if (comparison == NSOrderedSame)
comparison
= [[self displayName]
localizedCaseInsensitiveCompare: [otherFolder displayName]];
}
return comparison;
}
/* WebDAV */
- (NSArray *) davNamespaces