mirror of https://github.com/procxx/kepka.git
Remove ExpandLinksNone, rename Text::originalText.
This commit is contained in:
parent
cc2fd51097
commit
ff51423125
|
@ -50,11 +50,7 @@ bool ClickHandler::setActive(const ClickHandlerPtr &p, ClickHandlerHost *host) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ClickHandler::getExpandedLinkText(ExpandLinksMode mode, const QStringRef &textPart) const {
|
TextWithEntities ClickHandler::getExpandedLinkTextWithEntities(int entityOffset, const QStringRef &textPart) const {
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
TextWithEntities ClickHandler::getExpandedLinkTextWithEntities(ExpandLinksMode mode, int entityOffset, const QStringRef &textPart) const {
|
|
||||||
return { QString(), EntitiesInText() };
|
return { QString(), EntitiesInText() };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,8 @@ struct ClickContext {
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ExpandLinksMode {
|
enum ExpandLinksMode {
|
||||||
ExpandLinksNone,
|
|
||||||
ExpandLinksShortened,
|
ExpandLinksShortened,
|
||||||
ExpandLinksAll,
|
ExpandLinksAll,
|
||||||
ExpandLinksUrlOnly, // For custom urls leaves only url instead of text.
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ClickHandlerHost {
|
class ClickHandlerHost {
|
||||||
|
@ -63,8 +61,7 @@ public:
|
||||||
// Entities in text support.
|
// Entities in text support.
|
||||||
|
|
||||||
// This method returns empty string if just textPart should be used (nothing to expand).
|
// This method returns empty string if just textPart should be used (nothing to expand).
|
||||||
virtual QString getExpandedLinkText(ExpandLinksMode mode, const QStringRef &textPart) const;
|
virtual TextWithEntities getExpandedLinkTextWithEntities(int entityOffset, const QStringRef &textPart) const;
|
||||||
virtual TextWithEntities getExpandedLinkTextWithEntities(ExpandLinksMode mode, int entityOffset, const QStringRef &textPart) const;
|
|
||||||
|
|
||||||
// This method should be called on mouse over a click handler.
|
// This method should be called on mouse over a click handler.
|
||||||
// It returns true if the active handler was changed or false otherwise.
|
// It returns true if the active handler was changed or false otherwise.
|
||||||
|
|
|
@ -133,22 +133,13 @@ void UrlClickHandler::Open(QString url, QVariant context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString UrlClickHandler::getExpandedLinkText(ExpandLinksMode mode, const QStringRef &textPart) const {
|
TextWithEntities UrlClickHandler::getExpandedLinkTextWithEntities(int entityOffset, const QStringRef &textPart) const {
|
||||||
QString result;
|
auto result = TextWithEntities();
|
||||||
if (mode != ExpandLinksNone) {
|
result.text = _originalUrl;
|
||||||
result = _originalUrl;
|
const auto entityLength = _originalUrl.size();
|
||||||
}
|
const auto entityType = isEmail(_originalUrl)
|
||||||
return result;
|
? EntityInTextEmail
|
||||||
}
|
: EntityInTextUrl;
|
||||||
|
|
||||||
TextWithEntities UrlClickHandler::getExpandedLinkTextWithEntities(ExpandLinksMode mode, int entityOffset, const QStringRef &textPart) const {
|
|
||||||
TextWithEntities result;
|
|
||||||
auto entityType = isEmail(_originalUrl) ? EntityInTextEmail : EntityInTextUrl;
|
|
||||||
int entityLength = textPart.size();
|
|
||||||
if (mode != ExpandLinksNone) {
|
|
||||||
result.text = _originalUrl;
|
|
||||||
entityLength = _originalUrl.size();
|
|
||||||
}
|
|
||||||
result.entities.push_back({ entityType, entityOffset, entityLength });
|
result.entities.push_back({ entityType, entityOffset, entityLength });
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -209,28 +200,8 @@ void BotGameUrlClickHandler::onClick(ClickContext context) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString HiddenUrlClickHandler::getExpandedLinkText(ExpandLinksMode mode, const QStringRef &textPart) const {
|
TextWithEntities HiddenUrlClickHandler::getExpandedLinkTextWithEntities(int entityOffset, const QStringRef &textPart) const {
|
||||||
QString result;
|
return simpleTextWithEntity({ EntityInTextCustomUrl, entityOffset, textPart.size(), url() });
|
||||||
if (mode == ExpandLinksAll) {
|
|
||||||
result = textPart.toString() + qsl(" (") + url() + ')';
|
|
||||||
} else if (mode == ExpandLinksUrlOnly) {
|
|
||||||
result = url();
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
TextWithEntities HiddenUrlClickHandler::getExpandedLinkTextWithEntities(ExpandLinksMode mode, int entityOffset, const QStringRef &textPart) const {
|
|
||||||
TextWithEntities result;
|
|
||||||
if (mode == ExpandLinksUrlOnly) {
|
|
||||||
result.text = url();
|
|
||||||
result.entities.push_back({ EntityInTextUrl, entityOffset, result.text.size() });
|
|
||||||
} else {
|
|
||||||
result.entities.push_back({ EntityInTextCustomUrl, entityOffset, textPart.size(), url() });
|
|
||||||
if (mode == ExpandLinksAll) {
|
|
||||||
result.text = textPart.toString() + qsl(" (") + url() + ')';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MentionClickHandler::copyToClipboardContextItemText() const {
|
QString MentionClickHandler::copyToClipboardContextItemText() const {
|
||||||
|
@ -244,7 +215,7 @@ void MentionClickHandler::onClick(ClickContext context) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextWithEntities MentionClickHandler::getExpandedLinkTextWithEntities(ExpandLinksMode mode, int entityOffset, const QStringRef &textPart) const {
|
TextWithEntities MentionClickHandler::getExpandedLinkTextWithEntities(int entityOffset, const QStringRef &textPart) const {
|
||||||
return simpleTextWithEntity({ EntityInTextMention, entityOffset, textPart.size() });
|
return simpleTextWithEntity({ EntityInTextMention, entityOffset, textPart.size() });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,7 +228,7 @@ void MentionNameClickHandler::onClick(ClickContext context) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextWithEntities MentionNameClickHandler::getExpandedLinkTextWithEntities(ExpandLinksMode mode, int entityOffset, const QStringRef &textPart) const {
|
TextWithEntities MentionNameClickHandler::getExpandedLinkTextWithEntities(int entityOffset, const QStringRef &textPart) const {
|
||||||
auto data = QString::number(_userId) + '.' + QString::number(_accessHash);
|
auto data = QString::number(_userId) + '.' + QString::number(_accessHash);
|
||||||
return simpleTextWithEntity({ EntityInTextMentionName, entityOffset, textPart.size(), data });
|
return simpleTextWithEntity({ EntityInTextMentionName, entityOffset, textPart.size(), data });
|
||||||
}
|
}
|
||||||
|
@ -283,7 +254,7 @@ void HashtagClickHandler::onClick(ClickContext context) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextWithEntities HashtagClickHandler::getExpandedLinkTextWithEntities(ExpandLinksMode mode, int entityOffset, const QStringRef &textPart) const {
|
TextWithEntities HashtagClickHandler::getExpandedLinkTextWithEntities(int entityOffset, const QStringRef &textPart) const {
|
||||||
return simpleTextWithEntity({ EntityInTextHashtag, entityOffset, textPart.size() });
|
return simpleTextWithEntity({ EntityInTextHashtag, entityOffset, textPart.size() });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,7 +270,6 @@ void CashtagClickHandler::onClick(ClickContext context) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
TextWithEntities CashtagClickHandler::getExpandedLinkTextWithEntities(
|
TextWithEntities CashtagClickHandler::getExpandedLinkTextWithEntities(
|
||||||
ExpandLinksMode mode,
|
|
||||||
int entityOffset,
|
int entityOffset,
|
||||||
const QStringRef &textPart) const {
|
const QStringRef &textPart) const {
|
||||||
return simpleTextWithEntity({ EntityInTextCashtag, entityOffset, textPart.size() });
|
return simpleTextWithEntity({ EntityInTextCashtag, entityOffset, textPart.size() });
|
||||||
|
@ -334,6 +304,6 @@ void BotCommandClickHandler::onClick(ClickContext context) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextWithEntities BotCommandClickHandler::getExpandedLinkTextWithEntities(ExpandLinksMode mode, int entityOffset, const QStringRef &textPart) const {
|
TextWithEntities BotCommandClickHandler::getExpandedLinkTextWithEntities(int entityOffset, const QStringRef &textPart) const {
|
||||||
return simpleTextWithEntity({ EntityInTextBotCommand, entityOffset, textPart.size() });
|
return simpleTextWithEntity({ EntityInTextBotCommand, entityOffset, textPart.size() });
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,11 +47,7 @@ public:
|
||||||
return url();
|
return url();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString getExpandedLinkText(
|
|
||||||
ExpandLinksMode mode,
|
|
||||||
const QStringRef &textPart) const override;
|
|
||||||
TextWithEntities getExpandedLinkTextWithEntities(
|
TextWithEntities getExpandedLinkTextWithEntities(
|
||||||
ExpandLinksMode mode,
|
|
||||||
int entityOffset,
|
int entityOffset,
|
||||||
const QStringRef &textPart) const override;
|
const QStringRef &textPart) const override;
|
||||||
|
|
||||||
|
@ -100,11 +96,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString getExpandedLinkText(
|
|
||||||
ExpandLinksMode mode,
|
|
||||||
const QStringRef &textPart) const override;
|
|
||||||
TextWithEntities getExpandedLinkTextWithEntities(
|
TextWithEntities getExpandedLinkTextWithEntities(
|
||||||
ExpandLinksMode mode,
|
|
||||||
int entityOffset,
|
int entityOffset,
|
||||||
const QStringRef &textPart) const override;
|
const QStringRef &textPart) const override;
|
||||||
|
|
||||||
|
@ -137,7 +129,6 @@ public:
|
||||||
QString copyToClipboardContextItemText() const override;
|
QString copyToClipboardContextItemText() const override;
|
||||||
|
|
||||||
TextWithEntities getExpandedLinkTextWithEntities(
|
TextWithEntities getExpandedLinkTextWithEntities(
|
||||||
ExpandLinksMode mode,
|
|
||||||
int entityOffset,
|
int entityOffset,
|
||||||
const QStringRef &textPart) const override;
|
const QStringRef &textPart) const override;
|
||||||
|
|
||||||
|
@ -162,7 +153,6 @@ public:
|
||||||
void onClick(ClickContext context) const override;
|
void onClick(ClickContext context) const override;
|
||||||
|
|
||||||
TextWithEntities getExpandedLinkTextWithEntities(
|
TextWithEntities getExpandedLinkTextWithEntities(
|
||||||
ExpandLinksMode mode,
|
|
||||||
int entityOffset,
|
int entityOffset,
|
||||||
const QStringRef &textPart) const override;
|
const QStringRef &textPart) const override;
|
||||||
|
|
||||||
|
@ -189,7 +179,6 @@ public:
|
||||||
QString copyToClipboardContextItemText() const override;
|
QString copyToClipboardContextItemText() const override;
|
||||||
|
|
||||||
TextWithEntities getExpandedLinkTextWithEntities(
|
TextWithEntities getExpandedLinkTextWithEntities(
|
||||||
ExpandLinksMode mode,
|
|
||||||
int entityOffset,
|
int entityOffset,
|
||||||
const QStringRef &textPart) const override;
|
const QStringRef &textPart) const override;
|
||||||
|
|
||||||
|
@ -217,7 +206,6 @@ public:
|
||||||
QString copyToClipboardContextItemText() const override;
|
QString copyToClipboardContextItemText() const override;
|
||||||
|
|
||||||
TextWithEntities getExpandedLinkTextWithEntities(
|
TextWithEntities getExpandedLinkTextWithEntities(
|
||||||
ExpandLinksMode mode,
|
|
||||||
int entityOffset,
|
int entityOffset,
|
||||||
const QStringRef &textPart) const override;
|
const QStringRef &textPart) const override;
|
||||||
|
|
||||||
|
@ -252,7 +240,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
TextWithEntities getExpandedLinkTextWithEntities(
|
TextWithEntities getExpandedLinkTextWithEntities(
|
||||||
ExpandLinksMode mode,
|
|
||||||
int entityOffset,
|
int entityOffset,
|
||||||
const QStringRef &textPart) const override;
|
const QStringRef &textPart) const override;
|
||||||
|
|
||||||
|
|
|
@ -471,7 +471,7 @@ QString InnerWidget::tooltipText() const {
|
||||||
&& _mouseAction == MouseAction::None) {
|
&& _mouseAction == MouseAction::None) {
|
||||||
if (const auto view = App::hoveredItem()) {
|
if (const auto view = App::hoveredItem()) {
|
||||||
if (const auto forwarded = view->data()->Get<HistoryMessageForwarded>()) {
|
if (const auto forwarded = view->data()->Get<HistoryMessageForwarded>()) {
|
||||||
return forwarded->text.originalText(AllTextSelection, ExpandLinksNone);
|
return forwarded->text.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (const auto lnk = ClickHandler::getActive()) {
|
} else if (const auto lnk = ClickHandler::getActive()) {
|
||||||
|
|
|
@ -3103,7 +3103,7 @@ QString HistoryInner::tooltipText() const {
|
||||||
&& _mouseAction == MouseAction::None) {
|
&& _mouseAction == MouseAction::None) {
|
||||||
if (const auto view = App::hoveredItem()) {
|
if (const auto view = App::hoveredItem()) {
|
||||||
if (const auto forwarded = view->data()->Get<HistoryMessageForwarded>()) {
|
if (const auto forwarded = view->data()->Get<HistoryMessageForwarded>()) {
|
||||||
return forwarded->text.originalText(AllTextSelection, ExpandLinksNone);
|
return forwarded->text.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (const auto lnk = ClickHandler::getActive()) {
|
} else if (const auto lnk = ClickHandler::getActive()) {
|
||||||
|
|
|
@ -43,6 +43,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
constexpr auto kNotificationTextLimit = 255;
|
||||||
|
|
||||||
enum class MediaCheckResult {
|
enum class MediaCheckResult {
|
||||||
Good,
|
Good,
|
||||||
Unsupported,
|
Unsupported,
|
||||||
|
@ -686,20 +688,17 @@ bool HistoryItem::isEmpty() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString HistoryItem::notificationText() const {
|
QString HistoryItem::notificationText() const {
|
||||||
auto getText = [this]() {
|
const auto result = [&] {
|
||||||
if (_media) {
|
if (_media) {
|
||||||
return _media->notificationText();
|
return _media->notificationText();
|
||||||
} else if (!emptyText()) {
|
} else if (!emptyText()) {
|
||||||
return _text.originalText();
|
return _text.toString();
|
||||||
}
|
}
|
||||||
return QString();
|
return QString();
|
||||||
};
|
}();
|
||||||
|
return (result.size() <= kNotificationTextLimit)
|
||||||
auto result = getText();
|
? result
|
||||||
if (result.size() > 0xFF) {
|
: result.mid(0, kNotificationTextLimit) + qsl("...");
|
||||||
result = result.mid(0, 0xFF) + qsl("...");
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString HistoryItem::inDialogsText(DrawInDialog way) const {
|
QString HistoryItem::inDialogsText(DrawInDialog way) const {
|
||||||
|
@ -710,7 +709,7 @@ QString HistoryItem::inDialogsText(DrawInDialog way) const {
|
||||||
}
|
}
|
||||||
return _media->chatListText();
|
return _media->chatListText();
|
||||||
} else if (!emptyText()) {
|
} else if (!emptyText()) {
|
||||||
return TextUtilities::Clean(_text.originalText());
|
return TextUtilities::Clean(_text.toString());
|
||||||
}
|
}
|
||||||
return QString();
|
return QString();
|
||||||
};
|
};
|
||||||
|
|
|
@ -39,7 +39,7 @@ TextWithEntities WrapAsReply(
|
||||||
TextWithEntities WrapAsForwarded(
|
TextWithEntities WrapAsForwarded(
|
||||||
TextWithEntities &&text,
|
TextWithEntities &&text,
|
||||||
not_null<HistoryMessageForwarded*> forwarded) {
|
not_null<HistoryMessageForwarded*> forwarded) {
|
||||||
auto info = forwarded->text.originalTextWithEntities(
|
auto info = forwarded->text.toTextWithEntities(
|
||||||
AllTextSelection,
|
AllTextSelection,
|
||||||
ExpandLinksAll);
|
ExpandLinksAll);
|
||||||
auto result = TextWithEntities();
|
auto result = TextWithEntities();
|
||||||
|
|
|
@ -1093,14 +1093,14 @@ TextWithEntities HistoryMessage::originalText() const {
|
||||||
if (emptyText()) {
|
if (emptyText()) {
|
||||||
return { QString(), EntitiesInText() };
|
return { QString(), EntitiesInText() };
|
||||||
}
|
}
|
||||||
return _text.originalTextWithEntities();
|
return _text.toTextWithEntities();
|
||||||
}
|
}
|
||||||
|
|
||||||
TextWithEntities HistoryMessage::clipboardText() const {
|
TextWithEntities HistoryMessage::clipboardText() const {
|
||||||
if (emptyText()) {
|
if (emptyText()) {
|
||||||
return { QString(), EntitiesInText() };
|
return { QString(), EntitiesInText() };
|
||||||
}
|
}
|
||||||
return _text.originalTextWithEntities(AllTextSelection, ExpandLinksAll);
|
return _text.toTextWithEntities(AllTextSelection, ExpandLinksAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryMessage::textHasLinks() const {
|
bool HistoryMessage::textHasLinks() const {
|
||||||
|
|
|
@ -99,7 +99,7 @@ QSize HistoryContact::countOptimalSize() {
|
||||||
if (_contact) {
|
if (_contact) {
|
||||||
_contact->loadUserpic();
|
_contact->loadUserpic();
|
||||||
} else {
|
} else {
|
||||||
const auto full = _name.originalText();
|
const auto full = _name.toString();
|
||||||
_photoEmpty = std::make_unique<Ui::EmptyUserpic>(
|
_photoEmpty = std::make_unique<Ui::EmptyUserpic>(
|
||||||
Data::PeerUserpicColor(_userId
|
Data::PeerUserpicColor(_userId
|
||||||
? peerFromUser(_userId)
|
? peerFromUser(_userId)
|
||||||
|
|
|
@ -654,7 +654,7 @@ bool HistoryDocument::hasTextForCopy() const {
|
||||||
TextWithEntities HistoryDocument::selectedText(TextSelection selection) const {
|
TextWithEntities HistoryDocument::selectedText(TextSelection selection) const {
|
||||||
if (const auto captioned = Get<HistoryDocumentCaptioned>()) {
|
if (const auto captioned = Get<HistoryDocumentCaptioned>()) {
|
||||||
const auto &caption = captioned->_caption;
|
const auto &caption = captioned->_caption;
|
||||||
return caption.originalTextWithEntities(selection, ExpandLinksAll);
|
return caption.toTextWithEntities(selection, ExpandLinksAll);
|
||||||
}
|
}
|
||||||
return TextWithEntities();
|
return TextWithEntities();
|
||||||
}
|
}
|
||||||
|
@ -838,7 +838,7 @@ void HistoryDocument::parentTextUpdated() {
|
||||||
|
|
||||||
TextWithEntities HistoryDocument::getCaption() const {
|
TextWithEntities HistoryDocument::getCaption() const {
|
||||||
if (const auto captioned = Get<HistoryDocumentCaptioned>()) {
|
if (const auto captioned = Get<HistoryDocumentCaptioned>()) {
|
||||||
return captioned->_caption.originalTextWithEntities();
|
return captioned->_caption.toTextWithEntities();
|
||||||
}
|
}
|
||||||
return TextWithEntities();
|
return TextWithEntities();
|
||||||
}
|
}
|
||||||
|
|
|
@ -368,10 +368,10 @@ void HistoryGame::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pres
|
||||||
}
|
}
|
||||||
|
|
||||||
TextWithEntities HistoryGame::selectedText(TextSelection selection) const {
|
TextWithEntities HistoryGame::selectedText(TextSelection selection) const {
|
||||||
auto titleResult = _title.originalTextWithEntities(
|
auto titleResult = _title.toTextWithEntities(
|
||||||
selection,
|
selection,
|
||||||
ExpandLinksAll);
|
ExpandLinksAll);
|
||||||
auto descriptionResult = _description.originalTextWithEntities(
|
auto descriptionResult = _description.toTextWithEntities(
|
||||||
toDescriptionSelection(selection),
|
toDescriptionSelection(selection),
|
||||||
ExpandLinksAll);
|
ExpandLinksAll);
|
||||||
if (titleResult.text.isEmpty()) {
|
if (titleResult.text.isEmpty()) {
|
||||||
|
|
|
@ -681,7 +681,7 @@ TextState HistoryGif::textState(QPoint point, StateRequest request) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
TextWithEntities HistoryGif::selectedText(TextSelection selection) const {
|
TextWithEntities HistoryGif::selectedText(TextSelection selection) const {
|
||||||
return _caption.originalTextWithEntities(selection, ExpandLinksAll);
|
return _caption.toTextWithEntities(selection, ExpandLinksAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryGif::uploading() const {
|
bool HistoryGif::uploading() const {
|
||||||
|
|
|
@ -57,7 +57,7 @@ public:
|
||||||
void stopAnimation() override;
|
void stopAnimation() override;
|
||||||
|
|
||||||
TextWithEntities getCaption() const override {
|
TextWithEntities getCaption() const override {
|
||||||
return _caption.originalTextWithEntities();
|
return _caption.toTextWithEntities();
|
||||||
}
|
}
|
||||||
bool needsBubble() const override;
|
bool needsBubble() const override;
|
||||||
bool customInfoLayout() const override {
|
bool customInfoLayout() const override {
|
||||||
|
|
|
@ -306,7 +306,7 @@ TextSelection HistoryGroupedMedia::adjustSelection(
|
||||||
|
|
||||||
TextWithEntities HistoryGroupedMedia::selectedText(
|
TextWithEntities HistoryGroupedMedia::selectedText(
|
||||||
TextSelection selection) const {
|
TextSelection selection) const {
|
||||||
return _caption.originalTextWithEntities(selection, ExpandLinksAll);
|
return _caption.toTextWithEntities(selection, ExpandLinksAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryGroupedMedia::clickHandlerActiveChanged(
|
void HistoryGroupedMedia::clickHandlerActiveChanged(
|
||||||
|
|
|
@ -359,10 +359,10 @@ void HistoryInvoice::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool p
|
||||||
}
|
}
|
||||||
|
|
||||||
TextWithEntities HistoryInvoice::selectedText(TextSelection selection) const {
|
TextWithEntities HistoryInvoice::selectedText(TextSelection selection) const {
|
||||||
auto titleResult = _title.originalTextWithEntities(
|
auto titleResult = _title.toTextWithEntities(
|
||||||
selection,
|
selection,
|
||||||
ExpandLinksAll);
|
ExpandLinksAll);
|
||||||
auto descriptionResult = _description.originalTextWithEntities(
|
auto descriptionResult = _description.toTextWithEntities(
|
||||||
toDescriptionSelection(selection),
|
toDescriptionSelection(selection),
|
||||||
ExpandLinksAll);
|
ExpandLinksAll);
|
||||||
if (titleResult.text.isEmpty()) {
|
if (titleResult.text.isEmpty()) {
|
||||||
|
|
|
@ -25,7 +25,7 @@ public:
|
||||||
return _receiptMsgId;
|
return _receiptMsgId;
|
||||||
}
|
}
|
||||||
QString getTitle() const {
|
QString getTitle() const {
|
||||||
return _title.originalText();
|
return _title.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hideMessageText() const override {
|
bool hideMessageText() const override {
|
||||||
|
|
|
@ -279,8 +279,8 @@ TextSelection HistoryLocation::adjustSelection(TextSelection selection, TextSele
|
||||||
}
|
}
|
||||||
|
|
||||||
TextWithEntities HistoryLocation::selectedText(TextSelection selection) const {
|
TextWithEntities HistoryLocation::selectedText(TextSelection selection) const {
|
||||||
auto titleResult = _title.originalTextWithEntities(selection);
|
auto titleResult = _title.toTextWithEntities(selection);
|
||||||
auto descriptionResult = _description.originalTextWithEntities(toDescriptionSelection(selection));
|
auto descriptionResult = _description.toTextWithEntities(toDescriptionSelection(selection));
|
||||||
if (titleResult.text.isEmpty()) {
|
if (titleResult.text.isEmpty()) {
|
||||||
return descriptionResult;
|
return descriptionResult;
|
||||||
} else if (descriptionResult.text.isEmpty()) {
|
} else if (descriptionResult.text.isEmpty()) {
|
||||||
|
|
|
@ -536,7 +536,7 @@ void HistoryPhoto::validateGroupedCache(
|
||||||
}
|
}
|
||||||
|
|
||||||
TextWithEntities HistoryPhoto::selectedText(TextSelection selection) const {
|
TextWithEntities HistoryPhoto::selectedText(TextSelection selection) const {
|
||||||
return _caption.originalTextWithEntities(selection, ExpandLinksAll);
|
return _caption.toTextWithEntities(selection, ExpandLinksAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryPhoto::needsBubble() const {
|
bool HistoryPhoto::needsBubble() const {
|
||||||
|
|
|
@ -58,7 +58,7 @@ public:
|
||||||
StateRequest request) const override;
|
StateRequest request) const override;
|
||||||
|
|
||||||
TextWithEntities getCaption() const override {
|
TextWithEntities getCaption() const override {
|
||||||
return _caption.originalTextWithEntities();
|
return _caption.toTextWithEntities();
|
||||||
}
|
}
|
||||||
bool needsBubble() const override;
|
bool needsBubble() const override;
|
||||||
bool customInfoLayout() const override {
|
bool customInfoLayout() const override {
|
||||||
|
|
|
@ -183,7 +183,7 @@ HistoryPoll::Answer::Answer() : text(st::msgMinWidth / 2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryPoll::Answer::fillText(const PollAnswer &original) {
|
void HistoryPoll::Answer::fillText(const PollAnswer &original) {
|
||||||
if (!text.isEmpty() && text.originalText() == original.text) {
|
if (!text.isEmpty() && text.toString() == original.text) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
text.setText(
|
text.setText(
|
||||||
|
@ -320,7 +320,7 @@ void HistoryPoll::updateTexts() {
|
||||||
|
|
||||||
const auto willStartAnimation = checkAnimationStart();
|
const auto willStartAnimation = checkAnimationStart();
|
||||||
|
|
||||||
if (_question.originalText() != _poll->question) {
|
if (_question.toString() != _poll->question) {
|
||||||
_question.setText(
|
_question.setText(
|
||||||
st::historyPollQuestionStyle,
|
st::historyPollQuestionStyle,
|
||||||
_poll->question,
|
_poll->question,
|
||||||
|
|
|
@ -577,7 +577,7 @@ void HistoryVideo::setStatusSize(int newSize) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
TextWithEntities HistoryVideo::selectedText(TextSelection selection) const {
|
TextWithEntities HistoryVideo::selectedText(TextSelection selection) const {
|
||||||
return _caption.originalTextWithEntities(selection, ExpandLinksAll);
|
return _caption.toTextWithEntities(selection, ExpandLinksAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryVideo::needsBubble() const {
|
bool HistoryVideo::needsBubble() const {
|
||||||
|
|
|
@ -55,7 +55,7 @@ public:
|
||||||
bool uploading() const override;
|
bool uploading() const override;
|
||||||
|
|
||||||
TextWithEntities getCaption() const override {
|
TextWithEntities getCaption() const override {
|
||||||
return _caption.originalTextWithEntities();
|
return _caption.toTextWithEntities();
|
||||||
}
|
}
|
||||||
bool needsBubble() const override;
|
bool needsBubble() const override;
|
||||||
bool customInfoLayout() const override {
|
bool customInfoLayout() const override {
|
||||||
|
|
|
@ -686,10 +686,10 @@ bool HistoryWebPage::isDisplayed() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
TextWithEntities HistoryWebPage::selectedText(TextSelection selection) const {
|
TextWithEntities HistoryWebPage::selectedText(TextSelection selection) const {
|
||||||
auto titleResult = _title.originalTextWithEntities(
|
auto titleResult = _title.toTextWithEntities(
|
||||||
selection,
|
selection,
|
||||||
ExpandLinksAll);
|
ExpandLinksAll);
|
||||||
auto descriptionResult = _description.originalTextWithEntities(
|
auto descriptionResult = _description.toTextWithEntities(
|
||||||
toDescriptionSelection(selection),
|
toDescriptionSelection(selection),
|
||||||
ExpandLinksAll);
|
ExpandLinksAll);
|
||||||
if (titleResult.text.isEmpty()) {
|
if (titleResult.text.isEmpty()) {
|
||||||
|
|
|
@ -1070,9 +1070,7 @@ QString ListWidget::tooltipText() const {
|
||||||
QLocale::system().dateTimeFormat(QLocale::LongFormat));
|
QLocale::system().dateTimeFormat(QLocale::LongFormat));
|
||||||
} else if (_mouseCursorState == CursorState::Forwarded && item) {
|
} else if (_mouseCursorState == CursorState::Forwarded && item) {
|
||||||
if (const auto forwarded = item->Get<HistoryMessageForwarded>()) {
|
if (const auto forwarded = item->Get<HistoryMessageForwarded>()) {
|
||||||
return forwarded->text.originalText(
|
return forwarded->text.toString();
|
||||||
AllTextSelection,
|
|
||||||
ExpandLinksNone);
|
|
||||||
}
|
}
|
||||||
} else if (const auto link = ClickHandler::getActive()) {
|
} else if (const auto link = ClickHandler::getActive()) {
|
||||||
return link->tooltip();
|
return link->tooltip();
|
||||||
|
|
|
@ -1059,7 +1059,7 @@ TextWithEntities Message::selectedText(TextSelection selection) const {
|
||||||
const auto media = this->media();
|
const auto media = this->media();
|
||||||
|
|
||||||
TextWithEntities logEntryOriginalResult;
|
TextWithEntities logEntryOriginalResult;
|
||||||
auto textResult = item->_text.originalTextWithEntities(
|
auto textResult = item->_text.toTextWithEntities(
|
||||||
selection,
|
selection,
|
||||||
ExpandLinksAll);
|
ExpandLinksAll);
|
||||||
auto skipped = skipTextSelection(selection);
|
auto skipped = skipTextSelection(selection);
|
||||||
|
@ -1783,7 +1783,7 @@ void Message::refreshEditedBadge() {
|
||||||
if (const auto msgsigned = item->Get<HistoryMessageSigned>()) {
|
if (const auto msgsigned = item->Get<HistoryMessageSigned>()) {
|
||||||
const auto text = (!edited || !editDate)
|
const auto text = (!edited || !editDate)
|
||||||
? dateText
|
? dateText
|
||||||
: edited->text.originalText();
|
: edited->text.toString();
|
||||||
msgsigned->refresh(text);
|
msgsigned->refresh(text);
|
||||||
}
|
}
|
||||||
initTime();
|
initTime();
|
||||||
|
|
|
@ -531,7 +531,7 @@ void Service::updatePressed(QPoint point) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TextWithEntities Service::selectedText(TextSelection selection) const {
|
TextWithEntities Service::selectedText(TextSelection selection) const {
|
||||||
return message()->_text.originalTextWithEntities(selection);
|
return message()->_text.toTextWithEntities(selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextSelection Service::adjustSelection(
|
TextSelection Service::adjustSelection(
|
||||||
|
|
|
@ -743,7 +743,7 @@ void TopBarWidget::updateOnlineDisplay() {
|
||||||
text = lang(lng_chat_status_unaccessible);
|
text = lang(lng_chat_status_unaccessible);
|
||||||
} else if (chat->participants.empty()) {
|
} else if (chat->participants.empty()) {
|
||||||
if (!_titlePeerText.isEmpty()) {
|
if (!_titlePeerText.isEmpty()) {
|
||||||
text = _titlePeerText.originalText();
|
text = _titlePeerText.toString();
|
||||||
} else if (chat->count <= 0) {
|
} else if (chat->count <= 0) {
|
||||||
text = lang(lng_group_status);
|
text = lang(lng_group_status);
|
||||||
} else {
|
} else {
|
||||||
|
@ -800,7 +800,7 @@ void TopBarWidget::updateOnlineDisplay() {
|
||||||
text = lang(channel->isMegagroup() ? lng_group_status : lng_channel_status);
|
text = lang(channel->isMegagroup() ? lng_group_status : lng_channel_status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_titlePeerText.originalText() != text) {
|
if (_titlePeerText.toString() != text) {
|
||||||
_titlePeerText.setText(st::dialogsTextStyle, text);
|
_titlePeerText.setText(st::dialogsTextStyle, text);
|
||||||
_titlePeerTextOnline = titlePeerTextOnline;
|
_titlePeerTextOnline = titlePeerTextOnline;
|
||||||
updateMembersShowArea();
|
updateMembersShowArea();
|
||||||
|
|
|
@ -3046,12 +3046,14 @@ void Text::enumerateText(TextSelection selection, AppendPartCallback appendPartC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextWithEntities Text::originalTextWithEntities(TextSelection selection, ExpandLinksMode mode) const {
|
|
||||||
|
|
||||||
|
TextWithEntities Text::toTextWithEntities(TextSelection selection, ExpandLinksMode mode) const {
|
||||||
TextWithEntities result;
|
TextWithEntities result;
|
||||||
result.text.reserve(_text.size());
|
result.text.reserve(_text.size());
|
||||||
|
|
||||||
int lnkStart = 0, italicStart = 0, boldStart = 0, codeStart = 0, preStart = 0;
|
int lnkStart = 0, italicStart = 0, boldStart = 0, codeStart = 0, preStart = 0;
|
||||||
auto flagsChangeCallback = [&result, &italicStart, &boldStart, &codeStart, &preStart](int32 oldFlags, int32 newFlags) {
|
auto flagsChangeCallback = [&](int32 oldFlags, int32 newFlags) {
|
||||||
if ((oldFlags & TextBlockFItalic) && !(newFlags & TextBlockFItalic)) { // write italic
|
if ((oldFlags & TextBlockFItalic) && !(newFlags & TextBlockFItalic)) { // write italic
|
||||||
result.entities.push_back(EntityInText(EntityInTextItalic, italicStart, result.text.size() - italicStart));
|
result.entities.push_back(EntityInText(EntityInTextItalic, italicStart, result.text.size() - italicStart));
|
||||||
} else if ((newFlags & TextBlockFItalic) && !(oldFlags & TextBlockFItalic)) {
|
} else if ((newFlags & TextBlockFItalic) && !(oldFlags & TextBlockFItalic)) {
|
||||||
|
@ -3073,12 +3075,17 @@ TextWithEntities Text::originalTextWithEntities(TextSelection selection, ExpandL
|
||||||
preStart = result.text.size();
|
preStart = result.text.size();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
auto clickHandlerStartCallback = [&result, &lnkStart]() {
|
auto clickHandlerStartCallback = [&] {
|
||||||
lnkStart = result.text.size();
|
lnkStart = result.text.size();
|
||||||
};
|
};
|
||||||
auto clickHandlerFinishCallback = [mode, &result, &lnkStart](const QStringRef &r, const ClickHandlerPtr &handler) {
|
auto clickHandlerFinishCallback = [&](const QStringRef &r, const ClickHandlerPtr &handler) {
|
||||||
auto expanded = handler->getExpandedLinkTextWithEntities(mode, lnkStart, r);
|
const auto expanded = handler->getExpandedLinkTextWithEntities(lnkStart, r);
|
||||||
if (expanded.text.isEmpty()) {
|
if (mode == ExpandLinksAll
|
||||||
|
&& !expanded.entities.isEmpty()
|
||||||
|
&& expanded.entities[0].type() == EntityInTextCustomUrl) {
|
||||||
|
result.text += r;
|
||||||
|
result.text += qsl(" (") + expanded.entities[0].data() + ')';
|
||||||
|
} else if (expanded.text.isEmpty()) {
|
||||||
result.text += r;
|
result.text += r;
|
||||||
} else {
|
} else {
|
||||||
result.text += expanded.text;
|
result.text += expanded.text;
|
||||||
|
@ -3087,7 +3094,7 @@ TextWithEntities Text::originalTextWithEntities(TextSelection selection, ExpandL
|
||||||
result.entities.append(expanded.entities);
|
result.entities.append(expanded.entities);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
auto appendPartCallback = [&result](const QStringRef &r) {
|
auto appendPartCallback = [&](const QStringRef &r) {
|
||||||
result.text += r;
|
result.text += r;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3096,29 +3103,8 @@ TextWithEntities Text::originalTextWithEntities(TextSelection selection, ExpandL
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Text::originalText(TextSelection selection, ExpandLinksMode mode) const {
|
QString Text::toString(TextSelection selection, ExpandLinksMode mode) const {
|
||||||
QString result;
|
return toTextWithEntities(selection, mode).text;
|
||||||
result.reserve(_text.size());
|
|
||||||
|
|
||||||
auto appendPartCallback = [&result](const QStringRef &r) {
|
|
||||||
result += r;
|
|
||||||
};
|
|
||||||
auto clickHandlerStartCallback = []() {
|
|
||||||
};
|
|
||||||
auto clickHandlerFinishCallback = [mode, &result](const QStringRef &r, const ClickHandlerPtr &handler) {
|
|
||||||
auto expanded = handler->getExpandedLinkText(mode, r);
|
|
||||||
if (expanded.isEmpty()) {
|
|
||||||
result += r;
|
|
||||||
} else {
|
|
||||||
result += expanded;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
auto flagsChangeCallback = [](int32 oldFlags, int32 newFlags) {
|
|
||||||
};
|
|
||||||
|
|
||||||
enumerateText(selection, appendPartCallback, clickHandlerStartCallback, clickHandlerFinishCallback, flagsChangeCallback);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Text::clear() {
|
void Text::clear() {
|
||||||
|
|
|
@ -165,8 +165,8 @@ public:
|
||||||
return _text.size();
|
return _text.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
TextWithEntities originalTextWithEntities(TextSelection selection = AllTextSelection, ExpandLinksMode mode = ExpandLinksShortened) const;
|
QString toString(TextSelection selection = AllTextSelection, ExpandLinksMode mode = ExpandLinksShortened) const;
|
||||||
QString originalText(TextSelection selection = AllTextSelection, ExpandLinksMode mode = ExpandLinksShortened) const;
|
TextWithEntities toTextWithEntities(TextSelection selection = AllTextSelection, ExpandLinksMode mode = ExpandLinksShortened) const;
|
||||||
|
|
||||||
bool lastDots(int32 dots, int32 maxdots = 3) { // hack for typing animation
|
bool lastDots(int32 dots, int32 maxdots = 3) { // hack for typing animation
|
||||||
if (_text.size() < maxdots) return false;
|
if (_text.size() < maxdots) return false;
|
||||||
|
|
|
@ -571,14 +571,14 @@ void FlatLabel::showContextMenu(QContextMenuEvent *e, ContextMenuReason reason)
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlatLabel::onCopySelectedText() {
|
void FlatLabel::onCopySelectedText() {
|
||||||
auto selection = _selection.empty() ? (_contextMenu ? _savedSelection : _selection) : _selection;
|
const auto selection = _selection.empty() ? (_contextMenu ? _savedSelection : _selection) : _selection;
|
||||||
if (!selection.empty()) {
|
if (!selection.empty()) {
|
||||||
QApplication::clipboard()->setText(_text.originalText(selection, _contextExpandLinksMode));
|
QApplication::clipboard()->setText(_text.toString(selection, _contextExpandLinksMode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlatLabel::onCopyContextText() {
|
void FlatLabel::onCopyContextText() {
|
||||||
QApplication::clipboard()->setText(_text.originalText({ 0, 0xFFFF }, _contextExpandLinksMode));
|
QApplication::clipboard()->setText(_text.toString(AllTextSelection, _contextExpandLinksMode));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlatLabel::onTouchSelect() {
|
void FlatLabel::onTouchSelect() {
|
||||||
|
@ -606,7 +606,7 @@ void FlatLabel::onExecuteDrag() {
|
||||||
ClickHandlerPtr pressedHandler = ClickHandler::getPressed();
|
ClickHandlerPtr pressedHandler = ClickHandler::getPressed();
|
||||||
QString selectedText;
|
QString selectedText;
|
||||||
if (uponSelected) {
|
if (uponSelected) {
|
||||||
selectedText = _text.originalText(_selection, ExpandLinksAll);
|
selectedText = _text.toString(_selection, ExpandLinksAll);
|
||||||
} else if (pressedHandler) {
|
} else if (pressedHandler) {
|
||||||
selectedText = pressedHandler->dragText();
|
selectedText = pressedHandler->dragText();
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
QString description() const {
|
QString description() const {
|
||||||
return _description.originalText();
|
return _description.toString();
|
||||||
}
|
}
|
||||||
const Text &descriptionText() const {
|
const Text &descriptionText() const {
|
||||||
return _description;
|
return _description;
|
||||||
|
@ -152,7 +152,7 @@ void EditorBlock::Row::fillValueString() {
|
||||||
void EditorBlock::Row::fillSearchIndex() {
|
void EditorBlock::Row::fillSearchIndex() {
|
||||||
_searchWords.clear();
|
_searchWords.clear();
|
||||||
_searchStartChars.clear();
|
_searchStartChars.clear();
|
||||||
auto toIndex = _name + ' ' + _copyOf + ' ' + TextUtilities::RemoveAccents(_description.originalText()) + ' ' + _valueString;
|
auto toIndex = _name + ' ' + _copyOf + ' ' + TextUtilities::RemoveAccents(_description.toString()) + ' ' + _valueString;
|
||||||
auto words = toIndex.toLower().split(SearchSplitter, QString::SkipEmptyParts);
|
auto words = toIndex.toLower().split(SearchSplitter, QString::SkipEmptyParts);
|
||||||
for_const (auto &word, words) {
|
for_const (auto &word, words) {
|
||||||
_searchWords.insert(word);
|
_searchWords.insert(word);
|
||||||
|
|
Loading…
Reference in New Issue