CatalogueInspectorWidget.cpp
89 lines
| 2.8 KiB
| text/x-c
|
CppLexer
r1130 | #include "Catalogue/CatalogueInspectorWidget.h" | |||
#include "ui_CatalogueInspectorWidget.h" | ||||
r1162 | #include <Common/DateUtils.h> | |||
#include <DBCatalogue.h> | ||||
#include <DBEvent.h> | ||||
#include <DBTag.h> | ||||
r1180 | struct CatalogueInspectorWidget::CatalogueInspectorWidgetPrivate { | |||
std::shared_ptr<DBCatalogue> m_DisplayedCatalogue = nullptr; | ||||
std::shared_ptr<DBEvent> m_DisplayedEvent = nullptr; | ||||
}; | ||||
r1130 | CatalogueInspectorWidget::CatalogueInspectorWidget(QWidget *parent) | |||
r1180 | : QWidget(parent), | |||
ui(new Ui::CatalogueInspectorWidget), | ||||
impl{spimpl::make_unique_impl<CatalogueInspectorWidgetPrivate>()} | ||||
r1130 | { | |||
ui->setupUi(this); | ||||
r1134 | showPage(Page::Empty); | |||
r1180 | ||||
connect(ui->leCatalogueName, &QLineEdit::editingFinished, [this]() { | ||||
if (ui->leCatalogueName->text() != impl->m_DisplayedCatalogue->getName()) { | ||||
impl->m_DisplayedCatalogue->setName(ui->leCatalogueName->text()); | ||||
emit this->catalogueUpdated(impl->m_DisplayedCatalogue); | ||||
} | ||||
}); | ||||
connect(ui->leCatalogueAuthor, &QLineEdit::editingFinished, [this]() { | ||||
if (ui->leCatalogueAuthor->text() != impl->m_DisplayedCatalogue->getAuthor()) { | ||||
impl->m_DisplayedCatalogue->setAuthor(ui->leCatalogueAuthor->text()); | ||||
emit this->catalogueUpdated(impl->m_DisplayedCatalogue); | ||||
} | ||||
}); | ||||
r1130 | } | |||
CatalogueInspectorWidget::~CatalogueInspectorWidget() | ||||
{ | ||||
delete ui; | ||||
} | ||||
r1134 | ||||
void CatalogueInspectorWidget::showPage(CatalogueInspectorWidget::Page page) | ||||
{ | ||||
ui->stackedWidget->setCurrentIndex(static_cast<int>(page)); | ||||
} | ||||
CatalogueInspectorWidget::Page CatalogueInspectorWidget::currentPage() const | ||||
{ | ||||
return static_cast<Page>(ui->stackedWidget->currentIndex()); | ||||
} | ||||
r1140 | ||||
r1176 | void CatalogueInspectorWidget::setEvent(const std::shared_ptr<DBEvent> &event) | |||
r1140 | { | |||
r1180 | impl->m_DisplayedEvent = event; | |||
blockSignals(true); | ||||
r1140 | showPage(Page::EventProperties); | |||
r1176 | ui->leEventName->setText(event->getName()); | |||
ui->leEventMission->setText(event->getMission()); | ||||
ui->leEventProduct->setText(event->getProduct()); | ||||
r1162 | ||||
QString tagList; | ||||
r1176 | auto tags = event->getTags(); | |||
r1162 | for (auto tag : tags) { | |||
tagList += tag.getName(); | ||||
tagList += ' '; | ||||
} | ||||
ui->leEventTags->setText(tagList); | ||||
r1176 | ui->dateTimeEventTStart->setDateTime(DateUtils::dateTime(event->getTStart())); | |||
ui->dateTimeEventTEnd->setDateTime(DateUtils::dateTime(event->getTEnd())); | ||||
r1180 | ||||
blockSignals(false); | ||||
r1140 | } | |||
r1176 | void CatalogueInspectorWidget::setCatalogue(const std::shared_ptr<DBCatalogue> &catalogue) | |||
r1140 | { | |||
r1180 | impl->m_DisplayedCatalogue = catalogue; | |||
blockSignals(true); | ||||
r1140 | showPage(Page::CatalogueProperties); | |||
r1176 | ui->leCatalogueName->setText(catalogue->getName()); | |||
ui->leCatalogueAuthor->setText(catalogue->getAuthor()); | ||||
r1180 | ||||
blockSignals(false); | ||||
r1140 | } | |||