From 13dc9ff76d1eef882b7fcc21b35ef082ec8587d5 Mon Sep 17 00:00:00 2001 From: hsoft Date: Mon, 2 Nov 2009 15:16:34 +0000 Subject: [PATCH] Fixed a bug where the details panel would sometimes not be updated. Also, pushed the details toggling mechanism in dgbase. --HG-- extra : convert_revision : svn%3Ac306627e-7827-47d3-bdf0-9a457c9553a1/trunk%40239 --- base/cocoa/AppDelegate.h | 3 +++ base/cocoa/AppDelegate.m | 1 + base/cocoa/DetailsPanel.h | 1 + base/cocoa/DetailsPanel.m | 11 +++++++++++ base/cocoa/ResultWindow.h | 2 +- base/cocoa/ResultWindow.m | 5 +++++ se/cocoa/AppDelegate.m | 9 +++++++++ se/cocoa/ResultWindow.h | 3 --- se/cocoa/ResultWindow.m | 11 ----------- 9 files changed, 31 insertions(+), 15 deletions(-) diff --git a/base/cocoa/AppDelegate.h b/base/cocoa/AppDelegate.h index b24b044d..50d4eea8 100644 --- a/base/cocoa/AppDelegate.h +++ b/base/cocoa/AppDelegate.h @@ -10,6 +10,7 @@ http://www.hardcoded.net/licenses/hs_license #import "RecentDirectories.h" #import "PyDupeGuru.h" #import "ResultWindow.h" +#import "DetailsPanel.h" @interface AppDelegateBase : NSObject { @@ -19,9 +20,11 @@ http://www.hardcoded.net/licenses/hs_license IBOutlet ResultWindowBase *result; NSString *_appName; + DetailsPanelBase *_detailsPanel; } - (IBAction)unlockApp:(id)sender; - (PyDupeGuruBase *)py; - (RecentDirectories *)recentDirectories; +- (DetailsPanelBase *)detailsPanel; // Virtual @end diff --git a/base/cocoa/AppDelegate.m b/base/cocoa/AppDelegate.m index 092e95e4..fd915a26 100644 --- a/base/cocoa/AppDelegate.m +++ b/base/cocoa/AppDelegate.m @@ -35,6 +35,7 @@ http://www.hardcoded.net/licenses/hs_license - (PyDupeGuruBase *)py { return py; } - (RecentDirectories *)recentDirectories { return recentDirectories; } +- (DetailsPanelBase *)detailsPanel { return nil; } // Virtual /* Delegate */ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification diff --git a/base/cocoa/DetailsPanel.h b/base/cocoa/DetailsPanel.h index a9965268..60c2eb4b 100644 --- a/base/cocoa/DetailsPanel.h +++ b/base/cocoa/DetailsPanel.h @@ -18,6 +18,7 @@ http://www.hardcoded.net/licenses/hs_license - (id)initWithPy:(PyApp *)aPy; - (void)refresh; +- (void)toggleVisibility; /* Notifications */ - (void)duplicateSelectionChanged:(NSNotification *)aNotification; diff --git a/base/cocoa/DetailsPanel.m b/base/cocoa/DetailsPanel.m index 859a6d42..e31ad177 100644 --- a/base/cocoa/DetailsPanel.m +++ b/base/cocoa/DetailsPanel.m @@ -24,6 +24,17 @@ http://www.hardcoded.net/licenses/hs_license [detailsTable reloadData]; } +- (void)toggleVisibility +{ + if ([[self window] isVisible]) + [[self window] close]; + else + { + [self refresh]; // selection might have changed since last time + [[self window] orderFront:nil]; + } +} + /* Notifications */ - (void)duplicateSelectionChanged:(NSNotification *)aNotification { diff --git a/base/cocoa/ResultWindow.h b/base/cocoa/ResultWindow.h index ae00a2b8..05115497 100644 --- a/base/cocoa/ResultWindow.h +++ b/base/cocoa/ResultWindow.h @@ -8,7 +8,6 @@ http://www.hardcoded.net/licenses/hs_license #import #import "Outline.h" -#import "DirectoryPanel.h" #import "PyDupeGuru.h" @interface MatchesView : OutlineView @@ -56,6 +55,7 @@ http://www.hardcoded.net/licenses/hs_license - (IBAction)showPreferencesPanel:(id)sender; - (IBAction)switchSelected:(id)sender; - (IBAction)toggleColumn:(id)sender; +- (IBAction)toggleDetailsPanel:(id)sender; - (IBAction)togglePowerMarker:(id)sender; /* Notifications */ diff --git a/base/cocoa/ResultWindow.m b/base/cocoa/ResultWindow.m index 1a010610..1c5e9a96 100644 --- a/base/cocoa/ResultWindow.m +++ b/base/cocoa/ResultWindow.m @@ -346,6 +346,11 @@ http://www.hardcoded.net/licenses/hs_license } } +- (IBAction)toggleDetailsPanel:(id)sender +{ + [[(AppDelegateBase *)app detailsPanel] toggleVisibility]; +} + - (IBAction)togglePowerMarker:(id)sender { if ([pmSwitch selectedSegment] == 1) diff --git a/se/cocoa/AppDelegate.m b/se/cocoa/AppDelegate.m index dbb7d071..d3ecb58e 100644 --- a/se/cocoa/AppDelegate.m +++ b/se/cocoa/AppDelegate.m @@ -11,6 +11,7 @@ http://www.hardcoded.net/licenses/hs_license #import "cocoalib/RegistrationInterface.h" #import "cocoalib/Utils.h" #import "cocoalib/ValueTransformers.h" +#import "DetailsPanel.h" #import "Consts.h" @implementation AppDelegate @@ -62,6 +63,14 @@ http://www.hardcoded.net/licenses/hs_license _directoryPanel = [[DirectoryPanel alloc] initWithParentApp:self]; return _directoryPanel; } + +- (DetailsPanelBase *)detailsPanel +{ + if (!_detailsPanel) + _detailsPanel = [[DetailsPanel alloc] initWithPy:py]; + return _detailsPanel; +} + - (PyDupeGuru *)py { return (PyDupeGuru *)py; } //Delegate diff --git a/se/cocoa/ResultWindow.h b/se/cocoa/ResultWindow.h index 2794a995..86ec8305 100644 --- a/se/cocoa/ResultWindow.h +++ b/se/cocoa/ResultWindow.h @@ -9,7 +9,6 @@ http://www.hardcoded.net/licenses/hs_license #import #import "cocoalib/Outline.h" #import "dgbase/ResultWindow.h" -#import "DetailsPanel.h" #import "DirectoryPanel.h" @interface ResultWindow : ResultWindowBase @@ -17,7 +16,6 @@ http://www.hardcoded.net/licenses/hs_license IBOutlet NSSearchField *filterField; NSString *_lastAction; - DetailsPanel *_detailsPanel; NSMutableIndexSet *_deltaColumns; } - (IBAction)clearIgnoreList:(id)sender; @@ -37,5 +35,4 @@ http://www.hardcoded.net/licenses/hs_license - (IBAction)revealSelected:(id)sender; - (IBAction)startDuplicateScan:(id)sender; - (IBAction)toggleDelta:(id)sender; -- (IBAction)toggleDetailsPanel:(id)sender; @end diff --git a/se/cocoa/ResultWindow.m b/se/cocoa/ResultWindow.m index 7f70d11a..942f4291 100644 --- a/se/cocoa/ResultWindow.m +++ b/se/cocoa/ResultWindow.m @@ -18,7 +18,6 @@ http://www.hardcoded.net/licenses/hs_license - (void)awakeFromNib { [super awakeFromNib]; - _detailsPanel = nil; _displayDelta = NO; _powerMode = NO; _deltaColumns = [[NSMutableIndexSet indexSetWithIndexesInRange:NSMakeRange(2,4)] retain]; @@ -200,16 +199,6 @@ http://www.hardcoded.net/licenses/hs_license [self changeDelta:sender]; } -- (IBAction)toggleDetailsPanel:(id)sender -{ - if (!_detailsPanel) - _detailsPanel = [[DetailsPanel alloc] initWithPy:py]; - if ([[_detailsPanel window] isVisible]) - [[_detailsPanel window] close]; - else - [[_detailsPanel window] orderFront:nil]; -} - /* Public */ - (void)initResultColumns {