diff options
| author | Sandro Jäckel <sandro.jaeckel@gmail.com> | 2018-02-22 16:54:34 +0100 |
|---|---|---|
| committer | Sandro Jäckel <sandro.jaeckel@gmail.com> | 2018-02-22 16:54:34 +0100 |
| commit | 5e5c9c07291f6b09623d31c92b1fb61c4ede576e (patch) | |
| tree | 0684c123db375336e0e03f0240155a12e744db16 /src/viewmarkingscrollbar.cpp | |
| parent | 5ad912e1934061b38825801a27f7c12933878005 (diff) | |
Applied clang-format on source
Diffstat (limited to 'src/viewmarkingscrollbar.cpp')
| -rw-r--r-- | src/viewmarkingscrollbar.cpp | 54 |
1 files changed, 25 insertions, 29 deletions
diff --git a/src/viewmarkingscrollbar.cpp b/src/viewmarkingscrollbar.cpp index 2452d0e3..596af533 100644 --- a/src/viewmarkingscrollbar.cpp +++ b/src/viewmarkingscrollbar.cpp @@ -1,42 +1,38 @@ #include "viewmarkingscrollbar.h"
+#include <QPainter>
#include <QStyle>
#include <QStyleOptionSlider>
-#include <QPainter>
-ViewMarkingScrollBar::ViewMarkingScrollBar(QAbstractItemModel *model, QWidget *parent, int role)
- : QScrollBar(parent)
- , m_Model(model)
- , m_Role(role)
-{
- // not implemented for horizontal sliders
- Q_ASSERT(this->orientation() == Qt::Vertical);
+ViewMarkingScrollBar::ViewMarkingScrollBar(QAbstractItemModel* model, QWidget* parent, int role)
+ : QScrollBar(parent), m_Model(model), m_Role(role) {
+ // not implemented for horizontal sliders
+ Q_ASSERT(this->orientation() == Qt::Vertical);
}
-void ViewMarkingScrollBar::paintEvent(QPaintEvent *event)
-{
- if (m_Model == nullptr) {
- return;
- }
- QScrollBar::paintEvent(event);
+void ViewMarkingScrollBar::paintEvent(QPaintEvent* event) {
+ if (m_Model == nullptr) {
+ return;
+ }
+ QScrollBar::paintEvent(event);
- QStyleOptionSlider styleOption;
- initStyleOption(&styleOption);
+ QStyleOptionSlider styleOption;
+ initStyleOption(&styleOption);
- QPainter painter(this);
+ QPainter painter(this);
- QRect handleRect = style()->subControlRect(QStyle::CC_ScrollBar, &styleOption, QStyle::SC_ScrollBarSlider, this);
- QRect innerRect = style()->subControlRect(QStyle::CC_ScrollBar, &styleOption, QStyle::SC_ScrollBarGroove, this);
+ QRect handleRect = style()->subControlRect(QStyle::CC_ScrollBar, &styleOption, QStyle::SC_ScrollBarSlider, this);
+ QRect innerRect = style()->subControlRect(QStyle::CC_ScrollBar, &styleOption, QStyle::SC_ScrollBarGroove, this);
- painter.translate(innerRect.topLeft() + QPoint(0, 3));
- qreal scale = static_cast<qreal>(innerRect.height() - 3) / static_cast<qreal>(m_Model->rowCount());
+ painter.translate(innerRect.topLeft() + QPoint(0, 3));
+ qreal scale = static_cast<qreal>(innerRect.height() - 3) / static_cast<qreal>(m_Model->rowCount());
- for (int i = 0; i < m_Model->rowCount(); ++i) {
- QVariant data = m_Model->data(m_Model->index(i, 0), m_Role);
- if (data.isValid()) {
- QColor col = data.value<QColor>();
- painter.setPen(col);
- painter.setBrush(col);
- painter.drawRect(QRect(2, i * scale - 2, handleRect.width() - 5, 3));
+ for (int i = 0; i < m_Model->rowCount(); ++i) {
+ QVariant data = m_Model->data(m_Model->index(i, 0), m_Role);
+ if (data.isValid()) {
+ QColor col = data.value<QColor>();
+ painter.setPen(col);
+ painter.setBrush(col);
+ painter.drawRect(QRect(2, i * scale - 2, handleRect.width() - 5, 3));
+ }
}
- }
}
|
