From f3e65efba3f76cb2149fd8427af9463032d3c45d Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Sun, 12 Jun 2011 13:56:11 +0000 Subject: Add the ability to export favorites. --- Source/SPConnectionController.m | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'Source/SPConnectionController.m') diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m index 0f12303f..6ed6e392 100644 --- a/Source/SPConnectionController.m +++ b/Source/SPConnectionController.m @@ -38,6 +38,8 @@ #import "SPGeneralPreferencePane.h" #import "SPDatabaseViewController.h" #import "SPTreeNode.h" +#import "SPFavoritesExporter.h" +#import "SPFavoritesImporter.h" // Constants static NSString *SPRemoveNode = @"RemoveNode"; @@ -989,6 +991,8 @@ static NSComparisonResult compareFavoritesUsingKey(id favorite1, id favorite2, v { NSSavePanel *savePanel = [NSSavePanel savePanel]; + [savePanel setAccessoryView:exportPanelAccessoryView]; + [savePanel beginSheetForDirectory:nil file:SPExportFavoritesFilename modalForWindow:[dbDocument parentWindow] @@ -1131,9 +1135,20 @@ static NSComparisonResult compareFavoritesUsingKey(id favorite1, id favorite2, v /** * Called when the user dismisses either the import of export favorites panels. */ -- (void)importExportFavoritesSheetDidEnd:(NSOpenPanel *)openPanel returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo +- (void)importExportFavoritesSheetDidEnd:(NSOpenPanel *)panel returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo { + NSError *error = nil; + if (contextInfo == SPExportFavorites) { + SPFavoritesExporter *exporter = [[[SPFavoritesExporter alloc] init] autorelease]; + + [exporter setDelegate:self]; + + [exporter writeFavorites:[self selectedFavoriteNodes] toFile:[panel filename] error:&error]; + } + else if (contextInfo == SPImportFavorites) { + //SPFavoritesImporter *importer = [[SPFavoritesImporter alloc] init]; + } } /** -- cgit v1.2.3