From 05dadb964647bbf2953a45890f7a7bbb2b15a683 2017-12-18 13:30:37 From: Thibaud Rabillard Date: 2017-12-18 13:30:37 Subject: [PATCH] Fix display of tstart & tend when an event has no event products --- diff --git a/gui/src/Catalogue/CatalogueEventsModel.cpp b/gui/src/Catalogue/CatalogueEventsModel.cpp index ad78d41..d82e3a5 100644 --- a/gui/src/Catalogue/CatalogueEventsModel.cpp +++ b/gui/src/Catalogue/CatalogueEventsModel.cpp @@ -34,18 +34,13 @@ struct CatalogueEventsModel::CatalogueEventsModelPrivate { case Column::Name: return event->getName(); case Column::TStart: - return DateUtils::dateTime(event->getTStart()); + return nbEventProducts(event) > 0 ? DateUtils::dateTime(event->getTStart()) + : QVariant{}; case Column::TEnd: - return DateUtils::dateTime(event->getTEnd()); - case Column::Product: { - auto eventProductsIt = m_EventProducts.find(event.get()); - if (eventProductsIt != m_EventProducts.cend()) { - return QString::number(m_EventProducts.at(event.get()).count()) + " product(s)"; - } - else { - return "0 product"; - } - } + return nbEventProducts(event) > 0 ? DateUtils::dateTime(event->getTEnd()) + : QVariant{}; + case Column::Product: + return QString::number(nbEventProducts(event)) + " product(s)"; case Column::Tags: { QString tagList; auto tags = event->getTags(); @@ -71,6 +66,17 @@ struct CatalogueEventsModel::CatalogueEventsModelPrivate { } } + int nbEventProducts(const std::shared_ptr &event) const + { + auto eventProductsIt = m_EventProducts.find(event.get()); + if (eventProductsIt != m_EventProducts.cend()) { + return m_EventProducts.at(event.get()).count(); + } + else { + return 0; + } + } + QVariant eventProductData(int col, const std::shared_ptr &eventProduct) const { switch (static_cast(col)) {