summary refs log tree commit diff
path: root/src/timeline
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2021-07-12 00:24:33 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2021-07-12 00:24:33 +0200
commitbd26624ed8d3d1af619fe3d68a107141508ee249 (patch)
treeb9e611e2339e022abcbed41c3187f5bcf66d6391 /src/timeline
parentUse required properties and delegate pooling for room list (diff)
downloadnheko-bd26624ed8d3d1af619fe3d68a107141508ee249.tar.xz
Prepare for reuseItems in timeline
The actual reuseItems is still blocked on a few upstream bugs.
Diffstat (limited to 'src/timeline')
-rw-r--r--src/timeline/TimelineModel.cpp20
-rw-r--r--src/timeline/TimelineModel.h11
2 files changed, 18 insertions, 13 deletions
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index 4cb97e07..ab11f99b 100644
--- a/src/timeline/TimelineModel.cpp
+++ b/src/timeline/TimelineModel.cpp
@@ -427,11 +427,11 @@ TimelineModel::roleNames() const
           {Filename, "filename"},
           {Filesize, "filesize"},
           {MimeType, "mimetype"},
-          {Height, "height"},
-          {Width, "width"},
+          {OriginalHeight, "originalHeight"},
+          {OriginalWidth, "originalWidth"},
           {ProportionalHeight, "proportionalHeight"},
-          {Id, "id"},
-          {State, "state"},
+          {EventId, "eventId"},
+          {State, "status"},
           {IsEdited, "isEdited"},
           {IsEditable, "isEditable"},
           {IsEncrypted, "isEncrypted"},
@@ -556,9 +556,9 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r
                 return QVariant(utils::humanReadableFileSize(filesize(event)));
         case MimeType:
                 return QVariant(QString::fromStdString(mimetype(event)));
-        case Height:
+        case OriginalHeight:
                 return QVariant(qulonglong{media_height(event)});
-        case Width:
+        case OriginalWidth:
                 return QVariant(qulonglong{media_width(event)});
         case ProportionalHeight: {
                 auto w = media_width(event);
@@ -569,7 +569,7 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r
 
                 return QVariant(prop > 0 ? prop : 1.);
         }
-        case Id: {
+        case EventId: {
                 if (auto replaces = relations(event).replaces())
                         return QVariant(QString::fromStdString(replaces.value()));
                 else
@@ -660,11 +660,11 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r
                 m.insert(names[Filename], data(event, static_cast<int>(Filename)));
                 m.insert(names[Filesize], data(event, static_cast<int>(Filesize)));
                 m.insert(names[MimeType], data(event, static_cast<int>(MimeType)));
-                m.insert(names[Height], data(event, static_cast<int>(Height)));
-                m.insert(names[Width], data(event, static_cast<int>(Width)));
+                m.insert(names[OriginalHeight], data(event, static_cast<int>(OriginalHeight)));
+                m.insert(names[OriginalWidth], data(event, static_cast<int>(OriginalWidth)));
                 m.insert(names[ProportionalHeight],
                          data(event, static_cast<int>(ProportionalHeight)));
-                m.insert(names[Id], data(event, static_cast<int>(Id)));
+                m.insert(names[EventId], data(event, static_cast<int>(EventId)));
                 m.insert(names[State], data(event, static_cast<int>(State)));
                 m.insert(names[IsEdited], data(event, static_cast<int>(IsEdited)));
                 m.insert(names[IsEditable], data(event, static_cast<int>(IsEditable)));
diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h
index f093acb4..46153732 100644
--- a/src/timeline/TimelineModel.h
+++ b/src/timeline/TimelineModel.h
@@ -192,10 +192,10 @@ public:
                 Filename,
                 Filesize,
                 MimeType,
-                Height,
-                Width,
+                OriginalHeight,
+                OriginalWidth,
                 ProportionalHeight,
-                Id,
+                EventId,
                 State,
                 IsEdited,
                 IsEditable,
@@ -245,6 +245,11 @@ public:
         Q_INVOKABLE void showEvent(QString eventId);
         Q_INVOKABLE void copyLinkToEvent(QString eventId) const;
         void cacheMedia(QString eventId, std::function<void(const QString filename)> callback);
+        Q_INVOKABLE void sendReset()
+        {
+                beginResetModel();
+                endResetModel();
+        }
 
         std::vector<::Reaction> reactions(const std::string &event_id)
         {