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
+97 -41
View File
@@ -62,7 +62,8 @@ void Scrollbar::clearHighlights()
LimitedQueueSnapshot<ScrollbarHighlight> Scrollbar::getHighlightSnapshot()
{
if (!this->highlightsPaused_) {
if (!this->highlightsPaused_)
{
this->highlightSnapshot_ = this->highlights_.getSnapshot();
}
@@ -114,8 +115,10 @@ void Scrollbar::setDesiredValue(qreal value, bool animated)
std::min(this->maximum_ - this->largeChange_, value));
if (std::abs(this->desiredValue_ + this->smoothScrollingOffset_ - value) >
0.0001) {
if (animated) {
0.0001)
{
if (animated)
{
this->currentValueAnimation_.stop();
this->currentValueAnimation_.setStartValue(
this->currentValue_ + this->smoothScrollingOffset_);
@@ -130,9 +133,12 @@ void Scrollbar::setDesiredValue(qreal value, bool animated)
this->atBottom_ = ((this->getMaximum() - this->getLargeChange()) -
value) <= 0.0001;
this->currentValueAnimation_.start();
} else {
}
else
{
if (this->currentValueAnimation_.state() !=
QPropertyAnimation::Running) {
QPropertyAnimation::Running)
{
this->smoothScrollingOffset_ = 0;
this->desiredValue_ = value;
this->currentValueAnimation_.stop();
@@ -182,9 +188,12 @@ qreal Scrollbar::getCurrentValue() const
void Scrollbar::offset(qreal value)
{
if (this->currentValueAnimation_.state() == QPropertyAnimation::Running) {
if (this->currentValueAnimation_.state() == QPropertyAnimation::Running)
{
this->smoothScrollingOffset_ += value;
} else {
}
else
{
this->setDesiredValue(this->getDesiredValue() + value);
}
}
@@ -205,7 +214,8 @@ void Scrollbar::setCurrentValue(qreal value)
std::min(this->maximum_ - this->largeChange_,
value + this->smoothScrollingOffset_));
if (std::abs(this->currentValue_ - value) > 0.0001) {
if (std::abs(this->currentValue_ - value) > 0.0001)
{
this->currentValue_ = value;
this->updateScroll();
@@ -241,12 +251,14 @@ void Scrollbar::paintEvent(QPaintEvent *)
this->thumbRect_.setX(xOffset);
// mouse over thumb
if (this->mouseDownIndex_ == 2) {
if (this->mouseDownIndex_ == 2)
{
painter.fillRect(this->thumbRect_,
this->theme->scrollbars.thumbSelected);
}
// mouse not over thumb
else {
else
{
painter.fillRect(this->thumbRect_, this->theme->scrollbars.thumb);
}
@@ -254,7 +266,8 @@ void Scrollbar::paintEvent(QPaintEvent *)
auto snapshot = this->getHighlightSnapshot();
size_t snapshotLength = snapshot.getLength();
if (snapshotLength == 0) {
if (snapshotLength == 0)
{
return;
}
@@ -263,12 +276,15 @@ void Scrollbar::paintEvent(QPaintEvent *)
float dY = float(this->height()) / float(snapshotLength);
int highlightHeight = int(std::ceil(dY));
for (size_t i = 0; i < snapshotLength; i++) {
for (size_t i = 0; i < snapshotLength; i++)
{
ScrollbarHighlight const &highlight = snapshot[i];
if (!highlight.isNull()) {
if (!highlight.isNull())
{
QColor color = [&] {
switch (highlight.getColor()) {
switch (highlight.getColor())
{
case ScrollbarHighlight::Highlight:
return getApp()
->themes->scrollbars.highlights.highlight;
@@ -279,15 +295,20 @@ void Scrollbar::paintEvent(QPaintEvent *)
return QColor();
}();
switch (highlight.getStyle()) {
case ScrollbarHighlight::Default: {
switch (highlight.getStyle())
{
case ScrollbarHighlight::Default:
{
painter.fillRect(w / 8 * 3, int(y), w / 4, highlightHeight,
color);
} break;
}
break;
case ScrollbarHighlight::Line: {
case ScrollbarHighlight::Line:
{
painter.fillRect(0, int(y), w, 1, color);
} break;
}
break;
case ScrollbarHighlight::None:;
}
@@ -304,27 +325,40 @@ void Scrollbar::resizeEvent(QResizeEvent *)
void Scrollbar::mouseMoveEvent(QMouseEvent *event)
{
if (this->mouseDownIndex_ == -1) {
if (this->mouseDownIndex_ == -1)
{
int y = event->pos().y();
auto oldIndex = this->mouseOverIndex_;
if (y < this->buttonHeight_) {
if (y < this->buttonHeight_)
{
this->mouseOverIndex_ = 0;
} else if (y < this->thumbRect_.y()) {
}
else if (y < this->thumbRect_.y())
{
this->mouseOverIndex_ = 1;
} else if (this->thumbRect_.contains(2, y)) {
}
else if (this->thumbRect_.contains(2, y))
{
this->mouseOverIndex_ = 2;
} else if (y < height() - this->buttonHeight_) {
}
else if (y < height() - this->buttonHeight_)
{
this->mouseOverIndex_ = 3;
} else {
}
else
{
this->mouseOverIndex_ = 4;
}
if (oldIndex != this->mouseOverIndex_) {
if (oldIndex != this->mouseOverIndex_)
{
update();
}
} else if (this->mouseDownIndex_ == 2) {
}
else if (this->mouseDownIndex_ == 2)
{
int delta = event->pos().y() - this->lastMousePosition_.y();
setDesiredValue(this->desiredValue_ +
@@ -338,15 +372,24 @@ void Scrollbar::mousePressEvent(QMouseEvent *event)
{
int y = event->pos().y();
if (y < this->buttonHeight_) {
if (y < this->buttonHeight_)
{
this->mouseDownIndex_ = 0;
} else if (y < this->thumbRect_.y()) {
}
else if (y < this->thumbRect_.y())
{
this->mouseDownIndex_ = 1;
} else if (this->thumbRect_.contains(2, y)) {
}
else if (this->thumbRect_.contains(2, y))
{
this->mouseDownIndex_ = 2;
} else if (y < height() - this->buttonHeight_) {
}
else if (y < height() - this->buttonHeight_)
{
this->mouseDownIndex_ = 3;
} else {
}
else
{
this->mouseDownIndex_ = 4;
}
}
@@ -355,22 +398,35 @@ void Scrollbar::mouseReleaseEvent(QMouseEvent *event)
{
int y = event->pos().y();
if (y < this->buttonHeight_) {
if (this->mouseDownIndex_ == 0) {
if (y < this->buttonHeight_)
{
if (this->mouseDownIndex_ == 0)
{
setDesiredValue(this->desiredValue_ - this->smallChange_, true);
}
} else if (y < this->thumbRect_.y()) {
if (this->mouseDownIndex_ == 1) {
}
else if (y < this->thumbRect_.y())
{
if (this->mouseDownIndex_ == 1)
{
setDesiredValue(this->desiredValue_ - this->smallChange_, true);
}
} else if (this->thumbRect_.contains(2, y)) {
}
else if (this->thumbRect_.contains(2, y))
{
// do nothing
} else if (y < height() - this->buttonHeight_) {
if (this->mouseDownIndex_ == 3) {
}
else if (y < height() - this->buttonHeight_)
{
if (this->mouseDownIndex_ == 3)
{
setDesiredValue(this->desiredValue_ + this->smallChange_, true);
}
} else {
if (this->mouseDownIndex_ == 4) {
}
else
{
if (this->mouseDownIndex_ == 4)
{
setDesiredValue(this->desiredValue_ + this->smallChange_, true);
}
}