优化一些逻辑,解决bug
This commit is contained in:
parent
46a0a87da9
commit
55c9f8e435
@ -1131,6 +1131,9 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton_set_default">
|
<widget class="QPushButton" name="pushButton_set_default">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>100</width>
|
<width>100</width>
|
||||||
|
@ -38,7 +38,6 @@ void ConfigMgr::Save(QString & file_path) {
|
|||||||
card_type_[i] != kCardKeyphaseSingle &&
|
card_type_[i] != kCardKeyphaseSingle &&
|
||||||
card_type_[i] != kCardRelaySingle &&
|
card_type_[i] != kCardRelaySingle &&
|
||||||
card_type_[i] != kCardRelayTMRPrimary &&
|
card_type_[i] != kCardRelayTMRPrimary &&
|
||||||
card_type_[i] != kCardRelayTMRBackup &&
|
|
||||||
card_type_[i] != kCardRelaySingleNOK) {
|
card_type_[i] != kCardRelaySingleNOK) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -297,12 +296,11 @@ void ConfigMgr::Save(QString & file_path) {
|
|||||||
if(ptr->tmr_relay[ch].logic_expression != ""){
|
if(ptr->tmr_relay[ch].logic_expression != ""){
|
||||||
channel_item.insert("logic_expression", ptr->tmr_relay[ch].logic_expression);
|
channel_item.insert("logic_expression", ptr->tmr_relay[ch].logic_expression);
|
||||||
}
|
}
|
||||||
}else if(card_type_[i] == kCardRelayTMRBackup){
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
if(!channel_item.isEmpty())
|
if(!channel_item.isEmpty() ){
|
||||||
slot_item[QString::number(ch + 1)] = channel_item;
|
slot_item[QString::number(ch + 1)] = channel_item;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
slot_item["version"] = 1;
|
slot_item["version"] = 1;
|
||||||
}
|
}
|
||||||
doc_obj[QString::number(slot)] = slot_item;
|
doc_obj[QString::number(slot)] = slot_item;
|
||||||
@ -356,7 +354,7 @@ void ConfigMgr::Load(QString filename) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
slot = i + 1;
|
slot = i + 1;
|
||||||
if (json_obj[QString::number(slot)].isNull()) {
|
if (json_obj[QString::number(slot)].isNull() && card_type_[i] != kCardRelayTMRBackup) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
temp_obj = json_obj[QString::number(slot)].toObject();
|
temp_obj = json_obj[QString::number(slot)].toObject();
|
||||||
|
67
config_mgr.h
67
config_mgr.h
@ -8,6 +8,8 @@
|
|||||||
#include <QDragEnterEvent>
|
#include <QDragEnterEvent>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
|
#include <QStandardItemModel> //数据模型类
|
||||||
|
#include <QTreeView>
|
||||||
|
|
||||||
class DraggableListWidget : public QListWidget {
|
class DraggableListWidget : public QListWidget {
|
||||||
public:
|
public:
|
||||||
@ -38,6 +40,71 @@ protected:
|
|||||||
drag->exec(Qt::CopyAction);
|
drag->exec(Qt::CopyAction);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
class DropTreeModel : public QStandardItemModel {
|
||||||
|
public:
|
||||||
|
using QStandardItemModel::QStandardItemModel;
|
||||||
|
|
||||||
|
QStringList mimeTypes() const override {
|
||||||
|
// 支持自定义类型和 QListWidget 默认类型
|
||||||
|
return { "application/x-custom", "application/x-qabstractitemmodeldatalist" };
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dropMimeData(const QMimeData *data, Qt::DropAction action,
|
||||||
|
int row, int column, const QModelIndex &parent) override {
|
||||||
|
QStandardItem *parentItem = this->itemFromIndex(parent);
|
||||||
|
if (!parentItem)
|
||||||
|
parentItem = this->invisibleRootItem();
|
||||||
|
|
||||||
|
if (data->hasFormat("application/x-custom")) {
|
||||||
|
QByteArray rawData = data->data("application/x-custom");
|
||||||
|
QString customText = QString::fromUtf8(rawData);
|
||||||
|
|
||||||
|
QStandardItem *newItem = new QStandardItem(customText);
|
||||||
|
newItem->setData(customText, Qt::UserRole); // 假设 data 也就是内容
|
||||||
|
newItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable |
|
||||||
|
Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
|
||||||
|
|
||||||
|
if (row < 0)
|
||||||
|
parentItem->appendRow(newItem);
|
||||||
|
else
|
||||||
|
parentItem->insertRow(row, newItem);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data->hasFormat("application/x-qabstractitemmodeldatalist")) {
|
||||||
|
QByteArray encoded = data->data("application/x-qabstractitemmodeldatalist");
|
||||||
|
QDataStream stream(&encoded, QIODevice::ReadOnly);
|
||||||
|
|
||||||
|
while (!stream.atEnd()) {
|
||||||
|
int r, c;
|
||||||
|
QMap<int, QVariant> roleDataMap;
|
||||||
|
stream >> r >> c >> roleDataMap;
|
||||||
|
|
||||||
|
QString text = roleDataMap.value(Qt::DisplayRole).toString();
|
||||||
|
QVariant userData = roleDataMap.value(Qt::UserRole);
|
||||||
|
|
||||||
|
QStandardItem *newItem = new QStandardItem(text);
|
||||||
|
newItem->setData(userData, Qt::UserRole); // 保留附加数据
|
||||||
|
newItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable |
|
||||||
|
Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
|
||||||
|
|
||||||
|
if (row < 0)
|
||||||
|
parentItem->appendRow(newItem);
|
||||||
|
else
|
||||||
|
parentItem->insertRow(row, newItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::DropActions supportedDropActions() const override {
|
||||||
|
return Qt::CopyAction | Qt::MoveAction;
|
||||||
|
}
|
||||||
|
};
|
||||||
class ConfigMgr {
|
class ConfigMgr {
|
||||||
private:
|
private:
|
||||||
static ConfigMgr *instance;
|
static ConfigMgr *instance;
|
||||||
|
@ -183,8 +183,8 @@ void MainWindow::createMenu(const QString &rootTitle, QPushButton *parent) {
|
|||||||
// 创建第二层子菜单:/KPM834 键相模块
|
// 创建第二层子菜单:/KPM834 键相模块
|
||||||
QAction *keyphasor_1 = keyphasor->addAction("/KPM834 单板卡");
|
QAction *keyphasor_1 = keyphasor->addAction("/KPM834 单板卡");
|
||||||
keyphasor_1->setData(kCardKeyphaseSingle);
|
keyphasor_1->setData(kCardKeyphaseSingle);
|
||||||
QAction *keyphasor_2 = keyphasor->addAction("/KPM834 两板卡");
|
//QAction *keyphasor_2 = keyphasor->addAction("/KPM834 两板卡");
|
||||||
keyphasor_2->setData(kCardKeyphaseDouble);
|
//keyphasor_2->setData(kCardKeyphaseDouble);
|
||||||
// 创建第二层子菜单:/DOM810 继电器模块
|
// 创建第二层子菜单:/DOM810 继电器模块
|
||||||
QAction *relays_1 = relays->addAction("/DOM810 单板卡");
|
QAction *relays_1 = relays->addAction("/DOM810 单板卡");
|
||||||
relays_1->setData(kCardRelaySingle);
|
relays_1->setData(kCardRelaySingle);
|
||||||
|
@ -1071,6 +1071,9 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton_set_default">
|
<widget class="QPushButton" name="pushButton_set_default">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>100</width>
|
<width>100</width>
|
||||||
|
@ -258,7 +258,7 @@ void Seismic_monitor::on_comboBox_chan_type_1_currentTextChanged(const QString &
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Seismic_monitor::on_comboBox_chan_type_2_currentTextChanged(const QString &arg1) {
|
void Seismic_monitor::on_comboBox_chan_type_2_currentTextChanged(const QString &arg1) {
|
||||||
switch (ui->comboBox_chan_type_1->currentIndex()) {
|
switch (ui->comboBox_chan_type_2->currentIndex()) {
|
||||||
case kVibRadial:
|
case kVibRadial:
|
||||||
ui->label_unit_2->setText("mV / mm");
|
ui->label_unit_2->setText("mV / mm");
|
||||||
break;
|
break;
|
||||||
@ -272,7 +272,7 @@ void Seismic_monitor::on_comboBox_chan_type_2_currentTextChanged(const QString &
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Seismic_monitor::on_comboBox_chan_type_3_currentTextChanged(const QString &arg1) {
|
void Seismic_monitor::on_comboBox_chan_type_3_currentTextChanged(const QString &arg1) {
|
||||||
switch (ui->comboBox_chan_type_1->currentIndex()) {
|
switch (ui->comboBox_chan_type_3->currentIndex()) {
|
||||||
case kVibRadial:
|
case kVibRadial:
|
||||||
ui->label_unit_3->setText("mV / mm");
|
ui->label_unit_3->setText("mV / mm");
|
||||||
break;
|
break;
|
||||||
@ -286,7 +286,7 @@ void Seismic_monitor::on_comboBox_chan_type_3_currentTextChanged(const QString &
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Seismic_monitor::on_comboBox_chan_type_4_currentTextChanged(const QString &arg1) {
|
void Seismic_monitor::on_comboBox_chan_type_4_currentTextChanged(const QString &arg1) {
|
||||||
switch (ui->comboBox_chan_type_1->currentIndex()) {
|
switch (ui->comboBox_chan_type_4->currentIndex()) {
|
||||||
case kVibRadial:
|
case kVibRadial:
|
||||||
ui->label_unit_4->setText("mV / mm");
|
ui->label_unit_4->setText("mV / mm");
|
||||||
break;
|
break;
|
||||||
|
@ -82,6 +82,9 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton_set_default">
|
<widget class="QPushButton" name="pushButton_set_default">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>100</width>
|
<width>100</width>
|
||||||
@ -95,6 +98,9 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton">
|
<widget class="QPushButton" name="pushButton">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>100</width>
|
<width>100</width>
|
||||||
@ -108,6 +114,9 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton_load_template">
|
<widget class="QPushButton" name="pushButton_load_template">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>100</width>
|
<width>100</width>
|
||||||
|
101
setpoint.cpp
101
setpoint.cpp
@ -5,6 +5,7 @@
|
|||||||
#include "displacement_ds.h"
|
#include "displacement_ds.h"
|
||||||
#include "acceleration_ds.h"
|
#include "acceleration_ds.h"
|
||||||
#include "velocity_ds.h"
|
#include "velocity_ds.h"
|
||||||
|
#include <QListView>
|
||||||
|
|
||||||
Setpoint::Setpoint(int slot_no_,int cardtype,QWidget *parent) :
|
Setpoint::Setpoint(int slot_no_,int cardtype,QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
@ -14,7 +15,8 @@ Setpoint::Setpoint(int slot_no_,int cardtype,QWidget *parent) :
|
|||||||
slot_no = slot_no_;
|
slot_no = slot_no_;
|
||||||
car_type = static_cast<CardType>(cardtype);
|
car_type = static_cast<CardType>(cardtype);
|
||||||
ui->label_slot->setText(QString::number(slot_no));
|
ui->label_slot->setText(QString::number(slot_no));
|
||||||
|
ui->comboBox_chan->setView(new QListView());
|
||||||
|
ui->comboBox_danger->setView(new QListView());
|
||||||
Init();
|
Init();
|
||||||
connect(ui->comboBox_chan, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBox_chan, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &Setpoint::onComboBoxIndexChanged);
|
this, &Setpoint::onComboBoxIndexChanged);
|
||||||
@ -54,10 +56,9 @@ void Setpoint::Init(){
|
|||||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||||
vib_alert_ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
vib_alert_ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||||
|
|
||||||
|
|
||||||
switch (car_type) {
|
switch (car_type) {
|
||||||
case kCardVibSingle:{
|
case kCardVibSingle:{
|
||||||
slider_1x_ampl->setRange(0,20);
|
|
||||||
slider_2x_ampl->setRange(0,20);
|
|
||||||
update();
|
update();
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
@ -153,152 +154,156 @@ void Setpoint::update()
|
|||||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||||
std::shared_ptr<VibrationData> setpoint_data = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
std::shared_ptr<VibrationData> setpoint_data = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||||
std::vector<std::shared_ptr<VariableBase>> variable_ = setpoint_data->variables_;
|
std::vector<std::shared_ptr<VariableBase>> variable_ = setpoint_data->variables_;
|
||||||
|
if(!variable_[chan]->x1_.checked){
|
||||||
|
ui->checkBox_1x_ampl->setEnabled(false);
|
||||||
|
ui->lineEdit_1x_ampl_lower->setEnabled(false);
|
||||||
|
ui->lineEdit_1x_ampl_upper->setEnabled(false);
|
||||||
|
}
|
||||||
|
if(!variable_[chan]->x2_.checked){
|
||||||
|
ui->checkBox_2x_ampl->setEnabled(false);
|
||||||
|
ui->lineEdit_2x_ampl_upper->setEnabled(false);
|
||||||
|
ui->lineEdit_2x_ampl_lower->setEnabled(false);
|
||||||
|
}
|
||||||
if(setpoint_data->base_config_[chan].channel_type == kVibRadial){
|
if(setpoint_data->base_config_[chan].channel_type == kVibRadial){
|
||||||
for (int var = 0; var < variable_.size(); ++var) {
|
|
||||||
if(variable_[var]->direct_.full_scale_range == 0){
|
if(variable_[chan]->direct_.full_scale_range == 0){
|
||||||
slider_direct->setRange(0,100);
|
slider_direct->setRange(0,100);
|
||||||
slider_danger->setRange(0,100);
|
slider_danger->setRange(0,100);
|
||||||
}else if(variable_[var]->direct_.full_scale_range == 1){
|
}else if(variable_[chan]->direct_.full_scale_range == 1){
|
||||||
slider_direct->setRange(0,150);
|
slider_direct->setRange(0,150);
|
||||||
slider_danger->setRange(0,150);
|
slider_danger->setRange(0,150);
|
||||||
}else if(variable_[var]->direct_.full_scale_range == 2){
|
}else if(variable_[chan]->direct_.full_scale_range == 2){
|
||||||
slider_direct->setRange(0,200);
|
slider_direct->setRange(0,200);
|
||||||
slider_danger->setRange(0,200);
|
slider_danger->setRange(0,200);
|
||||||
}else if(variable_[var]->direct_.full_scale_range == 3){
|
}else if(variable_[chan]->direct_.full_scale_range == 3){
|
||||||
slider_direct->setRange(0,400);
|
slider_direct->setRange(0,400);
|
||||||
slider_danger->setRange(0,400);
|
slider_danger->setRange(0,400);
|
||||||
}else if(variable_[var]->direct_.full_scale_range == 4){
|
}else if(variable_[chan]->direct_.full_scale_range == 4){
|
||||||
slider_direct->setRange(0,500);
|
slider_direct->setRange(0,500);
|
||||||
slider_danger->setRange(0,500);
|
slider_danger->setRange(0,500);
|
||||||
}
|
}
|
||||||
ui->label_direct->setText("um");
|
ui->label_direct->setText("um");
|
||||||
ui->label_danger->setText("um");
|
ui->label_danger->setText("um");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(setpoint_data->base_config_[chan].channel_type == kVibAcc){
|
if(setpoint_data->base_config_[chan].channel_type == kVibAcc){
|
||||||
std::shared_ptr<VariableBase> base_channel_ptr = setpoint_data->GetChannelPtr(chan + 1);
|
std::shared_ptr<VariableBase> base_channel_ptr = setpoint_data->GetChannelPtr(chan + 1);
|
||||||
std::shared_ptr<AccVelVariable> av_ptr = std::dynamic_pointer_cast<AccVelVariable>(base_channel_ptr);
|
std::shared_ptr<AccVelVariable> av_ptr = std::dynamic_pointer_cast<AccVelVariable>(base_channel_ptr);
|
||||||
for (int var = 0; var < variable_.size(); ++ var) {
|
if(variable_[chan]->direct_.full_scale_range == 0){
|
||||||
if(variable_[var]->direct_.full_scale_range == 0){
|
|
||||||
slider_direct->setRange(0,20);
|
slider_direct->setRange(0,20);
|
||||||
slider_danger->setRange(0,20);
|
slider_danger->setRange(0,20);
|
||||||
}else if(variable_[var]->direct_.full_scale_range == 1){
|
}else if(variable_[chan]->direct_.full_scale_range == 1){
|
||||||
slider_direct->setRange(0,50);
|
slider_direct->setRange(0,50);
|
||||||
slider_danger->setRange(0,50);
|
slider_danger->setRange(0,50);
|
||||||
}else if(variable_[var]->direct_.full_scale_range == 2){
|
}else if(variable_[chan]->direct_.full_scale_range == 2){
|
||||||
slider_direct->setRange(0,100);
|
slider_direct->setRange(0,100);
|
||||||
slider_danger->setRange(0,100);
|
slider_danger->setRange(0,100);
|
||||||
}else if(variable_[var]->direct_.full_scale_range == 3){
|
}else if(variable_[chan]->direct_.full_scale_range == 3){
|
||||||
slider_direct->setRange(0,200);
|
slider_direct->setRange(0,200);
|
||||||
slider_danger->setRange(0,200);
|
slider_danger->setRange(0,200);
|
||||||
}else if(variable_[var]->direct_.full_scale_range == 4){
|
}else if(variable_[chan]->direct_.full_scale_range == 4){
|
||||||
slider_direct->setRange(0,250);
|
slider_direct->setRange(0,250);
|
||||||
slider_danger->setRange(0,250);
|
slider_danger->setRange(0,250);
|
||||||
}else if(variable_[var]->direct_.full_scale_range == 5){
|
}else if(variable_[chan]->direct_.full_scale_range == 5){
|
||||||
slider_direct->setRange(0,400);
|
slider_direct->setRange(0,400);
|
||||||
slider_danger->setRange(0,400);
|
slider_danger->setRange(0,400);
|
||||||
}
|
}
|
||||||
ui->label_direct->setText("m/s^2 pk");
|
ui->label_direct->setText("m/s^2 pk");
|
||||||
ui->label_danger->setText("m/s^2 pk");
|
ui->label_danger->setText("m/s^2 pk");
|
||||||
}
|
|
||||||
if(av_ptr->rms_active_){
|
if(av_ptr->rms_active_){
|
||||||
for (int var = 0; var < variable_.size(); ++ var) {
|
if(variable_[chan]->direct_.full_scale_range == 0){
|
||||||
if(variable_[var]->direct_.full_scale_range == 0){
|
|
||||||
slider_direct->setRange(0,20);
|
slider_direct->setRange(0,20);
|
||||||
slider_danger->setRange(0,20);
|
slider_danger->setRange(0,20);
|
||||||
}else if(variable_[var]->direct_.full_scale_range == 1){
|
}else if(variable_[chan]->direct_.full_scale_range == 1){
|
||||||
slider_direct->setRange(0,50);
|
slider_direct->setRange(0,50);
|
||||||
slider_danger->setRange(0,50);
|
slider_danger->setRange(0,50);
|
||||||
}else if(variable_[var]->direct_.full_scale_range == 2){
|
}else if(variable_[chan]->direct_.full_scale_range == 2){
|
||||||
slider_direct->setRange(0,100);
|
slider_direct->setRange(0,100);
|
||||||
slider_danger->setRange(0,100);
|
slider_danger->setRange(0,100);
|
||||||
}else if(variable_[var]->direct_.full_scale_range == 3){
|
}else if(variable_[chan]->direct_.full_scale_range == 3){
|
||||||
slider_direct->setRange(0,200);
|
slider_direct->setRange(0,200);
|
||||||
slider_danger->setRange(0,200);
|
slider_danger->setRange(0,200);
|
||||||
}
|
}
|
||||||
ui->label_direct->setText("m/s^2 rms");
|
ui->label_direct->setText("m/s^2 rms");
|
||||||
ui->label_danger->setText("m/s^2 rms");
|
ui->label_danger->setText("m/s^2 rms");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if(av_ptr->integrate_active_){
|
if(av_ptr->integrate_active_){
|
||||||
for (int var = 0; var < variable_.size(); ++ var) {
|
if(variable_[chan]->direct_.full_scale_range == 0){
|
||||||
if(variable_[var]->direct_.full_scale_range == 0){
|
|
||||||
slider_direct->setRange(0,25);
|
slider_direct->setRange(0,25);
|
||||||
slider_danger->setRange(0,25);
|
slider_danger->setRange(0,25);
|
||||||
}else if(variable_[var]->direct_.full_scale_range == 1){
|
}else if(variable_[chan]->direct_.full_scale_range == 1){
|
||||||
slider_direct->setRange(0,50);
|
slider_direct->setRange(0,50);
|
||||||
slider_danger->setRange(0,50);
|
slider_danger->setRange(0,50);
|
||||||
}else if(variable_[var]->direct_.full_scale_range == 2){
|
}else if(variable_[chan]->direct_.full_scale_range == 2){
|
||||||
slider_direct->setRange(0,100);
|
slider_direct->setRange(0,100);
|
||||||
slider_danger->setRange(0,100);
|
slider_danger->setRange(0,100);
|
||||||
}
|
}
|
||||||
ui->label_direct->setText("mm/s pk");
|
ui->label_direct->setText("mm/s pk");
|
||||||
ui->label_danger->setText("mm/s pk");
|
ui->label_danger->setText("mm/s pk");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if(av_ptr->rms_active_ && av_ptr->integrate_active_){
|
if(av_ptr->rms_active_ && av_ptr->integrate_active_){
|
||||||
for (int var = 0; var < variable_.size(); ++ var) {
|
if(variable_[chan]->direct_.full_scale_range == 0){
|
||||||
if(variable_[var]->direct_.full_scale_range == 0){
|
|
||||||
slider_direct->setRange(0,25);
|
slider_direct->setRange(0,25);
|
||||||
slider_danger->setRange(0,25);
|
slider_danger->setRange(0,25);
|
||||||
}else if(variable_[var]->direct_.full_scale_range == 1){
|
}else if(variable_[chan]->direct_.full_scale_range == 1){
|
||||||
slider_direct->setRange(0,50);
|
slider_direct->setRange(0,50);
|
||||||
slider_danger->setRange(0,50);
|
slider_danger->setRange(0,50);
|
||||||
}
|
}
|
||||||
ui->label_direct->setText("mm/s rms");
|
ui->label_direct->setText("mm/s rms");
|
||||||
ui->label_danger->setText("mm/s rms");
|
ui->label_danger->setText("mm/s rms");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(setpoint_data->base_config_[chan].channel_type == kVibVelocity){
|
if(setpoint_data->base_config_[chan].channel_type == kVibVelocity){
|
||||||
std::shared_ptr<VariableBase> base_channel_ptr = setpoint_data->GetChannelPtr(chan + 1);
|
std::shared_ptr<VariableBase> base_channel_ptr = setpoint_data->GetChannelPtr(chan + 1);
|
||||||
std::shared_ptr<AccVelVariable> av_ptr = std::dynamic_pointer_cast<AccVelVariable>(base_channel_ptr);
|
std::shared_ptr<AccVelVariable> av_ptr = std::dynamic_pointer_cast<AccVelVariable>(base_channel_ptr);
|
||||||
for (int var = 0; var < variable_.size(); ++ var) {
|
|
||||||
if(variable_[var]->direct_.full_scale_range == 0){
|
if(variable_[chan]->direct_.full_scale_range == 0){
|
||||||
slider_direct->setRange(0,10);
|
slider_direct->setRange(0,10);
|
||||||
slider_danger->setRange(0,10);
|
slider_danger->setRange(0,10);
|
||||||
}else if(variable_[var]->direct_.full_scale_range == 1){
|
}else if(variable_[chan]->direct_.full_scale_range == 1){
|
||||||
slider_direct->setRange(0,20);
|
slider_direct->setRange(0,20);
|
||||||
slider_danger->setRange(0,20);
|
slider_danger->setRange(0,20);
|
||||||
}else if(variable_[var]->direct_.full_scale_range == 2){
|
}else if(variable_[chan]->direct_.full_scale_range == 2){
|
||||||
slider_direct->setRange(0,50);
|
slider_direct->setRange(0,50);
|
||||||
slider_danger->setRange(0,50);
|
slider_danger->setRange(0,50);
|
||||||
}
|
}
|
||||||
ui->label_direct->setText("mm/s pk");
|
ui->label_direct->setText("mm/s pk");
|
||||||
ui->label_danger->setText("mm/s pk");
|
ui->label_danger->setText("mm/s pk");
|
||||||
}
|
|
||||||
if(av_ptr->rms_active_){
|
if(av_ptr->rms_active_){
|
||||||
for (int var = 0; var < variable_.size(); ++ var) {
|
if(variable_[chan]->direct_.full_scale_range == 0){
|
||||||
if(variable_[var]->direct_.full_scale_range == 0){
|
|
||||||
slider_direct->setRange(0,10);
|
slider_direct->setRange(0,10);
|
||||||
slider_danger->setRange(0,10);
|
slider_danger->setRange(0,10);
|
||||||
}else if(variable_[var]->direct_.full_scale_range == 1){
|
}else if(variable_[chan]->direct_.full_scale_range == 1){
|
||||||
slider_direct->setRange(0,20);
|
slider_direct->setRange(0,20);
|
||||||
slider_danger->setRange(0,20);
|
slider_danger->setRange(0,20);
|
||||||
}else if(variable_[var]->direct_.full_scale_range == 2){
|
}else if(variable_[chan]->direct_.full_scale_range == 2){
|
||||||
slider_direct->setRange(0,50);
|
slider_direct->setRange(0,50);
|
||||||
slider_danger->setRange(0,50);
|
slider_danger->setRange(0,50);
|
||||||
}
|
}
|
||||||
ui->label_direct->setText("mm/s rms");
|
ui->label_direct->setText("mm/s rms");
|
||||||
ui->label_danger->setText("mm/s rms");
|
ui->label_danger->setText("mm/s rms");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if(av_ptr->integrate_active_){
|
if(av_ptr->integrate_active_){
|
||||||
for (int var = 0; var < variable_.size(); ++ var) {
|
if(variable_[chan]->direct_.full_scale_range == 0){
|
||||||
if(variable_[var]->direct_.full_scale_range == 0){
|
|
||||||
slider_direct->setRange(0,100);
|
slider_direct->setRange(0,100);
|
||||||
slider_danger->setRange(0,100);
|
slider_danger->setRange(0,100);
|
||||||
}else if(variable_[var]->direct_.full_scale_range == 1){
|
}else if(variable_[chan]->direct_.full_scale_range == 1){
|
||||||
slider_direct->setRange(0,200);
|
slider_direct->setRange(0,200);
|
||||||
slider_danger->setRange(0,200);
|
slider_danger->setRange(0,200);
|
||||||
}else if(variable_[var]->direct_.full_scale_range == 2){
|
}else if(variable_[chan]->direct_.full_scale_range == 2){
|
||||||
slider_direct->setRange(0,500);
|
slider_direct->setRange(0,500);
|
||||||
slider_danger->setRange(0,500);
|
slider_danger->setRange(0,500);
|
||||||
}
|
}
|
||||||
ui->label_direct->setText("um pp");
|
ui->label_direct->setText("um pp");
|
||||||
ui->label_danger->setText("um pp");
|
ui->label_danger->setText("um pp");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ui->lineEdit_direct_upper->setText(QString::number(setpoint_data->alert_danger[chan].direct_upper));
|
ui->lineEdit_direct_upper->setText(QString::number(setpoint_data->alert_danger[chan].direct_upper));
|
||||||
ui->checkBox_direct->setChecked(setpoint_data->alert_danger[chan].direct_enable);
|
ui->checkBox_direct->setChecked(setpoint_data->alert_danger[chan].direct_enable);
|
||||||
|
80
setpoint.ui
80
setpoint.ui
@ -28,7 +28,7 @@
|
|||||||
<widget class="QComboBox" name="comboBox_danger">
|
<widget class="QComboBox" name="comboBox_danger">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>20</x>
|
||||||
<y>30</y>
|
<y>30</y>
|
||||||
<width>69</width>
|
<width>69</width>
|
||||||
<height>22</height>
|
<height>22</height>
|
||||||
@ -53,20 +53,35 @@
|
|||||||
<widget class="QLabel" name="label_danger">
|
<widget class="QLabel" name="label_danger">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>20</x>
|
<x>30</x>
|
||||||
<y>72</y>
|
<y>60</y>
|
||||||
<width>36</width>
|
<width>50</width>
|
||||||
<height>16</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>- -</string>
|
<string>- -</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QCheckBox" name="checkBox_danger">
|
<widget class="QCheckBox" name="checkBox_danger">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>20</x>
|
<x>30</x>
|
||||||
<y>415</y>
|
<y>415</y>
|
||||||
<width>47</width>
|
<width>47</width>
|
||||||
<height>16</height>
|
<height>16</height>
|
||||||
@ -82,7 +97,7 @@
|
|||||||
<widget class="QLineEdit" name="lineEdit_danger_upper">
|
<widget class="QLineEdit" name="lineEdit_danger_upper">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>12</x>
|
<x>30</x>
|
||||||
<y>90</y>
|
<y>90</y>
|
||||||
<width>50</width>
|
<width>50</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
@ -104,7 +119,7 @@
|
|||||||
<widget class="QWidget" name="widget_danger" native="true">
|
<widget class="QWidget" name="widget_danger" native="true">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>10</x>
|
||||||
<y>116</y>
|
<y>116</y>
|
||||||
<width>100</width>
|
<width>100</width>
|
||||||
<height>260</height>
|
<height>260</height>
|
||||||
@ -187,6 +202,9 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton_set_default">
|
<widget class="QPushButton" name="pushButton_set_default">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>100</width>
|
<width>100</width>
|
||||||
@ -319,10 +337,22 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>130</x>
|
<x>130</x>
|
||||||
<y>59</y>
|
<y>59</y>
|
||||||
<width>36</width>
|
<width>50</width>
|
||||||
<height>16</height>
|
<height>16</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>- -</string>
|
<string>- -</string>
|
||||||
</property>
|
</property>
|
||||||
@ -393,10 +423,22 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>230</x>
|
<x>230</x>
|
||||||
<y>59</y>
|
<y>59</y>
|
||||||
<width>36</width>
|
<width>50</width>
|
||||||
<height>16</height>
|
<height>16</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>- -</string>
|
<string>- -</string>
|
||||||
</property>
|
</property>
|
||||||
@ -533,12 +575,24 @@
|
|||||||
<widget class="QLabel" name="label_direct">
|
<widget class="QLabel" name="label_direct">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>40</x>
|
<x>25</x>
|
||||||
<y>60</y>
|
<y>60</y>
|
||||||
<width>36</width>
|
<width>50</width>
|
||||||
<height>16</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>- -</string>
|
<string>- -</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -10,15 +10,22 @@ SingleRelay::SingleRelay(int slot,int cardtype,QWidget *parent)
|
|||||||
car_type = static_cast<CardType>(cardtype);
|
car_type = static_cast<CardType>(cardtype);
|
||||||
ui->label_slot_no->setText(QString::number(slot_no));
|
ui->label_slot_no->setText(QString::number(slot_no));
|
||||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
QVBoxLayout *layout_relay = new QVBoxLayout(ui->widget_relay);
|
|
||||||
textEdit_relay = new DropTextEdit;
|
|
||||||
textEdit_relay->setAcceptDrops(true);
|
|
||||||
layout_relay->addWidget(textEdit_relay);
|
|
||||||
QVBoxLayout *layout_available = new QVBoxLayout(ui->widget_available);
|
QVBoxLayout *layout_available = new QVBoxLayout(ui->widget_available);
|
||||||
list_widget_available = new DraggableListWidget();
|
list_widget_available = new QListWidget();
|
||||||
layout_available->addWidget(list_widget_available);
|
layout_available->addWidget(list_widget_available);
|
||||||
list_widget_available->setDragEnabled(true);
|
list_widget_available->setDragEnabled(true);
|
||||||
|
|
||||||
|
QVBoxLayout *layout_relay = new QVBoxLayout(ui->widget_relay);
|
||||||
|
treeView_relay = new QTreeView;
|
||||||
|
layout_relay->addWidget(treeView_relay);
|
||||||
|
treeView_relay->setDragEnabled(true); // 启用拖动
|
||||||
|
treeView_relay->setAcceptDrops(true); // 接受放下
|
||||||
|
treeView_relay->setDropIndicatorShown(true); // 显示放置指示器
|
||||||
|
treeView_relay->setDragDropMode(QAbstractItemView::DropOnly);
|
||||||
|
model_Relay = new DropTreeModel(this); //创建模型指定父类
|
||||||
|
treeView_relay->setModel(model_Relay);
|
||||||
|
treeView_relay->setHeaderHidden(true);
|
||||||
|
|
||||||
btnGroup_slot = new QButtonGroup(this);
|
btnGroup_slot = new QButtonGroup(this);
|
||||||
btnGroup_slot->addButton(ui->pushButton_slot1);
|
btnGroup_slot->addButton(ui->pushButton_slot1);
|
||||||
btnGroup_slot->addButton(ui->pushButton_slot2);
|
btnGroup_slot->addButton(ui->pushButton_slot2);
|
||||||
@ -38,14 +45,15 @@ SingleRelay::SingleRelay(int slot,int cardtype,QWidget *parent)
|
|||||||
btnGroup_slot->addButton(ui->pushButton_slot16);
|
btnGroup_slot->addButton(ui->pushButton_slot16);
|
||||||
|
|
||||||
connect(btnGroup_slot, SIGNAL(buttonClicked(QAbstractButton *)), this, SLOT(OnButtonGroup(QAbstractButton *)));
|
connect(btnGroup_slot, SIGNAL(buttonClicked(QAbstractButton *)), this, SLOT(OnButtonGroup(QAbstractButton *)));
|
||||||
//connect(ui->pushButton_backspace, &QPushButton::clicked, textEdit_relay, &DropTextEdit::removeLastElement);
|
|
||||||
connect(ui->comboBox_relay_ch, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
connect(ui->comboBox_relay_ch, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &SingleRelay::onComboBoxIndexChanged);
|
this, &SingleRelay::onComboBoxIndexChanged);
|
||||||
Init();
|
Init();
|
||||||
current_index = ui->comboBox_relay_ch->currentIndex();
|
current_index = ui->comboBox_relay_ch->currentIndex();
|
||||||
if(single_relay_nok_data->single_relay_nok[current_index].logic_expression != ""){
|
if(single_relay_nok_data->single_relay_nok[current_index].logic_expression != ""){
|
||||||
QString channel_name = channelNameMap[single_relay_nok_data->single_relay_nok[current_index].logic_expression];
|
QString channel_name = channelNameMap[single_relay_nok_data->single_relay_nok[current_index].logic_expression];
|
||||||
textEdit_relay->setPlainText(channel_name);
|
QStandardItem *item = new QStandardItem(channel_name);
|
||||||
|
item->setData(single_relay_nok_data->single_relay_nok[current_index].logic_expression,Qt::UserRole);
|
||||||
|
model_Relay->appendRow(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,6 +129,7 @@ void SingleRelay::OnButtonGroup(QAbstractButton *slot_btn) {
|
|||||||
int button_id = object_name.right(object_name.length() - 15).toInt();
|
int button_id = object_name.right(object_name.length() - 15).toInt();
|
||||||
for(int var = 0; var < CHANNEL_COUNT ; ++var){
|
for(int var = 0; var < CHANNEL_COUNT ; ++var){
|
||||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(button_id);
|
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(button_id);
|
||||||
|
if(base_ptr->card_type_ == kCardVibSingle){
|
||||||
std::shared_ptr<VibrationData> vib_data = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
std::shared_ptr<VibrationData> vib_data = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||||
if((vib_data->base_config_[var].standby && vib_data->base_config_[var + 1].standby && !(var % 2)))
|
if((vib_data->base_config_[var].standby && vib_data->base_config_[var + 1].standby && !(var % 2)))
|
||||||
continue;
|
continue;
|
||||||
@ -129,6 +138,9 @@ void SingleRelay::OnButtonGroup(QAbstractButton *slot_btn) {
|
|||||||
QString item_data = QString("S%1C%2P##NO").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
QString item_data = QString("S%1C%2P##NO").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
||||||
item->setData(Qt::UserRole, item_data);
|
item->setData(Qt::UserRole, item_data);
|
||||||
list_widget_available->addItem(item);
|
list_widget_available->addItem(item);
|
||||||
|
}else if(base_ptr->card_type_ == kCardSpeedSingle){
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -142,7 +154,7 @@ void SingleRelay::on_pushButton_enter_clicked()
|
|||||||
|
|
||||||
void SingleRelay::on_pushButton_clr_clicked()
|
void SingleRelay::on_pushButton_clr_clicked()
|
||||||
{
|
{
|
||||||
textEdit_relay->setText("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -160,26 +172,39 @@ void SingleRelay::keyPressEvent(QKeyEvent *event) {
|
|||||||
|
|
||||||
void SingleRelay::on_pushButton_confirm_clicked()
|
void SingleRelay::on_pushButton_confirm_clicked()
|
||||||
{
|
{
|
||||||
single_relay_nok_data->single_relay_nok[current_index].logic_expression = textEdit_relay->toPlainText();
|
QStandardItemModel *model = qobject_cast<QStandardItemModel *>(treeView_relay->model());
|
||||||
|
if (!model) return;
|
||||||
|
QStandardItem *root = model->invisibleRootItem();
|
||||||
|
QStandardItem *topItem = root->child(0);
|
||||||
|
QString finalExpr;
|
||||||
|
QVariant userData = topItem->data(Qt::UserRole);
|
||||||
|
QString user_text = userData.toString().trimmed();
|
||||||
|
single_relay_nok_data->single_relay_nok[current_index].logic_expression = user_text;
|
||||||
this->close();
|
this->close();
|
||||||
}
|
}
|
||||||
void SingleRelay::onComboBoxIndexChanged(int index){
|
void SingleRelay::onComboBoxIndexChanged(int index){
|
||||||
|
|
||||||
qDebug()<< "[SingleRelay]:index " << index;
|
qDebug()<< "[SingleRelay]:index " << index;
|
||||||
QString html = textEdit_relay->toHtml();
|
QStandardItemModel *model = qobject_cast<QStandardItemModel *>(treeView_relay->model());
|
||||||
qDebug() << html ;
|
if (!model) return;
|
||||||
QRegularExpression spanRegex(R"(<span[^>]*data-key='([^']+)'[^>]*>([^<]+)</span>)");
|
QStandardItem *root = model->invisibleRootItem();
|
||||||
QRegularExpressionMatchIterator i = spanRegex.globalMatch(html);
|
if(root->rowCount() > 0){
|
||||||
QString userData = "",visibleText = "";
|
QStandardItem *topItem = root->child(0);
|
||||||
while (i.hasNext()) {
|
QString finalExpr;
|
||||||
QRegularExpressionMatch match = i.next();
|
QVariant userData = topItem->data(Qt::UserRole);
|
||||||
userData = match.captured(1);
|
QString user_text = userData.toString().trimmed();
|
||||||
visibleText = match.captured(2);
|
single_relay_nok_data->single_relay_nok[current_index].logic_expression = user_text;
|
||||||
}
|
}
|
||||||
qDebug() << "Extracted data-key:" << userData << ", text:" << visibleText;
|
|
||||||
|
|
||||||
single_relay_nok_data->single_relay_nok[current_index].logic_expression = userData;
|
|
||||||
current_index = index;
|
current_index = index;
|
||||||
textEdit_relay->setPlainText(single_relay_nok_data->single_relay_nok[index].logic_expression);
|
|
||||||
|
if(single_relay_nok_data->single_relay_nok[index].logic_expression != ""){
|
||||||
|
model_Relay->clear();
|
||||||
|
QString channel_name = channelNameMap[single_relay_nok_data->single_relay_nok[current_index].logic_expression];
|
||||||
|
QStandardItem *item = new QStandardItem(channel_name);
|
||||||
|
item->setData(single_relay_nok_data->single_relay_nok[current_index].logic_expression,Qt::UserRole);
|
||||||
|
model_Relay->appendRow(item);
|
||||||
|
}else{
|
||||||
|
model_Relay->clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,61 +8,13 @@
|
|||||||
#include "data_config.h"
|
#include "data_config.h"
|
||||||
#include "config_mgr.h"
|
#include "config_mgr.h"
|
||||||
#include "singlerelay_data.h"
|
#include "singlerelay_data.h"
|
||||||
|
#include <QStandardItemModel> //数据模型类
|
||||||
|
#include <QTreeView>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class SingleRelay;
|
class SingleRelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
class DropTextEdit : public QTextEdit {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
DropTextEdit(QWidget *parent = nullptr) : QTextEdit(parent) {
|
|
||||||
setAcceptDrops(true);
|
|
||||||
}
|
|
||||||
public slots:
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void dragEnterEvent(QDragEnterEvent *event) override {
|
|
||||||
if (event->mimeData()->hasFormat("application/x-custom")) {
|
|
||||||
event->acceptProposedAction();
|
|
||||||
} else {
|
|
||||||
event->ignore();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void dragMoveEvent(QDragMoveEvent *event) override {
|
|
||||||
if (event->mimeData()->hasFormat("application/x-custom")) {
|
|
||||||
event->acceptProposedAction();
|
|
||||||
} else {
|
|
||||||
event->ignore();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void dropEvent(QDropEvent *event) override {
|
|
||||||
if (!this->toPlainText().isEmpty()) {
|
|
||||||
event->ignore();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (event->mimeData()->hasFormat("application/x-custom")) {
|
|
||||||
QByteArray data = event->mimeData()->data("application/x-custom");
|
|
||||||
QDataStream stream(&data, QIODevice::ReadOnly);
|
|
||||||
QString visibleText, userData;
|
|
||||||
stream >> visibleText >> userData; // 解析显示文本和 UserRole 数据
|
|
||||||
qDebug() << visibleText << userData;
|
|
||||||
QString text = QString::fromUtf8(data);
|
|
||||||
|
|
||||||
QTextCursor cursor = this->textCursor();
|
|
||||||
this->setTextCursor(cursor);
|
|
||||||
|
|
||||||
QString html = QString("<span data-key='%1' style='color:black;'>%2</span> ")
|
|
||||||
.arg(userData.toHtmlEscaped(), visibleText.toHtmlEscaped());
|
|
||||||
cursor.insertHtml(html);
|
|
||||||
event->acceptProposedAction();
|
|
||||||
} else {
|
|
||||||
event->ignore();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
class SingleRelay : public QDialog {
|
class SingleRelay : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -89,8 +41,9 @@ class SingleRelay : public QDialog {
|
|||||||
private:
|
private:
|
||||||
Ui::SingleRelay *ui;
|
Ui::SingleRelay *ui;
|
||||||
QButtonGroup * btnGroup_slot = nullptr;
|
QButtonGroup * btnGroup_slot = nullptr;
|
||||||
DraggableListWidget *list_widget_available = nullptr;
|
QListWidget *list_widget_available = nullptr;
|
||||||
DropTextEdit *textEdit_relay = nullptr;
|
QTreeView *treeView_relay;
|
||||||
|
QStandardItemModel *model_Relay;
|
||||||
std::shared_ptr<SingleRelayDataNOK> single_relay_nok_data = nullptr;
|
std::shared_ptr<SingleRelayDataNOK> single_relay_nok_data = nullptr;
|
||||||
int current_index;
|
int current_index;
|
||||||
QMap<QString, QString> channelNameMap;
|
QMap<QString, QString> channelNameMap;
|
||||||
|
@ -6,8 +6,7 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include "data_config.h"
|
#include "data_config.h"
|
||||||
#include "config_mgr.h"
|
#include "config_mgr.h"
|
||||||
#include <QStandardItemModel> //数据模型类
|
|
||||||
#include <QTreeView>
|
|
||||||
#include "tmrrelayassociation_data.h"
|
#include "tmrrelayassociation_data.h"
|
||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
|
|
||||||
@ -23,71 +22,7 @@ struct ExprValidationResult {
|
|||||||
int errorPos;
|
int errorPos;
|
||||||
QString errorMsg;
|
QString errorMsg;
|
||||||
};
|
};
|
||||||
class DropTreeModel : public QStandardItemModel {
|
|
||||||
public:
|
|
||||||
using QStandardItemModel::QStandardItemModel;
|
|
||||||
|
|
||||||
QStringList mimeTypes() const override {
|
|
||||||
// 支持自定义类型和 QListWidget 默认类型
|
|
||||||
return { "application/x-custom", "application/x-qabstractitemmodeldatalist" };
|
|
||||||
}
|
|
||||||
|
|
||||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action,
|
|
||||||
int row, int column, const QModelIndex &parent) override {
|
|
||||||
QStandardItem *parentItem = this->itemFromIndex(parent);
|
|
||||||
if (!parentItem)
|
|
||||||
parentItem = this->invisibleRootItem();
|
|
||||||
|
|
||||||
if (data->hasFormat("application/x-custom")) {
|
|
||||||
QByteArray rawData = data->data("application/x-custom");
|
|
||||||
QString customText = QString::fromUtf8(rawData);
|
|
||||||
|
|
||||||
QStandardItem *newItem = new QStandardItem(customText);
|
|
||||||
newItem->setData(customText, Qt::UserRole); // 假设 data 也就是内容
|
|
||||||
newItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable |
|
|
||||||
Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
|
|
||||||
|
|
||||||
if (row < 0)
|
|
||||||
parentItem->appendRow(newItem);
|
|
||||||
else
|
|
||||||
parentItem->insertRow(row, newItem);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data->hasFormat("application/x-qabstractitemmodeldatalist")) {
|
|
||||||
QByteArray encoded = data->data("application/x-qabstractitemmodeldatalist");
|
|
||||||
QDataStream stream(&encoded, QIODevice::ReadOnly);
|
|
||||||
|
|
||||||
while (!stream.atEnd()) {
|
|
||||||
int r, c;
|
|
||||||
QMap<int, QVariant> roleDataMap;
|
|
||||||
stream >> r >> c >> roleDataMap;
|
|
||||||
|
|
||||||
QString text = roleDataMap.value(Qt::DisplayRole).toString();
|
|
||||||
QVariant userData = roleDataMap.value(Qt::UserRole);
|
|
||||||
|
|
||||||
QStandardItem *newItem = new QStandardItem(text);
|
|
||||||
newItem->setData(userData, Qt::UserRole); // 保留附加数据
|
|
||||||
newItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable |
|
|
||||||
Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
|
|
||||||
|
|
||||||
if (row < 0)
|
|
||||||
parentItem->appendRow(newItem);
|
|
||||||
else
|
|
||||||
parentItem->insertRow(row, newItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Qt::DropActions supportedDropActions() const override {
|
|
||||||
return Qt::CopyAction | Qt::MoveAction;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class TMRRelayAssociation : public QDialog
|
class TMRRelayAssociation : public QDialog
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user