From 45ab63a4480cda2e131d0d7879ed7c45f9682df9 2019-02-24 16:43:26 From: Alexis Jeandet Date: 2019-02-24 16:43:26 Subject: [PATCH] Some progress on new Catalogue GUI, can display most of items, still lack edition and link to SciQLop Signed-off-by: Alexis Jeandet --- diff --git a/core b/core index 548ec6a..6b6bb3a 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 548ec6a0c922e626003babc8b21a3953b777eae2 +Subproject commit 6b6bb3a15bf899d16716aa0f6d20f1122d67a0a5 diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index 1c3bef7..a7c4092 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -12,6 +12,8 @@ include/Catalogue2/eventstreeview.h include/Catalogue2/repositoriestreeview.h include/Catalogue2/repositoriesmodel.h + include/Catalogue2/browser.h + include/Catalogue2/eventeditor.h # include/Catalogue/CatalogueActionManager.h # include/Catalogue/CatalogueTreeModel.h # include/Catalogue/CatalogueExplorer.h @@ -82,6 +84,8 @@ src/Catalogue2/eventstreeview.cpp src/Catalogue2/repositoriestreeview.cpp src/Catalogue2/repositoriesmodel.cpp + src/Catalogue2/browser.cpp + src/Catalogue2/eventeditor.cpp #src/Catalogue/CatalogueEventsWidget.cpp #src/Catalogue/CatalogueSideBarWidget.cpp #src/Catalogue/CatalogueTreeItems/CatalogueAbstractTreeItem.cpp @@ -154,6 +158,8 @@ QT5_WRAP_UI( ui/Visualization/VisualizationWidget.ui ui/Visualization/VisualizationZoneWidget.ui ui/Visualization/VisualizationMultiZoneSelectionDialog.ui + ui/Catalogue2/browser.ui + ui/Catalogue2/eventeditor.ui #ui/Catalogue/CatalogueEventsWidget.ui #ui/Catalogue/CatalogueExplorer.ui #ui/Catalogue/CatalogueInspectorWidget.ui diff --git a/gui/include/Catalogue2/browser.h b/gui/include/Catalogue2/browser.h new file mode 100644 index 0000000..a154d35 --- /dev/null +++ b/gui/include/Catalogue2/browser.h @@ -0,0 +1,27 @@ +#ifndef BROWSER_H +#define BROWSER_H + +#include +#include + +namespace Ui { +class Browser; +} + +class Browser : public QWidget +{ + Q_OBJECT + +public: + explicit Browser(QWidget *parent = nullptr); + ~Browser(); +private slots: + void repositorySelected(const QString& repo); + void catalogueSelected(const CatalogueController::Catalogue_ptr& catalogue); + void eventSelected(const CatalogueController::Event_ptr& event); + void productSelected(const CatalogueController::Product_t& product, const CatalogueController::Event_ptr& event); +private: + Ui::Browser *ui; +}; + +#endif // BROWSER_H diff --git a/gui/include/Catalogue2/eventeditor.h b/gui/include/Catalogue2/eventeditor.h new file mode 100644 index 0000000..e192202 --- /dev/null +++ b/gui/include/Catalogue2/eventeditor.h @@ -0,0 +1,37 @@ +#ifndef EVENTEDITOR_H +#define EVENTEDITOR_H + +#include +#include + +namespace Ui { +class EventEditor; +} + +class EventEditor : public QWidget +{ + Q_OBJECT + enum class mode{ + editable = true, + readonly = false + }; + +public: + explicit EventEditor(QWidget *parent = nullptr); + ~EventEditor(); + +public slots: + void setEvent(const CatalogueController::Event_ptr& event); + void setProduct(const CatalogueController::Product_t& product, const CatalogueController::Event_ptr& event); + +private: + void _setEventName(const CatalogueController::Event_ptr& event, mode is_editable=mode::editable); + void _setTags(const CatalogueController::Event_ptr& event,mode is_editable=mode::editable); + void _setProducts(const CatalogueController::Event_ptr& event,mode is_editable=mode::editable); + void _setProducts(const CatalogueController::Product_t& product,mode is_editable=mode::editable); + void _setDates(double startDate, double stopDate, mode is_editable=mode::editable); + void _setDates(std::optional startDate, std::optional stopDate, mode is_editable=mode::editable); + Ui::EventEditor *ui; +}; + +#endif // EVENTEDITOR_H diff --git a/gui/include/Catalogue2/eventsmodel.h b/gui/include/Catalogue2/eventsmodel.h index c94cd35..27c51b9 100644 --- a/gui/include/Catalogue2/eventsmodel.h +++ b/gui/include/Catalogue2/eventsmodel.h @@ -18,19 +18,12 @@ #define EVENTSMODEL_H #include #include +#include #include class EventsModel : public QAbstractItemModel { Q_OBJECT - std::vector _events; - - enum class ItemType - { - None, - Event, - Product - }; enum class Columns { @@ -48,8 +41,131 @@ class EventsModel : public QAbstractItemModel public: + enum class ItemType + { + None, + Event, + Product + }; + + struct EventsModelItem + { + ItemType type; + std::variant item; + EventsModelItem() : type { ItemType::None } {} + EventsModelItem(const CatalogueController::Event_ptr& event) + : type { ItemType::Event }, item { event }, parent { nullptr }, icon {} + { + std::transform(std::cbegin(event->products), std::cend(event->products), + std::back_inserter(children), + [this](auto& product) { return std::make_unique(product, this); }); + } + + EventsModelItem(const CatalogueController::Product_t& product, EventsModelItem* parent) + : type { ItemType::Product }, item { product }, parent { parent }, icon {} + { + } + CatalogueController::Event_ptr event() const + { + return std::get(item); + } + CatalogueController::Product_t product() const + { + return std::get(item); + } + QVariant data(int col, int role) const + { + if(role==Qt::DisplayRole) + { + switch (type) + { + case ItemType::Product : + return data(product(),col); + case ItemType::Event: + return data(event(),col); + default: + break; + } + } + return QVariant{}; + } + QVariant data(const CatalogueController::Event_ptr& event, int col) const + { + switch (static_cast(col)) + { + case EventsModel::Columns::Name: + return QString::fromStdString(event->name); + case EventsModel::Columns::TStart: + if (auto start = event->startTime()) + return DateUtils::dateTime(*start).toString(DATETIME_FORMAT_ONE_LINE); + else + return QVariant {}; + case EventsModel::Columns::TEnd: + if (auto stop = event->stopTime()) + return DateUtils::dateTime(*stop).toString(DATETIME_FORMAT_ONE_LINE); + else + return QVariant {}; + case EventsModel::Columns::Product: + { + QStringList eventProductList; + for (const auto& evtProduct : event->products) + { + eventProductList << QString::fromStdString(evtProduct.name); + } + return eventProductList.join(";"); + } + case EventsModel::Columns::Tags: + { + QString tagList; + for (const auto& tag : event->tags) + { + tagList += QString::fromStdString(tag); + tagList += ' '; + } + return tagList; + } + default: + break; + } + return QVariant {}; + } + + QVariant data(const CatalogueController::Product_t& product, int col) const + { + switch (static_cast(col)) + { + case EventsModel::Columns::Name: + return QString::fromStdString(product.name); + case EventsModel::Columns::TStart: + return DateUtils::dateTime(product.startTime).toString(DATETIME_FORMAT_ONE_LINE); + case EventsModel::Columns::TEnd: + return DateUtils::dateTime(product.stopTime).toString(DATETIME_FORMAT_ONE_LINE); + case EventsModel::Columns::Product: + return QString::fromStdString(product.name); + default: + break; + } + return QVariant {}; + } + + QString text() const + { + if (type == ItemType::Event) + return QString::fromStdString(event()->name); + if (type == ItemType::Product) + return QString::fromStdString(product().name); + return QString(); + } + std::vector> children; + EventsModelItem* parent = nullptr; + QIcon icon; + }; EventsModel(QObject* parent = nullptr); + static inline EventsModelItem* to_item(const QModelIndex& index) + { + return static_cast(index.internalPointer()); + } ItemType type(const QModelIndex& index) const; @@ -57,8 +173,6 @@ public: { return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled; } - QVariant data(int col, const CatalogueController::Event_ptr& event) const; - QVariant data(int col, const CatalogueController::Product_t& product) const; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; QModelIndex index( @@ -79,9 +193,14 @@ public slots: void setEvents(std::vector events) { beginResetModel(); - std::swap(_events, events); + _items.clear(); + std::transform(std::begin(events), std::end(events), std::back_inserter(_items), + [](const auto& event) { return std::make_unique(event); }); endResetModel(); } + +private: + std::vector> _items; }; #endif // EVENTSMODEL_H diff --git a/gui/include/Catalogue2/eventstreeview.h b/gui/include/Catalogue2/eventstreeview.h index a8bf1f1..d670f80 100644 --- a/gui/include/Catalogue2/eventstreeview.h +++ b/gui/include/Catalogue2/eventstreeview.h @@ -27,8 +27,15 @@ class EventsTreeView : public QTreeView public: EventsTreeView(QWidget* parent = nullptr); +signals: + void eventSelected(const CatalogueController::Event_ptr& event); + void productSelected(const CatalogueController::Product_t& product, const CatalogueController::Event_ptr& event); + public slots: void setEvents(std::vector events); + +private: + void _itemSelected(const QModelIndex& index); }; #endif // EVENTSTREEVIEW_H diff --git a/gui/include/Catalogue2/repositoriesmodel.h b/gui/include/Catalogue2/repositoriesmodel.h index 73744fe..06b66cc 100644 --- a/gui/include/Catalogue2/repositoriesmodel.h +++ b/gui/include/Catalogue2/repositoriesmodel.h @@ -26,6 +26,8 @@ class RepositoriesModel : public QAbstractItemModel Q_OBJECT + +public: enum class ItemType { None, @@ -67,12 +69,11 @@ class RepositoriesModel : public QAbstractItemModel std::vector> _items; - inline RepoModelItem* to_item(const QModelIndex& index) const + static inline RepoModelItem* to_item(const QModelIndex& index) { return static_cast(index.internalPointer()); } -public: RepositoriesModel(QObject* parent = nullptr); ItemType type(const QModelIndex& index) const; diff --git a/gui/include/Catalogue2/repositoriestreeview.h b/gui/include/Catalogue2/repositoriestreeview.h index b71a4b1..67a1401 100644 --- a/gui/include/Catalogue2/repositoriestreeview.h +++ b/gui/include/Catalogue2/repositoriestreeview.h @@ -17,9 +17,9 @@ #ifndef REPOSITORIESTREEVIEW_H #define REPOSITORIESTREEVIEW_H +#include #include #include -#include class RepositoriesTreeView : public QTreeView { @@ -28,14 +28,25 @@ public: RepositoriesTreeView(QWidget* parent = nullptr); public slots: - void refresh() - { - static_cast(model())->refresh(); - } + void refresh() { static_cast(model())->refresh(); } signals: void repositorySelected(const QString& repository); + void catalogueSelected(const CatalogueController::Catalogue_ptr& catalogue); +private: + void _itemSelected(const QModelIndex& index) + { + auto item = RepositoriesModel::to_item(index); + if (item->type == RepositoriesModel::ItemType::Repository) + { + emit repositorySelected(item->repository()); + } + else if (item->type == RepositoriesModel::ItemType::Catalogue) + { + emit catalogueSelected(item->catalogue()); + } + } }; #endif // REPOSITORIESTREEVIEW_H diff --git a/gui/src/Catalogue2/browser.cpp b/gui/src/Catalogue2/browser.cpp new file mode 100644 index 0000000..ebc568b --- /dev/null +++ b/gui/src/Catalogue2/browser.cpp @@ -0,0 +1,50 @@ +#include "Catalogue2/browser.h" +#include "ui_browser.h" +#include + +Browser::Browser(QWidget* parent) : QWidget(parent), ui(new Ui::Browser) +{ + ui->setupUi(this); + connect(ui->repositories, &RepositoriesTreeView::repositorySelected, this, + &Browser::repositorySelected); + connect(ui->repositories, &RepositoriesTreeView::catalogueSelected, this, + &Browser::catalogueSelected); + connect(ui->events, &EventsTreeView::eventSelected, this, &Browser::eventSelected); + connect(ui->events, &EventsTreeView::productSelected, this, &Browser::productSelected); +} + +Browser::~Browser() +{ + delete ui; +} + +void Browser::repositorySelected(const QString& repo) +{ + this->ui->Infos->setCurrentIndex(0); + this->ui->events->setEvents(sqpApp->catalogueController().events(repo)); + // TODO add a statistic API + this->ui->catalogues_count->setText( + QString::number(sqpApp->catalogueController().catalogues(repo).size())); + this->ui->rep_events_count->setText( + QString::number(sqpApp->catalogueController().events(repo).size())); +} + +void Browser::catalogueSelected(const CatalogueController::Catalogue_ptr& catalogue) +{ + this->ui->Infos->setCurrentIndex(1); + this->ui->events->setEvents(sqpApp->catalogueController().events(catalogue)); + this->ui->cat_events_count->setText( + QString::number(sqpApp->catalogueController().events(catalogue).size())); +} + +void Browser::eventSelected(const CatalogueController::Event_ptr& event) +{ + this->ui->Infos->setCurrentIndex(2); + this->ui->Event->setEvent(event); +} + +void Browser::productSelected(const CatalogueController::Product_t& product, const CatalogueController::Event_ptr& event) +{ + this->ui->Infos->setCurrentIndex(2); + this->ui->Event->setProduct(product,event); +} diff --git a/gui/src/Catalogue2/eventeditor.cpp b/gui/src/Catalogue2/eventeditor.cpp new file mode 100644 index 0000000..24dae56 --- /dev/null +++ b/gui/src/Catalogue2/eventeditor.cpp @@ -0,0 +1,74 @@ +#include "Catalogue2/eventeditor.h" +#include "ui_eventeditor.h" +#include +#include + +EventEditor::EventEditor(QWidget* parent) : QWidget(parent), ui(new Ui::EventEditor) +{ + ui->setupUi(this); +} + +EventEditor::~EventEditor() +{ + delete ui; +} + +void EventEditor::setEvent(const CatalogueController::Event_ptr& event) +{ + _setEventName(event, mode::editable); + _setTags(event, mode::readonly); + _setProducts(event, mode::readonly); + _setDates(event->startTime(), event->stopTime(), mode::readonly); +} + +void EventEditor::setProduct( + const CatalogueController::Product_t& product, const CatalogueController::Event_ptr& event) +{ + _setEventName(event, mode::readonly); + _setTags(event, mode::readonly); + _setDates(product.startTime, product.stopTime, mode::editable); + _setProducts(product, mode::readonly); +} + +void EventEditor::_setEventName(const CatalogueController::Event_ptr& event, mode is_editable) +{ + this->ui->EventName->setText(QString::fromStdString(event->name)); + this->ui->EventName->setEnabled(bool(is_editable)); +} + +void EventEditor::_setTags(const CatalogueController::Event_ptr& event, mode is_editable) +{ + this->ui->Tags->setText(StringUtils::join(event->tags, ", ")); + this->ui->Tags->setEnabled(bool(is_editable)); +} + +void EventEditor::_setProducts(const CatalogueController::Event_ptr& event, mode is_editable) +{ + QStringList products; + this->ui->Products->setText(StringUtils::join(event->products, ", ", + [](const auto& product) { return QString::fromStdString(product.name); })); + this->ui->Products->setEnabled(bool(is_editable)); +} + +void EventEditor::_setProducts(const CatalogueController::Product_t& product, mode is_editable) +{ + this->ui->Products->setText(QString::fromStdString(product.name)); + this->ui->Products->setEnabled(bool(is_editable)); +} + +void EventEditor::_setDates(double startDate, double stopDate, mode is_editable) +{ + this->ui->StartTime->setDateTime(DateUtils::dateTime(startDate)); + this->ui->StopTime->setDateTime(DateUtils::dateTime(stopDate)); + this->ui->StartTime->setEnabled(bool(is_editable)); + this->ui->StopTime->setEnabled(bool(is_editable)); +} + +void EventEditor::_setDates( + std::optional startDate, std::optional stopDate, mode is_editable) +{ + if (startDate && stopDate) + _setDates(*startDate, *stopDate, is_editable); + else + _setDates(0., 0., is_editable); +} diff --git a/gui/src/Catalogue2/eventsmodel.cpp b/gui/src/Catalogue2/eventsmodel.cpp index 12a5c86..5f1d571 100644 --- a/gui/src/Catalogue2/eventsmodel.cpp +++ b/gui/src/Catalogue2/eventsmodel.cpp @@ -16,100 +16,24 @@ */ #include "Catalogue2/eventsmodel.h" #include +#include EventsModel::EventsModel(QObject* parent) : QAbstractItemModel(parent) {} EventsModel::ItemType EventsModel::type(const QModelIndex& index) const { - if (!index.isValid()) + if (EventsModelItem* item = to_item(index)) { - return ItemType::None; - } - else if (index.internalPointer() == nullptr) - { - return ItemType::Event; - } - else - { - return ItemType::Product; + return item->type; } -} - -QVariant EventsModel::data(int col, const CatalogueController::Event_ptr& event) const -{ - switch (static_cast(col)) - { - case EventsModel::Columns::Name: - return QString::fromStdString(event->name); - case EventsModel::Columns::TStart: - if (auto start = event->startTime()) - return DateUtils::dateTime(*start).toString(DATETIME_FORMAT_ONE_LINE); - else - return QVariant {}; - case EventsModel::Columns::TEnd: - if (auto stop = event->stopTime()) - return DateUtils::dateTime(*stop).toString(DATETIME_FORMAT_ONE_LINE); - else - return QVariant {}; - case EventsModel::Columns::Product: - { - QStringList eventProductList; - for (const auto& evtProduct : event->products) - { - eventProductList << QString::fromStdString(evtProduct.name); - } - return eventProductList.join(";"); - } - case EventsModel::Columns::Tags: - { - QString tagList; - for (const auto& tag : event->tags) - { - tagList += QString::fromStdString(tag); - tagList += ' '; - } - return tagList; - } - default: - break; - } - return QVariant {}; -} - -QVariant EventsModel::data(int col, const CatalogueController::Product_t& product) const -{ - switch (static_cast(col)) - { - case EventsModel::Columns::Name: - return QString::fromStdString(product.name); - case EventsModel::Columns::TStart: - return DateUtils::dateTime(product.startTime).toString(DATETIME_FORMAT_ONE_LINE); - case EventsModel::Columns::TEnd: - return DateUtils::dateTime(product.stopTime).toString(DATETIME_FORMAT_ONE_LINE); - case EventsModel::Columns::Product: - return QString::fromStdString(product.name); - default: - break; - } - return QVariant {}; + return ItemType::None; } QVariant EventsModel::data(const QModelIndex& index, int role) const { - if (_events.size() && index.isValid() && role == Qt::DisplayRole) + if (index.isValid()) { - switch (type(index)) - { - case EventsModel::ItemType::Event: - return data(index.column(), _events[index.row()]); - case EventsModel::ItemType::Product: - { - auto event = static_cast(index.internalPointer()); - return data(index.column(), event->products[index.row()]); - } - default: - break; - } + return to_item(index)->data(index.column(),role); } return QVariant {}; } @@ -123,16 +47,12 @@ QModelIndex EventsModel::index(int row, int column, const QModelIndex& parent) c switch (type(parent)) { - case EventsModel::ItemType::None: - return createIndex(row, column, nullptr); - case EventsModel::ItemType::Event: - { - return createIndex(row, column, _events[parent.row()].get()); - } - case EventsModel::ItemType::Product: - break; - default: - break; + case ItemType::None: // is an event + return createIndex(row, column, _items[row].get()); + case ItemType::Event: // is a product + return createIndex(row, column, to_item(parent)->children[row].get()); + case ItemType::Product: + QModelIndex(); } return QModelIndex(); @@ -140,23 +60,11 @@ QModelIndex EventsModel::index(int row, int column, const QModelIndex& parent) c QModelIndex EventsModel::parent(const QModelIndex& index) const { - switch (type(index)) + auto item = to_item(index); + if (item->type == ItemType::Product) { - case EventsModel::ItemType::None: - break; - case EventsModel::ItemType::Event: - break; - case EventsModel::ItemType::Product: - { - auto parentEvent = static_cast(index.internalPointer()); - auto pos = std::distance(std::cbegin(_events), - std::find_if(std::cbegin(_events), std::cend(_events), - [parentEvent](auto event) { return event.get() == parentEvent; })); - if (pos >= 0 && pos < _events.size()) - { - return createIndex(pos, 0); - } - } + auto repoIndex = SciQLop::containers::index_of(_items, item->parent); + return createIndex(repoIndex, 0, item->parent); } return QModelIndex(); } @@ -167,17 +75,13 @@ int EventsModel::rowCount(const QModelIndex& parent) const { return 0; } - switch (type(parent)) { - case EventsModel::ItemType::None: - return _events.size(); - case EventsModel::ItemType::Event: - return _events[parent.row()]->products.size(); - break; - case EventsModel::ItemType::Product: - break; - default: + case ItemType::None: + return _items.size(); + case ItemType::Event: + return to_item(parent)->children.size(); + case ItemType::Product: break; } return 0; diff --git a/gui/src/Catalogue2/eventstreeview.cpp b/gui/src/Catalogue2/eventstreeview.cpp index 32e22ad..e11956e 100644 --- a/gui/src/Catalogue2/eventstreeview.cpp +++ b/gui/src/Catalogue2/eventstreeview.cpp @@ -20,9 +20,26 @@ EventsTreeView::EventsTreeView(QWidget* parent) : QTreeView(parent) { this->setModel(new EventsModel()); + connect(this->selectionModel(), &QItemSelectionModel::currentChanged, [this](const QModelIndex ¤t, const QModelIndex &previous){ + Q_UNUSED(previous); + this->_itemSelected(current); + }); } void EventsTreeView::setEvents(std::vector events) { static_cast(this->model())->setEvents(events); } + +void EventsTreeView::_itemSelected(const QModelIndex &index) +{ + auto item = EventsModel::to_item(index); + if (item->type == EventsModel::ItemType::Event) + { + emit eventSelected(item->event()); + } + else if (item->type == EventsModel::ItemType::Product) + { + emit productSelected(item->product(), item->parent->event()); + } +} diff --git a/gui/src/Catalogue2/repositoriesmodel.cpp b/gui/src/Catalogue2/repositoriesmodel.cpp index 52a1ab3..ef6bed5 100644 --- a/gui/src/Catalogue2/repositoriesmodel.cpp +++ b/gui/src/Catalogue2/repositoriesmodel.cpp @@ -22,6 +22,10 @@ RepositoriesModel::RepositoriesModel(QObject* parent) : QAbstractItemModel(parent) { refresh(); + connect(&(sqpApp->catalogueController()), &CatalogueController::repositoryAdded, this, + [this](const QString&) { this->refresh(); }); + connect(&(sqpApp->catalogueController()), &CatalogueController::catalogueAdded, this, + [this](const CatalogueController::Catalogue_ptr&, const QString&) { this->refresh(); }); } RepositoriesModel::ItemType RepositoriesModel::type(const QModelIndex& index) const diff --git a/gui/src/Catalogue2/repositoriestreeview.cpp b/gui/src/Catalogue2/repositoriestreeview.cpp index 2df079e..2df2a0a 100644 --- a/gui/src/Catalogue2/repositoriestreeview.cpp +++ b/gui/src/Catalogue2/repositoriestreeview.cpp @@ -22,6 +22,10 @@ RepositoriesTreeView::RepositoriesTreeView(QWidget* parent) : QTreeView(parent) auto m = model(); this->setModel(new RepositoriesModel(this)); delete m; + connect(this->selectionModel(), &QItemSelectionModel::currentChanged, [this](const QModelIndex ¤t, const QModelIndex &previous){ + Q_UNUSED(previous); + this->_itemSelected(current); + }); } diff --git a/gui/tests/CMakeLists.txt b/gui/tests/CMakeLists.txt index 2a159a4..ad2acb6 100644 --- a/gui/tests/CMakeLists.txt +++ b/gui/tests/CMakeLists.txt @@ -5,3 +5,4 @@ declare_test(multiple_sync_graph multiple_sync_graph multiple_sync_graph/main.cp declare_manual_test(event_list event_list catalogue/event_list/main.cpp "sciqlopgui;TestUtils;GUITestUtils;Qt5::Test") declare_manual_test(repository_list repository_list catalogue/repository_list/main.cpp "sciqlopgui;TestUtils;GUITestUtils;Qt5::Test") +declare_manual_test(catalogue_browser catalogue_browser catalogue/browser/main.cpp "sciqlopgui;TestUtils;GUITestUtils;Qt5::Test") diff --git a/gui/tests/catalogue/browser/main.cpp b/gui/tests/catalogue/browser/main.cpp new file mode 100644 index 0000000..b7f991c --- /dev/null +++ b/gui/tests/catalogue/browser/main.cpp @@ -0,0 +1,70 @@ +#include +#include +#include +#include +#include +#include + + +#include +#include + +#include +#include + +#include +#include + + +class A_CatalogueBrowser : public QObject +{ + Q_OBJECT +public: + explicit A_CatalogueBrowser(QObject* parent = Q_NULLPTR) : QObject(parent) {} + +private slots: +}; + +// QT_BEGIN_NAMESPACE +// QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS +// QT_END_NAMESPACE +// int main(int argc, char* argv[]) +//{ +// SqpApplication app { argc, argv }; +// app.setAttribute(Qt::AA_Use96Dpi, true); +// QTEST_DISABLE_KEYPAD_NAVIGATION; +// QTEST_ADD_GPU_BLACKLIST_SUPPORT; +// An_EventList tc; +// QTEST_SET_MAIN_SOURCE_PATH; +// return QTest::qExec(&tc, argc, argv); +//} + +#include "main.moc" + + +int main(int argc, char* argv[]) +{ + Q_INIT_RESOURCE(sqpguiresources); + QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + + SqpApplication a { argc, argv }; + Browser w; + sqpApp->catalogueController().add("test"); + sqpApp->catalogueController().add("stuff"); + sqpApp->catalogueController().add("default"); + sqpApp->catalogueController().add("new catalogue", "default"); + auto catalogue = sqpApp->catalogueController().add("new catalogue2", "default"); + for (auto _ : std::array()) + { + static int i = 0; + auto event = CatalogueController::make_event_ptr(); + event->name = std::string("Event ") + std::to_string(i++); + event->tags = {"tag1", "tag2"}; + event->products = { CatalogueController::Event_t::Product_t { "Product1", 10., 11. }, + CatalogueController::Event_t::Product_t { "Product2", 11., 12. }, + CatalogueController::Event_t::Product_t { "Product3", 10.2, 11. } }; + catalogue->add(event); + } + w.show(); + return a.exec(); +} diff --git a/gui/ui/Catalogue2/browser.ui b/gui/ui/Catalogue2/browser.ui new file mode 100644 index 0000000..bd3c476 --- /dev/null +++ b/gui/ui/Catalogue2/browser.ui @@ -0,0 +1,218 @@ + + + Browser + + + + 0 + 0 + 708 + 461 + + + + Catalogues Browser + + + + + + Qt::Horizontal + + + + + 1 + 0 + + + + true + + + true + + + true + + + false + + + + + + 3 + 0 + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + 2 + + + + + 0 + 0 + + + + + + + + 0 + 0 + + + + Repository information + + + + + + + + Catalogues + + + + + + + + + + + + + + Events + + + + + + + + + + + + + + + + + + + + + 0 + 0 + + + + + + + + 0 + 0 + + + + Catalogue + + + + + + + + Name + + + + + + + + + + Events + + + + + + + + + + + + + + + + + + + + + 0 + 0 + + + + + + + + + + + + + + + RepositoriesTreeView + QTreeView +
Catalogue2/repositoriestreeview.h
+
+ + EventsTreeView + QTreeView +
Catalogue2/eventstreeview.h
+
+ + EventEditor + QWidget +
Catalogue2/eventeditor.h
+ 1 +
+
+ + +
diff --git a/gui/ui/Catalogue2/eventeditor.ui b/gui/ui/Catalogue2/eventeditor.ui new file mode 100644 index 0000000..bc065e7 --- /dev/null +++ b/gui/ui/Catalogue2/eventeditor.ui @@ -0,0 +1,96 @@ + + + EventEditor + + + + 0 + 0 + 465 + 227 + + + + + 0 + 0 + + + + Form + + + + + + + 0 + 0 + + + + Event + + + + + + + + Name + + + + + + + Tags + + + + + + + Product(s) + + + + + + + Start time + + + + + + + Stop time + + + + + + + + + + + + + + + + + + + + + + + + + + + +