diff options
author | Bibiko <bibiko@eva.mpg.de> | 2009-09-27 13:26:47 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2009-09-27 13:26:47 +0000 |
commit | 2183eeefefb81846c2cc2c6b4bf68b12167f2b24 (patch) | |
tree | dedc18dc550106e3d889c26fe263b3319f896c06 /Source | |
parent | 572b761e971c732585ef5f0fcf852e1842d44e31 (diff) | |
download | sequelpro-2183eeefefb81846c2cc2c6b4bf68b12167f2b24.tar.gz sequelpro-2183eeefefb81846c2cc2c6b4bf68b12167f2b24.tar.bz2 sequelpro-2183eeefefb81846c2cc2c6b4bf68b12167f2b24.zip |
• marked 'sequel-pro-print-template.html' as localizable
• outsourced default QuickLook types into a localizable plist
- prepared SP preferences and SP code to allow the user to add own QL types
• prepared a localizable 'ContentFilter.plist' [not yet implemented fully]
- this plist will held the default filter operators
- this approach will give the user the chance to add own filters
• removed three tiny memory leaks
Note: In MCPResult.m variable 'MCPYear0000' was stored retained. Why?
I removed it and couldn't encounter any problems.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CustomQuery.m | 2 | ||||
-rw-r--r-- | Source/SPFieldEditorController.h | 2 | ||||
-rw-r--r-- | Source/SPFieldEditorController.m | 37 |
3 files changed, 35 insertions, 6 deletions
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m index f393dc45..3f2afc2f 100644 --- a/Source/CustomQuery.m +++ b/Source/CustomQuery.m @@ -2626,6 +2626,8 @@ [usedQuery release]; [fullResult release]; [favoritesManager release]; + if (helpHTMLTemplate) [helpHTMLTemplate release]; + if (mySQLversion) [mySQLversion release]; if (sortField) [sortField release]; [super dealloc]; diff --git a/Source/SPFieldEditorController.h b/Source/SPFieldEditorController.h index 56b7a2bd..6349f568 100644 --- a/Source/SPFieldEditorController.h +++ b/Source/SPFieldEditorController.h @@ -60,6 +60,8 @@ NSUserDefaults *prefs; + NSDictionary *qlTypes; + int editSheetReturnCode; NSUndoManager *esUndoManager; diff --git a/Source/SPFieldEditorController.m b/Source/SPFieldEditorController.m index 2234681f..bdb78726 100644 --- a/Source/SPFieldEditorController.m +++ b/Source/SPFieldEditorController.m @@ -65,6 +65,32 @@ [menu addItem:item]; [item release]; NSUInteger tag = 2; + + // Load default QL types + NSMutableArray *qlTypesItems = [[NSMutableArray alloc] init]; + NSError *readError = nil; + NSString *convError = nil; + NSPropertyListFormat format; + + NSData *defaultTypeData = [NSData dataWithContentsOfFile:[NSBundle pathForResource:@"EditorQuickLookTypes.plist" ofType:nil inDirectory:[[NSBundle mainBundle] bundlePath]] + options:NSMappedRead error:&readError]; + + NSDictionary *defaultQLTypes = [NSPropertyListSerialization propertyListFromData:defaultTypeData + mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&convError]; + if(defaultQLTypes == nil || readError != nil || convError != nil) + NSLog(@"Error while reading 'EditorQuickLookTypes.plist':\n%@\n%@", [readError localizedDescription], convError); + if(defaultQLTypes != nil && [defaultQLTypes objectForKey:@"QuickLookTypes"]) { + for(id type in [defaultQLTypes objectForKey:@"QuickLookTypes"]) { + NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:[NSString stringWithString:[type objectForKey:@"MenuLabel"]] action:NULL keyEquivalent:@""]; + [item setTag:tag]; + [item setAction:@selector(quickLookFormatButton:)]; + [menu addItem:item]; + [item release]; + tag++; + [qlTypesItems addObject:type]; + } + } + // Load user-defined QL types if([prefs objectForKey:@"QuickLookTypes"]) { for(id type in [prefs objectForKey:@"QuickLookTypes"]) { NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:[NSString stringWithString:[type objectForKey:@"MenuLabel"]] action:NULL keyEquivalent:@""]; @@ -73,9 +99,11 @@ [menu addItem:item]; [item release]; tag++; + [qlTypesItems addObject:type]; } } - + qlTypes = [NSDictionary dictionaryWithObject:[qlTypesItems retain] forKey:@"QuickLookTypes"]; + [qlTypesItems release]; } return self; @@ -510,11 +538,8 @@ - (IBAction)quickLookFormatButton:(id)sender { - - id types = [prefs objectForKey:@"QuickLookTypes"]; - - if(types != nil && [types isKindOfClass:[NSArray class]] && [types count] > [sender tag] - 2) { - NSDictionary *type = [types objectAtIndex:[sender tag] - 2]; + if(qlTypes != nil && [[qlTypes objectForKey:@"QuickLookTypes"] count] > [sender tag] - 2) { + NSDictionary *type = [[qlTypes objectForKey:@"QuickLookTypes"] objectAtIndex:[sender tag] - 2]; [self invokeQuickLookOfType:[type objectForKey:@"Extension"] treatAsText:([[type objectForKey:@"treatAsText"] intValue])]; } } |