added brace wrapping after if and for

This commit is contained in:
fourtf
2018-10-21 13:43:02 +02:00
parent c6e1ec3c71
commit e259b9e39f
138 changed files with 4738 additions and 2237 deletions
+40 -19
View File
@@ -64,7 +64,8 @@ bool MessageLayout::layout(int width, float scale, MessageElementFlags flags)
this->currentLayoutWidth_ = width;
// check if layout state changed
if (this->layoutState_ != app->windows->getGeneration()) {
if (this->layoutState_ != app->windows->getGeneration())
{
layoutRequired = true;
this->flags.set(MessageLayoutFlag::RequiresBufferUpdate);
this->layoutState_ = app->windows->getGeneration();
@@ -82,13 +83,15 @@ bool MessageLayout::layout(int width, float scale, MessageElementFlags flags)
layoutRequired |= this->scale_ != scale;
this->scale_ = scale;
if (!layoutRequired) {
if (!layoutRequired)
{
return false;
}
int oldHeight = this->container_->getHeight();
this->actuallyLayout(width, flags);
if (widthChanged || this->container_->getHeight() != oldHeight) {
if (widthChanged || this->container_->getHeight() != oldHeight)
{
this->deleteBuffer();
}
this->invalidateBuffer();
@@ -109,11 +112,13 @@ void MessageLayout::actuallyLayout(int width, MessageElementFlags _flags)
this->container_->begin(width, this->scale_, messageFlags);
for (const auto &element : this->message_->elements) {
for (const auto &element : this->message_->elements)
{
element->addToContainer(*this->container_, _flags);
}
if (this->height_ != this->container_->getHeight()) {
if (this->height_ != this->container_->getHeight())
{
this->deleteBuffer();
}
@@ -122,7 +127,8 @@ void MessageLayout::actuallyLayout(int width, MessageElementFlags _flags)
// collapsed state
this->flags.unset(MessageLayoutFlag::Collapsed);
if (this->container_->isCollapsed()) {
if (this->container_->isCollapsed())
{
this->flags.set(MessageLayoutFlag::Collapsed);
}
}
@@ -136,7 +142,8 @@ void MessageLayout::paint(QPainter &painter, int width, int y, int messageIndex,
QPixmap *pixmap = this->buffer_.get();
// create new buffer if required
if (!pixmap) {
if (!pixmap)
{
#ifdef Q_OS_MACOS
pixmap = new QPixmap(int(width * painter.device()->devicePixelRatioF()),
int(container_->getHeight() *
@@ -152,7 +159,8 @@ void MessageLayout::paint(QPainter &painter, int width, int y, int messageIndex,
DebugCount::increase("message drawing buffers");
}
if (!this->bufferValid_ || !selection.isEmpty()) {
if (!this->bufferValid_ || !selection.isEmpty())
{
this->updateBuffer(pixmap, messageIndex, selection);
}
@@ -165,28 +173,35 @@ void MessageLayout::paint(QPainter &painter, int width, int y, int messageIndex,
this->container_->paintAnimatedElements(painter, y);
// draw disabled
if (this->message_->flags.has(MessageFlag::Disabled)) {
if (this->message_->flags.has(MessageFlag::Disabled))
{
painter.fillRect(0, y, pixmap->width(), pixmap->height(),
app->themes->messages.disabled);
}
// draw selection
if (!selection.isEmpty()) {
if (!selection.isEmpty())
{
this->container_->paintSelection(painter, messageIndex, selection, y);
}
// draw message seperation line
if (getSettings()->separateMessages.getValue()) {
if (getSettings()->separateMessages.getValue())
{
painter.fillRect(0, y, this->container_->getWidth(), 1,
app->themes->splits.messageSeperator);
}
// draw last read message line
if (isLastReadMessage) {
if (isLastReadMessage)
{
QColor color;
if (getSettings()->lastMessageColor != "") {
if (getSettings()->lastMessageColor != "")
{
color = QColor(getSettings()->lastMessageColor.getValue());
} else {
}
else
{
color =
isWindowFocused
? app->themes->tabs.selected.backgrounds.regular.color()
@@ -214,12 +229,17 @@ void MessageLayout::updateBuffer(QPixmap *buffer, int /*messageIndex*/,
// draw background
QColor backgroundColor = app->themes->messages.backgrounds.regular;
if (this->message_->flags.has(MessageFlag::Highlighted) &&
!this->flags.has(MessageLayoutFlag::IgnoreHighlights)) {
!this->flags.has(MessageLayoutFlag::IgnoreHighlights))
{
backgroundColor = app->themes->messages.backgrounds.highlighted;
} else if (this->message_->flags.has(MessageFlag::Subscription)) {
}
else if (this->message_->flags.has(MessageFlag::Subscription))
{
backgroundColor = app->themes->messages.backgrounds.subscription;
} else if (getSettings()->alternateMessageBackground.getValue() &&
this->flags.has(MessageLayoutFlag::AlternateBackground)) {
}
else if (getSettings()->alternateMessageBackground.getValue() &&
this->flags.has(MessageLayoutFlag::AlternateBackground))
{
backgroundColor = app->themes->messages.backgrounds.alternate;
}
@@ -249,7 +269,8 @@ void MessageLayout::invalidateBuffer()
void MessageLayout::deleteBuffer()
{
if (this->buffer_ != nullptr) {
if (this->buffer_ != nullptr)
{
DebugCount::decrease("message drawing buffers");
this->buffer_ = nullptr;