2023-08-21 14:22:41 +08:00
|
|
|
#ifndef DMSASYNCACTION_H
|
|
|
|
|
#define DMSASYNCACTION_H
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
|
|
class QEventLoop;
|
|
|
|
|
class QTimer;
|
|
|
|
|
|
|
|
|
|
struct DmsAsyncActionResult
|
|
|
|
|
{
|
|
|
|
|
DmsAsyncActionResult(bool aIsSucessful = false, const QString& aData = "")
|
|
|
|
|
{
|
|
|
|
|
mIsSucessful = aIsSucessful;
|
|
|
|
|
mData = aData;
|
|
|
|
|
}
|
|
|
|
|
bool mIsSucessful;
|
|
|
|
|
QString mData;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class DmsAsyncAction : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
DmsAsyncAction(int aServerId, int aActionId, QObject* aObject, const QString& aResponseSignal, QObject* aParent = nullptr);
|
|
|
|
|
~DmsAsyncAction();
|
|
|
|
|
|
|
|
|
|
bool execute();
|
|
|
|
|
void setSendData(const QString& aData);
|
2023-09-11 16:29:30 +08:00
|
|
|
void setTimeoutInterval(int aMsec);
|
2023-09-21 17:16:46 +08:00
|
|
|
void responsed();
|
2023-08-21 14:22:41 +08:00
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void timeout();
|
|
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
void sendTimeoutSignal();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int mServerId;
|
|
|
|
|
int mActionId;
|
|
|
|
|
QTimer* mTimer;
|
|
|
|
|
QObject* mObject;
|
|
|
|
|
QString mResponseSignal;
|
|
|
|
|
QString mSendData;
|
2023-09-25 13:43:00 +08:00
|
|
|
bool mIsResponsed;
|
2023-08-21 14:22:41 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // DMSASYNCACTION_H
|