6 const QString help_string,
7 const unsigned min_val,
8 const unsigned max_val,
9 std::vector<unsigned> locked) :
11 help_string_(help_string),
15 setObjectName(
"Modify range list selection");
18 QTabWidget *tab_widget =
new QTabWidget;
21 QHBoxLayout *all_none_buttons =
new QHBoxLayout;
26 layout_->addLayout(all_none_buttons);
28 QWidget *range_select =
new QWidget;
29 QVBoxLayout *range_select_layout =
new QVBoxLayout(range_select);
30 range_select->setLayout(range_select_layout);
32 range_select_layout->addWidget(
new QLabel(
"Select first and last:"));
40 QHBoxLayout *min_box_layout =
new QHBoxLayout;
41 min_box_layout->addWidget(
new QLabel(
"First"));
43 QHBoxLayout *max_box_layout =
new QHBoxLayout;
44 max_box_layout->addWidget(
new QLabel(
"Last"));
47 range_select_layout->addLayout(min_box_layout);
48 range_select_layout->addLayout(max_box_layout);
50 QHBoxLayout *add_remove_invert_buttons =
new QHBoxLayout;
58 range_select_layout->addLayout(add_remove_invert_buttons);
59 range_select_layout->addStretch(1);
61 QWidget *scroll_widget =
new QWidget;
62 QVBoxLayout *checkboxes_layout =
new QVBoxLayout;
63 scroll_widget->setLayout(checkboxes_layout);
64 QScrollArea *scroll_area =
new QScrollArea;
65 scroll_area->setWidget(scroll_widget);
66 scroll_area->setWidgetResizable(
true);
67 scroll_area->setFrameShape(QFrame::NoFrame);
69 tab_widget->addTab(scroll_area,
"Check-boxes");
70 tab_widget->addTab(range_select,
"Range select");
74 QCheckBox *checkbox =
new QCheckBox;
75 checkbox->setText(QString::fromStdString(std::to_string(i)));
81 checkboxes_layout->addWidget(checkbox);
89 std::sort(locked.begin(), locked.end());
90 if (locked.back() < checkboxes.size())
92 for (
unsigned i(0); i < locked.size(); ++i)
94 checkboxes[locked[i]]->setEnabled(
false);
95 checkboxes[locked[i]]->setChecked(
true);
101 button_box_ =
new QDialogButtonBox(QDialogButtonBox::Ok
102 | QDialogButtonBox::Cancel);
117 std::vector<unsigned>
123 for (
unsigned i(0); i <
selection_.size(); ++i)
125 selection.push_back(i);
135 Q_EMIT
layout_->parentWidget()->setEnabled(
false);
138 std::vector<QSignalBlocker> blockers;
140 blockers.push_back(QSignalBlocker(checkbox));
142 for (
unsigned i(0); i < checkboxes.size(); ++i)
145 Q_EMIT
layout_->parentWidget()->setEnabled(
true);
166 Q_EMIT
layout_->parentWidget()->setEnabled(
false);
168 for (
unsigned i(0); i <
selection_.size(); ++i)
171 Q_EMIT
layout_->parentWidget()->setEnabled(
true);
250 QMessageBox::warning(
this, (
"Wrong range"),
251 (
"Wrong selection, the \"last\" value must be superior or equal to the \"first\" value."),
virtual ~ModifyRangeListSelection()
std::vector< unsigned > getSelection()
QPushButton * remove_button_
ModifyRangeListSelection(QVBoxLayout *layout, const QString help_string="", const unsigned min_val=0, const unsigned max_val=0, std::vector< unsigned > locked=std::vector< unsigned >())
void updateTicksFromSelection()
const QString help_string_
std::recursive_mutex selection_mutex_
std::vector< unsigned > selection_
std::vector< QCheckBox * > checkboxes
QPushButton * add_button_
QPushButton * none_button_
QPushButton * invert_button_
void selectionChanged(std::vector< unsigned > selection)
QPushButton * all_button_
void updateSelectionFromTicks()
QDialogButtonBox * button_box_
ram_display::UpdateSelection::Request selection