aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPCopyTable.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2011-04-22 17:44:57 +0000
committerstuconnolly <stuart02@gmail.com>2011-04-22 17:44:57 +0000
commit4611475c5b255eed9202474dd3bdee147e932946 (patch)
tree39bdc50e046f802265950c6e2607ca9ebda453be /Source/SPCopyTable.m
parent3ed8b33deeadcc98185911f41bc6bcb4e53b4719 (diff)
downloadsequelpro-4611475c5b255eed9202474dd3bdee147e932946.tar.gz
sequelpro-4611475c5b255eed9202474dd3bdee147e932946.tar.bz2
sequelpro-4611475c5b255eed9202474dd3bdee147e932946.zip
Bring outline view branch up to date with trunk (r3234:3277).
Diffstat (limited to 'Source/SPCopyTable.m')
-rw-r--r--Source/SPCopyTable.m61
1 files changed, 46 insertions, 15 deletions
diff --git a/Source/SPCopyTable.m b/Source/SPCopyTable.m
index b44ba920..e1b7e773 100644
--- a/Source/SPCopyTable.m
+++ b/Source/SPCopyTable.m
@@ -23,7 +23,9 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#import <MCPKit/MCPKit.h>
+#ifndef SP_REFACTOR /* headers */
#import "MCPGeometryData.h"
+#endif
#import "SPCopyTable.h"
#import "SPTableContent.h"
@@ -67,8 +69,8 @@ NSInteger kBlobAsImageFile = 4;
return ([[self delegate] isKindOfClass:[SPCustomQuery class]]
|| ([[self delegate] isKindOfClass:[SPTableContent class]]
- && [[self delegate] valueForKeyPath:@"tablesListInstance"]
- && [[[self delegate] valueForKeyPath:@"tablesListInstance"] tableType] == SPTableTypeView));
+ && [(NSObject*)[self delegate] valueForKeyPath:@"tablesListInstance"]
+ && [(SPTablesList*)([(NSObject*)[self delegate] valueForKeyPath:@"tablesListInstance"]) tableType] == SPTableTypeView));
}
@@ -90,6 +92,7 @@ NSInteger kBlobAsImageFile = 4;
*/
- (void) copy:(id)sender
{
+#ifndef SP_REFACTOR /* copy table rows */
NSString *tmp = nil;
if([sender tag] == MENU_EDIT_COPY_AS_SQL) {
@@ -119,12 +122,14 @@ NSInteger kBlobAsImageFile = 4;
[pb setString:tmp forType:NSTabularTextPboardType];
}
}
+#endif
}
/**
* Get selected rows a string of newline separated lines of tab separated fields
* the value in each field is from the objects description method
*/
+#ifndef SP_REFACTOR /* get rows as string */
- (NSString *) rowsAsTabStringWithHeaders:(BOOL)withHeaders onlySelectedRows:(BOOL)onlySelected blobHandling:(NSInteger)withBlobHandling
{
if (onlySelected && [self numberOfSelectedRows] == 0) return nil;
@@ -397,6 +402,7 @@ NSInteger kBlobAsImageFile = 4;
return result;
}
+#endif
/*
* Return selected rows as SQL INSERT INTO `foo` VALUES (baz) string.
@@ -478,7 +484,7 @@ NSInteger kBlobAsImageFile = 4;
if ([cellData isSPNotLoaded] && [[self delegate] isKindOfClass:spTableContentClass]) {
// Abort if no table name given, not table content, or if there are no indices on this table
- if (!selectedTable || ![[self delegate] isKindOfClass:spTableContentClass] || ![[tableInstance argumentForRow:rowIndex] length]) {
+ if (!selectedTable || ![[self delegate] isKindOfClass:spTableContentClass] || ![(NSString*)[tableInstance argumentForRow:rowIndex] length]) {
NSBeep();
free(columnMappings);
free(columnTypes);
@@ -753,7 +759,11 @@ NSInteger kBlobAsImageFile = 4;
NSUInteger cellWidth, maxCellWidth, i;
NSRange linebreakRange;
double rowStep;
+#ifndef SP_REFACTOR /* patch */
NSFont *tableFont = [NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPGlobalResultTableFont]];
+#else
+ NSFont *tableFont = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
+#endif
NSUInteger columnIndex = [[columnDefinition objectForKey:@"datacolumnindex"] unsignedIntegerValue];
NSDictionary *stringAttributes = [NSDictionary dictionaryWithObject:tableFont forKey:NSFontAttributeName];
Class mcpGeometryData = [MCPGeometryData class];
@@ -836,6 +846,7 @@ NSInteger kBlobAsImageFile = 4;
{
NSMenu *menu = [self menu];
+#ifndef SP_REFACTOR /* menuForEvent: */
if(![[self delegate] isKindOfClass:[SPCustomQuery class]] && ![[self delegate] isKindOfClass:[SPTableContent class]]) return menu;
@@ -903,7 +914,7 @@ NSInteger kBlobAsImageFile = 4;
[bundleSubMenuItem release];
}
-
+#endif
return menu;
}
@@ -914,7 +925,11 @@ NSInteger kBlobAsImageFile = 4;
if(!rowIndices || ![rowIndices count]) return;
NSMutableIndexSet *selection = [NSMutableIndexSet indexSet];
+#ifndef SP_REFACTOR
NSInteger rows = [[self delegate] numberOfRowsInTableView:self];
+#else
+ NSInteger rows = [(id<NSTableViewDataSource>)[self delegate] numberOfRowsInTableView:self];
+#endif
NSInteger i;
if(rows > 0) {
for(NSString* idx in rowIndices) {
@@ -934,6 +949,7 @@ NSInteger kBlobAsImageFile = 4;
*/
- (BOOL) validateMenuItem:(NSMenuItem*)anItem
{
+#ifndef SP_REFACTOR /* validateMenuItem: */
NSInteger menuItemTag = [anItem tag];
if ([anItem action] == @selector(performFindPanelAction:)) {
@@ -959,7 +975,7 @@ NSInteger kBlobAsImageFile = 4;
if (menuItemTag == MENU_EDIT_COPY_AS_SQL) {
return (columnDefinitions != nil && [self numberOfSelectedRows] > 0);
}
-
+#endif
return NO;
}
@@ -984,7 +1000,7 @@ NSInteger kBlobAsImageFile = 4;
// Save the current line if it's the last field in the table
if ( [self numberOfColumns] - 1 == column ) {
if([[self delegate] respondsToSelector:@selector(saveRowToTable)])
- [[self delegate] saveRowToTable];
+ [(SPTableContent*)[self delegate] saveRowToTable];
[[self window] makeFirstResponder:self];
} else {
// Select the next field for editing
@@ -1002,7 +1018,7 @@ NSInteger kBlobAsImageFile = 4;
// Save the current line if it's the last field in the table
if ( column < 1 ) {
if([[self delegate] respondsToSelector:@selector(saveRowToTable)])
- [[self delegate] saveRowToTable];
+ [(SPTableContent*)([self delegate]) saveRowToTable];
[[self window] makeFirstResponder:self];
} else {
// Select the previous field for editing
@@ -1021,7 +1037,7 @@ NSInteger kBlobAsImageFile = 4;
[[control window] makeFirstResponder:control];
if([[self delegate] isKindOfClass:[SPTableContent class]] && ![self isCellEditingMode] && [[self delegate] respondsToSelector:@selector(saveRowToTable)])
- [[self delegate] saveRowToTable];
+ [(SPTableContent*)[self delegate] saveRowToTable];
return YES;
}
@@ -1035,14 +1051,22 @@ NSInteger kBlobAsImageFile = 4;
return NO;
NSInteger newRow = row+1;
+#ifndef SP_REFACTOR
if (newRow>=[[self delegate] numberOfRowsInTableView:self]) return YES; //check if we're already at the end of the list
+#else
+ if (newRow>=[(id<NSTableViewDataSource>)[self delegate] numberOfRowsInTableView:self]) return YES; //check if we're already at the end of the list
+#endif
[[control window] makeFirstResponder:control];
if([[self delegate] isKindOfClass:[SPTableContent class]] && ![self isCellEditingMode] && [[self delegate] respondsToSelector:@selector(saveRowToTable)])
- [[self delegate] saveRowToTable];
+ [(SPTableContent*)([self delegate]) saveRowToTable];
+#ifndef SP_REFACTOR
if (newRow>=[[self delegate] numberOfRowsInTableView:self]) return YES; //check again. saveRowToTable could reload the table and change the number of rows
- if (tableStorage && column >= (NSInteger)[tableStorage columnCount]) return YES; //the column count could change too
+#else
+ if (newRow>=[(id<NSTableViewDataSource>)[self delegate] numberOfRowsInTableView:self]) return YES; //check again. saveRowToTable could reload the table and change the number of rows
+#endif
+ if (tableStorage && (NSUInteger)column>=[tableStorage columnCount]) return YES; //the column count could change too
[self selectRowIndexes:[NSIndexSet indexSetWithIndex:newRow] byExtendingSelection:NO];
[self editColumn:column row:newRow withEvent:nil select:YES];
@@ -1062,10 +1086,14 @@ NSInteger kBlobAsImageFile = 4;
[[control window] makeFirstResponder:control];
if([[self delegate] isKindOfClass:[SPTableContent class]] && ![self isCellEditingMode] && [[self delegate] respondsToSelector:@selector(saveRowToTable)])
- [[self delegate] saveRowToTable];
+ [(SPTableContent*)([self delegate]) saveRowToTable];
+#ifndef SP_REFACTOR
if (newRow>=[[self delegate] numberOfRowsInTableView:self]) return YES; // saveRowToTable could reload the table and change the number of rows
- if (tableStorage && column >= (NSInteger)[tableStorage columnCount]) return YES; //the column count could change too
+#else
+ if (newRow>=[(id<NSTableViewDataSource>)[self delegate] numberOfRowsInTableView:self]) return YES; // saveRowToTable could reload the table and change the number of rows
+#endif
+ if (tableStorage && (NSUInteger)column>=[tableStorage columnCount]) return YES; //the column count could change too
[self selectRowIndexes:[NSIndexSet indexSetWithIndex:newRow] byExtendingSelection:NO];
[self editColumn:column row:newRow withEvent:nil select:YES];
@@ -1089,7 +1117,7 @@ NSInteger kBlobAsImageFile = 4;
// Check if ESCAPE is hit and use it to cancel row editing if supported
if ([theEvent keyCode] == 53 && [[self delegate] respondsToSelector:@selector(cancelRowEditing)])
{
- if ([[self delegate] cancelRowEditing]) return;
+ if ([[self delegate] performSelector:@selector(cancelRowEditing)]) return;
}
else if ([theEvent keyCode] == 48 && ([[self delegate] isKindOfClass:[SPCustomQuery class]]
@@ -1104,7 +1132,7 @@ NSInteger kBlobAsImageFile = 4;
- (void)performFindPanelAction:(id)sender
{
if([sender tag] == 1 && [[self delegate] isKindOfClass:[SPTableContent class]]) {
- [[self delegate] showFilterTable:self];
+ [(SPTableContent*)[self delegate] showFilterTable:self];
}
}
@@ -1113,6 +1141,7 @@ NSInteger kBlobAsImageFile = 4;
- (IBAction)executeBundleItemForDataTable:(id)sender
{
+#ifndef SP_REFACTOR /* executeBundleItemForDataTable: */
NSInteger idx = [sender tag] - 1000000;
NSString *infoPath = nil;
NSArray *bundleItems = [[NSApp delegate] bundleItemsForScope:SPBundleScopeDataTable];
@@ -1389,7 +1418,7 @@ NSInteger kBlobAsImageFile = 4;
if (cmdData) [cmdData release];
}
-
+#endif
}
#pragma mark -
@@ -1407,7 +1436,9 @@ NSInteger kBlobAsImageFile = 4;
- (void) dealloc
{
if (columnDefinitions) [columnDefinitions release];
+#ifndef SP_REFACTOR
[prefs release];
+#endif
[super dealloc];
}