Fix QSqlQuery copy and Qt6 deprecation issues
- Suppress deprecated QSqlQuery copy-constructor warning locally in NSqlQuery::operator= - Replace qChecksum overload with QByteArrayView - Use QTimeZone::utc(), QLibraryInfo::path(), check QTranslator::load return values - Replace deprecated operator+ for key combinations and other small Qt6 fixes Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
1 parent
f7c94bed68
commit
e1b5c2f918
7 files changed
+36
-20
No files matched your search
@@ -47,7 +47,8 @@ QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId)
|
|||||||
prefix.truncate(6);
|
prefix.truncate(6);
|
||||||
|
|
||||||
QByteArray idc = id.toUtf8();
|
QByteArray idc = id.toUtf8();
|
||||||
quint16 idNum = qChecksum(idc.constData(), idc.size());
|
// Use QByteArrayView overload to avoid deprecated qChecksum overload
|
||||||
|
quint16 idNum = qChecksum(QByteArrayView(idc));
|
||||||
socketName = QLatin1String("qtsingleapp-") + prefix
|
socketName = QLatin1String("qtsingleapp-") + prefix
|
||||||
+ QLatin1Char('-') + QString::number(idNum, 16);
|
+ QLatin1Char('-') + QString::number(idNum, 16);
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ NSqlQuery::NSqlQuery(const QString &query, const QSqlDatabase &db, NGL::INGLLogg
|
|||||||
void NSqlQuery::addBindValue(const QVariant &val, QSql::ParamType paramType)
|
void NSqlQuery::addBindValue(const QVariant &val, QSql::ParamType paramType)
|
||||||
{
|
{
|
||||||
DB_TRACE;
|
DB_TRACE;
|
||||||
DEBUG_LOG(mLogger) << "type: " << val.type() << " paramType: " << paramType;
|
DEBUG_LOG(mLogger) << "type: " << QString::fromLatin1(val.typeName()) << " paramType: " << paramType;
|
||||||
QSqlQuery::addBindValue(val, paramType);
|
QSqlQuery::addBindValue(val, paramType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,14 +74,14 @@ int NSqlQuery::at() const
|
|||||||
void NSqlQuery::bindValue(const QString &placeholder, const QVariant &val, QSql::ParamType paramType)
|
void NSqlQuery::bindValue(const QString &placeholder, const QVariant &val, QSql::ParamType paramType)
|
||||||
{
|
{
|
||||||
DB_TRACE;
|
DB_TRACE;
|
||||||
TRACE_LOG(mLogger) << "placeholder: " << placeholder << " type: " << val.type() << " paramType: " << paramType;
|
TRACE_LOG(mLogger) << "placeholder: " << placeholder << " type: " << QString::fromLatin1(val.typeName()) << " paramType: " << paramType;
|
||||||
QSqlQuery::bindValue(placeholder, val, paramType);
|
QSqlQuery::bindValue(placeholder, val, paramType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NSqlQuery::bindValue(int pos, const QVariant &val, QSql::ParamType paramType)
|
void NSqlQuery::bindValue(int pos, const QVariant &val, QSql::ParamType paramType)
|
||||||
{
|
{
|
||||||
DB_TRACE;
|
DB_TRACE;
|
||||||
TRACE_LOG(mLogger) << "pos: " << pos << " type: " << val.type() << " paramType: " << paramType;
|
TRACE_LOG(mLogger) << "pos: " << pos << " type: " << QString::fromLatin1(val.typeName()) << " paramType: " << paramType;
|
||||||
QSqlQuery::bindValue(pos, val, paramType);
|
QSqlQuery::bindValue(pos, val, paramType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,7 +387,17 @@ QVariant NSqlQuery::value(int index) const
|
|||||||
NSqlQuery &NSqlQuery::operator= (const NSqlQuery &other)
|
NSqlQuery &NSqlQuery::operator= (const NSqlQuery &other)
|
||||||
{
|
{
|
||||||
DB_TRACE
|
DB_TRACE
|
||||||
QSqlQuery::operator= (other);
|
// Use move assignment to avoid deprecated copy-assignment of QSqlQuery.
|
||||||
|
// The QSqlQuery copy constructor is deprecated; silence the warning locally.
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
#endif
|
||||||
|
QSqlQuery tmp(other);
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
QSqlQuery::operator=(std::move(tmp));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
#include <QTimeZone>
|
||||||
|
|
||||||
namespace DTG
|
namespace DTG
|
||||||
{
|
{
|
||||||
@@ -272,7 +273,7 @@ static DTGValidation validate18(const QString &input, QDateTime &dt)
|
|||||||
|
|
||||||
const int day = input.left(2).toInt();
|
const int day = input.left(2).toInt();
|
||||||
const int year = input.mid(16, 2).toInt() + 2000;
|
const int year = input.mid(16, 2).toInt() + 2000;
|
||||||
dt = QDateTime(QDate(year, month + 1, day), QTime(hh, mm, ss), Qt::UTC);
|
dt = QDateTime(QDate(year, month + 1, day), QTime(hh, mm, ss), QTimeZone::utc());
|
||||||
if (!dt.isValid())
|
if (!dt.isValid())
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -313,7 +314,7 @@ static DTGValidation validate7(const QString &input, QDateTime &dt)
|
|||||||
|
|
||||||
const int day = input.left(2).toInt();
|
const int day = input.left(2).toInt();
|
||||||
const QDate curDate = QDate::currentDate();
|
const QDate curDate = QDate::currentDate();
|
||||||
dt = QDateTime(QDate(curDate.year(), curDate.month(), day), QTime(hh, mm), Qt::UTC);
|
dt = QDateTime(QDate(curDate.year(), curDate.month(), day), QTime(hh, mm), QTimeZone::utc());
|
||||||
if (!dt.isValid())
|
if (!dt.isValid())
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -198,8 +198,11 @@ bool setTranslationLocale(const QByteArray &isoCode, const QString &qmPrefix)
|
|||||||
QStringList isoCodeList(QString::fromLatin1(isoCode).split(QLatin1Char('_')));
|
QStringList isoCodeList(QString::fromLatin1(isoCode).split(QLatin1Char('_')));
|
||||||
if (isoCodeList.count() == 2)
|
if (isoCodeList.count() == 2)
|
||||||
{
|
{
|
||||||
s_translationData->qtTranslator.load(QLatin1String("qt_") + isoCodeList.at(0),
|
if (!s_translationData->qtTranslator.load(QLatin1String("qt_") + isoCodeList.at(0),
|
||||||
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
QLibraryInfo::path(QLibraryInfo::TranslationsPath)))
|
||||||
|
{
|
||||||
|
qWarning("qtTranslator.load failed for %s", qPrintable(isoCodeList.at(0)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -207,8 +210,10 @@ bool setTranslationLocale(const QByteArray &isoCode, const QString &qmPrefix)
|
|||||||
qWarning() << "translation iso code not compatible with qt translations";
|
qWarning() << "translation iso code not compatible with qt translations";
|
||||||
}
|
}
|
||||||
|
|
||||||
s_translationData->kdReportsTranslator.load(kdReportsQmPath);
|
if (!s_translationData->kdReportsTranslator.load(kdReportsQmPath))
|
||||||
s_translationData->ltsTranslator.load(ltsQmPath);
|
qWarning("kdReportsTranslator.load failed: %s", qPrintable(kdReportsQmPath));
|
||||||
|
if (!s_translationData->ltsTranslator.load(ltsQmPath))
|
||||||
|
qWarning("ltsTranslator.load failed: %s", qPrintable(ltsQmPath));
|
||||||
s_translationData->dynamicTranslator.isoCodeChanged(isoCode);
|
s_translationData->dynamicTranslator.isoCodeChanged(isoCode);
|
||||||
|
|
||||||
return !s_translationData->ltsTranslator.isEmpty();
|
return !s_translationData->ltsTranslator.isEmpty();
|
||||||
|
|||||||
@@ -20,12 +20,10 @@ NGLMainWindow::NGLMainWindow(QWidget *parent)
|
|||||||
{
|
{
|
||||||
m_menu[QLatin1String("File")] = m_menuBar->addMenu(tr("File"));
|
m_menu[QLatin1String("File")] = m_menuBar->addMenu(tr("File"));
|
||||||
m_fileActionBefore = m_menu[QLatin1String("File")]->addSeparator();
|
m_fileActionBefore = m_menu[QLatin1String("File")]->addSeparator();
|
||||||
m_menu[QLatin1String("File")]->addAction(QIcon(QLatin1String(":/icons/16x16/application-exit.png")), tr("Quit"),
|
m_menu[QLatin1String("File")]->addAction(QIcon(QLatin1String(":/icons/16x16/application-exit.png")), tr("Quit"), QKeySequence(tr("Ctrl+q")), this, &NGLMainWindow::onExit);
|
||||||
this, &NGLMainWindow::onExit, QKeySequence(tr("Ctrl+q")));
|
|
||||||
|
|
||||||
m_menu[QLatin1String("Help")] = m_menuBar->addMenu(tr("Help"));
|
m_menu[QLatin1String("Help")] = m_menuBar->addMenu(tr("Help"));
|
||||||
m_menu[QLatin1String("Help")]->addAction(QIcon(QLatin1String(":/icons/16x16/help-contents.png")),
|
m_menu[QLatin1String("Help")]->addAction(QIcon(QLatin1String(":/icons/16x16/help-contents.png")), tr("Help"), QKeySequence(tr("F1")), this, &NGLMainWindow::onHelpIndex);
|
||||||
tr("Help"), this, &NGLMainWindow::onHelpIndex, QKeySequence(tr("F1")));
|
|
||||||
m_menu[QLatin1String("Help")]->addSeparator();
|
m_menu[QLatin1String("Help")]->addSeparator();
|
||||||
m_menu[QLatin1String("Help")]->addAction(QIcon(QLatin1String(":/icons/16x16/help-about.png")),
|
m_menu[QLatin1String("Help")]->addAction(QIcon(QLatin1String(":/icons/16x16/help-about.png")),
|
||||||
tr("About"), this, &NGLMainWindow::onHelpAbout);
|
tr("About"), this, &NGLMainWindow::onHelpAbout);
|
||||||
@@ -64,7 +62,7 @@ void NGLMainWindow::onInvokeHelp(const QString &helpContext)
|
|||||||
<< QCoreApplication::applicationDirPath() + QLatin1String("/../help/scms/") + fn
|
<< QCoreApplication::applicationDirPath() + QLatin1String("/../help/scms/") + fn
|
||||||
<< QLatin1String("-enableRemoteControl");
|
<< QLatin1String("-enableRemoteControl");
|
||||||
DEBUG_LOG(m_logger) << "Attempting to invoke help at URL: " << args.join(QLatin1String(" ")) ;
|
DEBUG_LOG(m_logger) << "Attempting to invoke help at URL: " << args.join(QLatin1String(" ")) ;
|
||||||
m_helpProcess->start(QLibraryInfo::location(QLibraryInfo::BinariesPath) + QLatin1String("/assistant"), args);
|
m_helpProcess->start(QLibraryInfo::path(QLibraryInfo::BinariesPath) + QLatin1String("/assistant"), args);
|
||||||
if (!m_helpProcess->waitForStarted())
|
if (!m_helpProcess->waitForStarted())
|
||||||
{
|
{
|
||||||
ERROR_LOG(m_logger) << "Could not start help browser (error: "
|
ERROR_LOG(m_logger) << "Could not start help browser (error: "
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ void NGLStandardButton::setType(StandardButton t)
|
|||||||
case Send:
|
case Send:
|
||||||
iconName = ":icons/svg/messages.svg";
|
iconName = ":icons/svg/messages.svg";
|
||||||
text = tr("&Send");
|
text = tr("&Send");
|
||||||
key = QKeySequence(Qt::CTRL + Qt::Key_Return);
|
key = QKeySequence(Qt::CTRL | Qt::Key_Return);
|
||||||
objectName = "btnSend";
|
objectName = "btnSend";
|
||||||
break;
|
break;
|
||||||
case New:
|
case New:
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
#include <QMetaType>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -726,7 +727,7 @@ QSqlRecord QInformixResult::record() const
|
|||||||
f.setType(qSqlType2Variant(sqlType));
|
f.setType(qSqlType2Variant(sqlType));
|
||||||
f.setSqlType(sqlType);
|
f.setSqlType(sqlType);
|
||||||
|
|
||||||
if (f.type() == QVariant::Invalid)
|
if (qSqlType2Variant(sqlType) == QVariant::Invalid)
|
||||||
qWarning("QInformixResult::record(): Unknown datatype %s", typeName);
|
qWarning("QInformixResult::record(): Unknown datatype %s", typeName);
|
||||||
|
|
||||||
info.append(f);
|
info.append(f);
|
||||||
@@ -806,7 +807,7 @@ bool bindValues(T *prep, const QVector<QVariant> &boundValues, const QInformixRe
|
|||||||
const QVariant &val = boundValues.at(i);
|
const QVariant &val = boundValues.at(i);
|
||||||
ITValue *param = prep->Param(i);
|
ITValue *param = prep->Param(i);
|
||||||
|
|
||||||
if (val.type() == QVariant::ByteArray)
|
if (val.metaType().id() == QMetaType::QByteArray)
|
||||||
{
|
{
|
||||||
ITDatum *lobj;
|
ITDatum *lobj;
|
||||||
|
|
||||||
@@ -870,7 +871,7 @@ bool bindValues(T *prep, const QVector<QVariant> &boundValues, const QInformixRe
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
f.setType(val.type());
|
// setValue() already sets the type appropriately
|
||||||
f.setValue(val);
|
f.setValue(val);
|
||||||
if (!param->FromPrintable(p->driverPrivate->toInformixEncoding(driver->formatValue(f))))
|
if (!param->FromPrintable(p->driverPrivate->toInformixEncoding(driver->formatValue(f))))
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in new issue
Block a user