| 656 | } |
| 657 | |
| 658 | void RemoteManager::on_deleteHost_clicked() |
| 659 | { |
| 660 | RDTreeWidgetItem *item = ui->hosts->selectedItem(); |
| 661 | |
| 662 | if(!item) |
| 663 | return; |
| 664 | |
| 665 | RemoteHost host = getRemoteHost(item); |
| 666 | |
| 667 | int itemIdx = ui->hosts->indexOfTopLevelItem(item); |
| 668 | |
| 669 | // don't delete running instances on a host |
| 670 | if(item->parent() != ui->hosts->invisibleRootItem() || itemIdx < 0 || !host.IsValid()) |
| 671 | return; |
| 672 | |
| 673 | QString hostname = item->text(0); |
| 674 | |
| 675 | if(hostname == lit("localhost")) |
| 676 | return; |
| 677 | |
| 678 | QMessageBox::StandardButton res = RDDialog::question( |
| 679 | this, tr("Deleting host"), tr("Are you sure you wish to delete %1?").arg(hostname), |
| 680 | RDDialog::YesNoCancel); |
| 681 | |
| 682 | if(res == QMessageBox::Cancel || res == QMessageBox::No) |
| 683 | return; |
| 684 | |
| 685 | if(res == QMessageBox::Yes) |
| 686 | { |
| 687 | RemoteHost h = m_Ctx.Config().GetRemoteHost(host.Hostname()); |
| 688 | if(!h.IsValid()) |
| 689 | return; |
| 690 | |
| 691 | // the host will be removed in queueDelete. |
| 692 | m_Ctx.Config().RemoveRemoteHost(h); |
| 693 | m_Ctx.Config().Save(); |
| 694 | |
| 695 | item->clear(); |
| 696 | |
| 697 | queueDelete(ui->hosts->takeTopLevelItem(itemIdx)); |
| 698 | |
| 699 | ui->hosts->clearSelection(); |
| 700 | |
| 701 | ui->hostname->setText(hostname); |
| 702 | on_hostname_textEdited(hostname); |
| 703 | } |
| 704 | } |
nothing calls this directly
no test coverage detected