File indexing completed on 2024-06-16 04:43:38

0001 /*
0002    SPDX-FileCopyrightText: 2022-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 #pragma once
0007 
0008 #include "delegateutils/textselection.h"
0009 #include "delegateutils/textselectionimpl.h"
0010 #include "delegateutils/textuibase.h"
0011 #include "libruqolawidgets_private_export.h"
0012 
0013 class QListView;
0014 class RocketChatAccount;
0015 
0016 class LIBRUQOLAWIDGETS_TESTS_EXPORT MessageDelegateHelperBase : public QObject, public DocumentFactoryInterface, public TextUiBase
0017 {
0018 public:
0019     struct DocumentDescriptionInfo {
0020         QString documentId;
0021         QString description;
0022         int width = -1;
0023     };
0024     explicit MessageDelegateHelperBase(RocketChatAccount *account, QListView *view, TextSelectionImpl *textSelectionImpl);
0025     virtual ~MessageDelegateHelperBase();
0026 
0027     virtual void setRocketChatAccount(RocketChatAccount *newRocketChatAccount);
0028 
0029     void removeMessageCache(const QString &messageId) override;
0030 
0031     void clearTextDocumentCache();
0032 
0033     void setSearchText(const QString &newSearchText);
0034     [[nodiscard]] QString searchText() const;
0035 
0036 protected:
0037     [[nodiscard]] QTextDocument *documentDescriptionForIndex(const MessageDelegateHelperBase::DocumentDescriptionInfo &info) const;
0038     [[nodiscard]] QSize documentDescriptionForIndexSize(const MessageDelegateHelperBase::DocumentDescriptionInfo &info) const;
0039     void updateView(const QModelIndex &index);
0040     RocketChatAccount *mRocketChatAccount = nullptr;
0041     QString mSearchText;
0042 };
0043 Q_DECLARE_TYPEINFO(MessageDelegateHelperBase::DocumentDescriptionInfo, Q_RELOCATABLE_TYPE);