##// END OF EJS Templates
Remove unused pending request of worker since it's already in the VC....
Remove unused pending request of worker since it's already in the VC. Fix bug with progress asynchrone computation

File last commit:

r1369:b20dcec1c57b
r1387:3f0567bfecb5 HEAD
Show More
CatalogueInspectorWidget.cpp
236 lines | 8.6 KiB | text/x-c | CppLexer
/ gui / src / Catalogue / CatalogueInspectorWidget.cpp
Sub widget classes
r1130 #include "Catalogue/CatalogueInspectorWidget.h"
#include "ui_CatalogueInspectorWidget.h"
Display catalogues and events with CatalogueAPI
r1162 #include <Common/DateUtils.h>
#include <DBCatalogue.h>
#include <DBEvent.h>
Edition of event products via the inspector
r1183 #include <DBEventProduct.h>
Display catalogues and events with CatalogueAPI
r1162 #include <DBTag.h>
Edition of catalogues from the inspector
r1180 struct CatalogueInspectorWidget::CatalogueInspectorWidgetPrivate {
std::shared_ptr<DBCatalogue> m_DisplayedCatalogue = nullptr;
std::shared_ptr<DBEvent> m_DisplayedEvent = nullptr;
Edition of event products via the inspector
r1183 std::shared_ptr<DBEventProduct> m_DisplayedEventProduct = nullptr;
Edition of events from the inspector
r1181
void connectCatalogueUpdateSignals(CatalogueInspectorWidget *inspector,
Ui::CatalogueInspectorWidget *ui);
void connectEventUpdateSignals(CatalogueInspectorWidget *inspector,
Ui::CatalogueInspectorWidget *ui);
Edition of catalogues from the inspector
r1180 };
Sub widget classes
r1130 CatalogueInspectorWidget::CatalogueInspectorWidget(QWidget *parent)
Edition of catalogues from the inspector
r1180 : QWidget(parent),
ui(new Ui::CatalogueInspectorWidget),
impl{spimpl::make_unique_impl<CatalogueInspectorWidgetPrivate>()}
Sub widget classes
r1130 {
ui->setupUi(this);
Inspector
r1134 showPage(Page::Empty);
Edition of catalogues from the inspector
r1180
Edition of events from the inspector
r1181 impl->connectCatalogueUpdateSignals(this, ui);
impl->connectEventUpdateSignals(this, ui);
Fix bug time precision with catalogue
r1369
ui->dateTimeEventTStart->setDisplayFormat(DATETIME_FORMAT);
ui->dateTimeEventTEnd->setDisplayFormat(DATETIME_FORMAT);
Edition of events from the inspector
r1181 }
CatalogueInspectorWidget::~CatalogueInspectorWidget()
{
delete ui;
}
void CatalogueInspectorWidget::CatalogueInspectorWidgetPrivate::connectCatalogueUpdateSignals(
CatalogueInspectorWidget *inspector, Ui::CatalogueInspectorWidget *ui)
{
connect(ui->leCatalogueName, &QLineEdit::editingFinished, [ui, inspector, this]() {
if (ui->leCatalogueName->text() != m_DisplayedCatalogue->getName()) {
m_DisplayedCatalogue->setName(ui->leCatalogueName->text());
emit inspector->catalogueUpdated(m_DisplayedCatalogue);
Edition of catalogues from the inspector
r1180 }
});
Edition of events from the inspector
r1181 connect(ui->leCatalogueAuthor, &QLineEdit::editingFinished, [ui, inspector, this]() {
if (ui->leCatalogueAuthor->text() != m_DisplayedCatalogue->getAuthor()) {
m_DisplayedCatalogue->setAuthor(ui->leCatalogueAuthor->text());
emit inspector->catalogueUpdated(m_DisplayedCatalogue);
Edition of catalogues from the inspector
r1180 }
});
Sub widget classes
r1130 }
Edition of events from the inspector
r1181 void CatalogueInspectorWidget::CatalogueInspectorWidgetPrivate::connectEventUpdateSignals(
CatalogueInspectorWidget *inspector, Ui::CatalogueInspectorWidget *ui)
Sub widget classes
r1130 {
Edition of events from the inspector
r1181 connect(ui->leEventName, &QLineEdit::editingFinished, [ui, inspector, this]() {
if (ui->leEventName->text() != m_DisplayedEvent->getName()) {
m_DisplayedEvent->setName(ui->leEventName->text());
emit inspector->eventUpdated(m_DisplayedEvent);
}
});
Edition of tags
r1186 connect(ui->leEventTags, &QLineEdit::editingFinished, [ui, inspector, this]() {
Discard an added event remove it now.
r1314 auto tags = ui->leEventTags->text().split(QRegExp("\\s+"), QString::SkipEmptyParts);
Edition of tags
r1186 std::list<QString> tagNames;
for (auto tag : tags) {
tagNames.push_back(tag);
}
if (m_DisplayedEvent->getTagsNames() != tagNames) {
m_DisplayedEvent->setTagsNames(tagNames);
emit inspector->eventUpdated(m_DisplayedEvent);
}
});
Edition of events from the inspector
r1181 connect(ui->leEventProduct, &QLineEdit::editingFinished, [ui, inspector, this]() {
Edition of event products via the inspector
r1183 if (ui->leEventProduct->text() != m_DisplayedEventProduct->getProductId()) {
Add init of DisplayedEvent. Add save on EventProduct modif
r1281 auto oldProductId = m_DisplayedEventProduct->getProductId();
Edition of event products via the inspector
r1183 m_DisplayedEventProduct->setProductId(ui->leEventProduct->text());
Add init of DisplayedEvent. Add save on EventProduct modif
r1281
auto eventProducts = m_DisplayedEvent->getEventProducts();
for (auto &eventProduct : eventProducts) {
if (eventProduct.getProductId() == oldProductId) {
eventProduct.setProductId(m_DisplayedEventProduct->getProductId());
}
}
m_DisplayedEvent->setEventProducts(eventProducts);
emit inspector->eventUpdated(m_DisplayedEvent);
Edition of event products via the inspector
r1183 }
Edition of events from the inspector
r1181 });
connect(ui->dateTimeEventTStart, &QDateTimeEdit::editingFinished, [ui, inspector, this]() {
Edition of event products via the inspector
r1183 auto time = DateUtils::secondsSinceEpoch(ui->dateTimeEventTStart->dateTime());
if (time != m_DisplayedEventProduct->getTStart()) {
m_DisplayedEventProduct->setTStart(time);
Add init of DisplayedEvent. Add save on EventProduct modif
r1281
auto eventProducts = m_DisplayedEvent->getEventProducts();
for (auto &eventProduct : eventProducts) {
if (eventProduct.getProductId() == m_DisplayedEventProduct->getProductId()) {
eventProduct.setTStart(m_DisplayedEventProduct->getTStart());
}
}
m_DisplayedEvent->setEventProducts(eventProducts);
emit inspector->eventUpdated(m_DisplayedEvent);
Edition of event products via the inspector
r1183 }
Edition of events from the inspector
r1181 });
connect(ui->dateTimeEventTEnd, &QDateTimeEdit::editingFinished, [ui, inspector, this]() {
Edition of event products via the inspector
r1183 auto time = DateUtils::secondsSinceEpoch(ui->dateTimeEventTEnd->dateTime());
if (time != m_DisplayedEventProduct->getTEnd()) {
m_DisplayedEventProduct->setTEnd(time);
Add init of DisplayedEvent. Add save on EventProduct modif
r1281
auto eventProducts = m_DisplayedEvent->getEventProducts();
for (auto &eventProduct : eventProducts) {
if (eventProduct.getProductId() == m_DisplayedEventProduct->getProductId()) {
eventProduct.setTEnd(m_DisplayedEventProduct->getTEnd());
}
}
m_DisplayedEvent->setEventProducts(eventProducts);
emit inspector->eventUpdated(m_DisplayedEvent);
Edition of event products via the inspector
r1183 }
Edition of events from the inspector
r1181 });
Sub widget classes
r1130 }
Inspector
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());
}
Skeleton to fill the inspector with the selection
r1140
Adaptation to the shared pointers of catalogue controller
r1176 void CatalogueInspectorWidget::setEvent(const std::shared_ptr<DBEvent> &event)
Skeleton to fill the inspector with the selection
r1140 {
Edition of catalogues from the inspector
r1180 impl->m_DisplayedEvent = event;
blockSignals(true);
Skeleton to fill the inspector with the selection
r1140 showPage(Page::EventProperties);
Edition of event products via the inspector
r1183 ui->leEventName->setEnabled(true);
Adaptation to the shared pointers of catalogue controller
r1176 ui->leEventName->setText(event->getName());
Edition of event products via the inspector
r1183 ui->leEventProduct->setEnabled(false);
Product field now display products event list instead of only its size
r1364
auto eventProducts = event->getEventProducts();
QStringList eventProductList;
for (auto evtProduct : eventProducts) {
eventProductList << evtProduct.getProductId();
}
ui->leEventProduct->setText(eventProductList.join(";"));
Display catalogues and events with CatalogueAPI
r1162
QString tagList;
Edition of tags
r1186 auto tags = event->getTagsNames();
Display catalogues and events with CatalogueAPI
r1162 for (auto tag : tags) {
Edition of tags
r1186 tagList += tag;
Display catalogues and events with CatalogueAPI
r1162 tagList += ' ';
}
Edition of event products via the inspector
r1183 ui->leEventTags->setEnabled(true);
Display catalogues and events with CatalogueAPI
r1162 ui->leEventTags->setText(tagList);
Edition of event products via the inspector
r1183 ui->dateTimeEventTStart->setEnabled(false);
ui->dateTimeEventTEnd->setEnabled(false);
Displays TStart & TEnd for events
r1185 ui->dateTimeEventTStart->setDateTime(DateUtils::dateTime(event->getTStart()));
ui->dateTimeEventTEnd->setDateTime(DateUtils::dateTime(event->getTEnd()));
Edition of catalogues from the inspector
r1180
blockSignals(false);
Skeleton to fill the inspector with the selection
r1140 }
Edition of event products via the inspector
r1183 void CatalogueInspectorWidget::setEventProduct(const std::shared_ptr<DBEvent> &event,
const std::shared_ptr<DBEventProduct> &eventProduct)
{
Add init of DisplayedEvent. Add save on EventProduct modif
r1281
impl->m_DisplayedEvent = event;
Edition of event products via the inspector
r1183 impl->m_DisplayedEventProduct = eventProduct;
blockSignals(true);
showPage(Page::EventProperties);
ui->leEventName->setEnabled(false);
ui->leEventName->setText(event->getName());
small gui improvements
r1293 ui->leEventProduct->setEnabled(false);
Edition of event products via the inspector
r1183 ui->leEventProduct->setText(eventProduct->getProductId());
ui->leEventTags->setEnabled(false);
ui->leEventTags->clear();
ui->dateTimeEventTStart->setEnabled(true);
ui->dateTimeEventTEnd->setEnabled(true);
ui->dateTimeEventTStart->setDateTime(DateUtils::dateTime(eventProduct->getTStart()));
ui->dateTimeEventTEnd->setDateTime(DateUtils::dateTime(eventProduct->getTEnd()));
blockSignals(false);
}
Adaptation to the shared pointers of catalogue controller
r1176 void CatalogueInspectorWidget::setCatalogue(const std::shared_ptr<DBCatalogue> &catalogue)
Skeleton to fill the inspector with the selection
r1140 {
Edition of catalogues from the inspector
r1180 impl->m_DisplayedCatalogue = catalogue;
blockSignals(true);
Skeleton to fill the inspector with the selection
r1140 showPage(Page::CatalogueProperties);
Adaptation to the shared pointers of catalogue controller
r1176 ui->leCatalogueName->setText(catalogue->getName());
ui->leCatalogueAuthor->setText(catalogue->getAuthor());
Edition of catalogues from the inspector
r1180
blockSignals(false);
Skeleton to fill the inspector with the selection
r1140 }
Link between selection zone item and event
r1347
void CatalogueInspectorWidget::refresh()
{
switch (static_cast<Page>(ui->stackedWidget->currentIndex())) {
case Page::CatalogueProperties:
setCatalogue(impl->m_DisplayedCatalogue);
break;
case Page::EventProperties: {
auto isEventShowed = ui->leEventName->isEnabled();
setEvent(impl->m_DisplayedEvent);
if (!isEventShowed && impl->m_DisplayedEvent) {
setEventProduct(impl->m_DisplayedEvent, impl->m_DisplayedEventProduct);
}
}
}
}