From 862396873ddb3d4017a5ab323ae0be6bded755b8 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Tue, 18 Nov 2008 01:46:48 +0000 Subject: Add support for marking the content for a required refresh on structure changes. Implemented by adding a method to TablesList (setContentRequiresReload) and using it when modifying the tble structure, thus only refreshing if the content is actually viewed again. --- TableSource.m | 13 +++++++++++++ TablesList.h | 3 +++ TablesList.m | 10 ++++++++++ 3 files changed, 26 insertions(+) diff --git a/TableSource.m b/TableSource.m index d43b83c5..9259a0b4 100644 --- a/TableSource.m +++ b/TableSource.m @@ -383,6 +383,9 @@ opens alertsheet and asks for confirmation [tableType retain]; // [[NSNotificationCenter defaultCenter] postNotificationName:@"SelectedTableStatusHasChanged" object:self]; + + // Mark the content table for refresh + [tablesListInstance setContentRequiresReload]; } else { [sender selectItemWithTitle:tableType]; NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, @@ -642,6 +645,10 @@ returns YES if no row is beeing edited and nothing has to be written to db isEditingRow = NO; isEditingNewRow = NO; [self loadTable:selectedTable]; + + // Mark the content table for refresh + [tablesListInstance setContentRequiresReload]; + return YES; } else { alertSheetOpened = YES; @@ -694,6 +701,9 @@ returns YES if no row is beeing edited and nothing has to be written to db if ( [[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) { [self loadTable:selectedTable]; + + // Mark the content table for refresh + [tablesListInstance setContentRequiresReload]; } else { NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"Couldn't remove field %@.\nMySQL said: %@", @"message of panel when field cannot be removed"), @@ -913,6 +923,9 @@ Having validated a drop, perform the field/column reordering to match. [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:self]; + // Mark the content table for refresh + [tablesListInstance setContentRequiresReload]; + return YES; } diff --git a/TablesList.h b/TablesList.h index 9a59de88..bc360434 100644 --- a/TablesList.h +++ b/TablesList.h @@ -73,6 +73,9 @@ - (BOOL)contentLoaded; - (BOOL)statusLoaded; +// Setter methods +- (void)setContentRequiresReload; + //tableView datasource methods - (int)numberOfRowsInTableView:(NSTableView *)aTableView; - (id)tableView:(NSTableView *)aTableView diff --git a/TablesList.m b/TablesList.m index 0cad02c5..270cd49b 100644 --- a/TablesList.m +++ b/TablesList.m @@ -341,6 +341,16 @@ returns YES if table status has already been loaded return statusLoaded; } +#pragma mark Setter methods + +/* +Mark the content table for refresh when it's next switched to +*/ +- (void)setContentRequiresReload +{ + contentLoaded = NO; +} + #pragma mark Datasource methods - (int)numberOfRowsInTableView:(NSTableView *)aTableView -- cgit v1.2.3