aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2013-04-03 17:42:09 +0000
committerstuconnolly <stuart02@gmail.com>2013-04-03 17:42:09 +0000
commit91d6518ac27d6b9daad29d4bcb2bf54c07925a16 (patch)
tree7ebfcbf0de20d2198ae9471fac516a4c5fedc78c
parentfda22b513f3134761991425b9fdef2ee144d01fb (diff)
downloadsequelpro-91d6518ac27d6b9daad29d4bcb2bf54c07925a16.tar.gz
sequelpro-91d6518ac27d6b9daad29d4bcb2bf54c07925a16.tar.bz2
sequelpro-91d6518ac27d6b9daad29d4bcb2bf54c07925a16.zip
Split the process list controller's table view data source and delegate methods into their own category.
-rw-r--r--Source/SPProcessListController.m64
-rw-r--r--Source/SPProcessListControllerDataSource.h35
-rw-r--r--Source/SPProcessListControllerDataSource.m98
-rw-r--r--sequel-pro.xcodeproj/project.pbxproj18
4 files changed, 149 insertions, 66 deletions
diff --git a/Source/SPProcessListController.m b/Source/SPProcessListController.m
index 7540ed43..c695c2e2 100644
--- a/Source/SPProcessListController.m
+++ b/Source/SPProcessListController.m
@@ -478,70 +478,6 @@ static NSString *SPTableViewIDColumnIdentifier = @"Id";
}
#pragma mark -
-#pragma mark Tableview delegate methods
-
-/**
- * Table view delegate method. Returns the number of rows in the table veiw.
- */
-- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
-{
- return [processesFiltered count];
-}
-
-/**
- * Table view delegate method. Returns the specific object for the request column and row.
- */
-- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
-{
- id object = ((NSUInteger)row < [processesFiltered count]) ? [[processesFiltered objectAtIndex:row] valueForKey:[tableColumn identifier]] : @"";
-
- if ([object isNSNull]) {
- return [prefs stringForKey:SPNullValue];
- }
-
- // If the string is exactly 100 characters long, and FULL process lists are not enabled, it's a safe
- // bet that the string is truncated
- if (!showFullProcessList && [object isKindOfClass:[NSString class]] && [(NSString *)object length] == 100) {
- return [object stringByAppendingString:@"…"];
- }
-
- return object;
-}
-
-/**
- * Table view delegate method. Called when the user changes the sort by column.
- */
-- (void)tableView:(NSTableView *)tableView sortDescriptorsDidChange:(NSArray *)oldDescriptors
-{
- [processesFiltered sortUsingDescriptors:[tableView sortDescriptors]];
-
- [tableView reloadData];
-}
-
-/**
- * Table view delegate method. Called whenever the user changes a column width.
- */
-- (void)tableViewColumnDidResize:(NSNotification *)notification
-{
- NSTableColumn *column = [[notification userInfo] objectForKey:@"NSTableColumn"];
-
- // Get the existing table column widths dictionary if it exists
- NSMutableDictionary *tableColumnWidths = ([prefs objectForKey:SPProcessListTableColumnWidths]) ?
- [NSMutableDictionary dictionaryWithDictionary:[prefs objectForKey:SPProcessListTableColumnWidths]] :
- [NSMutableDictionary dictionary];
-
- // Save column size
- NSString *columnName = [[column headerCell] stringValue];
-
- if (columnName) {
- [tableColumnWidths setObject:[NSNumber numberWithDouble:[column width]] forKey:columnName];
-
- [prefs setObject:tableColumnWidths forKey:SPProcessListTableColumnWidths];
- }
-}
-
-
-#pragma mark -
#pragma mark Text field delegate methods
/**
diff --git a/Source/SPProcessListControllerDataSource.h b/Source/SPProcessListControllerDataSource.h
new file mode 100644
index 00000000..3d0cc571
--- /dev/null
+++ b/Source/SPProcessListControllerDataSource.h
@@ -0,0 +1,35 @@
+//
+// $Id$
+//
+// SPProcessListControllerDataSource.h
+// sequel-pro
+//
+// Created by Stuart Connolly (stuconnolly.com) on April 3, 2013.
+// Copyright (c) 2013 Stuart Connolly. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+
+#import "SPProcessListController.h"
+
+@interface SPProcessListController (SPProcessListControllerDataSource)
+
+@end
diff --git a/Source/SPProcessListControllerDataSource.m b/Source/SPProcessListControllerDataSource.m
new file mode 100644
index 00000000..90e0c113
--- /dev/null
+++ b/Source/SPProcessListControllerDataSource.m
@@ -0,0 +1,98 @@
+//
+// $Id$
+//
+// SPProcessListControllerDataSource.m
+// sequel-pro
+//
+// Created by Stuart Connolly (stuconnolly.com) on April 3, 2013.
+// Copyright (c) 2013 Stuart Connolly. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+
+#import "SPProcessListControllerDataSource.h"
+
+@implementation SPProcessListController (SPProcessListControllerDataSource)
+
+#pragma mark -
+#pragma mark Tableview delegate methods
+
+/**
+ * Table view delegate method. Returns the number of rows in the table veiw.
+ */
+- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
+{
+ return [processesFiltered count];
+}
+
+/**
+ * Table view delegate method. Returns the specific object for the request column and row.
+ */
+- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
+{
+ id object = ((NSUInteger)row < [processesFiltered count]) ? [[processesFiltered objectAtIndex:row] valueForKey:[tableColumn identifier]] : @"";
+
+ if ([object isNSNull]) {
+ return [prefs stringForKey:SPNullValue];
+ }
+
+ // If the string is exactly 100 characters long, and FULL process lists are not enabled, it's a safe
+ // bet that the string is truncated
+ if (!showFullProcessList && [object isKindOfClass:[NSString class]] && [(NSString *)object length] == 100) {
+ return [object stringByAppendingString:@"…"];
+ }
+
+ return object;
+}
+
+/**
+ * Table view delegate method. Called when the user changes the sort by column.
+ */
+- (void)tableView:(NSTableView *)tableView sortDescriptorsDidChange:(NSArray *)oldDescriptors
+{
+ [processesFiltered sortUsingDescriptors:[tableView sortDescriptors]];
+
+ [tableView reloadData];
+}
+
+/**
+ * Table view delegate method. Called whenever the user changes a column width.
+ */
+- (void)tableViewColumnDidResize:(NSNotification *)notification
+{
+ NSTableColumn *column = [[notification userInfo] objectForKey:@"NSTableColumn"];
+
+ // Get the existing table column widths dictionary if it exists
+ NSMutableDictionary *tableColumnWidths = ([prefs objectForKey:SPProcessListTableColumnWidths]) ?
+ [NSMutableDictionary dictionaryWithDictionary:[prefs objectForKey:SPProcessListTableColumnWidths]] :
+ [NSMutableDictionary dictionary];
+
+ // Save column size
+ NSString *columnName = [[column headerCell] stringValue];
+
+ if (columnName) {
+ [tableColumnWidths setObject:[NSNumber numberWithDouble:[column width]] forKey:columnName];
+
+ [prefs setObject:tableColumnWidths forKey:SPProcessListTableColumnWidths];
+ }
+}
+
+@end
diff --git a/sequel-pro.xcodeproj/project.pbxproj b/sequel-pro.xcodeproj/project.pbxproj
index 8d6aa629..3956b8cc 100644
--- a/sequel-pro.xcodeproj/project.pbxproj
+++ b/sequel-pro.xcodeproj/project.pbxproj
@@ -70,6 +70,7 @@
177E792E0FCB54EC00E9E122 /* database-small.png in Resources */ = {isa = PBXBuildFile; fileRef = 177E792B0FCB54EC00E9E122 /* database-small.png */; };
177E792F0FCB54EC00E9E122 /* dummy-small.png in Resources */ = {isa = PBXBuildFile; fileRef = 177E792C0FCB54EC00E9E122 /* dummy-small.png */; };
177E7A230FCB6A2E00E9E122 /* SPExtendedTableInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 177E7A220FCB6A2E00E9E122 /* SPExtendedTableInfo.m */; };
+ 17846BA4170C962E00414499 /* SPProcessListControllerDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 17846BA3170C962E00414499 /* SPProcessListControllerDataSource.m */; };
1785E9F7127D8C7500F468C8 /* SPPreferencePane.m in Sources */ = {isa = PBXBuildFile; fileRef = 1785E9F6127D8C7500F468C8 /* SPPreferencePane.m */; };
1785EA16127DAE3A00F468C8 /* SPPreferenceControllerDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1785EA15127DAE3A00F468C8 /* SPPreferenceControllerDelegate.m */; };
1785EA23127DAF3300F468C8 /* SPTablesPreferencePane.m in Sources */ = {isa = PBXBuildFile; fileRef = 1785EA22127DAF3300F468C8 /* SPTablesPreferencePane.m */; };
@@ -683,6 +684,8 @@
177E792C0FCB54EC00E9E122 /* dummy-small.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "dummy-small.png"; sourceTree = "<group>"; };
177E7A210FCB6A2E00E9E122 /* SPExtendedTableInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPExtendedTableInfo.h; sourceTree = "<group>"; };
177E7A220FCB6A2E00E9E122 /* SPExtendedTableInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPExtendedTableInfo.m; sourceTree = "<group>"; };
+ 17846BA2170C962E00414499 /* SPProcessListControllerDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPProcessListControllerDataSource.h; sourceTree = "<group>"; };
+ 17846BA3170C962E00414499 /* SPProcessListControllerDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPProcessListControllerDataSource.m; sourceTree = "<group>"; };
1785E9F5127D8C7500F468C8 /* SPPreferencePane.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPPreferencePane.h; sourceTree = "<group>"; };
1785E9F6127D8C7500F468C8 /* SPPreferencePane.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPPreferencePane.m; sourceTree = "<group>"; };
1785EA14127DAE3A00F468C8 /* SPPreferenceControllerDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPPreferenceControllerDelegate.h; sourceTree = "<group>"; };
@@ -1568,8 +1571,6 @@
BC675A131072039C00C5ACD4 /* SPContentFilterManager.m */,
BC9F087F100FCF2C00A80D32 /* SPFieldEditorController.h */,
BC9F0880100FCF2C00A80D32 /* SPFieldEditorController.m */,
- 174CE14010AB9281008F892B /* SPProcessListController.h */,
- 174CE14110AB9281008F892B /* SPProcessListController.m */,
173C4364104455E0001F3A30 /* SPQueryFavoriteManager.h */,
173C4365104455E0001F3A30 /* SPQueryFavoriteManager.m */,
1792C13510AD75C800ABE758 /* SPServerVariablesController.h */,
@@ -1582,6 +1583,7 @@
BC27779F11514B940034DF6A /* SPNavigatorController.m */,
17A7773211C52D8E001E27B4 /* SPIndexesController.h */,
17A7773311C52D8E001E27B4 /* SPIndexesController.m */,
+ 17846B9D170C95D800414499 /* Process List */,
17381853151FB29C0078FFE2 /* User Manager */,
1713C73D140D88D400CFD461 /* Query Controller */,
);
@@ -1677,6 +1679,17 @@
name = RegexKitLite;
sourceTree = "<group>";
};
+ 17846B9D170C95D800414499 /* Process List */ = {
+ isa = PBXGroup;
+ children = (
+ 174CE14010AB9281008F892B /* SPProcessListController.h */,
+ 174CE14110AB9281008F892B /* SPProcessListController.m */,
+ 17846BA2170C962E00414499 /* SPProcessListControllerDataSource.h */,
+ 17846BA3170C962E00414499 /* SPProcessListControllerDataSource.m */,
+ );
+ name = "Process List";
+ sourceTree = "<group>";
+ };
1792C28910AE1C7200ABE758 /* Controller Categories */ = {
isa = PBXGroup;
children = (
@@ -3249,6 +3262,7 @@
17005CB316D6CF0000AF81F4 /* SPTableTriggersDelegate.m in Sources */,
58D29FE016E96306002EB401 /* SPUserManagerDataSource.m in Sources */,
58D2A6A716FBDEFF002EB401 /* SPComboPopupButton.m in Sources */,
+ 17846BA4170C962E00414499 /* SPProcessListControllerDataSource.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};