Commit 5f4e3cf3 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(Linphone/Chat): supports sections

parent abaa1519
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
QHash<int, QByteArray> ChatModel::roleNames () const { QHash<int, QByteArray> ChatModel::roleNames () const {
QHash<int, QByteArray> roles; QHash<int, QByteArray> roles;
roles[Qt::DisplayRole] = "$chatEntry"; roles[Roles::ChatEntry] = "$chatEntry";
roles[Roles::SectionDate] = "$sectionDate";
return roles; return roles;
} }
...@@ -19,8 +20,12 @@ QVariant ChatModel::data (const QModelIndex &index, int role) const { ...@@ -19,8 +20,12 @@ QVariant ChatModel::data (const QModelIndex &index, int role) const {
if (row < 0 || row >= m_entries.count()) if (row < 0 || row >= m_entries.count())
return QVariant(); return QVariant();
if (role == Qt::DisplayRole) switch (role) {
case: Roles::ChatEntry
return QVariant::fromValue(m_entries[row]); return QVariant::fromValue(m_entries[row]);
case: Roles::SectionDate
return QVariant::fromValue(m_entries[row]["sectionDate"]);
}
return QVariant(); return QVariant();
} }
......
...@@ -17,6 +17,11 @@ class ChatModel : public QAbstractListModel { ...@@ -17,6 +17,11 @@ class ChatModel : public QAbstractListModel {
); );
public: public:
enum Roles {
ChatEntry = Qt::DisplayRole,
SectionDate
};
ChatModel (QObject *parent = Q_NULLPTR) : QAbstractListModel(parent) {} ChatModel (QObject *parent = Q_NULLPTR) : QAbstractListModel(parent) {}
int rowCount (const QModelIndex &index = QModelIndex()) const { int rowCount (const QModelIndex &index = QModelIndex()) const {
......
...@@ -26,7 +26,7 @@ ColumnLayout { ...@@ -26,7 +26,7 @@ ColumnLayout {
section { section {
criteria: ViewSection.FullString criteria: ViewSection.FullString
delegate: sectionHeading delegate: sectionHeading
property: '$chatEntry.sectionDate' property: '$sectionDate'
} }
// --------------------------------------------------------------- // ---------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment