diff --git a/src/media/textrecording.cpp b/src/media/textrecording.cpp index c3467b81ae3eba545401491f065972a41fb0e3fa..dee46bf0a5c058ff6687e1e07d9290a998df9e8b 100644 --- a/src/media/textrecording.cpp +++ b/src/media/textrecording.cpp @@ -181,6 +181,24 @@ QAbstractItemModel* Media::TextRecording::instantMessagingModel() const return d_ptr->m_pImModel; } +///Set all messages as read and then save the recording +void Media::TextRecording::setAllRead() +{ + bool changed = false; + for(int row = 0; row < d_ptr->m_lNodes.size(); ++row) { + if (!d_ptr->m_lNodes[row]->m_pMessage->isRead) { + d_ptr->m_lNodes[row]->m_pMessage->isRead = true; + if (d_ptr->m_pImModel) { + auto idx = d_ptr->m_pImModel->index(row, 0); + emit d_ptr->m_pImModel->dataChanged(idx,idx); + } + changed = true; + } + } + if (changed) + save(); +} + /** * I (Emmanuel Lepage) is in the process of writing a better one for this that * can be upstreamed into Qt (there is interest in merging a generic QVariant diff --git a/src/media/textrecording.h b/src/media/textrecording.h index 7de7965ed00418c1aa011b1dedfa90d9ad97743a..b038f8644cebfe99b668269dfbcc8b73fd22a179 100644 --- a/src/media/textrecording.h +++ b/src/media/textrecording.h @@ -73,6 +73,9 @@ public: bool hasMimeType ( const QString& mimeType ) const; QStringList mimeTypes ( ) const; + //Helper + void setAllRead(); + Q_SIGNALS: void messageInserted(const QMap<QString,QString>& message, ContactMethod* cm, Media::Media::Direction direction);