aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TableContent.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2009-05-19 19:57:34 +0000
committerstuconnolly <stuart02@gmail.com>2009-05-19 19:57:34 +0000
commitdad2c2af5af18890fa927d171f1ff58530a1a810 (patch)
tree3ec05044742bdad1a6e963fe19b2d5057e5fdafe /Source/TableContent.m
parent641eeff363a2864456a985b246576bfd5d41b144 (diff)
downloadsequelpro-dad2c2af5af18890fa927d171f1ff58530a1a810.tar.gz
sequelpro-dad2c2af5af18890fa927d171f1ff58530a1a810.tar.bz2
sequelpro-dad2c2af5af18890fa927d171f1ff58530a1a810.zip
New preference to allow the displaying of vertical grid lines in table views.
Diffstat (limited to 'Source/TableContent.m')
-rw-r--r--Source/TableContent.m58
1 files changed, 39 insertions, 19 deletions
diff --git a/Source/TableContent.m b/Source/TableContent.m
index ac5a4f45..cc06902d 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -40,23 +40,37 @@
@implementation TableContent
+/**
+ * Standard init method. Initialize various ivars.
+ */
- (id)init
{
- if (![super init])
- return nil;
-
- fullResult = [[NSMutableArray alloc] init];
- filteredResult = [[NSMutableArray alloc] init];
- oldRow = [[NSMutableDictionary alloc] init];
- selectedTable = nil;
- sortField = nil;
- areShowingAllRows = false;
- currentlyEditingRow = -1;
- usedQuery = [[NSString stringWithString:@""] retain];
+ if ((self == [super init])) {
+
+ fullResult = [[NSMutableArray alloc] init];
+ filteredResult = [[NSMutableArray alloc] init];
+ oldRow = [[NSMutableDictionary alloc] init];
+
+ selectedTable = nil;
+ sortField = nil;
+
+ areShowingAllRows = false;
+ currentlyEditingRow = -1;
+ prefs = [NSUserDefaults standardUserDefaults];
+
+ usedQuery = [[NSString stringWithString:@""] retain];
+ }
+
return self;
}
+- (void)awakeFromNib
+{
+ // Set the table content view's vertical gridlines if required
+ [tableContentView setGridStyleMask:([prefs boolForKey:@"DisplayTableViewVerticalGridlines"]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone];
+}
+
/*
* Loads aTable, retrieving column information and updating the tableViewColumns before
* reloading table data into the fullResults array and redrawing the table.
@@ -1084,7 +1098,6 @@
[tableContentView setVerticalMotionCanBeginDrag:NO];
- prefs = [[NSUserDefaults standardUserDefaults] retain];
if ( [prefs boolForKey:@"UseMonospacedFonts"] ) {
[argumentField setFont:[NSFont fontWithName:@"Monaco" size:10]];
[limitRowsField setFont:[NSFont fontWithName:@"Monaco" size:[NSFont smallSystemFontSize]]];
@@ -2191,12 +2204,12 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
}
}
+// TextView delegate methods
-//textView delegate methods
-- (BOOL)textView:(NSTextView *)aTextView doCommandBySelector:(SEL)aSelector
-/*
- traps enter and return key and closes editSheet instead of inserting a linebreak when user hits return
+/**
+ * Traps enter and return key and closes editSheet instead of inserting a linebreak when user hits return.
*/
+- (BOOL)textView:(NSTextView *)aTextView doCommandBySelector:(SEL)aSelector
{
if ( aTextView == editTextView ) {
if ( [aTextView methodForSelector:aSelector] == [aTextView methodForSelector:@selector(insertNewline:)] &&
@@ -2211,9 +2224,17 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
return NO;
}
+/**
+ * This method is called as part of Key Value Observing which is used to watch for prefernce changes which effect the interface.
+ */
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
+{
+ if ([keyPath isEqualToString:@"DisplayTableViewVerticalGridlines"]) {
+ [tableContentView setGridStyleMask:([[change objectForKey:NSKeyValueChangeNewKey] boolValue]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone];
+ }
+}
-//last but not least
-
+// Last but not least
- (void)dealloc
{
[editData release];
@@ -2223,7 +2244,6 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
[oldRow release];
[compareType release];
if (sortField) [sortField release];
- [prefs release];
[usedQuery release];
[super dealloc];