#ifndef LICENSEMANAGER_MAINWIDGET_H
#define LICENSEMANAGER_MAINWIDGET_H

// Qt
#include <QMainWindow>
#include <QItemSelection>
class QAction;
class QLabel;
class QMenu;
class QStatusBar;
class QTableView;

// Self
#include "LicenseModel/LicenseModel.h"
class EditClientDialog;

class MainWidget : public QMainWindow
{
    Q_OBJECT
public:
    explicit MainWidget(QWidget *parent = nullptr);
    ~MainWidget() override;

protected:
    void closeEvent(QCloseEvent *event) override;

private slots:
    void onCustomContextMenuRequested(const QPoint &pos);
    void onGetInfoTriggered();
    void onReloadTableTriggered();
    void onAddClientTriggered();
    void onEditClientTriggered();
    void onDeleteClientTriggered();
    void onEditClientDialogClosed(int result);
    void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
    void modelStatusChanged();
private:
    void saveSettings();
    void loadSettings();

private:
    QTableView* m_tableView{nullptr};
    LicenseModel* m_licenseModel{nullptr};
    QToolBar* m_toolBar{nullptr};
    QMenu* m_menu{nullptr};
    QAction* m_addClientToolBarAction{nullptr};
    QAction* m_infoToolBarAction{nullptr};
    QAction* m_reloadTableMenuAction{nullptr};
    QAction* m_addClientsMenuAction{nullptr};
    QAction* m_deleteClientsMenuAction{nullptr};
    QAction* m_editClientsMenuAction{nullptr};
    EditClientDialog* m_editClientDialog{nullptr};
    QStatusBar* m_statusBar{nullptr};
    QLabel* m_statusLabel{nullptr};
};

#endif // LICENSEMANAGER_MAINWIDGET_H
