|
@@ -342,7 +342,7 @@ void BlastOpePage::loadDataFromSource(int currentPage, int pageSize)
|
|
|
progressBarLayout->addWidget(progressBar3);
|
|
|
progressBarLayout->setAlignment(Qt::AlignCenter);
|
|
|
progressBarLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
-
|
|
|
+ progressBarLayout->setSpacing(0); // 设置进度条之间的间距为0
|
|
|
QWidget *progressBarContainer = new QWidget(ui->tableView);
|
|
|
progressBarContainer->setLayout(progressBarLayout);
|
|
|
QModelIndex progressIndex = model->index(row, progressCol);
|
|
@@ -462,7 +462,7 @@ void BlastOpePage::updateProgressBar(int value, int row)
|
|
|
|
|
|
void BlastOpePage::onUpdateBlastStatus(int status ,int row)
|
|
|
{
|
|
|
- QModelIndex index = model->index(row, 6);
|
|
|
+ QModelIndex index = model->index(row, 9);
|
|
|
if (index.isValid()) {
|
|
|
QColor customColor;
|
|
|
QFont boldFont;
|
|
@@ -637,7 +637,7 @@ void BlastOpePage::on_btnSelect_clicked()
|
|
|
for (auto it = uuidMap.begin(); it != uuidMap.end(); ++it) {
|
|
|
int row = it.key();
|
|
|
QString uuid = it.value();
|
|
|
- firingWidget *widget = new firingWidget(row,true,uuid);
|
|
|
+ firingWidget *widgetSelect = new firingWidget(row,true,uuid);
|
|
|
QModelIndex index = model->index(row, 9);
|
|
|
if (index.isValid()) {
|
|
|
QWidget *widgetButton = ui->tableView->indexWidget(index);
|
|
@@ -648,12 +648,117 @@ void BlastOpePage::on_btnSelect_clicked()
|
|
|
}
|
|
|
|
|
|
// 信号连接
|
|
|
- connect(widget, &firingWidget::progressChanged, this, &BlastOpePage::updateProgressBar);
|
|
|
- connect(widget, &firingWidget::updateBlastStatus, this, &BlastOpePage::onUpdateBlastStatus);
|
|
|
+ connect(widgetSelect, &firingWidget::progressChanged, this, &BlastOpePage::updateProgressBar);
|
|
|
+ connect(widgetSelect, &firingWidget::updateBlastStatus, this, &BlastOpePage::onUpdateBlastStatus);
|
|
|
+ connect(widgetSelect, &firingWidget::selectSignal, this, &BlastOpePage::handleSelect);
|
|
|
+ connect(widgetSelect, &firingWidget::updateButton, this, &BlastOpePage::changeButByMqtt);
|
|
|
+ connect(widgetSelect, &firingWidget::updateProjectStatus, this, &BlastOpePage::updateProject);
|
|
|
+ connect(widgetSelect, &firingWidget::closeFiring, this, &BlastOpePage::destroyFiringWidgetSelect);
|
|
|
widget->show();
|
|
|
widget->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
+ uuidWidgetSMap.insert(uuid, widgetSelect);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+//完成充电
|
|
|
+void BlastOpePage::handleSelect(QString uuid){
|
|
|
+ selectedUuids.insert(uuid);
|
|
|
+ bool isSame = checkUuidsSame();
|
|
|
+ if (isSame) {
|
|
|
+ bool successSelect;
|
|
|
+ serialTool = SerialTool::getInstance(nullptr, &successSelect);
|
|
|
+ connect(serialTool, &SerialTool::buttonPressedReceived,this,&BlastOpePage::showDownWidgetSelect, Qt::SingleShotConnection);
|
|
|
+ if(serialTool){
|
|
|
+ QByteArray data = "\r\nENABLE_BUTTON\r\n";
|
|
|
+ bool success = serialTool->sendData(data);
|
|
|
+ if (success) {
|
|
|
+
|
|
|
+ qDebug() << "Data sent successfully";
|
|
|
+ } else {
|
|
|
+ qDebug() << "Failed to send data";
|
|
|
+ }
|
|
|
+ connect(serialTool, &SerialTool::enableButtonReceived,this, [this]() {
|
|
|
+
|
|
|
+ for (const auto& row : uuidMap.keys()) {
|
|
|
+ qDebug() << "Key:" << row;
|
|
|
+ onUpdateBlastStatus(10,row);
|
|
|
+ }
|
|
|
+ }, Qt::SingleShotConnection);
|
|
|
+
|
|
|
+ }else {
|
|
|
+ qDebug() << "serialTool Not fond.";
|
|
|
+
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ qDebug() << "The uuids in selectedUuids and uuidMap are different.";
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
+// 检查 selectedUuids 和 uuidMap 中的 uuid 是否相同
|
|
|
+bool BlastOpePage::checkUuidsSame() {
|
|
|
+ QSet<QString> mapUuids;
|
|
|
+ for (const auto& value : uuidMap) {
|
|
|
+ qDebug()<<"value"<<value;
|
|
|
+ mapUuids.insert(value);
|
|
|
+ }
|
|
|
+ return selectedUuids == mapUuids;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+void BlastOpePage::showDownWidgetSelect()
|
|
|
+{
|
|
|
+ QByteArray data = "\r\nDISABLE_BUTTON\r\n";
|
|
|
+ bool success = serialTool->sendData(data);
|
|
|
+ if (success) {
|
|
|
+ qDebug() << "Data sent successfully";
|
|
|
+ } else {
|
|
|
+ qDebug() << "Failed to send data";
|
|
|
+ }
|
|
|
+ serialTool->releaseInstance();
|
|
|
+ CountdownWidget *countdownWidgetSelect = new CountdownWidget(this);
|
|
|
+ countdownWidgetSelect->resize(200, 200);
|
|
|
+ int x = (this->width() - countdownWidgetSelect->width()) / 2;
|
|
|
+ int y = (this->height() - countdownWidgetSelect->height()) / 2;
|
|
|
+
|
|
|
+ countdownWidgetSelect->move(x, y);
|
|
|
+ countdownWidgetSelect->show();
|
|
|
+
|
|
|
+ connect(countdownWidgetSelect, &CountdownWidget::countdownFinished, this,&BlastOpePage::selectBlasting,Qt::SingleShotConnection);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void BlastOpePage::selectBlasting(){
|
|
|
+ for (auto it = uuidWidgetSMap.begin(); it != uuidWidgetSMap.end(); ++it) {
|
|
|
+ QString uuid = it.key();
|
|
|
+ firingWidget* widget = it.value();
|
|
|
+ QString topic = "hxgc/"+uuid+"/P";
|
|
|
+ QString message = "起爆";
|
|
|
+ widget->onCountdownFinished(topic,message);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+void BlastOpePage::destroyFiringWidgetSelect(const QString& uuid)
|
|
|
+{
|
|
|
+ firingWidget *widget = uuidWidgetSMap.value(uuid);
|
|
|
+ if (widget) {
|
|
|
+ widget->close();
|
|
|
+ widget->deleteLater();
|
|
|
+ uuidWidgetSMap.remove(uuid);
|
|
|
+ }
|
|
|
+ for (int row = 0; row < model->rowCount(); ++row) {
|
|
|
+ QStandardItem *item = model->item(row, 0);
|
|
|
+ if (item) {
|
|
|
+ Qt::ItemFlags flags = item->flags();
|
|
|
+ flags &= ~Qt::ItemIsEnabled; // 去除 ItemIsEnabled 标志位
|
|
|
+ item->setFlags(flags);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|