25 const QString ColumnNames[] = {
"Name",
"Value"};
26 const int NumColumns = (int)std::size(ColumnNames);
32 const QString RowNames[] = {
"Name",
"Sample",
"Instrument",
"Status",
"Begin",
"End",
"Duration"};
33 const int NumRows = (int)std::size(RowNames);
35 const QString ModelDateShortFormat =
"yyyy.MM.dd hh:mm:ss";
48 : QAbstractTableModel(parent)
56 disconnect(
m_item,
nullptr,
this,
nullptr);
61 if (!parent.isValid() &&
m_item)
68 if (!parent.isValid() &&
m_item)
75 if ((role != Qt::DisplayRole && role != Qt::EditRole && role != Qt::ToolTipRole)
76 || index.column() < 0 || index.column() >= NumColumns || index.row() < 0
77 || index.row() >= NumRows || !
m_item)
80 switch (index.column()) {
82 return RowNames[index.row()];
84 switch (index.row()) {
94 if (role == Qt::ToolTipRole)
98 if (role == Qt::ToolTipRole)
99 return QLocale().toString(
m_item->
endTime(), QLocale::LongFormat);
101 case Row::Duration: {
104 return QString(
"%1 s").arg(duration.value() / 1000., 0,
'f', 3);
119 if (role == Qt::DisplayRole && orientation == Qt::Horizontal && section >= 0
120 && section < NumColumns)
121 return ColumnNames[section];
127 Qt::ItemFlags f = QAbstractTableModel::flags(index);
129 f.setFlag(Qt::ItemIsEditable);
135 if (role != Qt::EditRole || index.column() !=
Column::Value || index.row() != Row::Name
146 disconnect(
m_item,
nullptr,
this,
nullptr);
162 {Qt::DisplayRole, Qt::EditRole});
168 {Qt::DisplayRole, Qt::EditRole});
174 {Qt::DisplayRole, Qt::EditRole});
180 {Qt::DisplayRole, Qt::EditRole});
Defines class JobPropertiesWidget.
QString jobStatusToString(JobStatus status)
get a string representation of the status
JobStatus
The JobStatus enum lists the possible states of a job.
Assembles beam, detector and their relative positions with respect to the sample.
void jobStatusChanged(const JobStatus status)
QString instrumentName() const
void jobEndTimeChanged(const QDateTime &end_time)
void setJobName(const QString &name)
QDateTime endTime() const
void jobBeginTimeChanged(const QDateTime &begin_time)
QString sampleName() const
void jobNameChanged(const QString &name)
QDateTime beginTime() const
JobStatus getStatus() const
std::optional< size_t > duration() const
if begin and end time are both available the duration in ms, otherwise empty
Qt::ItemFlags flags(const QModelIndex &index) const override
JobPropertiesTableModel(QObject *parent=nullptr)
~JobPropertiesTableModel() override
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
int rowCount(const QModelIndex &parent=QModelIndex()) const override
void notifyJobPropertyChange()
int columnCount(const QModelIndex &parent=QModelIndex()) const override
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
void setItem(JobItem *item)