aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPExportControllerDelegate.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2013-03-04 00:02:33 +0000
committerrowanbeentje <rowan@beent.je>2013-03-04 00:02:33 +0000
commitf2545c5e4fc4414d4ee448de4a5f399d6cf58ad2 (patch)
tree1d523fb5fc8ace7f75401ce0a0c883592cd01ff4 /Source/SPExportControllerDelegate.m
parent5ab13b27148a09e5bbf28c9ecfb7a8303b42462d (diff)
downloadsequelpro-f2545c5e4fc4414d4ee448de4a5f399d6cf58ad2.tar.gz
sequelpro-f2545c5e4fc4414d4ee448de4a5f399d6cf58ad2.tar.bz2
sequelpro-f2545c5e4fc4414d4ee448de4a5f399d6cf58ad2.zip
- Add support for export path tokens containing non-alphanumeric characters, automatically grouping and tokenising as required for both dragged and typed tokens. This addresses Issue #1567.
Diffstat (limited to 'Source/SPExportControllerDelegate.m')
-rw-r--r--Source/SPExportControllerDelegate.m27
1 files changed, 27 insertions, 0 deletions
diff --git a/Source/SPExportControllerDelegate.m b/Source/SPExportControllerDelegate.m
index ef084283..8c273813 100644
--- a/Source/SPExportControllerDelegate.m
+++ b/Source/SPExportControllerDelegate.m
@@ -112,8 +112,10 @@
- (NSArray *)tokenField:(NSTokenField *)tokenField shouldAddObjects:(NSArray *)tokens atIndex:(NSUInteger)index
{
NSUInteger i, j;
+ NSInteger k;
NSMutableArray *processedTokens = [NSMutableArray array];
NSCharacterSet *alphanumericSet = [NSCharacterSet alphanumericCharacterSet];
+ id groupToken;
for (NSString *inputToken in tokens)
{
@@ -137,6 +139,31 @@
}
}
+ // Check to see whether unprocessed strings can be combined to form tokens
+ for (i = 1; i < [processedTokens count]; i++) {
+
+ // If this is a token object, skip
+ if ([[processedTokens objectAtIndex:i] isKindOfClass:[SPExportFileNameTokenObject class]]) {
+ continue;
+ }
+
+ for (k = i - 1; k >= 0; k--) {
+
+ // If this is a token object, stop processing
+ if ([[processedTokens objectAtIndex:k] isKindOfClass:[SPExportFileNameTokenObject class]]) {
+ break;
+ }
+
+ // Check whether the group of items make up a token
+ groupToken = [self tokenObjectForString:[[processedTokens subarrayWithRange:NSMakeRange(k, 1 + i - k)] componentsJoinedByString:@""]];
+ if ([groupToken isKindOfClass:[SPExportFileNameTokenObject class]]) {
+ [processedTokens replaceObjectsInRange:NSMakeRange(k, 1 + i - k) withObjectsFromArray:[NSArray arrayWithObject:groupToken]];
+ i = k + 1;
+ break;
+ }
+ }
+ }
+
return processedTokens;
}