| 194 | } |
| 195 | |
| 196 | void BookmarkDialog::OnDeleteClick() |
| 197 | { |
| 198 | auto & bm = m_framework.GetBookmarkManager(); |
| 199 | for (auto const item : m_tree->selectedItems()) |
| 200 | { |
| 201 | auto const categoryIt = m_categories.find(item); |
| 202 | if (categoryIt != m_categories.cend()) |
| 203 | { |
| 204 | if (m_categories.size() == 1) |
| 205 | { |
| 206 | QMessageBox ask(this); |
| 207 | ask.setIcon(QMessageBox::Information); |
| 208 | ask.setText(tr("Could not delete the last category.")); |
| 209 | ask.addButton(tr("OK"), QMessageBox::NoRole); |
| 210 | ask.exec(); |
| 211 | } |
| 212 | else |
| 213 | { |
| 214 | bm.GetEditSession().DeleteBmCategory(categoryIt->second, true); |
| 215 | FillTree(); |
| 216 | } |
| 217 | return; |
| 218 | } |
| 219 | |
| 220 | auto const bookmarkIt = m_bookmarks.find(item); |
| 221 | if (bookmarkIt != m_bookmarks.cend()) |
| 222 | { |
| 223 | bm.GetEditSession().DeleteBookmark(bookmarkIt->second); |
| 224 | FillTree(); |
| 225 | return; |
| 226 | } |
| 227 | |
| 228 | auto const trackIt = m_tracks.find(item); |
| 229 | if (trackIt != m_tracks.cend()) |
| 230 | { |
| 231 | bm.GetEditSession().DeleteTrack(trackIt->second); |
| 232 | FillTree(); |
| 233 | return; |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | QMessageBox ask(this); |
| 238 | ask.setIcon(QMessageBox::Warning); |
| 239 | ask.setText(tr("Select category, bookmark or track to delete.")); |
| 240 | ask.addButton(tr("OK"), QMessageBox::NoRole); |
| 241 | ask.exec(); |
| 242 | } |
| 243 | |
| 244 | QTreeWidgetItem * BookmarkDialog::CreateTreeItem(std::string const & title, QTreeWidgetItem * parent) |
| 245 | { |
nothing calls this directly
no test coverage detected