From 7bd14d81798ee16c1014311cbb152f26d98c49df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B5=B7?= Date: Mon, 25 May 2026 11:56:32 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E6=B7=BB=E5=8A=A0=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E4=BB=BB=E5=8A=A1=E6=98=BE=E7=A4=BA=E8=A7=86=E5=9B=BE?= =?UTF-8?q?=E6=9C=AA=E6=8F=90=E4=BA=A4=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BackgroundTaskListView.cpp | 69 +++++++++++++++++++ .../BackgroundTaskListView.h | 40 +++++++++++ 2 files changed, 109 insertions(+) create mode 100644 src/BackgroundTaskListView/BackgroundTaskListView.cpp create mode 100644 src/BackgroundTaskListView/BackgroundTaskListView.h diff --git a/src/BackgroundTaskListView/BackgroundTaskListView.cpp b/src/BackgroundTaskListView/BackgroundTaskListView.cpp new file mode 100644 index 0000000..7925179 --- /dev/null +++ b/src/BackgroundTaskListView/BackgroundTaskListView.cpp @@ -0,0 +1,69 @@ +#include "BackgroundTaskListView.h" +#include "BackgroundTaskListModel.h" +#include +#include + + +BackgroundTaskListView::BackgroundTaskListView(QWidget* parent) + : QTableView(parent) +{ + this->setModel(BackgroundTaskListModel::Instance()); + + this->verticalHeader()->setVisible(false); + this->horizontalHeader()->setVisible(false); + this->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); + this->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch); + this->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); + + this->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); + this->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + + this->setGridStyle(Qt::NoPen); +} + +// ProgressBarItem::ProgressBarItem(const QString &text, QWidget *parent) +// : QProgressBar(parent) +// { +// this->setMinimum(0); +// this->setMaximum(100); +// this->setFormat(text + "......"); + +// QTimer* timer = new QTimer(this); +// timer->setInterval(200); +// connect(timer, &QTimer::timeout, [this](){ +// int progress = this->value(); +// if ( progress >= this->maximum() ) +// progress = 0; +// this->setValue(progress + 10); +// this->update(); +// }); +// timer->start(); +// } + +// ProgressBarDelegate::ProgressBarDelegate(QObject *parent) +// : QStyledItemDelegate(parent) +// { +// } + +// QWidget *ProgressBarDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const +// { +// QString text = index.data(Qt::DisplayRole).toString(); +// return new ProgressBarItem(text, parent); +// } + +// void ProgressBarDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const +// { + +// } + +// void ProgressBarDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const +// { +// editor->setGeometry(option.rect); +// } + +// QSize ProgressBarDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const +// { +// return QSize(option.rect.width(), 40); +// } + + diff --git a/src/BackgroundTaskListView/BackgroundTaskListView.h b/src/BackgroundTaskListView/BackgroundTaskListView.h new file mode 100644 index 0000000..caaa81c --- /dev/null +++ b/src/BackgroundTaskListView/BackgroundTaskListView.h @@ -0,0 +1,40 @@ +#ifndef BACKGROUNDTASKLISTVIEW_H +#define BACKGROUNDTASKLISTVIEW_H + +#include +#include +#include +#include +#include + +class BackgroundTaskListView : public QTableView +{ + Q_OBJECT +public: + explicit BackgroundTaskListView(QWidget* parent = nullptr); +}; + +// class ProgressBarItem : public QProgressBar +// { +// Q_OBJECT +// public: +// explicit ProgressBarItem(const QString& text, QWidget *parent = nullptr); +// }; + +// class ProgressBarDelegate : public QStyledItemDelegate +// { +// Q_OBJECT +// public: +// explicit ProgressBarDelegate(QObject *parent = nullptr); + +// QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override; + +// void setEditorData(QWidget *editor, const QModelIndex &index) const override; + +// void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override; + +// // QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; +// }; + + +#endif // BACKGROUNDTASKLISTVIEW_H