Fix selection rendering (#4830)
The rendering of selections was not aligned to the actual selection that took place for newlines at the end of messages, if they were the only part that was selected of that message. In addition to that fix, we've already refactored the MessageLayoutContainer to try to make it a little bit more sane to work with in the future. Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -60,12 +60,12 @@ bool MessageLayoutElement::hasTrailingSpace() const
|
||||
return this->trailingSpace;
|
||||
}
|
||||
|
||||
int MessageLayoutElement::getLine() const
|
||||
size_t MessageLayoutElement::getLine() const
|
||||
{
|
||||
return this->line_;
|
||||
}
|
||||
|
||||
void MessageLayoutElement::setLine(int line)
|
||||
void MessageLayoutElement::setLine(size_t line)
|
||||
{
|
||||
this->line_ = line;
|
||||
}
|
||||
@@ -132,7 +132,7 @@ void ImageLayoutElement::addCopyTextToString(QString &str, uint32_t from,
|
||||
}
|
||||
}
|
||||
|
||||
int ImageLayoutElement::getSelectionIndexCount() const
|
||||
size_t ImageLayoutElement::getSelectionIndexCount() const
|
||||
{
|
||||
return this->trailingSpace ? 2 : 1;
|
||||
}
|
||||
@@ -176,7 +176,7 @@ int ImageLayoutElement::getMouseOverIndex(const QPoint &abs) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ImageLayoutElement::getXFromIndex(int index)
|
||||
int ImageLayoutElement::getXFromIndex(size_t index)
|
||||
{
|
||||
if (index <= 0)
|
||||
{
|
||||
@@ -224,7 +224,7 @@ void LayeredImageLayoutElement::addCopyTextToString(QString &str, uint32_t from,
|
||||
}
|
||||
}
|
||||
|
||||
int LayeredImageLayoutElement::getSelectionIndexCount() const
|
||||
size_t LayeredImageLayoutElement::getSelectionIndexCount() const
|
||||
{
|
||||
return this->trailingSpace ? 2 : 1;
|
||||
}
|
||||
@@ -304,7 +304,7 @@ int LayeredImageLayoutElement::getMouseOverIndex(const QPoint &abs) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LayeredImageLayoutElement::getXFromIndex(int index)
|
||||
int LayeredImageLayoutElement::getXFromIndex(size_t index)
|
||||
{
|
||||
if (index <= 0)
|
||||
{
|
||||
@@ -422,7 +422,7 @@ void TextLayoutElement::addCopyTextToString(QString &str, uint32_t from,
|
||||
}
|
||||
}
|
||||
|
||||
int TextLayoutElement::getSelectionIndexCount() const
|
||||
size_t TextLayoutElement::getSelectionIndexCount() const
|
||||
{
|
||||
return this->getText().length() + (this->trailingSpace ? 1 : 0);
|
||||
}
|
||||
@@ -489,7 +489,7 @@ int TextLayoutElement::getMouseOverIndex(const QPoint &abs) const
|
||||
return this->getSelectionIndexCount() - (this->hasTrailingSpace() ? 1 : 0);
|
||||
}
|
||||
|
||||
int TextLayoutElement::getXFromIndex(int index)
|
||||
int TextLayoutElement::getXFromIndex(size_t index)
|
||||
{
|
||||
auto app = getApp();
|
||||
|
||||
@@ -532,7 +532,7 @@ void TextIconLayoutElement::addCopyTextToString(QString &str, uint32_t from,
|
||||
{
|
||||
}
|
||||
|
||||
int TextIconLayoutElement::getSelectionIndexCount() const
|
||||
size_t TextIconLayoutElement::getSelectionIndexCount() const
|
||||
{
|
||||
return this->trailingSpace ? 2 : 1;
|
||||
}
|
||||
@@ -576,7 +576,7 @@ int TextIconLayoutElement::getMouseOverIndex(const QPoint &abs) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
int TextIconLayoutElement::getXFromIndex(int index)
|
||||
int TextIconLayoutElement::getXFromIndex(size_t index)
|
||||
{
|
||||
if (index <= 0)
|
||||
{
|
||||
@@ -649,7 +649,7 @@ int ReplyCurveLayoutElement::getMouseOverIndex(const QPoint &abs) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ReplyCurveLayoutElement::getXFromIndex(int index)
|
||||
int ReplyCurveLayoutElement::getXFromIndex(size_t index)
|
||||
{
|
||||
if (index <= 0)
|
||||
{
|
||||
@@ -664,7 +664,7 @@ void ReplyCurveLayoutElement::addCopyTextToString(QString &str, uint32_t from,
|
||||
{
|
||||
}
|
||||
|
||||
int ReplyCurveLayoutElement::getSelectionIndexCount() const
|
||||
size_t ReplyCurveLayoutElement::getSelectionIndexCount() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user