]> err.no Git - sope/blob - sope-core/NGExtensions/EOExt.subproj/EOQualifierGrouping.m
fixed logging in WOComponent
[sope] / sope-core / NGExtensions / EOExt.subproj / EOQualifierGrouping.m
1 /*
2   Copyright (C) 2000-2003 SKYRIX Software AG
3
4   This file is part of OGo
5
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
9   later version.
10
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.
15
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
19   02111-1307, USA.
20 */
21 // $Id$
22
23 #include "EOGrouping.h"
24 #include <EOControl/EOQualifier.h>
25 #include "common.h"
26
27 @implementation EOQualifierGrouping
28
29 - (id)initWithQualifier:(EOQualifier *)_qualifier name:(NSString *)_name {
30   if ((self = [super initWithDefaultName:nil])) {
31     self->name      = [_name copy];
32     self->qualifier = [_qualifier retain];
33   }
34   return self;
35 }
36
37 - (void)dealloc {
38   [self->qualifier release];
39   [self->name      release];
40   [super dealloc];
41 }
42
43 /* accessors */
44
45 - (void)setName:(NSString *)_name {
46   NSAssert1(_name != nil, @"%s: name is nil", __PRETTY_FUNCTION__);
47   ASSIGNCOPY(self->name, _name);
48 }
49 - (NSString *)name {
50   return self->name;
51 }
52
53 - (void)setQualifier:(EOQualifier *)_qualifier {
54   ASSIGN(self->qualifier, _qualifier);
55 }
56 - (EOQualifier *)qualifier {
57   return self->qualifier;
58 }
59
60 /* operations */
61
62 - (NSString *)groupNameForObject:(id)_object {
63   if (self->qualifier == nil)
64     return self->name;
65   
66   if ([(id<EOQualifierEvaluation>)self->qualifier evaluateWithObject:_object])
67     return self->name;
68   
69   return self->defaultName;
70 }
71
72 - (NSArray *)orderedGroupNames {
73   return [NSArray arrayWithObjects:[self name], [self defaultName], nil];
74 }
75
76 @end /* EOQualifierGrouping */