rbutil: Replace QRegExp with QRegularExpression.
The former is not part of Qt6 anymore, while the latter has been introduced with Qt5. We don't support Qt4 anymore, so move to QRegularExpression. Change-Id: Icc15ef422790f3740660c5581294aa0536f46b1f
This commit is contained in:
parent
72071d108c
commit
9e28474e47
11 changed files with 41 additions and 37 deletions
|
@ -233,10 +233,10 @@ bool BootloaderInstallIpod::ipodInitialize(struct ipod_t *ipod)
|
|||
sprintf(ipod->diskname, "\\\\.\\PhysicalDrive%i", devicename.toInt());
|
||||
#elif defined(Q_OS_MACX)
|
||||
sprintf(ipod->diskname, "%s",
|
||||
qPrintable(devicename.remove(QRegExp("s[0-9]+$"))));
|
||||
qPrintable(devicename.remove(QRegularExpression("s[0-9]+$"))));
|
||||
#else
|
||||
sprintf(ipod->diskname, "%s",
|
||||
qPrintable(devicename.remove(QRegExp("[0-9]+$"))));
|
||||
qPrintable(devicename.remove(QRegularExpression("[0-9]+$"))));
|
||||
#endif
|
||||
LOG_INFO() << "ipodpatcher: overriding scan, using"
|
||||
<< ipod->diskname;
|
||||
|
|
|
@ -243,10 +243,10 @@ bool BootloaderInstallSansa::sansaInitialize(struct sansa_t *sansa)
|
|||
sprintf(sansa->diskname, "\\\\.\\PhysicalDrive%i", devicename.toInt());
|
||||
#elif defined(Q_OS_MACX)
|
||||
sprintf(sansa->diskname,
|
||||
"%s", qPrintable(devicename.remove(QRegExp("s[0-9]+$"))));
|
||||
"%s", qPrintable(devicename.remove(QRegularExpression("s[0-9]+$"))));
|
||||
#else
|
||||
sprintf(sansa->diskname,
|
||||
"%s", qPrintable(devicename.remove(QRegExp("[0-9]+$"))));
|
||||
"%s", qPrintable(devicename.remove(QRegularExpression("[0-9]+$"))));
|
||||
#endif
|
||||
LOG_INFO() << "sansapatcher: overriding scan, using"
|
||||
<< sansa->diskname;
|
||||
|
|
|
@ -263,9 +263,10 @@ QString TalkGenerator::correctString(QString s)
|
|||
int i = 0;
|
||||
int max = m_corrections.size();
|
||||
while(i < max) {
|
||||
corrected = corrected.replace(QRegExp(m_corrections.at(i).search,
|
||||
corrected = corrected.replace(QRegularExpression(m_corrections.at(i).search,
|
||||
m_corrections.at(i).modifier.contains("i")
|
||||
? Qt::CaseInsensitive : Qt::CaseSensitive),
|
||||
? QRegularExpression::NoPatternOption
|
||||
: QRegularExpression::CaseInsensitiveOption),
|
||||
m_corrections.at(i).replace);
|
||||
i++;
|
||||
}
|
||||
|
@ -329,7 +330,7 @@ void TalkGenerator::setLang(QString name)
|
|||
co.search = items.at(3);
|
||||
co.replace = items.at(4);
|
||||
// Qt uses backslash for back references, Perl uses dollar sign.
|
||||
co.replace.replace(QRegExp("\\$(\\d+)"), "\\\\1");
|
||||
co.replace.replace(QRegularExpression("\\$(\\d+)"), "\\\\1");
|
||||
co.modifier = items.at(5);
|
||||
m_corrections.append(co);
|
||||
}
|
||||
|
|
|
@ -294,8 +294,8 @@ QString TTSFestival::getVoiceInfo(QString voice)
|
|||
}
|
||||
else
|
||||
{
|
||||
response = response.remove(QRegExp("(description \"*\")",
|
||||
Qt::CaseInsensitive, QRegExp::Wildcard));
|
||||
response = response.remove(QRegularExpression("(description \".*\")",
|
||||
QRegularExpression::CaseInsensitiveOption));
|
||||
LOG_INFO() << "voiceInfo w/o descr:" << response;
|
||||
response = response.remove(')');
|
||||
#if QT_VERSION >= 0x050e00
|
||||
|
|
|
@ -118,7 +118,8 @@ QString Utils::resolvePathCase(QString path)
|
|||
// need to filter using QRegExp as QStringList::filter(QString)
|
||||
// matches any substring
|
||||
QString expr = QString("^" + elems.at(i) + "$");
|
||||
QRegExp rx = QRegExp(expr, Qt::CaseInsensitive);
|
||||
QRegularExpression rx = QRegularExpression(expr,
|
||||
QRegularExpression::CaseInsensitiveOption);
|
||||
QStringList a = direlems.filter(rx);
|
||||
|
||||
if(a.size() != 1)
|
||||
|
@ -403,9 +404,10 @@ QString Utils::checkEnvironment(bool permission)
|
|||
*/
|
||||
QString Utils::trimVersionString(QString s)
|
||||
{
|
||||
QRegExp r = QRegExp(".*([\\d\\.]+\\d+[a-z]?).*");
|
||||
if(r.indexIn(s) != -1) {
|
||||
return r.cap(1);
|
||||
QRegularExpression r = QRegularExpression("^\\D*([\\d\\.]+\\d+[a-z]?).*");
|
||||
QRegularExpressionMatch match = r.match(s);
|
||||
if(match.hasMatch()) {
|
||||
return match.captured(1);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
@ -428,15 +430,15 @@ int Utils::compareVersionStrings(QString s1, QString s2)
|
|||
|
||||
while(!a.isEmpty() || !b.isEmpty()) {
|
||||
// trim all leading non-digits and non-dots (dots are removed afterwards)
|
||||
a.remove(QRegExp("^[^\\d\\.]*"));
|
||||
b.remove(QRegExp("^[^\\d\\.]*"));
|
||||
a.remove(QRegularExpression("^[^\\d\\.]*"));
|
||||
b.remove(QRegularExpression("^[^\\d\\.]*"));
|
||||
|
||||
// trim all trailing non-digits for conversion (QString::toInt()
|
||||
// requires this). Copy strings first as replace() changes the string.
|
||||
QString numa = a;
|
||||
QString numb = b;
|
||||
numa.remove(QRegExp("\\D+.*$"));
|
||||
numb.remove(QRegExp("\\D+.*$"));
|
||||
numa.remove(QRegularExpression("\\D+.*$"));
|
||||
numb.remove(QRegularExpression("\\D+.*$"));
|
||||
|
||||
// convert to number
|
||||
bool ok1, ok2;
|
||||
|
@ -455,15 +457,15 @@ int Utils::compareVersionStrings(QString s1, QString s2)
|
|||
return (vala > valb) ? -1 : 1;
|
||||
|
||||
// trim leading digits.
|
||||
a.remove(QRegExp("^\\d*"));
|
||||
b.remove(QRegExp("^\\d*"));
|
||||
a.remove(QRegularExpression("^\\d*"));
|
||||
b.remove(QRegularExpression("^\\d*"));
|
||||
|
||||
// If only one of the following characters is a dot that one is
|
||||
// "greater" then anything else. Make sure it's followed by a number,
|
||||
// Otherwise it might be the end of the string or suffix. Do this
|
||||
// before version addon characters check to avoid stopping too early.
|
||||
bool adot = a.contains(QRegExp("^[a-zA-Z]*\\.[0-9]"));
|
||||
bool bdot = b.contains(QRegExp("^[a-zA-Z]*\\.[0-9]"));
|
||||
bool adot = a.contains(QRegularExpression("^[a-zA-Z]*\\.[0-9]"));
|
||||
bool bdot = b.contains(QRegularExpression("^[a-zA-Z]*\\.[0-9]"));
|
||||
if(adot && !bdot)
|
||||
return -1;
|
||||
if(!adot && bdot)
|
||||
|
@ -473,17 +475,17 @@ int Utils::compareVersionStrings(QString s1, QString s2)
|
|||
// (version numbers like 1.2b.3 aren't handled).
|
||||
QChar ltra;
|
||||
QChar ltrb;
|
||||
if(a.contains(QRegExp("^[a-zA-Z]")))
|
||||
if(a.contains(QRegularExpression("^[a-zA-Z]")))
|
||||
ltra = a.at(0);
|
||||
if(b.contains(QRegExp("^[a-zA-Z]")))
|
||||
if(b.contains(QRegularExpression("^[a-zA-Z]")))
|
||||
ltrb = b.at(0);
|
||||
if(ltra != ltrb)
|
||||
return (ltra < ltrb) ? 1 : -1;
|
||||
|
||||
// both are identical or no addon characters, ignore.
|
||||
// remove modifiers and following dot.
|
||||
a.remove(QRegExp("^[a-zA-Z]*\\."));
|
||||
b.remove(QRegExp("^[a-zA-Z]*\\."));
|
||||
a.remove(QRegularExpression("^[a-zA-Z]*\\."));
|
||||
b.remove(QRegularExpression("^[a-zA-Z]*\\."));
|
||||
}
|
||||
|
||||
// no differences found.
|
||||
|
@ -630,7 +632,7 @@ QString Utils::resolveMountPoint(QString device)
|
|||
|
||||
#if defined(Q_OS_WIN32)
|
||||
QString result;
|
||||
unsigned int driveno = device.replace(QRegExp("^.*([0-9]+)"), "\\1").toInt();
|
||||
unsigned int driveno = device.replace(QRegularExpression("^.*([0-9]+)"), "\\1").toInt();
|
||||
|
||||
int letter;
|
||||
for(letter = 'A'; letter <= 'Z'; letter++) {
|
||||
|
@ -800,8 +802,8 @@ QMap<QString, QList<int> > Utils::findRunningProcess(QStringList names)
|
|||
QStringList k(processlist.keys());
|
||||
#if defined(Q_OS_WIN32)
|
||||
// the process name might be truncated. Allow the extension to be partial.
|
||||
int index = k.indexOf(QRegExp(names.at(i) + "(\\.(e(x(e?)?)?)?)?",
|
||||
Qt::CaseInsensitive));
|
||||
int index = k.indexOf(QRegularExpression(names.at(i) + "(\\.(e(x(e?)?)?)?)?",
|
||||
QRegularExpression::CaseInsensitiveOption));
|
||||
#else
|
||||
int index = k.indexOf(names.at(i));
|
||||
#endif
|
||||
|
|
|
@ -557,7 +557,7 @@ QStringList Config::findLanguageFiles()
|
|||
QDir resDir(":/lang");
|
||||
fileNames += resDir.entryList(QStringList("*.qm"), QDir::Files, QDir::Name);
|
||||
|
||||
QRegExp exp("^rbutil_(.*)\\.qm");
|
||||
QRegularExpression exp("^rbutil_(.*)\\.qm");
|
||||
for(int i = 0; i < fileNames.size(); i++) {
|
||||
QString a = fileNames.at(i);
|
||||
a.replace(exp, "\\1");
|
||||
|
|
|
@ -60,10 +60,10 @@ QString Changelog::parseChangelogFile(QString filename)
|
|||
line = c.readLine();
|
||||
text.append("<ul>");
|
||||
while(line.startsWith("*")) {
|
||||
QString t = line.remove(QRegExp("^\\*"));
|
||||
t.replace(QRegExp("FS#(\\d+)"),
|
||||
QString t = line.remove(QRegularExpression("^\\*"));
|
||||
t.replace(QRegularExpression("FS#(\\d+)"),
|
||||
"<a href='http://www.rockbox.org/tracker/task/\\1'>FS#\\1</a>");
|
||||
t.replace(QRegExp("G#(\\d+)"),
|
||||
t.replace(QRegularExpression("G#(\\d+)"),
|
||||
"<a href='http://gerrit.rockbox.org/r/\\1'>G#\\1</a>");
|
||||
text.append(QString("<li>%1</li>").arg(t));
|
||||
line = c.readLine();
|
||||
|
|
|
@ -334,7 +334,7 @@ void SelectiveInstallWidget::installBootloader(void)
|
|||
PlayerBuildInfo::DisplayName).toString()
|
||||
+ " Firmware Backup";
|
||||
// remove invalid character(s)
|
||||
targetFolder.remove(QRegExp("[:/]"));
|
||||
targetFolder.remove(QRegularExpression("[:/]"));
|
||||
if(QMessageBox::question(this, tr("Create Bootloader backup"),
|
||||
tr("You can create a backup of the original bootloader "
|
||||
"file. Press \"Yes\" to select an output folder on your "
|
||||
|
|
|
@ -58,7 +58,7 @@ void InstallTalkWindow::saveSettings(void)
|
|||
for(int i = 0; i < si.size(); i++) {
|
||||
if(si.at(i).column() == 0) {
|
||||
QString current = fsm->filePath(si.at(i));
|
||||
foldersToTalk.append(current.remove(QRegExp("^" + mp)));
|
||||
foldersToTalk.append(current.remove(QRegularExpression("^" + mp)));
|
||||
}
|
||||
}
|
||||
RbSettings::setValue(RbSettings::TalkFolders, foldersToTalk);
|
||||
|
|
|
@ -303,8 +303,8 @@ void RbUtilQt::about()
|
|||
while(!r.atEnd()) {
|
||||
QString line = r.readLine();
|
||||
// filter out header.
|
||||
line.remove(QRegExp("^ +.*"));
|
||||
line.remove(QRegExp("^People.*"));
|
||||
line.remove(QRegularExpression("^ +.*"));
|
||||
line.remove(QRegularExpression("^People.*"));
|
||||
about.browserCredits->append(line);
|
||||
}
|
||||
credits.close();
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include <QDialog>
|
||||
#include <QDir>
|
||||
#include <QRegularExpression>
|
||||
#include "sysinfo.h"
|
||||
#include "ui_sysinfofrm.h"
|
||||
#include "system.h"
|
||||
|
@ -77,7 +78,7 @@ QString Sysinfo::getInfo(Sysinfo::InfoType type)
|
|||
info += "</table>";
|
||||
info += "<hr/>";
|
||||
if(type == InfoText) {
|
||||
info.replace(QRegExp("(<[^>]+>)+"),"\n");
|
||||
info.replace(QRegularExpression("(<[^>]+>)+"), "\n");
|
||||
}
|
||||
|
||||
return info;
|
||||
|
|
Loading…
Reference in a new issue