refactor: add if braces for linters
This commit is contained in:
@@ -64,9 +64,9 @@ QPixmap ActionBox::icon() const
|
||||
|
||||
ActionLabel* ActionBox::createItem(QAction * action, QLayout * l)
|
||||
{
|
||||
if (!action)
|
||||
if (!action) {
|
||||
return nullptr;
|
||||
|
||||
}
|
||||
ActionLabel *act = createItem("", l);
|
||||
act->setDefaultAction(action);
|
||||
return act;
|
||||
@@ -76,14 +76,15 @@ QList<ActionLabel*> ActionBox::createItems(QList<QAction*> actions)
|
||||
{
|
||||
QList<ActionLabel*> list;
|
||||
|
||||
if (actions.isEmpty())
|
||||
if (actions.isEmpty()) {
|
||||
return list;
|
||||
|
||||
}
|
||||
QLayout *l = createHBoxLayout();
|
||||
|
||||
for (QAction *action : actions) {
|
||||
if (auto *act = createItem(action, l))
|
||||
if (auto *act = createItem(action, l)) {
|
||||
list.append(act);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
@@ -95,8 +96,9 @@ ActionLabel* ActionBox::createItem(const QString & text, QLayout * l)
|
||||
act->setText(text);
|
||||
act->setProperty("class", "action");
|
||||
|
||||
if (l)
|
||||
if (l) {
|
||||
l->addWidget(act);
|
||||
}
|
||||
else {
|
||||
QHBoxLayout *hbl = new QHBoxLayout();
|
||||
hbl->addWidget(act);
|
||||
@@ -118,11 +120,14 @@ QSpacerItem* ActionBox::createSpacer(QLayout * l)
|
||||
{
|
||||
QSpacerItem * spacer;
|
||||
|
||||
if (l) // add horizontal spacer
|
||||
if (l) {
|
||||
// add horizontal spacer
|
||||
l->addItem(spacer = new QSpacerItem(1,0,QSizePolicy::MinimumExpanding,QSizePolicy::Ignored));
|
||||
else // add vertical spacer
|
||||
}
|
||||
else {
|
||||
// add vertical spacer
|
||||
dataLayout->addItem(spacer = new QSpacerItem(0,1,QSizePolicy::Ignored,QSizePolicy::MinimumExpanding));
|
||||
|
||||
}
|
||||
return spacer;
|
||||
}
|
||||
|
||||
@@ -146,13 +151,14 @@ void ActionBox::addLayout(QLayout * l)
|
||||
|
||||
void ActionBox::addWidget(QWidget * w, QLayout * l)
|
||||
{
|
||||
if (!w)
|
||||
if (!w) {
|
||||
return;
|
||||
|
||||
}
|
||||
w->setParent(this);
|
||||
|
||||
if (l)
|
||||
if (l) {
|
||||
l->addWidget(w);
|
||||
}
|
||||
else {
|
||||
QHBoxLayout *hbl = new QHBoxLayout();
|
||||
hbl->addWidget(w);
|
||||
|
||||
@@ -32,20 +32,20 @@ TaskGroup::TaskGroup(QWidget *parent, bool hasHeader)
|
||||
|
||||
bool TaskGroup::addActionLabel(ActionLabel *label, bool addToLayout, bool addStretch)
|
||||
{
|
||||
if (!label)
|
||||
if (!label) {
|
||||
return false;
|
||||
|
||||
}
|
||||
return addWidget(label, addToLayout, addStretch);
|
||||
}
|
||||
|
||||
bool TaskGroup::addWidget(QWidget *widget, bool addToLayout, bool addStretch)
|
||||
{
|
||||
if (!widget)
|
||||
if (!widget) {
|
||||
return false;
|
||||
|
||||
if (!addToLayout)
|
||||
}
|
||||
if (!addToLayout) {
|
||||
return true;
|
||||
|
||||
}
|
||||
if (addStretch) {
|
||||
QHBoxLayout *hbl = new QHBoxLayout();
|
||||
hbl->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
@@ -26,7 +26,6 @@ TaskHeader::TaskHeader(const QIcon &icon, const QString &title, bool expandable,
|
||||
m_buttonOver(false),
|
||||
m_fold(true),
|
||||
m_opacity(0.1),
|
||||
|
||||
myButton(nullptr)
|
||||
{
|
||||
setProperty("class", "header");
|
||||
@@ -57,9 +56,9 @@ void TaskHeader::setExpandable(bool expandable)
|
||||
if (expandable) {
|
||||
myExpandable = true;
|
||||
|
||||
if (myButton)
|
||||
if (myButton) {
|
||||
return;
|
||||
|
||||
}
|
||||
myButton = new QLabel(this);
|
||||
myButton->installEventFilter(this);
|
||||
myButton->setFixedSize(myScheme->headerButtonSize);
|
||||
@@ -70,9 +69,9 @@ void TaskHeader::setExpandable(bool expandable)
|
||||
} else {
|
||||
myExpandable = false;
|
||||
|
||||
if (!myButton)
|
||||
if (!myButton) {
|
||||
return;
|
||||
|
||||
}
|
||||
myButton->removeEventFilter(this);
|
||||
myButton->setParent(nullptr);
|
||||
delete myButton;
|
||||
@@ -85,8 +84,9 @@ bool TaskHeader::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
switch (event->type()) {
|
||||
case QEvent::MouseButtonPress:
|
||||
if (myExpandable)
|
||||
if (myExpandable) {
|
||||
fold();
|
||||
}
|
||||
return true;
|
||||
|
||||
case QEvent::Enter:
|
||||
@@ -121,16 +121,18 @@ void TaskHeader::paintEvent ( QPaintEvent * event )
|
||||
{
|
||||
QPainter p(this);
|
||||
|
||||
if (myScheme->headerAnimation)
|
||||
if (myScheme->headerAnimation) {
|
||||
p.setOpacity(m_opacity+0.7);
|
||||
}
|
||||
|
||||
BaseClass::paintEvent(event);
|
||||
}
|
||||
|
||||
void TaskHeader::animate()
|
||||
{
|
||||
if (!myScheme->headerAnimation)
|
||||
if (!myScheme->headerAnimation) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isEnabled()) {
|
||||
m_opacity = 0.1;
|
||||
@@ -164,9 +166,9 @@ void TaskHeader::enterEvent ( QEnterEvent * /*event*/ )
|
||||
{
|
||||
m_over = true;
|
||||
|
||||
if (isEnabled())
|
||||
if (isEnabled()) {
|
||||
QTimer::singleShot(100, this, &TaskHeader::animate);
|
||||
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -174,9 +176,9 @@ void TaskHeader::leaveEvent ( QEvent * /*event*/ )
|
||||
{
|
||||
m_over = false;
|
||||
|
||||
if (isEnabled())
|
||||
if (isEnabled()) {
|
||||
QTimer::singleShot(100, this, &TaskHeader::animate);
|
||||
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -205,21 +207,25 @@ void TaskHeader::setFold(bool on)
|
||||
|
||||
void TaskHeader::changeIcons()
|
||||
{
|
||||
if (!myButton)
|
||||
if (!myButton) {
|
||||
return;
|
||||
|
||||
}
|
||||
if (m_buttonOver)
|
||||
{
|
||||
if (m_fold)
|
||||
if (m_fold) {
|
||||
myButton->setPixmap(myScheme->headerButtonFoldOver);
|
||||
else
|
||||
}
|
||||
else {
|
||||
myButton->setPixmap(myScheme->headerButtonUnfoldOver);
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (m_fold)
|
||||
if (m_fold) {
|
||||
myButton->setPixmap(myScheme->headerButtonFold);
|
||||
else
|
||||
}
|
||||
else {
|
||||
myButton->setPixmap(myScheme->headerButtonUnfold);
|
||||
}
|
||||
}
|
||||
|
||||
myButton->setFixedSize(myScheme->headerButtonSize);
|
||||
|
||||
Reference in New Issue
Block a user