File indexing completed on 2025-01-05 04:59:46
0001 /* 0002 * SPDX-FileCopyrightText: 2014 Christian Mollekopf <mollekopf@kolabsys.com> 0003 * SPDX-FileCopyrightText: 2014 Kevin Ottens <ervin@kde.org> 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 0008 #include "datasourcedelegate.h" 0009 0010 #include <QApplication> 0011 #include <QMouseEvent> 0012 0013 #include "presentation/querytreemodel.h" 0014 0015 using namespace Widgets; 0016 0017 const int DELEGATE_HEIGHT = 16; 0018 0019 DataSourceDelegate::DataSourceDelegate(QObject *parent) 0020 : QStyledItemDelegate(parent) 0021 { 0022 } 0023 0024 void DataSourceDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt, const QModelIndex &index) const 0025 { 0026 Q_ASSERT(index.isValid()); 0027 0028 const auto isDefault = index.data(Presentation::QueryTreeModelBase::IsDefaultRole).toBool(); 0029 0030 QStyleOptionViewItem option = opt; 0031 initStyleOption(&option, index); 0032 option.font.setBold(isDefault); 0033 0034 QStyledItemDelegate::paint(painter, option, index); 0035 } 0036 0037 QSize DataSourceDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const 0038 { 0039 QSize size = QStyledItemDelegate::sizeHint(option, index); 0040 // Make sure we got a constant height 0041 size.setHeight(DELEGATE_HEIGHT + 4); 0042 return size; 0043 } 0044 0045 #include "moc_datasourcedelegate.cpp"