mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-10-30 09:30:47 +03:00
Use multidata in timeline model
This commit is contained in:
parent
e09188c4d0
commit
24f370d6c0
3 changed files with 25 additions and 3 deletions
|
@ -852,8 +852,8 @@ UserSettings::setOpenVideoExternal(bool state)
|
|||
void
|
||||
UserSettings::applyTheme()
|
||||
{
|
||||
QGuiApplication::setPalette(Theme::paletteFromTheme(this->theme()));
|
||||
QApplication::setPalette(Theme::paletteFromTheme(this->theme()));
|
||||
QGuiApplication::setPalette(Theme::paletteFromTheme(this->theme()));
|
||||
QApplication::setPalette(Theme::paletteFromTheme(this->theme()));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -875,7 +875,6 @@ QVariant
|
|||
TimelineModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
using namespace mtx::accessors;
|
||||
namespace acc = mtx::accessors;
|
||||
if (index.row() < 0 && index.row() >= rowCount())
|
||||
return {};
|
||||
|
||||
|
@ -891,6 +890,28 @@ TimelineModel::data(const QModelIndex &index, int role) const
|
|||
return data(*event, role);
|
||||
}
|
||||
|
||||
void
|
||||
TimelineModel::multiData(const QModelIndex &index, QModelRoleDataSpan roleDataSpan) const
|
||||
{
|
||||
if (index.row() < 0 && index.row() >= rowCount())
|
||||
return;
|
||||
|
||||
// HACK(Nico): fetchMore likes to break with dynamically sized delegates and reuseItems
|
||||
if (index.row() + 1 == rowCount() && !m_paginationInProgress)
|
||||
const_cast<TimelineModel *>(this)->fetchMore(index);
|
||||
|
||||
auto event = events.get(rowCount() - index.row() - 1);
|
||||
|
||||
if (!event)
|
||||
return;
|
||||
|
||||
for (QModelRoleData &roleData : roleDataSpan) {
|
||||
int role = roleData.role();
|
||||
|
||||
roleData.setData(data(*event, role));
|
||||
}
|
||||
}
|
||||
|
||||
QVariant
|
||||
TimelineModel::dataById(const QString &id, int role, const QString &relatedTo)
|
||||
{
|
||||
|
|
|
@ -277,6 +277,7 @@ public:
|
|||
QHash<int, QByteArray> roleNames() const override;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
void multiData(const QModelIndex &index, QModelRoleDataSpan roleDataSpan) const override;
|
||||
QVariant data(const mtx::events::collections::TimelineEvents &event, int role) const;
|
||||
Q_INVOKABLE QVariant dataById(const QString &id, int role, const QString &relatedTo);
|
||||
Q_INVOKABLE QVariant dataByIndex(int i, int role = Qt::DisplayRole) const
|
||||
|
|
Loading…
Reference in a new issue