qt_deviceconfig.cpp: Use QString::split with Qt >= 5.14
This commit is contained in:
@@ -282,20 +282,30 @@ DeviceConfig::ProcessConfig(void *dc, const void *c, const bool is_dep)
|
||||
fileField->setObjectName(config->name);
|
||||
fileField->setFileName(selected);
|
||||
/* Get the actually used part of the filter */
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||
QString filter = QString(config->file_filter).left(static_cast<int>(strcspn(config->file_filter, "|")));
|
||||
#else
|
||||
QString filter = QString(config->file_filter).split("|").at(0);
|
||||
#endif
|
||||
/* Extract the description and the extension list */
|
||||
QRegularExpressionMatch match = QRegularExpression("(.+) \\((.+)\\)$").match(filter);
|
||||
QString description = match.captured(1);
|
||||
QString extensions = match.captured(2);
|
||||
QStringList extensionList;
|
||||
/* Split the extension list up and strip the filename globs */
|
||||
QRegularExpression re("\\*\\.(.*)");
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||
QStringList extensionList;
|
||||
int i = 0;
|
||||
while (extensions.section(' ', i, i) != "") {
|
||||
QString extension = re.match(extensions.section(' ', i, i)).captured(1);
|
||||
extensionList.append(extension);
|
||||
i++;
|
||||
}
|
||||
#else
|
||||
QStringList extensionList = extensions.split(" ");
|
||||
for (int i = 0; i < extensionList.count(); i++)
|
||||
extensionList[i] = re.match(extensionList[i]).captured(1);
|
||||
#endif
|
||||
fileField->setFilter(tr(description.toUtf8().constData()) % util::DlgFilter(extensionList) % tr("All files") % util::DlgFilter({ "*" }, true));
|
||||
this->ui->formLayout->addRow(tr(config->description), fileField);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user