aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPQueryFavoriteManager.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-01-24 21:39:43 +0000
committerBibiko <bibiko@eva.mpg.de>2010-01-24 21:39:43 +0000
commitcca4f8dc17e904c516dc7e3ba8193aff5b8f9e70 (patch)
tree8d837c62de411b7e939ca06a4181cefcae688eb0 /Source/SPQueryFavoriteManager.m
parent9997d982ca4fcbacb04b41c7f7e2aa7dd44db312 (diff)
downloadsequelpro-cca4f8dc17e904c516dc7e3ba8193aff5b8f9e70.tar.gz
sequelpro-cca4f8dc17e904c516dc7e3ba8193aff5b8f9e70.tar.bz2
sequelpro-cca4f8dc17e904c516dc7e3ba8193aff5b8f9e70.zip
• added possibility to add a query favorite by user-definable alphanumeric tab trigger; eg if tab trigger is set to "sel" sel⇥ will insert the first query which has the defined the tab trigger
• preparations to insert programmable query favorites - eg "SELECT ${*} FROM ${Table}" -- after insertion "SELECT * FROM Table" the '*' is highlighted to change, press ⇥ to select the next snippet 'Table'; ⇧⇥ selects the previous snippet; the snippet selection follows the user input - Note: not yet active
Diffstat (limited to 'Source/SPQueryFavoriteManager.m')
-rw-r--r--Source/SPQueryFavoriteManager.m20
1 files changed, 17 insertions, 3 deletions
diff --git a/Source/SPQueryFavoriteManager.m b/Source/SPQueryFavoriteManager.m
index 2745f83c..a6f8941b 100644
--- a/Source/SPQueryFavoriteManager.m
+++ b/Source/SPQueryFavoriteManager.m
@@ -29,6 +29,7 @@
#import "SPQueryController.h"
#import "SPConstants.h"
#import "SPConnectionController.h"
+#import "RegexKitLite.h"
#define SP_MULTIPLE_SELECTION_PLACEHOLDER_STRING NSLocalizedString(@"[multiple selection]", @"[multiple selection]")
#define SP_NO_SELECTION_PLACEHOLDER_STRING NSLocalizedString(@"[no selection]", @"[no selection]")
@@ -415,9 +416,15 @@
*/
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
{
- if(![[favorites objectAtIndex:rowIndex] objectForKey:[aTableColumn identifier]]) return @"";
- return [[favorites objectAtIndex:rowIndex] objectForKey:[aTableColumn identifier]];
+ if([[aTableColumn identifier] isEqualToString:@"name"]) {
+ if(![[favorites objectAtIndex:rowIndex] objectForKey:@"name"]) return @"";
+ return [[favorites objectAtIndex:rowIndex] objectForKey:@"name"];
+ } else if([[aTableColumn identifier] isEqualToString:@"tabtrigger"]) {
+ if(![[favorites objectAtIndex:rowIndex] objectForKey:@"tabtrigger"] || ![(NSString*)[[favorites objectAtIndex:rowIndex] objectForKey:@"tabtrigger"] length]) return @"";
+ return [NSString stringWithFormat:@"%@⇥", [[favorites objectAtIndex:rowIndex] objectForKey:@"tabtrigger"]];
+ }
+ return @"";
}
/*
@@ -511,7 +518,7 @@
}
/*
- * Changes in the name text field will be saved in data source directly
+ * Changes in the name/tabtrigger text field will be saved in data source directly
* to update the table view accordingly
*/
- (void)controlTextDidChange:(NSNotification *)notification
@@ -525,6 +532,13 @@
if(object == favoriteNameTextField) {
[[favorites objectAtIndex:[favoritesTableView selectedRow]] setObject:[favoriteNameTextField stringValue] forKey:@"name"];
[favoritesTableView reloadData];
+ }
+ else if(object == favoriteTabTriggerTextField){
+ //Validate trigger - it only may contain alphnumeric characters
+ NSString *tabTrigger = [NSString stringWithString:[[favoriteTabTriggerTextField stringValue] stringByReplacingOccurrencesOfRegex:@"[^\\w0-9]" withString:@""]];
+ [favoriteTabTriggerTextField setStringValue:tabTrigger];
+ [[favorites objectAtIndex:[favoritesTableView selectedRow]] setObject:tabTrigger forKey:@"tabtrigger"];
+ [favoritesTableView reloadData];
}
}