File indexing completed on 2024-05-12 05:03:31

0001 /*
0002    SPDX-FileCopyrightText: 2021-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 #pragma once
0007 
0008 #include "libruqolawidgets_private_export.h"
0009 #include <QWidget>
0010 class QLabel;
0011 class SearchWithDelayLineEdit;
0012 class QTreeView;
0013 class CustomBaseModel;
0014 class QVBoxLayout;
0015 class SearchTreeBaseFilterProxyModel;
0016 class RocketChatAccount;
0017 class LIBRUQOLAWIDGETS_TESTS_EXPORT SearchTreeBaseWidget : public QWidget
0018 {
0019     Q_OBJECT
0020 public:
0021     explicit SearchTreeBaseWidget(RocketChatAccount *account, QWidget *parent = nullptr);
0022     ~SearchTreeBaseWidget() override;
0023 
0024     void initialize();
0025 Q_SIGNALS:
0026     void loadMoreElements();
0027     void doubleClicked(const QModelIndex &index);
0028 
0029 protected:
0030     virtual void slotCustomContextMenuRequested(const QPoint &pos) = 0;
0031     virtual void updateLabel() = 0;
0032     virtual void slotLoadElements(int offset = -1, int count = -1, const QString &searchName = {}) = 0;
0033     void slotLoadMoreElementDone(const QJsonObject &obj);
0034     void slotSearchDone(const QJsonObject &obj);
0035     void connectModel();
0036     void hideColumns();
0037     void finishSearching();
0038     void resizeColumToContents();
0039     QLabel *const mLabelResultSearch;
0040     SearchWithDelayLineEdit *const mSearchLineEdit;
0041     QTreeView *const mTreeView;
0042     CustomBaseModel *mModel = nullptr;
0043     SearchTreeBaseFilterProxyModel *mProxyModelModel = nullptr;
0044     QVBoxLayout *mSearchLayout = nullptr;
0045     RocketChatAccount *const mRocketChatAccount;
0046     [[nodiscard]] QString clickableStr() const;
0047 
0048 private:
0049     LIBRUQOLAWIDGETS_NO_EXPORT void slotSearchCleared();
0050     LIBRUQOLAWIDGETS_NO_EXPORT void slotSearchRequested(const QString &str);
0051     LIBRUQOLAWIDGETS_NO_EXPORT void slotLoadMoreElements();
0052 };