diff options
author | Samuel Fadel <samuelfadel@gmail.com> | 2016-01-21 19:36:14 +0100 |
---|---|---|
committer | Samuel Fadel <samuelfadel@gmail.com> | 2016-01-21 19:36:14 +0100 |
commit | d414b68cea008edc063e26133564d120a7430bd2 (patch) | |
tree | 7ae861a100d0b1560294b646014743dcd785ab4b /selectionhandler.cpp | |
parent | e9d14f93498832687cbdbeb79748f9030e49fb2f (diff) |
Added selection linking. Needs more tests.
Diffstat (limited to 'selectionhandler.cpp')
-rw-r--r-- | selectionhandler.cpp | 32 |
1 files changed, 23 insertions, 9 deletions
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 <QDebug> + +SelectionHandler::SelectionHandler(int numItems) + : m_selection(numItems, false) +{ +} + +void SelectionHandler::setSelection(const std::vector<bool> &selection) { + if (m_selection.size() != selection.size()) { + return; + } + + m_selection = selection; + emit selectionChanged(m_selection); } -void SelectionHandler::setSelection(const QSet<int> &selection) +void SelectionHandler::setSelected(int item, bool selected) { - QSet<int> 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<int> &items, bool selected) +{ + for (auto it = items.cbegin(); it != items.cend(); it++) { + m_selection[*it] = selected; } - emit selectionChanged(newSelection); + emit selectionChanged(m_selection); } |