追加添加后台任务显示视图未提交文件
This commit is contained in:
parent
8dd2f44dc5
commit
7bd14d8179
69
src/BackgroundTaskListView/BackgroundTaskListView.cpp
Normal file
69
src/BackgroundTaskListView/BackgroundTaskListView.cpp
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
#include "BackgroundTaskListView.h"
|
||||||
|
#include "BackgroundTaskListModel.h"
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QHeaderView>
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
40
src/BackgroundTaskListView/BackgroundTaskListView.h
Normal file
40
src/BackgroundTaskListView/BackgroundTaskListView.h
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
#ifndef BACKGROUNDTASKLISTVIEW_H
|
||||||
|
#define BACKGROUNDTASKLISTVIEW_H
|
||||||
|
|
||||||
|
#include <QTableView>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QProgressBar>
|
||||||
|
#include <QStyledItemDelegate>
|
||||||
|
|
||||||
|
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
|
||||||
Loading…
Reference in New Issue
Block a user