#pragma once
#include "IAuthorityManager.h"
#include "csqliteauthoritymanager.h"
#include <QWidget>
#include "cpermissioninfo.h"
namespace Ui { class CMWAuthorityPermission; };

class CMWAuthorityPermission : public QWidget, public IAuthoritySupport
{
	Q_OBJECT

public:
	CMWAuthorityPermission(QWidget *parent = Q_NULLPTR);
	~CMWAuthorityPermission();

	void FreshPermission();
	void FreshPermissionState();

	void SetAuthorityManager(IAuthorityManager* instance) override;

	void FreshAuthority() override;

	private slots:
	void on_btnRefresh_clicked();
	void on_btnDel_clicked();
	void on_btnAdd_clicked();
	void on_btnModify_clicked();
	void on_btnLogin_clicked();

	void on_tablePermission_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn);
	void InitAuthority() override;
	void SetControlPermission(QWidget* object, const PermissionInfo& permissionInfo);
private:
	std::map<QWidget*, PermissionInfo> m_mapObjectsPermission;
private:
	Ui::CMWAuthorityPermission *ui;

	CSqliteAuthorityManager* m_AuthorityManager;
	int m_iSelPermissionId = -1;
	int m_iLastUserSelRow = -1;

};
