aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTableContent.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2012-05-08 21:55:59 +0000
committerrowanbeentje <rowan@beent.je>2012-05-08 21:55:59 +0000
commitd8935e682e9f9430feba225e0490fed9885bc81e (patch)
tree06654611b83f1dafbe2345897baad90ac6825379 /Source/SPTableContent.m
parent62e4216b9e7ecbda9791f86feafbd1c7fbd031ce (diff)
downloadsequelpro-d8935e682e9f9430feba225e0490fed9885bc81e.tar.gz
sequelpro-d8935e682e9f9430feba225e0490fed9885bc81e.tar.bz2
sequelpro-d8935e682e9f9430feba225e0490fed9885bc81e.zip
- Alter table filtering to reset pagination when filters are entered; pagination should still be correctly preserved in all other cases
Diffstat (limited to 'Source/SPTableContent.m')
-rw-r--r--Source/SPTableContent.m13
1 files changed, 9 insertions, 4 deletions
diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m
index 29064a5e..9036c393 100644
--- a/Source/SPTableContent.m
+++ b/Source/SPTableContent.m
@@ -1485,11 +1485,16 @@
[self setPaginationViewVisibility:FALSE];
#endif
- // Select the correct pagination value
- if (![prefs boolForKey:SPLimitResults] || [paginationPageField integerValue] <= 0)
+ // Select the correct pagination value.
+ // If the filter button was used, or if pagination is disabled, reset to page one
+ if ([sender isKindOfClass:[NSButton class]] || [sender isKindOfClass:[NSTextField class]] || ![prefs boolForKey:SPLimitResults] || [paginationPageField integerValue] <= 0)
contentPage = 1;
+
+ // If the current page is out of bounds, move it within bounds
else if (([paginationPageField integerValue] - 1) * [prefs integerForKey:SPLimitResultsValue] >= maxNumRows)
contentPage = ceilf((CGFloat)maxNumRows / [prefs floatForKey:SPLimitResultsValue]);
+
+ // Otherwise, use the pagination value
else
contentPage = [paginationPageField integerValue];
@@ -1684,11 +1689,11 @@
if (sender == paginationPreviousButton) {
if (contentPage <= 1) return;
[paginationPageField setIntegerValue:(contentPage - 1)];
- [self filterTable:sender];
+ [self filterTable:self];
} else if (sender == paginationNextButton) {
if ((NSInteger)contentPage * [prefs integerForKey:SPLimitResultsValue] >= maxNumRows) return;
[paginationPageField setIntegerValue:(contentPage + 1)];
- [self filterTable:sender];
+ [self filterTable:self];
}
}