diff options
-rw-r--r-- | Source/SPConnectionControllerDelegate.m | 17 | ||||
-rw-r--r-- | Source/SPFavoritesImporter.m | 4 |
2 files changed, 16 insertions, 5 deletions
diff --git a/Source/SPConnectionControllerDelegate.m b/Source/SPConnectionControllerDelegate.m index a6001309..ec1c65f1 100644 --- a/Source/SPConnectionControllerDelegate.m +++ b/Source/SPConnectionControllerDelegate.m @@ -57,6 +57,7 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; - (void)_sortFavorites; - (void)_favoriteTypeDidChange; - (void)_reloadFavoritesViewData; +- (void)_scrollToSelectedNode; - (NSString *)_stripInvalidCharactersFromString:(NSString *)subject; @@ -665,17 +666,29 @@ static NSString *SPQuickConnectImageWhite = @"quick-connect-icon-white.pdf"; */ - (void)favoritesImportData:(NSArray *)data { + SPTreeNode *newNode; + NSMutableArray *importedNodes = [NSMutableArray array]; + NSMutableIndexSet *importedIndexSet = [NSMutableIndexSet indexSet]; + // Add each of the imported favorites to the root node for (NSMutableDictionary *favorite in data) { - [favoritesController addFavoriteNodeWithData:favorite asChildOfNode:nil]; + newNode = [favoritesController addFavoriteNodeWithData:favorite asChildOfNode:nil]; + [importedNodes addObject:newNode]; } if (currentSortItem > SPFavoritesSortUnsorted) { [self _sortFavorites]; -} + } [self _reloadFavoritesViewData]; + + // Select the new nodes and scroll into view + for (SPTreeNode *eachNode in importedNodes) { + [importedIndexSet addIndex:[favoritesOutlineView rowForItem:eachNode]]; + } + [favoritesOutlineView selectRowIndexes:importedIndexSet byExtendingSelection:NO]; + [self _scrollToSelectedNode]; } /** diff --git a/Source/SPFavoritesImporter.m b/Source/SPFavoritesImporter.m index f33e1705..bb027104 100644 --- a/Source/SPFavoritesImporter.m +++ b/Source/SPFavoritesImporter.m @@ -73,12 +73,10 @@ NSFileManager *fileManager = [NSFileManager defaultManager]; if ([fileManager fileExistsAtPath:[self importPath]]) { - importData = [[NSDictionary alloc] initWithContentsOfFile:[self importPath]]; + importData = [[[NSDictionary alloc] initWithContentsOfFile:[self importPath]] autorelease]; NSArray *favorites = [importData valueForKey:SPFavoritesDataRootKey]; - [importData release]; - if (favorites) { [self _informDelegateOfImportDataAvailable:favorites]; } |