transform_selector.cpp
Go to the documentation of this file.
1 #include "transform_selector.h"
2 #include "ui_transform_selector.h"
3 #include <QSettings>
4 #include <QDomDocument>
5 #include <QTableWidget>
6 #include <QComboBox>
7 #include <QDebug>
8 
9 TransformSelector::TransformSelector(QStringList builtin_transform,
10  QStringList available_transforms,
11  QString *default_tansform,
12  std::map<std::string, QString> *curve_transforms,
13  QWidget *parent) :
14  QDialog(parent),
15  ui(new Ui::transform_selector),
16  _curves_trans(curve_transforms),
17  _default_trans(default_tansform)
18 {
19  ui->setupUi(this);
20 
21  QStringList transforms = builtin_transform + available_transforms;
22 
23  ui->comboDefault->insertItems(0, transforms);
24  ui->comboDefault->insertSeparator( builtin_transform.size() );
25  if( transforms.contains( *default_tansform ) )
26  {
27  ui->comboDefault->setCurrentText( *default_tansform );
28  }
29 
30  ui->tableWidget->setRowCount( int(curve_transforms->size()) );
31  ui->tableWidget->setColumnCount(2);
32 
33  int row = 0;
34  for(const auto& it: *curve_transforms)
35  {
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 ) )
44  {
45  item_combo->setCurrentText( trans );
46  }
47  row++;
48  }
49  QHeaderView* header = ui->tableWidget->horizontalHeader();
50  header->setSectionResizeMode(QHeaderView::Stretch);
51 }
52 
54 {
55  delete ui;
56 }
57 
58 
60 {
61  int default_index = ui->comboDefault->currentIndex();
62  for(int row = 0; row < ui->tableWidget->rowCount(); row++)
63  {
64  auto combo = static_cast<QComboBox*>(ui->tableWidget->cellWidget(row,1));
65  combo->setCurrentIndex(default_index);
66  }
67 }
68 
70 {
71  for(int row = 0; row < ui->tableWidget->rowCount(); row++)
72  {
73  auto combo = static_cast<QComboBox*>(ui->tableWidget->cellWidget(row,1));
74  combo->setCurrentIndex(0);
75  }
76 }
77 
79 {
80  for(int row = 0; row < ui->tableWidget->rowCount(); row++)
81  {
82  const auto& name = ui->tableWidget->item(row,0)->text();
83  auto combo = static_cast<QComboBox*>(ui->tableWidget->cellWidget(row,1));
84  (*_curves_trans)[ name.toStdString() ] = combo->currentText();
85  }
86  *_default_trans = ui->comboDefault->currentText();
87 }
TransformSelector(QStringList builtin_transform, QStringList available_transforms, QString *default_tansform, std::map< std::string, QString > *curve_transforms, QWidget *parent=nullptr)
char name[1]
struct absl::base_internal::@37::AllocList::Header header
Ui::transform_selector * ui


plotjuggler
Author(s): Davide Faconti
autogenerated on Sat Jul 6 2019 03:44:18