Skip to content

Commit 41fe9c3

Browse files
committed
Resolve use of QString::replace(const QRegExp &, const QString &) for Qt 6
1 parent eee16fb commit 41fe9c3

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/ruleparser.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ class Rules
6363
QString replacement;
6464

6565
bool isValid() { return !pattern.isEmpty(); }
66+
#if QT_VERSION >= 0x060000
67+
QString apply(QString &string) { return pattern.replaceIn(string, replacement); }
68+
#else
6669
QString& apply(QString &string) { return string.replace(pattern, replacement); }
70+
#endif
6771
};
6872

6973
QRegExp rx;

src/svn.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,15 +438,23 @@ void SvnRevision::splitPathName(const Rules::Match &rule, const QString &pathNam
438438

439439
if (repository_p) {
440440
*repository_p = svnprefix;
441+
#if QT_VERSION >= 0x060000
442+
*repository_p = rule.rx.replaceIn(*repository_p, rule.repository);
443+
#else
441444
repository_p->replace(rule.rx, rule.repository);
445+
#endif
442446
foreach (Rules::Match::Substitution subst, rule.repo_substs) {
443447
subst.apply(*repository_p);
444448
}
445449
}
446450

447451
if (effectiveRepository_p) {
448452
*effectiveRepository_p = svnprefix;
453+
#if QT_VERSION >= 0x060000
454+
*effectiveRepository_p = rule.rx.replaceIn(*effectiveRepository_p, rule.repository);
455+
#else
449456
effectiveRepository_p->replace(rule.rx, rule.repository);
457+
#endif
450458
foreach (Rules::Match::Substitution subst, rule.repo_substs) {
451459
subst.apply(*effectiveRepository_p);
452460
}
@@ -458,15 +466,23 @@ void SvnRevision::splitPathName(const Rules::Match &rule, const QString &pathNam
458466

459467
if (branch_p) {
460468
*branch_p = svnprefix;
469+
#if QT_VERSION >= 0x060000
470+
*branch_p = rule.rx.replaceIn(*branch_p, rule.branch);
471+
#else
461472
branch_p->replace(rule.rx, rule.branch);
473+
#endif
462474
foreach (Rules::Match::Substitution subst, rule.branch_substs) {
463475
subst.apply(*branch_p);
464476
}
465477
}
466478

467479
if (path_p) {
468480
QString prefix = svnprefix;
481+
#if QT_VERSION >= 0x060000
482+
prefix = rule.rx.replaceIn(prefix, rule.prefix);
483+
#else
469484
prefix.replace(rule.rx, rule.prefix);
485+
#endif
470486
*path_p = prefix + pathName.mid(svnprefix.length());
471487
}
472488
}
@@ -1308,7 +1324,11 @@ int SvnRevision::fetchIgnoreProps(QString *ignore, apr_pool_t *pool, const char
13081324
// they didn't match anything in Subversion but would in Git eventually
13091325
ignore->remove(QRegExp("^[^\\r\\n]*[\\\\/][^\\r\\n]*(?:[\\r\\n]|$)|[\\r\\n][^\\r\\n]*[\\\\/][^\\r\\n]*(?=[\\r\\n]|$)"));
13101326
// add a slash in front to have the same meaning in Git of only working on the direct children
1327+
#if QT_VERSION >= 0x060000
1328+
*ignore = QRegExp("(^|[\\r\\n])\\s*(?![\\r\\n]|$)").replaceIn(*ignore, "\\1/");
1329+
#else
13111330
ignore->replace(QRegExp("(^|[\\r\\n])\\s*(?![\\r\\n]|$)"), "\\1/");
1331+
#endif
13121332
if (ignore->trimmed().isEmpty()) {
13131333
*ignore = QString();
13141334
}
@@ -1330,7 +1350,11 @@ int SvnRevision::fetchIgnoreProps(QString *ignore, apr_pool_t *pool, const char
13301350
}
13311351

13321352
// replace multiple asterisks Subversion meaning by Git meaning
1353+
#if QT_VERSION >= 0x060000
1354+
*ignore = QRegExp("\\*+").replaceIn(*ignore, "*");
1355+
#else
13331356
ignore->replace(QRegExp("\\*+"), "*");
1357+
#endif
13341358

13351359
return EXIT_SUCCESS;
13361360
}

0 commit comments

Comments
 (0)