WebpagePrinterTool 2.0
Print a web page skip the browser's print preview
载入中...
搜索中...
未找到
DataPack.h
浏览该文件的文档.
1#pragma once
2#include "../db/SqliteDb.h"
9#include <array>
10#include <functional>
11#include <optional>
12#include <qjsonobject.h>
13#include <tuple>
14enum STEP { GET_CONFIG = 0, PAGE_RENDER = 1, RENDER_PNG = 2, PRINTE = 3, LAST_PROCESS = 4 };
15constexpr std::array<char const*, 5> step_str = {"GET_CONFIG", "PAGE_RENDER", "RENDER_PNG",
16 "PRINTE",
17 "LAST_PROCESS"};
19
22 std::optional<int> uid;
23 std::function<void()> monitor_promise;
24 PrinterDataPack() = delete;
25 explicit PrinterDataPack(std::function<void()> f)
26 : monitor_promise(f) {};
27 void setData(std::tuple<QJsonObject, std::move_only_function<void(QJsonObject)>,
28 std::optional<int>>& t) {
29 resp = std::move(std::get<1>(t));
30 uid = std::get<2>(t);
31 try {
32 page = fromPrintedPageJson("", std::get<0>(t));
33 page.time = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
35 } catch (const JsonParseError& e) {
37 } catch (const SqliteOpError& e) {
39 }
40 }
41 void setRespValue(QJsonObject obj) {
42 resp(obj);
44 }
45
46 private:
47 std::move_only_function<void(QJsonObject)> resp;
48};
constexpr std::array< char const *, 5 > step_str
定义 DataPack.h:15
STEP
定义 DataPack.h:14
@ GET_CONFIG
定义 DataPack.h:14
@ PAGE_RENDER
定义 DataPack.h:14
@ PRINTE
定义 DataPack.h:14
@ LAST_PROCESS
定义 DataPack.h:14
@ RENDER_PNG
定义 DataPack.h:14
PrintedPage fromPrintedPageJson(const QString &json)
Converts a JSON string into a PrintedPage object.
定义 ModelsJson.cpp:22
request response 接口数据格式
定义 JsonParseError.h:6
const char * what() const noexcept override
定义 JsonParseError.h:19
static SqliteDb & instance()
定义 SqliteDb.cpp:33
void addPage(PrintedPage &) const
add new page page.id will be set to the database id
定义 SqliteDb.cpp:278
定义 SqliteOpError.h:6
定义 PrintedPage.h:5
定义 PrinterConfig.h:5
void setRespValue(QJsonObject obj)
定义 DataPack.h:41
void setData(std::tuple< QJsonObject, std::move_only_function< void(QJsonObject)>, std::optional< int > > &t)
定义 DataPack.h:27
PrinterDataPack()=delete
PrintedPage page
定义 DataPack.h:20
PrinterConfig config
定义 DataPack.h:21
std::move_only_function< void(QJsonObject)> resp
定义 DataPack.h:47
std::function< void()> monitor_promise
定义 DataPack.h:23
PrinterDataPack(std::function< void()> f)
定义 DataPack.h:25
std::optional< int > uid
定义 DataPack.h:22
static QJsonObject toJsonObject(std::optional< int > uid, const QString &msg)
定义 WebInterface.h:49