aboutsummaryrefslogtreecommitdiff
path: root/selectionhandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'selectionhandler.cpp')
-rw-r--r--selectionhandler.cpp32
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);
}