From baea344b3c9459e8c1556ad32e2c288b31a4349f Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Fri, 19 May 2017 22:47:13 +0200 Subject: [PATCH] FListBox: Import of data from a container via "lazy conversion" during item print --- ChangeLog | 2 +- src/flistbox.h | 35 +++++++++++++++++++++++++++++++++++ test/listbox.cpp | 11 +++++++---- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index cb51d116..4fff985e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,6 @@ 2017-05-19 Markus Gans * FListBox: Import of data from a container via - "lazy conversion" during item print. + "lazy conversion" during item print 2017-04-23 Markus Gans * Import of data from a standard container in FListBox diff --git a/src/flistbox.h b/src/flistbox.h index 75282a71..6f15e0a9 100644 --- a/src/flistbox.h +++ b/src/flistbox.h @@ -115,6 +115,8 @@ class FListBox : public FWidget explicit FListBox (FWidget* = 0); template FListBox (Iterator, Iterator, InsertConverter, FWidget* = 0); + template + FListBox (Container, LazyConverter, FWidget* = 0); // Destructor ~FListBox(); @@ -303,6 +305,39 @@ inline FListBox::FListBox ( Iterator first } } +//---------------------------------------------------------------------- +template +inline FListBox::FListBox ( Container container + , LazyConverter convert + , FWidget* parent ) + : FWidget(parent) + , convertToItem(0) + , data() + , source_container(0) + , conv_type(FListBox::no_convert) + , vbar(0) + , hbar(0) + , text() + , inc_search() + , multi_select(false) + , mouse_select(false) + , drag_scroll(FListBox::noScroll) + , scroll_timer(false) + , scroll_repeat(100) + , scroll_distance(1) + , current(0) + , last_current(-1) + , secect_from_item(-1) + , xoffset(0) + , yoffset(0) + , last_yoffset(-1) + , nf_offset(0) + , max_line_width(0) +{ + init(); + insert (container, convert); +} + //---------------------------------------------------------------------- inline const char* FListBox::getClassName() const { return "FListBox"; } diff --git a/test/listbox.cpp b/test/listbox.cpp index 920d46a8..0611781f 100644 --- a/test/listbox.cpp +++ b/test/listbox.cpp @@ -88,24 +88,27 @@ Listbox::Listbox (FWidget* parent) list1->insert (L"----- " + FString().setNumber(i) + L" -----"); // listbox 2 + double_list = new std::list; + + for (double i=1; i<=15; i++) + double_list->push_back(2*i + (i/100)); + FListBox* list2 = new FListBox (this); list2->setGeometry(21, 1, 10, 10); list2->setText ("double"); - double_list = new std::list; - for (double i=1; i<=15; i++) double_list->push_back(2*i + (i/100)); // // Import via lazy conversion on print // - //list2->insert (double_list, doubleToItem); + list2->insert (double_list, doubleToItem); // // Direct import of the complete list // - list2->insert (double_list->begin(), double_list->end(), doubleToString); + //list2->insert (double_list->begin(), double_list->end(), doubleToString); // listbox 3 std::map TLD;