diff options
Diffstat (limited to 'gui/groupview/Group.cpp')
-rw-r--r-- | gui/groupview/Group.cpp | 105 |
1 files changed, 93 insertions, 12 deletions
diff --git a/gui/groupview/Group.cpp b/gui/groupview/Group.cpp index 7cce674a..f3319dc3 100644 --- a/gui/groupview/Group.cpp +++ b/gui/groupview/Group.cpp @@ -3,6 +3,7 @@ #include <QModelIndex> #include <QPainter> #include <QtMath> +#include <QApplication> #include "GroupView.h" @@ -58,8 +59,9 @@ Group::HitResults Group::hitScan(const QPoint &pos) const return results; } -void Group::drawHeader(QPainter *painter, const QStyleOptionViewItem &option, const int y) +void Group::drawHeader(QPainter *painter, const QStyleOptionViewItem &option) { + /* QStyleOptionViewItemV4 opt = option; painter->save(); @@ -107,6 +109,95 @@ void Group::drawHeader(QPainter *painter, const QStyleOptionViewItem &option, co midY + 1); painter->restore(); + */ + painter->setRenderHint(QPainter::Antialiasing); + + const QRect optRect = option.rect; + QFont font(QApplication::font()); + font.setBold(true); + const QFontMetrics fontMetrics = QFontMetrics(font); + + QColor outlineColor = option.palette.text().color(); + outlineColor.setAlphaF(0.35); + + //BEGIN: top left corner + { + painter->save(); + painter->setPen(outlineColor); + const QPointF topLeft(optRect.topLeft()); + QRectF arc(topLeft, QSizeF(4, 4)); + arc.translate(0.5, 0.5); + painter->drawArc(arc, 1440, 1440); + painter->restore(); + } + //END: top left corner + + //BEGIN: left vertical line + { + QPoint start(optRect.topLeft()); + start.ry() += 3; + QPoint verticalGradBottom(optRect.topLeft()); + verticalGradBottom.ry() += fontMetrics.height() + 5; + QLinearGradient gradient(start, verticalGradBottom); + gradient.setColorAt(0, outlineColor); + gradient.setColorAt(1, Qt::transparent); + painter->fillRect(QRect(start, QSize(1, fontMetrics.height() + 5)), gradient); + } + //END: left vertical line + + //BEGIN: horizontal line + { + QPoint start(optRect.topLeft()); + start.rx() += 3; + QPoint horizontalGradTop(optRect.topLeft()); + horizontalGradTop.rx() += optRect.width() - 6; + painter->fillRect(QRect(start, QSize(optRect.width() - 6, 1)), outlineColor); + } + //END: horizontal line + + //BEGIN: top right corner + { + painter->save(); + painter->setPen(outlineColor); + QPointF topRight(optRect.topRight()); + topRight.rx() -= 4; + QRectF arc(topRight, QSizeF(4, 4)); + arc.translate(0.5, 0.5); + painter->drawArc(arc, 0, 1440); + painter->restore(); + } + //END: top right corner + + //BEGIN: right vertical line + { + QPoint start(optRect.topRight()); + start.ry() += 3; + QPoint verticalGradBottom(optRect.topRight()); + verticalGradBottom.ry() += fontMetrics.height() + 5; + QLinearGradient gradient(start, verticalGradBottom); + gradient.setColorAt(0, outlineColor); + gradient.setColorAt(1, Qt::transparent); + painter->fillRect(QRect(start, QSize(1, fontMetrics.height() + 5)), gradient); + } + //END: right vertical line + + //BEGIN: text + { + QRect textRect(option.rect); + textRect.setTop(textRect.top() + 7); + textRect.setLeft(textRect.left() + 7); + textRect.setHeight(fontMetrics.height()); + textRect.setRight(textRect.right() - 7); + + painter->save(); + painter->setFont(font); + QColor penColor(option.palette.text().color()); + penColor.setAlphaF(0.6); + painter->setPen(penColor); + painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, text); + painter->restore(); + } + //END: text } int Group::totalHeight() const @@ -144,17 +235,7 @@ int Group::numRows() const int Group::verticalPosition() const { - int res = 0; - const QList<Group *> cats = view->m_groups; - for (int i = 0; i < cats.size(); ++i) - { - if (cats.at(i) == this) - { - break; - } - res += cats.at(i)->totalHeight() + view->m_categoryMargin; - } - return res; + return m_verticalPosition; } QList<QModelIndex> Group::items() const |