Unite Dialogs and LeftChannels in Export.

This commit is contained in:
John Preston 2018-06-20 19:21:36 +01:00
parent 156c3d288c
commit 0a5eac50be
2 changed files with 23 additions and 10 deletions

View File

@ -79,7 +79,9 @@ private:
ProcessingState &result, ProcessingState &result,
const Data::DialogsInfo &info, const Data::DialogsInfo &info,
int index, int index,
const DownloadProgress &progress) const; const DownloadProgress &progress,
int addIndex,
int addCount) const;
int substepsInStep(Step step) const; int substepsInStep(Step step) const;
@ -550,15 +552,16 @@ ProcessingState Controller::stateLeftChannelsList(int processed) const {
result.entityIndex = processed; result.entityIndex = processed;
result.entityCount = std::max( result.entityCount = std::max(
processed, processed,
substepsInStep(Step::LeftChannels)); substepsInStep(Step::LeftChannels))
+ substepsInStep(Step::Dialogs);
}); });
} }
ProcessingState Controller::stateDialogsList(int processed) const { ProcessingState Controller::stateDialogsList(int processed) const {
const auto step = Step::DialogsList; const auto step = Step::DialogsList;
return prepareState(step, [&](ProcessingState &result) { return prepareState(step, [&](ProcessingState &result) {
result.entityIndex = processed; result.entityIndex = substepsInStep(Step::LeftChannels) + processed;
result.entityCount = std::max( result.entityCount = substepsInStep(Step::LeftChannels) + std::max(
processed, processed,
substepsInStep(Step::Dialogs)); substepsInStep(Step::Dialogs));
}); });
@ -594,11 +597,15 @@ ProcessingState Controller::stateLeftChannels(
const DownloadProgress & progress) const { const DownloadProgress & progress) const {
const auto step = Step::LeftChannels; const auto step = Step::LeftChannels;
return prepareState(step, [&](ProcessingState &result) { return prepareState(step, [&](ProcessingState &result) {
const auto addIndex = _dialogsInfo.list.size();
const auto addCount = addIndex;
fillMessagesState( fillMessagesState(
result, result,
_leftChannelsInfo, _leftChannelsInfo,
_leftChannelIndex, _leftChannelIndex,
progress); progress,
addIndex,
addCount);
}); });
} }
@ -606,11 +613,15 @@ ProcessingState Controller::stateDialogs(
const DownloadProgress &progress) const { const DownloadProgress &progress) const {
const auto step = Step::Dialogs; const auto step = Step::Dialogs;
return prepareState(step, [&](ProcessingState &result) { return prepareState(step, [&](ProcessingState &result) {
const auto addIndex = 0;
const auto addCount = _leftChannelsInfo.list.size();
fillMessagesState( fillMessagesState(
result, result,
_dialogsInfo, _dialogsInfo,
_dialogIndex, _dialogIndex,
progress); progress,
addIndex,
addCount);
}); });
} }
@ -618,7 +629,9 @@ void Controller::fillMessagesState(
ProcessingState &result, ProcessingState &result,
const Data::DialogsInfo &info, const Data::DialogsInfo &info,
int index, int index,
const DownloadProgress &progress) const { const DownloadProgress &progress,
int addIndex,
int addCount) const {
const auto &dialog = info.list[index]; const auto &dialog = info.list[index];
auto count = 0; auto count = 0;
for (const auto &dialog : info.list) { for (const auto &dialog : info.list) {
@ -626,8 +639,8 @@ void Controller::fillMessagesState(
++count; ++count;
} }
} }
result.entityIndex = index; result.entityIndex = index + addIndex;
result.entityCount = info.list.size(); result.entityCount = info.list.size() + addCount;
result.entityName = dialog.name; result.entityName = dialog.name;
result.itemIndex = _messagesWritten + progress.itemIndex; result.itemIndex = _messagesWritten + progress.itemIndex;
result.itemCount = std::max(_messagesCount, result.entityIndex); result.itemCount = std::max(_messagesCount, result.entityIndex);

View File

@ -55,7 +55,7 @@ struct ProcessingState {
QString entityName; QString entityName;
int entityIndex = 0; int entityIndex = 0;
int entityCount = 1; int entityCount = 0;
int itemIndex = 0; int itemIndex = 0;
int itemCount = 0; int itemCount = 0;