2 Copyright (C) 2004-2005 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #include "UIxContactsListView.h"
23 #include <Contacts/SOGoContactFolder.h>
26 @implementation UIxContactsListView
29 [self->allRecords release];
30 [self->filteredRecords release];
31 [self->searchText release];
32 [self->contact release];
38 - (void)setContact:(id)_contact {
39 ASSIGN(self->contact, _contact);
45 - (void)setSearchText:(NSString *)_txt {
46 ASSIGNCOPY(self->searchText, _txt);
49 return self->searchText;
52 - (EOQualifier *)qualifier {
55 s = [self searchText];
59 qs = [NSString stringWithFormat:
60 @"(sn isCaseInsensitiveLike: '%@*') OR "
61 @"(givenname isCaseInsensitiveLike: '%@*') OR "
62 @"(mail isCaseInsensitiveLike: '*%@*') OR "
63 @"(telephonenumber isCaseInsensitiveLike: '*%@*')",
65 return [EOQualifier qualifierWithQualifierFormat:qs];
68 - (NSString *)defaultSortKey {
71 - (NSString *)sortKey {
74 s = [[[self context] request] formValueForKey:@"sort"];
75 return [s length] > 0 ? s : [self defaultSortKey];
77 - (EOSortOrdering *)sortOrdering {
80 sel = [[[[self context] request] formValueForKey:@"desc"] boolValue]
81 ? EOCompareCaseInsensitiveDescending
82 : EOCompareCaseInsensitiveAscending;
84 return [EOSortOrdering sortOrderingWithKey:[self sortKey] selector:sel];
86 - (NSArray *)sortOrderings {
87 return [NSArray arrayWithObjects:[self sortOrdering], nil];
90 - (NSArray *)contactInfos {
91 // TODO: should be done in the backend, but for Agenor AB its OK here
95 if (self->filteredRecords)
96 return self->filteredRecords;
98 records = [[self clientObject] fetchCoreInfos];
100 [[records sortedArrayUsingKeyOrderArray:[self sortOrderings]] retain];
102 if ((q = [self qualifier]) != nil) {
103 [self logWithFormat:@"qs: %@", q];
104 self->filteredRecords =
105 [[self->allRecords filteredArrayUsingQualifier:q] retain];
108 self->filteredRecords = [self->allRecords retain];
110 return self->filteredRecords;
116 [self->contact release]; self->contact = nil;
117 [self->allRecords release]; self->allRecords = nil;
118 [self->filteredRecords release]; self->filteredRecords = nil;
124 - (BOOL)shouldTakeValuesFromRequest:(WORequest *)_rq inContext:(WOContext*)_c{
128 @end /* UIxContactsListView */