InstrumentView.cpp 2.04 KiB
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/Views/InstrumentWidgets/InstrumentView.cpp
//! @brief Implements class InstrumentView
//!
//! @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)
//
// ************************************************************************************************
#include "GUI/Views/InstrumentWidgets/InstrumentView.h"
#include "GUI/Models/InstrumentItems.h"
#include "GUI/Models/InstrumentModel.h"
#include "GUI/Views/CommonWidgets/StyledToolBar.h"
#include "GUI/Views/InstrumentWidgets/InstrumentEditor.h"
#include "GUI/Views/InstrumentWidgets/InstrumentListView.h"
#include "GUI/mainwindow/projectdocument.h"
#include <QBoxLayout>
InstrumentView::InstrumentView(QWidget* parent, ProjectDocument* document)
: QWidget(parent), m_document(document)
{
auto horizontalLayout = new QHBoxLayout;
m_instrumentListView = new InstrumentListView(document, this);
horizontalLayout->addWidget(m_instrumentListView);
m_instrumentEditor = new InstrumentEditor(this);
horizontalLayout->addWidget(m_instrumentEditor, 1);
StyledToolBar* toolbar = new StyledToolBar(this);
toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
toolbar->addActions(m_instrumentListView->toolbarActions());
auto mainLayout = new QVBoxLayout;
mainLayout->setMargin(0);
mainLayout->setSpacing(0);
mainLayout->addWidget(toolbar);
mainLayout->addLayout(horizontalLayout);
setLayout(mainLayout);
connect(m_instrumentListView, &InstrumentListView::instrumentSelected, this,
&InstrumentView::onInstrumentSelected);
onInstrumentSelected(nullptr);
}
void InstrumentView::onInstrumentSelected(InstrumentItem* instrumentItem)
{
m_instrumentEditor->setItem(instrumentItem);
}