diff options
Diffstat (limited to 'src/selection.cc')
-rw-r--r-- | src/selection.cc | 93 |
1 files changed, 52 insertions, 41 deletions
diff --git a/src/selection.cc b/src/selection.cc index c0300a4..0b93fa2 100644 --- a/src/selection.cc +++ b/src/selection.cc @@ -27,80 +27,91 @@ #include "selection.h" Selections::Selections() - : QObject(NULL) + : QObject(NULL) { - nextid = 0; - act = SEL_NONE; + nextid = 0; + act = SEL_NONE; } sel_id_t Selections::add(Selection selection) { - sel_id_t id = nextid++; - sels[id] = selection; - added(id); - return id; + sel_id_t id = nextid++; + sels[id] = selection; + added(id); + return id; } Selection Selections::get(sel_id_t id) { - if(sels.find(id) == sels.end()) { - Selection s(0,0,0,0); - return s; - } - return sels[id]; + if(sels.find(id) == sels.end()) + { + Selection s(0,0,0,0); + return s; + } + return sels[id]; } QVector<sel_id_t> Selections::ids() { - QVector<sel_id_t> v; + QVector<sel_id_t> v; - QMap<sel_id_t, Selection>::iterator i = sels.begin(); - while(i != sels.end()) { - v.push_back(i.key()); - i++; - } + QMap<sel_id_t, Selection>::iterator i = sels.begin(); + while(i != sels.end()) + { + v.push_back(i.key()); + i++; + } - return v; + return v; } void Selections::update(sel_id_t id, Selection selection) { - if(sels.find(id) != sels.end()) { - sels[id] = selection; - emit updated(id); - } + if(sels.find(id) != sels.end()) + { + sels[id] = selection; + emit updated(id); + } } void Selections::remove(sel_id_t id) { - if(sels.find(id) != sels.end()) { - sels.erase(sels.find(id)); - if(id == act) setActive(SEL_NONE); - emit removed(id); - } + if(sels.find(id) != sels.end()) + { + sels.erase(sels.find(id)); + if(id == act) + { + setActive(SEL_NONE); + } + emit removed(id); + } } void Selections::clear() { - QVector<sel_id_t> _ids = ids(); - QVector<sel_id_t>::iterator i = _ids.begin(); - while(i != _ids.end()) { - remove(*i); - i++; - } + QVector<sel_id_t> _ids = ids(); + QVector<sel_id_t>::iterator i = _ids.begin(); + while(i != _ids.end()) + { + remove(*i); + i++; + } } void Selections::setActive(sel_id_t id) { - if(sels.find(id) != sels.end()) { - act = id; - } else { - act = SEL_NONE; - } - emit activeChanged(act); + if(sels.find(id) != sels.end()) + { + act = id; + } + else + { + act = SEL_NONE; + } + emit activeChanged(act); } sel_id_t Selections::active() { - return act; + return act; } |