diff --git a/CustomModels/channelmodel.cpp b/CustomModels/channelmodel.cpp index 00debb844d19438f842c0ee570830aee06fa36ab..749fd931ab3350eb7d7809c5fa5d2d9d1cb6d1a8 100644 --- a/CustomModels/channelmodel.cpp +++ b/CustomModels/channelmodel.cpp @@ -196,9 +196,24 @@ void ChannelModel::onDataChanged( const QString &id, const QString &property ) } } -void ChannelModel::onDeleted( bool ) +void ChannelModel::onDeleted( const QString &pId, bool deleted ) { - //TODO: implement + if ( channelList.contains( pId ) ) { + int idx = -1; + + for ( int i = 0; i < channelList.length(); i++ ) { + if ( channelList.at( i ).getRoomId() == pId ) { + idx = i; + break; + } + } + + if ( idx != -1 ) { + beginRemoveRows( QModelIndex(), idx, idx ); + channelList.remove( idx ); + endRemoveRows(); + } + } } void ChannelModel::addChannelSlot( const QSharedPointer<RocketChatChannel> &channel ) diff --git a/CustomModels/channelmodel.h b/CustomModels/channelmodel.h index 3f17751b75c3c899923a620b3e8cb7d15e9f9857..03dd2a7da62c9031b92ca50e6a064de9e8ead48a 100644 --- a/CustomModels/channelmodel.h +++ b/CustomModels/channelmodel.h @@ -66,7 +66,7 @@ class ChannelModel : public QAbstractListModel void onNewerMessage( const QString &id, qint64 timestamp ); void onUnreadMessageChanged( const QString &id, int number ); void onDataChanged( const QString &id, const QString &property ); - void onDeleted( bool ); + void onDeleted( const QString &pId, bool deleted ); QTimer timer; signals: void countChanged( void ); diff --git a/repos/entities/rocketchatchannel.cpp b/repos/entities/rocketchatchannel.cpp index d45cc61042ffcd01f679fb2d86463f9fbe68b533..289310fb1f0ff61be5e4bdce07dfef498df4dbdc 100755 --- a/repos/entities/rocketchatchannel.cpp +++ b/repos/entities/rocketchatchannel.cpp @@ -253,7 +253,7 @@ bool RocketChatChannel::getDeleted() const void RocketChatChannel::setDeleted( bool deleted ) { mDeleted = deleted; - emit channelDeleted( deleted ); + emit channelDeleted( this->getRoomId(), deleted ); } bool RocketChatChannel::getBlocked() const { diff --git a/repos/entities/rocketchatchannel.h b/repos/entities/rocketchatchannel.h index b516791e1f1f7af8093e43c7085eb732dc75f87b..51df694c8d4a5ccaaca7e3e3a27d8caf2ad78fc0 100755 --- a/repos/entities/rocketchatchannel.h +++ b/repos/entities/rocketchatchannel.h @@ -128,7 +128,7 @@ class RocketChatChannel : public QObject void messageListReceived( QString pChannelId, QList<ChatMessage> pMessages ); void messageAdded( QString id, qint64 timestamp ); void unreadMessagesChanged( QString id, int number ); - void channelDeleted( bool ); + void channelDeleted( const QString &pId, bool deleted ); void dataChanged( QString id, QString property ); };