void PlaylistModel::removeSelectedItem() { QModelIndexList list = slct->selectedRows(); if (list.empty()) return; int c = 0; for (auto iter = list.cbegin(); iter != list.cend(); ++iter) { int row = (*iter).row(); if (row < img_index) c++; delete files[row]; files[row] = nullptr; } bool contain = (files[currentIndex(0)] == nullptr || (countShowImages() > 1 && files[currentIndex(1)] == nullptr)); for (int i = 0; i < files.count(); ) { if (files[i] == nullptr) { beginRemoveRows(QModelIndex(), i, i); files.remove(i); endRemoveRows(); } else { i++; } } if (empty()) { dataChangeNotice(-1, 0); showImages(); } else { dataChangeNotice(img_index - c, countShowImages()); if (contain) showImages(); } emit changePlaylistStatus(); }