| 1 | // For license of this file, see <project-root-folder>/LICENSE.md. |
| 2 | |
| 3 | #include "core/messagesmodelcache.h" |
| 4 | |
| 5 | #include "core/messagesmodel.h" |
| 6 | |
| 7 | MessagesModelCache::MessagesModelCache(QObject* parent) : QObject(parent) {} |
| 8 | |
| 9 | void MessagesModelCache::setData(const QModelIndex& index, const QVariant& value) { |
| 10 | if (!m_msgCache.contains(index.row())) { |
| 11 | m_msgCache[index.row()] = static_cast<const MessagesModel*>(index.model())->record(index.row()); |
| 12 | } |
| 13 | |
| 14 | m_msgCache[index.row()].setValue(index.column(), value); |
| 15 | } |
| 16 | |
| 17 | QVariant MessagesModelCache::data(const QModelIndex& idx) { |
| 18 | return m_msgCache[idx.row()].value(idx.column()); |
| 19 | } |