added brace wrapping after if and for
This commit is contained in:
@@ -96,9 +96,11 @@ void ImageLayoutElement::addCopyTextToString(QString &str, int from,
|
||||
{
|
||||
const auto *emoteElement =
|
||||
dynamic_cast<EmoteElement *>(&this->getCreator());
|
||||
if (emoteElement) {
|
||||
if (emoteElement)
|
||||
{
|
||||
str += emoteElement->getEmote()->getCopyString();
|
||||
if (this->hasTrailingSpace()) {
|
||||
if (this->hasTrailingSpace())
|
||||
{
|
||||
str += " ";
|
||||
}
|
||||
}
|
||||
@@ -111,12 +113,14 @@ int ImageLayoutElement::getSelectionIndexCount() const
|
||||
|
||||
void ImageLayoutElement::paint(QPainter &painter)
|
||||
{
|
||||
if (this->image_ == nullptr) {
|
||||
if (this->image_ == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto pixmap = this->image_->pixmap();
|
||||
if (pixmap && !this->image_->animated()) {
|
||||
if (pixmap && !this->image_->animated())
|
||||
{
|
||||
// fourtf: make it use qreal values
|
||||
painter.drawPixmap(QRectF(this->getRect()), *pixmap, QRectF());
|
||||
}
|
||||
@@ -124,12 +128,15 @@ void ImageLayoutElement::paint(QPainter &painter)
|
||||
|
||||
void ImageLayoutElement::paintAnimated(QPainter &painter, int yOffset)
|
||||
{
|
||||
if (this->image_ == nullptr) {
|
||||
if (this->image_ == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->image_->animated()) {
|
||||
if (auto pixmap = this->image_->pixmap()) {
|
||||
if (this->image_->animated())
|
||||
{
|
||||
if (auto pixmap = this->image_->pixmap())
|
||||
{
|
||||
auto rect = this->getRect();
|
||||
rect.moveTop(rect.y() + yOffset);
|
||||
painter.drawPixmap(QRectF(rect), *pixmap, QRectF());
|
||||
@@ -144,12 +151,17 @@ int ImageLayoutElement::getMouseOverIndex(const QPoint &abs) const
|
||||
|
||||
int ImageLayoutElement::getXFromIndex(int index)
|
||||
{
|
||||
if (index <= 0) {
|
||||
if (index <= 0)
|
||||
{
|
||||
return this->getRect().left();
|
||||
} else if (index == 1) {
|
||||
}
|
||||
else if (index == 1)
|
||||
{
|
||||
// fourtf: remove space width
|
||||
return this->getRect().right();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return this->getRect().right();
|
||||
}
|
||||
}
|
||||
@@ -174,7 +186,8 @@ void TextLayoutElement::addCopyTextToString(QString &str, int from,
|
||||
{
|
||||
str += this->getText().mid(from, to - from);
|
||||
|
||||
if (this->hasTrailingSpace()) {
|
||||
if (this->hasTrailingSpace())
|
||||
{
|
||||
str += " ";
|
||||
}
|
||||
}
|
||||
@@ -203,7 +216,8 @@ void TextLayoutElement::paintAnimated(QPainter &, int)
|
||||
|
||||
int TextLayoutElement::getMouseOverIndex(const QPoint &abs) const
|
||||
{
|
||||
if (abs.x() < this->getRect().left()) {
|
||||
if (abs.x() < this->getRect().left())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -213,11 +227,13 @@ int TextLayoutElement::getMouseOverIndex(const QPoint &abs) const
|
||||
|
||||
int x = this->getRect().left();
|
||||
|
||||
for (int i = 0; i < this->getText().size(); i++) {
|
||||
for (int i = 0; i < this->getText().size(); i++)
|
||||
{
|
||||
auto &text = this->getText();
|
||||
auto width = metrics.width(this->getText()[i]);
|
||||
|
||||
if (x + width > abs.x()) {
|
||||
if (x + width > abs.x())
|
||||
{
|
||||
if (text.size() > i + 1 &&
|
||||
QChar::isLowSurrogate(text[i].unicode())) //
|
||||
{
|
||||
@@ -239,15 +255,21 @@ int TextLayoutElement::getXFromIndex(int index)
|
||||
|
||||
QFontMetrics metrics = app->fonts->getFontMetrics(this->style, this->scale);
|
||||
|
||||
if (index <= 0) {
|
||||
if (index <= 0)
|
||||
{
|
||||
return this->getRect().left();
|
||||
} else if (index < this->getText().size()) {
|
||||
}
|
||||
else if (index < this->getText().size())
|
||||
{
|
||||
int x = 0;
|
||||
for (int i = 0; i < index; i++) {
|
||||
for (int i = 0; i < index; i++)
|
||||
{
|
||||
x += metrics.width(this->getText()[i]);
|
||||
}
|
||||
return x + this->getRect().left();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return this->getRect().right();
|
||||
}
|
||||
}
|
||||
@@ -286,10 +308,13 @@ void TextIconLayoutElement::paint(QPainter &painter)
|
||||
QTextOption option;
|
||||
option.setAlignment(Qt::AlignHCenter);
|
||||
|
||||
if (this->line2.isEmpty()) {
|
||||
if (this->line2.isEmpty())
|
||||
{
|
||||
QRect _rect(this->getRect());
|
||||
painter.drawText(_rect, this->line1, option);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
painter.drawText(
|
||||
QPoint(this->getRect().x(),
|
||||
this->getRect().y() + this->getRect().height() / 2),
|
||||
@@ -311,12 +336,17 @@ int TextIconLayoutElement::getMouseOverIndex(const QPoint &abs) const
|
||||
|
||||
int TextIconLayoutElement::getXFromIndex(int index)
|
||||
{
|
||||
if (index <= 0) {
|
||||
if (index <= 0)
|
||||
{
|
||||
return this->getRect().left();
|
||||
} else if (index == 1) {
|
||||
}
|
||||
else if (index == 1)
|
||||
{
|
||||
// fourtf: remove space width
|
||||
return this->getRect().right();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return this->getRect().right();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user