コード例 #1
0
void model_import_dlg::on_texture_table_changed()
{
	QTableWidget * table = mesh_tab->findChild<QTableWidget*>("texturesTable");
	QWidget * parent_group = table->parentWidget();
	QPushButton * edit_button = parent_group->findChild<QPushButton*>("textureEditButton");
	QPushButton * delete_button = parent_group->findChild<QPushButton*>("textureDeleteButton");

	bool selected = table->selectedItems().size() > 0;

	if (selected)
	{
		edit_button->setEnabled(true);
		delete_button->setEnabled(true);
	}
	else
	{
		edit_button->setEnabled(false);
		delete_button->setEnabled(false);
	}
}
コード例 #2
0
void VirshGui::applySnapshot()
{
    int count = 0;
    for (auto hddGroupBox : ui->snapshotsTab->findChildren<QGroupBox *>()) {
        QTableWidget *snapshotTable = hddGroupBox->findChild<QTableWidget *>();
        QList<QTableWidgetItem *> items = snapshotTable->selectedItems();
        //std::cout << items.count() << std::endl;
        if (items.count() == 1) {
            //cout
            //    << "hdd: "
            //    << hddGroupBox->title().toStdString()
            //    << ", snapshot: "
            //    << snapshotTable->item(items.at(0)->row(), 1)->text().toStdString()
            //    << endl;
            string snapshotID = snapshotTable->item(items.at(0)->row(), 0)->text().toStdString();
            string hddPath = hddGroupBox->title().toStdString();
            string cmd = "qemu-img snapshot -a '" + snapshotID + "' '" + hddPath + "'";

            string execOut;
            try {
                execOut = ssh->execCmd(cmd);
            } catch (ssh::SshException e) {
                handleDisconnect();
            }

            if (ssh->getLastExitCode() == 0) {
                ui->statusBar->showMessage("Snapshot erfolgreich angewandt", 5000);
            } else {
                ui->statusBar->showMessage(
                        QString::fromStdString("Fehler: " + execOut),
                        5000);
            }
            break;
        }
        count++;
    }
}