all repos — mgba @ faceb902c823411f8199705a02e196e8cf969337

mGBA Game Boy Advance Emulator

src/platform/qt/RotatedHeaderView.cpp (view raw)

 1/* Copyright (c) 2013-2019 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#include "RotatedHeaderView.h"
 7
 8#include <QPainter>
 9
10using namespace QGBA;
11
12RotatedHeaderView::RotatedHeaderView(Qt::Orientation orientation, QWidget* parent)
13	: QHeaderView(orientation, parent)
14{
15	int margin = 2 * style()->pixelMetric(QStyle::PM_HeaderMargin, 0, this);
16	setMinimumSectionSize(fontMetrics().height() + margin);
17}
18
19void RotatedHeaderView::paintSection(QPainter* painter, const QRect& rect, int logicalIndex) const {
20	painter->save();
21	painter->translate(rect.x() + rect.width(), rect.y());
22	painter->rotate(90);
23	QHeaderView::paintSection(painter, QRect(0, 0, rect.height(), rect.width()), logicalIndex);
24	painter->restore();
25}
26
27QSize RotatedHeaderView::sectionSizeFromContents(int logicalIndex) const {
28	return QHeaderView::sectionSizeFromContents(logicalIndex).transposed();
29}