Ajout des sélection sur le composant FListView

This commit is contained in:
Nicolas H 2021-07-13 08:15:38 +00:00
parent ea7f53be41
commit 79d4f6f7a9
2 changed files with 29 additions and 7 deletions

View File

@ -1428,33 +1428,46 @@ inline void FListView::mapKeyFunctions()
key_map_result[FKey('-')] = [this] { return collapseSubtree(); }; key_map_result[FKey('-')] = [this] { return collapseSubtree(); };
} }
//----------------------------------------------------------------------
std::vector<int> FListView::getmultimark()
{
return multi;
}
//----------------------------------------------------------------------
void FListView::setmultimark(std::vector<int> mark)
{
multi=mark;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::setindex(int index) void FListView::setindex(int index)
{ {
if (index==-666) if (index<0)
current_iter=getNullIterator(); current_iter=getNullIterator();
else else
{ {
current_iter=itemlist.begin(); current_iter=itemlist.begin();
current_iter+=index; current_iter+=index;
scrollToY(index);
} }
draw(); draw();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::setmark(int index) void FListView::setmark(int index)
{ {
if (index==-666) if (index<0)
current_iter=getNullIterator(); current_iter=getNullIterator();
else else
{ {
mark_iter=itemlist.begin(); mark_iter=itemlist.begin();
mark_iter+=index; mark_iter+=index;
scrollToY(index);
} }
draw(); draw();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FListView::getmark()
{
return mark_iter.getPosition();
}
//----------------------------------------------------------------------
int FListView::getindex() int FListView::getindex()
{ {
return current_iter.getPosition(); return current_iter.getPosition();
@ -1641,7 +1654,13 @@ void FListView::drawList()
{ {
const bool is_current_line( iter == current_iter ); const bool is_current_line( iter == current_iter );
const bool is_current_mark( iter == mark_iter ); const bool is_current_mark( iter == mark_iter );
const bool is_current_selected=false; bool is_current_selected=false;
for(int item: multi)
if (item==current_iter.getPosition())
{
is_current_selected=true;
break;
}
const auto& item = static_cast<FListViewItem*>(*iter); const auto& item = static_cast<FListViewItem*>(*iter);
const int tree_offset = tree_view ? int(item->getDepth() << 1) + 1 : 0; const int tree_offset = tree_view ? int(item->getDepth() << 1) + 1 : 0;
const int checkbox_offset = item->isCheckable() ? 1 : 0; const int checkbox_offset = item->isCheckable() ? 1 : 0;
@ -1825,7 +1844,7 @@ inline void FListView::setLineAttributes ( bool is_current
unsetBold(); unsetBold();
} }
if ( is_selected ) if ( is_selected )
setColor ( FColor::White , FColor::Black ); setColor ( FColor::White , FColor::Green );
if ( is_mark ) if ( is_mark )
setColor ( FColor::White, FColor::Red ); setColor ( FColor::White, FColor::Red );
} }

View File

@ -342,7 +342,10 @@ class FListView : public FWidget
// Methods // Methods
int getindex(); int getindex();
void setindex(int); void setindex(int);
int getmark();
void setmark(int); void setmark(int);
std::vector<int> getmultimark();
void setmultimark(std::vector<int> mark);
virtual int addColumn (const FString&, int = USE_MAX_SIZE); virtual int addColumn (const FString&, int = USE_MAX_SIZE);
void hide() override; void hide() override;
iterator insert (FListViewItem*); iterator insert (FListViewItem*);
@ -527,7 +530,7 @@ class FListView : public FWidget
bool tree_view{false}; bool tree_view{false};
bool hide_sort_indicator{false}; bool hide_sort_indicator{false};
bool has_checkable_items{false}; bool has_checkable_items{false};
std::vector<int> multi;
// Function Pointer // Function Pointer
bool (*user_defined_ascending) (const FObject*, const FObject*){nullptr}; bool (*user_defined_ascending) (const FObject*, const FObject*){nullptr};
bool (*user_defined_descending) (const FObject*, const FObject*){nullptr}; bool (*user_defined_descending) (const FObject*, const FObject*){nullptr};