Remove ExpandLinksNone, rename Text::originalText.

This commit is contained in:
John Preston 2019-04-08 15:53:08 +04:00
parent cc2fd51097
commit ff51423125
32 changed files with 80 additions and 147 deletions

View File

@ -50,11 +50,7 @@ bool ClickHandler::setActive(const ClickHandlerPtr &p, ClickHandlerHost *host) {
return true;
}
QString ClickHandler::getExpandedLinkText(ExpandLinksMode mode, const QStringRef &textPart) const {
return QString();
}
TextWithEntities ClickHandler::getExpandedLinkTextWithEntities(ExpandLinksMode mode, int entityOffset, const QStringRef &textPart) const {
TextWithEntities ClickHandler::getExpandedLinkTextWithEntities(int entityOffset, const QStringRef &textPart) const {
return { QString(), EntitiesInText() };
}

View File

@ -16,10 +16,8 @@ struct ClickContext {
};
enum ExpandLinksMode {
ExpandLinksNone,
ExpandLinksShortened,
ExpandLinksAll,
ExpandLinksUrlOnly, // For custom urls leaves only url instead of text.
};
class ClickHandlerHost {
@ -63,8 +61,7 @@ public:
// Entities in text support.
// 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(ExpandLinksMode mode, int entityOffset, const QStringRef &textPart) const;
virtual TextWithEntities getExpandedLinkTextWithEntities(int entityOffset, const QStringRef &textPart) const;
// This method should be called on mouse over a click handler.
// It returns true if the active handler was changed or false otherwise.

View File

@ -133,22 +133,13 @@ void UrlClickHandler::Open(QString url, QVariant context) {
}
}
QString UrlClickHandler::getExpandedLinkText(ExpandLinksMode mode, const QStringRef &textPart) const {
QString result;
if (mode != ExpandLinksNone) {
result = _originalUrl;
}
return result;
}
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();
}
TextWithEntities UrlClickHandler::getExpandedLinkTextWithEntities(int entityOffset, const QStringRef &textPart) const {
auto result = TextWithEntities();
result.text = _originalUrl;
const auto entityLength = _originalUrl.size();
const auto entityType = isEmail(_originalUrl)
? EntityInTextEmail
: EntityInTextUrl;
result.entities.push_back({ entityType, entityOffset, entityLength });
return result;
}
@ -209,28 +200,8 @@ void BotGameUrlClickHandler::onClick(ClickContext context) const {
}
}
QString HiddenUrlClickHandler::getExpandedLinkText(ExpandLinksMode mode, const QStringRef &textPart) const {
QString result;
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;
TextWithEntities HiddenUrlClickHandler::getExpandedLinkTextWithEntities(int entityOffset, const QStringRef &textPart) const {
return simpleTextWithEntity({ EntityInTextCustomUrl, entityOffset, textPart.size(), url() });
}
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() });
}
@ -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);
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() });
}
@ -299,7 +270,6 @@ void CashtagClickHandler::onClick(ClickContext context) const {
}
TextWithEntities CashtagClickHandler::getExpandedLinkTextWithEntities(
ExpandLinksMode mode,
int entityOffset,
const QStringRef &textPart) const {
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() });
}

View File

@ -47,11 +47,7 @@ public:
return url();
}
QString getExpandedLinkText(
ExpandLinksMode mode,
const QStringRef &textPart) const override;
TextWithEntities getExpandedLinkTextWithEntities(
ExpandLinksMode mode,
int entityOffset,
const QStringRef &textPart) const override;
@ -100,11 +96,7 @@ public:
}
}
QString getExpandedLinkText(
ExpandLinksMode mode,
const QStringRef &textPart) const override;
TextWithEntities getExpandedLinkTextWithEntities(
ExpandLinksMode mode,
int entityOffset,
const QStringRef &textPart) const override;
@ -137,7 +129,6 @@ public:
QString copyToClipboardContextItemText() const override;
TextWithEntities getExpandedLinkTextWithEntities(
ExpandLinksMode mode,
int entityOffset,
const QStringRef &textPart) const override;
@ -162,7 +153,6 @@ public:
void onClick(ClickContext context) const override;
TextWithEntities getExpandedLinkTextWithEntities(
ExpandLinksMode mode,
int entityOffset,
const QStringRef &textPart) const override;
@ -189,7 +179,6 @@ public:
QString copyToClipboardContextItemText() const override;
TextWithEntities getExpandedLinkTextWithEntities(
ExpandLinksMode mode,
int entityOffset,
const QStringRef &textPart) const override;
@ -217,7 +206,6 @@ public:
QString copyToClipboardContextItemText() const override;
TextWithEntities getExpandedLinkTextWithEntities(
ExpandLinksMode mode,
int entityOffset,
const QStringRef &textPart) const override;
@ -252,7 +240,6 @@ public:
}
TextWithEntities getExpandedLinkTextWithEntities(
ExpandLinksMode mode,
int entityOffset,
const QStringRef &textPart) const override;

