Skip to content

Commit

Permalink
Explicitly set item and line index
Browse files Browse the repository at this point in the history
  • Loading branch information
shundhammer committed Oct 28, 2020
1 parent f2f4874 commit 5b967b9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
22 changes: 11 additions & 11 deletions src/NCMultiSelectionBox.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,27 +81,28 @@ YItem * NCMultiSelectionBox::currentItem()
}



void NCMultiSelectionBox::setCurrentItem( YItem * item )
{
if ( item )
myPad()->ScrlLine( item->index() );
}


void NCMultiSelectionBox::addItem( YItem * item )
{
std::vector<NCTableCol*> Items( 2U, 0 );
std::vector<NCTableCol*> cells( 2U, 0 );

if ( item )
{
item->setIndex( itemsCount() );
YMultiSelectionBox::addItem( item );
Items[0] = new NCTableTag( item, item->selected() );
cells[0] = new NCTableTag( item, item->selected() );

// Do not set style to NCTableCol::PLAIN here, otherwise the current
//item will not be highlighted if the cursor is not over the widget
// item will not be highlighted if the cursor is not over the widget

Items[1] = new NCTableCol( item->label() );
myPad()->Append( Items );
cells[1] = new NCTableCol( item->label() );
myPad()->Append( cells, item->index() );
DrawPad();
}
}
Expand Down Expand Up @@ -133,7 +134,6 @@ const NCTableTag * NCMultiSelectionBox::tagCell( int index ) const
}



void NCMultiSelectionBox::deleteAllItems()
{
YMultiSelectionBox::deleteAllItems();
Expand All @@ -157,11 +157,11 @@ void NCMultiSelectionBox::selectItem( YItem *yitem, bool selected )
{
YMultiSelectionBox::selectItem( yitem, selected );

//retrieve pointer to the line tag associated with this item
NCTableTag * tag = ( NCTableTag * )yitem->data();
// retrieve pointer to the line tag associated with this item
NCTableTag * tag = (NCTableTag *) yitem->data();
YUI_CHECK_PTR( tag );

tag->SetSelected( selected );
tag->SetSelected( selected );

DrawPad();
}
Expand All @@ -177,7 +177,7 @@ void NCMultiSelectionBox::deselectAllItems()
NCTableTag *t = tagCell( i );
YUI_CHECK_PTR( t );

t->SetSelected( false );
t->SetSelected( false );
}

DrawPad();
Expand Down
7 changes: 4 additions & 3 deletions src/NCSelectionBox.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,14 @@ void NCSelectionBox::selectItem( int index )

void NCSelectionBox::addItem( YItem * item )
{
std::vector<NCTableCol*> Items( 1U, 0 );
std::vector<NCTableCol*> cells( 1U, 0 );

if ( item )
{
item->setIndex( itemsCount() );
YSelectionBox::addItem( item );
Items[0] = new NCTableCol( item->label() );
myPad()->Append( Items );
cells[0] = new NCTableCol( item->label() );
myPad()->Append( cells, item->index() );
DrawPad();

if ( item->selected() )
Expand Down

0 comments on commit 5b967b9

Please sign in to comment.