@@ -0,0 +1,33 | |||
|
1 | #ifndef SCIQLOP_CATALOGUEEVENTSTABLEMODEL_H | |
|
2 | #define SCIQLOP_CATALOGUEEVENTSTABLEMODEL_H | |
|
3 | ||
|
4 | #include <Common/spimpl.h> | |
|
5 | #include <QAbstractTableModel> | |
|
6 | ||
|
7 | #include <DBEvent.h> | |
|
8 | ||
|
9 | class CatalogueEventsTableModel : public QAbstractTableModel { | |
|
10 | public: | |
|
11 | CatalogueEventsTableModel(QObject *parent = nullptr); | |
|
12 | ||
|
13 | void setEvents(const QVector<DBEvent> &events); | |
|
14 | DBEvent getEvent(int row) const; | |
|
15 | ||
|
16 | ||
|
17 | // Model | |
|
18 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; | |
|
19 | int columnCount(const QModelIndex &parent = QModelIndex()) const override; | |
|
20 | Qt::ItemFlags flags(const QModelIndex &index) const override; | |
|
21 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; | |
|
22 | QVariant headerData(int section, Qt::Orientation orientation, | |
|
23 | int role = Qt::DisplayRole) const override; | |
|
24 | ||
|
25 | void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override; | |
|
26 | ||
|
27 | ||
|
28 | private: | |
|
29 | class CatalogueEventsTableModelPrivate; | |
|
30 | spimpl::unique_impl_ptr<CatalogueEventsTableModelPrivate> impl; | |
|
31 | }; | |
|
32 | ||
|
33 | #endif // SCIQLOP_CATALOGUEEVENTSTABLEMODEL_H |
@@ -0,0 +1,119 | |||
|
1 | #include "Catalogue/CatalogueEventsTableModel.h" | |
|
2 | ||
|
3 | #include <Common/DateUtils.h> | |
|
4 | #include <DBEvent.h> | |
|
5 | #include <DBTag.h> | |
|
6 | ||
|
7 | struct CatalogueEventsTableModel::CatalogueEventsTableModelPrivate { | |
|
8 | QVector<DBEvent> m_Events; | |
|
9 | ||
|
10 | enum class Column { Event, TStart, TEnd, Tags, Product, NbColumn }; | |
|
11 | QStringList columnNames() | |
|
12 | { | |
|
13 | return QStringList{tr("Event"), tr("TStart"), tr("TEnd"), tr("Tags"), tr("Product")}; | |
|
14 | } | |
|
15 | ||
|
16 | QVariant eventData(int col, const DBEvent &event) const | |
|
17 | { | |
|
18 | switch (static_cast<Column>(col)) { | |
|
19 | case Column::Event: | |
|
20 | return event.getName(); | |
|
21 | case Column::TStart: | |
|
22 | return DateUtils::dateTime(event.getTStart()); | |
|
23 | case Column::TEnd: | |
|
24 | return DateUtils::dateTime(event.getTEnd()); | |
|
25 | case Column::Product: | |
|
26 | return event.getProduct(); | |
|
27 | case Column::Tags: { | |
|
28 | QString tagList; | |
|
29 | auto tags = const_cast<DBEvent *>(&event)->getTags(); | |
|
30 | for (auto tag : tags) { | |
|
31 | tagList += tag.getName(); | |
|
32 | tagList += ' '; | |
|
33 | } | |
|
34 | ||
|
35 | return tagList; | |
|
36 | } | |
|
37 | default: | |
|
38 | break; | |
|
39 | } | |
|
40 | ||
|
41 | Q_ASSERT(false); | |
|
42 | return QStringLiteral("Unknown Data"); | |
|
43 | } | |
|
44 | }; | |
|
45 | ||
|
46 | CatalogueEventsTableModel::CatalogueEventsTableModel(QObject *parent) | |
|
47 | : QAbstractTableModel(parent), | |
|
48 | impl{spimpl::make_unique_impl<CatalogueEventsTableModelPrivate>()} | |
|
49 | { | |
|
50 | } | |
|
51 | ||
|
52 | void CatalogueEventsTableModel::setEvents(const QVector<DBEvent> &events) | |
|
53 | { | |
|
54 | beginResetModel(); | |
|
55 | impl->m_Events = events; | |
|
56 | endResetModel(); | |
|
57 | } | |
|
58 | ||
|
59 | DBEvent CatalogueEventsTableModel::getEvent(int row) const | |
|
60 | { | |
|
61 | return impl->m_Events.value(row); | |
|
62 | } | |
|
63 | ||
|
64 | int CatalogueEventsTableModel::rowCount(const QModelIndex &parent) const | |
|
65 | { | |
|
66 | int r = impl->m_Events.count(); | |
|
67 | return r; | |
|
68 | } | |
|
69 | ||
|
70 | int CatalogueEventsTableModel::columnCount(const QModelIndex &parent) const | |
|
71 | { | |
|
72 | int c = static_cast<int>(CatalogueEventsTableModelPrivate::Column::NbColumn); | |
|
73 | return c; | |
|
74 | } | |
|
75 | ||
|
76 | Qt::ItemFlags CatalogueEventsTableModel::flags(const QModelIndex &index) const | |
|
77 | { | |
|
78 | return Qt::ItemIsEnabled | Qt::ItemIsSelectable; | |
|
79 | } | |
|
80 | ||
|
81 | QVariant CatalogueEventsTableModel::data(const QModelIndex &index, int role) const | |
|
82 | { | |
|
83 | if (index.isValid()) { | |
|
84 | auto event = impl->m_Events.value(index.row()); | |
|
85 | ||
|
86 | switch (role) { | |
|
87 | case Qt::DisplayRole: | |
|
88 | return impl->eventData(index.column(), event); | |
|
89 | break; | |
|
90 | } | |
|
91 | } | |
|
92 | ||
|
93 | return QVariant{}; | |
|
94 | } | |
|
95 | ||
|
96 | QVariant CatalogueEventsTableModel::headerData(int section, Qt::Orientation orientation, | |
|
97 | int role) const | |
|
98 | { | |
|
99 | if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { | |
|
100 | return impl->columnNames().value(section); | |
|
101 | } | |
|
102 | ||
|
103 | return QVariant(); | |
|
104 | } | |
|
105 | ||
|
106 | void CatalogueEventsTableModel::sort(int column, Qt::SortOrder order) | |
|
107 | { | |
|
108 | std::sort(impl->m_Events.begin(), impl->m_Events.end(), | |
|
109 | [this, column, order](auto e1, auto e2) { | |
|
110 | auto data1 = impl->eventData(column, e1); | |
|
111 | auto data2 = impl->eventData(column, e2); | |
|
112 | ||
|
113 | auto result = data1.toString() < data2.toString(); | |
|
114 | ||
|
115 | return order == Qt::AscendingOrder ? result : !result; | |
|
116 | }); | |
|
117 | ||
|
118 | emit dataChanged(QModelIndex(), QModelIndex()); | |
|
119 | } |
@@ -1,73 +1,73 | |||
|
1 | 1 | # - Clone and build CatalogueAPI Module |
|
2 | 2 | include(ExternalProject) |
|
3 | 3 | |
|
4 | 4 | find_package(Git REQUIRED) |
|
5 | 5 | |
|
6 | 6 | if(WIN32) |
|
7 | 7 | find_program(MesonExec meson PATHS C:/Appli/Meson) |
|
8 | 8 | if(NOT MesonExec) |
|
9 | 9 | Message("Error: Meson not found") |
|
10 | 10 | else() |
|
11 | 11 | message("Meson found: ${MesonExec}" ) |
|
12 | 12 | endif() |
|
13 | 13 | find_program(NinjaExec ninja PATHS C:/Appli/Meson) |
|
14 | 14 | if(NOT NinjaExec) |
|
15 | 15 | Message("Error: Ninja not found") |
|
16 | 16 | else() |
|
17 | 17 | message("Ninja found: ${NinjaExec}" ) |
|
18 | 18 | endif() |
|
19 | 19 | endif() |
|
20 | 20 | if(NOT MesonExec) |
|
21 | 21 | set (MesonExec meson) |
|
22 | 22 | endif() |
|
23 | 23 | if(NOT NinjaExec) |
|
24 | 24 | set (NinjaExec ninja) |
|
25 | 25 | endif() |
|
26 | 26 | |
|
27 | 27 | SET(CATALOGUEAPI_SOURCES_PATH ${CMAKE_SOURCE_DIR}/3rdparty/CatalogueAPI) |
|
28 | 28 | SET(CATALOGUEAPI_BUILD_PATH ${CATALOGUEAPI_SOURCES_PATH}/build) |
|
29 | 29 | SET(CATALOGUEAPI_QXORM_LIB_PATH ${CATALOGUEAPI_BUILD_PATH}/subprojects/QxOrm) |
|
30 | 30 | SET(CatalogueAPI_build_type plain) |
|
31 | 31 | |
|
32 | 32 | if(CMAKE_BUILD_TYPE STREQUAL "") |
|
33 | 33 | set(CMAKE_BUILD_TYPE Release) |
|
34 | 34 | endif() |
|
35 | 35 | string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER) |
|
36 | 36 | |
|
37 | 37 | ExternalProject_Add( |
|
38 | 38 | CatalogueAPI |
|
39 | 39 | |
|
40 | 40 | GIT_REPOSITORY https://perrinel@hephaistos.lpp.polytechnique.fr/rhodecode/GIT_REPOSITORIES/LPP/Users/mperrinel/CatalogueAPI |
|
41 | 41 | GIT_TAG develop |
|
42 | 42 | |
|
43 | UPDATE_COMMAND ${GIT_EXECUTABLE} pull | |
|
43 | UPDATE_COMMAND ${GIT_EXECUTABLE} pull origin develop | |
|
44 | 44 | PATCH_COMMAND "" |
|
45 | 45 | |
|
46 | 46 | SOURCE_DIR "${CATALOGUEAPI_SOURCES_PATH}" |
|
47 | 47 | CONFIGURE_COMMAND ${MesonExec} --prefix=${CATALOGUEAPI_SOURCES_PATH} --buildtype=${CMAKE_BUILD_TYPE_TOLOWER} "${CATALOGUEAPI_SOURCES_PATH}" "${CATALOGUEAPI_BUILD_PATH}" |
|
48 | 48 | |
|
49 | 49 | BUILD_COMMAND ${NinjaExec} -C "${CATALOGUEAPI_BUILD_PATH}" |
|
50 | 50 | INSTALL_COMMAND ${NinjaExec} -C "${CATALOGUEAPI_BUILD_PATH}" install |
|
51 | 51 | LOG_DOWNLOAD 1 |
|
52 | 52 | LOG_UPDATE 1 |
|
53 | 53 | ) |
|
54 | 54 | |
|
55 | 55 | set(CATALOG_LIB_PATH lib) |
|
56 | 56 | if(WIN32) |
|
57 | 57 | set(CATALOG_LIB_PATH bin) |
|
58 | 58 | endif() |
|
59 | 59 | |
|
60 | 60 | ExternalProject_Add_Step( |
|
61 | 61 | CatalogueAPI CopyToBin |
|
62 | 62 | COMMAND ${CMAKE_COMMAND} -E copy_directory ${CATALOGUEAPI_SOURCES_PATH}/lib64 ${CATALOGUEAPI_SOURCES_PATH}/${CATALOG_LIB_PATH} |
|
63 | 63 | COMMAND ${CMAKE_COMMAND} -E copy_directory ${CATALOGUEAPI_QXORM_LIB_PATH} ${CATALOGUEAPI_SOURCES_PATH}/${CATALOG_LIB_PATH} |
|
64 | 64 | DEPENDEES install |
|
65 | 65 | ) |
|
66 | 66 | |
|
67 | 67 | |
|
68 | 68 | set(CATALOGUEAPI_INCLUDE ${CATALOGUEAPI_SOURCES_PATH}/src) |
|
69 | 69 | set(CATALOGUEAPI_LIBRARIES ${CATALOGUEAPI_SOURCES_PATH}/${CATALOG_LIB_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}CatalogueAPI${CMAKE_SHARED_LIBRARY_SUFFIX}) |
|
70 | 70 | list(APPEND CATALOGUEAPI_LIBRARIES ${CATALOGUEAPI_SOURCES_PATH}/${CATALOG_LIB_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}QxOrm${CMAKE_SHARED_LIBRARY_SUFFIX}) |
|
71 | 71 | |
|
72 | 72 | mark_as_advanced(CATALOGUEAPI_INCLUDE) |
|
73 | 73 | mark_as_advanced(CATALOGUEAPI_LIBRARIES) |
@@ -1,126 +1,127 | |||
|
1 | 1 | |
|
2 | 2 | qxorm_dep = dependency('QxOrm', required : true, fallback:['QxOrm','qxorm_dep']) |
|
3 | 3 | catalogueapi_dep = dependency('CatalogueAPI', required : true, fallback:['CatalogueAPI','CatalogueAPI_dep']) |
|
4 | 4 | |
|
5 | 5 | gui_moc_headers = [ |
|
6 | 6 | 'include/DataSource/DataSourceWidget.h', |
|
7 | 7 | 'include/Settings/SqpSettingsDialog.h', |
|
8 | 8 | 'include/Settings/SqpSettingsGeneralWidget.h', |
|
9 | 9 | 'include/SidePane/SqpSidePane.h', |
|
10 | 10 | 'include/SqpApplication.h', |
|
11 | 11 | 'include/DragAndDrop/DragDropScroller.h', |
|
12 | 12 | 'include/DragAndDrop/DragDropTabSwitcher.h', |
|
13 | 13 | 'include/TimeWidget/TimeWidget.h', |
|
14 | 14 | 'include/Variable/VariableInspectorWidget.h', |
|
15 | 15 | 'include/Variable/RenameVariableDialog.h', |
|
16 | 16 | 'include/Visualization/qcustomplot.h', |
|
17 | 17 | 'include/Visualization/VisualizationGraphWidget.h', |
|
18 | 18 | 'include/Visualization/VisualizationTabWidget.h', |
|
19 | 19 | 'include/Visualization/VisualizationWidget.h', |
|
20 | 20 | 'include/Visualization/VisualizationZoneWidget.h', |
|
21 | 21 | 'include/Visualization/VisualizationDragDropContainer.h', |
|
22 | 22 | 'include/Visualization/VisualizationDragWidget.h', |
|
23 | 23 | 'include/Visualization/ColorScaleEditor.h', |
|
24 | 24 | 'include/Actions/SelectionZoneAction.h', |
|
25 | 25 | 'include/Visualization/VisualizationMultiZoneSelectionDialog.h', |
|
26 | 26 | 'include/Catalogue/CatalogueExplorer.h', |
|
27 | 27 | 'include/Catalogue/CatalogueEventsWidget.h', |
|
28 | 28 | 'include/Catalogue/CatalogueSideBarWidget.h', |
|
29 | 29 | 'include/Catalogue/CatalogueInspectorWidget.h' |
|
30 | 30 | ] |
|
31 | 31 | |
|
32 | 32 | gui_ui_files = [ |
|
33 | 33 | 'ui/DataSource/DataSourceWidget.ui', |
|
34 | 34 | 'ui/Settings/SqpSettingsDialog.ui', |
|
35 | 35 | 'ui/Settings/SqpSettingsGeneralWidget.ui', |
|
36 | 36 | 'ui/SidePane/SqpSidePane.ui', |
|
37 | 37 | 'ui/TimeWidget/TimeWidget.ui', |
|
38 | 38 | 'ui/Variable/VariableInspectorWidget.ui', |
|
39 | 39 | 'ui/Variable/RenameVariableDialog.ui', |
|
40 | 40 | 'ui/Variable/VariableMenuHeaderWidget.ui', |
|
41 | 41 | 'ui/Visualization/VisualizationGraphWidget.ui', |
|
42 | 42 | 'ui/Visualization/VisualizationTabWidget.ui', |
|
43 | 43 | 'ui/Visualization/VisualizationWidget.ui', |
|
44 | 44 | 'ui/Visualization/VisualizationZoneWidget.ui', |
|
45 | 45 | 'ui/Visualization/ColorScaleEditor.ui', |
|
46 | 46 | 'ui/Visualization/VisualizationMultiZoneSelectionDialog.ui', |
|
47 | 47 | 'ui/Catalogue/CatalogueExplorer.ui', |
|
48 | 48 | 'ui/Catalogue/CatalogueEventsWidget.ui', |
|
49 | 49 | 'ui/Catalogue/CatalogueSideBarWidget.ui', |
|
50 | 50 | 'ui/Catalogue/CatalogueInspectorWidget.ui' |
|
51 | 51 | ] |
|
52 | 52 | |
|
53 | 53 | gui_qresources = ['resources/sqpguiresources.qrc'] |
|
54 | 54 | |
|
55 | 55 | gui_moc_files = qt5.preprocess(moc_headers : gui_moc_headers, |
|
56 | 56 | ui_files : gui_ui_files, |
|
57 | 57 | qresources : gui_qresources) |
|
58 | 58 | |
|
59 | 59 | gui_sources = [ |
|
60 | 60 | 'src/SqpApplication.cpp', |
|
61 | 61 | 'src/DragAndDrop/DragDropGuiController.cpp', |
|
62 | 62 | 'src/DragAndDrop/DragDropScroller.cpp', |
|
63 | 63 | 'src/DragAndDrop/DragDropTabSwitcher.cpp', |
|
64 | 64 | 'src/Common/ColorUtils.cpp', |
|
65 | 65 | 'src/Common/VisualizationDef.cpp', |
|
66 | 66 | 'src/DataSource/DataSourceTreeWidgetItem.cpp', |
|
67 | 67 | 'src/DataSource/DataSourceTreeWidgetHelper.cpp', |
|
68 | 68 | 'src/DataSource/DataSourceWidget.cpp', |
|
69 | 69 | 'src/DataSource/DataSourceTreeWidget.cpp', |
|
70 | 70 | 'src/Settings/SqpSettingsDialog.cpp', |
|
71 | 71 | 'src/Settings/SqpSettingsGeneralWidget.cpp', |
|
72 | 72 | 'src/SidePane/SqpSidePane.cpp', |
|
73 | 73 | 'src/TimeWidget/TimeWidget.cpp', |
|
74 | 74 | 'src/Variable/VariableInspectorWidget.cpp', |
|
75 | 75 | 'src/Variable/VariableInspectorTableView.cpp', |
|
76 | 76 | 'src/Variable/VariableMenuHeaderWidget.cpp', |
|
77 | 77 | 'src/Variable/RenameVariableDialog.cpp', |
|
78 | 78 | 'src/Visualization/VisualizationGraphHelper.cpp', |
|
79 | 79 | 'src/Visualization/VisualizationGraphRenderingDelegate.cpp', |
|
80 | 80 | 'src/Visualization/VisualizationGraphWidget.cpp', |
|
81 | 81 | 'src/Visualization/VisualizationTabWidget.cpp', |
|
82 | 82 | 'src/Visualization/VisualizationWidget.cpp', |
|
83 | 83 | 'src/Visualization/VisualizationZoneWidget.cpp', |
|
84 | 84 | 'src/Visualization/qcustomplot.cpp', |
|
85 | 85 | 'src/Visualization/QCustomPlotSynchronizer.cpp', |
|
86 | 86 | 'src/Visualization/operations/FindVariableOperation.cpp', |
|
87 | 87 | 'src/Visualization/operations/GenerateVariableMenuOperation.cpp', |
|
88 | 88 | 'src/Visualization/operations/MenuBuilder.cpp', |
|
89 | 89 | 'src/Visualization/operations/RemoveVariableOperation.cpp', |
|
90 | 90 | 'src/Visualization/operations/RescaleAxeOperation.cpp', |
|
91 | 91 | 'src/Visualization/VisualizationDragDropContainer.cpp', |
|
92 | 92 | 'src/Visualization/VisualizationDragWidget.cpp', |
|
93 | 93 | 'src/Visualization/AxisRenderingUtils.cpp', |
|
94 | 94 | 'src/Visualization/PlottablesRenderingUtils.cpp', |
|
95 | 95 | 'src/Visualization/MacScrollBarStyle.cpp', |
|
96 | 96 | 'src/Visualization/VisualizationCursorItem.cpp', |
|
97 | 97 | 'src/Visualization/ColorScaleEditor.cpp', |
|
98 | 98 | 'src/Visualization/SqpColorScale.cpp', |
|
99 | 99 | 'src/Visualization/QCPColorMapIterator.cpp', |
|
100 | 100 | 'src/Visualization/VisualizationSelectionZoneItem.cpp', |
|
101 | 101 | 'src/Visualization/VisualizationSelectionZoneManager.cpp', |
|
102 | 102 | 'src/Actions/SelectionZoneAction.cpp', |
|
103 | 103 | 'src/Actions/ActionsGuiController.cpp', |
|
104 | 104 | 'src/Visualization/VisualizationActionManager.cpp', |
|
105 | 105 | 'src/Visualization/VisualizationMultiZoneSelectionDialog.cpp', |
|
106 | 106 | 'src/Catalogue/CatalogueExplorer.cpp', |
|
107 | 107 | 'src/Catalogue/CatalogueEventsWidget.cpp', |
|
108 | 108 | 'src/Catalogue/CatalogueSideBarWidget.cpp', |
|
109 | 109 | 'src/Catalogue/CatalogueInspectorWidget.cpp', |
|
110 | 'src/Catalogue/CatalogueTreeWidgetItem.cpp' | |
|
110 | 'src/Catalogue/CatalogueTreeWidgetItem.cpp', | |
|
111 | 'src/Catalogue/CatalogueEventsTableModel.cpp' | |
|
111 | 112 | ] |
|
112 | 113 | |
|
113 | 114 | gui_inc = include_directories(['include']) |
|
114 | 115 | |
|
115 | 116 | sciqlop_gui_lib = library('sciqlopgui', |
|
116 | 117 | gui_sources, |
|
117 | 118 | gui_moc_files, |
|
118 | 119 | include_directories : [gui_inc], |
|
119 | 120 | dependencies : [ qt5printsupport, qt5gui, qt5widgets, qt5svg, sciqlop_core, catalogueapi_dep], |
|
120 | 121 | install : true |
|
121 | 122 | ) |
|
122 | 123 | |
|
123 | 124 | sciqlop_gui = declare_dependency(link_with : sciqlop_gui_lib, |
|
124 | 125 | include_directories : gui_inc, |
|
125 | 126 | dependencies : [qt5printsupport, qt5gui, qt5widgets, qt5svg, sciqlop_core, catalogueapi_dep]) |
|
126 | 127 |
@@ -1,115 +1,86 | |||
|
1 | 1 | #include "Catalogue/CatalogueEventsWidget.h" |
|
2 | 2 | #include "ui_CatalogueEventsWidget.h" |
|
3 | 3 | |
|
4 | 4 | #include <Catalogue/CatalogueController.h> |
|
5 | #include <Catalogue/CatalogueEventsTableModel.h> | |
|
5 | 6 | #include <CatalogueDao.h> |
|
6 | 7 | #include <DBCatalogue.h> |
|
7 | 8 | #include <SqpApplication.h> |
|
8 | 9 | |
|
9 | 10 | |
|
10 | 11 | /// Format of the dates appearing in the label of a cursor |
|
11 | 12 | const auto DATETIME_FORMAT = QStringLiteral("yyyy/MM/dd hh:mm:ss"); |
|
12 | 13 | |
|
13 | 14 | struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate { |
|
14 | void addEventItem(const QStringList &data, QTableWidget *tableWidget); | |
|
15 | 15 | |
|
16 | enum class Column { Event, TStart, TEnd, Tags, Product, NbColumn }; | |
|
17 | QStringList columnNames() { return QStringList{"Event", "TStart", "TEnd", "Tags", "Product"}; } | |
|
18 | ||
|
19 | QVector<DBEvent> m_Events; | |
|
16 | CatalogueEventsTableModel *m_Model = nullptr; | |
|
20 | 17 | }; |
|
21 | 18 | |
|
22 | 19 | |
|
23 | 20 | CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent) |
|
24 | 21 | : QWidget(parent), |
|
25 | 22 | ui(new Ui::CatalogueEventsWidget), |
|
26 | 23 | impl{spimpl::make_unique_impl<CatalogueEventsWidgetPrivate>()} |
|
27 | 24 | { |
|
28 | 25 | ui->setupUi(this); |
|
29 | 26 | |
|
27 | impl->m_Model = new CatalogueEventsTableModel(this); | |
|
28 | ui->tableView->setModel(impl->m_Model); | |
|
29 | ||
|
30 | ui->tableView->setSortingEnabled(true); | |
|
31 | ||
|
30 | 32 | connect(ui->btnTime, &QToolButton::clicked, [this](auto checked) { |
|
31 | 33 | if (checked) { |
|
32 | 34 | ui->btnChart->setChecked(false); |
|
33 | 35 | } |
|
34 | 36 | }); |
|
35 | 37 | |
|
36 | 38 | connect(ui->btnChart, &QToolButton::clicked, [this](auto checked) { |
|
37 | 39 | if (checked) { |
|
38 | 40 | ui->btnTime->setChecked(false); |
|
39 | 41 | } |
|
40 | 42 | }); |
|
41 | 43 | |
|
42 |
connect(ui->table |
|
|
43 |
auto event = impl->m_ |
|
|
44 | connect(ui->tableView, &QTableView::clicked, [this](auto index) { | |
|
45 | auto event = impl->m_Model->getEvent(index.row()); | |
|
44 | 46 | emit this->eventSelected(event); |
|
45 | 47 | }); |
|
46 | 48 | |
|
47 |
connect(ui->table |
|
|
49 | connect(ui->tableView->selectionModel(), &QItemSelectionModel::currentChanged, | |
|
48 | 50 | [this](auto current, auto previous) { |
|
49 |
if (current && current |
|
|
50 |
auto event = impl->m_Event |
|
|
51 | if (current.isValid() && current.row() >= 0) { | |
|
52 | auto event = impl->m_Model->getEvent(current.row()); | |
|
51 | 53 | emit this->eventSelected(event); |
|
52 | 54 | } |
|
53 | 55 | }); |
|
54 | 56 | |
|
55 |
connect(ui->table |
|
|
56 |
auto selection = ui->table |
|
|
57 | auto isNotMultiSelection | |
|
58 | = selection.isEmpty() || (selection.count() == 1 && selection.first().rowCount() == 1); | |
|
57 | connect(ui->tableView->selectionModel(), &QItemSelectionModel::selectionChanged, [this]() { | |
|
58 | auto isNotMultiSelection = ui->tableView->selectionModel()->selectedRows().count() <= 1; | |
|
59 | 59 | ui->btnChart->setEnabled(isNotMultiSelection); |
|
60 | 60 | ui->btnTime->setEnabled(isNotMultiSelection); |
|
61 | 61 | }); |
|
62 | 62 | |
|
63 | Q_ASSERT(impl->columnNames().count() == (int)CatalogueEventsWidgetPrivate::Column::NbColumn); | |
|
64 | ui->tableWidget->setColumnCount((int)CatalogueEventsWidgetPrivate::Column::NbColumn); | |
|
65 |
ui->table |
|
|
66 | ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); | |
|
67 | ui->tableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); | |
|
68 | ui->tableWidget->horizontalHeader()->setSortIndicatorShown(true); | |
|
63 | ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); | |
|
64 | ui->tableView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); | |
|
65 | ui->tableView->horizontalHeader()->setSortIndicatorShown(true); | |
|
69 | 66 | } |
|
70 | 67 | |
|
71 | 68 | CatalogueEventsWidget::~CatalogueEventsWidget() |
|
72 | 69 | { |
|
73 | 70 | delete ui; |
|
74 | 71 | } |
|
75 | 72 | |
|
76 | 73 | void CatalogueEventsWidget::populateWithCatalogue(const DBCatalogue &catalogue) |
|
77 | 74 | { |
|
78 | ui->tableWidget->clearContents(); | |
|
79 | ui->tableWidget->setRowCount(0); | |
|
80 | ||
|
81 | 75 | auto &dao = sqpApp->catalogueController().getDao(); |
|
82 | 76 | auto events = dao.getCatalogueEvents(catalogue); |
|
83 | 77 | |
|
78 | QVector<DBEvent> eventVector; | |
|
84 | 79 | for (auto event : events) { |
|
85 |
|
|
|
86 | ||
|
87 | auto tags = event.getTags(); | |
|
88 | QString tagList; | |
|
89 | for (auto tag : tags) { | |
|
90 | tagList += tag.getName(); | |
|
91 | tagList += ' '; | |
|
92 | } | |
|
93 | ||
|
94 | impl->addEventItem({event.getName(), | |
|
95 | DateUtils::dateTime(event.getTStart()).toString(DATETIME_FORMAT), | |
|
96 | DateUtils::dateTime(event.getTEnd()).toString(DATETIME_FORMAT), tagList, | |
|
97 | event.getProduct()}, | |
|
98 | ui->tableWidget); | |
|
80 | eventVector << event; | |
|
99 | 81 | } |
|
100 | } | |
|
101 | 82 | |
|
102 | void CatalogueEventsWidget::CatalogueEventsWidgetPrivate::addEventItem(const QStringList &data, | |
|
103 | QTableWidget *tableWidget) | |
|
104 | { | |
|
105 | tableWidget->setSortingEnabled(false); | |
|
106 | auto row = tableWidget->rowCount(); | |
|
107 | tableWidget->setRowCount(row + 1); | |
|
108 | ||
|
109 | for (auto i = 0; i < (int)Column::NbColumn; ++i) { | |
|
110 | auto item = new QTableWidgetItem(data.value(i)); | |
|
111 | item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); | |
|
112 | tableWidget->setItem(row, i, item); | |
|
113 | } | |
|
114 | tableWidget->setSortingEnabled(true); | |
|
83 | ui->tableView->setSortingEnabled(false); | |
|
84 | impl->m_Model->setEvents(eventVector); | |
|
85 | ui->tableView->setSortingEnabled(true); | |
|
115 | 86 | } |
@@ -1,139 +1,148 | |||
|
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
|
2 | 2 | <ui version="4.0"> |
|
3 | 3 | <class>CatalogueEventsWidget</class> |
|
4 | 4 | <widget class="QWidget" name="CatalogueEventsWidget"> |
|
5 | 5 | <property name="geometry"> |
|
6 | 6 | <rect> |
|
7 | 7 | <x>0</x> |
|
8 | 8 | <y>0</y> |
|
9 | 9 | <width>566</width> |
|
10 | 10 | <height>258</height> |
|
11 | 11 | </rect> |
|
12 | 12 | </property> |
|
13 | 13 | <property name="windowTitle"> |
|
14 | 14 | <string>Form</string> |
|
15 | 15 | </property> |
|
16 | 16 | <layout class="QVBoxLayout" name="verticalLayout"> |
|
17 | 17 | <property name="leftMargin"> |
|
18 | 18 | <number>0</number> |
|
19 | 19 | </property> |
|
20 | 20 | <property name="topMargin"> |
|
21 | 21 | <number>0</number> |
|
22 | 22 | </property> |
|
23 | 23 | <property name="rightMargin"> |
|
24 | 24 | <number>0</number> |
|
25 | 25 | </property> |
|
26 | 26 | <property name="bottomMargin"> |
|
27 | 27 | <number>0</number> |
|
28 | 28 | </property> |
|
29 | 29 | <item> |
|
30 | 30 | <layout class="QHBoxLayout" name="horizontalLayout"> |
|
31 | 31 | <item> |
|
32 | 32 | <widget class="QToolButton" name="btnAdd"> |
|
33 | 33 | <property name="text"> |
|
34 | 34 | <string>+</string> |
|
35 | 35 | </property> |
|
36 | 36 | <property name="icon"> |
|
37 | <iconset> | |
|
37 | <iconset resource="../../resources/sqpguiresources.qrc"> | |
|
38 | 38 | <normaloff>:/icones/add.png</normaloff>:/icones/add.png</iconset> |
|
39 | 39 | </property> |
|
40 | 40 | <property name="autoRaise"> |
|
41 | 41 | <bool>true</bool> |
|
42 | 42 | </property> |
|
43 | 43 | </widget> |
|
44 | 44 | </item> |
|
45 | 45 | <item> |
|
46 | 46 | <widget class="QToolButton" name="btnRemove"> |
|
47 | 47 | <property name="text"> |
|
48 | 48 | <string> - </string> |
|
49 | 49 | </property> |
|
50 | 50 | <property name="icon"> |
|
51 | <iconset> | |
|
51 | <iconset resource="../../resources/sqpguiresources.qrc"> | |
|
52 | 52 | <normaloff>:/icones/remove.png</normaloff>:/icones/remove.png</iconset> |
|
53 | 53 | </property> |
|
54 | 54 | <property name="autoRaise"> |
|
55 | 55 | <bool>true</bool> |
|
56 | 56 | </property> |
|
57 | 57 | </widget> |
|
58 | 58 | </item> |
|
59 | 59 | <item> |
|
60 | 60 | <widget class="Line" name="line"> |
|
61 | 61 | <property name="orientation"> |
|
62 | 62 | <enum>Qt::Vertical</enum> |
|
63 | 63 | </property> |
|
64 | 64 | </widget> |
|
65 | 65 | </item> |
|
66 | 66 | <item> |
|
67 | 67 | <widget class="QToolButton" name="btnTime"> |
|
68 | 68 | <property name="text"> |
|
69 | 69 | <string>T</string> |
|
70 | 70 | </property> |
|
71 | 71 | <property name="icon"> |
|
72 | <iconset> | |
|
72 | <iconset resource="../../resources/sqpguiresources.qrc"> | |
|
73 | 73 | <normaloff>:/icones/time.png</normaloff>:/icones/time.png</iconset> |
|
74 | 74 | </property> |
|
75 | 75 | <property name="checkable"> |
|
76 | 76 | <bool>true</bool> |
|
77 | 77 | </property> |
|
78 | 78 | <property name="autoRaise"> |
|
79 | 79 | <bool>true</bool> |
|
80 | 80 | </property> |
|
81 | 81 | </widget> |
|
82 | 82 | </item> |
|
83 | 83 | <item> |
|
84 | 84 | <widget class="QToolButton" name="btnChart"> |
|
85 | 85 | <property name="text"> |
|
86 | 86 | <string>G</string> |
|
87 | 87 | </property> |
|
88 | 88 | <property name="icon"> |
|
89 | <iconset> | |
|
89 | <iconset resource="../../resources/sqpguiresources.qrc"> | |
|
90 | 90 | <normaloff>:/icones/chart.png</normaloff>:/icones/chart.png</iconset> |
|
91 | 91 | </property> |
|
92 | 92 | <property name="checkable"> |
|
93 | 93 | <bool>true</bool> |
|
94 | 94 | </property> |
|
95 | 95 | <property name="autoRaise"> |
|
96 | 96 | <bool>true</bool> |
|
97 | 97 | </property> |
|
98 | 98 | </widget> |
|
99 | 99 | </item> |
|
100 | 100 | <item> |
|
101 | 101 | <widget class="Line" name="line_2"> |
|
102 | 102 | <property name="orientation"> |
|
103 | 103 | <enum>Qt::Vertical</enum> |
|
104 | 104 | </property> |
|
105 | 105 | </widget> |
|
106 | 106 | </item> |
|
107 | 107 | <item> |
|
108 | 108 | <widget class="QLineEdit" name="lineEdit"> |
|
109 | 109 | <property name="enabled"> |
|
110 | 110 | <bool>false</bool> |
|
111 | 111 | </property> |
|
112 | 112 | </widget> |
|
113 | 113 | </item> |
|
114 | 114 | </layout> |
|
115 | 115 | </item> |
|
116 | 116 | <item> |
|
117 |
<widget class="QTable |
|
|
118 | <property name="alternatingRowColors"> | |
|
119 | <bool>true</bool> | |
|
120 | </property> | |
|
117 | <widget class="QTableView" name="tableView"> | |
|
121 | 118 | <property name="selectionBehavior"> |
|
122 | 119 | <enum>QAbstractItemView::SelectRows</enum> |
|
123 | 120 | </property> |
|
121 | <attribute name="horizontalHeaderVisible"> | |
|
122 | <bool>true</bool> | |
|
123 | </attribute> | |
|
124 | 124 | <attribute name="horizontalHeaderHighlightSections"> |
|
125 | 125 | <bool>false</bool> |
|
126 | 126 | </attribute> |
|
127 | <attribute name="horizontalHeaderShowSortIndicator" stdset="0"> | |
|
128 | <bool>true</bool> | |
|
129 | </attribute> | |
|
127 | 130 | <attribute name="verticalHeaderVisible"> |
|
128 | 131 | <bool>false</bool> |
|
129 | 132 | </attribute> |
|
130 | 133 | <attribute name="verticalHeaderDefaultSectionSize"> |
|
131 | 134 | <number>25</number> |
|
132 | 135 | </attribute> |
|
136 | <attribute name="verticalHeaderHighlightSections"> | |
|
137 | <bool>false</bool> | |
|
138 | </attribute> | |
|
133 | 139 | </widget> |
|
134 | 140 | </item> |
|
135 | 141 | </layout> |
|
136 | 142 | </widget> |
|
137 |
<resources |
|
|
143 | <resources> | |
|
144 | <include location="../../resources/sqpguiresources.qrc"/> | |
|
145 | <include location="../../resources/sqpguiresources.qrc"/> | |
|
146 | </resources> | |
|
138 | 147 | <connections/> |
|
139 | 148 | </ui> |
General Comments 0
You need to be logged in to leave comments.
Login now