MCPcopy Create free account
hub / github.com/comaps/comaps / OnItemClick

Method OnItemClick

qt/update_dialog.cpp:158–259  ·  view source on GitHub ↗

when user clicks on any map row in the table

Source from the content-addressed store, hash-verified

156
157/// when user clicks on any map row in the table
158void UpdateDialog::OnItemClick(QTreeWidgetItem * item, int column)
159{
160 CountryId const countryId = GetCountryIdByTreeItem(item);
161
162 Storage & st = GetStorage();
163
164 NodeAttrs attrs;
165 st.GetNodeAttrs(countryId, attrs);
166
167 CountriesVec children;
168 st.GetChildren(countryId, children);
169
170 // For group process only click on the column #.
171 if (!children.empty() && column != 1)
172 return;
173
174 switch (attrs.m_status)
175 {
176 case NodeStatus::OnDiskOutOfDate:
177 {
178 // Map is already downloaded, so ask user about deleting.
179 QMessageBox ask(this);
180 ask.setIcon(QMessageBox::Question);
181 ask.setText(tr("Do you want to update or delete %1?").arg(countryId.c_str()));
182 QPushButton * const btnUpdate = ask.addButton(tr("Update"), QMessageBox::ActionRole);
183 QPushButton * const btnDelete = ask.addButton(tr("Delete"), QMessageBox::ActionRole);
184 QPushButton * const btnCancel = ask.addButton(tr("Cancel"), QMessageBox::NoRole);
185 UNUSED_VALUE(btnCancel);
186
187 ask.exec();
188
189 QAbstractButton * const res = ask.clickedButton();
190
191 if (res == btnUpdate)
192 st.UpdateNode(countryId);
193 else if (res == btnDelete)
194 {
195 if (!m_framework.HasUnsavedEdits(countryId) || DeleteNotUploadedEditsConfirmation())
196 st.DeleteNode(countryId);
197 }
198 }
199 break;
200
201 case NodeStatus::OnDisk:
202 {
203 // Map is already downloaded, so ask user about deleting.
204 QMessageBox ask(this);
205 ask.setIcon(QMessageBox::Question);
206 ask.setText(tr("Do you want to delete %1?").arg(countryId.c_str()));
207 QPushButton * const btnDelete = ask.addButton(tr("Delete"), QMessageBox::ActionRole);
208 QPushButton * const btnCancel = ask.addButton(tr("Cancel"), QMessageBox::NoRole);
209 UNUSED_VALUE(btnCancel);
210
211 ask.exec();
212
213 QAbstractButton * const res = ask.clickedButton();
214
215 if (res == btnDelete)

Callers

nothing calls this directly

Calls 11

ASSERTFunction · 0.85
GetNodeAttrsMethod · 0.80
GetChildrenMethod · 0.80
setIconMethod · 0.80
UpdateNodeMethod · 0.80
HasUnsavedEditsMethod · 0.80
DeleteNodeMethod · 0.80
DownloadNodeMethod · 0.80
CancelDownloadNodeMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected