Monotone-Parent: 527b8fb043af42d5bcd6913397ab32e1bc42a27a

Monotone-Revision: ccfa7fe7bfe69f390c767dfec7587ed458a13dfa

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2006-10-16T18:49:25
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2006-10-16 18:49:25 +00:00
parent 56696d680a
commit 6f3742b3fa
4 changed files with 119 additions and 13 deletions

View File

@@ -1,5 +1,9 @@
2006-10-16 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* UI/Scheduler/UIxCalCalendarsListView.m: added method to create
and associate a color for each user login depending on its
position in the list.
* UI/Scheduler/UIxCalAptListView.m ([UIxCalAptListView
-currentRowCSSClass]): return the correct class for the current
row depending on the owner of the event.

View File

@@ -25,10 +25,16 @@
#import <SOGoUI/UIxComponent.h>
@class NSMutableArray;
@class NSMutableDictionary;
@class iCalPerson;
@interface UIxCalCalendarsListView : UIxComponent
{
NSMutableArray *checkedContacts;
NSMutableArray *contacts;
NSMutableDictionary *colors;
iCalPerson *currentContactPerson;
}
@end

View File

@@ -21,6 +21,7 @@
*/
#import <Foundation/NSArray.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSString.h>
#import <Foundation/NSUserDefaults.h>
@@ -37,21 +38,89 @@
{
contacts = nil;
checkedContacts = nil;
currentContactPerson = nil;
colors = nil;
}
return self;
}
- (void) dealloc
{
if (currentContactPerson)
[currentContactPerson release];
if (contacts)
[contacts release];
if (checkedContacts)
[checkedContacts release];
if (colors)
[colors release];
[super dealloc];
}
- (NSString *) _colorForNumber: (unsigned int) number
{
unsigned int index, currentValue;
unsigned char colorTable[] = { 1, 1, 1 };
NSString *color;
if (number == NSNotFound)
color = @"#f00";
else
{
currentValue = number;
index = 0;
while (currentValue)
{
if (currentValue & 1)
colorTable[index]++;
if (index == 3)
index = 0;
currentValue >>= 1;
index++;
}
color = [NSString stringWithFormat: @"#%2x%2x%2x",
(256 / colorTable[2]) - 1,
(256 / colorTable[1]) - 1,
(256 / colorTable[0]) - 1];
}
NSLog(@"color = '%@'", color);
return color;
}
- (void) _addContactId: (NSString *) contactId
withUm: (AgenorUserManager *) um
andNumber: (unsigned int) count
{
NSString *contactRealId;
iCalPerson *currentContact;
if ([contactId hasPrefix: @"-"])
contactRealId = [contactId substringFromIndex: 1];
else
contactRealId = contactId;
currentContact = [um iCalPersonWithUid: contactRealId];
[contacts addObject: currentContact];
if (contactId == contactRealId)
[checkedContacts addObject: currentContact];
[colors setObject: [self _colorForNumber: count]
forKey: contactRealId];
}
- (void) _setupContacts
{
AgenorUserManager *um;
SOGoUser *user;
NSString *list, *currentId;
NSEnumerator *rawContacts;
iCalPerson *currentContact;
AgenorUserManager *um;
unsigned int count;
contacts = [NSMutableArray array];
checkedContacts = [NSMutableArray array];
contacts = [NSMutableArray new];
checkedContacts = [NSMutableArray new];
colors = [NSMutableDictionary new];
um = [AgenorUserManager sharedUserManager];
user = [context activeUser];
@@ -62,18 +131,12 @@
rawContacts
= [[list componentsSeparatedByString: @","] objectEnumerator];
currentId = [rawContacts nextObject];
count = 0;
while (currentId)
{
if ([currentId hasPrefix: @"-"])
currentContact
= [um iCalPersonWithUid: [currentId substringFromIndex: 1]];
else
{
currentContact = [um iCalPersonWithUid: currentId];
[checkedContacts addObject: currentContact];
}
[contacts addObject: currentContact];
[self _addContactId: currentId withUm: um andNumber: count];
currentId = [rawContacts nextObject];
count++;
}
}
@@ -93,4 +156,28 @@
return checkedContacts;
}
- (void) setCurrentContactPerson: (iCalPerson *) contact
{
if (currentContactPerson)
[currentContactPerson release];
currentContactPerson = contact;
if (currentContactPerson)
[currentContactPerson retain];
}
- (NSString *) currentContactLogin
{
return [currentContactPerson cn];
}
- (NSString *) currentContactSpanBG
{
return [colors objectForKey: [currentContactPerson cn]];
}
- (NSDictionary *) colors
{
return colors;
}
@end

View File

@@ -5,10 +5,19 @@
xmlns:const="http://www.skyrix.com/od/constant"
xmlns:rsrc="OGo:url"
xmlns:label="OGo:label">
<style type="text/css">
<var:foreach list="contacts" item="currentContactPerson">
.ownerIs<var:string value="currentContactLogin" />
{
background-color: <var:string value="currentContactSpanBG" /> !important;
}
</var:foreach>
</style>
<var:component className="UIxContactSelector"
const:selectorId="calendarsList"
const:hasCheckBoxes="YES"
const:checkBoxOnChange="return updateCalendarStatus(this);"
colors="colors"
contacts="contacts"
checkedBoxes="checkedContacts"
/>