Extracted ellipsis string from String::Text to global access.
This commit is contained in:
parent
774da18a38
commit
3461c18cda
3 changed files with 14 additions and 12 deletions
|
|
@ -2104,8 +2104,6 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void prepareElidedLine(QString &lineText, int32 lineStart, int32 &lineLength, const AbstractBlock *&_endBlock, int repeat = 0) {
|
void prepareElidedLine(QString &lineText, int32 lineStart, int32 &lineLength, const AbstractBlock *&_endBlock, int repeat = 0) {
|
||||||
static const auto _Elide = QString::fromLatin1("...");
|
|
||||||
|
|
||||||
_f = _t->_st->font;
|
_f = _t->_st->font;
|
||||||
QStackTextEngine engine(lineText, _f->f);
|
QStackTextEngine engine(lineText, _f->f);
|
||||||
engine.option.setTextDirection(_parDirection);
|
engine.option.setTextDirection(_parDirection);
|
||||||
|
|
@ -2142,11 +2140,11 @@ private:
|
||||||
}
|
}
|
||||||
if (_type == TextBlockTEmoji || _type == TextBlockTSkip || _type == TextBlockTNewline) {
|
if (_type == TextBlockTEmoji || _type == TextBlockTSkip || _type == TextBlockTNewline) {
|
||||||
if (_wLeft < si.width) {
|
if (_wLeft < si.width) {
|
||||||
lineText = lineText.mid(0, currentBlock->from() - _localFrom) + _Elide;
|
lineText = lineText.mid(0, currentBlock->from() - _localFrom) + kQEllipsis;
|
||||||
lineLength = currentBlock->from() + _Elide.size() - _lineStart;
|
lineLength = currentBlock->from() + kQEllipsis.size() - _lineStart;
|
||||||
_selection.to = qMin(_selection.to, currentBlock->from());
|
_selection.to = qMin(_selection.to, currentBlock->from());
|
||||||
_indexOfElidedBlock = blockIndex + (nextBlock ? 1 : 0);
|
_indexOfElidedBlock = blockIndex + (nextBlock ? 1 : 0);
|
||||||
setElideBidi(currentBlock->from(), _Elide.size());
|
setElideBidi(currentBlock->from(), kQEllipsis.size());
|
||||||
elideSaveBlock(blockIndex - 1, _endBlock, currentBlock->from(), elideWidth);
|
elideSaveBlock(blockIndex - 1, _endBlock, currentBlock->from(), elideWidth);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -2175,11 +2173,11 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lineText.size() <= pos || repeat > 3) {
|
if (lineText.size() <= pos || repeat > 3) {
|
||||||
lineText += _Elide;
|
lineText += kQEllipsis;
|
||||||
lineLength = _localFrom + pos + _Elide.size() - _lineStart;
|
lineLength = _localFrom + pos + kQEllipsis.size() - _lineStart;
|
||||||
_selection.to = qMin(_selection.to, uint16(_localFrom + pos));
|
_selection.to = qMin(_selection.to, uint16(_localFrom + pos));
|
||||||
_indexOfElidedBlock = blockIndex + (nextBlock ? 1 : 0);
|
_indexOfElidedBlock = blockIndex + (nextBlock ? 1 : 0);
|
||||||
setElideBidi(_localFrom + pos, _Elide.size());
|
setElideBidi(_localFrom + pos, kQEllipsis.size());
|
||||||
_blocksSize = blockIndex;
|
_blocksSize = blockIndex;
|
||||||
_endBlock = nextBlock;
|
_endBlock = nextBlock;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -2200,10 +2198,10 @@ private:
|
||||||
int32 elideStart = _localFrom + lineText.size();
|
int32 elideStart = _localFrom + lineText.size();
|
||||||
_selection.to = qMin(_selection.to, uint16(elideStart));
|
_selection.to = qMin(_selection.to, uint16(elideStart));
|
||||||
_indexOfElidedBlock = blockIndex + (nextBlock ? 1 : 0);
|
_indexOfElidedBlock = blockIndex + (nextBlock ? 1 : 0);
|
||||||
setElideBidi(elideStart, _Elide.size());
|
setElideBidi(elideStart, kQEllipsis.size());
|
||||||
|
|
||||||
lineText += _Elide;
|
lineText += kQEllipsis;
|
||||||
lineLength += _Elide.size();
|
lineLength += kQEllipsis.size();
|
||||||
|
|
||||||
if (!repeat) {
|
if (!repeat) {
|
||||||
for (; blockIndex < _blocksSize && _t->_blocks[blockIndex].get() != _endBlock && _t->_blocks[blockIndex]->from() < elideStart; ++blockIndex) {
|
for (; blockIndex < _blocksSize && _t->_blocks[blockIndex].get() != _endBlock && _t->_blocks[blockIndex]->from() < elideStart; ++blockIndex) {
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,10 @@
|
||||||
|
|
||||||
class SpoilerClickHandler;
|
class SpoilerClickHandler;
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
static const auto kQEllipsis = QStringLiteral("...");
|
||||||
|
} // namespace Ui
|
||||||
|
|
||||||
static const QChar TextCommand(0x0010);
|
static const QChar TextCommand(0x0010);
|
||||||
enum TextCommands {
|
enum TextCommands {
|
||||||
TextCommandBold = 0x01,
|
TextCommandBold = 0x01,
|
||||||
|
|
|
||||||
|
|
@ -2359,7 +2359,7 @@ QString CutTextWithCommands(
|
||||||
const auto additional = ((lastStart == -1) || (lastStart < lastStop))
|
const auto additional = ((lastStart == -1) || (lastStart < lastStop))
|
||||||
? QString()
|
? QString()
|
||||||
: stop;
|
: stop;
|
||||||
return text + additional + qstr("...");
|
return text + additional + Ui::kQEllipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace TextUtilities
|
} // namespace TextUtilities
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue