mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-09 16:38:45 +00:00
Fixes for adding and removing columns to the tableview after the tableview has already been displayed... There are still issues though.
This commit is contained in:
1 parent
7696b30067
commit
70f2d86b58
2 files changed
+86
-19
No files matched your search
+21
-1
@@ -220,6 +220,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
CPColor _sourceListActiveBottomLineColor;
|
||||
|
||||
int _draggedColumnIndex;
|
||||
CPArray _differedColumnDataToRemove;
|
||||
|
||||
/*
|
||||
CPGradient _sourceListInactiveGradient;
|
||||
@@ -340,6 +341,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
_sourceListInactiveGradient = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), [168.0/255.0,183.0/255.0,205.0/255.0,1.0,157.0/255.0,174.0/255.0,199.0/255.0,1.0], [0,1], 2);
|
||||
_sourceListInactiveTopLineColor = [CPColor colorWithCalibratedRed:(173.0/255.0) green:(187.0/255.0) blue:(209.0/255.0) alpha:1.0];
|
||||
_sourceListInactiveBottomLineColor = [CPColor colorWithCalibratedRed:(150.0/255.0) green:(161.0/255.0) blue:(183.0/255.0) alpha:1.0];*/
|
||||
_differedColumnDataToRemove = [ ];
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -725,6 +727,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
else
|
||||
_dirtyTableColumnRangeIndex = MIN(NUMBER_OF_COLUMNS() - 1, _dirtyTableColumnRangeIndex);
|
||||
|
||||
[self tile];
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
@@ -742,8 +745,11 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
if (index === CPNotFound)
|
||||
return;
|
||||
|
||||
// we differ the actual removal until the end of the runloop in order to keep a reference to the column.
|
||||
[_differedColumnDataToRemove addObject:{"column":aTableColumn, "shouldBeHidden": [aTableColumn isHidden]}];
|
||||
|
||||
[aTableColumn setHidden:YES];
|
||||
[aTableColumn setTableView:nil];
|
||||
[_tableColumns removeObjectAtIndex:index];
|
||||
|
||||
var tableColumnUID = [aTableColumn UID];
|
||||
|
||||
@@ -2244,6 +2250,20 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
[dataViews[count] removeFromSuperview];
|
||||
}
|
||||
|
||||
// if we have any columns to remove do that here
|
||||
if ([_differedColumnDataToRemove count])
|
||||
{
|
||||
for (var i = 0; i < _differedColumnDataToRemove.length; i++)
|
||||
{
|
||||
var data = _differedColumnDataToRemove[i],
|
||||
column = data.column;
|
||||
|
||||
[column setHidden:data.shouldBeHidden];
|
||||
[_tableColumns removeObject:column];
|
||||
}
|
||||
[_differedColumnDataToRemove removeAllObjects];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (void)_unloadDataViewsInRows:(CPIndexSet)rows columns:(CPIndexSet)columns
|
||||
|
||||
@@ -10,6 +10,8 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
CPImage iconImage;
|
||||
CPArray dataSet1;
|
||||
CPArray dataSet2;
|
||||
|
||||
CPTableColumn randomColumn;
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
|
||||
@@ -68,6 +70,9 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
|
||||
[column setEditable:YES];
|
||||
[tableView addTableColumn:column];
|
||||
|
||||
if (i === 2)
|
||||
randomColumn = column;
|
||||
}
|
||||
|
||||
// we offset this scrollview to make sure all the coordinates are calculated correctly
|
||||
@@ -95,16 +100,34 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
[button setAction:@selector(addRow:)];
|
||||
[contentView addSubview:button];
|
||||
|
||||
var sourceListActiveGradient = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), [255.0/255.0, 153.0/255.0, 209.0/255.0,1.0, 33.0/255.0, 94.0/255.0, 208.0/255.0,1.0], [0,1], 2),
|
||||
sourceListActiveTopLineColor = [CPColor colorWithCalibratedRed:(255.0/255.0) green:(123.0/255.0) blue:(218.0/255.0) alpha:1.0],
|
||||
sourceListActiveBottomLineColor = [CPColor colorWithCalibratedRed:(255.0/255.0) green:(92.0/255.0) blue:(207.0/255.0) alpha:1.0];
|
||||
[tableView setSelectionGradientColors:[CPDictionary dictionaryWithObjects:[sourceListActiveGradient, sourceListActiveTopLineColor, sourceListActiveBottomLineColor] forKeys:[CPSourceListGradient, CPSourceListTopLineColor, CPSourceListBottomLineColor]]];
|
||||
|
||||
var button = [[CPButton alloc] initWithFrame:CGRectMake(10,70,100, 24)];
|
||||
[button setTitle:@"Switch Highlight"];
|
||||
[button setTarget:self];
|
||||
[button setAction:@selector(switchSelectionHighlightType:)];
|
||||
[contentView addSubview:button];
|
||||
|
||||
var button = [[CPButton alloc] initWithFrame:CGRectMake(10,100,100, 24)];
|
||||
[button setTitle:@"Hide Column"];
|
||||
[button setTarget:self];
|
||||
[button setAction:@selector(hideColumn:)];
|
||||
[contentView addSubview:button];
|
||||
|
||||
var button = [[CPButton alloc] initWithFrame:CGRectMake(10,130,100, 24)];
|
||||
[button setTitle:@"Remove Column"];
|
||||
[button setTarget:self];
|
||||
[button setAction:@selector(removeColumn:)];
|
||||
[contentView addSubview:button];
|
||||
|
||||
var button = [[CPButton alloc] initWithFrame:CGRectMake(10,160,100, 24)];
|
||||
[button setTitle:@"Add Column"];
|
||||
[button setTarget:self];
|
||||
[button setAction:@selector(addColumn:)];
|
||||
[contentView addSubview:button];
|
||||
|
||||
var sourceListActiveGradient = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), [255.0/255.0, 153.0/255.0, 209.0/255.0,1.0, 33.0/255.0, 94.0/255.0, 208.0/255.0,1.0], [0,1], 2),
|
||||
sourceListActiveTopLineColor = [CPColor colorWithCalibratedRed:(255.0/255.0) green:(123.0/255.0) blue:(218.0/255.0) alpha:1.0],
|
||||
sourceListActiveBottomLineColor = [CPColor colorWithCalibratedRed:(255.0/255.0) green:(92.0/255.0) blue:(207.0/255.0) alpha:1.0];
|
||||
[tableView setSelectionGradientColors:[CPDictionary dictionaryWithObjects:[sourceListActiveGradient, sourceListActiveTopLineColor, sourceListActiveBottomLineColor] forKeys:[CPSourceListGradient, CPSourceListTopLineColor, CPSourceListBottomLineColor]]];
|
||||
}
|
||||
|
||||
- (void)switchSelectionHighlightType:(id)sender
|
||||
@@ -124,6 +147,31 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
[tableView reloadData];
|
||||
}
|
||||
|
||||
- (void)hideColumn:(id)sender
|
||||
{
|
||||
[randomColumn setHidden:![randomColumn isHidden]];
|
||||
}
|
||||
|
||||
- (void)removeColumn:(id)sender
|
||||
{
|
||||
// if ([[tableView tableColumns] containsObject:randomColumn])
|
||||
[tableView removeTableColumn:randomColumn];
|
||||
//else
|
||||
// [tableView addTableColumn:randomColumn];
|
||||
}
|
||||
|
||||
- (void)addColumn:(id)sender
|
||||
{
|
||||
var column = [[CPTableColumn alloc] initWithIdentifier:"NewColumn"];
|
||||
[[column headerView] setStringValue:"New Column"];
|
||||
|
||||
[column setMinWidth:50.0];
|
||||
[column setMaxWidth:500.0];
|
||||
[column setWidth:75.0];
|
||||
|
||||
[tableView addTableColumn:column];
|
||||
}
|
||||
|
||||
- (void)newWindow
|
||||
{
|
||||
|
||||
@@ -237,7 +285,7 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
return iconImage;
|
||||
|
||||
if (aTableView === tableView)
|
||||
return String(dataSet1[aRow]);
|
||||
return String(dataSet1[aRow]* ([[aTableView tableColumns] indexOfObject:aColumn] + 1));
|
||||
else if (aTableView === tableView2)
|
||||
return String(dataSet2[aRow]);
|
||||
else if(aTableView === tableView3)
|
||||
@@ -246,7 +294,7 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
|
||||
- (void)tableView:(CPTableView)aTableView sortDescriptorsDidChange:(CPArray)oldDescriptors
|
||||
{
|
||||
CPLogConsole(_cmd + [oldDescriptors description]);
|
||||
//CPLogConsole(_cmd + [oldDescriptors description]);
|
||||
|
||||
var newDescriptors = [aTableView sortDescriptors];
|
||||
|
||||
@@ -257,39 +305,39 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
|
||||
- (void)tableViewSelectionIsChanging:(CPNotification)aNotification
|
||||
{
|
||||
CPLog.debug(@"changing! %@", [aNotification description]);
|
||||
//CPLog.debug(@"changing! %@", [aNotification description]);
|
||||
}
|
||||
|
||||
- (void)tableViewSelectionDidChange:(CPNotification)aNotification
|
||||
{
|
||||
CPLog.debug(@"did change! %@", [aNotification description]);
|
||||
//CPLog.debug(@"did change! %@", [aNotification description]);
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(CPTableView)aTableView shouldSelectRow:(int)rowIndex
|
||||
{
|
||||
CPLog.debug(@"tableView:shouldSelectRow");
|
||||
//CPLog.debug(@"tableView:shouldSelectRow");
|
||||
return true;
|
||||
}
|
||||
|
||||
- (BOOL)selectionShouldChangeInTableView:(CPTableView)aTableView
|
||||
{
|
||||
CPLog.debug(@"selectionShouldChangeInTableView");
|
||||
//CPLog.debug(@"selectionShouldChangeInTableView");
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)tableViewSelectionDidChange:(id)notification
|
||||
{
|
||||
CPLogConsole(_cmd + [notification description]);
|
||||
//CPLogConsole(_cmd + [notification description]);
|
||||
}
|
||||
|
||||
- (void)tableViewSelectionIsChanging:(id)notification
|
||||
{
|
||||
CPLogConsole(_cmd + [notification description]);
|
||||
//CPLogConsole(_cmd + [notification description]);
|
||||
}
|
||||
|
||||
- (void)_tableViewColumnDidResize:(id)notification
|
||||
{
|
||||
CPLogConsole(_cmd + [notification description]);
|
||||
//CPLogConsole(_cmd + [notification description]);
|
||||
}
|
||||
- (BOOL)tableView:(CPTableView)aTableView shouldEditTableColumn:(CPTableColumn)tableColumn row:(int)row
|
||||
{
|
||||
@@ -301,7 +349,7 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
|
||||
- (void)tableView:(CPTableView)aTableView willDisplayView:(CPView)aView forTableColumn:(CPTableColumn)tableColumn row:(int)row
|
||||
{
|
||||
CPLogConsole(_cmd + " column: " + [tableColumn identifier] + " row:" + row)
|
||||
//CPLogConsole(_cmd + " column: " + [tableColumn identifier] + " row:" + row)
|
||||
}
|
||||
|
||||
- (void)tableView:(CPTableView)aTableView setObjectValue:(id)aValue forTableColumn:(CPTableColumn)tableColumn row:(int)row
|
||||
@@ -312,7 +360,7 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
|
||||
- (void)tableView:(CPTableView)aTableView sortDescriptorsDidChange:(CPArray)oldDescriptors
|
||||
{
|
||||
CPLogConsole(_cmd + [oldDescriptors description]);
|
||||
//CPLogConsole(_cmd + [oldDescriptors description]);
|
||||
|
||||
var newDescriptors = [aTableView sortDescriptors];
|
||||
|
||||
@@ -403,13 +451,12 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
|
||||
- (void)tableView:(CPTableView)aTableView didClickTableColumn:(CPTableColumn)aColumn
|
||||
{
|
||||
CPLog.debug("table: "+aTableView+" clicked column: "+aColumn);
|
||||
//CPLog.debug("table: "+aTableView+" clicked column: "+aColumn);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPArray (MoveIndexes)
|
||||
|
||||
- (void)moveIndexes:(CPIndexSet)indexes toIndex:(int)insertIndex
|
||||
{
|
||||
var aboveCount = 0,
|
||||
|
||||
Reference in new issue
Block a user