Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix a bug that could cause items in the favorite list to be color-lab…
…eled when they don't have a label assigned
  • Loading branch information
dmoagx committed Feb 19, 2015
1 parent fc02994 commit 5f3c003
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
19 changes: 11 additions & 8 deletions Source/SPConnectionControllerDelegate.m
Expand Up @@ -147,38 +147,41 @@ - (NSCell *)outlineView:(NSOutlineView *)outlineView dataCellForTableColumn:(NST

- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
SPTreeNode *node = (SPTreeNode *)item;
SPTreeNode *node = (SPTreeNode *)item;
SPFavoriteTextFieldCell *favoriteCell = (SPFavoriteTextFieldCell *)cell;

// Draw entries with the small system font by default
[(SPTableTextFieldCell *)cell setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
[cell setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];

// Set an image as appropriate; the quick connect image for that entry, no image for other
// top-level items, the folder image for group nodes, or the database image for other nodes.
if (![[node parentNode] parentNode]) {
if (node == quickConnectItem) {
if ([outlineView rowForItem:item] == [outlineView selectedRow]) {
[(SPTableTextFieldCell *)cell setImage:[NSImage imageNamed:SPQuickConnectImageWhite]];
[favoriteCell setImage:[NSImage imageNamed:SPQuickConnectImageWhite]];
}
else {
[(SPTableTextFieldCell *)cell setImage:[NSImage imageNamed:SPQuickConnectImage]];
[favoriteCell setImage:[NSImage imageNamed:SPQuickConnectImage]];
}
}
else {
[(SPTableTextFieldCell *)cell setImage:nil];
[favoriteCell setImage:nil];
}
[favoriteCell setLabelColor:nil];
}
else {
if ([node isGroup]) {
[(SPTableTextFieldCell *)cell setImage:folderImage];
[favoriteCell setImage:folderImage];
[favoriteCell setLabelColor:nil];
}
else {
[(SPTableTextFieldCell *)cell setImage:[NSImage imageNamed:SPDatabaseImage]];
[favoriteCell setImage:[NSImage imageNamed:SPDatabaseImage]];
NSColor *bgColor = nil;
NSNumber *colorIndexObj = [[[node representedObject] nodeFavorite] objectForKey:SPFavoriteColorIndexKey];
if(colorIndexObj != nil) {
bgColor = [[SPFavoriteColorSupport sharedInstance] colorForIndex:[colorIndexObj integerValue]];
}
[(SPFavoriteTextFieldCell *)cell setLabelColor:bgColor];
[favoriteCell setLabelColor:bgColor];
}
}

Expand Down
2 changes: 1 addition & 1 deletion Source/SPFavoriteTextFieldCell.m
Expand Up @@ -49,7 +49,7 @@ - (id)copyWithZone:(NSZone *)zone
SPFavoriteTextFieldCell *cell = (SPFavoriteTextFieldCell *)[super copyWithZone:zone];

cell->drawsDividerUnderCell = drawsDividerUnderCell;
cell->labelColor = nil; //TODO copying the color sometimes causes a drawing bug
cell->labelColor = [labelColor copyWithZone:zone];

return cell;
}
Expand Down

0 comments on commit 5f3c003

Please sign in to comment.