@implementation SectionController
-- (void) dealloc {
- [super dealloc];
-}
-
- (id) initWithDatabase:(Database *)database section:(NSString *)name {
NSString *title;
} return self;
}
-- (void) reloadData {
- [packages_ reloadData];
-}
-
-- (void) setDelegate:(id)delegate {
- [super setDelegate:delegate];
- [packages_ setDelegate:delegate];
-}
-
@end
/* }}} */
/* Sections Controller {{{ */
@end
/* }}} */
-/* Source Table {{{ */
+/* Source Controller {{{ */
+@interface SourceController : FilteredPackageController {
+}
+
+- (id) initWithDatabase:(Database *)database source:(Source *)source;
+
+@end
+
+@implementation SourceController
+
+- (id) initWithDatabase:(Database *)database source:(Source *)source {
+ if ((self = [super initWithDatabase:database title:[source label] filter:@selector(isVisibleInSource:) with:source]) != nil) {
+ } return self;
+}
+
+@end
+/* }}} */
+/* Sources Controller {{{ */
@interface SourcesController : CYViewController <
UITableViewDataSource,
UITableViewDelegate
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
Source *source = [self sourceAtIndexPath:indexPath];
- FilteredPackageController *packages = [[[FilteredPackageController alloc]
+ SourceController *controller = [[[SourceController alloc]
initWithDatabase:database_
- title:[source label]
- filter:@selector(isVisibleInSource:)
- with:source
+ source:source
] autorelease];
- [packages setDelegate:delegate_];
+ [controller setDelegate:delegate_];
- [[self navigationController] pushViewController:packages animated:YES];
+ [[self navigationController] pushViewController:controller animated:YES];
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
controller = [[[SourcesController alloc] initWithDatabase:database_] autorelease];
[(SourcesController *)controller showAddSourcePrompt];
} else {
- // XXX: Create page of the source specfified.
+ NSArray *sources = [database_ sources];
+ for (Source *source in sources) {
+ if ([[source name] caseInsensitiveCompare:argument] == NSOrderedSame) {
+ controller = [[[SourceController alloc] initWithDatabase:database_ source:source] autorelease];
+ break;
+ }
+ }
}
}