43 m_selected_steps.clear();
45 QString rangesString = QString::fromStdString(ranges);
47 if (regex.indexIn(rangesString, 0) == -1) {
48 m_all_selected =
true;
51 m_all_selected =
false;
54 while ((pos = regex.indexIn(rangesString, pos)) != -1) {
55 int start = regex.cap(1).toInt();
57 if (!regex.cap(2).isEmpty()) {
58 int stop = regex.cap(2).toInt();
60 if (!regex.cap(3).isEmpty()) {
61 step = regex.cap(3).toInt();
64 for (
int i = start; i <= stop; i += step) {
65 m_selected_steps.insert(i);
68 m_selected_steps.insert(start);
71 pos += regex.matchedLength();
81 std::set<int> intersected;
82 std::set_intersection(available.begin(), available.end(), m_selected_steps.begin(), m_selected_steps.end(), std::inserter(intersected, intersected.begin()));
89 return m_all_selected || m_selected_steps.find(step) != m_selected_steps.end();
bool Contains(int step) const
Checks whether the selection contains a specified step.
Namespace for SimPT shell package.
static const QRegExp g_range_regex
Regex for one range (start[-stop[:step]])
Interface for StepSelection.
void SetSelectionText(const std::string &ranges)
Sets the selected ranges of steps.
std::set< int > ApplySelection(const std::set< int > &available) const
Applies the selection to a set of available steps.
virtual ~StepSelection()
Destructor.
StepSelection()
Constructs a selection with an empty ranges text (ie. everything is selected)
static const QRegExp g_repeated_regex
Regex for a series of repeated ranges, separated by , of ;.