adds shouldReorderColumn to CPTableView delegate methods

This commit is contained in:
Christophe Serafin
2013-03-01 11:57:24 +01:00
parent 5312524871
commit 77d2ebbda0
2 changed files with 26 additions and 1 deletions
+1 -1
View File
@@ -455,7 +455,7 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
- (BOOL)_shouldDragTableColumn:(int)aColumnIndex at:(CGPoint)aPoint
{
return [_tableView allowsColumnReordering] && ABS(aPoint.x - _mouseDownLocation.x) >= 10.0;
return [_tableView _shouldReorderColumn:aColumnIndex toColumn:-1] && ABS(aPoint.x - _mouseDownLocation.x) >= 10.0;
}
- (CGRect)_headerRectOfLastVisibleColumn
+25
View File
@@ -82,6 +82,7 @@ var CPTableViewDelegate_selectionShouldChangeInTableView_
CPTableViewDelegate_tableViewSelectionDidChange_ = 1 << 18,
CPTableViewDelegate_tableViewSelectionIsChanging_ = 1 << 19,
CPTableViewDelegate_tableViewMenuForTableColumn_Row_ = 1 << 20;
CPTableViewDelegate_tableView_shouldReorderColumn_toColumn_ = 1 << 21;
//CPTableViewDraggingDestinationFeedbackStyles
CPTableViewDraggingDestinationFeedbackStyleNone = -1;
@@ -998,6 +999,21 @@ NOT YET IMPLEMENTED
[self reloadDataForRowIndexes:_exposedRows columnIndexes:[CPIndexSet indexSetWithIndex:[_tableColumns indexOfObject:previouslyDraggedColumn]]];
}
/*
@ignore
Returns YES if the column at columnIndex can be reordered.
It can be possible if column reordering is allowed and if the tableview
delegate also accept the reordering
*/
- (BOOL)_shouldReorderColumn:(int)columnIndex toColumn:(int)newColumnIndex
{
if ([self allowsColumnReordering]
&& _implementedDelegateMethods & CPTableViewDelegate_tableView_shouldReorderColumn_toColumn_)
return [_delegate tableView:self shouldReorderColumn:columnIndex toColumn:newColumnIndex];
return [self allowsColumnReordering];
}
/*
@ignore
Same as moveColumn:toColumn: but doesn't trigger an autosave
@@ -1011,6 +1027,9 @@ NOT YET IMPLEMENTED
if (fromIndex === toIndex)
return;
if (![self _shouldReorderColumn:fromIndex toColumn:toIndex])
return;
if (_dirtyTableColumnRangeIndex < 0)
_dirtyTableColumnRangeIndex = MIN(fromIndex, toIndex);
else
@@ -2575,6 +2594,8 @@ Informs the delegate that the tableview selection has changed.
@section movingandresizingcolumsn Moving and Resizing Columns:
Return YES if the column at a given index should move to a new column index, otherwise NO.
When a column is initially dragged by the user, the delegate is first called with a newColumnIndex value of -1
@code
- (BOOL)tableView:(CPTableView)tableView shouldReorderColumn:(int)columnIndex toColumn:(int)newColumnIndex;
@endcode
@@ -2726,6 +2747,10 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
if ([_delegate respondsToSelector:@selector(tableView:menuForTableColumn:row:)])
_implementedDelegateMethods |= CPTableViewDelegate_tableViewMenuForTableColumn_Row_;
if ([_delegate respondsToSelector:@selector(tableView:shouldReorderColumn:toColumn:)])
_implementedDelegateMethods |= CPTableViewDelegate_tableView_shouldReorderColumn_toColumn_;
if ([_delegate respondsToSelector:@selector(tableViewColumnDidMove:)])
[defaultCenter
addObserver:_delegate