Rewrote uiTableModelRowChanged() to properly update rows. We can do this now that we have the setup for row updates and reuse, but this is better than calling reloadData anyway (and reloadData doesn't update the row view, but we (almost) do, so...)...

This commit is contained in:
Pietro Gagliardi 2018-06-03 21:39:49 -04:00
parent 247d63be60
commit 6457e1668f
2 changed files with 19 additions and 18 deletions

View File

@ -26,7 +26,7 @@
- (NSView *)tableView:(NSTableView *)tv viewForTableColumn:(NSTableColumn *)cc row:(NSInteger)row
{
uiprivTableColumn *c = (uiprivTableColumn *) cc;
xx TODO consider renaming this type to uiprivTableCellView
// TODO consider renaming this type to uiprivTableCellView
uiprivColumnCellView *cv;
cv = (uiprivColumnCellView *) [tv makeViewWithIdentifier:[c identifier] owner:self];
@ -43,24 +43,17 @@
@end
=================== TODOTODO
uiTableModel *uiNewTableModel(uiTableModelHandler *mh)
{
uiTableModel *m;
m = uiprivNew(uiTableModel);
m->mh = mh;
m->m = [[tableModel alloc] initWithModel:m];
m->m = [[uiprivTableModel alloc] initWithModel:m];
m->tables = [NSMutableArray new];
return m;
}
void *uiTableModelGiveColor(double r, double g, double b, double a)
{
return [[NSColor colorWithSRGBRed:r green:g blue:b alpha:a] retain];
}
void uiFreeTableModel(uiTableModel *m)
{
if ([m->tables count] != 0)
@ -84,16 +77,22 @@ void uiTableModelRowInserted(uiTableModel *m, int newIndex)
void uiTableModelRowChanged(uiTableModel *m, int index)
{
NSTableView *tv;
NSIndexSet *set, *cols;
NSTableRowView *rv;
NSUInteger i, n;
uiprivTableColumnView *cv;
set = [NSIndexSet indexSetWithIndex:index];
for (tv in m->tables) {
cols = [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange(0, [[tv tableColumns] count])];
[tv reloadDataForRowIndexes:set columnIndexes:cols];
// TODO this isn't enough
[cols release];
rv = [tv rowViewForRow:index makeIfNecessary:NO];
if (rv != nil) {
xx TODO update colors
}
n = [[tv tableColumns] count];
for (i = 0; i < n; i++) {
cv = (uiprivTableCellView *) [tv viewForColumn:i row:index makeIfNecessary:NO];
if (cv != nil)
[cv uiprivUpdate:index];
}
}
// set is autoreleased
}
void uiTableModelRowDeleted(uiTableModel *m, int oldIndex)
@ -107,6 +106,8 @@ void uiTableModelRowDeleted(uiTableModel *m, int oldIndex)
// set is autoreleased
}
=================== TODOTODO
void uiTableColumnAppendTextPart(uiTableColumn *c, int modelColumn, int expand)
{
tablePart *part;

View File

@ -259,12 +259,12 @@ struct textColumnCreateParams {
data = (*(self->m->mh->CellValue))(self->m->mh, self->m, row, self->textParams.ColorModelColumn);
uiTableDataColor(data, &r, &g, &b, &a);
uiFreeTableData(data);
// TODO
color = [NSColor colorWithSRGBRed:r green:g blue:b alpha:a];
}
if (color == nil)
color = [NSColor controlTextColor];
[self->tf setColor:color];
// TODO release color
// we don't own color in ether case; don't release
}
if (self->iv != nil) {
uiImage *img;