aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/CMCopyTable.h2
-rw-r--r--Source/CMCopyTable.m92
-rw-r--r--Source/CustomQuery.m4
-rw-r--r--Source/SPContentFilterManager.m18
-rw-r--r--Source/SPPreferenceController.m20
-rw-r--r--Source/SPQueryFavoriteManager.m44
-rw-r--r--Source/TableContent.m10
-rw-r--r--Source/TableSource.m22
8 files changed, 104 insertions, 108 deletions
diff --git a/Source/CMCopyTable.h b/Source/CMCopyTable.h
index 288edafb..8b822df1 100644
--- a/Source/CMCopyTable.h
+++ b/Source/CMCopyTable.h
@@ -92,7 +92,7 @@
returns something meaningful.
@result The above described string, or nil if nothing selected
*/
-- (NSString *)draggedRowsAsTabString:(NSArray *)rows;
+- (NSString *)draggedRowsAsTabString;
/*
* Generate a string in form of INSERT INTO <table> VALUES () of
diff --git a/Source/CMCopyTable.m b/Source/CMCopyTable.m
index 64875cea..c12e7064 100644
--- a/Source/CMCopyTable.m
+++ b/Source/CMCopyTable.m
@@ -348,70 +348,64 @@ int MENU_EDIT_COPY_AS_SQL = 2002;
//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
+- (NSString *)draggedRowsAsTabString
{
- if ( [rows count] > 0 )
- {
- NSArray *columns = [self tableColumns];
- NSUInteger numColumns = [columns count];
- NSIndexSet *selectedRows = [self selectedRowIndexes];
- id dataSource = [self dataSource];
-
- NSMutableString *result = [NSMutableString stringWithCapacity:numColumns];
+ NSArray *columns = [self tableColumns];
+ NSUInteger numColumns = [columns count];
+ NSIndexSet *selectedRows = [self selectedRowIndexes];
+ id dataSource = [self dataSource];
+
+ NSMutableString *result = [NSMutableString stringWithCapacity:numColumns];
- NSUInteger c;
+ NSUInteger c;
- id rowData = nil;
- NSTableColumn *col = nil;
-
- NSUInteger rowIndex = [selectedRows firstIndex];
+ id rowData = nil;
+ NSTableColumn *col = nil;
+
+ NSUInteger rowIndex = [selectedRows firstIndex];
- while ( rowIndex != NSNotFound )
- {
- rowData = nil;
- for ( c = 0; c < numColumns; c++)
+ while ( rowIndex != NSNotFound )
+ {
+ rowData = nil;
+ for ( c = 0; c < numColumns; c++)
+ {
+ col = [columns objectAtIndex:c];
+ rowData = [dataSource tableView:self
+ objectValueForTableColumn:col
+ row:rowIndex ];
+
+ if ( nil != rowData )
{
- col = [columns objectAtIndex:c];
- rowData = [dataSource tableView:self
- objectValueForTableColumn:col
- row:rowIndex ];
-
- if ( nil != rowData )
- {
- if ([rowData isNSNull])
- [result appendString:[NSString stringWithFormat:@"%@\t", [prefs objectForKey:SPNullValue]]];
- else if ([rowData isSPNotLoaded])
- [result appendString:[NSString stringWithFormat:@"%@\t", NSLocalizedString(@"(not loaded)", @"value shown for hidden blob and text fields")]];
- else
- [result appendString:[NSString stringWithFormat:@"%@\t", [rowData description] ] ];
- }
+ if ([rowData isNSNull])
+ [result appendString:[NSString stringWithFormat:@"%@\t", [prefs objectForKey:SPNullValue]]];
+ else if ([rowData isSPNotLoaded])
+ [result appendString:[NSString stringWithFormat:@"%@\t", NSLocalizedString(@"(not loaded)", @"value shown for hidden blob and text fields")]];
else
- {
- [result appendString:@"\t"];
- }
- } //end for each column
-
- if ( [result length] )
+ [result appendString:[NSString stringWithFormat:@"%@\t", [rowData description] ] ];
+ }
+ else
{
- [result deleteCharactersInRange:NSMakeRange([result length]-1, 1)];
+ [result appendString:@"\t"];
}
- [result appendString: [ NSString stringWithFormat:@"\n"]];
-
- // next selected row
- rowIndex = [selectedRows indexGreaterThanIndex: rowIndex];
-
- } //end for each row
+ } //end for each column
if ( [result length] )
{
[result deleteCharactersInRange:NSMakeRange([result length]-1, 1)];
}
- return result;
- }
- else
+ [result appendString: [ NSString stringWithFormat:@"\n"]];
+
+ // next selected row
+ rowIndex = [selectedRows indexGreaterThanIndex: rowIndex];
+
+ } //end for each row
+
+ if ( [result length] )
{
- return nil;
+ [result deleteCharactersInRange:NSMakeRange([result length]-1, 1)];
}
+
+ return result;
}
/*
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m
index ebcf1259..4772823e 100644
--- a/Source/CustomQuery.m
+++ b/Source/CustomQuery.m
@@ -1643,10 +1643,10 @@
#pragma mark -
#pragma mark TableView Drag & Drop datasource methods
-- (BOOL)tableView:(NSTableView *)aTableView writeRows:(NSArray*)rows toPasteboard:(NSPasteboard*)pboard
+- (BOOL)tableView:(NSTableView *)aTableView writeRowsWithIndexes:(NSIndexSet *)rows toPasteboard:(NSPasteboard*)pboard
{
if ( aTableView == customQueryView ) {
- NSString *tmp = [customQueryView draggedRowsAsTabString:rows];
+ NSString *tmp = [customQueryView draggedRowsAsTabString];
if ( nil != tmp )
{
[pboard declareTypes:[NSArray arrayWithObjects: NSTabularTextPboardType,
diff --git a/Source/SPContentFilterManager.m b/Source/SPContentFilterManager.m
index 35896fcc..cdf7ee1f 100644
--- a/Source/SPContentFilterManager.m
+++ b/Source/SPContentFilterManager.m
@@ -605,11 +605,11 @@
/**
* Return whether or not the supplied rows can be written.
*/
-- (BOOL)tableView:(NSTableView *)tableView writeRows:(NSArray *)rows toPasteboard:(NSPasteboard *)pboard
+- (BOOL)tableView:(NSTableView *)aTableView writeRowsWithIndexes:(NSIndexSet *)rows toPasteboard:(NSPasteboard*)pboard
{
NSArray *pboardTypes = [NSArray arrayWithObject:SPContentFilterPasteboardDragType];
- NSInteger originalRow = [[rows objectAtIndex:0] intValue];
+ NSUInteger originalRow = [rows firstIndex];
if(originalRow < 1) return NO;
@@ -656,9 +656,18 @@
if(row < 1) return NO;
NSKeyedUnarchiver *unarchiver = [[[NSKeyedUnarchiver alloc] initForReadingWithData:[[info draggingPasteboard] dataForType:SPContentFilterPasteboardDragType]] autorelease];
- NSArray *draggedRows = [NSArray arrayWithArray:(NSArray *)[unarchiver decodeObjectForKey:@"indexdata"]];
+ NSIndexSet *draggedIndexes = [[NSIndexSet alloc] initWithIndexSet:(NSIndexSet *)[unarchiver decodeObjectForKey:@"indexdata"]];
[unarchiver finishDecoding];
+ // TODO: still rely on a NSArray but in the future rewrite it to use the NSIndexSet directly
+ NSMutableArray *draggedRows = [[NSMutableArray alloc] initWithCapacity:1];
+ NSUInteger rowIndex = [draggedIndexes firstIndex];
+ while ( rowIndex != NSNotFound ) {
+ [draggedRows addObject:[NSNumber numberWithInt:rowIndex]];
+ rowIndex = [draggedIndexes indexGreaterThanIndex: rowIndex];
+ }
+
+
NSInteger destinationRow = row;
NSInteger offset = 0;
@@ -690,7 +699,8 @@
[contentFilterTableView reloadData];
[contentFilterArrayController rearrangeObjects];
-
+ [draggedIndexes release];
+ [draggedRows release];
return YES;
}
diff --git a/Source/SPPreferenceController.m b/Source/SPPreferenceController.m
index 1a2fdf41..ef01ebf7 100644
--- a/Source/SPPreferenceController.m
+++ b/Source/SPPreferenceController.m
@@ -553,25 +553,19 @@
#pragma mark TableView drag & drop datasource methods
// -------------------------------------------------------------------------------
-// tableView:writeRows:toPasteboard:
+// tableView:writeRowsWithIndexes:toPasteboard:
// -------------------------------------------------------------------------------
-- (BOOL)tableView:(NSTableView *)tv writeRows:(NSArray *)rows toPasteboard:(NSPasteboard *)pboard
+- (BOOL)tableView:(NSTableView *)aTableView writeRowsWithIndexes:(NSIndexSet *)rows toPasteboard:(NSPasteboard*)pboard
{
- int originalRow;
- NSArray *pboardTypes;
-
+
if ([rows count] == 1) {
- pboardTypes = [NSArray arrayWithObject:SPFavoritesPasteboardDragType];
- originalRow = [[rows objectAtIndex:0] intValue];
-
- [pboard declareTypes:pboardTypes owner:nil];
- [pboard setString:[[NSNumber numberWithInt:originalRow] stringValue] forType:SPFavoritesPasteboardDragType];
-
+ [pboard declareTypes:[NSArray arrayWithObject:SPFavoritesPasteboardDragType] owner:nil];
+ [pboard setString:[[NSNumber numberWithInt:[rows firstIndex]] stringValue] forType:SPFavoritesPasteboardDragType];
return YES;
- }
- else {
+ } else {
return NO;
}
+
}
// -------------------------------------------------------------------------------
diff --git a/Source/SPQueryFavoriteManager.m b/Source/SPQueryFavoriteManager.m
index db70e8f5..d03581a6 100644
--- a/Source/SPQueryFavoriteManager.m
+++ b/Source/SPQueryFavoriteManager.m
@@ -564,33 +564,27 @@
/**
* Return whether or not the supplied rows can be written.
*/
-- (BOOL)tableView:(NSTableView *)tableView writeRows:(NSArray *)rows toPasteboard:(NSPasteboard *)pboard
+- (BOOL)tableView:(NSTableView *)aTableView writeRowsWithIndexes:(NSIndexSet *)rows toPasteboard:(NSPasteboard*)pboard
{
- // Up to now only one row can be dragged
- // if ([rows count] == 1) {
+ NSArray *pboardTypes = [NSArray arrayWithObject:SPFavoritesPasteboardDragType];
+ NSInteger originalRow = [rows firstIndex];
- NSArray *pboardTypes = [NSArray arrayWithObject:SPFavoritesPasteboardDragType];
- NSInteger originalRow = [[rows objectAtIndex:0] intValue];
+ if(originalRow < 1) return NO;
- if(originalRow < 1) return NO;
+ // Do not drag headers
+ if([[favorites objectAtIndex:originalRow] objectForKey:@"headerOfFileURL"]) return NO;
- // Do not drag headers
- if([[favorites objectAtIndex:originalRow] objectForKey:@"headerOfFileURL"]) return NO;
+ [pboard declareTypes:pboardTypes owner:nil];
- [pboard declareTypes:pboardTypes owner:nil];
+ NSMutableData *indexdata = [[[NSMutableData alloc] init] autorelease];
+ NSKeyedArchiver *archiver = [[[NSKeyedArchiver alloc] initForWritingWithMutableData:indexdata] autorelease];
+ [archiver encodeObject:rows forKey:@"indexdata"];
+ [archiver finishEncoding];
+ [pboard setData:indexdata forType:SPFavoritesPasteboardDragType];
- NSMutableData *indexdata = [[[NSMutableData alloc] init] autorelease];
- NSKeyedArchiver *archiver = [[[NSKeyedArchiver alloc] initForWritingWithMutableData:indexdata] autorelease];
- [archiver encodeObject:rows forKey:@"indexdata"];
- [archiver finishEncoding];
- [pboard setData:indexdata forType:SPFavoritesPasteboardDragType];
-
- return YES;
-
- // }
+ return YES;
- // return NO;
}
/**
@@ -621,9 +615,17 @@
if(row < 1) return NO;
NSKeyedUnarchiver *unarchiver = [[[NSKeyedUnarchiver alloc] initForReadingWithData:[[info draggingPasteboard] dataForType:SPFavoritesPasteboardDragType]] autorelease];
- NSArray *draggedRows = [NSArray arrayWithArray:(NSArray *)[unarchiver decodeObjectForKey:@"indexdata"]];
+ NSIndexSet *draggedIndexes = [[NSIndexSet alloc] initWithIndexSet:(NSIndexSet *)[unarchiver decodeObjectForKey:@"indexdata"]];
[unarchiver finishDecoding];
+ // TODO: still rely on a NSArray but in the future rewrite it to use the NSIndexSet directly
+ NSMutableArray *draggedRows = [[NSMutableArray alloc] initWithCapacity:1];
+ NSUInteger rowIndex = [draggedIndexes firstIndex];
+ while ( rowIndex != NSNotFound ) {
+ [draggedRows addObject:[NSNumber numberWithInt:rowIndex]];
+ rowIndex = [draggedIndexes indexGreaterThanIndex: rowIndex];
+ }
+
NSInteger destinationRow = row;
NSInteger offset = 0;
@@ -655,6 +657,8 @@
[favoritesTableView reloadData];
[favoritesArrayController rearrangeObjects];
+ [draggedIndexes release];
+ [draggedRows release];
return YES;
}
diff --git a/Source/TableContent.m b/Source/TableContent.m
index 6b8ecf0e..cacccc97 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -2907,9 +2907,9 @@
/**
* Enable drag from tableview
*/
-- (BOOL)tableView:(NSTableView *)tableView writeRows:(NSArray*)rows toPasteboard:(NSPasteboard*)pboard
-{
- if (tableView == tableContentView) {
+- (BOOL)tableView:(NSTableView *)aTableView writeRowsWithIndexes:(NSIndexSet *)rows toPasteboard:(NSPasteboard*)pboard
+{
+ if (aTableView == tableContentView) {
NSString *tmp;
// By holding ⌘, ⇧, or/and ⌥ copies selected rows as SQL INSERTS
@@ -2917,7 +2917,7 @@
if([[NSApp currentEvent] modifierFlags] & (NSCommandKeyMask|NSShiftKeyMask|NSAlternateKeyMask))
tmp = [tableContentView selectedRowsAsSqlInserts];
else
- tmp = [tableContentView draggedRowsAsTabString:rows];
+ tmp = [tableContentView draggedRowsAsTabString];
if ( nil != tmp && [tmp length] )
{
@@ -2930,7 +2930,7 @@
return YES;
}
}
-
+
return NO;
}
diff --git a/Source/TableSource.m b/Source/TableSource.m
index bf431326..9d1c6814 100644
--- a/Source/TableSource.m
+++ b/Source/TableSource.m
@@ -1082,29 +1082,23 @@ returns a dictionary containing enum/set field names as key and possible values
/*
Begin a drag and drop operation from the table - copy a single dragged row to the drag pasteboard.
*/
-- (BOOL)tableView:(NSTableView *)tableView writeRows:(NSArray*)rows toPasteboard:(NSPasteboard*)pboard
+- (BOOL)tableView:(NSTableView *)aTableView writeRowsWithIndexes:(NSIndexSet *)rows toPasteboard:(NSPasteboard*)pboard
{
- //make sure that the drag operation is started from the right table view
- if (tableView!=tableSourceView) return NO;
-
-
- int originalRow;
- NSArray *pboardTypes;
+
+ //make sure that the drag operation is started from the right table view
+ if (aTableView != tableSourceView) return NO;
// Check whether a save of the current field row is required.
if ( ![self saveRowOnDeselect] ) return NO;
- if ( ([rows count] == 1) && (tableView == tableSourceView) ) {
- pboardTypes=[NSArray arrayWithObjects:@"SequelProPasteboard", nil];
- originalRow = [[rows objectAtIndex:0] intValue];
-
- [pboard declareTypes:pboardTypes owner:nil];
- [pboard setString:[[NSNumber numberWithInt:originalRow] stringValue] forType:@"SequelProPasteboard"];
-
+ if ([rows count] == 1) {
+ [pboard declareTypes:[NSArray arrayWithObject:@"SequelProPasteboard"] owner:nil];
+ [pboard setString:[[NSNumber numberWithInt:[rows firstIndex]] stringValue] forType:@"SequelProPasteboard"];
return YES;
} else {
return NO;
}
+
}
/*