2 #include "ui_transform_selector.h"
4 #include <QDomDocument>
5 #include <QTableWidget>
10 QStringList available_transforms,
11 QString* default_tansform,
12 std::map<std::string, QString>* curve_transforms,
15 , ui(new
Ui::transform_selector)
16 , _curves_trans(curve_transforms)
17 , _default_trans(default_tansform)
21 QStringList transforms = builtin_transform + available_transforms;
23 ui->comboDefault->insertItems(0, transforms);
24 ui->comboDefault->insertSeparator(builtin_transform.size());
25 if (transforms.contains(*default_tansform))
27 ui->comboDefault->setCurrentText(*default_tansform);
30 ui->tableWidget->setRowCount(
int(curve_transforms->size()));
31 ui->tableWidget->setColumnCount(2);
34 for (
const auto& it : *curve_transforms)
36 const auto& trans = it.second;
37 auto item_name =
new QTableWidgetItem(QString::fromStdString(it.first));
38 auto item_combo =
new QComboBox();
39 item_combo->insertItems(0, transforms);
40 item_combo->insertSeparator(3);
41 ui->tableWidget->setItem(row, 0, item_name);
42 ui->tableWidget->setCellWidget(row, 1, item_combo);
43 if (transforms.contains(trans))
45 item_combo->setCurrentText(trans);
49 QHeaderView*
header =
ui->tableWidget->horizontalHeader();
50 header->setSectionResizeMode(QHeaderView::Stretch);
60 int default_index =
ui->comboDefault->currentIndex();
61 for (
int row = 0; row <
ui->tableWidget->rowCount(); row++)
63 auto combo =
static_cast<QComboBox*
>(
ui->tableWidget->cellWidget(row, 1));
64 combo->setCurrentIndex(default_index);
70 for (
int row = 0; row <
ui->tableWidget->rowCount(); row++)
72 auto combo =
static_cast<QComboBox*
>(
ui->tableWidget->cellWidget(row, 1));
73 combo->setCurrentIndex(0);
79 for (
int row = 0; row <
ui->tableWidget->rowCount(); row++)
81 const auto& name =
ui->tableWidget->item(row, 0)->text();
82 auto combo =
static_cast<QComboBox*
>(
ui->tableWidget->cellWidget(row, 1));
83 (*_curves_trans)[name.toStdString()] = combo->currentText();