Changeset 67:578192d6fe64 in SMSSender for src/ui/models/grouptablemodel.cpp
- Timestamp:
- Feb 7, 2010 4:11:28 PM (12 years ago)
- Branch:
- 3.0
- Convert:
- svn:3639001d-8e34-449c-bb86-3782b86c4877/branches/3.0@66
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ui/models/grouptablemodel.cpp
r61 r67 9 9 { 10 10 connect(BCGroupManager::instance(), SIGNAL(groupAdded(IGroup*)), 11 this, SLOT( groupUpdated(IGroup*)));11 this, SLOT(listAltered())); 12 12 connect(BCGroupManager::instance(), SIGNAL(groupUpdated(IGroup*)), 13 13 this, SLOT(groupUpdated(IGroup*))); 14 14 connect(BCGroupManager::instance(), SIGNAL(groupRemoved(IGroup*)), 15 this, SLOT( groupUpdated(IGroup*)));15 this, SLOT(listAltered())); 16 16 } 17 17 GroupTableModel::~GroupTableModel() { 18 18 disconnect(BCGroupManager::instance(), SIGNAL(groupAdded(IGroup*)), 19 this, SLOT( groupUpdated(IGroup*)));19 this, SLOT(listAltered())); 20 20 disconnect(BCGroupManager::instance(), SIGNAL(groupUpdated(IGroup*)), 21 21 this, SLOT(groupUpdated(IGroup*))); 22 22 disconnect(BCGroupManager::instance(), SIGNAL(groupRemoved(IGroup*)), 23 this, SLOT(groupUpdated(IGroup*))); 23 this, SLOT(listAltered())); 24 } 25 26 void GroupTableModel::listAltered() { 27 reloadList(); 24 28 } 25 29 26 30 void GroupTableModel::groupUpdated(IGroup* group) { 27 int row = BCGroupManager::instance()->getGroupList().values().indexOf(group);31 int row = items_.indexOf(group); 28 32 29 33 QModelIndex idx_start = index(row, 0); … … 35 39 reset(); 36 40 } 41 } 42 43 void GroupTableModel::reloadList() { 44 items_.clear(); 45 foreach(IGroup* group, BCGroupManager::instance()->getGroupList()) { 46 items_.append(group); 47 } 48 reset(); 37 49 } 38 50 … … 54 66 55 67 IGroup* GroupTableModel::dataObject(const QModelIndex& index) const { 56 return BCGroupManager::instance()->getGroupList().values().at(index.row());68 return items_.at(index.row()); 57 69 } 58 70 59 71 QVariant 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()) 62 73 return QVariant(); 63 74 64 const IGroup* group = groups.at(index.row());75 const IGroup* group = dataObject(index); 65 76 66 77 if (role == Qt::DisplayRole) { … … 89 100 90 101 int GroupTableModel::rowCount(const QModelIndex& parent) const { 91 return (parent.isValid()) ? 0 : BCGroupManager::instance()->getGroupList().count();102 return (parent.isValid()) ? 0 : items_.count(); 92 103 } 93 104 … … 98 109 int lastRow = row + count - 1; 99 110 beginRemoveRows(parent, row, lastRow); 100 QList<IGroup*> groups = BCGroupManager::instance()->getGroupList().values();101 111 for (int i = lastRow; i >= row; --i) { 102 BCGroupManager::instance()->removeGroup( groups.at(i)->id());112 BCGroupManager::instance()->removeGroup(items_.at(i)->id()); 103 113 } 104 114 endRemoveRows();
Note: See TracChangeset
for help on using the changeset viewer.