2 Copyright (C) 2000-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 <NGObjWeb/WOComponent.h>
24 @interface UIxMailFilterPanel : WOComponent
27 NSString *searchCriteria;
32 #include <SOGoUI/UIxComponent.h>
35 @implementation UIxMailFilterPanel
37 static NSArray *filters = nil;
38 static NSDictionary *filterToQualifier = nil;
41 // TODO: also available: answered, draft [custom: NotJunk and Junk]
42 // Note: we currently cannot use: "flags != 'deleted'"
43 static NSString *quals[] = {
45 @"read", @"flags = 'seen' AND NOT (flags = 'deleted')",
46 @"unread", @"flags = 'unseen' AND NOT (flags = 'deleted')",
47 @"deleted", @"flags = 'deleted'",
48 @"flagged", @"flags = 'flagged'",
51 NSMutableDictionary *md;
55 md = [[NSMutableDictionary alloc] initWithCapacity:8];
56 ma = [[NSMutableArray alloc] initWithCapacity:4];
58 for (i = 0; quals[i] != nil; i += 2) {
59 [ma addObject:quals[i]];
60 if (quals[i + 1] != nil) {
61 [md setObject:[EOQualifier qualifierWithQualifierFormat:quals[i + 1]]
66 filterToQualifier = [md copy];
68 [md release]; md = nil;
69 [ma release]; ma = nil;
74 if ((self = [super init]))
84 [self->searchCriteria release];
85 [self->searchText release];
91 - (void)setSearchText: (NSString *)_txt
93 ASSIGNCOPY(self->searchText, _txt);
96 - (void)setSearchCriteria: (NSString *)_txt
98 ASSIGNCOPY(self->searchText, _txt);
101 - (NSString *)searchText
103 if (self->searchText == nil)
106 [[[[self context] request] formValueForKey:@"search"] copy];
108 return self->searchText;
111 - (NSString *)searchCriteria
113 if (self->searchCriteria == nil)
115 self->searchCriteria =
116 [[[[self context] request] formValueForKey:@"criteria"] copy];
118 return self->searchCriteria;
130 - (EOQualifier *) searchTextQualifier
135 s = [self searchText];
139 q = [EOQualifier qualifierWithQualifierFormat:
140 @"(subject doesContain: %@) OR "
141 @"(from doesContain: %@)",
146 - (NSString *)filterLabel
149 return [[[self context] page] labelForKey:[self valueForKey:@"filter"]];
151 return [self valueForKey:@"filter"];
155 - (NSString *)selectedFilter
157 return [[[self context] request] formValueForKey:@"filterpopup"];
160 - (EOQualifier *)filterQualifier
162 NSString *selectedFilter;
164 selectedFilter = [self selectedFilter];
166 return [selectedFilter length] > 0
167 ? [filterToQualifier objectForKey:selectedFilter] : nil;
170 - (EOQualifier *) qualifier
172 EOQualifier *sq, *fq;
175 sq = [self searchTextQualifier];
176 fq = [self filterQualifier];
178 if (fq == nil) return sq;
179 if (sq == nil) return fq;
181 qa = [NSArray arrayWithObjects:fq, sq, nil];
182 return [[[EOAndQualifier alloc] initWithQualifierArray:qa] autorelease];
185 @end /* UIxMailFilterPanel */