21 #include <QItemSelectionModel>
23 #include <QPersistentModelIndex>
28 , m_runJobAction(nullptr)
29 , m_removeJobAction(nullptr)
30 , m_selectionModel(nullptr)
31 , m_jobModel(jobModel)
52 for (
auto index : indexList) {
60 QList<QPersistentModelIndex> toRemove;
63 toRemove.append(QPersistentModelIndex(index));
65 for (
auto index : toRemove)
86 if (selected_id >= selectedList.size())
93 if (!referenceDataItem)
96 for (
auto index : selectedList) {
98 if (jobItem == referenceItem)
101 dataItem->setLowerX(referenceDataItem->
getLowerX());
102 dataItem->setUpperX(referenceDataItem->
getUpperX());
103 dataItem->setLowerY(referenceDataItem->
getLowerY());
104 dataItem->setUpperY(referenceDataItem->
getUpperY());
105 dataItem->setLowerZ(referenceDataItem->
getLowerZ());
106 dataItem->setUpperZ(referenceDataItem->
getUpperZ());
113 menu.setToolTipsVisible(
true);
118 QModelIndex targetIndex = indexAtPoint;
119 if (!targetIndex.isValid()) {
121 if (!indexList.empty())
122 targetIndex = indexList.first();
134 QMenu* equalize_menu = menu.addMenu(
"Equalize selected plots");
135 equalize_menu->setToolTipsVisible(
true);
136 equalize_menu->setToolTip(
137 "All plots from the list of selected jobs will be equalized to the one.");
140 if (selected.size() <= 1) {
141 equalize_menu->setDisabled(
true);
144 std::sort(selected.begin(), selected.end(),
145 [](
const QModelIndex& a,
const QModelIndex& b) { return a.row() < b.row(); });
147 for (
int i = 0; i < selected.count(); ++i) {
149 QAction* action = equalize_menu->addAction(QString(
"to ").append(jobItem->
itemName()));
162 if (!index.isValid())
175 if (!index.isValid())
#define ASSERT(condition)
Defines class IntensityDataItem.
Defines class JobSelectorActions.
double getLowerZ() const
returns lower and upper zoom ranges of z-axis
double getLowerY() const
returns lower and upper zoom ranges of y-axis
double getLowerX() const
returns lower and upper zoom ranges of x-axis
QString getStatus() const
IntensityDataItem * intensityDataItem()
void runJob(const QModelIndex &index)
void removeJob(const QModelIndex &index)
const JobItem * getJobItemForIndex(const QModelIndex &index) const
void onContextMenuRequest(const QPoint &point, const QModelIndex &indexAtPoint={})
Generates context menu at given point.
void setupEqualizeMenu(QMenu &menu)
void initItemContextMenu(QMenu &menu, const QModelIndex &indexAtPoint)
JobSelectorActions(JobModel *jobModel, QObject *parent=0)
void equalizeSelectedToJob(int selected_id)
Puts all IntensityDataItem axes range to the selected job.
void setAllActionsEnabled(bool value)
QItemSelectionModel * m_selectionModel
void setSelectionModel(QItemSelectionModel *selectionModel)
bool canRemoveJob(const QModelIndex &index) const
QAction * m_removeJobAction
bool canRunJob(const QModelIndex &index) const
QString itemName() const
Get item name, return display name if no name is set.