std::string CPVRGUIActions::GetResumeLabel(const CFileItem &item) const { std::string resumeString; const CPVRRecordingPtr recording(CPVRItem(CFileItemPtr(new CFileItem(item))).GetRecording()); if (recording && !recording->IsDeleted()) { // First try to find the resume position on the back-end, if that fails use video database int positionInSeconds = recording->GetLastPlayedPosition(); // If the back-end does report a saved position it will be picked up by FileItem if (positionInSeconds < 0) { CVideoDatabase db; if (db.Open()) { CBookmark bookmark; std::string itemPath(recording->m_strFileNameAndPath); if (db.GetResumeBookMark(itemPath, bookmark) ) positionInSeconds = lrint(bookmark.timeInSeconds); db.Close(); } } // Suppress resume from 0 if (positionInSeconds > 0) resumeString = StringUtils::Format(g_localizeStrings.Get(12022).c_str(), StringUtils::SecondsToTimeString(positionInSeconds, TIME_FORMAT_HH_MM_SS).c_str()); } return resumeString; }
QMimeData *SharedUiItemsTreeModel::mimeData( const QModelIndexList &indexes) const { if (indexes.isEmpty()) return 0; QMimeData *md = new QMimeData; QSet<QString> pathsSet; QStringList ids; QStringList paths; foreach (const QModelIndex &index, indexes) { QString path = itemPath(index); if (!pathsSet.contains(path)) { ids.append(itemAt(index).qualifiedId()); paths.append(path); pathsSet.insert(path); } }
void CPlaylist::Write(const boost::filesystem::path& playlistPath) { std::unique_ptr<Framework::Xml::CNode> document(new Framework::Xml::CNode()); auto playlistNode = document->InsertNode(new Framework::Xml::CNode(PLAYLIST_NODE_TAG, true)); auto parentPath = playlistPath.parent_path(); for(auto itemIterator(std::begin(m_items)); itemIterator != std::end(m_items); itemIterator++) { const auto& item(*itemIterator); boost::filesystem::path itemPath(item.path); auto itemRelativePath(naive_uncomplete(itemPath, parentPath)); auto itemNode = playlistNode->InsertNode(new Framework::Xml::CNode(PLAYLIST_ITEM_NODE_TAG, true)); itemNode->InsertAttribute(PLAYLIST_ITEM_PATH_ATTRIBUTE, Framework::Utf8::ConvertTo(itemRelativePath.wstring()).c_str()); itemNode->InsertAttribute(PLAYLIST_ITEM_TITLE_ATTRIBUTE, Framework::Utf8::ConvertTo(item.title).c_str()); itemNode->InsertAttribute(Framework::Xml::CreateAttributeIntValue(PLAYLIST_ITEM_LENGTH_ATTRIBUTE, item.length)); } auto stream(Framework::CreateOutputStdStream(playlistPath.native())); Framework::Xml::CWriter::WriteDocument(stream, document.get()); }