View File

@ -471,7 +471,7 @@ QString InnerWidget::tooltipText() const {
&& _mouseAction == MouseAction::None) {
if (const auto view = App::hoveredItem()) {
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()) {

View File

@ -3103,7 +3103,7 @@ QString HistoryInner::tooltipText() const {
&& _mouseAction == MouseAction::None) {
if (const auto view = App::hoveredItem()) {
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()) {

View File

@ -43,6 +43,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace {
constexpr auto kNotificationTextLimit = 255;
enum class MediaCheckResult {
Good,
Unsupported,
@ -686,20 +688,17 @@ bool HistoryItem::isEmpty() const {
}
QString HistoryItem::notificationText() const {
auto getText = [this]() {
const auto result = [&] {
if (_media) {
return _media->notificationText();
} else if (!emptyText()) {
return _text.originalText();
return _text.toString();
}
return QString();
};
auto result = getText();
if (result.size() > 0xFF) {
result = result.mid(0, 0xFF) + qsl("...");
}
return result;
}();
return (result.size() <= kNotificationTextLimit)
? result
: result.mid(0, kNotificationTextLimit) + qsl("...");
}
QString HistoryItem::inDialogsText(DrawInDialog way) const {
@ -710,7 +709,7 @@ QString HistoryItem::inDialogsText(DrawInDialog way) const {
}
return _media->chatListText();
} else if (!emptyText()) {
return TextUtilities::Clean(_text.originalText());
return TextUtilities::Clean(_text.toString());
}
return QString();
};

View File

@ -39,7 +39,7 @@ TextWithEntities WrapAsReply(
TextWithEntities WrapAsForwarded(
TextWithEntities &&text,
not_null<HistoryMessageForwarded*> forwarded) {
auto info = forwarded->text.originalTextWithEntities(
auto info = forwarded->text.toTextWithEntities(
AllTextSelection,
ExpandLinksAll);
auto result = TextWithEntities();

View File

@ -1093,14 +1093,14 @@ TextWithEntities HistoryMessage::originalText() const {
if (emptyText()) {
return { QString(), EntitiesInText() };
}
return _text.originalTextWithEntities();
return _text.toTextWithEntities();
}
TextWithEntities HistoryMessage::clipboardText() const {
if (emptyText()) {
return { QString(), EntitiesInText() };
}
return _text.originalTextWithEntities(AllTextSelection, ExpandLinksAll);
return _text.toTextWithEntities(AllTextSelection, ExpandLinksAll);
}
bool HistoryMessage::textHasLinks() const {

View File

@ -99,7 +99,7 @@ QSize HistoryContact::countOptimalSize() {
if (_contact) {
_contact->loadUserpic();
} else {
const auto full = _name.originalText();
const auto full = _name.toString();
_photoEmpty = std::make_unique<Ui::EmptyUserpic>(
Data::PeerUserpicColor(_userId
? peerFromUser(_userId)

View File

@ -654,7 +654,7 @@ bool HistoryDocument::hasTextForCopy() const {
TextWithEntities HistoryDocument::selectedText(TextSelection selection) const {
if (const auto captioned = Get<HistoryDocumentCaptioned>()) {
const auto &caption = captioned->_caption;
return caption.originalTextWithEntities(selection, ExpandLinksAll);
return caption.toTextWithEntities(selection, ExpandLinksAll);
}
return TextWithEntities();
}
@ -838,7 +838,7 @@ void HistoryDocument::parentTextUpdated() {
TextWithEntities HistoryDocument::getCaption() const {
if (const auto captioned = Get<HistoryDocumentCaptioned>()) {
return captioned->_caption.originalTextWithEntities();
return captioned->_caption.toTextWithEntities();
}
return TextWithEntities();
}

View File

@ -368,10 +368,10 @@ void HistoryGame::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pres
}
TextWithEntities HistoryGame::selectedText(TextSelection selection) const {
auto titleResult = _title.originalTextWithEntities(
auto titleResult = _title.toTextWithEntities(
selection,
ExpandLinksAll);
auto descriptionResult = _description.originalTextWithEntities(
auto descriptionResult = _description.toTextWithEntities(
toDescriptionSelection(selection),
ExpandLinksAll);
if (titleResult.text.isEmpty()) {

View File

@ -681,7 +681,7 @@ TextState HistoryGif::textState(QPoint point, StateRequest request) const {
}
TextWithEntities HistoryGif::selectedText(TextSelection selection) const {
return _caption.originalTextWithEntities(selection, ExpandLinksAll);
return _caption.toTextWithEntities(selection, ExpandLinksAll);
}
bool HistoryGif::uploading() const {

View File

@ -57,7 +57,7 @@ public:
void stopAnimation() override;
TextWithEntities getCaption() const override {
return _caption.originalTextWithEntities();
return _caption.toTextWithEntities();
}
bool needsBubble() const override;
bool customInfoLayout() const override {

View File

@ -306,7 +306,7 @@ TextSelection HistoryGroupedMedia::adjustSelection(
TextWithEntities HistoryGroupedMedia::selectedText(
TextSelection selection) const {
return _caption.originalTextWithEntities(selection, ExpandLinksAll);
return _caption.toTextWithEntities(selection, ExpandLinksAll);
}
void HistoryGroupedMedia::clickHandlerActiveChanged(

View File

@ -359,10 +359,10 @@ void HistoryInvoice::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool p
}
TextWithEntities HistoryInvoice::selectedText(TextSelection selection) const {
auto titleResult = _title.originalTextWithEntities(
auto titleResult = _title.toTextWithEntities(
selection,
ExpandLinksAll);
auto descriptionResult = _description.originalTextWithEntities(
auto descriptionResult = _description.toTextWithEntities(
toDescriptionSelection(selection),
ExpandLinksAll);
if (titleResult.text.isEmpty()) {

View File

@ -25,7 +25,7 @@ public:
return _receiptMsgId;
}
QString getTitle() const {
return _title.originalText();
return _title.toString();
}
bool hideMessageText() const override {

View File

@ -279,8 +279,8 @@ TextSelection HistoryLocation::adjustSelection(TextSelection selection, TextSele
}
TextWithEntities HistoryLocation::selectedText(TextSelection selection) const {
auto titleResult = _title.originalTextWithEntities(selection);
auto descriptionResult = _description.originalTextWithEntities(toDescriptionSelection(selection));
auto titleResult = _title.toTextWithEntities(selection);
auto descriptionResult = _description.toTextWithEntities(toDescriptionSelection(selection));
if (titleResult.text.isEmpty()) {
return descriptionResult;
} else if (descriptionResult.text.isEmpty()) {

View File

@ -536,7 +536,7 @@ void HistoryPhoto::validateGroupedCache(
}
TextWithEntities HistoryPhoto::selectedText(TextSelection selection) const {
return _caption.originalTextWithEntities(selection, ExpandLinksAll);
return _caption.toTextWithEntities(selection, ExpandLinksAll);
}
bool HistoryPhoto::needsBubble() const {

View File

@ -58,7 +58,7 @@ public:
StateRequest request) const override;
TextWithEntities getCaption() const override {
return _caption.originalTextWithEntities();
return _caption.toTextWithEntities();
}
bool needsBubble() const override;
bool customInfoLayout() const override {

View File

@ -183,7 +183,7 @@ HistoryPoll::Answer::Answer() : text(st::msgMinWidth / 2) {
}
void HistoryPoll::Answer::fillText(const PollAnswer &original) {
if (!text.isEmpty() && text.originalText() == original.text) {
if (!text.isEmpty() && text.toString() == original.text) {
return;
}
text.setText(
@ -320,7 +320,7 @@ void HistoryPoll::updateTexts() {
const auto willStartAnimation = checkAnimationStart();
if (_question.originalText() != _poll->question) {
if (_question.toString() != _poll->question) {
_question.setText(
st::historyPollQuestionStyle,
_poll->question,

View File

@ -577,7 +577,7 @@ void HistoryVideo::setStatusSize(int newSize) const {
}
TextWithEntities HistoryVideo::selectedText(TextSelection selection) const {
return _caption.originalTextWithEntities(selection, ExpandLinksAll);
return _caption.toTextWithEntities(selection, ExpandLinksAll);
}
bool HistoryVideo::needsBubble() const {

View File

@ -55,7 +55,7 @@ public:
bool uploading() const override;
TextWithEntities getCaption() const override {
return _caption.originalTextWithEntities();
return _caption.toTextWithEntities();
}
bool needsBubble() const override;
bool customInfoLayout() const override {

View File

@ -686,10 +686,10 @@ bool HistoryWebPage::isDisplayed() const {
}
TextWithEntities HistoryWebPage::selectedText(TextSelection selection) const {
auto titleResult = _title.originalTextWithEntities(
auto titleResult = _title.toTextWithEntities(
selection,
ExpandLinksAll);
auto descriptionResult = _description.originalTextWithEntities(
auto descriptionResult = _description.toTextWithEntities(
toDescriptionSelection(selection),
ExpandLinksAll);
if (titleResult.text.isEmpty()) {

View File

@ -1070,9 +1070,7 @@ QString ListWidget::tooltipText() const {
QLocale::system().dateTimeFormat(QLocale::LongFormat));
} else if (_mouseCursorState == CursorState::Forwarded && item) {
if (const auto forwarded = item->Get<HistoryMessageForwarded>()) {
return forwarded->text.originalText(
AllTextSelection,
ExpandLinksNone);
return forwarded->text.toString();
}
} else if (const auto link = ClickHandler::getActive()) {
return link->tooltip();

View File

@ -1059,7 +1059,7 @@ TextWithEntities Message::selectedText(TextSelection selection) const {
const auto media = this->media();
TextWithEntities logEntryOriginalResult;
auto textResult = item->_text.originalTextWithEntities(
auto textResult = item->_text.toTextWithEntities(
selection,
ExpandLinksAll);
auto skipped = skipTextSelection(selection);
@ -1783,7 +1783,7 @@ void Message::refreshEditedBadge() {
if (const auto msgsigned = item->Get<HistoryMessageSigned>()) {
const auto text = (!edited || !editDate)
? dateText
: edited->text.originalText();
: edited->text.toString();
msgsigned->refresh(text);
}
initTime();

View File

@ -531,7 +531,7 @@ void Service::updatePressed(QPoint point) {
}
TextWithEntities Service::selectedText(TextSelection selection) const {
return message()->_text.originalTextWithEntities(selection);
return message()->_text.toTextWithEntities(selection);
}
TextSelection Service::adjustSelection(

View File

@ -743,7 +743,7 @@ void TopBarWidget::updateOnlineDisplay() {
text = lang(lng_chat_status_unaccessible);
} else if (chat->participants.empty()) {
if (!_titlePeerText.isEmpty()) {
text = _titlePeerText.originalText();
text = _titlePeerText.toString();
} else if (chat->count <= 0) {
text = lang(lng_group_status);
} else {
@ -800,7 +800,7 @@ void TopBarWidget::updateOnlineDisplay() {
text = lang(channel->isMegagroup() ? lng_group_status : lng_channel_status);
}
}
if (_titlePeerText.originalText() != text) {
if (_titlePeerText.toString() != text) {
_titlePeerText.setText(st::dialogsTextStyle, text);
_titlePeerTextOnline = titlePeerTextOnline;
updateMembersShowArea();

View File

@ -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;
result.text.reserve(_text.size());
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
result.entities.push_back(EntityInText(EntityInTextItalic, italicStart, result.text.size() - italicStart));
} else if ((newFlags & TextBlockFItalic) && !(oldFlags & TextBlockFItalic)) {
@ -3073,12 +3075,17 @@ TextWithEntities Text::originalTextWithEntities(TextSelection selection, ExpandL
preStart = result.text.size();
}
};
auto clickHandlerStartCallback = [&result, &lnkStart]() {
auto clickHandlerStartCallback = [&] {
lnkStart = result.text.size();
};
auto clickHandlerFinishCallback = [mode, &result, &lnkStart](const QStringRef &r, const ClickHandlerPtr &handler) {
auto expanded = handler->getExpandedLinkTextWithEntities(mode, lnkStart, r);
if (expanded.text.isEmpty()) {
auto clickHandlerFinishCallback = [&](const QStringRef &r, const ClickHandlerPtr &handler) {
const auto expanded = handler->getExpandedLinkTextWithEntities(lnkStart, r);
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;
} else {
result.text += expanded.text;
@ -3087,7 +3094,7 @@ TextWithEntities Text::originalTextWithEntities(TextSelection selection, ExpandL
result.entities.append(expanded.entities);
}
};
auto appendPartCallback = [&result](const QStringRef &r) {
auto appendPartCallback = [&](const QStringRef &r) {
result.text += r;
};
@ -3096,29 +3103,8 @@ TextWithEntities Text::originalTextWithEntities(TextSelection selection, ExpandL
return result;
}
QString Text::originalText(TextSelection selection, ExpandLinksMode mode) const {
QString result;
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;
QString Text::toString(TextSelection selection, ExpandLinksMode mode) const {
return toTextWithEntities(selection, mode).text;
}
void Text::clear() {

View File

@ -165,8 +165,8 @@ public:
return _text.size();
}
TextWithEntities originalTextWithEntities(TextSelection selection = AllTextSelection, ExpandLinksMode mode = ExpandLinksShortened) const;
QString originalText(TextSelection selection = AllTextSelection, ExpandLinksMode mode = ExpandLinksShortened) const;
QString toString(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
if (_text.size() < maxdots) return false;

View File

@ -571,14 +571,14 @@ void FlatLabel::showContextMenu(QContextMenuEvent *e, ContextMenuReason reason)
}
void FlatLabel::onCopySelectedText() {
auto selection = _selection.empty() ? (_contextMenu ? _savedSelection : _selection) : _selection;
const auto selection = _selection.empty() ? (_contextMenu ? _savedSelection : _selection) : _selection;
if (!selection.empty()) {
QApplication::clipboard()->setText(_text.originalText(selection, _contextExpandLinksMode));
QApplication::clipboard()->setText(_text.toString(selection, _contextExpandLinksMode));
}
}
void FlatLabel::onCopyContextText() {
QApplication::clipboard()->setText(_text.originalText({ 0, 0xFFFF }, _contextExpandLinksMode));
QApplication::clipboard()->setText(_text.toString(AllTextSelection, _contextExpandLinksMode));
}
void FlatLabel::onTouchSelect() {
@ -606,7 +606,7 @@ void FlatLabel::onExecuteDrag() {
ClickHandlerPtr pressedHandler = ClickHandler::getPressed();
QString selectedText;
if (uponSelected) {
selectedText = _text.originalText(_selection, ExpandLinksAll);
selectedText = _text.toString(_selection, ExpandLinksAll);
} else if (pressedHandler) {
selectedText = pressedHandler->dragText();
}

View File

@ -43,7 +43,7 @@ public:
}
QString description() const {
return _description.originalText();
return _description.toString();
}
const Text &descriptionText() const {
return _description;
@ -152,7 +152,7 @@ void EditorBlock::Row::fillValueString() {
void EditorBlock::Row::fillSearchIndex() {
_searchWords.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);
for_const (auto &word, words) {
_searchWords.insert(word);