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 "UIxContactsListViewBase.h"
23 #include <Contacts/SOGoContactFolder.h>
26 @implementation UIxContactsListViewBase
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 if (self->searchText == nil)
50 [self setSearchText:[[[self context] request] formValueForKey:@"search"]];
51 return self->searchText;
54 - (EOQualifier *)qualifier {
57 s = [self searchText];
61 // TODO: just use qualifier vars
62 qs = [NSString stringWithFormat:
63 @"(sn isCaseInsensitiveLike: '%@*') OR "
64 @"(givenname isCaseInsensitiveLike: '%@*') OR "
65 @"(mail isCaseInsensitiveLike: '*%@*') OR "
66 @"(telephonenumber isCaseInsensitiveLike: '*%@*')",
68 return [EOQualifier qualifierWithQualifierFormat:qs];
71 - (NSString *)defaultSortKey {
74 - (NSString *)sortKey {
77 s = [[[self context] request] formValueForKey:@"sort"];
78 return [s length] > 0 ? s : [self defaultSortKey];
80 - (EOSortOrdering *)sortOrdering {
83 sel = [[[[self context] request] formValueForKey:@"desc"] boolValue]
84 ? EOCompareCaseInsensitiveDescending
85 : EOCompareCaseInsensitiveAscending;
87 return [EOSortOrdering sortOrderingWithKey:[self sortKey] selector:sel];
89 - (NSArray *)sortOrderings {
90 return [NSArray arrayWithObjects:[self sortOrdering], nil];
93 - (NSArray *)contactInfos {
94 // TODO: should be done in the backend, but for Agenor AB its OK here
98 if (self->filteredRecords != nil)
99 return self->filteredRecords;
101 records = [[self clientObject] fetchCoreInfos];
103 [[records sortedArrayUsingKeyOrderArray:[self sortOrderings]] retain];
105 if ((q = [self qualifier]) != nil) {
106 [self debugWithFormat:@"qs: %@", q];
107 self->filteredRecords =
108 [[self->allRecords filteredArrayUsingQualifier:q] retain];
111 self->filteredRecords = [self->allRecords retain];
113 return self->filteredRecords;
119 [self->contact release]; self->contact = nil;
120 [self->allRecords release]; self->allRecords = nil;
121 [self->filteredRecords release]; self->filteredRecords = nil;
127 - (BOOL)shouldTakeValuesFromRequest:(WORequest *)_rq inContext:(WOContext*)_c{
131 @end /* UIxContactsListViewBase */