aheinecke@404: /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik aheinecke@404: * Software engineering by Intevation GmbH aheinecke@404: * aheinecke@404: * This file is Free Software under the GNU GPL (v>=2) aheinecke@404: * and comes with ABSOLUTELY NO WARRANTY! aheinecke@404: * See LICENSE.txt for details. aheinecke@404: */ rrenkert@273: #include rrenkert@273: rrenkert@273: #include "separatoritemdelegate.h" rrenkert@273: rrenkert@273: void SeparatorItemDelegate::paint(QPainter *painter, rrenkert@273: const QStyleOptionViewItem &option, const QModelIndex &index) const rrenkert@273: { rrenkert@273: // Save the current painter. rrenkert@273: painter->save(); rrenkert@273: rrenkert@273: // Get the position for separator line. rrenkert@273: int topLeftY = option.rect.topLeft().y(); rrenkert@273: int height = option.rect.height(); rrenkert@273: int middle = topLeftY + (height / 2); rrenkert@273: rrenkert@273: // Draw the first part. rrenkert@273: QPen linePen(Qt::black, 2, Qt::SolidLine); rrenkert@273: painter->setPen(linePen); rrenkert@273: painter->drawLine(10, middle, 80, middle); rrenkert@273: rrenkert@273: // Draw the text. rrenkert@273: QString text = index.data().toString(); rrenkert@273: QRect rect = option.rect.adjusted(85, -2, 0, -2); rrenkert@273: painter->drawText(rect.left(), rect.top(), rect.width(), rect.height(), rrenkert@273: Qt::AlignVCenter|Qt::AlignLeft, text, &rect); rrenkert@273: rrenkert@273: // Draw the second part. rrenkert@273: painter->drawLine(rect.topRight().x() + 5, middle, rect.topRight().x() + 75, middle); rrenkert@273: rrenkert@273: // Restore the painter to have an unmodified painter for the next draw rrenkert@273: // action. rrenkert@273: painter->restore(); rrenkert@273: return; rrenkert@273: }