4#include <gemc/gdetector/gdetectorConstruction.h>
5#include <gemc/gbase/gbase.h>
10#include <QStandardItem>
14#include <QStyledItemDelegate>
62 explicit DBSelectView(
const std::shared_ptr<GOptions>& gopts,
64 QWidget* parent =
nullptr);
106 void loadExperiments();
119 void loadSystemsForExperiment(QStandardItem* experimentItem);
130 QStringList getAvailableRuns(
const std::string& system,
const std::string& variation)
const;
143 int getGeometryCount(
const std::string& system,
const std::string& variation,
int run)
const;
154 void updateSystemItemAppearance(QStandardItem* systemItem);
166 bool systemAvailable(
const std::string& system,
const std::string& variation,
int run);
173 void updateExperimentHeader();
182 void updateModifiedUI();
190 void resizeExperimentColumns();
198 QIcon createStatusIcon(
const QColor& color);
209 bool isGeometryTableValid()
const;
221 void applyGSystemSelections();
225 bool modified =
false;
228 QLabel* titleLabel =
nullptr;
231 QPushButton* reloadButton =
nullptr;
234 sqlite3* db =
nullptr;
240 std::string experiment;
243 QTreeView* experimentTree =
nullptr;
246 QStandardItemModel* experimentModel =
nullptr;
249 QLabel* experimentHeaderLabel =
nullptr;
252 bool m_ignoreItemChange =
false;
258 std::shared_ptr<GOptions> gopt;
271 void onItemChanged(QStandardItem* item);
322 explicit ComboDelegate(QObject* parent =
nullptr) : QStyledItemDelegate(parent) {}
335 const QStyleOptionViewItem& option,
336 const QModelIndex& index)
const override {
339 auto editor =
new QComboBox(parent);
352 void setEditorData(QWidget* editor,
const QModelIndex& index)
const override {
353 auto combo = qobject_cast<QComboBox*>(editor);
358 QVariant var = index.model()->data(index, Qt::UserRole);
359 QStringList opts = var.toStringList();
362 combo->addItems(opts);
364 QString currentText = index.model()->data(index, Qt::EditRole).toString();
365 int idx = combo->findText(currentText);
367 combo->setCurrentIndex(idx);
380 const QModelIndex& index)
const override {
381 auto combo = qobject_cast<QComboBox*>(editor);
385 QString value = combo->currentText();
386 model->setData(index, value, Qt::EditRole);
397 const QStyleOptionViewItem& option,
398 const QModelIndex& index)
const override {
400 editor->setGeometry(option.rect);
Item delegate that edits a cell using a QComboBox populated from Qt::UserRole.
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
Write the selected editor value back to the model.
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Create a QComboBox editor for the given cell.
void setEditorData(QWidget *editor, const QModelIndex &index) const override
Populate the editor from the model.
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Position the editor within the cell rectangle.
ComboDelegate(QObject *parent=nullptr)
Construct the delegate.
Qt widget used to select experiment/system configurations from an SQLite geometry database.
void geometryReloaded()
Emitted after detector construction has reloaded geometry from the selected systems.
SystemList get_gsystems()
Build and return the list of selected systems as a SystemList.
~DBSelectView() override
Destructor.
void geometryAboutToReload()
Emitted immediately before detector construction replaces the current geometry.
DBSelectView(const std::shared_ptr< GOptions > &gopts, GDetectorConstruction *dc, QWidget *parent=nullptr)
Construct the view and populate the experiment/system model from the database.
void reload_geometry()
Slot invoked by the Reload button to reload geometry based on current selections.
std::vector< SystemPtr > SystemList