
#pragma once
#include "qt/MyQUI.h"
#include <QResizeEvent>

#include "common/Fields.h"

class DialogPop : public QDialog
{
public:
	DialogPop(QWidget* parent, const Fields& rowdata, string oper);

	virtual void initBody() {};

	void addParamLine(string key, string title, bool readlonly = false);
	void addParamCombox(string key, string title, const vector<pair<string, string>>& mapping);

	virtual void onAccept() {};

public:
	string oper;
	Fields originData;
	Fields curData;

	std::vector<pair<shared_ptr<QLabel>, shared_ptr<QWidget>>> vecWidgetParams;
	QPushButton btnOk;
	QPushButton btnCancel;

	std::map<string, vector<pair<string, string>>> mapMapping;

private:
	void addParam(string key, string title, shared_ptr<QWidget> widget);

	void slotLineTextChanged(const QString&);
	void slotComboxIndexChanged(int index);
	void slotBtnAccept();
	void slotBtnReject();

	void resizeEvent(QResizeEvent*) override;
};