Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /XspfManager/XspfMRuleEditorDelegate.m

Parent Directory Parent Directory | Revision Log Revision Log


Revision 120 - (hide annotations) (download)
Sun Nov 29 11:32:41 2009 UTC (14 years, 4 months ago) by masaki
File size: 2546 byte(s)
[Mod] NSRuleEditor テスト中 :-)
1 masaki 120 //
2     // XspfMRuleEditorDelegate.m
3     // XspfManager
4     //
5     // Created by Hori,Masaki on 09/11/28.
6     // Copyright 2009 masakih. All rights reserved.
7     //
8    
9     #import "XspfMRuleEditorDelegate.h"
10    
11     #import "XspfMRuleEditorRow.h"
12    
13     @implementation XspfMRuleEditorDelegate
14    
15     - (void)awakeFromNib
16     {
17     if(!compound) {
18     compound = [[XspfMCompound alloc] init];
19     }
20     if(!simples) {
21     simples = [NSMutableArray array];
22     [simples retain];
23    
24     XspfMStringPredicate *pre;
25     pre = [XspfMStringPredicate simpleWithKeyPath:@"title" rightType:0 operator:0];
26     [simples addObject:pre];
27     pre = [XspfMAbsoluteDatePredicate simpleWithKeyPath:@"creationDate" rightType:0 operator:0];
28     [simples addObject:pre];
29     }
30     }
31    
32     #pragma mark#### NSRuleEditor Delegate ####
33     - (NSInteger)ruleEditor:(NSRuleEditor *)editor
34     numberOfChildrenForCriterion:(id)criterion
35     withRowType:(NSRuleEditorRowType)rowType
36     {
37     NSInteger result = 0;
38    
39     if(rowType == NSRuleEditorRowTypeCompound) {
40     result = [compound numberOfChildrenForChild:criterion];
41     goto end;
42     }
43    
44     if(!criterion) {
45     result = [simples count];
46     goto end;
47     return result;
48     }
49    
50     for(id s in simples) {
51     if([s isMyChild:criterion]) result += [s numberOfChildrenForChild:criterion];
52     }
53    
54     end:
55     // NSLog(@"numner\tcriterion -> %@, type -> %d, result -> %d", criterion, rowType, result);
56    
57     return result;
58     }
59     - (id)ruleEditor:(NSRuleEditor *)editor
60     child:(NSInteger)index
61     forCriterion:(id)criterion
62     withRowType:(NSRuleEditorRowType)rowType
63     {
64     id result = nil;
65    
66     if(rowType == NSRuleEditorRowTypeCompound) {
67     result = [compound childForChild:criterion atIndex:index];
68     goto end;
69     }
70    
71     if(!criterion) {
72     id s = [simples objectAtIndex:index];
73     result = [s childForChild:criterion atIndex:index];
74     goto end;
75     }
76    
77     for(id s in simples) {
78     if([s isMyChild:criterion]) {
79     result = [s childForChild:criterion atIndex:index];
80     goto end;
81     }
82     }
83    
84     end:
85     // NSLog(@"child\tindex -> %d, criterion -> %@, type -> %d, result -> %@", index, criterion, rowType, result);
86    
87     return result;
88     }
89     - (id)ruleEditor:(NSRuleEditor *)editor
90     displayValueForCriterion:(id)criterion
91     inRow:(NSInteger)row
92     {
93     id result = nil;
94    
95     NSRuleEditorRowType rowType = [editor rowTypeForRow:row];
96     if(rowType == NSRuleEditorRowTypeCompound) {
97     result = [compound displayValueForChild:criterion];
98     goto end;
99     }
100    
101     for(id s in simples) {
102     if([s isMyChild:criterion]) {
103     result = [s displayValueForChild:criterion];
104     goto end;
105     }
106     }
107    
108     end:
109     // NSLog(@"display\tcriterion -> %@, row -> %d, result -> %@", criterion, row, result);
110     return result;
111     }
112    
113    
114     @end

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26