24 #include <QMessageBox>
25 #include <QVBoxLayout>
30 , m_document(document)
32 setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
34 auto* layout =
new QVBoxLayout(
this);
35 layout->setMargin(10);
43 m_listView->setSelectionMode(QAbstractItemView::SingleSelection);
47 QString::fromUtf8(
"QListView#listView\n"
49 " selection-background-color : rgb(98,100,105); \n"
50 " selection-color: rgb(255,255,255);\n"
51 " border: 1px solid rgb(98,100,105);\n"
60 m_newGisasAction->setToolTip(
"Add new GISAS instrument with default settings");
66 m_newOffspecAction->setToolTip(
"Add new off-specular instrument with default settings");
93 m_copyAction->setIcon(QIcon(
":/images/content-copy.svg"));
94 m_copyAction->setToolTip(
"Make a copy of the selected instrument");
116 setContextMenuPolicy(Qt::ActionsContextMenu);
118 connect(
m_listView->selectionModel(), &QItemSelectionModel::selectionChanged,
this,
132 return QSize(170, 400);
137 return QSize(96, 200);
150 const QModelIndexList indexes =
m_listView->selectionModel()->selectedIndexes();
151 if (!indexes.empty())
160 QModelIndexList indexes =
m_listView->selectionModel()->selectedIndexes();
161 if (!indexes.empty())
170 m_listView->selectionModel()->select(idx, QItemSelectionModel::ClearAndSelect);
176 m_listView->selectionModel()->select(idx, QItemSelectionModel::ClearAndSelect);
182 m_listView->selectionModel()->select(idx, QItemSelectionModel::ClearAndSelect);
188 m_listView->selectionModel()->select(idx, QItemSelectionModel::ClearAndSelect);
194 QModelIndexList indexes =
m_listView->selectionModel()->selectedIndexes();
195 if (!indexes.empty()) {
205 QModelIndexList indexes =
m_listView->selectionModel()->selectedIndexes();
206 if (!indexes.empty()) {
208 m_listView->selectionModel()->select(idx, QItemSelectionModel::ClearAndSelect);
214 if (!
m_listView->selectionModel()->hasSelection())
217 QModelIndex idx =
m_listView->selectionModel()->selectedIndexes().front();
232 "The library does not contain instruments so far.");
243 if (instrumentToCopy ==
nullptr)
247 m_listView->selectionModel()->select(idx, QItemSelectionModel::ClearAndSelect);
263 bool enabled =
m_listView->selectionModel()->hasSelection();
273 m_listView->selectionModel()->select(last, QItemSelectionModel::ClearAndSelect);
Defines class InstrumentItem and all its children.
Defines class InstrumentLibraryEditor.
Defines class InstrumentListModel.
Defines class InstrumentListView.
Defines class ProjectDocument.
SessionData * gSessionData
global pointer to the single instance
Defines struct SessionData.
Abstract base class for instrument-specific item classes.
void setOffspecEnabled(bool b)
InstrumentItem * execChoose()
Execute the dialog for choosing an instrument from the library. Returns nullptr if canceled.
void execAdd(const InstrumentItem &instrumentToAdd)
Execute the dialog to add an instrument to the library.
void setGisasEnabled(bool b)
void setSpecularEnabled(bool b)
void setDepthProbeEnabled(bool b)
List model for instruments.
QModelIndex copyInstrument(const QModelIndex &source)
QModelIndex addNewSpecularInstrument()
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QModelIndex addNewOffspecInstrument()
void removeInstrument(const QModelIndex &index)
QModelIndex addNewGISASInstrument()
InstrumentItem * instrumentForIndex(const QModelIndex &index) const
QModelIndex addNewDepthProbeInstrument()
QSize minimumSizeHint() const override
void ensureItemSelected()
QAction * m_separatorAction2
QAction * m_newSpecularAction
ProjectDocument * m_document
QAction * m_newOffspecAction
InstrumentListModel * m_model
void onCopy()
Makes a copy of the currently selected instrument.
InstrumentItem * currentInstrument() const
QAction * m_newGisasAction
void instrumentSelected(InstrumentItem *instrument)
QAction * m_separatorAction1
QAction * m_newDepthProbeAction
QSize sizeHint() const override
QList< QAction * > toolbarActions() const
InstrumentListView(ProjectDocument *document, QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
void onItemSelectionChanged()
void updateFunctionalityNarrowing()
Show/hide UI elements according to settings in current project.
void onRemove()
Removes currently selected instrument.
QAction * m_loadFromLibraryAction
QAction * m_storeInLibraryAction
Project document class handles all data related to the opened project (sample, job,...
Functionalities functionalities() const
bool singleInstrumentMode() const
void modified()
Emitted for any modifications in the document.
InstrumentsEditController * instrumentsEditController()
The edit controller for the instruments in this project document.
static QMainWindow * mainWindow
void information(QWidget *parent, const QString &title, const QString &text, const QString &detailedText)
InstrumentLibrary instrumentLibrary