29 #include "WItemSelection.h"
30 #include "WItemSelector.h"
31 #include "WStringUtils.h"
34 m_selection( selection ),
35 m_selected( selected ),
36 m_invalidateSignalConnection(),
44 m_selection( other.m_selection ),
45 m_selected( other.m_selected ),
46 m_valid( other.m_valid )
80 n.push_back( selected );
86 std::vector<std::string> tokens;
90 for(
size_t i = 0; i < tokens.size(); ++i )
92 l.push_back( string_utils::fromString< size_t >( tokens[i] ) );
115 for( WItemSelector::IndexList::const_iterator iter =
m_selected.begin(); iter !=
m_selected.end(); ++iter )
126 std::ostream& operator<<( std::ostream& out,
const WItemSelector& other )
128 return other.operator<<( out );
163 return (
size() == 0 );
194 WItemSelector::operator
unsigned int()
const
196 return getItemIndexOfSelected( 0 );
This class represents a subset of a WItemSelection.
virtual bool empty() const
True if the selection is empty.
std::vector< size_t > IndexList
The type used for storing index lists.
void unlock()
Unlocks the selection again.
void invalidate()
Handles the case of invalidation.
std::shared_ptr< WItemSelection > m_selection
The selection handled by this selector.
virtual const std::shared_ptr< WItemSelectionItem > at(size_t index) const
Gets the selected item with the given index.
WItemSelector & operator=(const WItemSelector &other)
Copy assignment.
virtual size_t size() const
The number of selected items.
WItemSelection::ReadTicket m_lock
This locks prevents the selection to be modified during selector iteration.
virtual size_t sizeAll() const
Gives the count of elements in the set of selectable items.
std::ostream & operator<<(std::ostream &out) const
Write a selection in string representation to the given output stream.
bool m_valid
If true the selector is valid.
WItemSelector createSelector(const IndexList &selected) const
Creates a new selector instance using the specified index list.
IndexList getIndexList() const
Casts the selector to a list of indices currently selected.
IndexList m_selected
The list of items currently selected.
WItemSelector(const WItemSelector &other)
Copy constructor.
bool operator==(const WItemSelector &other) const
Compares two selector.
virtual bool isValid() const
Checks whether the selection is valid anymore.
WItemSelector newSelector() const
Creates a new selector, but basing on this instance as old one.
virtual const std::shared_ptr< WItemSelectionItem > atAll(size_t index) const
Gets the item with the given index from the WItemSelection.
void lock()
Read locks the underlying selection.
virtual ~WItemSelector()
Destructor.
virtual size_t getItemIndexOfSelected(size_t index) const
Helps to get the index of an selected item in the WItemSelection.
boost::signals2::connection m_invalidateSignalConnection
Stores the connection made using WItemSelection::subscribeInvalidateSignal.
std::vector< std::string > tokenize(const std::string &source, const std::string &delim=WHITESPACE, bool compress=true)
Splits the given string into a vector of strings (so called tokens).