25 #include <QVBoxLayout>
30 bool row_descending(
const QModelIndex& idx1,
const QModelIndex& idx2)
32 return idx1.row() > idx2.row();
36 bool row_ascending(
const QModelIndex& idx1,
const QModelIndex& idx2)
38 return idx1.row() < idx2.row();
54 setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
56 auto* layout =
new QVBoxLayout(
this);
61 m_runAction->setToolTip(
"Run currently selected jobs");
80 toolbar->setMinimumSize(toolbar->minimumHeight(), toolbar->minimumHeight());
81 toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
85 layout->addWidget(toolbar);
88 m_listView->setSelectionMode(QAbstractItemView::ExtendedSelection);
96 setContextMenuPolicy(Qt::CustomContextMenu);
99 connect(
m_listView->selectionModel(), &QItemSelectionModel::selectionChanged,
this,
101 connect(
m_model, &QAbstractListModel::dataChanged,
this,
110 QVector<JobItem*> jobs;
111 for (
const QModelIndex& index :
m_listView->selectionModel()->selectedIndexes())
119 QModelIndexList selected =
m_listView->selectionModel()->selectedIndexes();
124 if (selected.size() == 1 && selected.front() == idx) {
129 m_listView->selectionModel()->select(idx, QItemSelectionModel::ClearAndSelect);
143 const QModelIndex& bottomRight)
146 ASSERT(topLeft == bottomRight);
148 if (
m_listView->selectionModel()->isSelected(topLeft))
154 for (
const QModelIndex& index :
m_listView->selectionModel()->selectedIndexes())
160 for (
const QModelIndex& index :
m_listView->selectionModel()->selectedIndexes())
166 QModelIndexList indexes =
m_listView->selectionModel()->selectedIndexes();
167 std::sort(indexes.begin(), indexes.end(), row_descending);
168 for (
const QModelIndex& index : indexes) {
176 QModelIndexList indexes =
m_listView->selectionModel()->selectedIndexes();
182 for (
const QModelIndex& index : indexes) {
207 QModelIndexList indexes =
m_listView->selectionModel()->selectedIndexes();
208 if (indexes.size() > 1) {
209 std::sort(indexes.begin(), indexes.end(), row_ascending);
210 for (
const QModelIndex& index : indexes) {
219 menu.exec(QCursor::pos());
228 QModelIndexList indexes =
m_listView->selectionModel()->selectedIndexes();
230 struct IsRunningOrFitting {
236 bool operator()(
const QModelIndex& i)
const
244 bool none_running = std::none_of(indexes.begin(), indexes.end(), IsRunningOrFitting(
m_model));
245 bool all_running = std::all_of(indexes.begin(), indexes.end(), IsRunningOrFitting(
m_model));
246 bool nonempty = !indexes.empty();
256 m_listView->selectionModel()->select(last, QItemSelectionModel::ClearAndSelect);
Defines class IntensityDataItem.
Defines class JobListModel.
Defines class JobListViewDelegate.
Defines class JobListView.
void setLowerX(double value)
double getLowerZ() const
Returns lower and upper zoom ranges of z-axis.
void setLowerY(double value)
void setUpperZ(double zmax)
void setLowerZ(double zmin)
double getLowerY() const
Returns lower and upper zoom ranges of y-axis.
void setUpperX(double value)
void setUpperY(double value)
double getLowerX() const
Returns lower and upper zoom ranges of x-axis.
IntensityDataItem * intensityDataItem()
void removeJob(const QModelIndex &index)
int rowCount(const QModelIndex &parent=QModelIndex()) const override
void cancelJob(const QModelIndex &index)
QModelIndex indexForJob(JobItem *job)
JobItem * jobForIndex(const QModelIndex &index) const
void runJob(const QModelIndex &index)
ViewDelegate to show progress bar JobQueuListView.
void equalizeSelectedToJob(JobItem *job)
void onJobListModelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
void onItemSelectionChanged()
QVector< JobItem * > selectedJobs() const
JobListViewDelegate * m_listViewDelegate
void ensureItemSelected()
JobListView(JobModel *jobs, QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
void selectedJobsChanged(const QVector< JobItem * > &jobs)
void showContextMenu(const QPoint &pos)
void selectJob(JobItem *job)