2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Saving FlatTextarea tags to drafts, applying them in setText.

Now instead of plain text a TextWithTags struct is used almost
everywhere. Started writing and reading serialized tags to drafts
from 9048, switched version to 0.9.48 for testing.
This commit is contained in:
John Preston
2016-05-05 19:04:17 +03:00
parent 5a47d8e29b
commit 463450e607
18 changed files with 324 additions and 205 deletions

View File

@@ -159,7 +159,9 @@ bool MainWidget::onShareUrl(const PeerId &peer, const QString &url, const QStrin
return false;
}
History *h = App::history(peer);
h->setMsgDraft(std_::make_unique<HistoryDraft>(url + '\n' + text, 0, MessageCursor(url.size() + 1, url.size() + 1 + text.size(), QFIXED_MAX), false));
TextWithTags textWithTags = { url + '\n' + text, TextWithTags::Tags() };
MessageCursor cursor = { url.size() + 1, url.size() + 1 + text.size(), QFIXED_MAX };
h->setMsgDraft(std_::make_unique<HistoryDraft>(textWithTags, 0, cursor, false));
h->clearEditDraft();
bool opened = _history->peer() && (_history->peer()->id == peer);
if (opened) {
@@ -177,7 +179,9 @@ bool MainWidget::onInlineSwitchChosen(const PeerId &peer, const QString &botAndQ
return false;
}
History *h = App::history(peer);
h->setMsgDraft(std_::make_unique<HistoryDraft>(botAndQuery, 0, MessageCursor(botAndQuery.size(), botAndQuery.size(), QFIXED_MAX), false));
TextWithTags textWithTags = { botAndQuery, TextWithTags::Tags() };
MessageCursor cursor = { botAndQuery.size(), botAndQuery.size(), QFIXED_MAX };
h->setMsgDraft(std_::make_unique<HistoryDraft>(textWithTags, 0, cursor, false));
h->clearEditDraft();
bool opened = _history->peer() && (_history->peer()->id == peer);
if (opened) {
@@ -1086,7 +1090,7 @@ void executeParsedCommand(const QString &command) {
void MainWidget::sendMessage(const MessageToSend &message) {
auto history = message.history;
const auto &text = message.text;
const auto &textWithTags = message.textWithTags;
readServerHistory(history, false);
_history->fastShowAtEnd(history);
@@ -1095,13 +1099,13 @@ void MainWidget::sendMessage(const MessageToSend &message) {
return;
}
saveRecentHashtags(text);
saveRecentHashtags(textWithTags.text);
EntitiesInText sendingEntities, leftEntities = entitiesFromFieldTags(message.entities);
EntitiesInText sendingEntities, leftEntities = entitiesFromTextTags(textWithTags.tags);
auto prepareFlags = itemTextOptions(history, App::self()).flags;
QString sendingText, leftText = prepareTextWithEntities(text, prepareFlags, &leftEntities);
QString sendingText, leftText = prepareTextWithEntities(textWithTags.text, prepareFlags, &leftEntities);
QString command = parseCommandFromMessage(history, text);
QString command = parseCommandFromMessage(history, textWithTags.text);
HistoryItem *lastMessage = nullptr;
MsgId replyTo = (message.replyTo < 0) ? _history->replyToId() : 0;