/*
  SPDX-FileCopyrightText: 2024-2026 Laurent Montel <montel@kde.org>

  SPDX-License-Identifier: GPL-2.0-or-later
*/

#pragma once
#include "config-ruqola.h"
#ifdef HAVE_TEXTADDONSWIDGETS_COMPLETIONLINEEDIT
#include <TextAddonsWidgets/CompletionLineEdit>
#else
#include "common/completionlineedit.h"
#endif
#include "libruqolawidgets_private_export.h"
class JoinedChannelModel;
class QTimer;
class RocketChatAccount;
class LIBRUQOLAWIDGETS_TESTS_EXPORT JoinedChannelCompletionLineEditBase : public
#ifdef HAVE_TEXTADDONSWIDGETS_COMPLETIONLINEEDIT
                                                                          TextAddonsWidgets::
#endif
                                                                              CompletionLineEdit
{
    Q_OBJECT
public:
    struct JoinedChannelCompletionInfo {
        QString name;
        QByteArray channelId;
    };
    explicit JoinedChannelCompletionLineEditBase(RocketChatAccount *account, QWidget *parent = nullptr);
    ~JoinedChannelCompletionLineEditBase() override;

Q_SIGNALS:
    void joinedChannelFound(const JoinedChannelCompletionLineEditBase::JoinedChannelCompletionInfo &channelInfo);

protected:
    void slotSearchTextEdited();

private:
    LIBRUQOLAWIDGETS_NO_EXPORT void slotComplete(const QModelIndex &index);
    LIBRUQOLAWIDGETS_NO_EXPORT void slotSearchTimerFired();
    LIBRUQOLAWIDGETS_NO_EXPORT void slotTextChanged(const QString &text);
    JoinedChannelModel *const mJoinedChannelModel;
    QTimer *const mSearchTimer;
    RocketChatAccount *const mRocketChatAccount;
};
Q_DECLARE_TYPEINFO(JoinedChannelCompletionLineEditBase::JoinedChannelCompletionInfo, Q_RELOCATABLE_TYPE);
