-
Wuttke, Joachim authoredWuttke, Joachim authored
InstrumentLibraryEditor.h 2.43 KiB
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/View/Instrument/InstrumentLibraryEditor.h
//! @brief Defines class InstrumentLibraryEditor
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#ifndef BORNAGAIN_GUI_VIEW_INSTRUMENT_INSTRUMENTLIBRARYEDITOR_H
#define BORNAGAIN_GUI_VIEW_INSTRUMENT_INSTRUMENTLIBRARYEDITOR_H
#include "GUI/Model/Instrument/InstrumentsTreeModel.h"
#include <QDialog>
class InstrumentItem;
namespace Ui {
class InstrumentLibraryEditor;
}
class InstrumentLibraryEditor : public QDialog {
Q_OBJECT
public:
InstrumentLibraryEditor(QWidget* parent);
~InstrumentLibraryEditor() override;
void setGisasEnabled(bool b);
void setOffSpecEnabled(bool b);
void setSpecularEnabled(bool b);
void setDepthProbeEnabled(bool b);
//! Execute the dialog for choosing an instrument from the library.
//! return nullptr if canceled
InstrumentItem* execChoose();
//! Execute the dialog to add an instrument to the library.
void execAdd(const InstrumentItem& instrumentToAdd);
private:
void onItemDoubleClickedForChoose(const QModelIndex& index);
void onCurrentChangedForChoose();
QList<QAction*> getOverlayActions(const QModelIndex& index, bool asHover);
void editNameAndDescription(InstrumentItem* item);
private:
//! A model extension for InstrumentsTreeModel which
//! * shows a "NEW" sign in the icon of a newly added instrument.
//! * creates a HTML text for the Display role
class TreeModel : public InstrumentsTreeModel {
public:
TreeModel(QObject* parent, InstrumentModel* model);
//! Set the instrument which shall have a "NEW" sign in its icon
void setNewInstrument(InstrumentItem* addedInstrument);
QVariant data(const QModelIndex& index, int role) const override;
private:
InstrumentItem* m_newInstrument = nullptr;
};
Ui::InstrumentLibraryEditor* m_ui;
TreeModel* m_treeModel;
InstrumentItem* m_chosenItem;
};
#endif // BORNAGAIN_GUI_VIEW_INSTRUMENT_INSTRUMENTLIBRARYEDITOR_H