diff --git a/ChangeLog b/ChangeLog index e1f2767b..7d0d9eae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2019-04-27 Markus Gans + * Add the reserve() method to FListBox to increase the capacity of the list + 2019-03-24 Markus Gans * Add a "scroll view" chapter to the first steps document diff --git a/examples/ui.cpp b/examples/ui.cpp index 8178c539..44c5572d 100644 --- a/examples/ui.cpp +++ b/examples/ui.cpp @@ -568,6 +568,7 @@ void MyDialog::initWidgets() myList.setText ("Items"); myList.setStatusbarMessage ("99 items in a list"); myList.setMultiSelection(); + myList.reserve(100); for (int z = 1; z < 100; z++) myList.insert (finalcut::FString() << z << L" placeholder"); diff --git a/src/include/final/flistbox.h b/src/include/final/flistbox.h index b3a6dbd9..bd3c57ff 100644 --- a/src/include/final/flistbox.h +++ b/src/include/final/flistbox.h @@ -221,6 +221,7 @@ class FListBox : public FWidget , bool = false , FDataPtr = nullptr ); void remove (std::size_t); + void reserve (std::size_t); void clear(); // Event handlers @@ -471,6 +472,10 @@ inline bool FListBox::hasBrackets(std::size_t index) inline bool FListBox::hasBrackets(listBoxItems::iterator iter) const { return bool(iter->brackets > 0); } +//---------------------------------------------------------------------- +inline void FListBox::reserve (std::size_t new_cap) +{ itemlist.reserve(new_cap); } + //---------------------------------------------------------------------- template inline void FListBox::insert ( Iterator first