22 #include <QVBoxLayout>
23 #include <QPushButton>
25 #include <QStringList>
26 #include <QStringListModel>
31 m_single_selection(false)
37 QDialog(parent), m_single_selection(single)
42 void ExplorationSelection::DrawGui()
44 setWindowTitle(
"Select Explorations");
46 QVBoxLayout *layout =
new QVBoxLayout;
48 m_exploration_widget =
new QListView;
49 m_exploration_widget->setEditTriggers(QAbstractItemView::NoEditTriggers);
50 if (m_single_selection)
51 m_exploration_widget->setSelectionMode(QAbstractItemView::SingleSelection);
53 m_exploration_widget->setSelectionMode(QAbstractItemView::MultiSelection);
54 m_exploration_widget->setSelectionBehavior(QAbstractItemView::SelectItems);
55 m_exploration_widget->clearSelection();
57 QStringListModel *model =
new QStringListModel();
59 list <<
"Retrieving info from server...";
60 model->setStringList(list);
62 m_exploration_widget->setModel(model);
64 layout->addWidget(m_exploration_widget);
66 QHBoxLayout *buttonLayout =
new QHBoxLayout;
67 m_ok_button =
new QPushButton(
"Ok");
68 buttonLayout->addWidget(m_ok_button);
70 QPushButton *cancel =
new QPushButton(
"Cancel");
71 buttonLayout->addWidget(cancel);
73 layout->addLayout(buttonLayout);
77 connect(m_ok_button, SIGNAL(clicked()),
this, SLOT(Accept()));
78 connect(cancel, SIGNAL(clicked()),
this, SLOT(reject()));
83 delete m_exploration_widget;
86 void ExplorationSelection::Accept()
88 m_selected_exploration.clear();
90 auto selection = m_exploration_widget->selectionModel();
91 auto selected_indices = selection->selectedIndexes();
92 auto model = m_exploration_widget->model();
94 for (
auto index : selected_indices) {
95 m_selected_exploration.push_back(model->data(index, 0).toString().toStdString());
103 QStringListModel* model = (QStringListModel*) m_exploration_widget->model();
106 if (explorations.size() == 0)
107 list <<
"No explorations found!";
109 for (
auto name : explorations)
110 list << QString(name.c_str());
112 model->setStringList(list);
117 return m_selected_exploration;
122 return (m_selected_exploration.size() != 0);
bool Selected()
Return true if an exploration is selected.
Interface for ExplorationSelection.
ExplorationSelection(QWidget *parent=0)
Constructor.
virtual ~ExplorationSelection()
Destructor.
void UpdateExplorations(std::vector< std::string > explorations)
updates the current displayed explorations
see the online Qt documentation
Namespace for SimPT parameter explorer package.
std::vector< std::string > GetSelection()
Get the name of the selected exploration.
see the online Qt documentation