mirror of https://github.com/procxx/kepka.git
Export userpics in a separate file.
This commit is contained in:
parent
59df447fed
commit
40c0286942
|
@ -445,10 +445,7 @@ Result TextWriter::writePersonal(const Data::PersonalInfo &data) {
|
||||||
Expects(_summary != nullptr);
|
Expects(_summary != nullptr);
|
||||||
|
|
||||||
const auto &info = data.user.info;
|
const auto &info = data.user.info;
|
||||||
const auto serialized = "Personal information"
|
const auto serialized = SerializeKeyValue({
|
||||||
+ kLineBreak
|
|
||||||
+ kLineBreak
|
|
||||||
+ SerializeKeyValue({
|
|
||||||
{ "First name", info.firstName },
|
{ "First name", info.firstName },
|
||||||
{ "Last name", info.lastName },
|
{ "Last name", info.lastName },
|
||||||
{ "Phone number", Data::FormatPhoneNumber(info.phoneNumber) },
|
{ "Phone number", Data::FormatPhoneNumber(info.phoneNumber) },
|
||||||
|
@ -461,45 +458,49 @@ Result TextWriter::writePersonal(const Data::PersonalInfo &data) {
|
||||||
|
|
||||||
Result TextWriter::writeUserpicsStart(const Data::UserpicsInfo &data) {
|
Result TextWriter::writeUserpicsStart(const Data::UserpicsInfo &data) {
|
||||||
Expects(_summary != nullptr);
|
Expects(_summary != nullptr);
|
||||||
|
Expects(_userpics == nullptr);
|
||||||
|
|
||||||
_userpicsCount = data.count;
|
_userpicsCount = data.count;
|
||||||
if (!_userpicsCount) {
|
if (!_userpicsCount) {
|
||||||
return Result::Success();
|
return Result::Success();
|
||||||
}
|
}
|
||||||
|
const auto filename = "personal_photos.txt";
|
||||||
|
_userpics = fileWithRelativePath(filename);
|
||||||
|
|
||||||
const auto serialized = "Personal photos "
|
const auto serialized = "Personal photos "
|
||||||
"(" + Data::NumberToString(_userpicsCount) + ")"
|
"(" + Data::NumberToString(_userpicsCount) + ") - " + filename
|
||||||
+ kLineBreak
|
+ kLineBreak
|
||||||
+ kLineBreak;
|
+ kLineBreak;
|
||||||
return _summary->writeBlock(serialized);
|
return _summary->writeBlock(serialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result TextWriter::writeUserpicsSlice(const Data::UserpicsSlice &data) {
|
Result TextWriter::writeUserpicsSlice(const Data::UserpicsSlice &data) {
|
||||||
Expects(_summary != nullptr);
|
Expects(_userpics != nullptr);
|
||||||
Expects(!data.list.empty());
|
Expects(!data.list.empty());
|
||||||
|
|
||||||
auto lines = QByteArray();
|
auto lines = std::vector<QByteArray>();
|
||||||
|
lines.reserve(data.list.size());
|
||||||
for (const auto &userpic : data.list) {
|
for (const auto &userpic : data.list) {
|
||||||
if (!userpic.date) {
|
if (!userpic.date) {
|
||||||
lines.append("(deleted photo)");
|
lines.push_back("(deleted photo)");
|
||||||
} else {
|
} else {
|
||||||
lines.append(Data::FormatDateTime(userpic.date)).append(" - ");
|
lines.push_back(SerializeKeyValue({
|
||||||
if (userpic.image.file.relativePath.isEmpty()) {
|
{ "Date", Data::FormatDateTime(userpic.date) },
|
||||||
lines.append("(file unavailable)");
|
{
|
||||||
} else {
|
"Photo",
|
||||||
lines.append(userpic.image.file.relativePath.toUtf8());
|
(userpic.image.file.relativePath.isEmpty()
|
||||||
}
|
? QByteArray("(file unavailable)")
|
||||||
|
: userpic.image.file.relativePath.toUtf8())
|
||||||
|
},
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
lines.append(kLineBreak);
|
|
||||||
}
|
}
|
||||||
return _summary->writeBlock(lines);
|
return _userpics->writeBlock(JoinList(kLineBreak, lines) + kLineBreak);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result TextWriter::writeUserpicsEnd() {
|
Result TextWriter::writeUserpicsEnd() {
|
||||||
Expects(_summary != nullptr);
|
_userpics = nullptr;
|
||||||
|
return Result::Success();
|
||||||
return (_userpicsCount > 0)
|
|
||||||
? _summary->writeBlock(kLineBreak)
|
|
||||||
: Result::Success();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result TextWriter::writeContactsList(const Data::ContactsList &data) {
|
Result TextWriter::writeContactsList(const Data::ContactsList &data) {
|
||||||
|
|
|
@ -64,7 +64,9 @@ private:
|
||||||
Stats *_stats = nullptr;
|
Stats *_stats = nullptr;
|
||||||
|
|
||||||
std::unique_ptr<File> _summary;
|
std::unique_ptr<File> _summary;
|
||||||
|
|
||||||
int _userpicsCount = 0;
|
int _userpicsCount = 0;
|
||||||
|
std::unique_ptr<File> _userpics;
|
||||||
|
|
||||||
int _dialogsCount = 0;
|
int _dialogsCount = 0;
|
||||||
int _dialogIndex = 0;
|
int _dialogIndex = 0;
|
||||||
|
|
Loading…
Reference in New Issue