Update libqmatrixclient && Fix "full path is posted instead of filename

when uploading files".
This commit is contained in:
Black Hat 2018-08-03 20:58:12 +08:00
parent 3e9a12e4cb
commit 4a9967c5c1
5 changed files with 36 additions and 37 deletions

@ -1 +1 @@
Subproject commit 527a12eb5b6009f679b7e18eceda782f3f5747b7 Subproject commit 7298e99125522c4d010ec83052cd10ce085e09b4

View File

@ -13,6 +13,8 @@ Item {
readonly property bool isMessage: eventType === "message" || eventType === "notice" readonly property bool isMessage: eventType === "message" || eventType === "notice"
readonly property bool isFile: eventType === "video" || eventType === "audio" || eventType === "file" || eventType === "image" readonly property bool isFile: eventType === "video" || eventType === "audio" || eventType === "file" || eventType === "image"
visible: eventType != "redaction"
z: -5 z: -5
width: delegateLoader.width width: delegateLoader.width
height: delegateLoader.height height: delegateLoader.height
@ -23,6 +25,6 @@ Item {
Loader { Loader {
id: delegateLoader id: delegateLoader
source: isMessage ? "MessageBubble.qml" : isState ? "StateBubble.qml" : isFile ? eventType === "image" ? "ImageBubble.qml" : "FileBubble.qml" : "" source: eventType != "redaction" ? isMessage ? "MessageBubble.qml" : isState ? "StateBubble.qml" : isFile ? eventType === "image" ? "ImageBubble.qml" : "FileBubble.qml" : "" : ""
} }
} }

View File

