#ifndef APPMANAGERMAINWIDGET_H
#define APPMANAGERMAINWIDGET_H

#include <QWidget>
#include <kwidget.h>
#include <knavigationbar.h>
#include <QStackedWidget>

#include "AppManagerItemWidget.h"
#include "DBusClient.h"

class AppManagerMainWidget : public kdk::KWidget
{
    Q_OBJECT
public:
    AppManagerMainWidget(QWidget* = nullptr);
    ~AppManagerMainWidget() = default;

public:
    void addItem(int, int, bool, const QString&, const QString&, const QList<ClientDeviceInfo>&, const QList<ClientDeviceInfo>&);

    void removeItem(int);

    void setValue(int, int);

    void setMute(int, bool);

    void setCurrentItem(int);

    void setCurrentIndex(int, const NodeType&, int);

    void addPortToAppItem(int, const NodeType&, const QString&, const QVariant&);

    void removeProtFromAppItem(int, const NodeType&, int);

    std::unordered_map<uint32_t, AppManagerItemWidget*> getAppItems() const;

    AppManagerItemWidget* getAppWidgetByIndex(int);

Q_SIGNALS:
    void valueChangedSignals(int, int);

    void muteChangedSignals(int);

    void currentIndexChangedSignals(int, const QString&, const QString&);

    void closeWindowSignals();

private:
    void initUi();

    void initSlots();

private:
    kdk::KNavigationBar* m_pNavigationBar {};
    QStackedWidget* m_pStackedWidget {};
    std::map<uint32_t, QStandardItem*> m_itemMap {};
    std::unordered_map<uint32_t, AppManagerItemWidget*> m_appWidgetMap;
};

#endif // APPMANAGERMAINWIDGET_H
