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
This commit is contained in:
Vadim Zeitlin
2014-09-27 20:46:18 +00:00
parent d058c09e9f
commit 06ab4da3f3
2 changed files with 12 additions and 0 deletions

View File

@@ -71,6 +71,13 @@ public:
// return true if the given item is selected // return true if the given item is selected
bool IsSelected(unsigned item) const; 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 // return the total number of selected items
unsigned GetSelectedCount() const unsigned GetSelectedCount() const
{ {

View File

@@ -125,11 +125,16 @@ void SelStoreTestCase::SetItemCount()
void SelStoreTestCase::Clear() void SelStoreTestCase::Clear()
{ {
CPPUNIT_ASSERT(m_store->IsEmpty());
CPPUNIT_ASSERT_EQUAL( 0u, m_store->GetSelectedCount() ); CPPUNIT_ASSERT_EQUAL( 0u, m_store->GetSelectedCount() );
m_store->SelectItem(0); m_store->SelectItem(0);
CPPUNIT_ASSERT(!m_store->IsEmpty());
m_store->Clear(); m_store->Clear();
CPPUNIT_ASSERT(m_store->IsEmpty());
CPPUNIT_ASSERT_EQUAL( 0u, m_store->GetSelectedCount() ); CPPUNIT_ASSERT_EQUAL( 0u, m_store->GetSelectedCount() );
} }