1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
---|---|
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #include "projectdelegate.h" |
6 | |
7 | #include <QPainter> |
8 | |
9 | class ProjectDelegatePrivate |
10 | { |
11 | friend class ProjectDelegate; |
12 | QModelIndex index; |
13 | }; |
14 | |
15 | ProjectDelegate::ProjectDelegate(QObject *parent) |
16 | : QStyledItemDelegate (parent) |
17 | , d (new ProjectDelegatePrivate) |
18 | { |
19 | |
20 | } |
21 | |
22 | void ProjectDelegate::setActiveProject(const QModelIndex &root) |
23 | { |
24 | d->index = root; |
25 | } |
26 | |
27 | const QModelIndex &ProjectDelegate::getActiveProject() const |
28 | { |
29 | return d->index; |
30 | } |
31 | |
32 | void ProjectDelegate::paint(QPainter *painter, |
33 | const QStyleOptionViewItem &option, |
34 | const QModelIndex &index) const |
35 | { |
36 | QStyleOptionViewItem iOption = option; |
37 | if (d->index.isValid() && d->index == index) { |
38 | iOption.font.setBold(true); |
39 | } |
40 | QStyledItemDelegate::paint(painter, iOption, index); |
41 | } |
42 |