diff options
author | rowanbeentje <rowan@beent.je> | 2009-12-16 01:01:34 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2009-12-16 01:01:34 +0000 |
commit | d915e45bc51b59618a054ececa38d46898603a3b (patch) | |
tree | 3280e9b03e7afa38f06d50baada86eeef49409bd /Source/SPPreferenceController.m | |
parent | 03ac736b6aac57d700a43184a062cf5e29a50d9e (diff) | |
download | sequelpro-32683976ba68c64da8d93cccaae588e3a3f74242.tar.gz sequelpro-32683976ba68c64da8d93cccaae588e3a3f74242.tar.bz2 sequelpro-32683976ba68c64da8d93cccaae588e3a3f74242.zip |
- Merge in r1608 (SPF saving of custom SSH ports), r1610 (Fix multi-line favourite titles), r1619 (History navigation task not closed) and r1622 (Pagination interface clarification) to the 0.9.7 branchrelease-0.9.7
Diffstat (limited to 'Source/SPPreferenceController.m')
-rw-r--r-- | Source/SPPreferenceController.m | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/Source/SPPreferenceController.m b/Source/SPPreferenceController.m index 38c76f9e..ce7c7424 100644 --- a/Source/SPPreferenceController.m +++ b/Source/SPPreferenceController.m @@ -267,21 +267,31 @@ [prefs setObject:[NSDictionary dictionaryWithDictionary:toolbarDict] forKey:@"NSToolbar Configuration TableWindowToolbar"]; } - // For versions prior to r1598 (~0.9.7), convert the query favorites array to an array of dictionaries - if (recordedVersionNumber < 1598 && [prefs objectForKey:SPQueryFavorites]) { + // For versions prior to r1609 (~0.9.7), convert the query favorites array to an array of dictionaries + if (recordedVersionNumber < 1609 && [prefs objectForKey:SPQueryFavorites]) { NSMutableArray *queryFavoritesArray = [NSMutableArray arrayWithArray:[prefs objectForKey:SPQueryFavorites]]; for (i = 0; i < [queryFavoritesArray count]; i++) { id favorite = [queryFavoritesArray objectAtIndex:i]; - if (([favorite isKindOfClass:[NSDictionary class]]) && ([favorite objectForKey:@"name"]) && ([favorite objectForKey:@"query"])) continue; + // If the favorite is already a dictionary, just make sure there's no newlines in the title + if (([favorite isKindOfClass:[NSDictionary class]]) && ([favorite objectForKey:@"name"]) && ([favorite objectForKey:@"query"])) { + NSMutableString *favoriteName = [NSMutableString stringWithString:[favorite objectForKey:@"name"]]; + [favoriteName replaceOccurrencesOfString:@"\n" withString:@" " options:NSLiteralSearch range:NSMakeRange(0, [favoriteName length])]; + [queryFavoritesArray replaceObjectAtIndex:i withObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:[NSString stringWithString:favoriteName], [favorite objectForKey:@"query"], nil] forKeys:[NSArray arrayWithObjects:@"name", @"query", nil]]]; + continue; + } - // By default make the query's name the first 32 characters of the query with '...' appended - int idx = ( [favorite length] > 32 ) ? 32 : [favorite length]-1; - NSString *favoriteName = [[[favorite stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]] substringToIndex:idx] stringByAppendingString:@"..."]; - - [queryFavoritesArray replaceObjectAtIndex:i withObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:favoriteName, favorite, nil] forKeys:[NSArray arrayWithObjects:@"name", @"query", nil]]]; + // By default make the query's name the first 32 characters of the query with '...' appended, stripping newlines + NSMutableString *favoriteName = [NSMutableString stringWithString:[favorite stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]]]; + [favoriteName replaceOccurrencesOfString:@"\n" withString:@" " options:NSLiteralSearch range:NSMakeRange(0, [favoriteName length])]; + if ([favoriteName length] > 32) { + [favoriteName deleteCharactersInRange:NSMakeRange(32, [favoriteName length] - 32)]; + [favoriteName appendString:@"..."]; + } + + [queryFavoritesArray replaceObjectAtIndex:i withObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:[NSString stringWithString:favoriteName], favorite, nil] forKeys:[NSArray arrayWithObjects:@"name", @"query", nil]]]; } [prefs setObject:queryFavoritesArray forKey:SPQueryFavorites]; |