72 lines
1.4 KiB
C++
72 lines
1.4 KiB
C++
#ifndef COUNTEREDITOR_H
|
|
#define COUNTEREDITOR_H
|
|
|
|
#include <QWidget>
|
|
|
|
namespace Ui {
|
|
class CounterEditor;
|
|
}
|
|
|
|
/**
|
|
* @brief 用于 CounterEditor 的视图模型
|
|
*
|
|
* 包含了计数器ID、计数器位数以及各个计数器当前的配置
|
|
*
|
|
*/
|
|
struct CounterEditorVM {
|
|
|
|
int counterType = 7;
|
|
int digitalNum = 2;
|
|
|
|
struct CounterSlot {
|
|
int startValue = 1;
|
|
int endValue = 9999;
|
|
int repeatValue = 1;
|
|
int stepValue = 1;
|
|
int currValue = 1;
|
|
bool editCurrValue = false; // 对应 checkBoxResetCnt2CurrValue:勾选才允许重置/编辑当前值
|
|
bool eleEyeIncEn = false; // 对应 eleCNT2IncEn:电眼触发使计数器+1
|
|
};
|
|
|
|
CounterSlot counter1, counter2;
|
|
};
|
|
|
|
using CounterSettings = CounterEditorVM::CounterSlot;
|
|
|
|
class CounterEditor : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit CounterEditor(QWidget *parent = nullptr);
|
|
~CounterEditor();
|
|
|
|
/**
|
|
* @brief 设置 UI 所用的视图模型
|
|
*
|
|
* @param vm
|
|
*/
|
|
void setViewModel(CounterEditorVM vm);
|
|
|
|
/**
|
|
* @brief 获取 UI 当前的视图模型
|
|
*
|
|
* @return CounterEditorVM
|
|
*/
|
|
CounterEditorVM viewModel();
|
|
|
|
private slots:
|
|
void onEditCurrValueToggled();
|
|
void onCounterTypeChanged(int i);
|
|
void onDigitalNumChanged(int i);
|
|
|
|
private:
|
|
void fetchCounterConfigFromView();
|
|
|
|
Ui::CounterEditor *ui;
|
|
|
|
CounterEditorVM m_vm;
|
|
};
|
|
|
|
#endif // COUNTEREDITOR_H
|