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

feat(Linphone/Chat): supports sections

parent abaa1519
......@@ -9,7 +9,8 @@
QHash<int, QByteArray> ChatModel::roleNames () const {
QHash<int, QByteArray> roles;
roles[Qt::DisplayRole] = "$chatEntry";
roles[Roles::ChatEntry] = "$chatEntry";
roles[Roles::SectionDate] = "$sectionDate";
return roles;
}
......@@ -19,8 +20,12 @@ QVariant ChatModel::data (const QModelIndex &index, int role) const {
if (row < 0 || row >= m_entries.count())
return QVariant();
if (role == Qt::DisplayRole)
return QVariant::fromValue(m_entries[row]);
switch (role) {
case: Roles::ChatEntry
return QVariant::fromValue(m_entries[row]);
case: Roles::SectionDate
return QVariant::fromValue(m_entries[row]["sectionDate"]);
}
return QVariant();
}
......
......@@ -17,6 +17,11 @@ class ChatModel : public QAbstractListModel {
);
public:
enum Roles {
ChatEntry = Qt::DisplayRole,
SectionDate
};
ChatModel (QObject *parent = Q_NULLPTR) : QAbstractListModel(parent) {}
int rowCount (const QModelIndex &index = QModelIndex()) const {
......
......@@ -26,7 +26,7 @@ ColumnLayout {
section {
criteria: ViewSection.FullString
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