|
@@ -15,6 +15,7 @@
|
|
|
const int ColIndexBlastStatus = 7;
|
|
|
const int ColIndexProgressBar = 8;
|
|
|
const int ColIndexOpBtn = 9;
|
|
|
+const int ColIndexUuid = 10;
|
|
|
|
|
|
BlastOpePage::BlastOpePage(QWidget *parent)
|
|
|
: QWidget(parent), ui(new Ui::BlastOpePage), dao(DatabaseManager::getInstance().getDatabase()) {
|
|
@@ -412,7 +413,7 @@ void BlastOpePage::loadDataAndDrawTable(int currentPage, int pageSize) {
|
|
|
if (index.isValid()) {
|
|
|
ui->tableView->setIndexWidget(index, widget);
|
|
|
connect(button, &QPushButton::clicked,
|
|
|
- [this, row, button]() { handleSingleBlastButtonClick(row, button); });
|
|
|
+ [this, row, button]() { handleSingleBlastButtonClicked(row, button); });
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -538,11 +539,11 @@ void BlastOpePage::onFiringStageUpdated(int stage, int row) {
|
|
|
}
|
|
|
|
|
|
updateProgressBar(stage, row);
|
|
|
- updateOpBtnStage(stage, row);
|
|
|
+ handleUpdateOpButton(stage, row);
|
|
|
}
|
|
|
|
|
|
-void BlastOpePage::handleSingleBlastButtonClick(int row, QPushButton *button) {
|
|
|
- QStandardItem *uuidItem = model->item(row, ColIndexOpBtn);
|
|
|
+void BlastOpePage::handleSingleBlastButtonClicked(int row, QPushButton *button) {
|
|
|
+ QStandardItem *uuidItem = model->item(row, ColIndexUuid);
|
|
|
QString uuid;
|
|
|
if (uuidItem) {
|
|
|
QVariant uuidVariant = uuidItem->data(Qt::UserRole);
|
|
@@ -552,6 +553,13 @@ void BlastOpePage::handleSingleBlastButtonClick(int row, QPushButton *button) {
|
|
|
}
|
|
|
|
|
|
if (button->text() == startBlastButtonTxt) {
|
|
|
+ button->setDisabled(true);
|
|
|
+ QTimer::singleShot(5000, [button]() {
|
|
|
+ if (button->isEnabled()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ button->setEnabled(true);
|
|
|
+ });
|
|
|
button->setMinimumWidth(80);
|
|
|
button->setText(stopBlastButtonTxt);
|
|
|
firingWidget *widget = new firingWidget(row, false, uuid);
|
|
@@ -565,17 +573,34 @@ void BlastOpePage::handleSingleBlastButtonClick(int row, QPushButton *button) {
|
|
|
|
|
|
widget->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
firingWidgetByUuid.insert(uuid, widget);
|
|
|
+ widget->startBlasting();
|
|
|
|
|
|
} else if (button->text() == stopBlastButtonTxt) {
|
|
|
+ // TODO: wrap into class
|
|
|
+ QMessageBox msgBox;
|
|
|
+ msgBox.setWindowTitle("提示");
|
|
|
+ msgBox.setText("是否取消爆破?");
|
|
|
+ QPushButton *yesButton = msgBox.addButton("是", QMessageBox::YesRole);
|
|
|
+ QPushButton *noButton = msgBox.addButton("否", QMessageBox::NoRole);
|
|
|
+ yesButton->setStyleSheet(
|
|
|
+ "QPushButton { background-color:rgb(5, 58, 156); color: white; padding: 5px 15px; "
|
|
|
+ "border-radius: 4px; }");
|
|
|
+ noButton->setStyleSheet(
|
|
|
+ "QPushButton { background-color: #f44336; color: white; padding: 5px 15px; "
|
|
|
+ "border-radius: 4px; }");
|
|
|
+ msgBox.exec();
|
|
|
+ if (msgBox.clickedButton() == noButton) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
firingWidget *widget = firingWidgetByUuid.value(uuid);
|
|
|
if (widget) {
|
|
|
widget->sendCancelFiringMsg();
|
|
|
}
|
|
|
- button->setText("...");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void BlastOpePage::updateOpBtnStage(int stage, int row) {
|
|
|
+void BlastOpePage::handleUpdateOpButton(int stage, int row) {
|
|
|
QModelIndex index = model->index(row, ColIndexOpBtn);
|
|
|
if (!index.isValid()) {
|
|
|
Logger::getInstance().error(QString("can not get updateOpBtnStage index %1").arg(row));
|
|
@@ -591,24 +616,27 @@ void BlastOpePage::updateOpBtnStage(int stage, int row) {
|
|
|
|
|
|
switch (stage) {
|
|
|
case FiringStages::Starting:
|
|
|
- button->setText(stopBlastButtonTxt);
|
|
|
button->setDisabled(true);
|
|
|
break;
|
|
|
case FiringStages::QuickTesting:
|
|
|
button->setEnabled(true);
|
|
|
+ button->setText(stopBlastButtonTxt);
|
|
|
break;
|
|
|
case FiringStages::QuickTestFinished:
|
|
|
button->setEnabled(true);
|
|
|
+ button->setText(stopBlastButtonTxt);
|
|
|
break;
|
|
|
case FiringStages::NetCharging:
|
|
|
button->setEnabled(true);
|
|
|
+ button->setText(stopBlastButtonTxt);
|
|
|
break;
|
|
|
case FiringStages::NetChargingFinished:
|
|
|
button->setEnabled(true);
|
|
|
+ button->setText(stopBlastButtonTxt);
|
|
|
break;
|
|
|
case FiringStages::PendingTriggerButtonClick:
|
|
|
- button->setText(stopBlastButtonTxt);
|
|
|
button->setEnabled(true);
|
|
|
+ button->setText(stopBlastButtonTxt);
|
|
|
break;
|
|
|
case FiringStages::Blasting:
|
|
|
button->setDisabled(true);
|
|
@@ -691,7 +719,7 @@ void BlastOpePage::on_btnSelect_clicked() {
|
|
|
int row = it.key();
|
|
|
QString uuid = it.value();
|
|
|
firingWidget *widgetSelect = new firingWidget(row, true, uuid);
|
|
|
- QModelIndex index = model->index(row, ColIndexOpBtn);
|
|
|
+ QModelIndex index = model->index(row, ColIndexUuid);
|
|
|
if (index.isValid()) {
|
|
|
QWidget *widgetButton = ui->tableView->indexWidget(index);
|
|
|
if (widgetButton) {
|
|
@@ -708,6 +736,7 @@ void BlastOpePage::on_btnSelect_clicked() {
|
|
|
connect(widgetSelect, &firingWidget::closeFiring, this, &BlastOpePage::destroyBatchFiringWidget);
|
|
|
widgetSelect->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
uuidWidgetSMap.insert(uuid, widgetSelect);
|
|
|
+ widgetSelect->startBlasting();
|
|
|
|
|
|
if (isShowTriggeringWidget) {
|
|
|
widgetSelect->show();
|