@ -82,7 +82,7 @@ void Controller::postMessage(Room* room, const QString& type,
void Controller::postFile(Room* room, const QUrl& localFile, void Controller::postFile(Room* room, const QUrl& localFile,
const QUrl& mxcUrl) { const QUrl& mxcUrl) {
const QString mime = getMIME(localFile); const QString mime = getMIME(localFile);
const QString fileName = localFile.toLocalFile(); const QString fileName = localFile.fileName();
QString msgType = "m.file"; QString msgType = "m.file";
if (mime.startsWith("image")) msgType = "m.image"; if (mime.startsWith("image")) msgType = "m.image";
if (mime.startsWith("video")) msgType = "m.video"; if (mime.startsWith("video")) msgType = "m.video";

View File

@ -4,17 +4,35 @@
#include <QtCore/QSettings> #include <QtCore/QSettings>
#include <QtQml> // for qmlRegisterType() #include <QtQml> // for qmlRegisterType()
#include "events/redactionevent.h" #include <connection.h>
#include "events/roomavatarevent.h" #include <events/redactionevent.h>
#include "events/roommemberevent.h" #include <events/roomavatarevent.h>
#include "events/simplestateevents.h" #include <events/roommemberevent.h>
#include <events/simplestateevents.h>
#include <settings.h>
#include <user.h>
#include "connection.h" QHash<int, QByteArray> MessageEventModel::roleNames() const {
#include "settings.h" QHash<int, QByteArray> roles = QAbstractItemModel::roleNames();
#include "user.h" roles[EventTypeRole] = "eventType";
roles[EventIdRole] = "eventId";
roles[TimeRole] = "time";
roles[AboveTimeRole] = "aboveTime";
roles[SectionRole] = "section";
roles[AboveSectionRole] = "aboveSection";
roles[AuthorRole] = "author";
roles[AboveAuthorRole] = "aboveAuthor";
roles[ContentRole] = "content";
roles[ContentTypeRole] = "contentType";
roles[ReadMarkerRole] = "readMarker";
roles[SpecialMarksRole] = "marks";
roles[LongOperationRole] = "progressInfo";
roles[EventResolvedTypeRole] = "eventResolvedType";
return roles;
}
MessageEventModel::MessageEventModel(QObject* parent) MessageEventModel::MessageEventModel(QObject* parent)
: QAbstractListModel(parent) { : QAbstractListModel(parent), m_currentRoom(nullptr) {
qmlRegisterType<QMatrixClient::FileTransferInfo>(); qmlRegisterType<QMatrixClient::FileTransferInfo>();
qRegisterMetaType<QMatrixClient::FileTransferInfo>(); qRegisterMetaType<QMatrixClient::FileTransferInfo>();
} }
@ -122,7 +140,7 @@ inline bool hasValidTimestamp(const QMatrixClient::TimelineItem& ti) {
} }
QDateTime MessageEventModel::makeMessageTimestamp( QDateTime MessageEventModel::makeMessageTimestamp(
QMatrixClient::Room::rev_iter_t baseIt) const { const QMatrixClient::Room::rev_iter_t& baseIt) const {
const auto& timeline = m_currentRoom->messageEvents(); const auto& timeline = m_currentRoom->messageEvents();
auto ts = baseIt->event()->timestamp(); auto ts = baseIt->event()->timestamp();
if (ts.isValid()) return ts; if (ts.isValid()) return ts;
@ -143,7 +161,7 @@ QDateTime MessageEventModel::makeMessageTimestamp(
} }
QString MessageEventModel::makeDateString( QString MessageEventModel::makeDateString(
QMatrixClient::Room::rev_iter_t baseIt) const { const QMatrixClient::Room::rev_iter_t& baseIt) const {
auto date = makeMessageTimestamp(baseIt).toLocalTime().date(); auto date = makeMessageTimestamp(baseIt).toLocalTime().date();
if (QMatrixClient::SettingsGroup("UI") if (QMatrixClient::SettingsGroup("UI")
.value("banner_human_friendly_date", true) .value("banner_human_friendly_date", true)
@ -344,8 +362,6 @@ QVariant MessageEventModel::data(const QModelIndex& index, int role) const {
}; };
} }
// HighlightRole is missing. This will be fixed soon.
if (role == ReadMarkerRole) return evt.id() == lastReadEventId; if (role == ReadMarkerRole) return evt.id() == lastReadEventId;
if (role == SpecialMarksRole) { if (role == SpecialMarksRole) {
@ -393,23 +409,3 @@ QVariant MessageEventModel::data(const QModelIndex& index, int role) const {
return QVariant(); return QVariant();
} }
QHash<int, QByteArray> MessageEventModel::roleNames() const {
QHash<int, QByteArray> roles = QAbstractItemModel::roleNames();
roles[EventTypeRole] = "eventType";
roles[EventIdRole] = "eventId";
roles[TimeRole] = "time";
roles[AboveTimeRole] = "aboveTime";
roles[SectionRole] = "section";
roles[AboveSectionRole] = "aboveSection";
roles[AuthorRole] = "author";
roles[AboveAuthorRole] = "aboveAuthor";
roles[ContentRole] = "content";
roles[ContentTypeRole] = "contentType";
roles[HighlightRole] = "highlight";
roles[ReadMarkerRole] = "readMarker";
roles[SpecialMarksRole] = "marks";
roles[LongOperationRole] = "progressInfo";
roles[EventResolvedTypeRole] = "eventResolvedType";
return roles;
}

View File

@ -49,8 +49,9 @@ class MessageEventModel : public QAbstractListModel {
bool mergingEcho = 0; bool mergingEcho = 0;
int nextNewerRow = -1; int nextNewerRow = -1;
QDateTime makeMessageTimestamp(QMatrixClient::Room::rev_iter_t baseIt) const; QDateTime makeMessageTimestamp(
QString makeDateString(QMatrixClient::Room::rev_iter_t baseIt) const; const QMatrixClient::Room::rev_iter_t& baseIt) const;
QString makeDateString(const QMatrixClient::Room::rev_iter_t& baseIt) const;
void refreshEventRoles(const int row, const QVector<int>& roles); void refreshEventRoles(const int row, const QVector<int>& roles);
void refreshEventRoles(const QString& eventId, const QVector<int>& roles); void refreshEventRoles(const QString& eventId, const QVector<int>& roles);