##// END OF EJS Templates
Edition of events from the inspector
trabillard -
r1181:ac6f44836b9a
parent child
Show More
@@ -13,8 +13,10 public:
13 void setEvents(const QVector<std::shared_ptr<DBEvent> > &events);
13 void setEvents(const QVector<std::shared_ptr<DBEvent> > &events);
14 std::shared_ptr<DBEvent> getEvent(int row) const;
14 std::shared_ptr<DBEvent> getEvent(int row) const;
15
15
16 void addEvent(const std::shared_ptr<DBEvent> &events);
16 void addEvent(const std::shared_ptr<DBEvent> &event);
17 void removeEvent(const std::shared_ptr<DBEvent> &events);
17 void removeEvent(const std::shared_ptr<DBEvent> &event);
18
19 void refreshEvent(const std::shared_ptr<DBEvent> &event);
18
20
19 // Model
21 // Model
20 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
22 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
@@ -27,6 +27,8 public:
27
27
28 void setVisualizationWidget(VisualizationWidget *visualization);
28 void setVisualizationWidget(VisualizationWidget *visualization);
29
29
30 void setEventChanges(const std::shared_ptr<DBEvent> &event, bool hasChanges);
31
30 public slots:
32 public slots:
31 void populateWithCatalogues(const QVector<std::shared_ptr<DBCatalogue> > &catalogues);
33 void populateWithCatalogues(const QVector<std::shared_ptr<DBCatalogue> > &catalogues);
32
34
@@ -66,17 +66,16 std::shared_ptr<DBEvent> CatalogueEventsTableModel::getEvent(int row) const
66 return impl->m_Events.value(row);
66 return impl->m_Events.value(row);
67 }
67 }
68
68
69 void CatalogueEventsTableModel::addEvent(const std::shared_ptr<DBEvent> &events)
69 void CatalogueEventsTableModel::addEvent(const std::shared_ptr<DBEvent> &event)
70 {
70 {
71 beginInsertRows(QModelIndex(), impl->m_Events.count() - 1, impl->m_Events.count() - 1);
71 beginInsertRows(QModelIndex(), impl->m_Events.count() - 1, impl->m_Events.count() - 1);
72 // impl->m_Events.append(event); TODO
72 impl->m_Events.append(event);
73 endInsertRows();
73 endInsertRows();
74 }
74 }
75
75
76 void CatalogueEventsTableModel::removeEvent(const std::shared_ptr<DBEvent> &events)
76 void CatalogueEventsTableModel::removeEvent(const std::shared_ptr<DBEvent> &event)
77 {
77 {
78 // TODO
78 auto index = impl->m_Events.indexOf(event);
79 auto index = -1; // impl->m_Events.indexOf(event);
80 if (index >= 0) {
79 if (index >= 0) {
81 beginRemoveRows(QModelIndex(), index, index);
80 beginRemoveRows(QModelIndex(), index, index);
82 impl->m_Events.removeAt(index);
81 impl->m_Events.removeAt(index);
@@ -84,6 +83,14 void CatalogueEventsTableModel::removeEvent(const std::shared_ptr<DBEvent> &even
84 }
83 }
85 }
84 }
86
85
86 void CatalogueEventsTableModel::refreshEvent(const std::shared_ptr<DBEvent> &event)
87 {
88 auto eventIndex = impl->m_Events.indexOf(event);
89 if (eventIndex >= 0) {
90 emit dataChanged(index(eventIndex, 0), index(eventIndex, columnCount()));
91 }
92 }
93
87 int CatalogueEventsTableModel::rowCount(const QModelIndex &parent) const
94 int CatalogueEventsTableModel::rowCount(const QModelIndex &parent) const
88 {
95 {
89 int r = impl->m_Events.count();
96 int r = impl->m_Events.count();
@@ -92,8 +99,7 int CatalogueEventsTableModel::rowCount(const QModelIndex &parent) const
92
99
93 int CatalogueEventsTableModel::columnCount(const QModelIndex &parent) const
100 int CatalogueEventsTableModel::columnCount(const QModelIndex &parent) const
94 {
101 {
95 int c = static_cast<int>(CatalogueEventsTableModelPrivate::Column::NbColumn);
102 return static_cast<int>(CatalogueEventsTableModelPrivate::Column::NbColumn);
96 return c;
97 }
103 }
98
104
99 Qt::ItemFlags CatalogueEventsTableModel::flags(const QModelIndex &index) const
105 Qt::ItemFlags CatalogueEventsTableModel::flags(const QModelIndex &index) const
@@ -271,6 +271,11 void CatalogueEventsWidget::setVisualizationWidget(VisualizationWidget *visualiz
271 impl->m_VisualizationWidget = visualization;
271 impl->m_VisualizationWidget = visualization;
272 }
272 }
273
273
274 void CatalogueEventsWidget::setEventChanges(const std::shared_ptr<DBEvent> &event, bool hasChanges)
275 {
276 impl->m_Model->refreshEvent(event);
277 }
278
274 void CatalogueEventsWidget::populateWithCatalogues(
279 void CatalogueEventsWidget::populateWithCatalogues(
275 const QVector<std::shared_ptr<DBCatalogue> > &catalogues)
280 const QVector<std::shared_ptr<DBCatalogue> > &catalogues)
276 {
281 {
@@ -51,6 +51,9 CatalogueExplorer::CatalogueExplorer(QWidget *parent)
51
51
52 connect(ui->inspector, &CatalogueInspectorWidget::catalogueUpdated,
52 connect(ui->inspector, &CatalogueInspectorWidget::catalogueUpdated,
53 [this](auto catalogue) { ui->catalogues->setCatalogueChanges(catalogue, true); });
53 [this](auto catalogue) { ui->catalogues->setCatalogueChanges(catalogue, true); });
54
55 connect(ui->inspector, &CatalogueInspectorWidget::eventUpdated,
56 [this](auto event) { ui->events->setEventChanges(event, true); });
54 }
57 }
55
58
56 CatalogueExplorer::~CatalogueExplorer()
59 CatalogueExplorer::~CatalogueExplorer()
@@ -9,6 +9,11
9 struct CatalogueInspectorWidget::CatalogueInspectorWidgetPrivate {
9 struct CatalogueInspectorWidget::CatalogueInspectorWidgetPrivate {
10 std::shared_ptr<DBCatalogue> m_DisplayedCatalogue = nullptr;
10 std::shared_ptr<DBCatalogue> m_DisplayedCatalogue = nullptr;
11 std::shared_ptr<DBEvent> m_DisplayedEvent = nullptr;
11 std::shared_ptr<DBEvent> m_DisplayedEvent = nullptr;
12
13 void connectCatalogueUpdateSignals(CatalogueInspectorWidget *inspector,
14 Ui::CatalogueInspectorWidget *ui);
15 void connectEventUpdateSignals(CatalogueInspectorWidget *inspector,
16 Ui::CatalogueInspectorWidget *ui);
12 };
17 };
13
18
14 CatalogueInspectorWidget::CatalogueInspectorWidget(QWidget *parent)
19 CatalogueInspectorWidget::CatalogueInspectorWidget(QWidget *parent)
@@ -19,24 +24,76 CatalogueInspectorWidget::CatalogueInspectorWidget(QWidget *parent)
19 ui->setupUi(this);
24 ui->setupUi(this);
20 showPage(Page::Empty);
25 showPage(Page::Empty);
21
26
22 connect(ui->leCatalogueName, &QLineEdit::editingFinished, [this]() {
27 impl->connectCatalogueUpdateSignals(this, ui);
23 if (ui->leCatalogueName->text() != impl->m_DisplayedCatalogue->getName()) {
28 impl->connectEventUpdateSignals(this, ui);
24 impl->m_DisplayedCatalogue->setName(ui->leCatalogueName->text());
29 }
25 emit this->catalogueUpdated(impl->m_DisplayedCatalogue);
30
31 CatalogueInspectorWidget::~CatalogueInspectorWidget()
32 {
33 delete ui;
34 }
35
36 void CatalogueInspectorWidget::CatalogueInspectorWidgetPrivate::connectCatalogueUpdateSignals(
37 CatalogueInspectorWidget *inspector, Ui::CatalogueInspectorWidget *ui)
38 {
39 connect(ui->leCatalogueName, &QLineEdit::editingFinished, [ui, inspector, this]() {
40 if (ui->leCatalogueName->text() != m_DisplayedCatalogue->getName()) {
41 m_DisplayedCatalogue->setName(ui->leCatalogueName->text());
42 emit inspector->catalogueUpdated(m_DisplayedCatalogue);
26 }
43 }
27 });
44 });
28
45
29 connect(ui->leCatalogueAuthor, &QLineEdit::editingFinished, [this]() {
46 connect(ui->leCatalogueAuthor, &QLineEdit::editingFinished, [ui, inspector, this]() {
30 if (ui->leCatalogueAuthor->text() != impl->m_DisplayedCatalogue->getAuthor()) {
47 if (ui->leCatalogueAuthor->text() != m_DisplayedCatalogue->getAuthor()) {
31 impl->m_DisplayedCatalogue->setAuthor(ui->leCatalogueAuthor->text());
48 m_DisplayedCatalogue->setAuthor(ui->leCatalogueAuthor->text());
32 emit this->catalogueUpdated(impl->m_DisplayedCatalogue);
49 emit inspector->catalogueUpdated(m_DisplayedCatalogue);
33 }
50 }
34 });
51 });
35 }
52 }
36
53
37 CatalogueInspectorWidget::~CatalogueInspectorWidget()
54 void CatalogueInspectorWidget::CatalogueInspectorWidgetPrivate::connectEventUpdateSignals(
55 CatalogueInspectorWidget *inspector, Ui::CatalogueInspectorWidget *ui)
38 {
56 {
39 delete ui;
57 connect(ui->leEventName, &QLineEdit::editingFinished, [ui, inspector, this]() {
58 if (ui->leEventName->text() != m_DisplayedEvent->getName()) {
59 m_DisplayedEvent->setName(ui->leEventName->text());
60 emit inspector->eventUpdated(m_DisplayedEvent);
61 }
62 });
63
64 connect(ui->leEventMission, &QLineEdit::editingFinished, [ui, inspector, this]() {
65 if (ui->leEventMission->text() != m_DisplayedEvent->getMission()) {
66 m_DisplayedEvent->setMission(ui->leEventMission->text());
67 emit inspector->eventUpdated(m_DisplayedEvent);
68 }
69 });
70
71 connect(ui->leEventProduct, &QLineEdit::editingFinished, [ui, inspector, this]() {
72 if (ui->leEventProduct->text() != m_DisplayedEvent->getProduct()) {
73 m_DisplayedEvent->setProduct(ui->leEventProduct->text());
74 emit inspector->eventUpdated(m_DisplayedEvent);
75 }
76 });
77
78 connect(ui->leEventTags, &QLineEdit::editingFinished, [ui, inspector, this]() {
79 // TODO
80 });
81
82 connect(ui->dateTimeEventTStart, &QDateTimeEdit::editingFinished, [ui, inspector, this]() {
83 auto time = DateUtils::secondsSinceEpoch(ui->dateTimeEventTStart->dateTime());
84 if (time != m_DisplayedEvent->getTStart()) {
85 m_DisplayedEvent->setTStart(time);
86 emit inspector->eventUpdated(m_DisplayedEvent);
87 }
88 });
89
90 connect(ui->dateTimeEventTEnd, &QDateTimeEdit::editingFinished, [ui, inspector, this]() {
91 auto time = DateUtils::secondsSinceEpoch(ui->dateTimeEventTEnd->dateTime());
92 if (time != m_DisplayedEvent->getTEnd()) {
93 m_DisplayedEvent->setTEnd(time);
94 emit inspector->eventUpdated(m_DisplayedEvent);
95 }
96 });
40 }
97 }
41
98
42 void CatalogueInspectorWidget::showPage(CatalogueInspectorWidget::Page page)
99 void CatalogueInspectorWidget::showPage(CatalogueInspectorWidget::Page page)
@@ -114,7 +114,11
114 <widget class="QWidget" name="eventInspectorPage">
114 <widget class="QWidget" name="eventInspectorPage">
115 <layout class="QGridLayout" name="gridLayout">
115 <layout class="QGridLayout" name="gridLayout">
116 <item row="5" column="1">
116 <item row="5" column="1">
117 <widget class="QDateTimeEdit" name="dateTimeEventTEnd"/>
117 <widget class="QDateTimeEdit" name="dateTimeEventTEnd">
118 <property name="timeSpec">
119 <enum>Qt::UTC</enum>
120 </property>
121 </widget>
118 </item>
122 </item>
119 <item row="4" column="0">
123 <item row="4" column="0">
120 <widget class="QLabel" name="label_4">
124 <widget class="QLabel" name="label_4">
@@ -148,7 +152,11
148 </widget>
152 </widget>
149 </item>
153 </item>
150 <item row="4" column="1">
154 <item row="4" column="1">
151 <widget class="QDateTimeEdit" name="dateTimeEventTStart"/>
155 <widget class="QDateTimeEdit" name="dateTimeEventTStart">
156 <property name="timeSpec">
157 <enum>Qt::UTC</enum>
158 </property>
159 </widget>
152 </item>
160 </item>
153 <item row="2" column="0">
161 <item row="2" column="0">
154 <widget class="QLabel" name="label_2">
162 <widget class="QLabel" name="label_2">
General Comments 3
Under Review
author

Auto status change to "Under Review"

Approved

Status change > Approved

You need to be logged in to leave comments. Login now