mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-13 22:21:29 +00:00
+43
-8
@@ -2465,7 +2465,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
- (void)_sendDataSourceSortDescriptorsDidChange:(CPArray)oldDescriptors
|
||||
{
|
||||
if (_implementedDataSourceMethods & CPTableViewDataSource_tableView_sortDescriptorsDidChange_)
|
||||
[_dataSource tableView:self sortDescriptorsDidChange:oldDescriptors];
|
||||
[_dataSource tableView:self sortDescriptorsDidChange:oldDescriptors];
|
||||
}
|
||||
|
||||
|
||||
@@ -2543,13 +2543,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
[newSortDescriptors removeObjectsInArray:outdatedDescriptors];
|
||||
[newSortDescriptors insertObject:newMainSortDescriptor atIndex:0];
|
||||
|
||||
// Update indicator image & highlighted column before
|
||||
var image = [newMainSortDescriptor ascending] ? [self _tableHeaderSortImage] : [self _tableHeaderReverseSortImage];
|
||||
|
||||
[self setIndicatorImage:nil inTableColumn:_currentHighlightedTableColumn];
|
||||
[self setIndicatorImage:image inTableColumn:tableColumn];
|
||||
[self setHighlightedTableColumn:tableColumn];
|
||||
|
||||
[self setSortDescriptors:newSortDescriptors];
|
||||
}
|
||||
|
||||
@@ -2814,6 +2808,28 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
return _verticalMotionCanDrag;
|
||||
}
|
||||
|
||||
- (CPTableColumn)_tableColumnForSortDescriptor:(CPSortDescriptor)theSortDescriptor
|
||||
{
|
||||
var tableColumns = [self tableColumns];
|
||||
|
||||
for (var i = 0; i < [tableColumns count]; i++)
|
||||
{
|
||||
var tableColumn = [tableColumns objectAtIndex:i],
|
||||
sortDescriptorPrototype = [tableColumn sortDescriptorPrototype];
|
||||
|
||||
if (!sortDescriptorPrototype)
|
||||
continue;
|
||||
|
||||
if ([sortDescriptorPrototype key] === [theSortDescriptor key]
|
||||
&& [sortDescriptorPrototype selector] === [theSortDescriptor selector])
|
||||
{
|
||||
return tableColumn;
|
||||
}
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the table view's CPSortDescriptors objects in an array.
|
||||
|
||||
@@ -2821,7 +2837,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
*/
|
||||
- (void)setSortDescriptors:(CPArray)sortDescriptors
|
||||
{
|
||||
var oldSortDescriptors = [self sortDescriptors],
|
||||
var oldSortDescriptors = [[self sortDescriptors] copy],
|
||||
newSortDescriptors = nil;
|
||||
|
||||
if (sortDescriptors == nil)
|
||||
@@ -2834,6 +2850,25 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
|
||||
_sortDescriptors = newSortDescriptors;
|
||||
|
||||
var oldColumn = nil,
|
||||
newColumn = nil;
|
||||
|
||||
if ([newSortDescriptors count] > 0)
|
||||
{
|
||||
var newMainSortDescriptor = [newSortDescriptors objectAtIndex:0];
|
||||
newColumn = [self _tableColumnForSortDescriptor:newMainSortDescriptor];
|
||||
}
|
||||
|
||||
if ([oldSortDescriptors count] > 0)
|
||||
{
|
||||
var oldMainSortDescriptor = [oldSortDescriptors objectAtIndex:0];
|
||||
oldColumn = [self _tableColumnForSortDescriptor:oldMainSortDescriptor];
|
||||
}
|
||||
|
||||
var image = [newMainSortDescriptor ascending] ? [self _tableHeaderSortImage] : [self _tableHeaderReverseSortImage];
|
||||
[self setIndicatorImage:nil inTableColumn:oldColumn];
|
||||
[self setIndicatorImage:image inTableColumn:newColumn];
|
||||
|
||||
[self _sendDataSourceSortDescriptorsDidChange:oldSortDescriptors];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user