2 #include "ui_transform_selector.h" 4 #include <QDomDocument> 5 #include <QTableWidget> 10 QString* default_tansform, std::map<std::string, QString>* curve_transforms,
12 : QDialog(parent), ui(new
Ui::transform_selector), _curves_trans(curve_transforms), _default_trans(default_tansform)
16 QStringList transforms = builtin_transform + available_transforms;
18 ui->comboDefault->insertItems(0, transforms);
19 ui->comboDefault->insertSeparator(builtin_transform.size());
20 if (transforms.contains(*default_tansform))
22 ui->comboDefault->setCurrentText(*default_tansform);
25 ui->tableWidget->setRowCount(
int(curve_transforms->size()));
26 ui->tableWidget->setColumnCount(2);
29 for (
const auto& it : *curve_transforms)
31 const auto& trans = it.second;
32 auto item_name =
new QTableWidgetItem(QString::fromStdString(it.first));
33 auto item_combo =
new QComboBox();
34 item_combo->insertItems(0, transforms);
35 item_combo->insertSeparator(3);
36 ui->tableWidget->setItem(row, 0, item_name);
37 ui->tableWidget->setCellWidget(row, 1, item_combo);
38 if (transforms.contains(trans))
40 item_combo->setCurrentText(trans);
44 QHeaderView* header =
ui->tableWidget->horizontalHeader();
45 header->setSectionResizeMode(QHeaderView::Stretch);
55 int default_index =
ui->comboDefault->currentIndex();
56 for (
int row = 0; row <
ui->tableWidget->rowCount(); row++)
58 auto combo =
static_cast<QComboBox*
>(
ui->tableWidget->cellWidget(row, 1));
59 combo->setCurrentIndex(default_index);
65 for (
int row = 0; row <
ui->tableWidget->rowCount(); row++)
67 auto combo =
static_cast<QComboBox*
>(
ui->tableWidget->cellWidget(row, 1));
68 combo->setCurrentIndex(0);
74 for (
int row = 0; row <
ui->tableWidget->rowCount(); row++)
76 const auto&
name =
ui->tableWidget->item(row, 0)->text();
77 auto combo =
static_cast<QComboBox*
>(
ui->tableWidget->cellWidget(row, 1));
78 (*_curves_trans)[
name.toStdString()] = combo->currentText();