| 1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
|---|---|
| 2 | // |
| 3 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 4 | |
| 5 | #include "taskview.h" |
| 6 | #include "taskdelegate.h" |
| 7 | |
| 8 | #include <QScrollBar> |
| 9 | |
| 10 | TaskView::TaskView(QWidget *parent) : QListView(parent) |
| 11 | { |
| 12 | setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
| 13 | setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); |
| 14 | |
| 15 | QFontMetrics fm(font()); |
| 16 | int vStepSize = fm.height() + 3; |
| 17 | if (vStepSize < TaskDelegate::Positions::minimumHeight()) |
| 18 | vStepSize = TaskDelegate::Positions::minimumHeight(); |
| 19 | |
| 20 | verticalScrollBar()->setSingleStep(vStepSize); |
| 21 | } |
| 22 | |
| 23 | TaskView::~TaskView() = default; |
| 24 | |
| 25 | void TaskView::resizeEvent(QResizeEvent *e) |
| 26 | { |
| 27 | Q_UNUSED(e) |
| 28 | static_cast<TaskDelegate *>(itemDelegate())->emitSizeHintChanged(selectionModel()->currentIndex()); |
| 29 | } |
| 30 |