~mailbox-ullrich/mnemosyne-proj/MnemoCoco

« back to all changes in this revision

Viewing changes to Classes/CardEditViewController.m

  • Committer: Ullrich Martini
  • Date: 2010-11-04 23:02:45 UTC
  • Revision ID: ullrich@opportunity.local-20101104230245-vlg1ficyytd21tnh
added display of facts 

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
//  Copyright 2010 Ullrich Martini. All rights reserved.
7
7
//
8
8
 
 
9
#import "MnemosyneAppDelegate.h"
9
10
#import "CardEditViewController.h"
10
 
 
 
11
#import "Card.h"
 
12
#import "Fact.h"
 
13
#import "Factlet.h"
11
14
 
12
15
@implementation CardEditViewController
13
16
 
 
17
@synthesize card;
 
18
 
 
19
- (void)updateDictionary{
 
20
        NSMutableSet *factlets = [[card cardFactRelation] factFactlets];
 
21
        NSEnumerator *enumerator = [factlets objectEnumerator];
 
22
        factletDictionary = [[NSMutableDictionary alloc] init];
 
23
        Factlet *factlet;
 
24
        while (factlet = [enumerator nextObject]) {
 
25
                [factletDictionary setObject:[factlet factletValue] forKey:[factlet factletKey]];
 
26
        }       
 
27
}
 
28
 
14
29
/*
15
30
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
16
31
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
27
42
}
28
43
*/
29
44
 
30
 
/*
 
45
 
31
46
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
32
47
- (void)viewDidLoad {
33
 
    [super viewDidLoad];
 
48
 [super viewDidLoad];
34
49
}
35
 
*/
 
50
 
36
51
 
37
52
/*
38
53
// Override to allow orientations other than the default portrait orientation.
42
57
}
43
58
*/
44
59
 
 
60
#pragma mark Table view methods
 
61
 
 
62
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
 
63
    return 1;
 
64
}
 
65
 
 
66
 
 
67
// Customize the number of rows in the table view.
 
68
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
 
69
        switch ([[card cardType] intValue]) {
 
70
                case frontToBack:
 
71
                case bothWays:
 
72
                        return 2;
 
73
                        break;
 
74
                case threeSided:
 
75
                        return 3;
 
76
                        break;
 
77
                default:
 
78
                        break;
 
79
        }
 
80
        return 0;
 
81
}
 
82
 
 
83
 
 
84
// Customize the appearance of table view cells.
 
85
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
 
86
    
 
87
    static NSString *CellIdentifier = @"Cell";
 
88
    
 
89
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
 
90
    if (cell == nil) {
 
91
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
 
92
    }
 
93
    
 
94
    // Set up the cell...
 
95
        NSUInteger row = [indexPath row];
 
96
        cell.textLabel.text = @"to do";
 
97
        switch (row) {
 
98
                case 0:
 
99
                        switch ([[card cardType] intValue]) {
 
100
                                case frontToBack:
 
101
                                case bothWays:
 
102
                                        cell.textLabel.text = [factletDictionary valueForKey:@"q"];
 
103
                                        break;
 
104
                                case threeSided:
 
105
                                        cell.textLabel.text = [factletDictionary valueForKey:@"f"];
 
106
                                        break;
 
107
                                default:
 
108
                                        break;
 
109
                        }
 
110
                        break;
 
111
                case 1:
 
112
                        switch ([[card cardType] intValue]) {
 
113
                                case frontToBack:
 
114
                                case bothWays:
 
115
                                        cell.textLabel.text = [factletDictionary valueForKey:@"a"];
 
116
                                        break;
 
117
                                case threeSided:
 
118
                                        cell.textLabel.text = [factletDictionary valueForKey:@"p"];
 
119
                                        break;
 
120
                                default:
 
121
                                        break;
 
122
                        }
 
123
                        break;
 
124
                case 2:
 
125
                        switch ([[card cardType] intValue]) {
 
126
                                case threeSided:
 
127
                                        cell.textLabel.text = [factletDictionary valueForKey:@"t"];
 
128
                                        break;
 
129
                                default:
 
130
                                        cell.textLabel.text = @"card has no third side.";
 
131
                                        break;
 
132
                        }
 
133
                        break;
 
134
                default:
 
135
                        break;
 
136
        }
 
137
        
 
138
    return cell;
 
139
}
 
140
 
 
141
 
 
142
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
 
143
        NSLog(@"CardEditViewController.tableView.didSelectRowAtIndexPath @%",indexPath);
 
144
}
 
145
 
 
146
 
 
147
/*
 
148
 // Override to support conditional editing of the table view.
 
149
 - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
 
150
 // Return NO if you do not want the specified item to be editable.
 
151
 return YES;
 
152
 }
 
153
 */
 
154
 
 
155
 
 
156
/*
 
157
 // Override to support editing the table view.
 
158
 - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
 
159
 
 
160
 if (editingStyle == UITableViewCellEditingStyleDelete) {
 
161
 // Delete the row from the data source
 
162
 [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
 
163
 }   
 
164
 else if (editingStyle == UITableViewCellEditingStyleInsert) {
 
165
 // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
 
166
 }   
 
167
 }
 
168
 */
 
169
 
 
170
 
 
171
/*
 
172
 // Override to support rearranging the table view.
 
173
 - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
 
174
 }
 
175
 */
 
176
 
 
177
 
 
178
/*
 
179
 // Override to support conditional rearranging of the table view.
 
180
 - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
 
181
 // Return NO if you do not want the item to be re-orderable.
 
182
 return YES;
 
183
 }
 
184
 */
 
185
 
45
186
- (void)didReceiveMemoryWarning {
46
187
        // Releases the view if it doesn't have a superview.
47
188
    [super didReceiveMemoryWarning];