/* -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*-
 * -*- coding: utf-8 -*-
 *
 * Copyright (C) 2025 KylinSoft Co., Ltd.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef UKUI4DEVICEPORTSELECTITEM_H
#define UKUI4DEVICEPORTSELECTITEM_H

#include <QLabel>
#include <QWidget>
#include <QListWidget>
#include <QPushButton>
#include "IDevicePortSelectItem.h"

class Ukui4DevicePortItem : public QWidget, public IDevicePortItem
{
public:
    Ukui4DevicePortItem(QLabel*, QPushButton*, const QString&, const QString&, QWidget* = nullptr);
    ~Ukui4DevicePortItem() = default;

public:
    void initUi();

    virtual QWidget* getWidget() override;

    virtual bool isChecked() override;

    virtual void setChecked(bool) override;

    virtual void setIcon(const QIcon&) override;

private:
    QLabel* m_pDisplayLabel = nullptr;
    QPushButton* m_pIconBtn = nullptr;
};

class Ukui4DevicePortSelectItem : public QWidget, public IDevicePortSelectItem
{
public:
    Ukui4DevicePortSelectItem(QListWidget*, QWidget* = nullptr);

public:
    QListWidget* getListWidget() const;

    virtual void initSlots() override;

    virtual void setCurrentIndex(int) override;

    virtual void insertItem(std::shared_ptr<IDevicePortItem>) override;

    virtual void removeItem(const QString&, const QString&) override;

    virtual QVariant currentData(int = Qt::UserRole) const override;

    virtual int count() const override;

    virtual QWidget* getWidget() override;

Q_SIGNALS:
    void deviceChangedSignals(const QString&, const QString&);

private Q_SLOTS:
    void currentRowChangedSlots(int);

private:
    void setListWidgetSelectItem(int);

private:
    QListWidget* m_pListWidget = nullptr;
};

#endif // UKUI4DEVICEPORTSELECTITEM_H
