Message info
 
To:kde-commits@kde.org From:Daniele E. Domenichelli Subject:[ktp-accounts-kcm] src: Give a name to padding magic numbers Date:Fri, 30 Mar 2012 17:58:08 +0200 (CEST)
 

Git commit f6a7c94867454429a33db6ba054b8e189104ebf7 by Daniele E. Domenichelli.
Committed on 30/03/2012 at 16:58.
Pushed by ddomenichelli into branch 'master'.

Give a name to padding magic numbers

M +7 -7 src/accounts-list-delegate.cpp
M +4 -0 src/accounts-list-delegate.h

http://commits.kde.org/telepathy-accounts-kcm/f6a7c94867454429a33db6ba054b8e189104ebf7

diff --git a/src/accounts-list-delegate.cpp b/src/accounts-list-delegate.cpp
index e6e9425..dcb43dc 100644
--- a/src/accounts-list-delegate.cpp
+++ b/src/accounts-list-delegate.cpp
@@ -53,8 +53,8 @@ QSize AccountsListDelegate::sizeHint(const QStyleOptionViewItem &option, const Q
{
Q_UNUSED(index);

- int iconHeight = option.decorationSize.height() + (7*2); //icon height + padding either side
- int textHeight = option.fontMetrics.height()*2 + (7*2);
+ int iconHeight = option.decorationSize.height() + (m_vpadding*2); //icon height + padding either side
+ int textHeight = option.fontMetrics.height()*2 + (m_vpadding*2) + 10; // text height * 2 + padding + some space between the lines

return QSize(-1,qMax(iconHeight, textHeight)); //any width,the view should give us the whole thing.
}
@@ -131,7 +131,7 @@ void AccountsListDelegate::updateItemWidgets(const QList<QWidget *> widgets, con


QRect outerRect(0, 0, option.rect.width(), option.rect.height());
- QRect contentRect = outerRect.adjusted(7,2,-7,-2); //add some padding
+ QRect contentRect = outerRect.adjusted(m_hpadding,m_vpadding,-m_hpadding,-m_vpadding); //add some padding


// checkbox
@@ -220,9 +220,9 @@ void AccountsListDelegate::updateItemWidgets(const QList<QWidget *> widgets, con

QString displayNameButtonText = displayNameButton->fontMetrics().elidedText(displayName,
Qt::ElideRight,
- innerRect.width() - (7*2));
+ innerRect.width() - (m_hpadding*2));
displayNameButton->setText(displayNameButtonText);
- displayNameButton->setFixedSize(displayNameButton->fontMetrics().boundingRect(displayNameButtonText).width() + (7*2),
+ displayNameButton->setFixedSize(displayNameButton->fontMetrics().boundingRect(displayNameButtonText).width() + (m_hpadding*2),
displayNameButton->minimumSizeHint().height());
displayNameButton->setAccount(account);

@@ -249,12 +249,12 @@ void AccountsListDelegate::updateItemWidgets(const QList<QWidget *> widgets, con

QString connectionErrorLabelText = connectionErrorLabel->fontMetrics().elidedText(connectionError,
Qt::ElideRight,
- innerRect.width() - (7*2));
+ innerRect.width() - (m_hpadding*2));
connectionErrorLabel->setText(connectionErrorLabelText);
connectionErrorLabel->setFixedSize(connectionErrorLabel->fontMetrics().boundingRect(connectionErrorLabelText).width(),
displayNameButton->height());

- int connectionErrorLabelLeftMargin = innerRect.left() + 7;
+ int connectionErrorLabelLeftMargin = innerRect.left() + m_hpadding;
int connectionErrorLabelTopMargin = contentRect.bottom() - displayNameButton->height();
connectionErrorLabel->move(connectionErrorLabelLeftMargin, connectionErrorLabelTopMargin);
}
diff --git a/src/accounts-list-delegate.h b/src/accounts-list-delegate.h
index 0055046..2016b94 100644
--- a/src/accounts-list-delegate.h
+++ b/src/accounts-list-delegate.h
@@ -41,6 +41,10 @@ Q_SIGNALS:

private Q_SLOTS:
void onCheckBoxToggled(bool checked);
+
+private:
+ static const int m_hpadding = 7;
+ static const int m_vpadding = 2;
};

#endif // ACCOUNTLISTDELEGATE_H