39 lines
1.1 KiB
C++
39 lines
1.1 KiB
C++
#pragma once
|
||
#include <functional>
|
||
#include <QList>
|
||
#include <QObject>
|
||
#include <QPointer>
|
||
#include <QString>
|
||
#include <QVariant>
|
||
#include "ApiBatch.hpp"
|
||
|
||
namespace geopro::data {
|
||
|
||
// ── 通用详情句柄(tab 引擎):载荷经 QVariant 类型擦除,单一 done(QVariant)。 ──
|
||
// 可测试缝(类比 IApiCall):仓储返回基类指针,控制器/测试只依赖它。
|
||
class DetailLoad : public QObject {
|
||
Q_OBJECT
|
||
public:
|
||
using QObject::QObject;
|
||
~DetailLoad() override = default;
|
||
virtual void abort() = 0;
|
||
signals:
|
||
void done(const QVariant& payload);
|
||
void failed(const QString& message);
|
||
};
|
||
|
||
// Api 实现:包 ApiBatch + 注入解析器(返回 QVariant 载荷)。逻辑与 ApiChartLoad 等价。
|
||
class ApiDetailLoad : public DetailLoad {
|
||
Q_OBJECT
|
||
public:
|
||
using Parser = std::function<QVariant(const QList<geopro::net::ApiResponse>&)>;
|
||
ApiDetailLoad(geopro::net::ApiBatch* batch, Parser parse, QObject* parent = nullptr);
|
||
void abort() override;
|
||
private:
|
||
QPointer<geopro::net::ApiBatch> batch_;
|
||
Parser parse_;
|
||
bool aborted_ = false;
|
||
};
|
||
|
||
} // namespace geopro::data
|