From d414b68cea008edc063e26133564d120a7430bd2 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Thu, 21 Jan 2016 19:36:14 +0100 Subject: Added selection linking. Needs more tests. --- selectionhandler.cpp | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'selectionhandler.cpp') diff --git a/selectionhandler.cpp b/selectionhandler.cpp index 44eef28..190040d 100644 --- a/selectionhandler.cpp +++ b/selectionhandler.cpp @@ -1,19 +1,33 @@ #include "selectionhandler.h" -SelectionHandler::SelectionHandler(const arma::uvec &sampleIndices) - : m_sampleIndices(sampleIndices) +#include + +SelectionHandler::SelectionHandler(int numItems) + : m_selection(numItems, false) +{ +} + +void SelectionHandler::setSelection(const std::vector &selection) { + if (m_selection.size() != selection.size()) { + return; + } + + m_selection = selection; + emit selectionChanged(m_selection); } -void SelectionHandler::setSelection(const QSet &selection) +void SelectionHandler::setSelected(int item, bool selected) { - QSet newSelection; + m_selection[item] = selected; + emit selectionChanged(m_selection); +} - // The selecion happens over the sample indices. We use the original dataset - // indices in sampleIndices to translate indices. - for (auto it = selection.begin(); it != selection.end(); it++) { - newSelection.insert(m_sampleIndices[*it]); +void SelectionHandler::setSelected(const std::set &items, bool selected) +{ + for (auto it = items.cbegin(); it != items.cend(); it++) { + m_selection[*it] = selected; } - emit selectionChanged(newSelection); + emit selectionChanged(m_selection); } -- cgit v1.2.3