diff -r 1e962b12a8db -r d2f833ab7940 contentstorage/caclient/src/caitemmodel.cpp --- a/contentstorage/caclient/src/caitemmodel.cpp Tue Jun 01 11:30:17 2010 +0300 +++ b/contentstorage/caclient/src/caitemmodel.cpp Fri Jun 11 16:13:51 2010 +0300 @@ -17,6 +17,7 @@ #include +#include "caclient_defines.h" #include "caitemmodel.h" #include "caitemmodel_p.h" #include "canotifier.h" @@ -469,6 +470,9 @@ variant = QVariant(entry(modelIndex)->text() + QString(" ") + entry(modelIndex)->description()); break; + case CaItemModel::UninstalRole: + variant = QVariant(entry(modelIndex)->attribute(UNINSTALL_PROGRESS_APPLICATION_ATTRIBUTE_NAME).toInt()); + break; default: variant = QVariant(QVariant::Invalid); } @@ -699,22 +703,27 @@ /*! Updates model item with fresh data - \param id id of item to update + \param entry item to update */ -void CaItemModelPrivate::updateItemData(int id) +void CaItemModelPrivate::updateItemData(const QSharedPointer &entry) { CACLIENTTEST_FUNC_ENTRY("CaItemModelPrivate::updateItemData"); - mEntries.updateEntry(id); + int id = entry->id(); QList ids = mService->getEntryIds(mQuery); if (mEntries.indexOf(id) >= 0 && ids.indexOf(id) == mEntries.indexOf(id)) { - emit m_q->dataChanged(index(mEntries.indexOf(id)), index( - mEntries.indexOf(id))); + mEntries.updateEntry(entry); + emit m_q->dataChanged( + index(mEntries.indexOf(id)), index(mEntries.indexOf(id))); } else if (mParentEntry && id == mParentEntry->id()) { updateParentEntry(); m_q->reset(); + } else if (ids.indexOf(id) < 0) { + removeItem(id); + } else if (mEntries.indexOf(id) < 0) { + addItem(id); } else { updateModel(); } @@ -911,8 +920,8 @@ void CaItemModelPrivate::connectSlots() { CACLIENTTEST_FUNC_ENTRY("CaItemModelPrivate::connectSlots"); - connect(mNotifier, SIGNAL(entryChanged(int,ChangeType)), - this, SLOT(updateModelItem(int,ChangeType))); + connect(mNotifier, SIGNAL(entryChanged(CaEntry ,ChangeType)), + this, SLOT(updateModelItem(CaEntry, ChangeType))); if (mQuery.parentId() > 0) { connect(mNotifier, SIGNAL(groupContentChanged(int)), @@ -927,8 +936,8 @@ void CaItemModelPrivate::disconnectSlots() { CACLIENTTEST_FUNC_ENTRY("CaItemModelPrivate::disconnectSlots"); - disconnect(mNotifier, SIGNAL(entryChanged(int,ChangeType)), - this, SLOT(updateModelItem(int,ChangeType))); + disconnect(mNotifier, SIGNAL(entryChanged(CaEntry ,ChangeType)), + this, SLOT(updateModelItem(CaEntry, ChangeType))); if (mQuery.parentId() > 0) { disconnect(mNotifier, SIGNAL(groupContentChanged(int)), this, SLOT(updateModelContent(int))); @@ -952,20 +961,22 @@ \param id of item to handle \param changeType change type */ -void CaItemModelPrivate::updateModelItem(int id, ChangeType changeType) +void CaItemModelPrivate::updateModelItem( + const CaEntry &entry, ChangeType changeType) { CACLIENTTEST_FUNC_ENTRY("CaItemModelPrivate::updateModelItem"); + QSharedPointer sharedEntry(new CaEntry(entry)); int previousCount = rowCount(); switch (changeType) { - case AddChangeType: - addItem(id); - break; - case RemoveChangeType: - removeItem(id); - break; - default: - updateItemData(id); - break; + case AddChangeType: + addItem(sharedEntry->id()); + break; + case RemoveChangeType: + removeItem(sharedEntry->id()); + break; + default: + updateItemData(sharedEntry); + break; } emitEmpty(previousCount); CACLIENTTEST_FUNC_EXIT("CaItemModelPrivate::updateModelItem");