diff --git a/CMakeLists.txt b/CMakeLists.txt index f77d997822f7b54492ff68eb3728c5b7fd808b26..b802d37cf5f4b9e95cb7360ce39e65b39b7462c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -354,7 +354,7 @@ set(SRC_FILES src/Olm.cpp src/RegisterPage.cpp src/SSOHandler.cpp - src/ImagePackModel.cpp + src/CombinedImagePackModel.cpp src/TrayIcon.cpp src/UserSettingsPage.cpp src/UsersModel.cpp @@ -558,7 +558,7 @@ qt5_wrap_cpp(MOC_HEADERS src/MxcImageProvider.h src/RegisterPage.h src/SSOHandler.h - src/ImagePackModel.h + src/CombinedImagePackModel.h src/TrayIcon.h src/UserSettingsPage.h src/UsersModel.h diff --git a/src/ImagePackModel.cpp b/src/CombinedImagePackModel.cpp similarity index 84% rename from src/ImagePackModel.cpp rename to src/CombinedImagePackModel.cpp index 9b0dca8d9f2bdb492a4f2f1fbd9f2be638ae4b07..c5b5b8863911b9ff45221a938b49e03286ed416c 100644 --- a/src/ImagePackModel.cpp +++ b/src/CombinedImagePackModel.cpp @@ -2,12 +2,14 @@ // // SPDX-License-Identifier: GPL-3.0-or-later -#include "ImagePackModel.h" +#include "CombinedImagePackModel.h" #include "Cache_p.h" #include "CompletionModelRoles.h" -ImagePackModel::ImagePackModel(const std::string &roomId, bool stickers, QObject *parent) +CombinedImagePackModel::CombinedImagePackModel(const std::string &roomId, + bool stickers, + QObject *parent) : QAbstractListModel(parent) , room_id(roomId) { @@ -27,13 +29,13 @@ ImagePackModel::ImagePackModel(const std::string &roomId, bool stickers, QObject } int -ImagePackModel::rowCount(const QModelIndex &) const +CombinedImagePackModel::rowCount(const QModelIndex &) const { return (int)images.size(); } QHash<int, QByteArray> -ImagePackModel::roleNames() const +CombinedImagePackModel::roleNames() const { return { {CompletionModel::CompletionRole, "completionRole"}, @@ -48,7 +50,7 @@ ImagePackModel::roleNames() const } QVariant -ImagePackModel::data(const QModelIndex &index, int role) const +CombinedImagePackModel::data(const QModelIndex &index, int role) const { if (hasIndex(index.row(), index.column(), index.parent())) { switch (role) { diff --git a/src/ImagePackModel.h b/src/CombinedImagePackModel.h similarity index 87% rename from src/ImagePackModel.h rename to src/CombinedImagePackModel.h index 937014eccf23e9bcaf8db31308c03cd99bc8bbd8..f0f697999b8617a5fff08d8597f515406ee6324d 100644 --- a/src/ImagePackModel.h +++ b/src/CombinedImagePackModel.h @@ -8,7 +8,7 @@ #include <mtx/events/mscs/image_packs.hpp> -class ImagePackModel : public QAbstractListModel +class CombinedImagePackModel : public QAbstractListModel { Q_OBJECT public: @@ -21,7 +21,7 @@ public: OriginalRow, }; - ImagePackModel(const std::string &roomId, bool stickers, QObject *parent = nullptr); + CombinedImagePackModel(const std::string &roomId, bool stickers, QObject *parent = nullptr); QHash<int, QByteArray> roleNames() const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override; QVariant data(const QModelIndex &index, int role) const override; diff --git a/src/timeline/InputBar.cpp b/src/timeline/InputBar.cpp index 56d0d1ceb3da0a43cbe3df7eadfd391c525224e0..f17081e57e8092797bb9a27634d4480ab966b27c 100644 --- a/src/timeline/InputBar.cpp +++ b/src/timeline/InputBar.cpp @@ -19,9 +19,9 @@ #include "Cache.h" #include "ChatPage.h" +#include "CombinedImagePackModel.h" #include "CompletionProxyModel.h" #include "Config.h" -#include "ImagePackModel.h" #include "Logging.h" #include "MainWindow.h" #include "MatrixClient.h" @@ -503,7 +503,7 @@ InputBar::video(const QString &filename, } void -InputBar::sticker(ImagePackModel *model, int row) +InputBar::sticker(CombinedImagePackModel *model, int row) { if (!model || row < 0) return; diff --git a/src/timeline/InputBar.h b/src/timeline/InputBar.h index acedceb75209b9364cc8780ee725e3eef4736077..2e6fb5c06bfe4fb0b65e86bf63f72c047cf99822 100644 --- a/src/timeline/InputBar.h +++ b/src/timeline/InputBar.h @@ -12,7 +12,7 @@ #include <mtx/responses/messages.hpp> class TimelineModel; -class ImagePackModel; +class CombinedImagePackModel; class QMimeData; class QDropEvent; class QStringList; @@ -58,7 +58,7 @@ public slots: MarkdownOverride useMarkdown = MarkdownOverride::NOT_SPECIFIED, bool rainbowify = false); void reaction(const QString &reactedEvent, const QString &reactionKey); - void sticker(ImagePackModel *model, int row); + void sticker(CombinedImagePackModel *model, int row); private slots: void startTyping(); diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp index b16437986da80b5d77eab6c6ff8ce0b7fed15bbf..2da7d7893db7fb533e7f93163978e94256f7172e 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp @@ -15,11 +15,11 @@ #include "ChatPage.h" #include "Clipboard.h" #include "ColorImageProvider.h" +#include "CombinedImagePackModel.h" #include "CompletionProxyModel.h" #include "DelegateChooser.h" #include "DeviceVerificationFlow.h" #include "EventAccessors.h" -#include "ImagePackModel.h" #include "InviteesModel.h" #include "Logging.h" #include "MainWindow.h" @@ -146,7 +146,7 @@ TimelineViewManager::TimelineViewManager(CallManager *callManager, ChatPage *par qRegisterMetaType<mtx::events::msg::KeyVerificationReady>(); qRegisterMetaType<mtx::events::msg::KeyVerificationRequest>(); qRegisterMetaType<mtx::events::msg::KeyVerificationStart>(); - qRegisterMetaType<ImagePackModel *>(); + qRegisterMetaType<CombinedImagePackModel *>(); qmlRegisterUncreatableMetaObject(qml_mtx_events::staticMetaObject, "im.nheko", @@ -622,7 +622,7 @@ TimelineViewManager::completerFor(QString completerName, QString roomId) roomModel->setParent(proxy); return proxy; } else if (completerName == "stickers") { - auto stickerModel = new ImagePackModel(roomId.toStdString(), true); + auto stickerModel = new CombinedImagePackModel(roomId.toStdString(), true); auto proxy = new CompletionProxyModel(stickerModel, 1, static_cast<size_t>(-1) / 4); stickerModel->setParent(proxy); return proxy;