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
31 #include <SOGoUI/UIxComponent.h>
34 @implementation UIxMailFilterPanel
36 static NSArray *filters = nil;
37 static NSDictionary *filterToQualifier = nil;
40 // TODO: also available: answered, draft [custom: NotJunk and Junk]
41 // Note: we currently cannot use: "flags != 'deleted'"
42 static NSString *quals[] = {
44 @"read", @"flags = 'seen' AND NOT (flags = 'deleted')",
45 @"unread", @"flags = 'unseen' AND NOT (flags = 'deleted')",
46 @"deleted", @"flags = 'deleted'",
47 @"flagged", @"flags = 'flagged'",
50 NSMutableDictionary *md;
54 md = [[NSMutableDictionary alloc] initWithCapacity:8];
55 ma = [[NSMutableArray alloc] initWithCapacity:4];
57 for (i = 0; quals[i] != nil; i += 2) {
58 [ma addObject:quals[i]];
59 if (quals[i + 1] != nil) {
60 [md setObject:[EOQualifier qualifierWithQualifierFormat:quals[i + 1]]
65 filterToQualifier = [md copy];
67 [md release]; md = nil;
68 [ma release]; ma = nil;
72 [self->searchText release];
78 - (void)setSearchText:(NSString *)_txt {
79 ASSIGNCOPY(self->searchText, _txt);
81 - (NSString *)searchText {
82 if (self->searchText == nil) {
85 [[[[self context] request] formValueForKey:@"searchtext"] copy];
87 return self->searchText;
92 - (NSArray *)filters {
98 - (EOQualifier *)searchTextQualifier {
102 s = [self searchText];
106 q = [EOQualifier qualifierWithQualifierFormat:
107 @"(subject doesContain: %@) OR "
108 @"(from doesContain: %@)",
113 - (NSString *)filterLabel {
115 return [[[self context] page] labelForKey:[self valueForKey:@"filter"]];
117 return [self valueForKey:@"filter"];
121 - (NSString *)selectedFilter {
122 return [[[self context] request] formValueForKey:@"filterpopup"];
125 - (EOQualifier *)filterQualifier {
126 NSString *selectedFilter;
128 selectedFilter = [self selectedFilter];
130 return [selectedFilter length] > 0
131 ? [filterToQualifier objectForKey:selectedFilter] : nil;
134 - (EOQualifier *)qualifier {
135 EOQualifier *sq, *fq;
138 sq = [self searchTextQualifier];
139 fq = [self filterQualifier];
141 if (fq == nil) return sq;
142 if (sq == nil) return fq;
144 qa = [NSArray arrayWithObjects:fq, sq, nil];
145 return [[[EOAndQualifier alloc] initWithQualifierArray:qa] autorelease];
148 @end /* UIxMailFilterPanel */