2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Everywhere TextWithTags and TextWithEntities are used.

Copy tags from messages to clipboard, to drag mime data.
Sorting entities while processing (links, monospace, mentions).
This commit is contained in:
John Preston
2016-05-06 20:33:48 +03:00
parent 463450e607
commit 3e5f51f45a
19 changed files with 542 additions and 369 deletions

View File

@@ -1293,8 +1293,8 @@ public:
}
virtual void previousItemChanged();
virtual QString selectedText(TextSelection selection) const {
return qsl("[-]");
virtual TextWithEntities selectedText(TextSelection selection) const {
return { qsl("[-]"), EntitiesInText() };
}
virtual QString inDialogsText() const {
return qsl("-");
@@ -1302,6 +1302,9 @@ public:
virtual QString inReplyText() const {
return inDialogsText();
}
virtual TextWithEntities originalText() const {
return { QString(), EntitiesInText() };
}
virtual void drawInfo(Painter &p, int32 right, int32 bottom, int32 width, bool selected, InfoDisplayType type) const {
}
@@ -1363,15 +1366,9 @@ public:
virtual HistoryMedia *getMedia() const {
return nullptr;
}
virtual void setText(const QString &text, const EntitiesInText &links) {
virtual void setText(const TextWithEntities &textWithEntities) {
}
virtual QString originalText() const {
return QString();
}
virtual EntitiesInText originalEntities() const {
return EntitiesInText();
}
virtual bool textHasLinks() {
virtual bool textHasLinks() const {
return false;
}
@@ -1663,7 +1660,7 @@ public:
virtual HistoryMediaType type() const = 0;
virtual QString inDialogsText() const = 0;
virtual QString selectedText(TextSelection selection) const = 0;
virtual TextWithEntities selectedText(TextSelection selection) const = 0;
bool hasPoint(int x, int y) const {
return (x >= 0 && y >= 0 && x < _width && y < _height);
@@ -1750,8 +1747,8 @@ public:
virtual ImagePtr replyPreview() {
return ImagePtr();
}
virtual QString getCaption() const {
return QString();
virtual TextWithEntities getCaption() const {
return TextWithEntities();
}
virtual bool needsBubble() const = 0;
virtual bool customInfoLayout() const = 0;
@@ -1900,7 +1897,7 @@ public:
}
QString inDialogsText() const override;
QString selectedText(TextSelection selection) const override;
TextWithEntities selectedText(TextSelection selection) const override;
PhotoData *photo() const {
return _data;
@@ -1917,8 +1914,8 @@ public:
}
ImagePtr replyPreview() override;
QString getCaption() const override {
return _caption.original();
TextWithEntities getCaption() const override {
return _caption.originalTextWithEntities();
}
bool needsBubble() const override {
if (!_caption.isEmpty()) {
@@ -1980,7 +1977,7 @@ public:
}
QString inDialogsText() const override;
QString selectedText(TextSelection selection) const override;
TextWithEntities selectedText(TextSelection selection) const override;
DocumentData *getDocument() override {
return _data;
@@ -2000,8 +1997,8 @@ public:
}
ImagePtr replyPreview() override;
QString getCaption() const override {
return _caption.original();
TextWithEntities getCaption() const override {
return _caption.originalTextWithEntities();
}
bool needsBubble() const override {
if (!_caption.isEmpty()) {
@@ -2103,7 +2100,7 @@ public:
}
QString inDialogsText() const override;
QString selectedText(TextSelection selection) const override;
TextWithEntities selectedText(TextSelection selection) const override;
bool uploading() const override {
return _data->uploading();
@@ -2124,11 +2121,11 @@ public:
}
ImagePtr replyPreview() override;
QString getCaption() const override {
TextWithEntities getCaption() const override {
if (const HistoryDocumentCaptioned *captioned = Get<HistoryDocumentCaptioned>()) {
return captioned->_caption.original();
return captioned->_caption.originalTextWithEntities();
}
return QString();
return TextWithEntities();
}
bool needsBubble() const override {
return true;
@@ -2190,7 +2187,7 @@ public:
}
QString inDialogsText() const override;
QString selectedText(TextSelection selection) const override;
TextWithEntities selectedText(TextSelection selection) const override;
bool uploading() const override {
return _data->uploading();
@@ -2217,8 +2214,8 @@ public:
}
ImagePtr replyPreview() override;
QString getCaption() const override {
return _caption.original();
TextWithEntities getCaption() const override {
return _caption.originalTextWithEntities();
}
bool needsBubble() const override {
if (!_caption.isEmpty()) {
@@ -2288,7 +2285,7 @@ public:
}
QString inDialogsText() const override;
QString selectedText(TextSelection selection) const override;
TextWithEntities selectedText(TextSelection selection) const override;
DocumentData *getDocument() override {
return _data;
@@ -2357,7 +2354,7 @@ public:
}
QString inDialogsText() const override;
QString selectedText(TextSelection selection) const override;
TextWithEntities selectedText(TextSelection selection) const override;
void attachToParent() override;
void detachFromParent() override;
@@ -2425,7 +2422,7 @@ public:
}
QString inDialogsText() const override;
QString selectedText(TextSelection selection) const override;
TextWithEntities selectedText(TextSelection selection) const override;
void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) override;
void clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) override;
@@ -2559,7 +2556,7 @@ public:
}
QString inDialogsText() const override;
QString selectedText(TextSelection selection) const override;
TextWithEntities selectedText(TextSelection selection) const override;
bool needsBubble() const override {
if (!_title.isEmpty() || !_description.isEmpty()) {
@@ -2613,8 +2610,8 @@ public:
static HistoryMessage *create(History *history, MsgId msgId, MTPDmessage::Flags flags, QDateTime date, int32 from, HistoryMessage *fwd) {
return _create(history, msgId, flags, date, from, fwd);
}
static HistoryMessage *create(History *history, MsgId msgId, MTPDmessage::Flags flags, MsgId replyTo, int32 viaBotId, QDateTime date, int32 from, const QString &msg, const EntitiesInText &entities) {
return _create(history, msgId, flags, replyTo, viaBotId, date, from, msg, entities);
static HistoryMessage *create(History *history, MsgId msgId, MTPDmessage::Flags flags, MsgId replyTo, int32 viaBotId, QDateTime date, int32 from, const TextWithEntities &textWithEntities) {
return _create(history, msgId, flags, replyTo, viaBotId, date, from, textWithEntities);
}
static HistoryMessage *create(History *history, MsgId msgId, MTPDmessage::Flags flags, MsgId replyTo, int32 viaBotId, QDateTime date, int32 from, DocumentData *doc, const QString &caption, const MTPReplyMarkup &markup) {
return _create(history, msgId, flags, replyTo, viaBotId, date, from, doc, caption, markup);
@@ -2685,13 +2682,12 @@ public:
int32 addToOverview(AddToOverviewMethod method) override;
void eraseFromOverview();
QString selectedText(TextSelection selection) const override;
TextWithEntities selectedText(TextSelection selection) const override;
QString inDialogsText() const override;
HistoryMedia *getMedia() const override;
void setText(const QString &text, const EntitiesInText &entities) override;
QString originalText() const override;
EntitiesInText originalEntities() const override;
bool textHasLinks() override;
void setText(const TextWithEntities &textWithEntities) override;
TextWithEntities originalText() const override;
bool textHasLinks() const override;
int32 infoWidth() const override {
int32 result = _timeWidth;
@@ -2753,7 +2749,7 @@ private:
HistoryMessage(History *history, const MTPDmessage &msg);
HistoryMessage(History *history, MsgId msgId, MTPDmessage::Flags flags, QDateTime date, int32 from, HistoryMessage *fwd); // local forwarded
HistoryMessage(History *history, MsgId msgId, MTPDmessage::Flags flags, MsgId replyTo, int32 viaBotId, QDateTime date, int32 from, const QString &msg, const EntitiesInText &entities); // local message
HistoryMessage(History *history, MsgId msgId, MTPDmessage::Flags flags, MsgId replyTo, int32 viaBotId, QDateTime date, int32 from, const TextWithEntities &textWithEntities); // local message
HistoryMessage(History *history, MsgId msgId, MTPDmessage::Flags flags, MsgId replyTo, int32 viaBotId, QDateTime date, int32 from, DocumentData *doc, const QString &caption, const MTPReplyMarkup &markup); // local document
HistoryMessage(History *history, MsgId msgId, MTPDmessage::Flags flags, MsgId replyTo, int32 viaBotId, QDateTime date, int32 from, PhotoData *photo, const QString &caption, const MTPReplyMarkup &markup); // local photo
friend class HistoryItemInstantiated<HistoryMessage>;
@@ -2902,7 +2898,7 @@ public:
bool serviceMsg() const override {
return true;
}
QString selectedText(TextSelection selection) const override;
TextWithEntities selectedText(TextSelection selection) const override;
QString inDialogsText() const override;
QString inReplyText() const override;
@@ -2939,8 +2935,8 @@ public:
HistoryTextState getState(int x, int y, HistoryStateRequest request) const override;
QString selectedText(TextSelection selection) const override {
return QString();
TextWithEntities selectedText(TextSelection selection) const override {
return { QString(), EntitiesInText() };
}
HistoryItemType type() const override {
return HistoryItemGroup;
@@ -2989,8 +2985,8 @@ public:
void draw(Painter &p, const QRect &r, TextSelection selection, uint64 ms) const override;
HistoryTextState getState(int x, int y, HistoryStateRequest request) const override;
QString selectedText(TextSelection selection) const override {
return QString();
TextWithEntities selectedText(TextSelection selection) const override {
return { QString(), EntitiesInText() };
}
HistoryItemType type() const override {
return HistoryItemCollapse;