10#include <QStandardItem>
14#include <QStyledItemDelegate>
63 explicit DBSelectView(
const std::shared_ptr<GOptions>& gopts,
65 QWidget* parent =
nullptr);
107 void loadExperiments();
120 void loadSystemsForExperiment(QStandardItem* experimentItem);
130 QStringList getAvailableVariations(
const std::string& system)
const;
140 QStringList getAvailableRuns(
const std::string& system);
153 int getGeometryCount(
const std::string& system,
const std::string& variation,
int run)
const;
164 void updateSystemItemAppearance(QStandardItem* systemItem);
176 bool systemAvailable(
const std::string& system,
const std::string& variation,
int run);
183 void updateExperimentHeader();
192 void updateModifiedUI();
200 QIcon createStatusIcon(
const QColor& color);
211 bool isGeometryTableValid()
const;
223 void applyGSystemSelections();
227 bool modified =
false;
230 QLabel* titleLabel =
nullptr;
233 QPushButton* reloadButton =
nullptr;
236 sqlite3* db =
nullptr;
242 std::string experiment;
245 QTreeView* experimentTree =
nullptr;
248 QStandardItemModel* experimentModel =
nullptr;
251 QLabel* experimentHeaderLabel =
nullptr;
254 bool m_ignoreItemChange =
false;
260 std::shared_ptr<GOptions> gopt;
273 void onItemChanged(QStandardItem* item);
307 explicit ComboDelegate(QObject* parent =
nullptr) : QStyledItemDelegate(parent) {}
320 const QStyleOptionViewItem& option,
321 const QModelIndex& index)
const override {
324 auto editor =
new QComboBox(parent);
337 void setEditorData(QWidget* editor,
const QModelIndex& index)
const override {
338 auto combo = qobject_cast<QComboBox*>(editor);
343 QVariant var = index.model()->data(index, Qt::UserRole);
344 QStringList opts = var.toStringList();
347 combo->addItems(opts);
349 QString currentText = index.model()->data(index, Qt::EditRole).toString();
350 int idx = combo->findText(currentText);
352 combo->setCurrentIndex(idx);
365 const QModelIndex& index)
const override {
366 auto combo = qobject_cast<QComboBox*>(editor);
370 QString value = combo->currentText();
371 model->setData(index, value, Qt::EditRole);
382 const QStyleOptionViewItem& option,
383 const QModelIndex& index)
const override {
385 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.
SystemList get_gsystems()
Build and return the list of selected systems as a SystemList.
~DBSelectView() override
Destructor.
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