aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-06-07 21:40:06 +0000
committerBibiko <bibiko@eva.mpg.de>2009-06-07 21:40:06 +0000
commitda1616e9c31fd922fef7ed567a28dfdd788bcb0c (patch)
treeb2f1fb8a59bbcb7422838feae04b9c5327446ee0
parent7ce154492f0e307644b66a3d2410a255345d86db (diff)
downloadsequelpro-da1616e9c31fd922fef7ed567a28dfdd788bcb0c.tar.gz
sequelpro-da1616e9c31fd922fef7ed567a28dfdd788bcb0c.tar.bz2
sequelpro-da1616e9c31fd922fef7ed567a28dfdd788bcb0c.zip
• improved "Copy as SQL INSERT" (still hidden)
• disabled "Copy with Column Names" if Custom Query editor is active
-rw-r--r--Source/CMCopyTable.h3
-rw-r--r--Source/CMCopyTable.m5
-rw-r--r--Source/CMTextView.m9
-rw-r--r--Source/TableContent.m3
4 files changed, 15 insertions, 5 deletions
diff --git a/Source/CMCopyTable.h b/Source/CMCopyTable.h
index f31e3575..0676267d 100644
--- a/Source/CMCopyTable.h
+++ b/Source/CMCopyTable.h
@@ -36,6 +36,7 @@
{
NSArray* columnDefinitions;
+ NSString* selectedTable;
}
@@ -91,7 +92,7 @@
- (NSString *)selectedRowsAsSqlInserts;
-- (void)setColumnDefinitions:(NSArray *)columnDefs;
+- (void)setTableInfoWithColumns:(NSArray *)columnDefs withTable:(NSString *)aTable;
@end
diff --git a/Source/CMCopyTable.m b/Source/CMCopyTable.m
index ed1e5439..7bb66da7 100644
--- a/Source/CMCopyTable.m
+++ b/Source/CMCopyTable.m
@@ -189,7 +189,7 @@ int MENU_EDIT_COPY_AS_SQL = 2002;
}
[result appendString:[NSString stringWithFormat:@"INSERT INTO `%@` (%@)\nVALUES\n",
- @"<table>", [tbHeader componentsJoinedAndBacktickQuoted]]];
+ (selectedTable == nil)?@"<table>":selectedTable, [tbHeader componentsJoinedAndBacktickQuoted]]];
int c;
id rowData = nil;
@@ -310,9 +310,10 @@ int MENU_EDIT_COPY_AS_SQL = 2002;
}
}
-- (void)setColumnDefinitions:(NSArray *)columnDefs
+- (void)setTableInfoWithColumns:(NSArray *)columnDefs withTable:(NSString *)aTable
{
columnDefinitions = [[NSArray arrayWithArray:columnDefs] retain];
+ selectedTable = aTable;
}
@end
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index d15a9f5b..ddb26f32 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -2382,7 +2382,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
long stringSize = [self getRangeForCurrentWord].length;
return (stringSize || stringSize > 64);
}
- // Enable Copy as RTF if soemthing is selected
+ // Enable Copy as RTF if something is selected
if ([menuItem action] == @selector(copyAsRTF)) {
return ([self selectedRange].length>0);
}
@@ -2390,6 +2390,13 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
if ([menuItem action] == @selector(selectCurrentQuery)) {
return ([self isEditable]);
}
+ // Disable "Copy with Column Names" and "Copy as SQL INSERT"
+ // in the main menu
+ if ( [menuItem tag] == MENU_EDIT_COPY_WITH_COLUMN
+ || [menuItem tag] == MENU_EDIT_COPY_AS_SQL ) {
+ return NO;
+ }
+
return YES;
}
diff --git a/Source/TableContent.m b/Source/TableContent.m
index a5e17db4..7c548307 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -154,7 +154,8 @@
theColumns = [tableDataInstance columns];
columnNames = [tableDataInstance columnNames];
- [tableContentView setColumnDefinitions:theColumns];
+ // Init copyTable with necessary information for copying selected rows as SQL INSERT
+ [tableContentView setTableInfoWithColumns:theColumns withTable:selectedTable];
// Retrieve the total number of rows of the current table
// to adjustify "Limit From:"