aboutsummaryrefslogtreecommitdiffstats
path: root/Source/CMCopyTable.m
diff options
context:
space:
mode:
authorbamse16 <marius@marius.me.uk>2009-05-14 13:26:16 +0000
committerbamse16 <marius@marius.me.uk>2009-05-14 13:26:16 +0000
commitb60ee8e3720b0dac888f5d542869712a6c16e409 (patch)
treefae05445d95ed9174fde15390a47d15b5cf5d18b /Source/CMCopyTable.m
parentd5ab2d92548974758959134bf169c7af33466ac9 (diff)
downloadsequelpro-b60ee8e3720b0dac888f5d542869712a6c16e409.tar.gz
sequelpro-b60ee8e3720b0dac888f5d542869712a6c16e409.tar.bz2
sequelpro-b60ee8e3720b0dac888f5d542869712a6c16e409.zip
Issue 233: Option to copy field headings from result panels
Implementation of copy with column names menu item Removal of copy column names
Diffstat (limited to 'Source/CMCopyTable.m')
-rw-r--r--Source/CMCopyTable.m22
1 files changed, 18 insertions, 4 deletions
diff --git a/Source/CMCopyTable.m b/Source/CMCopyTable.m
index 7eb80c52..e0f29aaa 100644
--- a/Source/CMCopyTable.m
+++ b/Source/CMCopyTable.m
@@ -27,8 +27,14 @@
- (void)copy:(id)sender
{
- NSString *tmp = [self selectedRowsAsTabString];
+ NSString *tmp = nil;
+
+ BOOL withHeaders = NO;
+ if([[sender title] isEqualToString:@"Copy with Column Names"]) {
+ withHeaders = YES;
+ }
+ tmp = [self selectedRowsAsTabStringWithHeaders:withHeaders];
if ( nil != tmp )
{
NSPasteboard *pb = [NSPasteboard generalPasteboard];
@@ -52,7 +58,7 @@
- (BOOL)validateMenuItem:(NSMenuItem*)anItem
{
int row = [self selectedRow];
- if ([[anItem title] isEqualToString:@"Copy"] )
+ if ( [[anItem title] isEqualToString:@"Copy"] || [[anItem title] isEqualToString:@"Copy with Column Names"] )
{
if (row < 0 )
{
@@ -64,7 +70,7 @@
//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
+- (NSString *)selectedRowsAsTabStringWithHeaders:(BOOL)withHeaders
{
if ( [self numberOfSelectedRows] > 0 )
{
@@ -73,7 +79,15 @@
id dataSource = [self dataSource];
NSMutableString *result = [NSMutableString stringWithCapacity:numColumns];
-
+
+ if(withHeaders) {
+ int i;
+ for( i = 0; i < numColumns; i++ ){
+ [result appendString:[NSString stringWithFormat:@"%@\t", [[[columns objectAtIndex:i] headerCell] stringValue]]];
+ }
+ [result appendString:[NSString stringWithFormat:@"\n"]];
+ }
+
//this is really deprecated in 10.3, but the new method is really weird
NSEnumerator *enumerator = [self selectedRowEnumerator];