#ifndef SIDEBARWIDGET_H
#define SIDEBARWIDGET_H

#include <QWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPixmap>
#include <QSvgRenderer>
#include <QPainter>
#include <QLabel>
#include <QString>
#include <QLineEdit>
#include <QDebug>
#include <QListWidgetItem>
#include <QIcon>
#include <QPixmap>
#include <QStackedWidget>
#include <QDir>
#include <QFileInfoList>
#include <QJsonDocument>
#include <QJsonArray>
#include <QJsonObject>
#include <ksearchlineedit.h>
#include <kborderbutton.h>
#include <ktabbar.h>

#include "searchlineedit.h"
#include "historyitemwidget.h"

using namespace kdk;

class SideBarWidget : public QWidget
{
    Q_OBJECT
public:
    enum TabStatePosition
    {
        TABTITLE_DIALOG = 0,
        TABTITLE_PLUGIN = 1
    };

    enum CustomDataRole
    {
        CUSTOM_ROLE_PLUGIN = Qt::UserRole + 1
    };

    explicit SideBarWidget(QWidget *parent = nullptr);
    void initLayout();
    void initSlots();
    void initHistoryWidgetLayout();
    void initPluginsWidgetLayout();
    void initPluginItem();
    void initHistoryDialogItem();
    void initSingleDialogItem(const QString &dialogFile);
    void initTestItem();

public slots:
    void onTabBarChanged(int index);
    void onCreateButtonClicked();
    void onBackButtonClicked();
    void onSaveDialog(QString fileName);
    void onPluginItemClicked(QListWidgetItem *item);

signals:
    void sigCreateButtonClicked();
    void sigPluginItemClicked(const QString targetHtmlFile);

private:
    QVBoxLayout *m_mainLayout = nullptr;
    KBorderlessButton *m_backButton = nullptr;
    QPushButton *m_createButton = nullptr;
    KSearchLineEdit *m_queryLineEdit = nullptr;
    QWidget *m_historyDialog = nullptr;
    QListWidget *m_dialogListwidget = nullptr;
    QWidget *m_plugins = nullptr;
    QListWidget *m_pluginListwidget = nullptr;
    KBorderButton *m_editButton = nullptr;
    KTabBar *m_tabBar = nullptr;
    QStackedWidget *m_stackedWidget = nullptr;

};

#endif // SIDEBARWIDGET_H
