mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-08-01 09:04:13 +02:00
Guard Qt6-only deprecation replacements for Qt5 compatibility
Three deprecated APIs have replacements that only exist in newer Qt6: - QLocale::nativeCountryName() -> nativeTerritoryName() (Qt 6.2) - QDomDocument::setContent() overload -> ParseResult (Qt 6.5) - qt_ntfs_permission_lookup -> QNtfsPermissionCheckGuard RAII (Qt 6.6) Each is wrapped in QT_VERSION_CHECK so Qt5 keeps the old path. Clears 4 -Wdeprecated-declarations warnings.
This commit is contained in:
@@ -143,8 +143,12 @@ ElementsLocation ECHSFileToFile::copyElement(ElementsLocation &source, ElementsL
|
|||||||
//On windows when user drag and drop an element from the common elements collection
|
//On windows when user drag and drop an element from the common elements collection
|
||||||
//to the custom elements collection, the element file stay in read only mode, and so
|
//to the custom elements collection, the element file stay in read only mode, and so
|
||||||
//user can't save the element
|
//user can't save the element
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
|
||||||
|
QNtfsPermissionCheckGuard ntfs_guard;
|
||||||
|
#else
|
||||||
extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
|
extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
|
||||||
qt_ntfs_permission_lookup++;
|
qt_ntfs_permission_lookup++;
|
||||||
|
#endif
|
||||||
QFile file(destination.fileSystemPath() % "/" % new_elmt_name);
|
QFile file(destination.fileSystemPath() % "/" % new_elmt_name);
|
||||||
if (!file.isWritable()) {
|
if (!file.isWritable()) {
|
||||||
if (!file.setPermissions(file.permissions() | QFileDevice::WriteUser)) {
|
if (!file.setPermissions(file.permissions() | QFileDevice::WriteUser)) {
|
||||||
@@ -152,7 +156,9 @@ ElementsLocation ECHSFileToFile::copyElement(ElementsLocation &source, ElementsL
|
|||||||
<< " in ECHSFileToFile::copyElement";
|
<< " in ECHSFileToFile::copyElement";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
|
||||||
qt_ntfs_permission_lookup--;
|
qt_ntfs_permission_lookup--;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
return ElementsLocation (destination.fileSystemPath() % "/" % new_elmt_name);
|
return ElementsLocation (destination.fileSystemPath() % "/" % new_elmt_name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -422,6 +422,14 @@ int checkOneElement(const QString &path)
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
QDomDocument doc;
|
QDomDocument doc;
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
||||||
|
if (const auto result = doc.setContent(&file); !result) {
|
||||||
|
file.close();
|
||||||
|
out << "FAIL " << path << " (XML error line "
|
||||||
|
<< result.errorLine << ": " << result.errorMessage << ")\n";
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
#else
|
||||||
QString error;
|
QString error;
|
||||||
int line = 0;
|
int line = 0;
|
||||||
if (!doc.setContent(&file, &error, &line)) {
|
if (!doc.setContent(&file, &error, &line)) {
|
||||||
@@ -430,6 +438,7 @@ int checkOneElement(const QString &path)
|
|||||||
<< line << ": " << error << ")\n";
|
<< line << ": " << error << ")\n";
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
const QDomElement root = doc.documentElement();
|
const QDomElement root = doc.documentElement();
|
||||||
|
|||||||
@@ -150,7 +150,11 @@ void MachineInfo::send_info_to_debug()
|
|||||||
qInfo()<< "";
|
qInfo()<< "";
|
||||||
|
|
||||||
qInfo()<< " OS System language:"<< QLocale::system().name();
|
qInfo()<< " OS System language:"<< QLocale::system().name();
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
|
||||||
|
qInfo()<< " OS System Native Country Name:"<< QLocale::system().nativeTerritoryName();
|
||||||
|
#else
|
||||||
qInfo()<< " OS System Native Country Name:"<< QLocale::system().nativeCountryName();
|
qInfo()<< " OS System Native Country Name:"<< QLocale::system().nativeCountryName();
|
||||||
|
#endif
|
||||||
qInfo()<< " OS System Native Language Name:"<< QLocale::system().nativeLanguageName();
|
qInfo()<< " OS System Native Language Name:"<< QLocale::system().nativeLanguageName();
|
||||||
qInfo()<< "";
|
qInfo()<< "";
|
||||||
qInfo()<< " System language defined in QET configuration:"<< QString(QETApp::langFromSetting().toLatin1());
|
qInfo()<< " System language defined in QET configuration:"<< QString(QETApp::langFromSetting().toLatin1());
|
||||||
|
|||||||
Reference in New Issue
Block a user