aboutsummaryrefslogtreecommitdiff
path: root/selectionhandler.cpp
blob: 8a33158e006af5dbebd013893b1e47f541987190 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "selectionhandler.h"

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::setSelected(int item, bool selected)
{
    m_selection[item] = selected;
    emit selectionChanged(m_selection);
}

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(m_selection);
}