46 if (!
d->directory.exists()) {
53 QHash<int, QString> files;
56 Q_FOREACH (QString file, fileNames) {
57 QRegularExpressionMatch match = fileRegex.match(file);
59 if (match.hasMatch()) {
60 int index = match.captured(1).toInt();
61 files.insert(index, file);
62 indecies.push_back(index);
67 std::sort(indecies.begin(), indecies.end());
69 QHash<int, int> holes;
72 for (
auto it = indecies.begin(); it != indecies.end(); ++it) {
74 int diff = curIndex - prevIndex;
77 holes.insert(curIndex, diff - 1);
84 if (holes.isEmpty()) {
89 for (
auto it = indecies.begin(); it != indecies.end(); ++it) {
92 if (holes.contains(ind)) {
100 QString oldName = files[ind];
101 QString newName = QString(
"%2.%3").arg(QString(
"%1").arg(ind - offset, 7, 10, QLatin1Char(
'0')),
105 d->directory.rename(oldName, newName);