PlayListItem PlayList::itemAt(int row) { if (mpModel->rowCount() < 0) { qWarning("Invalid rowCount"); return PlayListItem(); } return mpModel->data(mpModel->index(row), Qt::DisplayRole).value<PlayListItem>(); }
bool NGMainWnd::onnet_playlistfiles(const vector<string> &files, const vector<dword> &indexes, const dword total) { if (this->playlist.size() > total) { this->playlist.erase(this->playlist.begin() + total, this->playlist.end()); } for (dword i = 0; i < files.size(); i++) { if (indexes[i] < this->playlist.size()) { this->playlist[indexes[i]].path = files[i]; } else if (indexes[i] < total) { for (dword j = this->playlist.size(); j < indexes[i]; j++) { this->playlist.push_back(PlayListItem("?", "?")); } this->playlist.push_back(PlayListItem("?", files[i])); } } this->listview_refreshplaylist(); return true; }
bool PlayListModel::insertRows(int row, int count, const QModelIndex &parent) { if (count < 1 || row < 0 || row > rowCount(parent)) return false; beginInsertRows(QModelIndex(), row, row + count - 1); for (int r = 0; r < count; ++r) mItems.insert(row, PlayListItem()); endInsertRows(); return true; }