• R/O
  • HTTP
  • SSH
  • HTTPS

Tombo: Commit

TOMBO source code


Commit MetaInfo

Revisiond8df42dcb4f5b97ac5e732b3a4203c100f703ed4 (tree)
Time2012-04-03 19:06:00
AuthorHirami <tomohisa.hirami@nift...>
CommiterHirami

Log Message

Implement delete file/folder.

Change Summary

Incremental Difference

--- a/iOS/Tombo/Tombo/MasterViewController.m
+++ b/iOS/Tombo/Tombo/MasterViewController.m
@@ -6,7 +6,7 @@
66 #import "Storage.h"
77 #import "FileItem.h"
88
9-@interface MasterViewController () <UIAlertViewDelegate, UITableViewDelegate> {
9+@interface MasterViewController () <UIAlertViewDelegate, UITableViewDelegate, UISplitViewControllerDelegate> {
1010 NSMutableArray *_objects;
1111 Storage *storage;
1212
@@ -35,6 +35,7 @@
3535 // Do any additional setup after loading the view, typically from a nib.
3636 self.detailViewController = (DetailViewController *)[[self.splitViewController.viewControllers lastObject] topViewController];
3737 self.detailViewController.master = self;
38+ self.splitViewController.delegate = self;
3839
3940 imgFolder = nil;
4041 imgDocument = nil;
@@ -58,6 +59,7 @@
5859 if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
5960 return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
6061 } else {
62+
6163 return YES;
6264 }
6365 }
@@ -120,6 +122,11 @@
120122 i++;
121123 }
122124 }
125+
126+- (BOOL)splitViewController:(UISplitViewController *)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation {
127+ return NO;
128+}
129+
123130 #pragma mark - Table View
124131
125132 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
@@ -161,14 +168,20 @@
161168 - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
162169 {
163170 // Return NO if you do not want the specified item to be editable.
171+ FileItem *item = [_objects objectAtIndex:indexPath.row];
172+ if (item.isUp) return NO;
164173 return YES;
165174 }
166175
167176 - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
168177 {
169178 if (editingStyle == UITableViewCellEditingStyleDelete) {
179+ FileItem *item = [_objects objectAtIndex:indexPath.row];
180+ [storage deleteItem:item];
181+
170182 [_objects removeObjectAtIndex:indexPath.row];
171- [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
183+ [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
184+ withRowAnimation:UITableViewRowAnimationFade];
172185 } else if (editingStyle == UITableViewCellEditingStyleInsert) {
173186 // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
174187 }
--- a/iOS/Tombo/Tombo/Storage.h
+++ b/iOS/Tombo/Tombo/Storage.h
@@ -40,4 +40,6 @@
4040 * If path is not changed, returns item itself.
4141 */
4242 -(FileItem *)save:(NSString *)note item:(FileItem *)item;
43+
44+- (void)deleteItem:(FileItem*)item;
4345 @end
--- a/iOS/Tombo/Tombo/Storage.m
+++ b/iOS/Tombo/Tombo/Storage.m
@@ -153,4 +153,8 @@
153153 return p;
154154 }
155155
156+- (void)deleteItem:(FileItem*)item {
157+ [fileManager removeItemAtPath:item.path error:nil];
158+}
159+
156160 @end
Show on old repository browser