...
 
Commits (2)
......@@ -23,6 +23,7 @@ UploadQueueWidget::UploadQueueWidget(QWidget *parent, FurAffinityClient* client)
tableModel->setEditStrategy(QSqlTableModel::OnManualSubmit);
// 15 == sort_id
tableModel->setSort(15, Qt::AscendingOrder);
tableModel->setFilter("`completed_at` IS NULL");
tableModel->select();
ui->qlvUploads->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->qlvUploads->setModel(tableModel);
......@@ -34,6 +35,8 @@ UploadQueueWidget::UploadQueueWidget(QWidget *parent, FurAffinityClient* client)
this->ui->qlStatus, &QLabel::setText);
connect(queueWorker, &UploadQueueWorker::workingChanged,
this, &UploadQueueWidget::disableUi);
connect(queueWorker, &UploadQueueWorker::targetChanged,
this, &UploadQueueWidget::onQueueWorkerTargetChanged);
}
UploadQueueWidget::~UploadQueueWidget()
......@@ -101,8 +104,11 @@ void UploadQueueWidget::on_qlvUploads_clicked(const QModelIndex &index)
{
auto upload = Upload::find(tableModel->record(index.row()).value("id").toInt());
ui->qpbMoveUp->setDisabled(false);
ui->qpbMoveDown->setDisabled(false);
if (ui->qlvUploads->isEnabled())
{
ui->qpbMoveUp->setDisabled(false);
ui->qpbMoveDown->setDisabled(false);
}
if (upload)
{
......@@ -229,6 +235,7 @@ void UploadQueueWidget::on_qpbMoveDown_clicked()
void UploadQueueWidget::on_qcbUpload_stateChanged(int state)
{
tableModel->select();
if (state == Qt::CheckState::Checked)
{
queueWorker->setWorking(true);
......@@ -252,3 +259,17 @@ void UploadQueueWidget::disableUi(bool shouldDisable)
ui->qpbMoveDown->setDisabled(true);
}
}
void UploadQueueWidget::onQueueWorkerTargetChanged(const qlonglong)
{
tableModel->select();
// just set the selection target to the topmost one
auto index = tableModel->index(0, 0);
if (!index.isValid())
{
return;
}
ui->qlvUploads->selectionModel()
->setCurrentIndex(index, QItemSelectionModel::Select);
on_qlvUploads_clicked(index);
}
......@@ -37,6 +37,8 @@ private slots:
void disableUi(bool shouldDisable);
void onQueueWorkerTargetChanged(const qlonglong uploadId);
private:
Ui::UploadQueueWidget *ui;
QSqlTableModel *tableModel;
......
......@@ -40,6 +40,7 @@ void UploadQueueWorker::perform()
}
auto upload = Upload::find(q.value("id").toLongLong());
emit(targetChanged(upload->id()));
emit(statusTextChanged(tr("Initialising upload “%1”").arg(upload->title())));
furAffinityClient->initSubmission(upload->id());
......
......@@ -37,6 +37,7 @@ signals:
void workingChanged(bool working);
void processingChanged(bool processing);
void statusTextChanged(const QString &updatedStatusText);
void targetChanged(const qlonglong uploadId);
public slots:
void setWorking(bool working)
......