Merge story/release-validation-scope
Bring the validation-scope line (in-tree Jenkins CI copy, lcov coverage wiring, step-by-step release-scope README, TetraIF unit tests, the LogView runtime icon/resource fix, Dockerfile, rpmbuild and the new_docker_build.sh driver with the DEB output path) on top of the XmlPatterns branch pruned to the Release 2 scope. Conflict policy: - Out-of-scope targets/modules: keep the prune (deletion wins). - In-scope files that validation had deleted: restored from story/release-2-cleanup (the Release 2 closure, with the pruned-module guards). - In-scope sources carrying migration work: XmlPatterns versions (Qt XmlPatterns rework on QDomDocument, DDS member and logger fixes, first-build fixes). - Scope-aware CMakeLists (top level, PluginInterfaces, LtsWidgets) and .envrc: story/release-2-cleanup / ours versions.
This commit is contained in:
commit
cfe15c72c4
521 files changed
+37159
-36635
No files matched your search
@@ -7,6 +7,9 @@
|
||||
#
|
||||
|
||||
# LtsUtilsGuiDds is needed by LtsMultiMonitor regardless of BUILD_RTI
|
||||
ADD_SUBDIRECTORY(LtsUtilsGuiDds)
|
||||
# Exclude from release scope - requires DDS headers, only used by LtsMultiMonitor
|
||||
if(NOT RELEASE_BUILD)
|
||||
ADD_SUBDIRECTORY(LtsUtilsGuiDds)
|
||||
endif()
|
||||
ADD_SUBDIRECTORY(ConnectDialog)
|
||||
ADD_SUBDIRECTORY(StyleManager)
|
||||
-6
@@ -45,9 +45,6 @@ if(QT6_GUI_AVAILABLE)
|
||||
Qt6::Svg
|
||||
)
|
||||
endif()
|
||||
IF(BUILD_RTI)
|
||||
TARGET_LINK_LIBRARIES(LtsUtilsGuiDds PUBLIC ddscore)
|
||||
ENDIF(BUILD_RTI)
|
||||
NGL_TARGET_COMPILE_DEFINITIONS(LtsUtilsGuiDds
|
||||
PUBLIC
|
||||
REQUEST_HELPER_WITH_GUI
|
||||
@@ -80,6 +77,3 @@ NGL_TARGET_LINK_LIBRARIES(LtsUtilsDds
|
||||
PUBLIC
|
||||
Qt6::Core
|
||||
)
|
||||
IF(BUILD_RTI)
|
||||
TARGET_LINK_LIBRARIES(LtsUtilsDds PUBLIC ddscore)
|
||||
ENDIF(BUILD_RTI)
|
||||
+57
-57
@@ -13,8 +13,8 @@
|
||||
namespace LtsUtils
|
||||
{
|
||||
|
||||
QIcon iconFromSvg(const QByteArray& svgData, QSize iconSize)
|
||||
{
|
||||
QIcon iconFromSvg(const QByteArray &svgData, QSize iconSize)
|
||||
{
|
||||
QSvgRenderer renderer(svgData);
|
||||
QPixmap p(iconSize);
|
||||
p.fill(Qt::transparent);
|
||||
@@ -23,60 +23,60 @@ QIcon iconFromSvg(const QByteArray& svgData, QSize iconSize)
|
||||
painter.end();
|
||||
|
||||
return {p};
|
||||
}
|
||||
}
|
||||
|
||||
QIcon iconFromSvg(const QString& svgFilename, QSize iconSize)
|
||||
{
|
||||
QIcon iconFromSvg(const QString &svgFilename, QSize iconSize)
|
||||
{
|
||||
QFile f(svgFilename);
|
||||
if (!f.open(QIODevice::ReadOnly))
|
||||
return {};
|
||||
return {};
|
||||
return iconFromSvg(f.readAll(), iconSize);
|
||||
}
|
||||
}
|
||||
|
||||
QPixmap pixmapFromIcon(const QIcon& icon, QSize iconSize)
|
||||
{
|
||||
QPixmap pixmapFromIcon(const QIcon &icon, QSize iconSize)
|
||||
{
|
||||
return icon.pixmap(iconSize).scaled(100, 100, Qt::AspectRatioMode::IgnoreAspectRatio);
|
||||
}
|
||||
}
|
||||
|
||||
QPixmap pixmapFromSvg(const QString& svgFilename, QSize iconSize)
|
||||
{
|
||||
QPixmap pixmapFromSvg(const QString &svgFilename, QSize iconSize)
|
||||
{
|
||||
return pixmapFromIcon(iconFromSvg(svgFilename, iconSize), iconSize);
|
||||
}
|
||||
}
|
||||
|
||||
QPixmap getPixmap(const std::vector<uint8_t>& data)
|
||||
{
|
||||
QPixmap getPixmap(const std::vector<uint8_t> &data)
|
||||
{
|
||||
if (data.size() == 0)
|
||||
return QPixmap();
|
||||
return QPixmap();
|
||||
|
||||
return getPixmap(QByteArray(reinterpret_cast<const char*>(&data.at(0)), data.size()));
|
||||
}
|
||||
return getPixmap(QByteArray(reinterpret_cast<const char *>(&data.at(0)), data.size()));
|
||||
}
|
||||
|
||||
QPixmap getPixmap(const QByteArray& data)
|
||||
{
|
||||
QPixmap getPixmap(const QByteArray &data)
|
||||
{
|
||||
return QPixmap::fromImage(QImage::fromData(data));
|
||||
}
|
||||
}
|
||||
|
||||
QImage getImage(const std::vector<uint8_t>& data)
|
||||
{
|
||||
QImage getImage(const std::vector<uint8_t> &data)
|
||||
{
|
||||
if (data.size() == 0)
|
||||
return QImage();
|
||||
return QImage();
|
||||
|
||||
return getImage(QByteArray(reinterpret_cast<const char*>(&data.at(0)), data.size()));
|
||||
}
|
||||
return getImage(QByteArray(reinterpret_cast<const char *>(&data.at(0)), data.size()));
|
||||
}
|
||||
|
||||
QImage getImage(const QByteArray& data)
|
||||
{
|
||||
QImage getImage(const QByteArray &data)
|
||||
{
|
||||
return QImage::fromData(data);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void setIf(bool* boolPtr, bool val)
|
||||
{
|
||||
static inline void setIf(bool *boolPtr, bool val)
|
||||
{
|
||||
if (boolPtr)
|
||||
*boolPtr = val;
|
||||
}
|
||||
*boolPtr = val;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> fromPixmap(const QPixmap& pixmap, bool* bIsPng)
|
||||
{
|
||||
std::vector<uint8_t> fromPixmap(const QPixmap &pixmap, bool *bIsPng)
|
||||
{
|
||||
QBuffer buf;
|
||||
buf.open(QIODevice::WriteOnly);
|
||||
pixmap.save(&buf, "PNG");
|
||||
@@ -87,22 +87,22 @@ std::vector<uint8_t> fromPixmap(const QPixmap& pixmap, bool* bIsPng)
|
||||
|
||||
if (ba.size() > 10240 && !pixmap.hasAlpha() && !pixmap.hasAlphaChannel())
|
||||
{
|
||||
QBuffer buf2;
|
||||
buf2.open(QIODevice::WriteOnly);
|
||||
pixmap.save(&buf2, "JPG");
|
||||
buf2.close();
|
||||
if (buf2.buffer().size() < buf.buffer().size())
|
||||
{
|
||||
setIf(bIsPng, false);
|
||||
ba = buf2.buffer();
|
||||
}
|
||||
QBuffer buf2;
|
||||
buf2.open(QIODevice::WriteOnly);
|
||||
pixmap.save(&buf2, "JPG");
|
||||
buf2.close();
|
||||
if (buf2.buffer().size() < buf.buffer().size())
|
||||
{
|
||||
setIf(bIsPng, false);
|
||||
ba = buf2.buffer();
|
||||
}
|
||||
}
|
||||
|
||||
return convert<std::vector<uint8_t>>(ba);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<uint8_t> fromImage(const QImage& image, bool* bIsPng)
|
||||
{
|
||||
std::vector<uint8_t> fromImage(const QImage &image, bool *bIsPng)
|
||||
{
|
||||
QBuffer buf;
|
||||
buf.open(QIODevice::WriteOnly);
|
||||
image.save(&buf, "PNG");
|
||||
@@ -112,18 +112,18 @@ std::vector<uint8_t> fromImage(const QImage& image, bool* bIsPng)
|
||||
setIf(bIsPng, true);
|
||||
if ((ba.size() > 10240 && !image.hasAlphaChannel()) || ba.size() > 1024 * 1024)
|
||||
{
|
||||
QBuffer buf2;
|
||||
buf2.open(QIODevice::WriteOnly);
|
||||
image.save(&buf2, "JPG");
|
||||
buf2.close();
|
||||
if (buf2.buffer().size() < buf.buffer().size())
|
||||
{
|
||||
setIf(bIsPng, false);
|
||||
ba = buf2.buffer();
|
||||
}
|
||||
QBuffer buf2;
|
||||
buf2.open(QIODevice::WriteOnly);
|
||||
image.save(&buf2, "JPG");
|
||||
buf2.close();
|
||||
if (buf2.buffer().size() < buf.buffer().size())
|
||||
{
|
||||
setIf(bIsPng, false);
|
||||
ba = buf2.buffer();
|
||||
}
|
||||
}
|
||||
|
||||
return convert<std::vector<uint8_t>>(ba);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace LtsUtils
|
||||
+10
-10
@@ -17,15 +17,15 @@ class QIcon;
|
||||
namespace LtsUtils
|
||||
{
|
||||
|
||||
LTSUTILSCORE_EXPORT QPixmap getPixmap(const std::vector<uint8_t>& data);
|
||||
LTSUTILSCORE_EXPORT QPixmap getPixmap(const QByteArray& data);
|
||||
LTSUTILSCORE_EXPORT QImage getImage(const std::vector<uint8_t>& data);
|
||||
LTSUTILSCORE_EXPORT QImage getImage(const QByteArray& data);
|
||||
LTSUTILSCORE_EXPORT QIcon iconFromSvg(const QByteArray& svgData, QSize iconSize = QSize(100, 100));
|
||||
LTSUTILSCORE_EXPORT QIcon iconFromSvg(const QString& svgFilename, QSize iconSize = QSize(100, 100));
|
||||
LTSUTILSCORE_EXPORT QPixmap pixmapFromIcon(const QIcon& icon, QSize iconSize = QSize(100, 100));
|
||||
LTSUTILSCORE_EXPORT QPixmap pixmapFromSvg(const QString& svgFilename, QSize iconSize = QSize(100, 100));
|
||||
LTSUTILSCORE_EXPORT std::vector<uint8_t> fromPixmap(const QPixmap& pixmap, bool* bIsPng = nullptr);
|
||||
LTSUTILSCORE_EXPORT std::vector<uint8_t> fromImage(const QImage& image, bool* bIsPng = nullptr);
|
||||
LTSUTILSCORE_EXPORT QPixmap getPixmap(const std::vector<uint8_t> &data);
|
||||
LTSUTILSCORE_EXPORT QPixmap getPixmap(const QByteArray &data);
|
||||
LTSUTILSCORE_EXPORT QImage getImage(const std::vector<uint8_t> &data);
|
||||
LTSUTILSCORE_EXPORT QImage getImage(const QByteArray &data);
|
||||
LTSUTILSCORE_EXPORT QIcon iconFromSvg(const QByteArray &svgData, QSize iconSize = QSize(100, 100));
|
||||
LTSUTILSCORE_EXPORT QIcon iconFromSvg(const QString &svgFilename, QSize iconSize = QSize(100, 100));
|
||||
LTSUTILSCORE_EXPORT QPixmap pixmapFromIcon(const QIcon &icon, QSize iconSize = QSize(100, 100));
|
||||
LTSUTILSCORE_EXPORT QPixmap pixmapFromSvg(const QString &svgFilename, QSize iconSize = QSize(100, 100));
|
||||
LTSUTILSCORE_EXPORT std::vector<uint8_t> fromPixmap(const QPixmap &pixmap, bool *bIsPng = nullptr);
|
||||
LTSUTILSCORE_EXPORT std::vector<uint8_t> fromImage(const QImage &image, bool *bIsPng = nullptr);
|
||||
|
||||
} // namespace LtsUtils
|
||||
+1
-1
@@ -9,4 +9,4 @@
|
||||
#define LTSUTILSGUIDDS_EXPORT
|
||||
#define LTSUTILSGUIDDS_NO_EXPORT
|
||||
|
||||
#endif // LTSUTILSDDS_EXPORT_H
|
||||
#endif // LTSUTILSDDS_EXPORT_H
|
||||
+113
-110
@@ -18,72 +18,76 @@
|
||||
|
||||
namespace LtsUtils
|
||||
{
|
||||
bool RequestHelper::s_debug = false;
|
||||
bool RequestHelper::s_debug = false;
|
||||
|
||||
RequestHelper::RequestHelper(QObject* parent, bool quiet,
|
||||
RequestHelper::RequestHelper(QObject *parent,
|
||||
bool quiet,
|
||||
|
||||
const std::function<void(void)>& success, const std::function<void(void)>& failure)
|
||||
: QObject(parent), m_failed(false), m_repliedId(-1), m_quiet(quiet), m_blockingCall(true), m_successFn(success),
|
||||
m_failureFn(failure)
|
||||
{
|
||||
const std::function<void(void)> &success,
|
||||
const std::function<void(void)> &failure)
|
||||
: QObject(parent)
|
||||
, m_failed(false)
|
||||
, m_repliedId(-1)
|
||||
, m_quiet(quiet)
|
||||
, m_blockingCall(true)
|
||||
, m_successFn(success)
|
||||
, m_failureFn(failure)
|
||||
{
|
||||
connect(this, &RequestHelper::signalSuccess, this, m_successFn, Qt::QueuedConnection);
|
||||
connect(this, &RequestHelper::signalFailed, this, m_failureFn, Qt::QueuedConnection);
|
||||
|
||||
if (s_debug)
|
||||
{
|
||||
QTimer* t = new QTimer(this);
|
||||
t->setInterval(2000);
|
||||
t->setSingleShot(true);
|
||||
connect(this, &RequestHelper::signalNextRequest, t, static_cast<void (QTimer::*)(void)>(&QTimer::start));
|
||||
connect(t, &QTimer::timeout, this, &RequestHelper::slotNextRequest, Qt::QueuedConnection);
|
||||
QTimer *t = new QTimer(this);
|
||||
t->setInterval(2000);
|
||||
t->setSingleShot(true);
|
||||
connect(this, &RequestHelper::signalNextRequest, t, static_cast<void (QTimer::*)(void)>(&QTimer::start));
|
||||
connect(t, &QTimer::timeout, this, &RequestHelper::slotNextRequest, Qt::QueuedConnection);
|
||||
}
|
||||
else
|
||||
{
|
||||
connect(this, &RequestHelper::signalNextRequest, this, &RequestHelper::slotNextRequest, Qt::QueuedConnection
|
||||
connect(this, &RequestHelper::signalNextRequest, this, &RequestHelper::slotNextRequest, Qt::QueuedConnection
|
||||
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RequestHelper::addRequest(const std::function<int64_t()>& requestFunction,
|
||||
const std::function<void(const Core::FunctionReply& baseReply)>& baseReplyHandler)
|
||||
{
|
||||
void RequestHelper::addRequest(const std::function<int64_t()> &requestFunction, const std::function<void(const Core::FunctionReply &baseReply)> &baseReplyHandler)
|
||||
{
|
||||
m_requestFunctions.append(RequestFunctionContainer(requestFunction, baseReplyHandler));
|
||||
}
|
||||
}
|
||||
|
||||
bool RequestHelper::requestReply(const Core::FunctionReply& baseReply)
|
||||
{
|
||||
bool RequestHelper::requestReply(const Core::FunctionReply &baseReply)
|
||||
{
|
||||
// rtiddsgen 7.7 generates plain public members (no getters/setters)
|
||||
const Core::FunctionReplyObject fro(baseReply.id, baseReply.errorString, baseReply.errorParams);
|
||||
return _requestReply(fro, &baseReply);
|
||||
}
|
||||
}
|
||||
|
||||
bool RequestHelper::requestReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
bool RequestHelper::requestReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
return _requestReply(replyObject, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
bool RequestHelper::_requestReply(const Core::FunctionReplyObject& fro, const Core::FunctionReply* baseReply)
|
||||
{
|
||||
bool RequestHelper::_requestReply(const Core::FunctionReplyObject &fro, const Core::FunctionReply *baseReply)
|
||||
{
|
||||
m_errorString = fro.translated();
|
||||
|
||||
#ifdef REQUEST_HELPER_WITH_GUI
|
||||
if (fro.error())
|
||||
{
|
||||
|
||||
if (!m_quiet)
|
||||
if (!m_quiet)
|
||||
{
|
||||
if (m_blockingCall)
|
||||
{
|
||||
if (m_blockingCall)
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(qobject_cast<QWidget*>(parent()), m_errorString,
|
||||
tr("Request failed"));
|
||||
}
|
||||
else
|
||||
{
|
||||
new LtsWidgets::LtsMessageDialogNew(qobject_cast<QWidget*>(parent()), m_errorString,
|
||||
tr("Request failed"));
|
||||
}
|
||||
LtsWidgets::LtsMessageDialog::showMessage(qobject_cast<QWidget *>(parent()), m_errorString, tr("Request failed"));
|
||||
}
|
||||
else
|
||||
{
|
||||
new LtsWidgets::LtsMessageDialogNew(qobject_cast<QWidget *>(parent()), m_errorString, tr("Request failed"));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -91,67 +95,65 @@ bool RequestHelper::_requestReply(const Core::FunctionReplyObject& fro, const Co
|
||||
|
||||
if (m_singleRequestCustomFunctionReply != nullptr)
|
||||
{
|
||||
if (baseReply)
|
||||
m_singleRequestCustomFunctionReply(*baseReply);
|
||||
else
|
||||
m_singleRequestCustomFunctionReply(
|
||||
Core::FunctionReply(fro.id(), fro.str(), fro.args(), fro.additionalInfo()));
|
||||
if (baseReply)
|
||||
m_singleRequestCustomFunctionReply(*baseReply);
|
||||
else
|
||||
m_singleRequestCustomFunctionReply(Core::FunctionReply(fro.id(), fro.str(), fro.args(), fro.additionalInfo()));
|
||||
}
|
||||
|
||||
if (fro.error())
|
||||
{
|
||||
failure();
|
||||
return false;
|
||||
failure();
|
||||
return false;
|
||||
}
|
||||
|
||||
emit signalNextRequest();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool RequestHelper::startSingleRequest(
|
||||
const std::function<int64_t()>& requestFunction,
|
||||
const std::function<void(const Core::FunctionReply& baseReply)>& baseReplyHandler)
|
||||
{
|
||||
bool RequestHelper::startSingleRequest(const std::function<int64_t()> &requestFunction,
|
||||
const std::function<void(const Core::FunctionReply &baseReply)> &baseReplyHandler)
|
||||
{
|
||||
addRequest(requestFunction, baseReplyHandler);
|
||||
return startRequests();
|
||||
}
|
||||
}
|
||||
|
||||
void RequestHelper::failure()
|
||||
{
|
||||
void RequestHelper::failure()
|
||||
{
|
||||
m_failed = true;
|
||||
emit signalFailed();
|
||||
done();
|
||||
}
|
||||
}
|
||||
|
||||
void RequestHelper::done()
|
||||
{
|
||||
void RequestHelper::done()
|
||||
{
|
||||
#ifdef REQUEST_HELPER_WITH_GUI
|
||||
if (!m_quiet)
|
||||
LtsWidgets::LtsGlobalWaitDialog::getInstance()->done();
|
||||
LtsWidgets::LtsGlobalWaitDialog::getInstance()->done();
|
||||
#endif
|
||||
|
||||
m_requestFunctions.clear();
|
||||
m_singleRequestCustomFunctionReply = nullptr;
|
||||
|
||||
if (m_blockingCall)
|
||||
emit signalQuitLoop();
|
||||
emit signalQuitLoop();
|
||||
|
||||
m_blockingCall = true;
|
||||
|
||||
if (!m_blockingCall)
|
||||
deleteLater();
|
||||
}
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
void RequestHelper::slotNextRequest()
|
||||
{
|
||||
void RequestHelper::slotNextRequest()
|
||||
{
|
||||
if (m_requestFunctions.isEmpty())
|
||||
{
|
||||
if (!m_blockingCall)
|
||||
emit signalSuccess();
|
||||
if (!m_blockingCall)
|
||||
emit signalSuccess();
|
||||
|
||||
done();
|
||||
done();
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
const RequestFunctionContainer rfc = m_requestFunctions.takeFirst();
|
||||
@@ -162,59 +164,60 @@ void RequestHelper::slotNextRequest()
|
||||
if (result == 0)
|
||||
{
|
||||
#ifdef REQUEST_HELPER_WITH_GUI
|
||||
if (!m_quiet)
|
||||
if (!m_quiet)
|
||||
{
|
||||
if (m_blockingCall)
|
||||
{
|
||||
if (m_blockingCall)
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(qobject_cast<QWidget*>(parent()), tr("Request failed"));
|
||||
}
|
||||
else
|
||||
{
|
||||
connect(new LtsWidgets::LtsMessageDialogNew(qobject_cast<QWidget*>(parent()), tr("Request failed")),
|
||||
&LtsWidgets::LtsMessageDialogNew::destroyed, this, [this]() { failure(); });
|
||||
|
||||
return;
|
||||
}
|
||||
LtsWidgets::LtsMessageDialog::showMessage(qobject_cast<QWidget *>(parent()), tr("Request failed"));
|
||||
}
|
||||
#endif
|
||||
failure();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
connect(new LtsWidgets::LtsMessageDialogNew(qobject_cast<QWidget *>(parent()), tr("Request failed")),
|
||||
&LtsWidgets::LtsMessageDialogNew::destroyed,
|
||||
this,
|
||||
[this]() { failure(); });
|
||||
|
||||
void RequestHelper::startSingleBackgroundRequest(
|
||||
const std::function<int64_t()>& requestFunction,
|
||||
const std::function<void(const Core::FunctionReply&)>& baseReplyHandler)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
failure();
|
||||
}
|
||||
}
|
||||
|
||||
void RequestHelper::startSingleBackgroundRequest(const std::function<int64_t()> &requestFunction,
|
||||
const std::function<void(const Core::FunctionReply &)> &baseReplyHandler)
|
||||
{
|
||||
m_blockingCall = false;
|
||||
startSingleRequest(requestFunction, baseReplyHandler);
|
||||
}
|
||||
}
|
||||
|
||||
void RequestHelper::startBackgroundRequests()
|
||||
{
|
||||
void RequestHelper::startBackgroundRequests()
|
||||
{
|
||||
m_blockingCall = false;
|
||||
startRequests();
|
||||
}
|
||||
}
|
||||
|
||||
void RequestHelper::setCustomWaitMessage(const QString& customWaitMessage)
|
||||
{
|
||||
void RequestHelper::setCustomWaitMessage(const QString &customWaitMessage)
|
||||
{
|
||||
m_customWaitMessage = (customWaitMessage + QStringLiteral(" ..."));
|
||||
}
|
||||
}
|
||||
|
||||
bool RequestHelper::startRequests()
|
||||
{
|
||||
bool RequestHelper::startRequests()
|
||||
{
|
||||
if (m_requestFunctions.isEmpty())
|
||||
{
|
||||
#ifdef LTS_DEBUG
|
||||
qWarning("RequestHelper: started request helper without requests!");
|
||||
qWarning("RequestHelper: started request helper without requests!");
|
||||
#endif
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
m_failed = false;
|
||||
|
||||
#ifdef REQUEST_HELPER_WITH_GUI
|
||||
if (!m_quiet)
|
||||
LtsWidgets::LtsGlobalWaitDialog::getInstance()->wait(m_customWaitMessage);
|
||||
LtsWidgets::LtsGlobalWaitDialog::getInstance()->wait(m_customWaitMessage);
|
||||
m_customWaitMessage.clear();
|
||||
#endif
|
||||
|
||||
@@ -223,25 +226,25 @@ bool RequestHelper::startRequests()
|
||||
|
||||
if (s_debug)
|
||||
{
|
||||
QTimer* t = new QTimer(this);
|
||||
t->setInterval(2000);
|
||||
connect(t, &QTimer::timeout, this, &RequestHelper::slotNextRequest, Qt::QueuedConnection);
|
||||
connect(t, &QTimer::timeout, t, &QTimer::deleteLater);
|
||||
t->start();
|
||||
QTimer *t = new QTimer(this);
|
||||
t->setInterval(2000);
|
||||
connect(t, &QTimer::timeout, this, &RequestHelper::slotNextRequest, Qt::QueuedConnection);
|
||||
connect(t, &QTimer::timeout, t, &QTimer::deleteLater);
|
||||
t->start();
|
||||
}
|
||||
else
|
||||
{
|
||||
slotNextRequest();
|
||||
slotNextRequest();
|
||||
|
||||
if (m_blockingCall)
|
||||
{
|
||||
QEventLoop loop;
|
||||
connect(this, &RequestHelper::signalQuitLoop, &loop, &QEventLoop::quit, Qt::QueuedConnection);
|
||||
loop.exec();
|
||||
}
|
||||
if (m_blockingCall)
|
||||
{
|
||||
QEventLoop loop;
|
||||
connect(this, &RequestHelper::signalQuitLoop, &loop, &QEventLoop::quit, Qt::QueuedConnection);
|
||||
loop.exec();
|
||||
}
|
||||
}
|
||||
|
||||
return (!m_failed);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace LtsUtils
|
||||
+69
-70
@@ -27,114 +27,113 @@
|
||||
namespace LtsUtils
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
dds::core::optional<T> toOptional(T inVal)
|
||||
{
|
||||
return inVal != T() ? dds::core::optional<T>(inVal) : dds::core::optional<T>();
|
||||
}
|
||||
template <typename T> dds::core::optional<T> toOptional(T inVal)
|
||||
{
|
||||
return inVal != T() ? dds::core::optional<T>(inVal) : dds::core::optional<T>();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
dds::core::optional<T> optional()
|
||||
{
|
||||
return dds::core::optional<T>();
|
||||
}
|
||||
template <typename T> dds::core::optional<T> optional()
|
||||
{
|
||||
return dds::core::optional<T>();
|
||||
}
|
||||
|
||||
|
||||
class LTSUTILSGUIDDS_INTERNAL_EXPORT RequestHelper : public QObject // TODO: DOC !!!
|
||||
{
|
||||
Q_OBJECT
|
||||
class LTSUTILSGUIDDS_INTERNAL_EXPORT RequestHelper : public QObject // TODO: DOC !!!
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static bool s_debug;
|
||||
public:
|
||||
static bool s_debug;
|
||||
|
||||
explicit RequestHelper(QObject *parent = nullptr, bool quiet = false,
|
||||
// for non-blocking
|
||||
const std::function<void (void)> &success = [](){},
|
||||
const std::function<void (void)> &failure = [](){});
|
||||
~RequestHelper() = default;
|
||||
explicit RequestHelper(
|
||||
QObject *parent = nullptr,
|
||||
bool quiet = false,
|
||||
// for non-blocking
|
||||
const std::function<void(void)> &success = []() {},
|
||||
const std::function<void(void)> &failure = []() {});
|
||||
~RequestHelper() = default;
|
||||
|
||||
bool quiet() const { return m_quiet; }
|
||||
void setQuiet(bool quiet) { m_quiet = quiet; }
|
||||
void addRequest(const std::function<int64_t()> &requestFunction,
|
||||
const std::function<void(const Core::FunctionReply &baseReply)> &baseReplyHandler = nullptr);
|
||||
bool startRequests(); // blocks!
|
||||
bool quiet() const { return m_quiet; }
|
||||
void setQuiet(bool quiet) { m_quiet = quiet; }
|
||||
void addRequest(const std::function<int64_t()> &requestFunction, const std::function<void(const Core::FunctionReply &baseReply)> &baseReplyHandler = nullptr);
|
||||
bool startRequests(); // blocks!
|
||||
|
||||
// do not throw a message if this method fails, as this method does this already // blocks!
|
||||
bool startSingleRequest(const std::function<int64_t(void)> &requestFunction,
|
||||
const std::function<void(const Core::FunctionReply &baseReply)> &baseReplyHandler = nullptr // for replies that return a custom FunctionReply, which has to be handled >>after successful execution<<
|
||||
);
|
||||
// do not throw a message if this method fails, as this method does this already // blocks!
|
||||
bool startSingleRequest(const std::function<int64_t(void)> &requestFunction,
|
||||
const std::function<void(const Core::FunctionReply &baseReply)> &baseReplyHandler =
|
||||
nullptr // for replies that return a custom FunctionReply, which has to be handled >>after successful execution<<
|
||||
);
|
||||
|
||||
// non-blocking !
|
||||
/**
|
||||
// non-blocking !
|
||||
/**
|
||||
* @brief startSingleBackgroundRequest << you cannot reuse this request helper after using background requests! Only use if your REALLY need it.
|
||||
* @param requestFunction
|
||||
* @param baseReplyHandler
|
||||
*/
|
||||
void startSingleBackgroundRequest(const std::function<int64_t()> &requestFunction,
|
||||
const std::function<void(const Core::FunctionReply &baseReply)> &baseReplyHandler = nullptr);
|
||||
/**
|
||||
void startSingleBackgroundRequest(const std::function<int64_t()> &requestFunction,
|
||||
const std::function<void(const Core::FunctionReply &baseReply)> &baseReplyHandler = nullptr);
|
||||
/**
|
||||
* @brief startBackgroundRequests << you cannot reuse this request helper after using background requests! Only use if your REALLY need it.
|
||||
*/
|
||||
void startBackgroundRequests(); // non-blocking !
|
||||
void startBackgroundRequests(); // non-blocking !
|
||||
|
||||
bool requestReply(const Core::FunctionReply &baseReply); // if you have a custom FunctionReply, pass the base ptr
|
||||
bool requestReply(const Core::FunctionReplyObject &replyObject);
|
||||
bool requestReply(const Core::FunctionReply &baseReply); // if you have a custom FunctionReply, pass the base ptr
|
||||
bool requestReply(const Core::FunctionReplyObject &replyObject);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief hasRequests are requests is added?
|
||||
* @return True if a request is added, otherwise false
|
||||
*/
|
||||
bool hasRequests() const { return !m_requestFunctions.isEmpty(); }
|
||||
bool hasRequests() const { return !m_requestFunctions.isEmpty(); }
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief getRepliedId returns the Return-ID of the ReplyObject you gave to the method 'requestReply' - which is mostly the ID for the new Table Entry (Unique ID)
|
||||
* @return the Return-ID or -1 on error (not set)
|
||||
*/
|
||||
int getRepliedId() const { return m_repliedId; }
|
||||
int getRepliedId() const { return m_repliedId; }
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief getErrorString returns the error string set by an ftc reply
|
||||
* @return
|
||||
*/
|
||||
QString getErrorString() const { return m_errorString; }
|
||||
QString getErrorString() const { return m_errorString; }
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief setCustomWaitMessage changes the default 'Waiting for server reply ...' message with a custom one (NOTE: " ..." is automagically added to the custom text)
|
||||
* After a request was started, the custom wait message is immediately reset, so that the next call to start a request, shows the default message again
|
||||
* @param customWaitMessage the wait message to replace the default message with (note that " ..." is added to the text)
|
||||
*/
|
||||
void setCustomWaitMessage(const QString &customWaitMessage);
|
||||
void setCustomWaitMessage(const QString &customWaitMessage);
|
||||
|
||||
bool failed() const { return m_failed; }
|
||||
void failure();
|
||||
bool failed() const { return m_failed; }
|
||||
void failure();
|
||||
|
||||
private:
|
||||
using RequestFunctionContainer = QPair<std::function<int64_t()>, std::function<void(const Core::FunctionReply &)>>;
|
||||
private:
|
||||
using RequestFunctionContainer = QPair<std::function<int64_t()>, std::function<void(const Core::FunctionReply &)>>;
|
||||
|
||||
QVector<RequestFunctionContainer> m_requestFunctions;
|
||||
bool m_failed;
|
||||
int m_repliedId;
|
||||
std::function<void(const Core::FunctionReply &)> m_singleRequestCustomFunctionReply;
|
||||
bool m_quiet;
|
||||
bool m_blockingCall;
|
||||
std::function<void (void)> m_successFn;
|
||||
std::function<void (void)> m_failureFn;
|
||||
QString m_errorString;
|
||||
QString m_customWaitMessage;
|
||||
QVector<RequestFunctionContainer> m_requestFunctions;
|
||||
bool m_failed;
|
||||
int m_repliedId;
|
||||
std::function<void(const Core::FunctionReply &)> m_singleRequestCustomFunctionReply;
|
||||
bool m_quiet;
|
||||
bool m_blockingCall;
|
||||
std::function<void(void)> m_successFn;
|
||||
std::function<void(void)> m_failureFn;
|
||||
QString m_errorString;
|
||||
QString m_customWaitMessage;
|
||||
|
||||
void done();
|
||||
bool _requestReply(const Core::FunctionReplyObject &fro, const Core::FunctionReply *baseReply);
|
||||
void done();
|
||||
bool _requestReply(const Core::FunctionReplyObject &fro, const Core::FunctionReply *baseReply);
|
||||
|
||||
signals:
|
||||
void signalNextRequest();
|
||||
void signalQuitLoop();
|
||||
void signalSuccess();
|
||||
void signalFailed();
|
||||
signals:
|
||||
void signalNextRequest();
|
||||
void signalQuitLoop();
|
||||
void signalSuccess();
|
||||
void signalFailed();
|
||||
|
||||
private slots:
|
||||
void slotNextRequest();
|
||||
|
||||
};
|
||||
private slots:
|
||||
void slotNextRequest();
|
||||
};
|
||||
|
||||
} // namespace LtsUtils
|
||||
Reference in new issue
Block a user