28 : QAbstractListModel(parent)
34 connect(jobs, &QAbstractItemModel::rowsAboutToBeInserted,
this,
54 if (!index.isValid() || index.row() >= jobs.size() || index.row() < 0)
57 JobItem* item = jobs[index.row()];
58 if (role == Qt::DisplayRole)
67 if (index.row() >= 0 && index.row() < jobs.size())
68 return jobs[index.row()];
75 int idx = jobs.indexOf(job);
88 beginRemoveRows(QModelIndex(), index.row(), index.row());
103 int i = jobs.indexOf(job);
105 QModelIndex idx = index(i, 0);
106 emit dataChanged(idx, idx);
116 if (!parent.isValid())
117 beginInsertRows(QModelIndex(), start, end);
122 if (!parent.isValid()) {
125 for (
int i = start; i <= end; i++)
150 disconnect(job,
nullptr,
this,
nullptr);
Defines class JobListModel.
JobStatus
The JobStatus enum lists the possible states of a job.
void jobStatusChanged(const JobStatus status)
void jobProgressChanged(int progress)
void jobNameChanged(const QString &name)
void removeJob(const QModelIndex &index)
void disableJobNotification(JobItem *job)
JobListModel(JobModel *jobs, QObject *parent=nullptr)
int rowCount(const QModelIndex &parent=QModelIndex()) const override
void cancelJob(const QModelIndex &index)
QModelIndex indexForJob(JobItem *job)
void onRowsInserted(const QModelIndex &parent, int start, int end)
void emitJobListModelChanged(JobItem *job)
JobItem * jobForIndex(const QModelIndex &index) const
void enableJobNotification(JobItem *job)
void onRowsAboutToBeInserted(const QModelIndex &parent, int start, int end)
void runJob(const QModelIndex &index)
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
QVector< JobItem * > jobItems() const
void runJob(JobItem *jobItem)
void removeJob(JobItem *jobItem)
void cancelJob(JobItem *jobItem)