##// END OF EJS Templates
Converted catalogue gui tests to manual tests...
jeandet -
r1407:fb115035b41a
parent child
Show More
@@ -0,0 +1,41
1 /*
2 This file is part of SciQLop.
3
4 SciQLop is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 SciQLop is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with SciQLop. If not, see <https://www.gnu.org/licenses/>.
16 */
17 #ifndef REPOSITORIESTREEVIEW_H
18 #define REPOSITORIESTREEVIEW_H
19
20 #include <QObject>
21 #include <QTreeView>
22 #include <Catalogue2/repositoriesmodel.h>
23
24 class RepositoriesTreeView : public QTreeView
25 {
26 Q_OBJECT
27 public:
28 RepositoriesTreeView(QWidget* parent = nullptr);
29
30 public slots:
31 void refresh()
32 {
33 static_cast<RepositoriesModel*>(model())->refresh();
34 }
35
36 signals:
37 void repositorySelected(const QString& repository);
38
39 };
40
41 #endif // REPOSITORIESTREEVIEW_H
@@ -0,0 +1,27
1 /*
2 This file is part of SciQLop.
3
4 SciQLop is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 SciQLop is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with SciQLop. If not, see <https://www.gnu.org/licenses/>.
16 */
17 #include <Catalogue2/repositoriesmodel.h>
18 #include <Catalogue2/repositoriestreeview.h>
19
20 RepositoriesTreeView::RepositoriesTreeView(QWidget* parent) : QTreeView(parent)
21 {
22 auto m = model();
23 this->setModel(new RepositoriesModel(this));
24 delete m;
25 }
26
27
@@ -1,5 +1,11
1 1 macro(declare_test testname testexe sources libraries)
2 2 add_executable(${testexe} ${sources})
3 3 target_link_libraries(${testexe} ${libraries})
4 4 add_test(NAME ${testname} COMMAND ${testexe})
5 5 endmacro(declare_test)
6
7
8 macro(declare_manual_test testname testexe sources libraries)
9 add_executable(${testexe} ${sources})
10 target_link_libraries(${testexe} ${libraries})
11 endmacro(declare_manual_test)
@@ -1,186 +1,188
1 1 ο»ΏFILE (GLOB_RECURSE gui_SRCS
2 2
3 3 include/DataSource/DataSourceWidget.h
4 4 include/DataSource/DataSourceTreeWidget.h
5 5 include/DataSource/DataSourceTreeWidgetItem.h
6 6 include/DataSource/DataSourceTreeWidgetHelper.h
7 7 include/SqpApplication.h
8 8 include/Common/ColorUtils.h
9 9 include/Common/VisualizationDef.h
10 10 include/SidePane/SqpSidePane.h
11 11 include/Catalogue2/eventsmodel.h
12 12 include/Catalogue2/eventstreeview.h
13 include/Catalogue2/repositoriestreeview.h
13 14 include/Catalogue2/repositoriesmodel.h
14 15 # include/Catalogue/CatalogueActionManager.h
15 16 # include/Catalogue/CatalogueTreeModel.h
16 17 # include/Catalogue/CatalogueExplorer.h
17 18 # include/Catalogue/CatalogueSideBarWidget.h
18 19 # include/Catalogue/CatalogueInspectorWidget.h
19 20 # include/Catalogue/CatalogueTreeItems/CatalogueTextTreeItem.h
20 21 # include/Catalogue/CatalogueTreeItems/CatalogueTreeItem.h
21 22 # include/Catalogue/CatalogueTreeItems/CatalogueAbstractTreeItem.h
22 23 # include/Catalogue/CatalogueEventsModel.h
23 24 # include/Catalogue/CatalogueEventsWidget.h
24 25 # include/Catalogue/CatalogueExplorerHelper.h
25 26 include/Visualization/VisualizationGraphHelper.h
26 27 include/Visualization/VisualizationTabWidget.h
27 28 include/Visualization/VisualizationDefs.h
28 29 include/Visualization/QCustomPlotSynchronizer.h
29 30 include/Visualization/QCPColorMapIterator.h
30 31 include/Visualization/operations/GenerateVariableMenuOperation.h
31 32 include/Visualization/operations/RemoveVariableOperation.h
32 33 include/Visualization/operations/FindVariableOperation.h
33 34 include/Visualization/operations/MenuBuilder.h
34 35 include/Visualization/operations/RescaleAxeOperation.h
35 36 include/Visualization/PlottablesRenderingUtils.h
36 37 include/Visualization/IVisualizationWidgetVisitor.h
37 38 include/Visualization/VisualizationGraphWidget.h
38 39 include/Visualization/IVisualizationWidget.h
39 40 include/Visualization/IVariableContainer.h
40 41 include/Visualization/SqpColorScale.h
41 42 include/Visualization/VisualizationWidget.h
42 43 include/Visualization/VisualizationZoneWidget.h
43 44 include/Visualization/VisualizationMultiZoneSelectionDialog.h
44 45 include/Visualization/VisualizationGraphRenderingDelegate.h
45 46 include/Visualization/AxisRenderingUtils.h
46 47 include/Visualization/VisualizationSelectionZoneItem.h
47 48 include/Visualization/VisualizationDragWidget.h
48 49 include/Visualization/VisualizationActionManager.h
49 50 include/Visualization/IGraphSynchronizer.h
50 51 include/Visualization/ColorScaleEditor.h
51 52 include/Visualization/MacScrollBarStyle.h
52 53 include/Visualization/VisualizationSelectionZoneManager.h
53 54 include/Visualization/qcustomplot.h
54 55 include/Visualization/VisualizationDragDropContainer.h
55 56 include/Visualization/VisualizationCursorItem.h
56 57 include/Settings/SqpSettingsDialog.h
57 58 include/Settings/SqpSettingsGeneralWidget.h
58 59 include/Variable/VariableMenuHeaderWidget.h
59 60 include/Variable/VariableInspectorTableView.h
60 61 include/Variable/VariableInspectorWidget.h
61 62 include/Variable/RenameVariableDialog.h
62 63 include/TimeWidget/TimeWidget.h
63 64 include/DragAndDrop/DragDropScroller.h
64 65 include/DragAndDrop/DragDropTabSwitcher.h
65 66 include/DragAndDrop/DragDropGuiController.h
66 67 include/Actions/FilteringAction.h
67 68 include/Actions/ActionsGuiController.h
68 69 include/Actions/SelectionZoneAction.h
69 70
70 71
71 72
72 73
73 74 src/DataSource/DataSourceTreeWidgetItem.cpp
74 75 src/DataSource/DataSourceWidget.cpp
75 76 src/DataSource/DataSourceTreeWidget.cpp
76 77 src/DataSource/DataSourceTreeWidgetHelper.cpp
77 78 src/Common/ColorUtils.cpp
78 79 src/Common/VisualizationDef.cpp
79 80 src/SidePane/SqpSidePane.cpp
80 81 src/Catalogue2/eventsmodel.cpp
81 82 src/Catalogue2/eventstreeview.cpp
83 src/Catalogue2/repositoriestreeview.cpp
82 84 src/Catalogue2/repositoriesmodel.cpp
83 85 #src/Catalogue/CatalogueEventsWidget.cpp
84 86 #src/Catalogue/CatalogueSideBarWidget.cpp
85 87 #src/Catalogue/CatalogueTreeItems/CatalogueAbstractTreeItem.cpp
86 88 #src/Catalogue/CatalogueTreeItems/CatalogueTextTreeItem.cpp
87 89 #src/Catalogue/CatalogueTreeItems/CatalogueTreeItem.cpp
88 90 #src/Catalogue/CatalogueExplorerHelper.cpp
89 91 #src/Catalogue/CatalogueExplorer.cpp
90 92 #src/Catalogue/CatalogueTreeModel.cpp
91 93 #src/Catalogue/CatalogueInspectorWidget.cpp
92 94 #src/Catalogue/CatalogueEventsModel.cpp
93 95 #src/Catalogue/CatalogueActionManager.cpp
94 96 src/Visualization/VisualizationDragDropContainer.cpp
95 97 src/Visualization/VisualizationTabWidget.cpp
96 98 src/Visualization/VisualizationWidget.cpp
97 99 src/Visualization/MacScrollBarStyle.cpp
98 100 src/Visualization/VisualizationCursorItem.cpp
99 101 src/Visualization/operations/MenuBuilder.cpp
100 102 src/Visualization/operations/RemoveVariableOperation.cpp
101 103 src/Visualization/operations/FindVariableOperation.cpp
102 104 src/Visualization/operations/GenerateVariableMenuOperation.cpp
103 105 src/Visualization/operations/RescaleAxeOperation.cpp
104 106 src/Visualization/AxisRenderingUtils.cpp
105 107 src/Visualization/PlottablesRenderingUtils.cpp
106 108 src/Visualization/VisualizationGraphRenderingDelegate.cpp
107 109 src/Visualization/VisualizationSelectionZoneManager.cpp
108 110 src/Visualization/QCPColorMapIterator.cpp
109 111 src/Visualization/ColorScaleEditor.cpp
110 112 src/Visualization/VisualizationGraphHelper.cpp
111 113 src/Visualization/VisualizationGraphWidget.cpp
112 114 src/Visualization/VisualizationDragWidget.cpp
113 115 src/Visualization/VisualizationZoneWidget.cpp
114 116 src/Visualization/VisualizationActionManager.cpp
115 117 src/Visualization/VisualizationSelectionZoneItem.cpp
116 118 src/Visualization/QCustomPlotSynchronizer.cpp
117 119 src/Visualization/qcustomplot.cpp
118 120 src/Visualization/VisualizationMultiZoneSelectionDialog.cpp
119 121 src/Visualization/SqpColorScale.cpp
120 122 src/Settings/SqpSettingsGeneralWidget.cpp
121 123 src/Settings/SqpSettingsDialog.cpp
122 124 src/SqpApplication.cpp
123 125 src/Variable/VariableInspectorWidget.cpp
124 126 src/Variable/VariableMenuHeaderWidget.cpp
125 127 src/Variable/RenameVariableDialog.cpp
126 128 src/Variable/VariableInspectorTableView.cpp
127 129 src/TimeWidget/TimeWidget.cpp
128 130 src/DragAndDrop/DragDropScroller.cpp
129 131 src/DragAndDrop/DragDropTabSwitcher.cpp
130 132 src/DragAndDrop/DragDropGuiController.cpp
131 133 src/Actions/ActionsGuiController.cpp
132 134 src/Actions/SelectionZoneAction.cpp
133 135 src/Actions/FilteringAction.cpp
134 136
135 137 ./resources/sqpguiresources.qrc
136 138 )
137 139
138 140
139 141 QT5_WRAP_UI(
140 142 UiGenerated_SRCS
141 143 ui/DataSource/DataSourceWidget.ui
142 144 ui/Settings/SqpSettingsDialog.ui
143 145 ui/Settings/SqpSettingsGeneralWidget.ui
144 146 ui/SidePane/SqpSidePane.ui
145 147 ui/TimeWidget/TimeWidget.ui
146 148 ui/Variable/RenameVariableDialog.ui
147 149 ui/Variable/VariableInspectorWidget.ui
148 150 ui/Variable/VariableMenuHeaderWidget.ui
149 151 ui/Visualization/ColorScaleEditor.ui
150 152 ui/Visualization/VisualizationGraphWidget.ui
151 153 ui/Visualization/VisualizationTabWidget.ui
152 154 ui/Visualization/VisualizationWidget.ui
153 155 ui/Visualization/VisualizationZoneWidget.ui
154 156 ui/Visualization/VisualizationMultiZoneSelectionDialog.ui
155 157 #ui/Catalogue/CatalogueEventsWidget.ui
156 158 #ui/Catalogue/CatalogueExplorer.ui
157 159 #ui/Catalogue/CatalogueInspectorWidget.ui
158 160 #ui/Catalogue/CatalogueSideBarWidget.ui
159 161 )
160 162
161 163 add_library(sciqlopgui ${gui_SRCS} ${UiGenerated_SRCS})
162 164 SET_TARGET_PROPERTIES(sciqlopgui PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
163 165
164 166 target_include_directories(sciqlopgui PUBLIC
165 167 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
166 168 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/Visualization>
167 169 $<INSTALL_INTERFACE:include/SciQLOP>
168 170 )
169 171
170 172 target_link_libraries(sciqlopgui PUBLIC
171 173 Qt5::Widgets
172 174 Qt5::PrintSupport
173 175 Qt5::Svg
174 176 sciqlopcore
175 177 )
176 178
177 179 install(TARGETS sciqlopgui EXPORT SciQLOPGuiConfig
178 180 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
179 181 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
180 182 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
181 183
182 184 install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/SciQLOP)
183 185 install(EXPORT SciQLOPGuiConfig DESTINATION share/SciQLOPGui/cmake)
184 186 export(TARGETS sciqlopgui FILE SciQLOPGuiConfig.cmake)
185 187
186 188 subdirs(tests)
@@ -1,71 +1,87
1 /*
2 This file is part of SciQLop.
3
4 SciQLop is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 SciQLop is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with SciQLop. If not, see <https://www.gnu.org/licenses/>.
16 */
1 17 #ifndef EVENTSMODEL_H
2 18 #define EVENTSMODEL_H
3 19 #include <Catalogue/CatalogueController.h>
4 20 #include <QAbstractItemModel>
5 21 #include <array>
6 22
7 23 class EventsModel : public QAbstractItemModel
8 24 {
9 25 Q_OBJECT
10 26 std::vector<CatalogueController::Event_ptr> _events;
11 27
12 28 enum class ItemType
13 29 {
14 30 None,
15 31 Event,
16 32 Product
17 33 };
18 34
19 35 enum class Columns
20 36 {
21 37 Name = 0,
22 38 TStart = 1,
23 39 TEnd = 2,
24 40 Tags = 3,
25 41 Product = 4,
26 42 Validation = 5,
27 43 NbColumn = 6
28 44 };
29 45
30 46 const std::array<QString, static_cast<int>(Columns::NbColumn)> ColumnsNames
31 47 = { "Name", "Start time", "Stop time", "Tags", "Product(s)", "" };
32 48
33 49
34 50 public:
35 51 EventsModel(QObject* parent = nullptr);
36 52
37 53
38 54 ItemType type(const QModelIndex& index) const;
39 55
40 56 Qt::ItemFlags flags(const QModelIndex& index) const override
41 57 {
42 58 return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled;
43 59 }
44 60 QVariant data(int col, const CatalogueController::Event_ptr& event) const;
45 61 QVariant data(int col, const CatalogueController::Product_t& product) const;
46 62 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
47 63
48 64 QModelIndex index(
49 65 int row, int column, const QModelIndex& parent = QModelIndex()) const override;
50 66
51 67 QModelIndex parent(const QModelIndex& index) const override;
52 68
53 69 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
54 70
55 71 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
56 72
57 73 QVariant headerData(
58 74 int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
59 75
60 76 void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
61 77
62 78 public slots:
63 79 void setEvents(std::vector<CatalogueController::Event_ptr> events)
64 80 {
65 81 beginResetModel();
66 82 std::swap(_events, events);
67 83 endResetModel();
68 84 }
69 85 };
70 86
71 87 #endif // EVENTSMODEL_H
@@ -1,18 +1,34
1 /*
2 This file is part of SciQLop.
3
4 SciQLop is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 SciQLop is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with SciQLop. If not, see <https://www.gnu.org/licenses/>.
16 */
1 17 #ifndef EVENTSTREEVIEW_H
2 18 #define EVENTSTREEVIEW_H
3 19
4 20 #include <Catalogue/CatalogueController.h>
5 21 #include <QObject>
6 22 #include <QTreeView>
7 23
8 24 class EventsTreeView : public QTreeView
9 25 {
10 26 Q_OBJECT
11 27 public:
12 28 EventsTreeView(QWidget* parent = nullptr);
13 29
14 30 public slots:
15 31 void setEvents(std::vector<CatalogueController::Event_ptr> events);
16 32 };
17 33
18 34 #endif // EVENTSTREEVIEW_H
@@ -1,83 +1,99
1 /*
2 This file is part of SciQLop.
3
4 SciQLop is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 SciQLop is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with SciQLop. If not, see <https://www.gnu.org/licenses/>.
16 */
1 17 #ifndef REPOSITORIESMODEL_H
2 18 #define REPOSITORIESMODEL_H
3 19 #include <Catalogue/CatalogueController.h>
4 20 #include <QAbstractItemModel>
5 21 #include <QIcon>
6 22 #include <QObject>
7 23
8 24 class RepositoriesModel : public QAbstractItemModel
9 25 {
10 26 Q_OBJECT
11 27
12 28
13 29 enum class ItemType
14 30 {
15 31 None,
16 32 Catalogue,
17 33 Repository
18 34 };
19 35
20 36 struct RepoModelItem
21 37 {
22 38 ItemType type;
23 39 std::variant<QString, CatalogueController::Catalogue_ptr> item;
24 40 RepoModelItem() : type { ItemType::None } {}
25 41 RepoModelItem(const QString& repo);
26 42 RepoModelItem(const CatalogueController::Catalogue_ptr& catalogue, RepoModelItem* parent)
27 43 : type { ItemType::Catalogue }
28 44 , item { catalogue }
29 45 , parent { parent }
30 46 , icon { ":/icones/catalogue.png" }
31 47 {
32 48 }
33 49 QString repository() const { return std::get<QString>(item); }
34 50 CatalogueController::Catalogue_ptr catalogue() const
35 51 {
36 52 return std::get<CatalogueController::Catalogue_ptr>(item);
37 53 }
38 54 QVariant data(int role) const;
39 55 QString text() const
40 56 {
41 57 if (type == ItemType::Catalogue)
42 58 return QString::fromStdString(catalogue()->name);
43 59 if (type == ItemType::Repository)
44 60 return repository();
45 61 return QString();
46 62 }
47 63 std::vector<std::unique_ptr<RepoModelItem>> children;
48 64 RepoModelItem* parent = nullptr;
49 65 QIcon icon;
50 66 };
51 67
52 68 std::vector<std::unique_ptr<RepoModelItem>> _items;
53 69
54 70 inline RepoModelItem* to_item(const QModelIndex& index) const
55 71 {
56 72 return static_cast<RepoModelItem*>(index.internalPointer());
57 73 }
58 74
59 75 public:
60 76 RepositoriesModel(QObject* parent = nullptr);
61 77
62 78 ItemType type(const QModelIndex& index) const;
63 79
64 80 Qt::ItemFlags flags(const QModelIndex& index) const override
65 81 {
66 82 return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled;
67 83 }
68 84
69 85 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
70 86
71 87 QModelIndex index(
72 88 int row, int column, const QModelIndex& parent = QModelIndex()) const override;
73 89
74 90 QModelIndex parent(const QModelIndex& index) const override;
75 91
76 92 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
77 93
78 94 int columnCount(const QModelIndex& parent = QModelIndex()) const override { return 1; }
79 95 public slots:
80 96 void refresh();
81 97 };
82 98
83 99 #endif // REPOSITORIESMODEL_H
@@ -1,185 +1,201
1 /*
2 This file is part of SciQLop.
3
4 SciQLop is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 SciQLop is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with SciQLop. If not, see <https://www.gnu.org/licenses/>.
16 */
1 17 #include "Catalogue2/eventsmodel.h"
2 18 #include <SqpApplication.h>
3 19
4 20 EventsModel::EventsModel(QObject* parent) : QAbstractItemModel(parent) {}
5 21
6 22 EventsModel::ItemType EventsModel::type(const QModelIndex& index) const
7 23 {
8 24 if (!index.isValid())
9 25 {
10 26 return ItemType::None;
11 27 }
12 28 else if (index.internalPointer() == nullptr)
13 29 {
14 30 return ItemType::Event;
15 31 }
16 32 else
17 33 {
18 34 return ItemType::Product;
19 35 }
20 36 }
21 37
22 38 QVariant EventsModel::data(int col, const CatalogueController::Event_ptr& event) const
23 39 {
24 40 switch (static_cast<Columns>(col))
25 41 {
26 42 case EventsModel::Columns::Name:
27 43 return QString::fromStdString(event->name);
28 44 case EventsModel::Columns::TStart:
29 45 if (auto start = event->startTime())
30 46 return DateUtils::dateTime(*start).toString(DATETIME_FORMAT_ONE_LINE);
31 47 else
32 48 return QVariant {};
33 49 case EventsModel::Columns::TEnd:
34 50 if (auto stop = event->stopTime())
35 51 return DateUtils::dateTime(*stop).toString(DATETIME_FORMAT_ONE_LINE);
36 52 else
37 53 return QVariant {};
38 54 case EventsModel::Columns::Product:
39 55 {
40 56 QStringList eventProductList;
41 57 for (const auto& evtProduct : event->products)
42 58 {
43 59 eventProductList << QString::fromStdString(evtProduct.name);
44 60 }
45 61 return eventProductList.join(";");
46 62 }
47 63 case EventsModel::Columns::Tags:
48 64 {
49 65 QString tagList;
50 66 for (const auto& tag : event->tags)
51 67 {
52 68 tagList += QString::fromStdString(tag);
53 69 tagList += ' ';
54 70 }
55 71 return tagList;
56 72 }
57 73 default:
58 74 break;
59 75 }
60 76 return QVariant {};
61 77 }
62 78
63 79 QVariant EventsModel::data(int col, const CatalogueController::Product_t& product) const
64 80 {
65 81 switch (static_cast<Columns>(col))
66 82 {
67 83 case EventsModel::Columns::Name:
68 84 return QString::fromStdString(product.name);
69 85 case EventsModel::Columns::TStart:
70 86 return DateUtils::dateTime(product.startTime).toString(DATETIME_FORMAT_ONE_LINE);
71 87 case EventsModel::Columns::TEnd:
72 88 return DateUtils::dateTime(product.stopTime).toString(DATETIME_FORMAT_ONE_LINE);
73 89 case EventsModel::Columns::Product:
74 90 return QString::fromStdString(product.name);
75 91 default:
76 92 break;
77 93 }
78 94 return QVariant {};
79 95 }
80 96
81 97 QVariant EventsModel::data(const QModelIndex& index, int role) const
82 98 {
83 99 if (_events.size() && index.isValid() && role == Qt::DisplayRole)
84 100 {
85 101 switch (type(index))
86 102 {
87 103 case EventsModel::ItemType::Event:
88 104 return data(index.column(), _events[index.row()]);
89 105 case EventsModel::ItemType::Product:
90 106 {
91 107 auto event = static_cast<CatalogueController::Event_t*>(index.internalPointer());
92 108 return data(index.column(), event->products[index.row()]);
93 109 }
94 110 default:
95 111 break;
96 112 }
97 113 }
98 114 return QVariant {};
99 115 }
100 116
101 117 QModelIndex EventsModel::index(int row, int column, const QModelIndex& parent) const
102 118 {
103 119 if (!hasIndex(row, column, parent))
104 120 {
105 121 return QModelIndex();
106 122 }
107 123
108 124 switch (type(parent))
109 125 {
110 126 case EventsModel::ItemType::None:
111 127 return createIndex(row, column, nullptr);
112 128 case EventsModel::ItemType::Event:
113 129 {
114 130 return createIndex(row, column, _events[parent.row()].get());
115 131 }
116 132 case EventsModel::ItemType::Product:
117 133 break;
118 134 default:
119 135 break;
120 136 }
121 137
122 138 return QModelIndex();
123 139 }
124 140
125 141 QModelIndex EventsModel::parent(const QModelIndex& index) const
126 142 {
127 143 switch (type(index))
128 144 {
129 145 case EventsModel::ItemType::None:
130 146 break;
131 147 case EventsModel::ItemType::Event:
132 148 break;
133 149 case EventsModel::ItemType::Product:
134 150 {
135 151 auto parentEvent = static_cast<CatalogueController::Event_t*>(index.internalPointer());
136 152 auto pos = std::distance(std::cbegin(_events),
137 153 std::find_if(std::cbegin(_events), std::cend(_events),
138 154 [parentEvent](auto event) { return event.get() == parentEvent; }));
139 155 if (pos >= 0 && pos < _events.size())
140 156 {
141 157 return createIndex(pos, 0);
142 158 }
143 159 }
144 160 }
145 161 return QModelIndex();
146 162 }
147 163
148 164 int EventsModel::rowCount(const QModelIndex& parent) const
149 165 {
150 166 if (parent.column() > 0)
151 167 {
152 168 return 0;
153 169 }
154 170
155 171 switch (type(parent))
156 172 {
157 173 case EventsModel::ItemType::None:
158 174 return _events.size();
159 175 case EventsModel::ItemType::Event:
160 176 return _events[parent.row()]->products.size();
161 177 break;
162 178 case EventsModel::ItemType::Product:
163 179 break;
164 180 default:
165 181 break;
166 182 }
167 183 return 0;
168 184 }
169 185
170 186 int EventsModel::columnCount(const QModelIndex& parent) const
171 187 {
172 188 return static_cast<int>(EventsModel::Columns::NbColumn);
173 189 }
174 190
175 191 QVariant EventsModel::headerData(int section, Qt::Orientation orientation, int role) const
176 192 {
177 193 if (orientation == Qt::Horizontal && role == Qt::DisplayRole && section < ColumnsNames.size())
178 194 {
179 195 return ColumnsNames[section];
180 196 }
181 197
182 198 return QVariant();
183 199 }
184 200
185 201 void EventsModel::sort(int column, Qt::SortOrder order) {}
@@ -1,12 +1,28
1 /*
2 This file is part of SciQLop.
3
4 SciQLop is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 SciQLop is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with SciQLop. If not, see <https://www.gnu.org/licenses/>.
16 */
1 17 #include <Catalogue2/eventsmodel.h>
2 18 #include <Catalogue2/eventstreeview.h>
3 19
4 20 EventsTreeView::EventsTreeView(QWidget* parent) : QTreeView(parent)
5 21 {
6 22 this->setModel(new EventsModel());
7 23 }
8 24
9 25 void EventsTreeView::setEvents(std::vector<CatalogueController::Event_ptr> events)
10 26 {
11 27 static_cast<EventsModel*>(this->model())->setEvents(events);
12 28 }
@@ -1,107 +1,123
1 /*
2 This file is part of SciQLop.
3
4 SciQLop is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 SciQLop is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with SciQLop. If not, see <https://www.gnu.org/licenses/>.
16 */
1 17 #include <Catalogue2/repositoriesmodel.h>
2 18 #include <Common/containers.h>
3 19 #include <SqpApplication.h>
4 20
5 21
6 22 RepositoriesModel::RepositoriesModel(QObject* parent) : QAbstractItemModel(parent)
7 23 {
8 24 refresh();
9 25 }
10 26
11 27 RepositoriesModel::ItemType RepositoriesModel::type(const QModelIndex& index) const
12 28 {
13 29 if (RepoModelItem* item = to_item(index))
14 30 {
15 31 return item->type;
16 32 }
17 33 return ItemType::None;
18 34 }
19 35
20 36 void RepositoriesModel::refresh()
21 37 {
22 38 beginResetModel();
23 39 _items.clear();
24 40 _items.push_back(std::make_unique<RepoModelItem>("All"));
25 41 _items.push_back(std::make_unique<RepoModelItem>("Trash"));
26 42 auto repo_list = sqpApp->catalogueController().repositories();
27 43 std::transform(std::begin(repo_list), std::end(repo_list), std::back_inserter(_items),
28 44 [](const auto& repo_name) { return std::make_unique<RepoModelItem>(repo_name); });
29 45 endResetModel();
30 46 }
31 47
32 48 QVariant RepositoriesModel::data(const QModelIndex& index, int role) const
33 49 {
34 50 if (index.isValid() && index.column() == 0)
35 51 {
36 52 return to_item(index)->data(role);
37 53 }
38 54 return QVariant {};
39 55 }
40 56
41 57 QModelIndex RepositoriesModel::index(int row, int column, const QModelIndex& parent) const
42 58 {
43 59 if (!hasIndex(row, column, parent))
44 60 {
45 61 return QModelIndex();
46 62 }
47 63
48 64 switch (type(parent))
49 65 {
50 66 case RepositoriesModel::ItemType::None: // is a repo
51 67 return createIndex(row, column, _items[row].get());
52 68 case RepositoriesModel::ItemType::Repository: // is a catalogue
53 69 return createIndex(row, column, to_item(parent)->children[row].get());
54 70 case RepositoriesModel::ItemType::Catalogue:
55 71 return createIndex(row, column, new RepoModelItem());
56 72 }
57 73
58 74 return QModelIndex();
59 75 }
60 76
61 77 QModelIndex RepositoriesModel::parent(const QModelIndex& index) const
62 78 {
63 79 auto item = to_item(index);
64 80 if (item->type == ItemType::Catalogue)
65 81 {
66 82 auto repoIndex = SciQLop::containers::index_of(_items, item->parent);
67 83 return createIndex(repoIndex, 0, item->parent);
68 84 }
69 85 return QModelIndex();
70 86 }
71 87
72 88 int RepositoriesModel::rowCount(const QModelIndex& parent) const
73 89 {
74 90 switch (type(parent))
75 91 {
76 92 case RepositoriesModel::ItemType::None:
77 93 return _items.size();
78 94 case RepositoriesModel::ItemType::Repository:
79 95 return to_item(parent)->children.size();
80 96 case RepositoriesModel::ItemType::Catalogue:
81 97 break;
82 98 }
83 99 return 0;
84 100 }
85 101
86 102 RepositoriesModel::RepoModelItem::RepoModelItem(const QString& repo)
87 103 : type { ItemType::Repository }, item { repo }, icon { ":/icones/database.png" }
88 104 {
89 105 auto catalogues = sqpApp->catalogueController().catalogues(repo);
90 106 std::transform(std::begin(catalogues), std::end(catalogues), std::back_inserter(children),
91 107 [this](auto& catalogue) { return std::make_unique<RepoModelItem>(catalogue, this); });
92 108 }
93 109
94 110 QVariant RepositoriesModel::RepoModelItem::data(int role) const
95 111 {
96 112 switch (role)
97 113 {
98 114 case Qt::EditRole:
99 115 case Qt::DisplayRole:
100 116 return text();
101 117 case Qt::DecorationRole:
102 118 return QVariant { icon };
103 119 default:
104 120 break;
105 121 }
106 122 return QVariant {};
107 123 }
@@ -1,6 +1,7
1 include(sciqlop_tests)
1 2 subdirs(GUITestUtils)
2 3 declare_test(simple_graph simple_graph simple_graph/main.cpp "sciqlopgui;TestUtils;GUITestUtils;Qt5::Test")
3 4 declare_test(multiple_sync_graph multiple_sync_graph multiple_sync_graph/main.cpp "sciqlopgui;TestUtils;GUITestUtils;Qt5::Test")
4 5
5 declare_test(event_list event_list catalogue/event_list/main.cpp "sciqlopgui;TestUtils;GUITestUtils;Qt5::Test")
6 declare_test(repository_list repository_list catalogue/repository_list/main.cpp "sciqlopgui;TestUtils;GUITestUtils;Qt5::Test")
6 declare_manual_test(event_list event_list catalogue/event_list/main.cpp "sciqlopgui;TestUtils;GUITestUtils;Qt5::Test")
7 declare_manual_test(repository_list repository_list catalogue/repository_list/main.cpp "sciqlopgui;TestUtils;GUITestUtils;Qt5::Test")
@@ -1,65 +1,61
1 1 #include <QMainWindow>
2 2 #include <QObject>
3 3 #include <QScreen>
4 4 #include <QString>
5 5 #include <QWheelEvent>
6 6 #include <QtTest>
7 7
8 8 #include <QTreeView>
9 9
10 10
11 11 #include <Common/cpp_utils.h>
12 12 #include <SqpApplication.h>
13 13
14 14 #include <GUITestUtils.h>
15 15 #include <TestProviders.h>
16 16
17 //#include <Catalogue/CatalogueEventsWidget.h>
18
19 #include <Catalogue2/eventstreeview.h>
20 #include <Catalogue2/repositoriesmodel.h>
17 #include <Catalogue2/repositoriestreeview.h>
21 18
22 19
23 20 class An_EventList : public QObject
24 21 {
25 22 Q_OBJECT
26 23 public:
27 24 explicit An_EventList(QObject* parent = Q_NULLPTR) : QObject(parent) {}
28 25
29 26 private slots:
30 27 };
31 28
32 29 // QT_BEGIN_NAMESPACE
33 30 // QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS
34 31 // QT_END_NAMESPACE
35 32 // int main(int argc, char* argv[])
36 33 //{
37 34 // SqpApplication app { argc, argv };
38 35 // app.setAttribute(Qt::AA_Use96Dpi, true);
39 36 // QTEST_DISABLE_KEYPAD_NAVIGATION;
40 37 // QTEST_ADD_GPU_BLACKLIST_SUPPORT;
41 38 // An_EventList tc;
42 39 // QTEST_SET_MAIN_SOURCE_PATH;
43 40 // return QTest::qExec(&tc, argc, argv);
44 41 //}
45 42
46 43 #include "main.moc"
47 44
48 45
49 46 int main(int argc, char* argv[])
50 47 {
51 48 Q_INIT_RESOURCE(sqpguiresources);
52 49 QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
53 50
54 51 SqpApplication a { argc, argv };
55 QTreeView w;
52 RepositoriesTreeView w;
56 53 sqpApp->catalogueController().add("test");
57 54 sqpApp->catalogueController().add("stuff");
58 55 sqpApp->catalogueController().add("default");
59 56 sqpApp->catalogueController().add("new catalogue", "default");
60 57 sqpApp->catalogueController().add("new catalogue2", "default");
61 RepositoriesModel* model = new RepositoriesModel();
62 w.setModel(model);
63 58 w.show();
59 w.refresh();
64 60 return a.exec();
65 61 }
General Comments 0
You need to be logged in to leave comments. Login now