Removed TextParseRichText.
This commit is contained in:
parent
7e279bd83a
commit
b81b9371e6
9 changed files with 16 additions and 68 deletions
|
|
@ -59,19 +59,6 @@ Qt::LayoutDirection StringDirection(
|
|||
return Qt::LayoutDirectionAuto;
|
||||
}
|
||||
|
||||
TextWithEntities PrepareRichFromPlain(
|
||||
const QString &text,
|
||||
const TextParseOptions &options) {
|
||||
auto result = TextWithEntities{ text };
|
||||
if (options.flags & TextParseLinks) {
|
||||
TextUtilities::ParseEntities(
|
||||
result,
|
||||
options.flags,
|
||||
(options.flags & TextParseRichText));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
TextWithEntities PrepareRichFromRich(
|
||||
const TextWithEntities &text,
|
||||
const TextParseOptions &options) {
|
||||
|
|
@ -175,11 +162,6 @@ namespace Text {
|
|||
|
||||
class Parser {
|
||||
public:
|
||||
Parser(
|
||||
not_null<String*> string,
|
||||
const QString &text,
|
||||
const TextParseOptions &options,
|
||||
const std::any &context);
|
||||
Parser(
|
||||
not_null<String*> string,
|
||||
const TextWithEntities &textWithEntities,
|
||||
|
|
@ -250,7 +232,6 @@ private:
|
|||
const QChar *_ptr = nullptr;
|
||||
const EntitiesInText::const_iterator _entitiesEnd;
|
||||
EntitiesInText::const_iterator _waitingEntity;
|
||||
const bool _rich = false;
|
||||
const bool _multiline = false;
|
||||
|
||||
const QFixed _stopAfterWidth; // summary width of all added words
|
||||
|
|
@ -318,19 +299,6 @@ std::optional<uint16> Parser::StartedEntity::spoilerIndex() const {
|
|||
return std::nullopt;
|
||||
}
|
||||
|
||||
Parser::Parser(
|
||||
not_null<String*> string,
|
||||
const QString &text,
|
||||
const TextParseOptions &options,
|
||||
const std::any &context)
|
||||
: Parser(
|
||||
string,
|
||||
PrepareRichFromPlain(text, options),
|
||||
options,
|
||||
context,
|
||||
ReadyToken()) {
|
||||
}
|
||||
|
||||
Parser::Parser(
|
||||
not_null<String*> string,
|
||||
const TextWithEntities &textWithEntities,
|
||||
|
|
@ -358,7 +326,6 @@ Parser::Parser(
|
|||
, _ptr(_start)
|
||||
, _entitiesEnd(_source.entities.end())
|
||||
, _waitingEntity(_source.entities.begin())
|
||||
, _rich(options.flags & TextParseRichText)
|
||||
, _multiline(options.flags & TextParseMultiline)
|
||||
, _stopAfterWidth(ComputeStopAfter(options, *_t->_st))
|
||||
, _checkTilde(ComputeCheckTilde(*_t->_st)) {
|
||||
|
|
@ -2700,20 +2667,16 @@ private:
|
|||
String::String(int32 minResizeWidth) : _minResizeWidth(minResizeWidth) {
|
||||
}
|
||||
|
||||
String::String(const style::TextStyle &st, const QString &text, const TextParseOptions &options, int32 minResizeWidth, bool richText)
|
||||
String::String(const style::TextStyle &st, const QString &text, const TextParseOptions &options, int32 minResizeWidth)
|
||||
: _minResizeWidth(minResizeWidth) {
|
||||
if (richText) {
|
||||
setRichText(st, text, options);
|
||||
} else {
|
||||
setText(st, text, options);
|
||||
}
|
||||
setText(st, text, options);
|
||||
}
|
||||
|
||||
void String::setText(const style::TextStyle &st, const QString &text, const TextParseOptions &options) {
|
||||
_st = &st;
|
||||
clear();
|
||||
{
|
||||
Parser parser(this, text, options, {});
|
||||
Parser parser(this, { text }, options, {});
|
||||
}
|
||||
recountNaturalSize(true, options.dir);
|
||||
}
|
||||
|
|
@ -2877,11 +2840,6 @@ void String::setMarkedText(const style::TextStyle &st, const TextWithEntities &t
|
|||
recountNaturalSize(true, options.dir);
|
||||
}
|
||||
|
||||
void String::setRichText(const style::TextStyle &st, const QString &text, TextParseOptions options) {
|
||||
options.flags |= TextParseRichText;
|
||||
setText(st, text, options);
|
||||
}
|
||||
|
||||
void String::setLink(uint16 lnkIndex, const ClickHandlerPtr &lnk) {
|
||||
if (!lnkIndex || lnkIndex > _links.size()) return;
|
||||
_links[lnkIndex - 1] = lnk;
|
||||
|
|
|
|||
|
|
@ -103,8 +103,7 @@ public:
|
|||
const style::TextStyle &st,
|
||||
const QString &text,
|
||||
const TextParseOptions &options = _defaultOptions,
|
||||
int32 minResizeWidth = QFIXED_MAX,
|
||||
bool richText = false);
|
||||
int32 minResizeWidth = QFIXED_MAX);
|
||||
String(const String &other) = default;
|
||||
String(String &&other) = default;
|
||||
String &operator=(const String &other) = default;
|
||||
|
|
@ -115,7 +114,6 @@ public:
|
|||
int countHeight(int width, bool breakEverywhere = false) const;
|
||||
void countLineWidths(int width, QVector<int> *lineWidths, bool breakEverywhere = false) const;
|
||||
void setText(const style::TextStyle &st, const QString &text, const TextParseOptions &options = _defaultOptions);
|
||||
void setRichText(const style::TextStyle &st, const QString &text, TextParseOptions options = _defaultOptions);
|
||||
void setMarkedText(const style::TextStyle &st, const TextWithEntities &textWithEntities, const TextParseOptions &options = _defaultOptions, const std::any &context = {});
|
||||
|
||||
void setLink(uint16 lnkIndex, const ClickHandlerPtr &lnk);
|
||||
|
|
|
|||
|
|
@ -1528,14 +1528,13 @@ bool CutPart(TextWithEntities &sending, TextWithEntities &left, int32 limit) {
|
|||
}
|
||||
|
||||
TextWithEntities ParseEntities(const QString &text, int32 flags) {
|
||||
const auto rich = ((flags & TextParseRichText) != 0);
|
||||
auto result = TextWithEntities{ text, EntitiesInText() };
|
||||
ParseEntities(result, flags, rich);
|
||||
ParseEntities(result, flags);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Some code is duplicated in message_field.cpp!
|
||||
void ParseEntities(TextWithEntities &result, int32 flags, bool rich) {
|
||||
void ParseEntities(TextWithEntities &result, int32 flags) {
|
||||
constexpr auto kNotFound = std::numeric_limits<int>::max();
|
||||
|
||||
auto newEntities = EntitiesInText();
|
||||
|
|
|
|||
|
|
@ -237,12 +237,11 @@ struct TextForMimeData {
|
|||
enum {
|
||||
TextParseMultiline = 0x001,
|
||||
TextParseLinks = 0x002,
|
||||
TextParseRichText = 0x004,
|
||||
TextParseMentions = 0x008,
|
||||
TextParseHashtags = 0x010,
|
||||
TextParseBotCommands = 0x020,
|
||||
TextParseMarkdown = 0x040,
|
||||
TextParsePlainLinks = 0x080,
|
||||
TextParseMentions = 0x004,
|
||||
TextParseHashtags = 0x008,
|
||||
TextParseBotCommands = 0x010,
|
||||
TextParseMarkdown = 0x020,
|
||||
TextParsePlainLinks = 0x040,
|
||||
};
|
||||
|
||||
struct TextWithTags {
|
||||
|
|
@ -335,7 +334,7 @@ inline QString MentionNameDataFromFields(const MentionNameFields &fields) {
|
|||
// New entities are added to the ones that are already in result.
|
||||
// Changes text if (flags & TextParseMarkdown).
|
||||
TextWithEntities ParseEntities(const QString &text, int32 flags);
|
||||
void ParseEntities(TextWithEntities &result, int32 flags, bool rich = false);
|
||||
void ParseEntities(TextWithEntities &result, int32 flags);
|
||||
|
||||
void PrepareForSending(TextWithEntities &result, int32 flags);
|
||||
void Trim(TextWithEntities &result);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ TextParseOptions _checkboxOptions = {
|
|||
};
|
||||
|
||||
TextParseOptions _checkboxRichOptions = {
|
||||
TextParseMultiline | TextParseRichText, // flags
|
||||
TextParseMultiline, // flags
|
||||
0, // maxw
|
||||
0, // maxh
|
||||
Qt::LayoutDirectionAuto, // dir
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ TextParseOptions _labelOptions = {
|
|||
};
|
||||
|
||||
TextParseOptions _labelMarkedOptions = {
|
||||
TextParseMultiline | TextParseRichText | TextParseLinks | TextParseHashtags | TextParseMentions | TextParseBotCommands | TextParseMarkdown, // flags
|
||||
TextParseMultiline | TextParseLinks | TextParseHashtags | TextParseMentions | TextParseBotCommands | TextParseMarkdown, // flags
|
||||
0, // maxw
|
||||
0, // maxh
|
||||
Qt::LayoutDirectionAuto, // dir
|
||||
|
|
@ -257,11 +257,6 @@ void FlatLabel::setText(const QString &text) {
|
|||
textUpdated();
|
||||
}
|
||||
|
||||
void FlatLabel::setRichText(const QString &text) {
|
||||
_text.setRichText(_st.style, text, _labelOptions);
|
||||
textUpdated();
|
||||
}
|
||||
|
||||
void FlatLabel::setMarkedText(const TextWithEntities &textWithEntities) {
|
||||
_text.setMarkedText(_st.style, textWithEntities, _labelMarkedOptions);
|
||||
textUpdated();
|
||||
|
|
|
|||
|
|
@ -116,7 +116,6 @@ public:
|
|||
void setTextColorOverride(std::optional<QColor> color);
|
||||
|
||||
void setText(const QString &text);
|
||||
void setRichText(const QString &text);
|
||||
void setMarkedText(const TextWithEntities &textWithEntities);
|
||||
void setSelectable(bool selectable);
|
||||
void setDoubleClickSelectsParagraph(bool doubleClickSelectsParagraph);
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ namespace {
|
|||
}
|
||||
|
||||
TextParseOptions MenuTextOptions = {
|
||||
TextParseLinks | TextParseRichText, // flags
|
||||
TextParseLinks, // flags
|
||||
0, // maxw
|
||||
0, // maxh
|
||||
Qt::LayoutDirectionAuto, // dir
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ void Tooltip::popup(const QPoint &m, const QString &text, const style::Tooltip *
|
|||
|
||||
_point = m;
|
||||
_st = st;
|
||||
_text = Text::String(_st->textStyle, text, _textPlainOptions, _st->widthMax, true);
|
||||
_text = Text::String(_st->textStyle, text, _textPlainOptions, _st->widthMax);
|
||||
|
||||
_useTransparency = Platform::TranslucentWindowsSupported(_point);
|
||||
setAttribute(Qt::WA_OpaquePaintEvent, !_useTransparency);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue