37 #include <QFormLayout>
39 #include <QHBoxLayout>
40 #include <QHeaderView>
43 #include <QMessageBox>
44 #include <QPushButton>
46 #include <QTableWidget>
47 #include <QVBoxLayout>
57 : QWidget(parent), long_name_(long_name), short_name_(short_name)
60 QVBoxLayout* layout =
new QVBoxLayout();
63 title_ =
new QLabel(
"",
this);
64 QFont group_title_font(QFont().defaultFamily(), 12, QFont::Bold);
65 title_->setFont(group_title_font);
69 QHBoxLayout* hlayout =
new QHBoxLayout();
72 QVBoxLayout* column1 =
new QVBoxLayout();
83 connect(
data_table_->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
this,
84 SLOT(previewSelectedLeft(QItemSelection, QItemSelection)));
87 QStringList data_header_list;
88 data_header_list.append(QString(
" Names").prepend(
short_name_));
89 data_table_->setHorizontalHeaderLabels(data_header_list);
90 data_table_->horizontalHeader()->setDefaultAlignment(Qt::AlignHCenter);
93 hlayout->addLayout(column1);
96 QVBoxLayout* column2 =
new QVBoxLayout();
97 column2->setSizeConstraint(QLayout::SetFixedSize);
100 QPushButton* btn_right =
new QPushButton(
">",
this);
101 btn_right->setMaximumSize(25, 80);
102 connect(btn_right, SIGNAL(clicked()),
this, SLOT(selectDataButtonClicked()));
103 column2->addWidget(btn_right);
106 QPushButton* btn_left =
new QPushButton(
"<",
this);
107 btn_left->setMaximumSize(25, 80);
108 connect(btn_left, SIGNAL(clicked()),
this, SLOT(deselectDataButtonClicked()));
109 column2->addWidget(btn_left);
112 hlayout->addLayout(column2);
115 QVBoxLayout* column3 =
new QVBoxLayout();
126 connect(
selected_data_table_->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
this,
127 SLOT(previewSelectedRight(QItemSelection, QItemSelection)));
133 hlayout->addLayout(column3);
136 layout->addLayout(hlayout);
141 QHBoxLayout* controls_layout =
new QHBoxLayout();
142 controls_layout->setContentsMargins(0, 25, 0, 15);
145 controls_layout->addItem(
new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum));
148 QPushButton* btn_save =
new QPushButton(
"&Save",
this);
150 connect(btn_save, SIGNAL(clicked()),
this, SIGNAL(
doneEditing()));
151 controls_layout->addWidget(btn_save);
152 controls_layout->setAlignment(btn_save, Qt::AlignRight);
155 QPushButton* btn_cancel =
new QPushButton(
"&Cancel",
this);
157 connect(btn_cancel, SIGNAL(clicked()),
this, SIGNAL(
cancelEditing()));
158 controls_layout->addWidget(btn_cancel);
159 controls_layout->setAlignment(btn_cancel, Qt::AlignRight);
162 layout->addLayout(controls_layout);
166 this->setLayout(layout);
207 table->setUpdatesEnabled(
false);
208 table->setDisabled(
true);
209 table->clearContents();
212 table->setRowCount(items.size());
216 for (
const std::string& item : items)
220 if (item ==
"ASSUMED_FIXED_ROOT_JOINT")
224 QTableWidgetItem* data_name =
new QTableWidgetItem(item.c_str());
225 data_name->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
228 table->setItem(row, 0, data_name);
234 table->setRowCount(row);
237 table->setUpdatesEnabled(
true);
238 table->setDisabled(
false);
244 void DoubleListWidget::selectDataButtonClicked()
247 QList<QTableWidgetItem*> selected =
data_table_->selectedItems();
250 for (QTableWidgetItem* item : selected)
252 std::string
name = item->text().toStdString();
253 bool already_exists =
false;
261 if (item->text().toStdString() ==
name)
263 already_exists =
true;
273 QTableWidgetItem* new_item =
new QTableWidgetItem(
name.c_str());
274 new_item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
285 void DoubleListWidget::deselectDataButtonClicked()
291 for (QTableWidgetItem* item : deselected)
302 void DoubleListWidget::previewSelectedLeft(
const QItemSelection& ,
const QItemSelection& )
304 const QList<QTableWidgetItem*> selected_items =
data_table_->selectedItems();
311 void DoubleListWidget::previewSelectedRight(
const QItemSelection& ,
const QItemSelection& )
323 if (selected.empty())
326 std::vector<std::string> selected_vector;
329 selected_vector.reserve(selected.size());
330 for (QTableWidgetItem* item : selected)
331 selected_vector.emplace_back(item->text().toStdString());
339 std::vector<std::string> values;
std::string append(const std::string &left, const std::string &right)