Skip to content
Snippets Groups Projects
Commit a8dcf02e authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

fix for ipad

parent 5fd9042f
Branches
Tags
No related merge requests found
...@@ -9,10 +9,13 @@ ...@@ -9,10 +9,13 @@
-(void)viewDidLoad -(void)viewDidLoad
{ {
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init]; UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
[refreshControl addTarget:self action:@selector(refreshList) forControlEvents:UIControlEventValueChanged]; [refreshControl addTarget:self action:@selector(refreshList)
forControlEvents:UIControlEventValueChanged];
self.refreshControl = refreshControl; self.refreshControl = refreshControl;
UILongPressGestureRecognizer *lpgr = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)]; UILongPressGestureRecognizer *lpgr =
[[UILongPressGestureRecognizer alloc] initWithTarget:self
action:@selector(handleLongPress:)];
lpgr.minimumPressDuration = 1.0; lpgr.minimumPressDuration = 1.0;
[self.tableView addGestureRecognizer:lpgr]; [self.tableView addGestureRecognizer:lpgr];
...@@ -32,7 +35,11 @@ ...@@ -32,7 +35,11 @@
} }
[models sortUsingSelector:@selector(compare:)]; [models sortUsingSelector:@selector(compare:)];
UIBarButtonItem *about = [[UIBarButtonItem alloc] initWithTitle:@"About" style:UIBarButtonItemStylePlain target:self action:@selector(showAbout)]; UIBarButtonItem *about =
[[UIBarButtonItem alloc] initWithTitle:@"About"
style:UIBarButtonItemStylePlain
target:self
action:@selector(showAbout)];
[self.navigationItem setRightBarButtonItems:[NSArray arrayWithObjects: about, nil]]; [self.navigationItem setRightBarButtonItems:[NSArray arrayWithObjects: about, nil]];
} }
...@@ -86,7 +93,8 @@ ...@@ -86,7 +93,8 @@
Model *m = [models objectAtIndex:indexPath.row]; Model *m = [models objectAtIndex:indexPath.row];
cell = [tableView dequeueReusableCellWithIdentifier:[m getName]]; cell = [tableView dequeueReusableCellWithIdentifier:[m getName]];
if(cell != nil) return cell; if(cell != nil) return cell;
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:[m getName]]; cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:[m getName]];
[cell.textLabel setText:[m getName]]; [cell.textLabel setText:[m getName]];
if([m getSummary] != nil) [cell.detailTextLabel setText:[m getSummary]]; if([m getSummary] != nil) [cell.detailTextLabel setText:[m getSummary]];
if([m getPreview] != nil) cell.imageView.image = [m getPreview]; if([m getPreview] != nil) cell.imageView.image = [m getPreview];
...@@ -114,7 +122,9 @@ ...@@ -114,7 +122,9 @@
[UIView transitionWithView:appDelegate.window [UIView transitionWithView:appDelegate.window
duration:0.5 duration:0.5
options:UIViewAnimationOptionTransitionFlipFromLeft options:UIViewAnimationOptionTransitionFlipFromLeft
animations:^{ appDelegate.window.rootViewController = appDelegate.splitViewController; } animations:^{
appDelegate.window.rootViewController = appDelegate.splitViewController;
}
completion:nil]; completion:nil];
} }
else{ else{
...@@ -129,14 +139,28 @@ ...@@ -129,14 +139,28 @@
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:p]; NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:p];
if(indexPath == nil) return; if(indexPath == nil) return;
if([[models objectAtIndex:indexPath.row] getUrl]) if([[models objectAtIndex:indexPath.row] getUrl])
self.longPressActionSheet = [[UIActionSheet alloc] initWithTitle:[[models objectAtIndex:indexPath.row] getName] delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles: @"Open", @"Remove", @"Clear results", @"Edit model files", @"Email model files", @"Visit model website", nil]; self.longPressActionSheet =
[[UIActionSheet alloc] initWithTitle:[[models objectAtIndex:indexPath.row] getName]
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles: @"Open", @"Remove", @"Clear results",
@"Edit model files", @"Email model files",
@"Visit model website", nil];
else else
self.longPressActionSheet = [[UIActionSheet alloc] initWithTitle:[[models objectAtIndex:indexPath.row] getName] delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles: @"Open", @"Remove", @"Clear results", @"Edit model files", @"Email model files", nil]; self.longPressActionSheet =
[[UIActionSheet alloc] initWithTitle:[[models objectAtIndex:indexPath.row] getName]
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles: @"Open", @"Remove", @"Clear results",
@"Edit model files", @"Email model files",
nil];
self.longPressActionSheet.tag = indexPath.row; self.longPressActionSheet.tag = indexPath.row;
[self.longPressActionSheet showInView:self.view]; [self.longPressActionSheet showInView:self.view];
} }
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex -(void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{ {
if(actionSheet == self.longPressActionSheet){ if(actionSheet == self.longPressActionSheet){
switch (buttonIndex) { switch (buttonIndex) {
...@@ -147,7 +171,8 @@ ...@@ -147,7 +171,8 @@
{ {
NSString *modelFile = [[models objectAtIndex:actionSheet.tag] getFile]; NSString *modelFile = [[models objectAtIndex:actionSheet.tag] getFile];
NSString *modelPath = [modelFile stringByDeletingLastPathComponent]; NSString *modelPath = [modelFile stringByDeletingLastPathComponent];
NSArray *modelFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:modelPath error:NULL]; NSArray *modelFiles = [[NSFileManager defaultManager]
contentsOfDirectoryAtPath:modelPath error:NULL];
// TODO: would probably be better to email a zip archive? (this ignores subdirectories) // TODO: would probably be better to email a zip archive? (this ignores subdirectories)
[self attachFilesToEmail:modelFiles filePath:modelPath]; [self attachFilesToEmail:modelFiles filePath:modelPath];
} }
...@@ -156,8 +181,10 @@ ...@@ -156,8 +181,10 @@
{ {
NSString *modelFile = [[models objectAtIndex:actionSheet.tag] getFile]; NSString *modelFile = [[models objectAtIndex:actionSheet.tag] getFile];
NSString *modelPath = [modelFile stringByDeletingLastPathComponent]; NSString *modelPath = [modelFile stringByDeletingLastPathComponent];
NSArray *modelFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:modelPath error:NULL]; NSArray *modelFiles = [[NSFileManager defaultManager]
self.editFilesActionSheet = [[UIActionSheet alloc] initWithTitle:@"Model files" delegate:self contentsOfDirectoryAtPath:modelPath error:NULL];
self.editFilesActionSheet = [[UIActionSheet alloc] initWithTitle:@"Model files"
delegate:self
cancelButtonTitle: nil cancelButtonTitle: nil
destructiveButtonTitle: nil destructiveButtonTitle: nil
otherButtonTitles: nil]; otherButtonTitles: nil];
...@@ -170,16 +197,18 @@ ...@@ -170,16 +197,18 @@
[self.editFilesActionSheet addButtonWithTitle:file]; [self.editFilesActionSheet addButtonWithTitle:file];
} }
} }
self.editFilesActionSheet.cancelButtonIndex = [self.editFilesActionSheet addButtonWithTitle:@"Cancel"]; self.editFilesActionSheet.cancelButtonIndex =
self.editFilesActionSheet.tag = actionSheet.tag; [self.editFilesActionSheet addButtonWithTitle:@"Cancel"];
self.editFilesActionSheet.tag = self.longPressActionSheet.tag;
[self.editFilesActionSheet showInView:self.view]; [self.editFilesActionSheet showInView:self.view];
} }
break; break;
case 2: case 2:
{ {
NSString *modelFile = [[models objectAtIndex:actionSheet.tag] getFile]; NSString *modelFile = [[models objectAtIndex:actionSheet.tag] getFile];
NSString *modelPath = [modelFile stringByDeletingLastPathComponent]; NSString *modelPath = [modelFile stringByDeletingLastPathComponent];
NSArray *modelFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:modelPath error:NULL]; NSArray *modelFiles = [[NSFileManager defaultManager]
contentsOfDirectoryAtPath:modelPath error:NULL];
for (NSString *obj in modelFiles){ for (NSString *obj in modelFiles){
NSString *extension = [obj pathExtension]; NSString *extension = [obj pathExtension];
if([extension isEqualToString:@"msh"] || if([extension isEqualToString:@"msh"] ||
...@@ -202,7 +231,8 @@ ...@@ -202,7 +231,8 @@
} }
break; break;
case 0: case 0:
[self tableView:self.tableView didSelectRowAtIndexPath:[NSIndexPath indexPathForRow:actionSheet.tag inSection:0]]; [self tableView:self.tableView
didSelectRowAtIndexPath:[NSIndexPath indexPathForRow:actionSheet.tag inSection:0]];
break; break;
} }
} }
...@@ -263,13 +293,15 @@ ...@@ -263,13 +293,15 @@
} }
- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error - (void) mailComposeController:(MFMailComposeViewController *)controller
didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{ {
switch (result){ switch (result){
case MFMailComposeResultCancelled: NSLog(@"Mail cancelled"); break; case MFMailComposeResultCancelled: NSLog(@"Mail cancelled"); break;
case MFMailComposeResultSaved: NSLog(@"Mail saved"); break; case MFMailComposeResultSaved: NSLog(@"Mail saved"); break;
case MFMailComposeResultSent: NSLog(@"Mail sent"); break; case MFMailComposeResultSent: NSLog(@"Mail sent"); break;
case MFMailComposeResultFailed: NSLog(@"Mail sent failure: %@", [error localizedDescription]); break; case MFMailComposeResultFailed: NSLog(@"Mail sent failure: %@",
[error localizedDescription]); break;
default: break; default: break;
} }
// Close the Mail Interface // Close the Mail Interface
...@@ -290,7 +322,9 @@ ...@@ -290,7 +322,9 @@
return [parser parse]; return [parser parse];
} }
-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict -(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
attributes:(NSDictionary *)attributeDict
{ {
currentElement = elementName; currentElement = elementName;
//[currentElementValue release]; //[currentElementValue release];
...@@ -305,7 +339,8 @@ ...@@ -305,7 +339,8 @@
[currentElementValue appendString:string]; [currentElementValue appendString:string];
} }
-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName -(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{ {
if([elementName isEqual:@"title"]) { if([elementName isEqual:@"title"]) {
for(Model *mp in models) { for(Model *mp in models) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment