mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-04-29 05:06:22 +00:00
feat(Linphone/Chat): supports sections
This commit is contained in:
parent
abaa151930
commit
5f4e3cf350
3 changed files with 14 additions and 4 deletions
|
|
@ -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'
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue