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

View File

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