aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/SPHistoryController.h9
-rw-r--r--Source/SPHistoryController.m32
-rw-r--r--Source/TableContent.m2
-rw-r--r--Source/TableDocument.h2
-rw-r--r--Source/TableDocument.m36
5 files changed, 67 insertions, 14 deletions
diff --git a/Source/SPHistoryController.h b/Source/SPHistoryController.h
index 5829dce7..58f66352 100644
--- a/Source/SPHistoryController.h
+++ b/Source/SPHistoryController.h
@@ -35,20 +35,25 @@ enum sphistory_view_types
SP_VIEW_RELATIONS = 4
};
-@interface SPHistoryController : NSObject {
+@interface SPHistoryController : NSObject
+{
IBOutlet TableDocument *theDocument;
IBOutlet NSSegmentedControl *historyControl;
TableContent *tableContentInstance;
NSMutableArray *history;
- unsigned int historyPosition;
+ NSUInteger historyPosition;
BOOL modifyingHistoryState;
}
+@property (readonly) NSUInteger historyPosition;
+@property (readonly) NSMutableArray *history;
@property (readwrite, assign) BOOL modifyingHistoryState;
// Interface interaction
- (void) updateToolbarItem;
+- (void)goBackwardInHistory;
+- (void)goForwardInHistory;
- (IBAction) historyControlClicked:(NSSegmentedControl *)theControl;
- (unsigned int) currentlySelectedView;
diff --git a/Source/SPHistoryController.m b/Source/SPHistoryController.m
index d602d8d4..e3fbb9cf 100644
--- a/Source/SPHistoryController.m
+++ b/Source/SPHistoryController.m
@@ -30,6 +30,8 @@
@implementation SPHistoryController
+@synthesize history;
+@synthesize historyPosition;
@synthesize modifyingHistoryState;
#pragma mark Setup and teardown
@@ -102,23 +104,41 @@
}
/**
+ * Go backward in the history.
+ */
+- (void)goBackwardInHistory
+{
+ if (historyPosition == NSNotFound || !historyPosition) return;
+
+ [self loadEntryAtPosition:historyPosition - 1];
+}
+
+/**
+ * Go forward in the history.
+ */
+- (void)goForwardInHistory
+{
+ if (historyPosition == NSNotFound || historyPosition + 1 >= [history count]) return;
+
+ [self loadEntryAtPosition:historyPosition + 1];
+}
+
+/**
* Trigger a navigation action in response to a click
*/
- (IBAction) historyControlClicked:(NSSegmentedControl *)theControl
{
- switch ([theControl selectedSegment]) {
-
+ switch ([theControl selectedSegment])
+ {
// Back button clicked:
case 0:
- if (historyPosition == NSNotFound || !historyPosition) return;
- [self loadEntryAtPosition:historyPosition - 1];
+ [self goBackwardInHistory];
break;
// Forward button clicked:
case 1:
- if (historyPosition == NSNotFound || historyPosition + 1 >= [history count]) return;
- [self loadEntryAtPosition:historyPosition + 1];
+ [self goForwardInHistory];
break;
}
}
diff --git a/Source/TableContent.m b/Source/TableContent.m
index 2efd6d75..806e1f47 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -2164,7 +2164,7 @@
* Confirm whether to allow editing of a row. Returns YES by default, unless the multipleLineEditingButton is in
* the ON state, or for blob or text fields - in those cases opens a sheet for editing instead and returns NO.
*/
-- (BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(NSUInteger)rowIndex
+- (BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
{
NSUInteger i;
diff --git a/Source/TableDocument.h b/Source/TableDocument.h
index 868b5dcd..57cbeb4f 100644
--- a/Source/TableDocument.h
+++ b/Source/TableDocument.h
@@ -29,7 +29,6 @@
#import <MCPKit/MCPKit.h>
#import <WebKit/WebKit.h>
-
@class SPConnectionController, SPUserManager;
enum sp_current_query_mode
@@ -206,6 +205,7 @@ enum sp_current_query_mode
- (IBAction)validateSaveConnectionAccessory:(id)sender;
- (BOOL)saveDocumentWithFilePath:(NSString *)fileName inBackground:(BOOL)saveInBackground onlyPreferences:(BOOL)saveOnlyPreferences;
- (IBAction)closePasswordSheet:(id)sender;
+- (IBAction)backForwardInHistory:(id)sender;
// Getter methods
- (NSString *)name;
diff --git a/Source/TableDocument.m b/Source/TableDocument.m
index a546333a..dbb4e2f7 100644
--- a/Source/TableDocument.m
+++ b/Source/TableDocument.m
@@ -496,6 +496,24 @@
[NSApp abortModal];
}
+/**
+ * Go backward or forward in the history depending on the menu item selected.
+ */
+- (IBAction)backForwardInHistory:(id)sender
+{
+ switch ([sender tag])
+ {
+ // Go backward
+ case 0:
+ [spHistoryControllerInstance goBackwardInHistory];
+ break;
+ // Go forward
+ case 1:
+ [spHistoryControllerInstance goForwardInHistory];
+ break;
+ }
+}
+
#pragma mark -
#pragma mark Connection callback and methods
@@ -2467,13 +2485,13 @@
// and disable it if no query in the editor
if ([menuItem action] == @selector(saveConnectionSheet:) && [menuItem tag] == 0) {
if([customQueryInstance numberOfQueries] < 1) {
- [menuItem setTitle:NSLocalizedString(@"Save Query…",@"Save Query…")];
+ [menuItem setTitle:NSLocalizedString(@"Save Query…", @"Save Query…")];
return NO;
}
else if([customQueryInstance numberOfQueries] == 1)
- [menuItem setTitle:NSLocalizedString(@"Save Query…",@"Save Query…")];
+ [menuItem setTitle:NSLocalizedString(@"Save Query…", @"Save Query…")];
else
- [menuItem setTitle:NSLocalizedString(@"Save Queries…",@"Save Queries…")];
+ [menuItem setTitle:NSLocalizedString(@"Save Queries…", @"Save Queries…")];
return YES;
}
@@ -2502,7 +2520,17 @@
}
if ([menuItem action] == @selector(addConnectionToFavorites:)) {
- return ([connectionController selectedFavorite]?NO:YES);
+ return ([connectionController selectedFavorite] ? NO : YES);
+ }
+
+ // Backward in history menu item
+ if (([menuItem action] == @selector(backForwardInHistory:)) && ([menuItem tag] == 0)) {
+ return (([[spHistoryControllerInstance history] count]) && ([spHistoryControllerInstance historyPosition] > 0));
+ }
+
+ // Forward in history menu item
+ if (([menuItem action] == @selector(backForwardInHistory:)) && ([menuItem tag] == 1)) {
+ return (([[spHistoryControllerInstance history] count]) && (([spHistoryControllerInstance historyPosition] + 1) < [[spHistoryControllerInstance history] count]));
}
return [super validateMenuItem:menuItem];