Changeset 67:578192d6fe64 in SMSSender for src/ui/models/grouptablemodel.cpp


Ignore:
Timestamp:
Feb 7, 2010 4:11:28 PM (12 years ago)
Author:
Sämy Zehnder <saemy.zehnder@…>
Branch:
3.0
Convert:
svn:3639001d-8e34-449c-bb86-3782b86c4877/branches/3.0@66
Message:
  • added synchttp
  • backup before removing these diamond interfaces...
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ui/models/grouptablemodel.cpp

    r61 r67  
    99{
    1010    connect(BCGroupManager::instance(), SIGNAL(groupAdded(IGroup*)),
    11             this, SLOT(groupUpdated(IGroup*)));
     11            this, SLOT(listAltered()));
    1212    connect(BCGroupManager::instance(), SIGNAL(groupUpdated(IGroup*)),
    1313            this, SLOT(groupUpdated(IGroup*)));
    1414    connect(BCGroupManager::instance(), SIGNAL(groupRemoved(IGroup*)),
    15             this, SLOT(groupUpdated(IGroup*)));
     15            this, SLOT(listAltered()));
    1616}
    1717GroupTableModel::~GroupTableModel() {
    1818    disconnect(BCGroupManager::instance(), SIGNAL(groupAdded(IGroup*)),
    19                this, SLOT(groupUpdated(IGroup*)));
     19               this, SLOT(listAltered()));
    2020    disconnect(BCGroupManager::instance(), SIGNAL(groupUpdated(IGroup*)),
    2121               this, SLOT(groupUpdated(IGroup*)));
    2222    disconnect(BCGroupManager::instance(), SIGNAL(groupRemoved(IGroup*)),
    23                this, SLOT(groupUpdated(IGroup*)));
     23               this, SLOT(listAltered()));
     24}
     25
     26void GroupTableModel::listAltered() {
     27    reloadList();
    2428}
    2529
    2630void GroupTableModel::groupUpdated(IGroup* group) {
    27     int row = BCGroupManager::instance()->getGroupList().values().indexOf(group);
     31    int row = items_.indexOf(group);
    2832
    2933    QModelIndex idx_start = index(row, 0);
     
    3539        reset();
    3640    }
     41}
     42
     43void GroupTableModel::reloadList() {
     44    items_.clear();
     45    foreach(IGroup* group, BCGroupManager::instance()->getGroupList()) {
     46        items_.append(group);
     47    }
     48    reset();
    3749}
    3850
     
    5466
    5567IGroup* GroupTableModel::dataObject(const QModelIndex& index) const {
    56     return BCGroupManager::instance()->getGroupList().values().at(index.row());
     68    return items_.at(index.row());
    5769}
    5870
    5971QVariant GroupTableModel::data(const QModelIndex& index, int role) const {
    60     QList<IGroup*> groups = BCGroupManager::instance()->getGroupList().values();
    61     if (!index.isValid() || index.row() < 0 || index.row() >= groups.size())
     72    if (!index.isValid() || index.row() < 0 || index.row() >= items_.size())
    6273        return QVariant();
    6374
    64     const IGroup* group = groups.at(index.row());
     75    const IGroup* group = dataObject(index);
    6576
    6677    if (role == Qt::DisplayRole) {
     
    89100
    90101int GroupTableModel::rowCount(const QModelIndex& parent) const {
    91     return (parent.isValid()) ? 0 : BCGroupManager::instance()->getGroupList().count();
     102    return (parent.isValid()) ? 0 : items_.count();
    92103}
    93104
     
    98109    int lastRow = row + count - 1;
    99110    beginRemoveRows(parent, row, lastRow);
    100     QList<IGroup*> groups = BCGroupManager::instance()->getGroupList().values();
    101111    for (int i = lastRow; i >= row; --i) {
    102         BCGroupManager::instance()->removeGroup(groups.at(i)->id());
     112        BCGroupManager::instance()->removeGroup(items_.at(i)->id());
    103113    }
    104114    endRemoveRows();
Note: See TracChangeset for help on using the changeset viewer.