aboutsummaryrefslogtreecommitdiffstats
path: root/CMCopyTable.m
diff options
context:
space:
mode:
authormltownsend <mltownsend@gmail.com>2008-11-10 19:56:30 +0000
committermltownsend <mltownsend@gmail.com>2008-11-10 19:56:30 +0000
commitc8146f9c28da66f02d47537e505a70725fb0c2b4 (patch)
treef967e1cadc654ea262f5fa7402572fdc2482d60d /CMCopyTable.m
parent87173093000bc5c36962451cc3e58c9aaac5ab50 (diff)
downloadsequelpro-c8146f9c28da66f02d47537e505a70725fb0c2b4.tar.gz
sequelpro-c8146f9c28da66f02d47537e505a70725fb0c2b4.tar.bz2
sequelpro-c8146f9c28da66f02d47537e505a70725fb0c2b4.zip
New XCode project
Diffstat (limited to 'CMCopyTable.m')
-rw-r--r--CMCopyTable.m254
1 files changed, 127 insertions, 127 deletions
diff --git a/CMCopyTable.m b/CMCopyTable.m
index 8b46b583..7eb80c52 100644
--- a/CMCopyTable.m
+++ b/CMCopyTable.m
@@ -27,19 +27,19 @@
- (void)copy:(id)sender
{
- NSString *tmp = [self selectedRowsAsTabString];
-
- if ( nil != tmp )
- {
- NSPasteboard *pb = [NSPasteboard generalPasteboard];
-
- [pb declareTypes:[NSArray arrayWithObjects: NSTabularTextPboardType,
- NSStringPboardType, nil]
- owner:nil];
-
- [pb setString:tmp forType:NSStringPboardType];
- [pb setString:tmp forType:NSTabularTextPboardType];
- }
+ NSString *tmp = [self selectedRowsAsTabString];
+
+ if ( nil != tmp )
+ {
+ NSPasteboard *pb = [NSPasteboard generalPasteboard];
+
+ [pb declareTypes:[NSArray arrayWithObjects: NSTabularTextPboardType,
+ NSStringPboardType, nil]
+ owner:nil];
+
+ [pb setString:tmp forType:NSStringPboardType];
+ [pb setString:tmp forType:NSTabularTextPboardType];
+ }
}
//allow for drag-n-drop out of the application as a copy
@@ -50,134 +50,134 @@
//only have the copy menu item enabled when row(s) are selected
- (BOOL)validateMenuItem:(NSMenuItem*)anItem
-{
- int row = [self selectedRow];
- if ([[anItem title] isEqualToString:@"Copy"] )
- {
- if (row < 0 )
- {
- return NO;
- }
- }
- return YES;
+{
+ int row = [self selectedRow];
+ if ([[anItem title] isEqualToString:@"Copy"] )
+ {
+ if (row < 0 )
+ {
+ return NO;
+ }
+ }
+ return YES;
}
//get selected rows a string of newline separated lines of tab separated fields
//the value in each field is from the objects description method
- (NSString *)selectedRowsAsTabString
{
- if ( [self numberOfSelectedRows] > 0 )
- {
- NSArray *columns = [self tableColumns];
- int numColumns = [columns count];
- id dataSource = [self dataSource];
-
- NSMutableString *result = [NSMutableString stringWithCapacity:numColumns];
+ if ( [self numberOfSelectedRows] > 0 )
+ {
+ NSArray *columns = [self tableColumns];
+ int numColumns = [columns count];
+ id dataSource = [self dataSource];
+
+ NSMutableString *result = [NSMutableString stringWithCapacity:numColumns];
- //this is really deprecated in 10.3, but the new method is really weird
- NSEnumerator *enumerator = [self selectedRowEnumerator];
-
- int c;
- id row = nil;
- id rowData = nil;
- NSTableColumn *col = nil;
-
- while (row = [enumerator nextObject])
- {
- rowData = nil;
- for ( c = 0; c < numColumns; c++)
- {
- col = [columns objectAtIndex:c];
- rowData = [dataSource tableView:self
- objectValueForTableColumn:col
- row:[row intValue] ];
-
- if ( nil != rowData )
- {
- [result appendString:[NSString stringWithFormat:@"%@\t", [rowData description] ] ];
- }
- else
- {
- [result appendString:@"\t"];
- }
- } //end for each column
-
- if ( [result length] )
- {
- [result deleteCharactersInRange:NSMakeRange([result length]-1, 1)];
- }
- [result appendString: [ NSString stringWithFormat:@"\n"]];
- } //end for each row
-
- if ( [result length] )
- {
- [result deleteCharactersInRange:NSMakeRange([result length]-1, 1)];
- }
- return result;
- }
- else
- {
- return nil;
- }
+ //this is really deprecated in 10.3, but the new method is really weird
+ NSEnumerator *enumerator = [self selectedRowEnumerator];
+
+ int c;
+ id row = nil;
+ id rowData = nil;
+ NSTableColumn *col = nil;
+
+ while (row = [enumerator nextObject])
+ {
+ rowData = nil;
+ for ( c = 0; c < numColumns; c++)
+ {
+ col = [columns objectAtIndex:c];
+ rowData = [dataSource tableView:self
+ objectValueForTableColumn:col
+ row:[row intValue] ];
+
+ if ( nil != rowData )
+ {
+ [result appendString:[NSString stringWithFormat:@"%@\t", [rowData description] ] ];
+ }
+ else
+ {
+ [result appendString:@"\t"];
+ }
+ } //end for each column
+
+ if ( [result length] )
+ {
+ [result deleteCharactersInRange:NSMakeRange([result length]-1, 1)];
+ }
+ [result appendString: [ NSString stringWithFormat:@"\n"]];
+ } //end for each row
+
+ if ( [result length] )
+ {
+ [result deleteCharactersInRange:NSMakeRange([result length]-1, 1)];
+ }
+ return result;
+ }
+ else
+ {
+ return nil;
+ }
}
//get dragged rows a string of newline separated lines of tab separated fields
//the value in each field is from the objects description method
- (NSString *)draggedRowsAsTabString:(NSArray *)rows
{
- if ( [rows count] > 0 )
- {
- NSArray *columns = [self tableColumns];
- int numColumns = [columns count];
- id dataSource = [self dataSource];
-
- NSMutableString *result = [NSMutableString stringWithCapacity:numColumns];
+ if ( [rows count] > 0 )
+ {
+ NSArray *columns = [self tableColumns];
+ int numColumns = [columns count];
+ id dataSource = [self dataSource];
+
+ NSMutableString *result = [NSMutableString stringWithCapacity:numColumns];
- //this is really deprecated in 10.3, but the new method is really weird
- NSEnumerator *enumerator = [rows objectEnumerator];
-
- int c;
- id row = nil;
- id rowData = nil;
- NSTableColumn *col = nil;
-
- while (row = [enumerator nextObject])
- {
- rowData = nil;
- for ( c = 0; c < numColumns; c++)
- {
- col = [columns objectAtIndex:c];
- rowData = [dataSource tableView:self
- objectValueForTableColumn:col
- row:[row intValue] ];
-
- if ( nil != rowData )
- {
- [result appendString:[NSString stringWithFormat:@"%@\t", [rowData description] ] ];
- }
- else
- {
- [result appendString:@"\t"];
- }
- } //end for each column
-
- if ( [result length] )
- {
- [result deleteCharactersInRange:NSMakeRange([result length]-1, 1)];
- }
- [result appendString: [ NSString stringWithFormat:@"\n"]];
- } //end for each row
-
- if ( [result length] )
- {
- [result deleteCharactersInRange:NSMakeRange([result length]-1, 1)];
- }
- return result;
- }
- else
- {
- return nil;
- }
+ //this is really deprecated in 10.3, but the new method is really weird
+ NSEnumerator *enumerator = [rows objectEnumerator];
+
+ int c;
+ id row = nil;
+ id rowData = nil;
+ NSTableColumn *col = nil;
+
+ while (row = [enumerator nextObject])
+ {
+ rowData = nil;
+ for ( c = 0; c < numColumns; c++)
+ {
+ col = [columns objectAtIndex:c];
+ rowData = [dataSource tableView:self
+ objectValueForTableColumn:col
+ row:[row intValue] ];
+
+ if ( nil != rowData )
+ {
+ [result appendString:[NSString stringWithFormat:@"%@\t", [rowData description] ] ];
+ }
+ else
+ {
+ [result appendString:@"\t"];
+ }
+ } //end for each column
+
+ if ( [result length] )
+ {
+ [result deleteCharactersInRange:NSMakeRange([result length]-1, 1)];
+ }
+ [result appendString: [ NSString stringWithFormat:@"\n"]];
+ } //end for each row
+
+ if ( [result length] )
+ {
+ [result deleteCharactersInRange:NSMakeRange([result length]-1, 1)];
+ }
+ return result;
+ }
+ else
+ {
+ return nil;
+ }
}
@end