Changeset 67:578192d6fe64 in SMSSender for src/ui/models/contactgroupmodel.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/contactgroupmodel.cpp

    r55 r67  
    99{
    1010    connect(BCContactManager::instance(), SIGNAL(contactAdded(IContact*)),
    11             this, SLOT(dataUpdated(IContact*)));
     11            this, SLOT(listAltered()));
    1212    connect(BCContactManager::instance(), SIGNAL(contactUpdated(IContact*)),
    1313            this, SLOT(dataUpdated(IContact*)));
    1414    connect(BCContactManager::instance(), SIGNAL(contactRemoved(IContact*)),
    15             this, SLOT(dataUpdated(IContact*)));
     15            this, SLOT(listAltered()));
    1616
    1717    connect(BCGroupManager::instance(), SIGNAL(groupAdded(IGroup*)),
    18             this, SLOT(dataUpdated(IGroup*)));
     18            this, SLOT(listAltered()));
    1919    connect(BCGroupManager::instance(), SIGNAL(groupUpdated(IGroup*)),
    2020            this, SLOT(dataUpdated(IGroup*)));
    2121    connect(BCGroupManager::instance(), SIGNAL(groupRemoved(IGroup*)),
    22             this, SLOT(dataUpdated(IGroup*)));
     22            this, SLOT(listAltered()));
    2323
    2424    reloadList();
     
    2626ContactGroupListModel::~ContactGroupListModel() {
    2727    disconnect(BCContactManager::instance(), SIGNAL(contactAdded(IContact*)),
    28                this, SLOT(dataUpdated(IContact*)));
     28               this, SLOT(listAltered()));
    2929    disconnect(BCContactManager::instance(), SIGNAL(contactUpdated(IContact*)),
    3030               this, SLOT(dataUpdated(IContact*)));
    3131    disconnect(BCContactManager::instance(), SIGNAL(contactRemoved(IContact*)),
    32                this, SLOT(dataUpdated(IContact*)));
     32               this, SLOT(listAltered()));
    3333
    3434    disconnect(BCGroupManager::instance(), SIGNAL(groupAdded(IGroup*)),
    35                this, SLOT(dataUpdated(IGroup*)));
     35               this, SLOT(listAltered()));
    3636    disconnect(BCGroupManager::instance(), SIGNAL(groupUpdated(IGroup*)),
    3737               this, SLOT(dataUpdated(IGroup*)));
    3838    disconnect(BCGroupManager::instance(), SIGNAL(groupRemoved(IGroup*)),
    39                this, SLOT(dataUpdated(IGroup*)));
     39               this, SLOT(listAltered()));
     40}
     41
     42void ContactGroupListModel::listAltered() {
     43    reloadList();
    4044}
    4145
     
    4852void ContactGroupListModel::dataUpdated(IInterface* contactOrGroup) {
    4953    int row = items_.indexOf(contactOrGroup);
     54
    5055    QModelIndex idx1 = index(row, 0);
    51 
    52     row = items_.indexOf(contactOrGroup);
    53 
    54     reloadList();
    55 
    56     if (row < 0) { // New contact/group added
    57         reset();
    58     } else {
    59         row = items_.indexOf(contactOrGroup);
    60 
    61         if (row < 0) { // Contact/group removed
    62             reset();
    63         } else {
    64             QModelIndex idx2 = index(row, 0);
    65 
    66             emit dataChanged(idx1, idx1);
    67             if (idx1 != idx2) {
    68                 emit dataChanged(idx2, idx2);
    69             }
    70         }
     56    QModelIndex idx2 = index(row, columnCount());
     57
     58    if (idx1.isValid() && idx2.isValid()) { // Contact/group in list
     59        emit dataChanged(idx1, idx2);
    7160    }
    7261}
     
    8069        items_.append(group);
    8170    }
     71
     72    reset();
    8273}
    8374
Note: See TracChangeset for help on using the changeset viewer.