From 06ab4da3f33591317691ced25a14c894bf2c80da Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 27 Sep 2014 20:46:18 +0000 Subject: [PATCH] Add wxSelectionStore::IsEmpty() helper. Just a simple and potentially (although not right now) more efficient equivalent to GetSelectedCount() == 0. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77903 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/selstore.h | 7 +++++++ tests/misc/selstoretest.cpp | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/include/wx/selstore.h b/include/wx/selstore.h index e52ac1cbc0..fec3c212a4 100644 --- a/include/wx/selstore.h +++ b/include/wx/selstore.h @@ -71,6 +71,13 @@ public: // return true if the given item is selected bool IsSelected(unsigned item) const; + // return true if no items are currently selected + bool IsEmpty() const + { + return m_defaultState ? m_itemsSel.size() == m_count + : m_itemsSel.empty(); + } + // return the total number of selected items unsigned GetSelectedCount() const { diff --git a/tests/misc/selstoretest.cpp b/tests/misc/selstoretest.cpp index 3459abd4da..3184383f84 100644 --- a/tests/misc/selstoretest.cpp +++ b/tests/misc/selstoretest.cpp @@ -125,11 +125,16 @@ void SelStoreTestCase::SetItemCount() void SelStoreTestCase::Clear() { + CPPUNIT_ASSERT(m_store->IsEmpty()); CPPUNIT_ASSERT_EQUAL( 0u, m_store->GetSelectedCount() ); m_store->SelectItem(0); + + CPPUNIT_ASSERT(!m_store->IsEmpty()); + m_store->Clear(); + CPPUNIT_ASSERT(m_store->IsEmpty()); CPPUNIT_ASSERT_EQUAL( 0u, m_store->GetSelectedCount() ); }