Add a tab bar to the room drawer which includes a new media tab in addition to the room information tab. This mr completes the architecture for adding others easily later e.g. message highlights or threads. To put this together I had to make sure things like the menus and the maximize delegate were available to both the room drawer and page so there is some rework there to put it all together. Wide\  Mobile\ 
66 lines
1.9 KiB
C++
66 lines
1.9 KiB
C++
// SPDX-FileCopyrightText: 2023 James Graham <james.h.graham@protonmail.com>
|
|
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
|
|
|
#pragma once
|
|
|
|
#include <QSortFilterProxyModel>
|
|
#include <qobjectdefs.h>
|
|
|
|
#include "models/messagefiltermodel.h"
|
|
|
|
class MessageFilterModel;
|
|
|
|
/**
|
|
* @class MediaMessageFilterModel
|
|
*
|
|
* This model filters a MessageEventModel for image and video messages.
|
|
*
|
|
* @sa MessageEventModel
|
|
*/
|
|
class MediaMessageFilterModel : public QSortFilterProxyModel
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
enum MediaType {
|
|
Image = 0,
|
|
Video,
|
|
};
|
|
Q_ENUM(MediaType)
|
|
|
|
/**
|
|
* @brief Defines the model roles.
|
|
*/
|
|
enum Roles {
|
|
SourceRole = MessageFilterModel::LastRole + 1, /**< The mxc source URL for the item. */
|
|
TempSourceRole, /**< Source for the temporary content (either blurhash or mxc URL). */
|
|
TypeRole, /**< The type of the media (image or video). */
|
|
CaptionRole, /**< The caption for the item. */
|
|
SourceWidthRole, /**< The width of the source item. */
|
|
SourceHeightRole, /**< The height of the source item. */
|
|
};
|
|
Q_ENUM(Roles)
|
|
|
|
explicit MediaMessageFilterModel(QObject *parent = nullptr, MessageFilterModel *sourceMediaModel = nullptr);
|
|
|
|
/**
|
|
* @brief Custom filter to show only image and video messages.
|
|
*/
|
|
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
|
|
|
/**
|
|
* @brief Get the given role value at the given index.
|
|
*
|
|
* @sa QSortFilterProxyModel::data
|
|
*/
|
|
[[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
|
|
|
/**
|
|
* @brief Returns a mapping from Role enum values to role names.
|
|
*
|
|
* @sa Roles, QAbstractProxyModel::roleNames()
|
|
*/
|
|
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
|
|
|
|
Q_INVOKABLE int getRowForSourceItem(int sourceRow) const;
|
|
};
|