2018-06-19 11:42:21 +01:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "export/export_controller.h"
|
|
|
|
|
|
|
|
namespace Export {
|
|
|
|
namespace View {
|
|
|
|
|
|
|
|
struct Content {
|
|
|
|
struct Row {
|
|
|
|
QString id;
|
|
|
|
QString label;
|
|
|
|
QString info;
|
|
|
|
float64 progress = 0.;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<Row> rows;
|
|
|
|
|
2018-06-20 16:54:13 +01:00
|
|
|
static const QString kDoneId;
|
|
|
|
|
2018-06-19 11:42:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
Content ContentFromState(const ProcessingState &state);
|
2018-06-20 16:54:13 +01:00
|
|
|
Content ContentFromState(const FinishedState &state);
|
2018-06-19 11:42:21 +01:00
|
|
|
|
|
|
|
inline auto ContentFromState(rpl::producer<State> state) {
|
2018-06-20 01:02:36 +01:00
|
|
|
return std::move(
|
2018-06-19 11:42:21 +01:00
|
|
|
state
|
|
|
|
) | rpl::filter([](const State &state) {
|
2018-06-20 01:02:36 +01:00
|
|
|
return state.is<ProcessingState>() || state.is<FinishedState>();
|
2018-06-19 11:42:21 +01:00
|
|
|
}) | rpl::map([](const State &state) {
|
2018-06-20 01:02:36 +01:00
|
|
|
if (const auto process = base::get_if<ProcessingState>(&state)) {
|
|
|
|
return ContentFromState(*process);
|
2018-06-20 16:54:13 +01:00
|
|
|
} else if (const auto done = base::get_if<FinishedState>(&state)) {
|
|
|
|
return ContentFromState(*done);
|
2018-06-20 01:02:36 +01:00
|
|
|
}
|
2018-06-20 16:54:13 +01:00
|
|
|
Unexpected("State type in ContentFromState.");
|
2018-06-20 01:02:36 +01:00
|
|
|
});
|
2018-06-19 11:42:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace View
|
|
|
|
} // namespace Export
|