aboutsummaryrefslogtreecommitdiffstats
path: root/Source/CustomQuery.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-01-04 12:59:51 +0000
committerBibiko <bibiko@eva.mpg.de>2010-01-04 12:59:51 +0000
commit313c5bc247548319dc1f93c9ece04ea4326d37e8 (patch)
tree3d2a0b62c92a60668dfd0020a88822ebed4a3dc2 /Source/CustomQuery.m
parent25d72032f5f6296c69a5e44fb41ee9bc7942e8ca (diff)
downloadsequelpro-313c5bc247548319dc1f93c9ece04ea4326d37e8.tar.gz
sequelpro-313c5bc247548319dc1f93c9ece04ea4326d37e8.tar.bz2
sequelpro-313c5bc247548319dc1f93c9ece04ea4326d37e8.zip
• remember scrollview port and selected row after editing in the Custom Query table view
- after reloading the entire data the table view port will be restored but this leads up to now to a "tiny jitter" (maybe fixable in the near future) - the re-selection does NOT follow the actual edited row, e.g. if one changes a cell value whose column is used for sorting the actual edited row could appear somewhere • if the editing in the Custom Query table view was invoked by pressing RETURN/ENTER one can go through the columns by pressing ESC but up to now that editing will be interrupted after the user pressed OK - this behaviour is temporary and should be fixed in the near future by storing the new row data temporarily; after editing the last column AND if all columns have the same table origin the row data will be updated. To allow the row editing for columns which have different table origins could probably cause inconsistencies. - further discussion is needed
Diffstat (limited to 'Source/CustomQuery.m')
-rw-r--r--Source/CustomQuery.m32
1 files changed, 23 insertions, 9 deletions
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m
index 71ed2ec4..ebcf1259 100644
--- a/Source/CustomQuery.m
+++ b/Source/CustomQuery.m
@@ -408,8 +408,10 @@
// Reset the current table view as necessary to avoid redraw and reload issues.
// Restore the view position to the top left to be within the results for all datasets.
- [customQueryView scrollRowToVisible:0];
- [customQueryView scrollColumnToVisible:0];
+ if(editedRow == -1) {
+ [customQueryView scrollRowToVisible:0];
+ [customQueryView scrollColumnToVisible:0];
+ }
// Remove all the columns
if(!tableReloadAfterEditing) {
@@ -576,7 +578,6 @@
if(!databaseWasChanged && [query isMatchedByRegex:@"(?i)\\b(use|drop\\s+database|drop\\s+schema)\\b\\s+."])
databaseWasChanged = YES;
}
-
// If the query was cancelled, end all queries.
if ([mySQLConnection queryCancelled]) break;
}
@@ -761,14 +762,20 @@
}
}
+ [customQueryView reloadData];
+
if(tableReloadAfterEditing) {
- // scroll to last edited row after refreshing data
- // TODO: should be improved
- [customQueryView scrollRowToVisible:[customQueryView selectedRow]];
+ // scroll to last edited row/view port after refreshing data
+ if(editedRow > -1) {
+ [customQueryView selectRowIndexes:[NSIndexSet indexSetWithIndex:editedRow] byExtendingSelection:NO];
+ [[customQueryScrollView contentView] scrollToPoint:NSMakePoint(editedScrollViewRect.origin.x, editedScrollViewRect.origin.y)];
+ [customQueryScrollView reflectScrolledClipView:[customQueryScrollView contentView]];
+ editedRow = -1;
+ } else {
+ [customQueryView scrollRowToVisible:[customQueryView selectedRow]];
+ }
}
- [customQueryView reloadData];
-
// Init copyTable with necessary information for copying selected rows as SQL INSERT
[customQueryView setTableInstance:self withTableData:fullResult withColumns:cqColumnDefinition withTableName:resultTableName withConnection:mySQLConnection];
@@ -1506,6 +1513,7 @@
// On success reload table data by executing the last query
tableReloadAfterEditing = YES;
+
[self performQueries:[NSArray arrayWithObject:lastExecutedQuery] withCallback:NULL];
} else {
@@ -1753,7 +1761,7 @@
/*
* Double-click action on a field
*/
-- (BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
+- (BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
{
// Only allow editing if a task is not active
@@ -1819,6 +1827,11 @@
SPFieldEditorController *fieldEditor = [[SPFieldEditorController alloc] init];
+
+ // Remember edited row for reselecting and setting the scroll view after reload
+ editedRow = rowIndex;
+ editedScrollViewRect = [customQueryScrollView documentVisibleRect];
+
// Set max text length
if ([[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"string"]
&& [columnDefinition valueForKey:@"char_length"])
@@ -2844,6 +2857,7 @@
// init tableView's data source
fullResultCount = 0;
fullResult = [[NSMutableArray alloc] init];
+ editedRow = -1;
prefs = [NSUserDefaults standardUserDefaults];
}