From 2183eeefefb81846c2cc2c6b4bf68b12167f2b24 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Sun, 27 Sep 2009 13:26:47 +0000 Subject: =?UTF-8?q?=E2=80=A2=20marked=20'sequel-pro-print-template.html'?= =?UTF-8?q?=20as=20localizable=20=E2=80=A2=20outsourced=20default=20QuickL?= =?UTF-8?q?ook=20types=20into=20a=20localizable=20plist=20-=20prepared=20S?= =?UTF-8?q?P=20preferences=20and=20SP=20code=20to=20allow=20the=20user=20t?= =?UTF-8?q?o=20add=20own=20QL=20types=20=E2=80=A2=20prepared=20a=20localiz?= =?UTF-8?q?able=20'ContentFilter.plist'=20[not=20yet=20implemented=20fully?= =?UTF-8?q?]=20-=20this=20plist=20will=20held=20the=20default=20filter=20o?= =?UTF-8?q?perators=20-=20this=20approach=20will=20give=20the=20user=20the?= =?UTF-8?q?=20chance=20to=20add=20own=20filters=20=E2=80=A2=20removed=20th?= =?UTF-8?q?ree=20tiny=20memory=20leaks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Note: In MCPResult.m variable 'MCPYear0000' was stored retained. Why? I removed it and couldn't encounter any problems. --- Source/CustomQuery.m | 2 ++ Source/SPFieldEditorController.h | 2 ++ Source/SPFieldEditorController.m | 37 +++++++++++++++++++++++++++++++------ 3 files changed, 35 insertions(+), 6 deletions(-) (limited to 'Source') 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])]; } } -- cgit v1.2.3