Skip to content
Snippets Groups Projects
Commit db957727 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

precaution against duplicate underscore

parent 6af71cf0
No related branches found
No related tags found
1 merge request!2404ensure that there are no duplicate names in lists; disable cp/rm actions for empty lists
......@@ -19,7 +19,7 @@
namespace {
QStringList splitName(const QString& s) {
QRegularExpression pattern("(.*)_(\\d+)");
QRegularExpression pattern("(.*)_(\\d+)$");
QRegularExpressionMatch match = pattern.match(s);
if (match.hasMatch()) {
QStringList groups;
......@@ -36,13 +36,13 @@ QStringList splitName(const QString& s) {
void NamedItem::renumber(const QStringList& extant_names)
{
// Item name consists of a stem and an optional number
QStringList ns = splitName(name());
QStringList ns = ::splitName(name());
QString stem = ns.isEmpty() ? name() : ns[0];
// Determine highest number for given stem in extant_items
int imax = 0;
for (QString tname : extant_names) {
QStringList ts = splitName(tname);
QStringList ts = ::splitName(tname);
if (ts.isEmpty()) {
if (tname == stem)
imax = std::max(imax, 1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment