Browse Source

fix: correct format log files

- correct format of "save chat log"
 - add date like in chat
 - correct type dialog for export dialog
reviewable/pr5267/r1
pkev 7 years ago committed by Anthony Bilinski
parent
commit
ee0d4bb880
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
  1. 2
      src/chatlog/chatmessage.cpp
  2. 5
      src/widget/form/chatform.cpp
  3. 11
      src/widget/form/genericchatform.cpp

2
src/chatlog/chatmessage.cpp

@ -124,7 +124,7 @@ ChatMessage::Ptr ChatMessage::createChatInfoMessage(const QString& rawMessage,
msg->addColumn(new Image(QSize(18, 18), img), msg->addColumn(new Image(QSize(18, 18), img),
ColumnFormat(NAME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right)); ColumnFormat(NAME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right));
msg->addColumn(new Text("<b>" + text + "</b>", baseFont, false, ""), msg->addColumn(new Text("<b>" + text + "</b>", baseFont, false, text),
ColumnFormat(1.0, ColumnFormat::VariableSize, ColumnFormat::Left)); ColumnFormat(1.0, ColumnFormat::VariableSize, ColumnFormat::Left));
msg->addColumn(new Timestamp(date, Settings::getInstance().getTimestampFormat(), baseFont), msg->addColumn(new Timestamp(date, Settings::getInstance().getTimestampFormat(), baseFont),
ColumnFormat(TIME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right)); ColumnFormat(TIME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right));

5
src/widget/form/chatform.cpp

@ -1087,11 +1087,12 @@ void ChatForm::onExportChat()
QString buffer; QString buffer;
for (const auto& it : msgs) { for (const auto& it : msgs) {
QString timestamp = it.timestamp.toString(); QString timestamp = it.timestamp.time().toString("hh:mm:ss");
QString datestamp = it.timestamp.date().toString("yyyy-MM-dd");
ToxPk authorPk(ToxId(it.sender).getPublicKey()); ToxPk authorPk(ToxId(it.sender).getPublicKey());
QString author = getMsgAuthorDispName(authorPk, it.dispName); QString author = getMsgAuthorDispName(authorPk, it.dispName);
QString line = QString("%1\t%2\t%3\n").arg(timestamp, author, it.message); QString line = QString("%1\t%2\t%3\t%4\n").arg(datestamp, timestamp, author, it.message);
buffer = buffer % line; buffer = buffer % line;
} }
file.write(buffer.toUtf8()); file.write(buffer.toUtf8());

11
src/widget/form/genericchatform.cpp

@ -494,17 +494,16 @@ void GenericChatForm::onSaveLogClicked()
for (ChatLine::Ptr l : lines) { for (ChatLine::Ptr l : lines) {
Timestamp* rightCol = qobject_cast<Timestamp*>(l->getContent(2)); Timestamp* rightCol = qobject_cast<Timestamp*>(l->getContent(2));
if (!rightCol)
break;
ChatLineContent* middleCol = l->getContent(1); ChatLineContent* middleCol = l->getContent(1);
ChatLineContent* leftCol = l->getContent(0); ChatLineContent* leftCol = l->getContent(0);
QString timestamp = rightCol->getTime().isNull() ? tr("Not sent") : rightCol->getText(); QString nick = leftCol->getText().isNull() ? tr("[System message]") : leftCol->getText();
QString nick = leftCol->getText();
QString msg = middleCol->getText(); QString msg = middleCol->getText();
plainText += QString("[%2] %1\n%3\n\n").arg(nick, timestamp, msg); QString timestamp = (rightCol == nullptr) ? tr("Not sent") : rightCol->getText();
plainText += QString("%1\t%3\t%2\n").arg(nick, timestamp, msg);
} }
file.write(plainText.toUtf8()); file.write(plainText.toUtf8());

Loading…
Cancel
Save