diff options
author | montellese <montellese@xbmc.org> | 2013-07-22 23:38:54 +0200 |
---|---|---|
committer | montellese <montellese@xbmc.org> | 2013-08-02 16:49:03 +0200 |
commit | 4b726b644c3bb4fcd9c23f2c99944afa7e529542 (patch) | |
tree | 9548fd716ea54cee7cd7af0267ef7abea5dd5514 | |
parent | 68829f47f4dba0d059d2f3d72a03c907e88011ea (diff) |
video: add "Edit sort title" to "Manage ..." context menu entry
-rw-r--r-- | language/English/strings.po | 6 | ||||
-rw-r--r-- | xbmc/dialogs/GUIDialogContextMenu.h | 1 | ||||
-rw-r--r-- | xbmc/video/VideoDatabase.cpp | 27 | ||||
-rw-r--r-- | xbmc/video/VideoDatabase.h | 1 | ||||
-rw-r--r-- | xbmc/video/dialogs/GUIDialogVideoInfo.cpp | 35 | ||||
-rw-r--r-- | xbmc/video/dialogs/GUIDialogVideoInfo.h | 1 |
6 files changed, 70 insertions, 1 deletions
diff --git a/language/English/strings.po b/language/English/strings.po index d578a1dee9..c4b2ec79c1 100644 --- a/language/English/strings.po +++ b/language/English/strings.po @@ -6714,7 +6714,11 @@ msgctxt "#16106" msgid "Manage ..." msgstr "" -#empty strings from id 16107 to 16199 +msgctxt "#16107" +msgid "Edit sort title" +msgstr "" + +#empty strings from id 16108 to 16199 #: xbmc/windows/GUIWindowFileManager.cpp msgctxt "#16200" diff --git a/xbmc/dialogs/GUIDialogContextMenu.h b/xbmc/dialogs/GUIDialogContextMenu.h index 863436c209..fff3b24ded 100644 --- a/xbmc/dialogs/GUIDialogContextMenu.h +++ b/xbmc/dialogs/GUIDialogContextMenu.h @@ -127,6 +127,7 @@ enum CONTEXT_BUTTON { CONTEXT_BUTTON_CANCELLED = 0, CONTEXT_BUTTON_SET_MOVIESET, CONTEXT_BUTTON_MOVIESET_ADD_REMOVE_ITEMS, CONTEXT_BUTTON_BROWSE_INTO, + CONTEXT_BUTTON_EDIT_SORTTITLE, CONTEXT_BUTTON_USER1, CONTEXT_BUTTON_USER2, CONTEXT_BUTTON_USER3, diff --git a/xbmc/video/VideoDatabase.cpp b/xbmc/video/VideoDatabase.cpp index 8f5b2b2523..96b0fc4c79 100644 --- a/xbmc/video/VideoDatabase.cpp +++ b/xbmc/video/VideoDatabase.cpp @@ -4741,6 +4741,33 @@ void CVideoDatabase::UpdateMovieTitle(int idMovie, const CStdString& strNewMovie } } +bool CVideoDatabase::UpdateVideoSortTitle(int idDb, const CStdString& strNewSortTitle, VIDEODB_CONTENT_TYPE iType /* = VIDEODB_CONTENT_MOVIES */) +{ + try + { + if (NULL == m_pDB.get() || NULL == m_pDS.get()) + return false; + if (iType != VIDEODB_CONTENT_MOVIES && iType != VIDEODB_CONTENT_TVSHOWS) + return false; + + CStdString content = "movie"; + if (iType == VIDEODB_CONTENT_TVSHOWS) + content = "tvshow"; + + if (SetSingleValue(iType, idDb, FieldSortTitle, strNewSortTitle)) + { + AnnounceUpdate(content, idDb); + return true; + } + } + catch (...) + { + CLog::Log(LOGERROR, "%s (int idDb, const CStdString& strNewSortTitle, VIDEODB_CONTENT_TYPE iType) failed on ID: %i and Sort Title: %s", __FUNCTION__, idDb, strNewSortTitle.c_str()); + } + + return false; +} + /// \brief EraseVideoSettings() Erases the videoSettings table and reconstructs it void CVideoDatabase::EraseVideoSettings() { diff --git a/xbmc/video/VideoDatabase.h b/xbmc/video/VideoDatabase.h index 3b495e9b81..90fa1900c4 100644 --- a/xbmc/video/VideoDatabase.h +++ b/xbmc/video/VideoDatabase.h @@ -410,6 +410,7 @@ public: bool GetPlayCounts(const CStdString &path, CFileItemList &items); void UpdateMovieTitle(int idMovie, const CStdString& strNewMovieTitle, VIDEODB_CONTENT_TYPE iType=VIDEODB_CONTENT_MOVIES); + bool UpdateVideoSortTitle(int idDb, const CStdString& strNewSortTitle, VIDEODB_CONTENT_TYPE iType = VIDEODB_CONTENT_MOVIES); bool HasMovieInfo(const CStdString& strFilenameAndPath); bool HasTvShowInfo(const CStdString& strFilenameAndPath); diff --git a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp index 322ae2fcef..5c072f3bec 100644 --- a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp @@ -949,6 +949,9 @@ int CGUIDialogVideoInfo::ManageVideoItem(const CFileItemPtr &item) CContextButtons buttons; buttons.Add(CONTEXT_BUTTON_EDIT, 16105); + if (type == VIDEODB_CONTENT_MOVIES || type == VIDEODB_CONTENT_TVSHOWS) + buttons.Add(CONTEXT_BUTTON_EDIT_SORTTITLE, 16107); + if (item->m_bIsFolder) { // Have both options for folders since we don't know whether all childs are watched/unwatched @@ -991,6 +994,10 @@ int CGUIDialogVideoInfo::ManageVideoItem(const CFileItemPtr &item) result = UpdateVideoItemTitle(item); break; + case CONTEXT_BUTTON_EDIT_SORTTITLE: + result = UpdateVideoItemSortTitle(item); + break; + case CONTEXT_BUTTON_MARK_WATCHED: result = MarkWatched(item, true); break; @@ -1272,6 +1279,34 @@ bool CGUIDialogVideoInfo::SetMovieSet(const CFileItem *movieItem, const CFileIte return true; } +bool CGUIDialogVideoInfo::UpdateVideoItemSortTitle(const CFileItemPtr &pItem) +{ + // dont allow update while scanning + if (g_application.IsVideoScanning()) + { + CGUIDialogOK::ShowAndGetInput(257, 0, 14057, 0); + return false; + } + + CVideoDatabase database; + if (!database.Open()) + return false; + + int iDbId = pItem->GetVideoInfoTag()->m_iDbId; + CVideoInfoTag detail; + VIDEODB_CONTENT_TYPE iType = (VIDEODB_CONTENT_TYPE)pItem->GetVideoContentType(); + if (iType == VIDEODB_CONTENT_MOVIES) + database.GetMovieInfo("", detail, iDbId); + else if (iType == VIDEODB_CONTENT_TVSHOWS) + database.GetTvShowInfo(pItem->GetVideoInfoTag()->m_strFileNameAndPath, detail, iDbId); + + // get the new sort title + if (!CGUIKeyboardFactory::ShowAndGetInput(detail.m_strTitle, g_localizeStrings.Get(16107), false)) + return false; + + return database.UpdateVideoSortTitle(iDbId, detail.m_strTitle, iType); +} + bool CGUIDialogVideoInfo::LinkMovieToTvShow(const CFileItemPtr &item, bool bRemove, CVideoDatabase &database) { int dbId = item->GetVideoInfoTag()->m_iDbId; diff --git a/xbmc/video/dialogs/GUIDialogVideoInfo.h b/xbmc/video/dialogs/GUIDialogVideoInfo.h index 80aa2c5f99..2ce4aca43a 100644 --- a/xbmc/video/dialogs/GUIDialogVideoInfo.h +++ b/xbmc/video/dialogs/GUIDialogVideoInfo.h @@ -68,6 +68,7 @@ protected: void OnGetFanart(); void PlayTrailer(); + static bool UpdateVideoItemSortTitle(const CFileItemPtr &pItem); static bool LinkMovieToTvShow(const CFileItemPtr &item, bool bRemove, CVideoDatabase &database); CFileItemPtr m_movieItem; |