diff options
author | stuconnolly <stuart02@gmail.com> | 2009-07-21 00:04:41 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2009-07-21 00:04:41 +0000 |
commit | 8c47108f6de8d04fa7d1cf7dbfc8a4fd423979f5 (patch) | |
tree | 766c97b0f5e82d2e9e39b1f4afa5e4de2f116092 | |
parent | c506398bb7f92644c04f542c067a761e8eee77ee (diff) | |
download | sequelpro-8c47108f6de8d04fa7d1cf7dbfc8a4fd423979f5.tar.gz sequelpro-8c47108f6de8d04fa7d1cf7dbfc8a4fd423979f5.tar.bz2 sequelpro-8c47108f6de8d04fa7d1cf7dbfc8a4fd423979f5.zip |
Improvements to reporting the correct row count for tables. See issue #141.
-rw-r--r-- | Source/SPTableData.h | 1 | ||||
-rw-r--r-- | Source/SPTableData.m | 9 | ||||
-rw-r--r-- | Source/TableContent.m | 20 |
3 files changed, 20 insertions, 10 deletions
diff --git a/Source/SPTableData.h b/Source/SPTableData.h index 02179852..7ed99edd 100644 --- a/Source/SPTableData.h +++ b/Source/SPTableData.h @@ -51,6 +51,7 @@ - (NSArray *) getConstraints; - (BOOL) columnIsBlobOrText:(NSString *)colName; - (NSString *) statusValueForKey:(NSString *)aKey; +- (void)setStatusValue:(NSString *)value forKey:(NSString *)key; - (NSDictionary *) statusValues; - (void) resetAllData; - (void) resetStatusData; diff --git a/Source/SPTableData.m b/Source/SPTableData.m index 69db2b93..c8dbe7b0 100644 --- a/Source/SPTableData.m +++ b/Source/SPTableData.m @@ -196,6 +196,15 @@ return [status objectForKey:aKey]; } +/* + * Set the table status value for the supplied key. This method is useful for when status values are obtained + * via other means and are subsequently more accurate than the value currently set. + */ +- (void)setStatusValue:(NSString *)value forKey:(NSString *)key +{ + [status setValue:value forKey:key]; +} + /* * Retrieve all known status values as a dictionary, using or refreshing the cache as appropriate. diff --git a/Source/TableContent.m b/Source/TableContent.m index 8bcf4942..2e7d32c2 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -1651,7 +1651,7 @@ } } -/* +/** * Show Error sheet (can be called from inside of a endSheet selector) * via [self performSelector:@selector(showErrorSheetWithTitle:) withObject: afterDelay:] */ @@ -1664,7 +1664,7 @@ } -/* +/** * Returns the number of rows in the selected table * Queries the number from MySQL if enabled in prefs and result is limited, otherwise just return the fullResult count. */ @@ -1676,6 +1676,9 @@ numRows = [fullResult count]; } + // Update table data cache with the more accurate row count + [tableDataInstance setStatusValue:[NSString stringWithFormat:@"%d", numRows] forKey:@"Rows"]; + return numRows; } @@ -1687,15 +1690,13 @@ return [[[[mySQLConnection queryString:[NSString stringWithFormat:@"SELECT COUNT(1) FROM %@", [selectedTable backtickQuotedString]]] fetchRowAsArray] objectAtIndex:0] intValue]; } -//tableView datasource methods +// TableView datasource methods - (int)numberOfRowsInTableView:(NSTableView *)aTableView { return [filteredResult count]; } -- (id)tableView:(CMCopyTable *)aTableView -objectValueForTableColumn:(NSTableColumn *)aTableColumn - row:(int)rowIndex +- (id)tableView:(CMCopyTable *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex { id theValue = NSArrayObjectAtIndex(NSArrayObjectAtIndex(filteredResult, rowIndex), [[aTableColumn identifier] intValue]); @@ -1706,14 +1707,13 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn return theValue; } +/** + * This function changes the text color of text/blob fields which are not yet loaded to gray + */ - (void)tableView: (CMCopyTable *)aTableView willDisplayCell: (id)cell forTableColumn: (NSTableColumn*)aTableColumn row: (int)row -/* - * This function changes the text color of - * text/blob fields which are not yet loaded to gray -*/ { // Check if loading of text/blob fields is disabled // If not, all text fields are loaded and we don't have to make them gray |