From e20e7e066845538b1d071b2d4081465fc5d819cb Mon Sep 17 00:00:00 2001 From: montellese Date: Sun, 21 Jul 2013 12:20:08 +0200 Subject: media: move "Update library" and "Stop scanning" out of the context menu --- xbmc/addons/GUIWindowAddonBrowser.cpp | 4 ++-- xbmc/dialogs/GUIDialogContextMenu.h | 3 +-- xbmc/music/windows/GUIWindowMusicNav.cpp | 26 +++++++++++----------- xbmc/video/windows/GUIWindowVideoBase.cpp | 6 ------ xbmc/video/windows/GUIWindowVideoNav.cpp | 36 ++++++++++++------------------- 5 files changed, 29 insertions(+), 46 deletions(-) diff --git a/xbmc/addons/GUIWindowAddonBrowser.cpp b/xbmc/addons/GUIWindowAddonBrowser.cpp index 33c9a2be21..ca31201fc0 100644 --- a/xbmc/addons/GUIWindowAddonBrowser.cpp +++ b/xbmc/addons/GUIWindowAddonBrowser.cpp @@ -157,7 +157,7 @@ void CGUIWindowAddonBrowser::GetContextButtons(int itemNumber, if (addon->Type() == ADDON_REPOSITORY && pItem->m_bIsFolder) { buttons.Add(CONTEXT_BUTTON_SCAN,24034); - buttons.Add(CONTEXT_BUTTON_UPDATE_LIBRARY,24035); + buttons.Add(CONTEXT_BUTTON_REFRESH,24035); } buttons.Add(CONTEXT_BUTTON_INFO,24003); @@ -185,7 +185,7 @@ bool CGUIWindowAddonBrowser::OnContextButton(int itemNumber, if (button == CONTEXT_BUTTON_SETTINGS) return CGUIDialogAddonSettings::ShowAndGetInput(addon); - if (button == CONTEXT_BUTTON_UPDATE_LIBRARY) + if (button == CONTEXT_BUTTON_REFRESH) { CAddonDatabase database; database.Open(); diff --git a/xbmc/dialogs/GUIDialogContextMenu.h b/xbmc/dialogs/GUIDialogContextMenu.h index 822f57c6ea..1b0d43302d 100644 --- a/xbmc/dialogs/GUIDialogContextMenu.h +++ b/xbmc/dialogs/GUIDialogContextMenu.h @@ -75,8 +75,7 @@ enum CONTEXT_BUTTON { CONTEXT_BUTTON_CANCELLED = 0, CONTEXT_BUTTON_INFO, CONTEXT_BUTTON_INFO_ALL, CONTEXT_BUTTON_CDDB, - CONTEXT_BUTTON_UPDATE_LIBRARY, - CONTEXT_BUTTON_UPDATE_TVSHOW, + CONTEXT_BUTTON_REFRESH, CONTEXT_BUTTON_SCAN, CONTEXT_BUTTON_STOP_SCANNING, CONTEXT_BUTTON_SET_ARTIST_THUMB, diff --git a/xbmc/music/windows/GUIWindowMusicNav.cpp b/xbmc/music/windows/GUIWindowMusicNav.cpp index 2dde21a021..9fbe45993a 100644 --- a/xbmc/music/windows/GUIWindowMusicNav.cpp +++ b/xbmc/music/windows/GUIWindowMusicNav.cpp @@ -72,6 +72,8 @@ using namespace MUSICDATABASEDIRECTORY; #define CONTROL_BTN_FILTER 19 #define CONTROL_LABELEMPTY 18 +#define CONTROL_UPDATE_LIBRARY 20 + CGUIWindowMusicNav::CGUIWindowMusicNav(void) : CGUIWindowMusicBase(WINDOW_MUSIC_NAV, "MyMusicNav.xml") { @@ -165,6 +167,14 @@ bool CGUIWindowMusicNav::OnMessage(CGUIMessage& message) SetProperty("search", search); return true; } + else if (iControl == CONTROL_UPDATE_LIBRARY) + { + if (!g_application.IsMusicScanning()) + g_application.StartMusicScan(""); + else + g_application.StopMusicScan(); + return true; + } } break; case GUI_MSG_PLAYBACK_STOPPED: @@ -381,6 +391,8 @@ void CGUIWindowMusicNav::UpdateButtons() SET_CONTROL_LABEL(CONTROL_FILTER, strLabel); SET_CONTROL_SELECTED(GetID(),CONTROL_BTNPARTYMODE, g_partyModeManager.IsEnabled()); + + CONTROL_ENABLE_ON_CONDITION(CONTROL_UPDATE_LIBRARY, !m_vecItems->IsAddonsPath() && !m_vecItems->IsPlugin() && !m_vecItems->IsScript()); } void CGUIWindowMusicNav::PlayItem(int iItem) @@ -535,14 +547,6 @@ void CGUIWindowMusicNav::GetContextButtons(int itemNumber, CContextButtons &butt } // noncontextual buttons - if (g_application.IsMusicScanning()) - buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); // Stop Scanning - else - { - if (!m_vecItems->IsPlugin()) - buttons.Add(CONTEXT_BUTTON_UPDATE_LIBRARY, 653); - } - CGUIWindowMusicBase::GetNonContextButtons(buttons); } @@ -610,12 +614,6 @@ bool CGUIWindowMusicNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button) OnInfoAll(itemNumber); return true; - case CONTEXT_BUTTON_UPDATE_LIBRARY: - { - g_application.StartMusicScan(""); - return true; - } - case CONTEXT_BUTTON_SET_DEFAULT: CSettings::Get().SetString("mymusic.defaultlibview", GetQuickpathName(item->GetPath())); CSettings::Get().Save(); diff --git a/xbmc/video/windows/GUIWindowVideoBase.cpp b/xbmc/video/windows/GUIWindowVideoBase.cpp index aa6d743b50..818947bcba 100644 --- a/xbmc/video/windows/GUIWindowVideoBase.cpp +++ b/xbmc/video/windows/GUIWindowVideoBase.cpp @@ -1405,13 +1405,7 @@ bool CGUIWindowVideoBase::OnContextButton(int itemNumber, CONTEXT_BUTTON button) OnInfo(itemNumber); return true; - case CONTEXT_BUTTON_STOP_SCANNING: - { - g_application.StopVideoScan(); - return true; - } case CONTEXT_BUTTON_SCAN: - case CONTEXT_BUTTON_UPDATE_TVSHOW: { if( !item) return false; diff --git a/xbmc/video/windows/GUIWindowVideoNav.cpp b/xbmc/video/windows/GUIWindowVideoNav.cpp index 105270c452..d6c04093aa 100644 --- a/xbmc/video/windows/GUIWindowVideoNav.cpp +++ b/xbmc/video/windows/GUIWindowVideoNav.cpp @@ -80,6 +80,8 @@ using namespace std; #define CONTROL_BTNFLATTEN 17 #define CONTROL_LABELEMPTY 18 +#define CONTROL_UPDATE_LIBRARY 20 + CGUIWindowVideoNav::CGUIWindowVideoNav(void) : CGUIWindowVideoBase(WINDOW_VIDEO_NAV, "MyVideoNav.xml") { @@ -189,6 +191,14 @@ bool CGUIWindowVideoNav::OnMessage(CGUIMessage& message) OnFilterItems(GetProperty("filter").asString()); return true; } + else if (iControl == CONTROL_UPDATE_LIBRARY) + { + if (!g_application.IsVideoScanning()) + OnScan(""); + else + g_application.StopVideoScan(); + return true; + } } break; // update the display @@ -543,6 +553,8 @@ void CGUIWindowVideoNav::UpdateButtons() SET_CONTROL_SELECTED(GetID(),CONTROL_BTNPARTYMODE, g_partyModeManager.IsEnabled()); SET_CONTROL_SELECTED(GetID(),CONTROL_BTNFLATTEN, CSettings::Get().GetBool("myvideos.flatten")); + + CONTROL_ENABLE_ON_CONDITION(CONTROL_UPDATE_LIBRARY, !m_vecItems->IsAddonsPath() && !m_vecItems->IsPlugin() && !m_vecItems->IsScript()); } bool CGUIWindowVideoNav::GetFilteredItems(const CStdString &filter, CFileItemList &items) @@ -857,10 +869,7 @@ void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &butt if (!item) { - if (g_application.IsVideoScanning()) - buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); - else - buttons.Add(CONTEXT_BUTTON_UPDATE_LIBRARY, 653); + // nothing to do here } else if (m_vecItems->GetPath().Equals("sources://video/")) { @@ -945,7 +954,7 @@ void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &butt if (g_application.IsVideoScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); else - buttons.Add(CONTEXT_BUTTON_UPDATE_TVSHOW, 13349); + buttons.Add(CONTEXT_BUTTON_SCAN, 13349); } if (!item->IsPlugin() && !item->IsScript() && !item->IsLiveTV() && !item->IsAddonsPath() && item->GetPath() != "sources://video/" && item->GetPath() != "special://videoplaylists/" && @@ -1030,18 +1039,6 @@ void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &butt } buttons.Add(CONTEXT_BUTTON_DELETE, 646); } - - // this should ideally be non-contextual (though we need some context for non-tv show node I guess) - if (g_application.IsVideoScanning()) - { - if (node != NODE_TYPE_TITLE_TVSHOWS) - buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); - } - else - { - if (!(item->IsPlugin() || item->IsScript() || m_vecItems->IsPlugin())) - buttons.Add(CONTEXT_BUTTON_UPDATE_LIBRARY, 653); - } } if (!m_vecItems->IsVideoDb() && !m_vecItems->IsVirtualDirectoryRoot()) @@ -1377,11 +1374,6 @@ bool CGUIWindowVideoNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button) Refresh(); return true; } - case CONTEXT_BUTTON_UPDATE_LIBRARY: - { - OnScan(""); - return true; - } case CONTEXT_BUTTON_UNLINK_MOVIE: { OnLinkMovieToTvShow(itemNumber, true); -- cgit v1.2.3 From 4bf68ba257451d3750244ec6052da6ac4e27e6a4 Mon Sep 17 00:00:00 2001 From: montellese Date: Sun, 21 Jul 2013 12:20:53 +0200 Subject: [confluence] add "Update library" and "Stop scanning" to sidebar --- addons/skin.confluence/720p/MyMusicNav.xml | 20 +++++++++++++++++++- addons/skin.confluence/720p/MyVideoNav.xml | 20 +++++++++++++++++++- addons/skin.confluence/language/English/strings.po | 7 ++++++- 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/addons/skin.confluence/720p/MyMusicNav.xml b/addons/skin.confluence/720p/MyMusicNav.xml index 1c7be7e35f..d5567a608d 100644 --- a/addons/skin.confluence/720p/MyMusicNav.xml +++ b/addons/skin.confluence/720p/MyMusicNav.xml @@ -108,7 +108,7 @@ ButtonCommonValues - + Container.CanFilterAdvanced Filter ButtonCommonValues @@ -145,6 +145,24 @@ ButtonCommonValues + + 250 + 35 + font12 + + blue + center + center + + + Update library + ButtonCommonValues + + 13353 + button-focus.png + - + library.isscanningvideo + CommonNowPlaying_Controls diff --git a/addons/skin.confluence/720p/MyVideoNav.xml b/addons/skin.confluence/720p/MyVideoNav.xml index cb7bce38b6..7d79e290cf 100644 --- a/addons/skin.confluence/720p/MyVideoNav.xml +++ b/addons/skin.confluence/720p/MyVideoNav.xml @@ -105,7 +105,7 @@ ButtonCommonValues - + Container.CanFilterAdvanced Filter ButtonCommonValues @@ -170,6 +170,24 @@ system.ismaster system.haslocks + + 250 + 35 + font12 + + blue + center + center + + + Update library + ButtonCommonValues + + 13353 + button-focus.png + - + library.isscanningvideo + CommonNowPlaying_Controls diff --git a/addons/skin.confluence/language/English/strings.po b/addons/skin.confluence/language/English/strings.po index 310a997eb1..57118bac7c 100644 --- a/addons/skin.confluence/language/English/strings.po +++ b/addons/skin.confluence/language/English/strings.po @@ -102,7 +102,12 @@ msgctxt "#31033" msgid "Info" msgstr "" -#empty strings from id 31034 to 31039 +#empty strings from id 31034 to 31038 + +msgctxt "#31039" +msgid "Actions" +msgstr "" + #Extra labels msgctxt "#31040" -- cgit v1.2.3 From 3d92f83b9c5db3d97faf8b327da199dae11654ad Mon Sep 17 00:00:00 2001 From: montellese Date: Sun, 21 Jul 2013 13:05:07 +0200 Subject: media: move "Now playing..." out of the context menu --- xbmc/dialogs/GUIDialogContextMenu.h | 1 - xbmc/music/windows/GUIWindowMusicBase.cpp | 6 ------ xbmc/video/windows/GUIWindowVideoBase.cpp | 10 ---------- xbmc/video/windows/GUIWindowVideoBase.h | 1 - xbmc/video/windows/GUIWindowVideoNav.cpp | 1 - 5 files changed, 19 deletions(-) diff --git a/xbmc/dialogs/GUIDialogContextMenu.h b/xbmc/dialogs/GUIDialogContextMenu.h index 1b0d43302d..863436c209 100644 --- a/xbmc/dialogs/GUIDialogContextMenu.h +++ b/xbmc/dialogs/GUIDialogContextMenu.h @@ -80,7 +80,6 @@ enum CONTEXT_BUTTON { CONTEXT_BUTTON_CANCELLED = 0, CONTEXT_BUTTON_STOP_SCANNING, CONTEXT_BUTTON_SET_ARTIST_THUMB, CONTEXT_BUTTON_SET_SEASON_ART, - CONTEXT_BUTTON_NOW_PLAYING, CONTEXT_BUTTON_CANCEL_PARTYMODE, CONTEXT_BUTTON_MARK_WATCHED, CONTEXT_BUTTON_MARK_UNWATCHED, diff --git a/xbmc/music/windows/GUIWindowMusicBase.cpp b/xbmc/music/windows/GUIWindowMusicBase.cpp index 4961a36eca..87fbaeffd8 100644 --- a/xbmc/music/windows/GUIWindowMusicBase.cpp +++ b/xbmc/music/windows/GUIWindowMusicBase.cpp @@ -737,8 +737,6 @@ void CGUIWindowMusicBase::GetNonContextButtons(CContextButtons &buttons) { if (!m_vecItems->IsVirtualDirectoryRoot()) buttons.Add(CONTEXT_BUTTON_GOTO_ROOT, 20128); - if (g_playlistPlayer.GetPlaylist(PLAYLIST_MUSIC).size() > 0) - buttons.Add(CONTEXT_BUTTON_NOW_PLAYING, 13350); buttons.Add(CONTEXT_BUTTON_SETTINGS, 5); } @@ -805,10 +803,6 @@ bool CGUIWindowMusicBase::OnContextButton(int itemNumber, CONTEXT_BUTTON button) return true; } - case CONTEXT_BUTTON_NOW_PLAYING: - g_windowManager.ActivateWindow(WINDOW_MUSIC_PLAYLIST); - return true; - case CONTEXT_BUTTON_GOTO_ROOT: Update(""); return true; diff --git a/xbmc/video/windows/GUIWindowVideoBase.cpp b/xbmc/video/windows/GUIWindowVideoBase.cpp index 818947bcba..c1802435ec 100644 --- a/xbmc/video/windows/GUIWindowVideoBase.cpp +++ b/xbmc/video/windows/GUIWindowVideoBase.cpp @@ -1274,12 +1274,6 @@ void CGUIWindowVideoBase::GetContextButtons(int itemNumber, CContextButtons &but CGUIMediaWindow::GetContextButtons(itemNumber, buttons); } -void CGUIWindowVideoBase::GetNonContextButtons(int itemNumber, CContextButtons &buttons) -{ - if (g_playlistPlayer.GetPlaylist(PLAYLIST_VIDEO).size() > 0) - buttons.Add(CONTEXT_BUTTON_NOW_PLAYING, 13350); -} - bool CGUIWindowVideoBase::OnPlayStackPart(int iItem) { if (iItem < 0 || iItem >= m_vecItems->Size()) @@ -1397,10 +1391,6 @@ bool CGUIWindowVideoBase::OnContextButton(int itemNumber, CONTEXT_BUTTON button) case CONTEXT_BUTTON_RESUME_ITEM: return OnFileAction(itemNumber, SELECT_ACTION_RESUME); - case CONTEXT_BUTTON_NOW_PLAYING: - g_windowManager.ActivateWindow(WINDOW_VIDEO_PLAYLIST); - return true; - case CONTEXT_BUTTON_INFO: OnInfo(itemNumber); return true; diff --git a/xbmc/video/windows/GUIWindowVideoBase.h b/xbmc/video/windows/GUIWindowVideoBase.h index c483b263ba..b6e305d8d8 100644 --- a/xbmc/video/windows/GUIWindowVideoBase.h +++ b/xbmc/video/windows/GUIWindowVideoBase.h @@ -104,7 +104,6 @@ protected: virtual bool CanContainFilter(const CStdString &strDirectory) const; virtual void GetContextButtons(int itemNumber, CContextButtons &buttons); - void GetNonContextButtons(int itemNumber, CContextButtons &buttons); virtual bool OnContextButton(int itemNumber, CONTEXT_BUTTON button); virtual void OnQueueItem(int iItem); virtual void OnDeleteItem(CFileItemPtr pItem); diff --git a/xbmc/video/windows/GUIWindowVideoNav.cpp b/xbmc/video/windows/GUIWindowVideoNav.cpp index d6c04093aa..c107e2e666 100644 --- a/xbmc/video/windows/GUIWindowVideoNav.cpp +++ b/xbmc/video/windows/GUIWindowVideoNav.cpp @@ -1070,7 +1070,6 @@ void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &butt buttons.Add(CONTEXT_BUTTON_PLUGIN_SETTINGS, 1045); } } - CGUIWindowVideoBase::GetNonContextButtons(itemNumber, buttons); } // predicate used by sorting and set_difference -- cgit v1.2.3 From cb531fc732d28a134120dea2049b422e39c93fc8 Mon Sep 17 00:00:00 2001 From: montellese Date: Sun, 21 Jul 2013 13:05:43 +0200 Subject: [confluence] add "Now playing..." to sidebar player controls --- addons/skin.confluence/720p/MyMusicNav.xml | 4 ++-- addons/skin.confluence/720p/MyVideoNav.xml | 4 ++-- addons/skin.confluence/720p/MyWeather.xml | 4 ++-- addons/skin.confluence/720p/includes.xml | 15 ++++++++++++++- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/addons/skin.confluence/720p/MyMusicNav.xml b/addons/skin.confluence/720p/MyMusicNav.xml index d5567a608d..ad337889f2 100644 --- a/addons/skin.confluence/720p/MyMusicNav.xml +++ b/addons/skin.confluence/720p/MyMusicNav.xml @@ -56,9 +56,9 @@ SideBladeLeft 0 - 110 + 60 250 - 600 + 650 9000 50 9000 diff --git a/addons/skin.confluence/720p/MyVideoNav.xml b/addons/skin.confluence/720p/MyVideoNav.xml index 7d79e290cf..e3e0e56b01 100644 --- a/addons/skin.confluence/720p/MyVideoNav.xml +++ b/addons/skin.confluence/720p/MyVideoNav.xml @@ -60,9 +60,9 @@ SideBladeLeft 0 - 110 + 60 250 - 600 + 650 9000 50 9000 diff --git a/addons/skin.confluence/720p/MyWeather.xml b/addons/skin.confluence/720p/MyWeather.xml index 76b66834a5..40943b9099 100644 --- a/addons/skin.confluence/720p/MyWeather.xml +++ b/addons/skin.confluence/720p/MyWeather.xml @@ -723,9 +723,9 @@ SideBladeLeft 0 - 110 + 60 250 - 610 + 650 9000 50 9000 diff --git a/addons/skin.confluence/720p/includes.xml b/addons/skin.confluence/720p/includes.xml index d886a0bd1c..1885ddb87f 100644 --- a/addons/skin.confluence/720p/includes.xml +++ b/addons/skin.confluence/720p/includes.xml @@ -28,6 +28,10 @@ $INFO[ListItem.Art(poster)] $INFO[ListItem.Icon] + + ActivateWindow(videoplaylist) + ActivateWindow(musicplaylist) + @@ -148,7 +152,7 @@ LOGO 15 - 50 + 0 220 80 keep @@ -887,6 +891,15 @@ GoFullscreen.png Player.HasMedia + + Go to playlist + ButtonCommonValues + + $VAR[PlayList] + Player.HasMedia + !VideoPlayer.Content(LiveTV) + !Window.IsVisible(MusicPlaylist) + !Window.IsVisible(VideoPlaylist) + -- cgit v1.2.3 From 926ab4845c094c1b4fc5fd45b9e4ec051a9553e2 Mon Sep 17 00:00:00 2001 From: montellese Date: Sun, 21 Jul 2013 22:16:48 +0200 Subject: CFileItem: add IsLibraryFolder() --- xbmc/FileItem.cpp | 8 ++++++++ xbmc/FileItem.h | 1 + xbmc/utils/URIUtils.cpp | 6 ++++++ xbmc/utils/URIUtils.h | 1 + xbmc/video/GUIViewStateVideo.cpp | 8 ++++---- xbmc/video/windows/GUIWindowVideoNav.cpp | 2 +- xbmc/view/GUIViewState.cpp | 2 +- 7 files changed, 22 insertions(+), 6 deletions(-) diff --git a/xbmc/FileItem.cpp b/xbmc/FileItem.cpp index 5a9301e7a8..015eb1c91a 100644 --- a/xbmc/FileItem.cpp +++ b/xbmc/FileItem.cpp @@ -941,6 +941,14 @@ bool CFileItem::IsSmartPlayList() const return URIUtils::HasExtension(m_strPath, ".xsp"); } +bool CFileItem::IsLibraryFolder() const +{ + if (HasProperty("library.filter") && GetProperty("library.filter").asBoolean()) + return true; + + return URIUtils::IsLibraryFolder(m_strPath); +} + bool CFileItem::IsPlayList() const { return CPlayListFactory::IsPlaylist(*this); diff --git a/xbmc/FileItem.h b/xbmc/FileItem.h index 4253fe1234..3d9c565105 100644 --- a/xbmc/FileItem.h +++ b/xbmc/FileItem.h @@ -147,6 +147,7 @@ public: bool IsInternetStream(const bool bStrictCheck = false) const; bool IsPlayList() const; bool IsSmartPlayList() const; + bool IsLibraryFolder() const; bool IsPythonScript() const; bool IsPlugin() const; bool IsScript() const; diff --git a/xbmc/utils/URIUtils.cpp b/xbmc/utils/URIUtils.cpp index c8bbe62b50..1b1707ceb5 100644 --- a/xbmc/utils/URIUtils.cpp +++ b/xbmc/utils/URIUtils.cpp @@ -853,6 +853,12 @@ bool URIUtils::IsAndroidApp(const CStdString &path) return path.Left(11).Equals("androidapp:"); } +bool URIUtils::IsLibraryFolder(const CStdString& strFile) +{ + CURL url(strFile); + return url.GetProtocol().Equals("library"); +} + bool URIUtils::IsDOSPath(const CStdString &path) { if (path.size() > 1 && path[1] == ':' && isalpha(path[0])) diff --git a/xbmc/utils/URIUtils.h b/xbmc/utils/URIUtils.h index cd9929fbdd..b0c8f9309c 100644 --- a/xbmc/utils/URIUtils.h +++ b/xbmc/utils/URIUtils.h @@ -114,6 +114,7 @@ public: static bool IsArchive(const CStdString& strFile); static bool IsBluray(const CStdString& strFile); static bool IsAndroidApp(const CStdString& strFile); + static bool IsLibraryFolder(const CStdString& strFile); static void AddSlashAtEnd(CStdString& strFolder); static bool HasSlashAtEnd(const CStdString& strFile, bool checkURL = false); diff --git a/xbmc/video/GUIViewStateVideo.cpp b/xbmc/video/GUIViewStateVideo.cpp index 303262c3f1..06a1805146 100644 --- a/xbmc/video/GUIViewStateVideo.cpp +++ b/xbmc/video/GUIViewStateVideo.cpp @@ -479,7 +479,7 @@ CGUIViewStateVideoMovies::CGUIViewStateVideoMovies(const CFileItemList& items) : AddSortMethod(SortByYear, 562, LABEL_MASKS("%T", "%Y", "%T", "%Y")); // Title, Year | Title, Year const CViewState *viewState = CViewStateSettings::Get().Get("videonavtitles"); - if (items.IsSmartPlayList() || items.GetProperty("library.filter").asBoolean()) + if (items.IsSmartPlayList() || items.IsLibraryFolder()) AddPlaylistOrder(items, LABEL_MASKS("%T", "%R", "%T", "%R")); // Title, Rating | Title, Rating else { @@ -516,7 +516,7 @@ CGUIViewStateVideoMusicVideos::CGUIViewStateVideoMusicVideos(const CFileItemList AddSortMethod(SortByTrackNumber, 554, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined | empty, empty const CViewState *viewState = CViewStateSettings::Get().Get("videonavmusicvideos"); - if (items.IsSmartPlayList() || items.GetProperty("library.filter").asBoolean()) + if (items.IsSmartPlayList() || items.IsLibraryFolder()) AddPlaylistOrder(items, LABEL_MASKS("%A - %T", "%Y")); // Artist - Title, Year | empty, empty else { @@ -541,7 +541,7 @@ CGUIViewStateVideoTVShows::CGUIViewStateVideoTVShows(const CFileItemList& items) AddSortMethod(SortByYear, 562, LABEL_MASKS("%T", "%Y", "%T", "%Y")); // Title, Year | Title, Year const CViewState *viewState = CViewStateSettings::Get().Get("videonavtvshows"); - if (items.IsSmartPlayList() || items.GetProperty("library.filter").asBoolean()) + if (items.IsSmartPlayList() || items.IsLibraryFolder()) AddPlaylistOrder(items, LABEL_MASKS("%T", "%M", "%T", "%M")); // Title, #Episodes | Title, #Episodes else { @@ -581,7 +581,7 @@ CGUIViewStateVideoEpisodes::CGUIViewStateVideoEpisodes(const CFileItemList& item } const CViewState *viewState = CViewStateSettings::Get().Get("videonavepisodes"); - if (items.IsSmartPlayList() || items.GetProperty("library.filter").asBoolean()) + if (items.IsSmartPlayList() || items.IsLibraryFolder()) AddPlaylistOrder(items, LABEL_MASKS("%Z - %H. %T", "%R")); // TvShow - Order. Title, Rating | empty, empty else { diff --git a/xbmc/video/windows/GUIWindowVideoNav.cpp b/xbmc/video/windows/GUIWindowVideoNav.cpp index c107e2e666..bcba55540f 100644 --- a/xbmc/video/windows/GUIWindowVideoNav.cpp +++ b/xbmc/video/windows/GUIWindowVideoNav.cpp @@ -1699,7 +1699,7 @@ bool CGUIWindowVideoNav::ApplyWatchedFilter(CFileItemList &items) if (!items.IsVideoDb()) filterWatched = true; if (items.GetContent() == "tvshows" && - (items.IsSmartPlayList() || (items.HasProperty("library.filter") && items.GetProperty("library.filter").asBoolean()))) + (items.IsSmartPlayList() || items.IsLibraryFolder())) node = NODE_TYPE_TITLE_TVSHOWS; // so that the check below works int watchMode = CMediaSettings::Get().GetWatchedMode(m_vecItems->GetContent()); diff --git a/xbmc/view/GUIViewState.cpp b/xbmc/view/GUIViewState.cpp index 95c8a9a057..e2f8677b14 100644 --- a/xbmc/view/GUIViewState.cpp +++ b/xbmc/view/GUIViewState.cpp @@ -82,7 +82,7 @@ CGUIViewState* CGUIViewState::GetViewState(int windowId, const CFileItemList& it return new CGUIViewStateMusicSearch(items); if (items.IsSmartPlayList() || url.GetProtocol() == "upnp" || - items.GetProperty("library.filter").asBoolean()) + items.IsLibraryFolder()) { if (items.GetContent() == "songs" || items.GetContent() == "albums" || -- cgit v1.2.3 From bff7a8f20aef34d1db84b1c4705ce45ab590be81 Mon Sep 17 00:00:00 2001 From: montellese Date: Sun, 21 Jul 2013 22:17:43 +0200 Subject: video: fix "Set content" showing for library folders (genres etc.) --- xbmc/video/windows/GUIWindowVideoNav.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xbmc/video/windows/GUIWindowVideoNav.cpp b/xbmc/video/windows/GUIWindowVideoNav.cpp index bcba55540f..3590de664f 100644 --- a/xbmc/video/windows/GUIWindowVideoNav.cpp +++ b/xbmc/video/windows/GUIWindowVideoNav.cpp @@ -1052,7 +1052,7 @@ void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &butt buttons.Add(CONTEXT_BUTTON_RENAME, 118); } // add "Set/Change content" to folders - if (item->m_bIsFolder && !item->IsPlayList() && !item->IsSmartPlayList() && !item->IsLiveTV() && !item->IsPlugin() && !item->IsAddonsPath() && !URIUtils::IsUPnP(item->GetPath())) + if (item->m_bIsFolder && !item->IsVideoDb() && !item->IsPlayList() && !item->IsSmartPlayList() && !item->IsLibraryFolder() && !item->IsLiveTV() && !item->IsPlugin() && !item->IsAddonsPath() && !URIUtils::IsUPnP(item->GetPath())) { if (!g_application.IsVideoScanning()) { -- cgit v1.2.3 From 5e2f1e45691ccedfda9194ef02e71603e664df69 Mon Sep 17 00:00:00 2001 From: montellese Date: Sun, 21 Jul 2013 23:09:05 +0200 Subject: CFileItem: extend GetVideoContentType() to detect movie sets --- xbmc/FileItem.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/xbmc/FileItem.cpp b/xbmc/FileItem.cpp index 015eb1c91a..341a295cba 100644 --- a/xbmc/FileItem.cpp +++ b/xbmc/FileItem.cpp @@ -31,6 +31,7 @@ #include "filesystem/MultiPathDirectory.h" #include "filesystem/MusicDatabaseDirectory.h" #include "filesystem/VideoDatabaseDirectory.h" +#include "filesystem/VideoDatabaseDirectory/QueryParams.h" #include "music/tags/MusicInfoTagLoaderFactory.h" #include "CueDocument.h" #include "video/VideoDatabase.h" @@ -3272,9 +3273,16 @@ int CFileItem::GetVideoContentType() const if (HasVideoInfoTag() && !GetVideoInfoTag()->m_strShowTitle.IsEmpty()) // tvshow type = VIDEODB_CONTENT_TVSHOWS; if (HasVideoInfoTag() && GetVideoInfoTag()->m_iSeason > -1 && !m_bIsFolder) // episode - type = VIDEODB_CONTENT_EPISODES; - if (HasVideoInfoTag() && !GetVideoInfoTag()->m_artist.empty()) - type = VIDEODB_CONTENT_MUSICVIDEOS; + return VIDEODB_CONTENT_EPISODES; + if (HasVideoInfoTag() && !GetVideoInfoTag()->m_artist.empty()) // music video + return VIDEODB_CONTENT_MUSICVIDEOS; + + CVideoDatabaseDirectory dir; + VIDEODATABASEDIRECTORY::CQueryParams params; + dir.GetQueryParams(m_strPath, params); + if (params.GetSetId() != -1 && params.GetMovieId() == -1) // movie set + return VIDEODB_CONTENT_MOVIE_SETS; + return type; } -- cgit v1.2.3 From b73b7fe2f5e1c0f81f51f5eff104f1bd2a54b70e Mon Sep 17 00:00:00 2001 From: montellese Date: Sun, 21 Jul 2013 23:18:01 +0200 Subject: CVideoDatabase: refactor SetDetail() into SetSingleValue() --- xbmc/video/VideoDatabase.cpp | 33 +++++++++++++++++++------------ xbmc/video/VideoDatabase.h | 3 ++- xbmc/video/dialogs/GUIDialogVideoInfo.cpp | 6 +++--- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/xbmc/video/VideoDatabase.cpp b/xbmc/video/VideoDatabase.cpp index 2d268d4944..0571568721 100644 --- a/xbmc/video/VideoDatabase.cpp +++ b/xbmc/video/VideoDatabase.cpp @@ -9146,42 +9146,49 @@ bool CVideoDatabase::CommitTransaction() return false; } -void CVideoDatabase::SetDetail(const CStdString& strDetail, int id, int field, - VIDEODB_CONTENT_TYPE type) +bool CVideoDatabase::SetSingleValue(VIDEODB_CONTENT_TYPE type, int dbId, int dbField, const std::string &strValue) { + string strSQL; try { - if (NULL == m_pDB.get()) return; - if (NULL == m_pDS.get()) return; + if (NULL == m_pDB.get() || NULL == m_pDS.get()) + return false; - CStdString strTable, strField; + string strTable, strField; if (type == VIDEODB_CONTENT_MOVIES) { strTable = "movie"; strField = "idMovie"; } - if (type == VIDEODB_CONTENT_TVSHOWS) + else if (type == VIDEODB_CONTENT_TVSHOWS) { strTable = "tvshow"; strField = "idShow"; } - if (type == VIDEODB_CONTENT_MUSICVIDEOS) + else if (type == VIDEODB_CONTENT_EPISODES) + { + strTable = "episode"; + strField = "idEpisode"; + } + else if (type == VIDEODB_CONTENT_MUSICVIDEOS) { strTable = "musicvideo"; strField = "idMVideo"; } - if (strTable.IsEmpty()) - return; + if (strTable.empty()) + return false; - CStdString strSQL = PrepareSQL("update %s set c%02u='%s' where %s=%u", - strTable.c_str(), field, strDetail.c_str(), strField.c_str(), id); - m_pDS->exec(strSQL.c_str()); + strSQL = PrepareSQL("UPDATE %s SET c%02u='%s' WHERE %s=%u", + strTable.c_str(), dbField, strValue.c_str(), strField.c_str(), dbId); + if (m_pDS->exec(strSQL.c_str()) == 0) + return true; } catch (...) { - CLog::Log(LOGERROR, "%s failed", __FUNCTION__); + CLog::Log(LOGERROR, "%s (%s) failed", __FUNCTION__, strSQL.c_str()); } + return false; } CStdString CVideoDatabase::GetSafeFile(const CStdString &dir, const CStdString &name) const diff --git a/xbmc/video/VideoDatabase.h b/xbmc/video/VideoDatabase.h index b07c78a3b8..a97d0de06a 100644 --- a/xbmc/video/VideoDatabase.h +++ b/xbmc/video/VideoDatabase.h @@ -449,7 +449,8 @@ public: int SetDetailsForMusicVideo(const CStdString& strFilenameAndPath, const CVideoInfoTag& details, const std::map &artwork, int idMVideo = -1); void SetStreamDetailsForFile(const CStreamDetails& details, const CStdString &strFileNameAndPath); void SetStreamDetailsForFileId(const CStreamDetails& details, int idFile); - void SetDetail(const CStdString& strDetail, int id, int field, VIDEODB_CONTENT_TYPE type); + + bool SetSingleValue(VIDEODB_CONTENT_TYPE type, int dbId, int dbField, const std::string &strValue); void DeleteMovie(int idMovie, bool bKeepId = false); void DeleteMovie(const CStdString& strFilenameAndPath, bool bKeepId = false, int idMovie = -1); diff --git a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp index 2833f1813c..0d34f5d387 100644 --- a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp @@ -342,9 +342,9 @@ void CGUIDialogVideoInfo::SetMovie(const CFileItem *item) CVideoDatabase database; if(database.Open()) { - database.SetDetail(m_movieItem->GetVideoInfoTag()->m_strTrailer, - m_movieItem->GetVideoInfoTag()->m_iDbId, - VIDEODB_ID_TRAILER, VIDEODB_CONTENT_MOVIES); + database.SetSingleValue(VIDEODB_CONTENT_MOVIES, VIDEODB_ID_TRAILER, + m_movieItem->GetVideoInfoTag()->m_iDbId, + m_movieItem->GetVideoInfoTag()->m_strTrailer); database.Close(); CUtil::DeleteVideoDatabaseDirectoryCache(); } -- cgit v1.2.3 From 27c9c545f9fc756206e629397008bdc29b866d6b Mon Sep 17 00:00:00 2001 From: montellese Date: Mon, 22 Jul 2013 00:01:37 +0200 Subject: DatabaseUtils: add GetField() and MediaTypeFromVideoContentType() --- xbmc/utils/DatabaseUtils.cpp | 399 ++++++++++++++++++++++++------------------- xbmc/utils/DatabaseUtils.h | 5 + 2 files changed, 232 insertions(+), 172 deletions(-) diff --git a/xbmc/utils/DatabaseUtils.cpp b/xbmc/utils/DatabaseUtils.cpp index cd8b6a774b..44f60a7955 100644 --- a/xbmc/utils/DatabaseUtils.cpp +++ b/xbmc/utils/DatabaseUtils.cpp @@ -84,6 +84,33 @@ MediaType DatabaseUtils::MediaTypeFromString(const std::string &strMediaType) return MediaTypeNone; } +MediaType DatabaseUtils::MediaTypeFromVideoContentType(int videoContentType) +{ + VIDEODB_CONTENT_TYPE type = (VIDEODB_CONTENT_TYPE)videoContentType; + switch (type) + { + case VIDEODB_CONTENT_MOVIES: + return MediaTypeMovie; + + case VIDEODB_CONTENT_MOVIE_SETS: + return MediaTypeVideoCollection; + + case VIDEODB_CONTENT_TVSHOWS: + return MediaTypeTvShow; + + case VIDEODB_CONTENT_EPISODES: + return MediaTypeEpisode; + + case VIDEODB_CONTENT_MUSICVIDEOS: + return MediaTypeMusicVideo; + + default: + break; + } + + return MediaTypeNone; +} + std::string DatabaseUtils::GetField(Field field, MediaType mediaType, DatabaseQueryPart queryPart) { if (field == FieldNone || mediaType == MediaTypeNone) @@ -275,184 +302,20 @@ std::string DatabaseUtils::GetField(Field field, MediaType mediaType, DatabaseQu return ""; } -int DatabaseUtils::GetFieldIndex(Field field, MediaType mediaType) +int DatabaseUtils::GetField(Field field, MediaType mediaType) { if (field == FieldNone || mediaType == MediaTypeNone) return -1; - int index = -1; - - if (mediaType == MediaTypeAlbum) - { - if (field == FieldId) return CMusicDatabase::album_idAlbum; - else if (field == FieldAlbum) return CMusicDatabase::album_strAlbum; - else if (field == FieldArtist || field == FieldAlbumArtist) return CMusicDatabase::album_strArtists; - else if (field == FieldGenre) return CMusicDatabase::album_strGenres; - else if (field == FieldYear) return CMusicDatabase::album_iYear; - else if (field == FieldMoods) return CMusicDatabase::album_strMoods; - else if (field == FieldStyles) return CMusicDatabase::album_strStyles; - else if (field == FieldThemes) return CMusicDatabase::album_strThemes; - else if (field == FieldReview) return CMusicDatabase::album_strReview; - else if (field == FieldMusicLabel) return CMusicDatabase::album_strLabel; - else if (field == FieldAlbumType) return CMusicDatabase::album_strType; - else if (field == FieldRating) return CMusicDatabase::album_iRating; - else if (field == FieldPlaycount) return CMusicDatabase::album_iTimesPlayed; - } - else if (mediaType == MediaTypeSong) - { - if (field == FieldId) return CMusicDatabase::song_idSong; - else if (field == FieldTitle) return CMusicDatabase::song_strTitle; - else if (field == FieldTrackNumber) return CMusicDatabase::song_iTrack; - else if (field == FieldTime) return CMusicDatabase::song_iDuration; - else if (field == FieldYear) return CMusicDatabase::song_iYear; - else if (field == FieldFilename) return CMusicDatabase::song_strFileName; - else if (field == FieldPlaycount) return CMusicDatabase::song_iTimesPlayed; - else if (field == FieldStartOffset) return CMusicDatabase::song_iStartOffset; - else if (field == FieldEndOffset) return CMusicDatabase::song_iEndOffset; - else if (field == FieldLastPlayed) return CMusicDatabase::song_lastplayed; - else if (field == FieldRating) return CMusicDatabase::song_rating; - else if (field == FieldComment) return CMusicDatabase::song_comment; - else if (field == FieldAlbum) return CMusicDatabase::song_strAlbum; - else if (field == FieldPath) return CMusicDatabase::song_strPath; - else if (field == FieldGenre) return CMusicDatabase::song_strGenres; - else if (field == FieldArtist || field == FieldAlbumArtist) return CMusicDatabase::song_strArtists; - } - else if (mediaType == MediaTypeArtist) - { - if (field == FieldId) return CMusicDatabase::artist_idArtist; - else if (field == FieldArtist) return CMusicDatabase::artist_strArtist; - else if (field == FieldGenre) return CMusicDatabase::artist_strGenres; - else if (field == FieldMoods) return CMusicDatabase::artist_strMoods; - else if (field == FieldStyles) return CMusicDatabase::artist_strStyles; - else if (field == FieldInstruments) return CMusicDatabase::artist_strInstruments; - else if (field == FieldBiography) return CMusicDatabase::artist_strBiography; - else if (field == FieldBorn) return CMusicDatabase::artist_strBorn; - else if (field == FieldBandFormed) return CMusicDatabase::artist_strFormed; - else if (field == FieldDisbanded) return CMusicDatabase::artist_strDisbanded; - else if (field == FieldDied) return CMusicDatabase::artist_strDied; - } - else if (mediaType == MediaTypeMusicVideo) - { - if (field == FieldId) return 0; - else if (field == FieldTitle) index = VIDEODB_ID_MUSICVIDEO_TITLE; - else if (field == FieldTime) index = VIDEODB_ID_MUSICVIDEO_RUNTIME; - else if (field == FieldDirector) index = VIDEODB_ID_MUSICVIDEO_DIRECTOR; - else if (field == FieldStudio) index = VIDEODB_ID_MUSICVIDEO_STUDIOS; - else if (field == FieldYear) index = VIDEODB_ID_MUSICVIDEO_YEAR; - else if (field == FieldPlot) index = VIDEODB_ID_MUSICVIDEO_PLOT; - else if (field == FieldAlbum) index = VIDEODB_ID_MUSICVIDEO_ALBUM; - else if (field == FieldArtist) index = VIDEODB_ID_MUSICVIDEO_ARTIST; - else if (field == FieldGenre) index = VIDEODB_ID_MUSICVIDEO_GENRE; - else if (field == FieldTrackNumber) index = VIDEODB_ID_MUSICVIDEO_TRACK; - else if (field == FieldFilename) return VIDEODB_DETAILS_MUSICVIDEO_FILE; - else if (field == FieldPath) return VIDEODB_DETAILS_MUSICVIDEO_PATH; - else if (field == FieldPlaycount) return VIDEODB_DETAILS_MUSICVIDEO_PLAYCOUNT; - else if (field == FieldLastPlayed) return VIDEODB_DETAILS_MUSICVIDEO_LASTPLAYED; - else if (field == FieldDateAdded) return VIDEODB_DETAILS_MUSICVIDEO_DATEADDED; - - if (index < 0) - return index; - - // see VideoDatabase.h - // the first field is the item's ID and the second is the item's file ID - index += 2; - } - else if (mediaType == MediaTypeMovie) - { - if (field == FieldId) return 0; - else if (field == FieldTitle) index = VIDEODB_ID_TITLE; - else if (field == FieldSortTitle) index = VIDEODB_ID_SORTTITLE; - else if (field == FieldPlot) index = VIDEODB_ID_PLOT; - else if (field == FieldPlotOutline) index = VIDEODB_ID_PLOTOUTLINE; - else if (field == FieldTagline) index = VIDEODB_ID_TAGLINE; - else if (field == FieldVotes) index = VIDEODB_ID_VOTES; - else if (field == FieldRating) index = VIDEODB_ID_RATING; - else if (field == FieldWriter) index = VIDEODB_ID_CREDITS; - else if (field == FieldYear) index = VIDEODB_ID_YEAR; - else if (field == FieldTime) index = VIDEODB_ID_RUNTIME; - else if (field == FieldMPAA) index = VIDEODB_ID_MPAA; - else if (field == FieldTop250) index = VIDEODB_ID_TOP250; - else if (field == FieldSet) return VIDEODB_DETAILS_MOVIE_SET_NAME; - else if (field == FieldGenre) index = VIDEODB_ID_GENRE; - else if (field == FieldDirector) index = VIDEODB_ID_DIRECTOR; - else if (field == FieldStudio) index = VIDEODB_ID_STUDIOS; - else if (field == FieldTrailer) index = VIDEODB_ID_TRAILER; - else if (field == FieldCountry) index = VIDEODB_ID_COUNTRY; - else if (field == FieldFilename) index = VIDEODB_DETAILS_MOVIE_FILE; - else if (field == FieldPath) return VIDEODB_DETAILS_MOVIE_PATH; - else if (field == FieldPlaycount) return VIDEODB_DETAILS_MOVIE_PLAYCOUNT; - else if (field == FieldLastPlayed) return VIDEODB_DETAILS_MOVIE_LASTPLAYED; - else if (field == FieldDateAdded) return VIDEODB_DETAILS_MOVIE_DATEADDED; - - if (index < 0) - return index; - - // see VideoDatabase.h - // the first field is the item's ID and the second is the item's file ID - index += 2; - } - else if (mediaType == MediaTypeTvShow) - { - if (field == FieldId) return 0; - else if (field == FieldTitle) index = VIDEODB_ID_TV_TITLE; - else if (field == FieldSortTitle) index = VIDEODB_ID_TV_SORTTITLE; - else if (field == FieldPlot) index = VIDEODB_ID_TV_PLOT; - else if (field == FieldTvShowStatus) index = VIDEODB_ID_TV_STATUS; - else if (field == FieldVotes) index = VIDEODB_ID_TV_VOTES; - else if (field == FieldRating) index = VIDEODB_ID_TV_RATING; - else if (field == FieldYear) index = VIDEODB_ID_TV_PREMIERED; - else if (field == FieldGenre) index = VIDEODB_ID_TV_GENRE; - else if (field == FieldMPAA) index = VIDEODB_ID_TV_MPAA; - else if (field == FieldStudio) index = VIDEODB_ID_TV_STUDIOS; - else if (field == FieldPath) return VIDEODB_DETAILS_TVSHOW_PATH; - else if (field == FieldDateAdded) return VIDEODB_DETAILS_TVSHOW_DATEADDED; - else if (field == FieldLastPlayed) return VIDEODB_DETAILS_TVSHOW_LASTPLAYED; - else if (field == FieldNumberOfEpisodes) return VIDEODB_DETAILS_TVSHOW_NUM_EPISODES; - else if (field == FieldNumberOfWatchedEpisodes) return VIDEODB_DETAILS_TVSHOW_NUM_WATCHED; - else if (field == FieldSeason) return VIDEODB_DETAILS_TVSHOW_NUM_SEASONS; - - if (index < 0) - return index; - - // see VideoDatabase.h - // the first field is the item's ID - index += 1; - } - else if (mediaType == MediaTypeEpisode) - { - if (field == FieldId) return 0; - else if (field == FieldTitle) index = VIDEODB_ID_EPISODE_TITLE; - else if (field == FieldPlot) index = VIDEODB_ID_EPISODE_PLOT; - else if (field == FieldVotes) index = VIDEODB_ID_EPISODE_VOTES; - else if (field == FieldRating) index = VIDEODB_ID_EPISODE_RATING; - else if (field == FieldWriter) index = VIDEODB_ID_EPISODE_CREDITS; - else if (field == FieldAirDate) index = VIDEODB_ID_EPISODE_AIRED; - else if (field == FieldTime) index = VIDEODB_ID_EPISODE_RUNTIME; - else if (field == FieldDirector) index = VIDEODB_ID_EPISODE_DIRECTOR; - else if (field == FieldSeason) index = VIDEODB_ID_EPISODE_SEASON; - else if (field == FieldEpisodeNumber) index = VIDEODB_ID_EPISODE_EPISODE; - else if (field == FieldUniqueId) index = VIDEODB_ID_EPISODE_UNIQUEID; - else if (field == FieldEpisodeNumberSpecialSort) index = VIDEODB_ID_EPISODE_SORTEPISODE; - else if (field == FieldSeasonSpecialSort) index = VIDEODB_ID_EPISODE_SORTSEASON; - else if (field == FieldFilename) return VIDEODB_DETAILS_EPISODE_FILE; - else if (field == FieldPath) return VIDEODB_DETAILS_EPISODE_PATH; - else if (field == FieldPlaycount) return VIDEODB_DETAILS_EPISODE_PLAYCOUNT; - else if (field == FieldLastPlayed) return VIDEODB_DETAILS_EPISODE_LASTPLAYED; - else if (field == FieldDateAdded) return VIDEODB_DETAILS_EPISODE_DATEADDED; - else if (field == FieldTvShowTitle) return VIDEODB_DETAILS_EPISODE_TVSHOW_NAME; - else if (field == FieldStudio) return VIDEODB_DETAILS_EPISODE_TVSHOW_STUDIO; - else if (field == FieldYear) return VIDEODB_DETAILS_EPISODE_TVSHOW_AIRED; - else if (field == FieldMPAA) return VIDEODB_DETAILS_EPISODE_TVSHOW_MPAA; - - if (index < 0) - return index; + return GetField(field, mediaType, false); +} - // see VideoDatabase.h - // the first field is the item's ID and the second is the item's file ID - index += 2; - } +int DatabaseUtils::GetFieldIndex(Field field, MediaType mediaType) +{ + if (field == FieldNone || mediaType == MediaTypeNone) + return -1; - return index; + return GetField(field, mediaType, true); } bool DatabaseUtils::GetSelectFields(const Fields &fields, MediaType mediaType, FieldList &selectFields) @@ -674,3 +537,195 @@ std::string DatabaseUtils::BuildLimitClause(int end, int start /* = 0 */) return sql.str(); } + +int DatabaseUtils::GetField(Field field, MediaType mediaType, bool asIndex) +{ + if (field == FieldNone || mediaType == MediaTypeNone) + return -1; + + int index = -1; + + if (mediaType == MediaTypeAlbum) + { + if (field == FieldId) return CMusicDatabase::album_idAlbum; + else if (field == FieldAlbum) return CMusicDatabase::album_strAlbum; + else if (field == FieldArtist || field == FieldAlbumArtist) return CMusicDatabase::album_strArtists; + else if (field == FieldGenre) return CMusicDatabase::album_strGenres; + else if (field == FieldYear) return CMusicDatabase::album_iYear; + else if (field == FieldMoods) return CMusicDatabase::album_strMoods; + else if (field == FieldStyles) return CMusicDatabase::album_strStyles; + else if (field == FieldThemes) return CMusicDatabase::album_strThemes; + else if (field == FieldReview) return CMusicDatabase::album_strReview; + else if (field == FieldMusicLabel) return CMusicDatabase::album_strLabel; + else if (field == FieldAlbumType) return CMusicDatabase::album_strType; + else if (field == FieldRating) return CMusicDatabase::album_iRating; + else if (field == FieldPlaycount) return CMusicDatabase::album_iTimesPlayed; + } + else if (mediaType == MediaTypeSong) + { + if (field == FieldId) return CMusicDatabase::song_idSong; + else if (field == FieldTitle) return CMusicDatabase::song_strTitle; + else if (field == FieldTrackNumber) return CMusicDatabase::song_iTrack; + else if (field == FieldTime) return CMusicDatabase::song_iDuration; + else if (field == FieldYear) return CMusicDatabase::song_iYear; + else if (field == FieldFilename) return CMusicDatabase::song_strFileName; + else if (field == FieldPlaycount) return CMusicDatabase::song_iTimesPlayed; + else if (field == FieldStartOffset) return CMusicDatabase::song_iStartOffset; + else if (field == FieldEndOffset) return CMusicDatabase::song_iEndOffset; + else if (field == FieldLastPlayed) return CMusicDatabase::song_lastplayed; + else if (field == FieldRating) return CMusicDatabase::song_rating; + else if (field == FieldComment) return CMusicDatabase::song_comment; + else if (field == FieldAlbum) return CMusicDatabase::song_strAlbum; + else if (field == FieldPath) return CMusicDatabase::song_strPath; + else if (field == FieldGenre) return CMusicDatabase::song_strGenres; + else if (field == FieldArtist || field == FieldAlbumArtist) return CMusicDatabase::song_strArtists; + } + else if (mediaType == MediaTypeArtist) + { + if (field == FieldId) return CMusicDatabase::artist_idArtist; + else if (field == FieldArtist) return CMusicDatabase::artist_strArtist; + else if (field == FieldGenre) return CMusicDatabase::artist_strGenres; + else if (field == FieldMoods) return CMusicDatabase::artist_strMoods; + else if (field == FieldStyles) return CMusicDatabase::artist_strStyles; + else if (field == FieldInstruments) return CMusicDatabase::artist_strInstruments; + else if (field == FieldBiography) return CMusicDatabase::artist_strBiography; + else if (field == FieldBorn) return CMusicDatabase::artist_strBorn; + else if (field == FieldBandFormed) return CMusicDatabase::artist_strFormed; + else if (field == FieldDisbanded) return CMusicDatabase::artist_strDisbanded; + else if (field == FieldDied) return CMusicDatabase::artist_strDied; + } + else if (mediaType == MediaTypeMusicVideo) + { + if (field == FieldId) return 0; + else if (field == FieldTitle) index = VIDEODB_ID_MUSICVIDEO_TITLE; + else if (field == FieldTime) index = VIDEODB_ID_MUSICVIDEO_RUNTIME; + else if (field == FieldDirector) index = VIDEODB_ID_MUSICVIDEO_DIRECTOR; + else if (field == FieldStudio) index = VIDEODB_ID_MUSICVIDEO_STUDIOS; + else if (field == FieldYear) index = VIDEODB_ID_MUSICVIDEO_YEAR; + else if (field == FieldPlot) index = VIDEODB_ID_MUSICVIDEO_PLOT; + else if (field == FieldAlbum) index = VIDEODB_ID_MUSICVIDEO_ALBUM; + else if (field == FieldArtist) index = VIDEODB_ID_MUSICVIDEO_ARTIST; + else if (field == FieldGenre) index = VIDEODB_ID_MUSICVIDEO_GENRE; + else if (field == FieldTrackNumber) index = VIDEODB_ID_MUSICVIDEO_TRACK; + else if (field == FieldFilename) return VIDEODB_DETAILS_MUSICVIDEO_FILE; + else if (field == FieldPath) return VIDEODB_DETAILS_MUSICVIDEO_PATH; + else if (field == FieldPlaycount) return VIDEODB_DETAILS_MUSICVIDEO_PLAYCOUNT; + else if (field == FieldLastPlayed) return VIDEODB_DETAILS_MUSICVIDEO_LASTPLAYED; + else if (field == FieldDateAdded) return VIDEODB_DETAILS_MUSICVIDEO_DATEADDED; + + if (index < 0) + return index; + + if (asIndex) + { + // see VideoDatabase.h + // the first field is the item's ID and the second is the item's file ID + index += 2; + } + } + else if (mediaType == MediaTypeMovie) + { + if (field == FieldId) return 0; + else if (field == FieldTitle) index = VIDEODB_ID_TITLE; + else if (field == FieldSortTitle) index = VIDEODB_ID_SORTTITLE; + else if (field == FieldPlot) index = VIDEODB_ID_PLOT; + else if (field == FieldPlotOutline) index = VIDEODB_ID_PLOTOUTLINE; + else if (field == FieldTagline) index = VIDEODB_ID_TAGLINE; + else if (field == FieldVotes) index = VIDEODB_ID_VOTES; + else if (field == FieldRating) index = VIDEODB_ID_RATING; + else if (field == FieldWriter) index = VIDEODB_ID_CREDITS; + else if (field == FieldYear) index = VIDEODB_ID_YEAR; + else if (field == FieldTime) index = VIDEODB_ID_RUNTIME; + else if (field == FieldMPAA) index = VIDEODB_ID_MPAA; + else if (field == FieldTop250) index = VIDEODB_ID_TOP250; + else if (field == FieldSet) return VIDEODB_DETAILS_MOVIE_SET_NAME; + else if (field == FieldGenre) index = VIDEODB_ID_GENRE; + else if (field == FieldDirector) index = VIDEODB_ID_DIRECTOR; + else if (field == FieldStudio) index = VIDEODB_ID_STUDIOS; + else if (field == FieldTrailer) index = VIDEODB_ID_TRAILER; + else if (field == FieldCountry) index = VIDEODB_ID_COUNTRY; + else if (field == FieldFilename) index = VIDEODB_DETAILS_MOVIE_FILE; + else if (field == FieldPath) return VIDEODB_DETAILS_MOVIE_PATH; + else if (field == FieldPlaycount) return VIDEODB_DETAILS_MOVIE_PLAYCOUNT; + else if (field == FieldLastPlayed) return VIDEODB_DETAILS_MOVIE_LASTPLAYED; + else if (field == FieldDateAdded) return VIDEODB_DETAILS_MOVIE_DATEADDED; + + if (index < 0) + return index; + + if (asIndex) + { + // see VideoDatabase.h + // the first field is the item's ID and the second is the item's file ID + index += 2; + } + } + else if (mediaType == MediaTypeTvShow) + { + if (field == FieldId) return 0; + else if (field == FieldTitle) index = VIDEODB_ID_TV_TITLE; + else if (field == FieldSortTitle) index = VIDEODB_ID_TV_SORTTITLE; + else if (field == FieldPlot) index = VIDEODB_ID_TV_PLOT; + else if (field == FieldTvShowStatus) index = VIDEODB_ID_TV_STATUS; + else if (field == FieldVotes) index = VIDEODB_ID_TV_VOTES; + else if (field == FieldRating) index = VIDEODB_ID_TV_RATING; + else if (field == FieldYear) index = VIDEODB_ID_TV_PREMIERED; + else if (field == FieldGenre) index = VIDEODB_ID_TV_GENRE; + else if (field == FieldMPAA) index = VIDEODB_ID_TV_MPAA; + else if (field == FieldStudio) index = VIDEODB_ID_TV_STUDIOS; + else if (field == FieldPath) return VIDEODB_DETAILS_TVSHOW_PATH; + else if (field == FieldDateAdded) return VIDEODB_DETAILS_TVSHOW_DATEADDED; + else if (field == FieldLastPlayed) return VIDEODB_DETAILS_TVSHOW_LASTPLAYED; + else if (field == FieldNumberOfEpisodes) return VIDEODB_DETAILS_TVSHOW_NUM_EPISODES; + else if (field == FieldNumberOfWatchedEpisodes) return VIDEODB_DETAILS_TVSHOW_NUM_WATCHED; + else if (field == FieldSeason) return VIDEODB_DETAILS_TVSHOW_NUM_SEASONS; + + if (index < 0) + return index; + + if (asIndex) + { + // see VideoDatabase.h + // the first field is the item's ID + index += 1; + } + } + else if (mediaType == MediaTypeEpisode) + { + if (field == FieldId) return 0; + else if (field == FieldTitle) index = VIDEODB_ID_EPISODE_TITLE; + else if (field == FieldPlot) index = VIDEODB_ID_EPISODE_PLOT; + else if (field == FieldVotes) index = VIDEODB_ID_EPISODE_VOTES; + else if (field == FieldRating) index = VIDEODB_ID_EPISODE_RATING; + else if (field == FieldWriter) index = VIDEODB_ID_EPISODE_CREDITS; + else if (field == FieldAirDate) index = VIDEODB_ID_EPISODE_AIRED; + else if (field == FieldTime) index = VIDEODB_ID_EPISODE_RUNTIME; + else if (field == FieldDirector) index = VIDEODB_ID_EPISODE_DIRECTOR; + else if (field == FieldSeason) index = VIDEODB_ID_EPISODE_SEASON; + else if (field == FieldEpisodeNumber) index = VIDEODB_ID_EPISODE_EPISODE; + else if (field == FieldUniqueId) index = VIDEODB_ID_EPISODE_UNIQUEID; + else if (field == FieldEpisodeNumberSpecialSort) index = VIDEODB_ID_EPISODE_SORTEPISODE; + else if (field == FieldSeasonSpecialSort) index = VIDEODB_ID_EPISODE_SORTSEASON; + else if (field == FieldFilename) return VIDEODB_DETAILS_EPISODE_FILE; + else if (field == FieldPath) return VIDEODB_DETAILS_EPISODE_PATH; + else if (field == FieldPlaycount) return VIDEODB_DETAILS_EPISODE_PLAYCOUNT; + else if (field == FieldLastPlayed) return VIDEODB_DETAILS_EPISODE_LASTPLAYED; + else if (field == FieldDateAdded) return VIDEODB_DETAILS_EPISODE_DATEADDED; + else if (field == FieldTvShowTitle) return VIDEODB_DETAILS_EPISODE_TVSHOW_NAME; + else if (field == FieldStudio) return VIDEODB_DETAILS_EPISODE_TVSHOW_STUDIO; + else if (field == FieldYear) return VIDEODB_DETAILS_EPISODE_TVSHOW_AIRED; + else if (field == FieldMPAA) return VIDEODB_DETAILS_EPISODE_TVSHOW_MPAA; + + if (index < 0) + return index; + + if (asIndex) + { + // see VideoDatabase.h + // the first field is the item's ID and the second is the item's file ID + index += 2; + } + } + + return index; +} diff --git a/xbmc/utils/DatabaseUtils.h b/xbmc/utils/DatabaseUtils.h index 67e6e761dc..e59b7600f9 100644 --- a/xbmc/utils/DatabaseUtils.h +++ b/xbmc/utils/DatabaseUtils.h @@ -154,8 +154,10 @@ class DatabaseUtils public: static std::string MediaTypeToString(MediaType mediaType); static MediaType MediaTypeFromString(const std::string &strMediaType); + static MediaType MediaTypeFromVideoContentType(int videoContentType); static std::string GetField(Field field, MediaType mediaType, DatabaseQueryPart queryPart); + static int GetField(Field field, MediaType mediaType); static int GetFieldIndex(Field field, MediaType mediaType); static bool GetSelectFields(const Fields &fields, MediaType mediaType, FieldList &selectFields); @@ -163,4 +165,7 @@ public: static bool GetDatabaseResults(MediaType mediaType, const FieldList &fields, const std::auto_ptr &dataset, DatabaseResults &results); static std::string BuildLimitClause(int end, int start = 0); + +private: + static int GetField(Field field, MediaType mediaType, bool asIndex); }; -- cgit v1.2.3 From ce2b3bdcdf7e3b17d46ebbebcfabc7bf46a6b632 Mon Sep 17 00:00:00 2001 From: montellese Date: Mon, 22 Jul 2013 00:02:24 +0200 Subject: CVideoDatabase: add SetSingleValue() overloads --- xbmc/video/VideoDatabase.cpp | 57 ++++++++++++++++++++++++++++++++++---------- xbmc/video/VideoDatabase.h | 3 +++ 2 files changed, 48 insertions(+), 12 deletions(-) diff --git a/xbmc/video/VideoDatabase.cpp b/xbmc/video/VideoDatabase.cpp index 0571568721..8f5b2b2523 100644 --- a/xbmc/video/VideoDatabase.cpp +++ b/xbmc/video/VideoDatabase.cpp @@ -4702,40 +4702,38 @@ void CVideoDatabase::UpdateMovieTitle(int idMovie, const CStdString& strNewMovie if (NULL == m_pDB.get()) return ; if (NULL == m_pDS.get()) return ; CStdString content; - CStdString strSQL; if (iType == VIDEODB_CONTENT_MOVIES) { CLog::Log(LOGINFO, "Changing Movie:id:%i New Title:%s", idMovie, strNewMovieTitle.c_str()); - strSQL = PrepareSQL("UPDATE movie SET c%02d='%s' WHERE idMovie=%i", VIDEODB_ID_TITLE, strNewMovieTitle.c_str(), idMovie ); content = "movie"; } else if (iType == VIDEODB_CONTENT_EPISODES) { CLog::Log(LOGINFO, "Changing Episode:id:%i New Title:%s", idMovie, strNewMovieTitle.c_str()); - strSQL = PrepareSQL("UPDATE episode SET c%02d='%s' WHERE idEpisode=%i", VIDEODB_ID_EPISODE_TITLE, strNewMovieTitle.c_str(), idMovie ); content = "episode"; } else if (iType == VIDEODB_CONTENT_TVSHOWS) { CLog::Log(LOGINFO, "Changing TvShow:id:%i New Title:%s", idMovie, strNewMovieTitle.c_str()); - strSQL = PrepareSQL("UPDATE tvshow SET c%02d='%s' WHERE idShow=%i", VIDEODB_ID_TV_TITLE, strNewMovieTitle.c_str(), idMovie ); content = "tvshow"; } else if (iType == VIDEODB_CONTENT_MUSICVIDEOS) { CLog::Log(LOGINFO, "Changing MusicVideo:id:%i New Title:%s", idMovie, strNewMovieTitle.c_str()); - strSQL = PrepareSQL("UPDATE musicvideo SET c%02d='%s' WHERE idMVideo=%i", VIDEODB_ID_MUSICVIDEO_TITLE, strNewMovieTitle.c_str(), idMovie ); content = "musicvideo"; } else if (iType == VIDEODB_CONTENT_MOVIE_SETS) { CLog::Log(LOGINFO, "Changing Movie set:id:%i New Title:%s", idMovie, strNewMovieTitle.c_str()); - strSQL = PrepareSQL("UPDATE sets SET strSet='%s' WHERE idSet=%i", strNewMovieTitle.c_str(), idMovie ); + CStdString strSQL = PrepareSQL("UPDATE sets SET strSet='%s' WHERE idSet=%i", strNewMovieTitle.c_str(), idMovie ); + m_pDS->exec(strSQL.c_str()); } - m_pDS->exec(strSQL.c_str()); - if (content.size() > 0) + if (!content.empty()) + { + SetSingleValue(iType, idMovie, FieldTitle, strNewMovieTitle); AnnounceUpdate(content, idMovie); + } } catch (...) { @@ -9179,10 +9177,7 @@ bool CVideoDatabase::SetSingleValue(VIDEODB_CONTENT_TYPE type, int dbId, int dbF if (strTable.empty()) return false; - strSQL = PrepareSQL("UPDATE %s SET c%02u='%s' WHERE %s=%u", - strTable.c_str(), dbField, strValue.c_str(), strField.c_str(), dbId); - if (m_pDS->exec(strSQL.c_str()) == 0) - return true; + return SetSingleValue(strTable, StringUtils::Format("c%02u", dbField), strValue, strField, dbId); } catch (...) { @@ -9191,6 +9186,44 @@ bool CVideoDatabase::SetSingleValue(VIDEODB_CONTENT_TYPE type, int dbId, int dbF return false; } +bool CVideoDatabase::SetSingleValue(VIDEODB_CONTENT_TYPE type, int dbId, Field dbField, const std::string &strValue) +{ + MediaType mediaType = DatabaseUtils::MediaTypeFromVideoContentType(type); + if (mediaType == MediaTypeNone) + return false; + + int dbFieldIndex = DatabaseUtils::GetField(dbField, mediaType); + if (dbFieldIndex < 0) + return false; + + return SetSingleValue(type, dbId, dbFieldIndex, strValue); +} + +bool CVideoDatabase::SetSingleValue(const std::string &table, const std::string &fieldName, const std::string &strValue, + const std::string &conditionName /* = "" */, int conditionValue /* = -1 */) +{ + if (table.empty() || fieldName.empty()) + return false; + + std::string sql; + try + { + if (NULL == m_pDB.get() || NULL == m_pDS.get()) + return false; + + sql = PrepareSQL("UPDATE %s SET %s='%s'", table.c_str(), fieldName.c_str(), strValue.c_str()); + if (!conditionName.empty()) + sql += PrepareSQL(" WHERE %s=%u", conditionName.c_str(), conditionValue); + if (m_pDS->exec(sql.c_str()) == 0) + return true; + } + catch (...) + { + CLog::Log(LOGERROR, "%s (%s) failed", __FUNCTION__, sql.c_str()); + } + return false; +} + CStdString CVideoDatabase::GetSafeFile(const CStdString &dir, const CStdString &name) const { CStdString safeThumb(name); diff --git a/xbmc/video/VideoDatabase.h b/xbmc/video/VideoDatabase.h index a97d0de06a..3b495e9b81 100644 --- a/xbmc/video/VideoDatabase.h +++ b/xbmc/video/VideoDatabase.h @@ -451,6 +451,9 @@ public: void SetStreamDetailsForFileId(const CStreamDetails& details, int idFile); bool SetSingleValue(VIDEODB_CONTENT_TYPE type, int dbId, int dbField, const std::string &strValue); + bool SetSingleValue(VIDEODB_CONTENT_TYPE type, int dbId, Field dbField, const std::string &strValue); + bool SetSingleValue(const std::string &table, const std::string &fieldName, const std::string &strValue, + const std::string &conditionName = "", int conditionValue = -1); void DeleteMovie(int idMovie, bool bKeepId = false); void DeleteMovie(const CStdString& strFilenameAndPath, bool bKeepId = false, int idMovie = -1); -- cgit v1.2.3 From f0e4a3c14a40e06b2eba57c08acadc2868c29b5a Mon Sep 17 00:00:00 2001 From: montellese Date: Mon, 22 Jul 2013 00:03:23 +0200 Subject: media: move "Edit title" context menu entry under new "Manage ..." entry --- language/English/strings.po | 6 ++- xbmc/music/windows/GUIWindowMusicNav.cpp | 3 +- xbmc/video/dialogs/GUIDialogVideoInfo.cpp | 66 +++++++++++++++++++++++++++++++ xbmc/video/dialogs/GUIDialogVideoInfo.h | 3 ++ xbmc/video/windows/GUIWindowVideoBase.cpp | 51 ------------------------ xbmc/video/windows/GUIWindowVideoBase.h | 1 - xbmc/video/windows/GUIWindowVideoNav.cpp | 17 ++++---- 7 files changed, 85 insertions(+), 62 deletions(-) diff --git a/language/English/strings.po b/language/English/strings.po index ec3ee5f82f..920fda6ed9 100644 --- a/language/English/strings.po +++ b/language/English/strings.po @@ -6710,7 +6710,11 @@ msgctxt "#16105" msgid "Edit title" msgstr "" -#empty strings from id 16106 to 16199 +msgctxt "#16106" +msgid "Manage ..." +msgstr "" + +#empty strings from id 16107 to 16199 #: xbmc/windows/GUIWindowFileManager.cpp msgctxt "#16200" diff --git a/xbmc/music/windows/GUIWindowMusicNav.cpp b/xbmc/music/windows/GUIWindowMusicNav.cpp index 9fbe45993a..a409672768 100644 --- a/xbmc/music/windows/GUIWindowMusicNav.cpp +++ b/xbmc/music/windows/GUIWindowMusicNav.cpp @@ -31,6 +31,7 @@ #include "playlists/PlayListFactory.h" #include "profiles/ProfilesManager.h" #include "video/VideoDatabase.h" +#include "video/dialogs/GUIDialogVideoInfo.h" #include "video/windows/GUIWindowVideoNav.h" #include "music/tags/MusicInfoTag.h" #include "guilib/GUIWindowManager.h" @@ -657,7 +658,7 @@ bool CGUIWindowMusicNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button) return true; case CONTEXT_BUTTON_RENAME: - CGUIWindowVideoBase::UpdateVideoTitle(item.get()); + CGUIDialogVideoInfo::UpdateVideoItemTitle(item); CUtil::DeleteVideoDatabaseDirectoryCache(); Refresh(); return true; diff --git a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp index 0d34f5d387..6ada057135 100644 --- a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp @@ -19,6 +19,7 @@ */ #include "GUIDialogVideoInfo.h" +#include "Application.h" #include "guilib/GUIWindow.h" #include "Util.h" #include "guilib/GUIImage.h" @@ -51,6 +52,7 @@ #include "URL.h" #include "video/VideoThumbLoader.h" #include "filesystem/Directory.h" +#include "filesystem/VideoDatabaseDirectory.h" using namespace std; using namespace XFILE; @@ -928,3 +930,67 @@ void CGUIDialogVideoInfo::AddItemPathToFileBrowserSources(VECSOURCES &sources, c sources.push_back(itemSource); } } + +int CGUIDialogVideoInfo::ManageVideoItem(const CFileItemPtr &item) +{ + if (item == NULL || !item->IsVideoDb() || !item->HasVideoInfoTag() || item->GetVideoInfoTag()->m_iDbId < 0) + return -1; + + CContextButtons buttons; + buttons.Add(CONTEXT_BUTTON_EDIT, 16105); + + int button = CGUIDialogContextMenu::ShowAndGetChoice(buttons); + if (button < 0) + return -1; + + bool result = false; + switch ((CONTEXT_BUTTON)button) + { + case CONTEXT_BUTTON_EDIT: + result = UpdateVideoItemTitle(item); + + default: + return -1; + } + + if (result) + return button; + + return -1; +} + +//Add change a title's name +bool CGUIDialogVideoInfo::UpdateVideoItemTitle(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_MOVIE_SETS) + database.GetSetInfo(iDbId, detail); + else if (iType == VIDEODB_CONTENT_EPISODES) + database.GetEpisodeInfo(pItem->GetPath(), detail, iDbId); + else if (iType == VIDEODB_CONTENT_TVSHOWS) + database.GetTvShowInfo(pItem->GetVideoInfoTag()->m_strFileNameAndPath, detail, iDbId); + else if (iType == VIDEODB_CONTENT_MUSICVIDEOS) + database.GetMusicVideoInfo(pItem->GetVideoInfoTag()->m_strFileNameAndPath, detail, iDbId); + + // get the new title + if (!CGUIKeyboardFactory::ShowAndGetInput(detail.m_strTitle, g_localizeStrings.Get(16105), false)) + return false; + + database.UpdateMovieTitle(iDbId, detail.m_strTitle, iType); + return true; +} diff --git a/xbmc/video/dialogs/GUIDialogVideoInfo.h b/xbmc/video/dialogs/GUIDialogVideoInfo.h index bc77a4f391..22065b0673 100644 --- a/xbmc/video/dialogs/GUIDialogVideoInfo.h +++ b/xbmc/video/dialogs/GUIDialogVideoInfo.h @@ -43,6 +43,9 @@ public: static std::string ChooseArtType(const CFileItem &item, std::map ¤tArt); static void AddItemPathToFileBrowserSources(VECSOURCES &sources, const CFileItem &item); + + static int ManageVideoItem(const CFileItemPtr &item); + static bool UpdateVideoItemTitle(const CFileItemPtr &pItem); protected: virtual void OnInitWindow(); void Update(); diff --git a/xbmc/video/windows/GUIWindowVideoBase.cpp b/xbmc/video/windows/GUIWindowVideoBase.cpp index c1802435ec..4165fbe7f9 100644 --- a/xbmc/video/windows/GUIWindowVideoBase.cpp +++ b/xbmc/video/windows/GUIWindowVideoBase.cpp @@ -1674,57 +1674,6 @@ void CGUIWindowVideoBase::MarkWatched(const CFileItemPtr &item, bool bMark) } } -//Add change a title's name -void CGUIWindowVideoBase::UpdateVideoTitle(const CFileItem* pItem) -{ - // dont allow update while scanning - if (g_application.IsVideoScanning()) - { - CGUIDialogOK::ShowAndGetInput(257, 0, 14057, 0); - return; - } - - CVideoInfoTag detail; - CVideoDatabase database; - database.Open(); - CVideoDatabaseDirectory dir; - CQueryParams params; - dir.GetQueryParams(pItem->GetPath(),params); - int iDbId = pItem->GetVideoInfoTag()->m_iDbId; - - VIDEODB_CONTENT_TYPE iType=VIDEODB_CONTENT_MOVIES; - if (pItem->HasVideoInfoTag() && (!pItem->GetVideoInfoTag()->m_strShowTitle.IsEmpty() || - pItem->GetVideoInfoTag()->m_iEpisode > 0)) - { - iType = VIDEODB_CONTENT_TVSHOWS; - } - if (pItem->HasVideoInfoTag() && pItem->GetVideoInfoTag()->m_iSeason > -1 && !pItem->m_bIsFolder) - iType = VIDEODB_CONTENT_EPISODES; - if (pItem->HasVideoInfoTag() && !pItem->GetVideoInfoTag()->m_artist.empty()) - iType = VIDEODB_CONTENT_MUSICVIDEOS; - if (params.GetSetId() != -1 && params.GetMovieId() == -1) - iType = VIDEODB_CONTENT_MOVIE_SETS; - if (iType == VIDEODB_CONTENT_MOVIES) - database.GetMovieInfo("", detail, pItem->GetVideoInfoTag()->m_iDbId); - if (iType == VIDEODB_CONTENT_MOVIE_SETS) - database.GetSetInfo(params.GetSetId(), detail); - if (iType == VIDEODB_CONTENT_EPISODES) - database.GetEpisodeInfo(pItem->GetPath(),detail,pItem->GetVideoInfoTag()->m_iDbId); - if (iType == VIDEODB_CONTENT_TVSHOWS) - database.GetTvShowInfo(pItem->GetVideoInfoTag()->m_strFileNameAndPath,detail,pItem->GetVideoInfoTag()->m_iDbId); - if (iType == VIDEODB_CONTENT_MUSICVIDEOS) - database.GetMusicVideoInfo(pItem->GetVideoInfoTag()->m_strFileNameAndPath,detail,pItem->GetVideoInfoTag()->m_iDbId); - - CStdString strInput; - strInput = detail.m_strTitle; - - //Get the new title - if (!CGUIKeyboardFactory::ShowAndGetInput(strInput, g_localizeStrings.Get(16105), false)) - return; - - database.UpdateMovieTitle(iDbId, strInput, iType); -} - void CGUIWindowVideoBase::LoadPlayList(const CStdString& strPlayList, int iPlayList /* = PLAYLIST_VIDEO */) { // if partymode is active, we disable it diff --git a/xbmc/video/windows/GUIWindowVideoBase.h b/xbmc/video/windows/GUIWindowVideoBase.h index b6e305d8d8..f10498d885 100644 --- a/xbmc/video/windows/GUIWindowVideoBase.h +++ b/xbmc/video/windows/GUIWindowVideoBase.h @@ -51,7 +51,6 @@ public: void AddToDatabase(int iItem); virtual void OnInfo(CFileItem* pItem, const ADDON::ScraperPtr& scraper); static void MarkWatched(const CFileItemPtr &pItem, bool bMark); - static void UpdateVideoTitle(const CFileItem* pItem); /*! \brief Show dialog allowing selection of wanted playback item */ static bool ShowPlaySelection(CFileItemPtr& item); diff --git a/xbmc/video/windows/GUIWindowVideoNav.cpp b/xbmc/video/windows/GUIWindowVideoNav.cpp index 3590de664f..c69c6f0c97 100644 --- a/xbmc/video/windows/GUIWindowVideoNav.cpp +++ b/xbmc/video/windows/GUIWindowVideoNav.cpp @@ -975,10 +975,10 @@ void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &butt buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103); //Mark as Watched } } - if ((node == NODE_TYPE_TITLE_TVSHOWS) || - (item->IsVideoDb() && item->HasVideoInfoTag() && !item->m_bIsFolder)) + if (!g_application.IsVideoScanning() && item->IsVideoDb() && item->HasVideoInfoTag() && + (!item->m_bIsFolder || m_vecItems->GetContent().Equals("movies") || m_vecItems->GetContent().Equals("tvshows"))) { - buttons.Add(CONTEXT_BUTTON_EDIT, 16105); //Edit Title + buttons.Add(CONTEXT_BUTTON_EDIT, 16106); } if (m_database.HasContent(VIDEODB_CONTENT_TVSHOWS) && item->HasVideoInfoTag() && !item->m_bIsFolder && item->GetVideoInfoTag()->m_iEpisode == -1 && @@ -998,7 +998,6 @@ void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &butt if (StringUtils::StartsWith(item->GetPath(), "videodb://movies/sets/") && item->GetPath().size() > 22 && item->m_bIsFolder) // sets { - buttons.Add(CONTEXT_BUTTON_EDIT, 16105); buttons.Add(CONTEXT_BUTTON_SET_MOVIESET_ART, 13511); buttons.Add(CONTEXT_BUTTON_MOVIESET_ADD_REMOVE_ITEMS, 20465); buttons.Add(CONTEXT_BUTTON_DELETE, 646); @@ -1097,10 +1096,12 @@ bool CGUIWindowVideoNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button) switch (button) { case CONTEXT_BUTTON_EDIT: - UpdateVideoTitle(item.get()); - CUtil::DeleteVideoDatabaseDirectoryCache(); - Refresh(); - return true; + { + CONTEXT_BUTTON ret = (CONTEXT_BUTTON)CGUIDialogVideoInfo::ManageVideoItem(item); + if (ret >= 0) + Refresh(true); + return true; + } case CONTEXT_BUTTON_SET_SEASON_ART: case CONTEXT_BUTTON_SET_ACTOR_THUMB: -- cgit v1.2.3 From 18231c34be5a8f72dc0f8760f90ebc3fe99c700e Mon Sep 17 00:00:00 2001 From: montellese Date: Mon, 22 Jul 2013 10:31:38 +0200 Subject: video: move "Link movie to tvshow" and "Remove link to tvshow" context menu entries under new "Manage ..." entry --- xbmc/video/dialogs/GUIDialogVideoInfo.cpp | 104 +++++++++++++++++++++++++++--- xbmc/video/dialogs/GUIDialogVideoInfo.h | 4 ++ xbmc/video/windows/GUIWindowVideoNav.cpp | 76 ---------------------- xbmc/video/windows/GUIWindowVideoNav.h | 1 - 4 files changed, 100 insertions(+), 85 deletions(-) diff --git a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp index 6ada057135..fa623cb24e 100644 --- a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp @@ -936,23 +936,50 @@ int CGUIDialogVideoInfo::ManageVideoItem(const CFileItemPtr &item) if (item == NULL || !item->IsVideoDb() || !item->HasVideoInfoTag() || item->GetVideoInfoTag()->m_iDbId < 0) return -1; + CVideoDatabase database; + if (!database.Open()) + return -1; + + VIDEODB_CONTENT_TYPE type = (VIDEODB_CONTENT_TYPE)item->GetVideoContentType(); + int dbId = item->GetVideoInfoTag()->m_iDbId; + CContextButtons buttons; buttons.Add(CONTEXT_BUTTON_EDIT, 16105); - int button = CGUIDialogContextMenu::ShowAndGetChoice(buttons); - if (button < 0) - return -1; + if (type == VIDEODB_CONTENT_MOVIES && + database.HasContent(VIDEODB_CONTENT_TVSHOWS)) + { + buttons.Add(CONTEXT_BUTTON_LINK_MOVIE, 20384); + if (database.IsLinkedToTvshow(dbId)) + buttons.Add(CONTEXT_BUTTON_UNLINK_MOVIE, 20385); + } bool result = false; - switch ((CONTEXT_BUTTON)button) + int button = CGUIDialogContextMenu::ShowAndGetChoice(buttons); + if (button >= 0) { - case CONTEXT_BUTTON_EDIT: - result = UpdateVideoItemTitle(item); + switch ((CONTEXT_BUTTON)button) + { + case CONTEXT_BUTTON_EDIT: + result = UpdateVideoItemTitle(item); + break; + + case CONTEXT_BUTTON_LINK_MOVIE: + result = LinkMovieToTvShow(item, false, database); + break; + + case CONTEXT_BUTTON_UNLINK_MOVIE: + result = LinkMovieToTvShow(item, true, database); + break; - default: - return -1; + default: + result = false; + break; + } } + database.Close(); + if (result) return button; @@ -994,3 +1021,64 @@ bool CGUIDialogVideoInfo::UpdateVideoItemTitle(const CFileItemPtr &pItem) database.UpdateMovieTitle(iDbId, detail.m_strTitle, iType); return true; } + +bool CGUIDialogVideoInfo::LinkMovieToTvShow(const CFileItemPtr &item, bool bRemove, CVideoDatabase &database) +{ + int dbId = item->GetVideoInfoTag()->m_iDbId; + + CFileItemList list; + if (bRemove) + { + vector ids; + if (!database.GetLinksToTvShow(dbId, ids)) + return false; + + for (unsigned int i = 0; i < ids.size(); ++i) + { + CVideoInfoTag tag; + database.GetTvShowInfo("", tag, ids[i]); + CFileItemPtr show(new CFileItem(tag)); + list.Add(show); + } + } + else + { + database.GetTvShowsNav("videodb://tvshows/titles", list); + + // remove already linked shows + vector ids; + if (!database.GetLinksToTvShow(dbId, ids)) + return false; + + for (int i = 0; i < list.Size(); ) + { + size_t j; + for (j = 0; j < ids.size(); ++j) + { + if (list[i]->GetVideoInfoTag()->m_iDbId == ids[j]) + break; + } + if (j == ids.size()) + i++; + else + list.Remove(i); + } + } + + int iSelectedLabel = 0; + if (list.Size() > 1) + { + list.Sort(SortByLabel, SortOrderAscending, CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone); + CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); + pDialog->Reset(); + pDialog->SetItems(&list); + pDialog->SetHeading(20356); + pDialog->DoModal(); + iSelectedLabel = pDialog->GetSelectedLabel(); + } + + if (iSelectedLabel > -1) + return database.LinkMovieToTvshow(dbId, list[iSelectedLabel]->GetVideoInfoTag()->m_iDbId, bRemove); + + return false; +} diff --git a/xbmc/video/dialogs/GUIDialogVideoInfo.h b/xbmc/video/dialogs/GUIDialogVideoInfo.h index 22065b0673..89515525b9 100644 --- a/xbmc/video/dialogs/GUIDialogVideoInfo.h +++ b/xbmc/video/dialogs/GUIDialogVideoInfo.h @@ -23,6 +23,8 @@ #include "guilib/GUIDialog.h" #include "FileItem.h" +class CVideoDatabase; + class CGUIDialogVideoInfo : public CGUIDialog { @@ -61,6 +63,8 @@ protected: void OnGetFanart(); void PlayTrailer(); + static bool LinkMovieToTvShow(const CFileItemPtr &item, bool bRemove, CVideoDatabase &database); + CFileItemPtr m_movieItem; CFileItemList *m_castList; bool m_bViewReview; diff --git a/xbmc/video/windows/GUIWindowVideoNav.cpp b/xbmc/video/windows/GUIWindowVideoNav.cpp index c69c6f0c97..2ae52101ea 100644 --- a/xbmc/video/windows/GUIWindowVideoNav.cpp +++ b/xbmc/video/windows/GUIWindowVideoNav.cpp @@ -980,14 +980,6 @@ void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &butt { buttons.Add(CONTEXT_BUTTON_EDIT, 16106); } - if (m_database.HasContent(VIDEODB_CONTENT_TVSHOWS) && item->HasVideoInfoTag() && - !item->m_bIsFolder && item->GetVideoInfoTag()->m_iEpisode == -1 && - item->GetVideoInfoTag()->m_artist.empty() && item->GetVideoInfoTag()->m_iDbId >= 0) // movie entry - { - if (m_database.IsLinkedToTvshow(item->GetVideoInfoTag()->m_iDbId)) - buttons.Add(CONTEXT_BUTTON_UNLINK_MOVIE,20385); - buttons.Add(CONTEXT_BUTTON_LINK_MOVIE,20384); - } if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_type == "movie") // movie entry { buttons.Add(CONTEXT_BUTTON_SET_MOVIESET,20465); // set or change movie set the movie belongs to @@ -1374,17 +1366,6 @@ bool CGUIWindowVideoNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button) Refresh(); return true; } - case CONTEXT_BUTTON_UNLINK_MOVIE: - { - OnLinkMovieToTvShow(itemNumber, true); - Refresh(); - return true; - } - case CONTEXT_BUTTON_LINK_MOVIE: - { - OnLinkMovieToTvShow(itemNumber, false); - return true; - } case CONTEXT_BUTTON_GO_TO_ARTIST: { CStdString strPath; @@ -1489,63 +1470,6 @@ void CGUIWindowVideoNav::OnChooseFanart(const CFileItem &videoItem) Refresh(); } -void CGUIWindowVideoNav::OnLinkMovieToTvShow(int itemnumber, bool bRemove) -{ - CFileItemList list; - if (bRemove) - { - vector ids; - if (!m_database.GetLinksToTvShow(m_vecItems->Get(itemnumber)->GetVideoInfoTag()->m_iDbId,ids)) - return; - for (unsigned int i=0;i ids; - if (!m_database.GetLinksToTvShow(m_vecItems->Get(itemnumber)->GetVideoInfoTag()->m_iDbId,ids)) - return; - for (int i=0;iGetVideoInfoTag()->m_iDbId == ids[j]) - break; - } - if (j == ids.size()) - i++; - else - list.Remove(i); - } - } - int iSelectedLabel = 0; - if (list.Size() > 1) - { - list.Sort(SortByLabel, SortOrderAscending, CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone); - CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); - pDialog->Reset(); - pDialog->SetItems(&list); - pDialog->SetHeading(20356); - pDialog->DoModal(); - iSelectedLabel = pDialog->GetSelectedLabel(); - } - if (iSelectedLabel > -1) - { - m_database.LinkMovieToTvshow(m_vecItems->Get(itemnumber)->GetVideoInfoTag()->m_iDbId, - list[iSelectedLabel]->GetVideoInfoTag()->m_iDbId, bRemove); - CUtil::DeleteVideoDatabaseDirectoryCache(); - } -} - bool CGUIWindowVideoNav::OnClick(int iItem) { CFileItemPtr item = m_vecItems->Get(iItem); diff --git a/xbmc/video/windows/GUIWindowVideoNav.h b/xbmc/video/windows/GUIWindowVideoNav.h index a7ae9e0289..c3fd6889fb 100644 --- a/xbmc/video/windows/GUIWindowVideoNav.h +++ b/xbmc/video/windows/GUIWindowVideoNav.h @@ -64,7 +64,6 @@ protected: virtual bool GetFilteredItems(const CStdString &filter, CFileItemList &items); virtual void OnItemLoaded(CFileItem* pItem) {}; - void OnLinkMovieToTvShow(int itemnumber, bool bRemove); // override base class methods virtual bool GetDirectory(const CStdString &strDirectory, CFileItemList &items); virtual void UpdateButtons(); -- cgit v1.2.3 From 85c1d7ae0a25bb99fa95345c79962300c142e02f Mon Sep 17 00:00:00 2001 From: montellese Date: Mon, 22 Jul 2013 14:04:44 +0200 Subject: video: move "Manage movie set" context menu entry under new "Manage ..." entry --- xbmc/video/dialogs/GUIDialogVideoInfo.cpp | 170 +++++++++++++++++++++++++++++- xbmc/video/dialogs/GUIDialogVideoInfo.h | 4 + xbmc/video/windows/GUIWindowVideoNav.cpp | 167 +---------------------------- xbmc/video/windows/GUIWindowVideoNav.h | 4 - 4 files changed, 172 insertions(+), 173 deletions(-) diff --git a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp index fa623cb24e..3ac95b90e8 100644 --- a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp @@ -946,12 +946,18 @@ int CGUIDialogVideoInfo::ManageVideoItem(const CFileItemPtr &item) CContextButtons buttons; buttons.Add(CONTEXT_BUTTON_EDIT, 16105); - if (type == VIDEODB_CONTENT_MOVIES && - database.HasContent(VIDEODB_CONTENT_TVSHOWS)) + if (type == VIDEODB_CONTENT_MOVIES) { - buttons.Add(CONTEXT_BUTTON_LINK_MOVIE, 20384); - if (database.IsLinkedToTvshow(dbId)) - buttons.Add(CONTEXT_BUTTON_UNLINK_MOVIE, 20385); + // only show link/unlink if there are tvshows available + if (database.HasContent(VIDEODB_CONTENT_TVSHOWS)) + { + buttons.Add(CONTEXT_BUTTON_LINK_MOVIE, 20384); + if (database.IsLinkedToTvshow(dbId)) + buttons.Add(CONTEXT_BUTTON_UNLINK_MOVIE, 20385); + } + + // set or change movie set the movie belongs to + buttons.Add(CONTEXT_BUTTON_SET_MOVIESET, 20465); } bool result = false; @@ -972,6 +978,14 @@ int CGUIDialogVideoInfo::ManageVideoItem(const CFileItemPtr &item) result = LinkMovieToTvShow(item, true, database); break; + case CONTEXT_BUTTON_SET_MOVIESET: + { + CFileItemPtr selectedSet; + if (GetSetForMovie(item.get(), selectedSet)) + result = SetMovieSet(item.get(), selectedSet.get()); + break; + } + default: result = false; break; @@ -1022,6 +1036,152 @@ bool CGUIDialogVideoInfo::UpdateVideoItemTitle(const CFileItemPtr &pItem) return true; } +bool CGUIDialogVideoInfo::GetMoviesForSet(const CFileItem *setItem, CFileItemList &originalMovies, CFileItemList &selectedMovies) +{ + CVideoDatabase videodb; + if (!videodb.Open()) + return false; + + CStdString strHeading; strHeading.Format(g_localizeStrings.Get(20457)); + CStdString baseDir; + baseDir.Format("videodb://movies/sets/%d", setItem->GetVideoInfoTag()->m_iDbId); + + if (!CDirectory::GetDirectory(baseDir, originalMovies) || originalMovies.Size() <= 0) // keep a copy of the original members of the set + return false; + + CFileItemList listItems; + if (!videodb.GetSortedVideos(MediaTypeMovie, "videodb://movies", SortDescription(), listItems) || listItems.Size() <= 0) + return false; + + CGUIDialogSelect *dialog = (CGUIDialogSelect *)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); + if (dialog == NULL) + return false; + + listItems.Sort(SortByLabel, SortOrderAscending, SortAttributeIgnoreArticle); + + dialog->Reset(); + dialog->SetMultiSelection(true); + dialog->SetHeading(strHeading); + dialog->SetItems(&listItems); + vector selectedIndices; + for (int i = 0; i < originalMovies.Size(); i++) + { + for (int listIndex = 0; listIndex < listItems.Size(); listIndex++) + { + if (listItems.Get(listIndex)->GetVideoInfoTag()->m_iDbId == originalMovies[i]->GetVideoInfoTag()->m_iDbId) + { + selectedIndices.push_back(listIndex); + break; + } + } + } + dialog->SetSelected(selectedIndices); + dialog->EnableButton(true, 186); + dialog->DoModal(); + + if (dialog->IsConfirmed()) + { + selectedMovies.Copy(dialog->GetSelectedItems()); + return (selectedMovies.Size() > 0); + } + else + return false; +} + +bool CGUIDialogVideoInfo::GetSetForMovie(const CFileItem *movieItem, CFileItemPtr &selectedSet) +{ + CVideoDatabase videodb; + if (!videodb.Open()) + return false; + + CFileItemList listItems; + CStdString baseDir = "videodb://movies/sets/"; + if (!CDirectory::GetDirectory(baseDir, listItems) || listItems.Size() <= 0) + return false; + listItems.Sort(SortByLabel, SortOrderAscending, SortAttributeIgnoreArticle); + + int currentSetId = 0; + CStdString currentSetLabel; + + if (movieItem->GetVideoInfoTag()->m_iSetId > currentSetId) + { + currentSetId = movieItem->GetVideoInfoTag()->m_iSetId; + currentSetLabel = videodb.GetSetById(currentSetId); + } + + if (currentSetId > 0) + { + // add clear item + CStdString strClear; strClear.Format(g_localizeStrings.Get(20467), currentSetLabel); + CFileItemPtr clearItem(new CFileItem(strClear)); + clearItem->GetVideoInfoTag()->m_iDbId = -1; // -1 will be used to clear set + listItems.AddFront(clearItem, 0); + // add keep current set item + CStdString strKeep; strKeep.Format(g_localizeStrings.Get(20469), currentSetLabel); + CFileItemPtr keepItem(new CFileItem(strKeep)); + keepItem->GetVideoInfoTag()->m_iDbId = currentSetId; + listItems.AddFront(keepItem, 1); + } + + CGUIDialogSelect *dialog = (CGUIDialogSelect *)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); + if (dialog == NULL) + return false; + + CStdString strHeading; + strHeading.Format(g_localizeStrings.Get(20466)); + dialog->Reset(); + dialog->SetHeading(strHeading); + dialog->SetItems(&listItems); + if (currentSetId >= 0) + { + for (int listIndex = 0; listIndex < listItems.Size(); listIndex++) + { + if (listItems.Get(listIndex)->GetVideoInfoTag()->m_iDbId == currentSetId) + { + dialog->SetSelected(listIndex); + break; + } + } + } + dialog->EnableButton(true, 20468); // new set via button + dialog->DoModal(); + + if (dialog->IsButtonPressed()) + { // creating new set + CStdString newSetTitle; + if (!CGUIKeyboardFactory::ShowAndGetInput(newSetTitle, g_localizeStrings.Get(20468), false)) + return false; + int idSet = videodb.AddSet(newSetTitle); + map movieArt, setArt; + if (!videodb.GetArtForItem(idSet, "set", setArt)) + { + videodb.GetArtForItem(movieItem->GetVideoInfoTag()->m_iDbId, "movie", movieArt); + videodb.SetArtForItem(idSet, "set", movieArt); + } + CFileItemPtr newSet(new CFileItem(newSetTitle)); + newSet->GetVideoInfoTag()->m_iDbId = idSet; + selectedSet = newSet; + return true; + } + else if (dialog->IsConfirmed()) + { + selectedSet = dialog->GetSelectedItem(); + return (selectedSet != NULL); + } + else + return false; +} + +bool CGUIDialogVideoInfo::SetMovieSet(const CFileItem *movieItem, const CFileItem *selectedSet) +{ + CVideoDatabase videodb; + if (!videodb.Open()) + return false; + + videodb.SetMovieSet(movieItem->GetVideoInfoTag()->m_iDbId, selectedSet->GetVideoInfoTag()->m_iDbId); + return true; +} + 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 89515525b9..c22938a3b1 100644 --- a/xbmc/video/dialogs/GUIDialogVideoInfo.h +++ b/xbmc/video/dialogs/GUIDialogVideoInfo.h @@ -48,6 +48,10 @@ public: static int ManageVideoItem(const CFileItemPtr &item); static bool UpdateVideoItemTitle(const CFileItemPtr &pItem); + + static bool GetMoviesForSet(const CFileItem *setItem, CFileItemList &originalMovies, CFileItemList &selectedMovies); + static bool GetSetForMovie(const CFileItem *movieItem, CFileItemPtr &selectedSet); + static bool SetMovieSet(const CFileItem *movieItem, const CFileItem *selectedSet); protected: virtual void OnInitWindow(); void Update(); diff --git a/xbmc/video/windows/GUIWindowVideoNav.cpp b/xbmc/video/windows/GUIWindowVideoNav.cpp index 2ae52101ea..41f791f6ee 100644 --- a/xbmc/video/windows/GUIWindowVideoNav.cpp +++ b/xbmc/video/windows/GUIWindowVideoNav.cpp @@ -980,10 +980,6 @@ void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &butt { buttons.Add(CONTEXT_BUTTON_EDIT, 16106); } - if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_type == "movie") // movie entry - { - buttons.Add(CONTEXT_BUTTON_SET_MOVIESET,20465); // set or change movie set the movie belongs to - } if (node == NODE_TYPE_SEASONS && item->m_bIsFolder) buttons.Add(CONTEXT_BUTTON_SET_SEASON_ART, 13511); @@ -1318,23 +1314,12 @@ bool CGUIWindowVideoNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button) items.RemoveDiscCache(GetID()); return true; } - case CONTEXT_BUTTON_SET_MOVIESET: - { - CFileItemPtr selectedSet; - if (!GetSetForMovie(item, selectedSet)) - return true; - - if (SetMovieSet(item, selectedSet)) - Refresh(); - - return true; - } case CONTEXT_BUTTON_MOVIESET_ADD_REMOVE_ITEMS: { CFileItemList originalItems; CFileItemList selectedItems; - if (!GetMoviesForSet(item, originalItems, selectedItems) || selectedItems.Size() == 0) // need at least one item selected + if (!CGUIDialogVideoInfo::GetMoviesForSet(item.get(), originalItems, selectedItems) || selectedItems.Size() == 0) // need at least one item selected return true; VECFILEITEMS original = originalItems.GetList(); std::sort(original.begin(), original.end(), compFileItemsByDbId); @@ -1347,7 +1332,7 @@ bool CGUIWindowVideoNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button) set_difference(selected.begin(),selected.end(), original.begin(),original.end(), std::back_inserter(addedItems), compFileItemsByDbId); for (VECFILEITEMS::iterator it = addedItems.begin(); it != addedItems.end(); ++it) { - if (SetMovieSet(*it, item)) + if (CGUIDialogVideoInfo::SetMovieSet(it->get(), item.get())) refreshNeeded = true; } // update the "deleted" items @@ -1357,7 +1342,7 @@ bool CGUIWindowVideoNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button) set_difference(original.begin(),original.end(), selected.begin(),selected.end(), std::back_inserter(deletedItems), compFileItemsByDbId); for (VECFILEITEMS::iterator it = deletedItems.begin(); it != deletedItems.end(); ++it) { - if (SetMovieSet(*it, clearItem)) + if (CGUIDialogVideoInfo::SetMovieSet(it->get(), clearItem.get())) refreshNeeded = true; } @@ -1731,152 +1716,6 @@ bool CGUIWindowVideoNav::GetItemsForTag(const CStdString &strHeading, const std: return items.Size() > 0; } -bool CGUIWindowVideoNav::GetMoviesForSet(CFileItemPtr &setItem, CFileItemList &originalMovies, CFileItemList &selectedMovies) -{ - CVideoDatabase videodb; - if (!videodb.Open()) - return false; - - CStdString strHeading; strHeading.Format(g_localizeStrings.Get(20457)); - CStdString baseDir; - baseDir.Format("videodb://movies/sets/%d", setItem->GetVideoInfoTag()->m_iDbId); - - if (!CDirectory::GetDirectory(baseDir, originalMovies) || originalMovies.Size() <= 0) // keep a copy of the original members of the set - return false; - - CFileItemList listItems; - if (!videodb.GetSortedVideos(MediaTypeMovie, "videodb://movies", SortDescription(), listItems) || listItems.Size() <= 0) - return false; - - CGUIDialogSelect *dialog = (CGUIDialogSelect *)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); - if (dialog == NULL) - return false; - - listItems.Sort(SortByLabel, SortOrderAscending, SortAttributeIgnoreArticle); - - dialog->Reset(); - dialog->SetMultiSelection(true); - dialog->SetHeading(strHeading); - dialog->SetItems(&listItems); - vector selectedIndices; - for (int i = 0; i < originalMovies.Size(); i++) - { - for (int listIndex = 0; listIndex < listItems.Size(); listIndex++) - { - if (listItems.Get(listIndex)->GetVideoInfoTag()->m_iDbId == originalMovies[i]->GetVideoInfoTag()->m_iDbId) - { - selectedIndices.push_back(listIndex); - break; - } - } - } - dialog->SetSelected(selectedIndices); - dialog->EnableButton(true, 186); - dialog->DoModal(); - - if (dialog->IsConfirmed()) - { - selectedMovies.Copy(dialog->GetSelectedItems()); - return (selectedMovies.Size() > 0); - } - else - return false; -} - -bool CGUIWindowVideoNav::GetSetForMovie(CFileItemPtr &movieItem, CFileItemPtr &selectedSet) -{ - CVideoDatabase videodb; - if (!videodb.Open()) - return false; - - CFileItemList listItems; - CStdString baseDir = "videodb://movies/sets/"; - if (!CDirectory::GetDirectory(baseDir, listItems) || listItems.Size() <= 0) - return false; - listItems.Sort(SortByLabel, SortOrderAscending, SortAttributeIgnoreArticle); - - int currentSetId = 0; - CStdString currentSetLabel; - - if (movieItem->GetVideoInfoTag()->m_iSetId > currentSetId) - { - currentSetId = movieItem->GetVideoInfoTag()->m_iSetId; - currentSetLabel = videodb.GetSetById(currentSetId); - } - - if (currentSetId > 0) - { - // add clear item - CStdString strClear; strClear.Format(g_localizeStrings.Get(20467), currentSetLabel); - CFileItemPtr clearItem(new CFileItem(strClear)); - clearItem->GetVideoInfoTag()->m_iDbId = -1; // -1 will be used to clear set - listItems.AddFront(clearItem, 0); - // add keep current set item - CStdString strKeep; strKeep.Format(g_localizeStrings.Get(20469), currentSetLabel); - CFileItemPtr keepItem(new CFileItem(strKeep)); - keepItem->GetVideoInfoTag()->m_iDbId = currentSetId; - listItems.AddFront(keepItem, 1); - } - - CGUIDialogSelect *dialog = (CGUIDialogSelect *)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); - if (dialog == NULL) - return false; - - CStdString strHeading; - strHeading.Format(g_localizeStrings.Get(20466)); - dialog->Reset(); - dialog->SetHeading(strHeading); - dialog->SetItems(&listItems); - if (currentSetId >= 0) - { - for (int listIndex = 0; listIndex < listItems.Size(); listIndex++) - { - if (listItems.Get(listIndex)->GetVideoInfoTag()->m_iDbId == currentSetId) - { - dialog->SetSelected(listIndex); - break; - } - } - } - dialog->EnableButton(true, 20468); // new set via button - dialog->DoModal(); - - if (dialog->IsButtonPressed()) - { // creating new set - CStdString newSetTitle; - if (!CGUIKeyboardFactory::ShowAndGetInput(newSetTitle, g_localizeStrings.Get(20468), false)) - return false; - int idSet = videodb.AddSet(newSetTitle); - map movieArt, setArt; - if (!videodb.GetArtForItem(idSet, "set", setArt)) - { - videodb.GetArtForItem(movieItem->GetVideoInfoTag()->m_iDbId, "movie", movieArt); - videodb.SetArtForItem(idSet, "set", movieArt); - } - CFileItemPtr newSet(new CFileItem(newSetTitle)); - newSet->GetVideoInfoTag()->m_iDbId = idSet; - selectedSet = newSet; - return true; - } - else if (dialog->IsConfirmed()) - { - selectedSet = dialog->GetSelectedItem(); - return (selectedSet != NULL); - } - else - return false; -} - -bool CGUIWindowVideoNav::SetMovieSet(CFileItemPtr &movieItem, CFileItemPtr &selectedSet) -{ - CVideoDatabase videodb; - if (!videodb.Open()) - return false; - - videodb.SetMovieSet(movieItem->GetVideoInfoTag()->m_iDbId, selectedSet->GetVideoInfoTag()->m_iDbId); - return true; -} - CStdString CGUIWindowVideoNav::GetLocalizedType(const std::string &strType) { if (strType == "movie" || strType == "movies") diff --git a/xbmc/video/windows/GUIWindowVideoNav.h b/xbmc/video/windows/GUIWindowVideoNav.h index c3fd6889fb..d36bb0c355 100644 --- a/xbmc/video/windows/GUIWindowVideoNav.h +++ b/xbmc/video/windows/GUIWindowVideoNav.h @@ -80,9 +80,5 @@ protected: bool GetItemsForTag(const CStdString &strHeading, const std::string &type, CFileItemList &items, int idTag = -1, bool showAll = true); static CStdString GetLocalizedType(const std::string &strType); - bool GetSetForMovie(CFileItemPtr &movieItem, CFileItemPtr &selectedSet); - bool GetMoviesForSet(CFileItemPtr &setItem, CFileItemList &originalMovies, CFileItemList &selectedMovies); - bool SetMovieSet(CFileItemPtr &movieItem, CFileItemPtr &selectedSet); - VECSOURCES m_shares; }; -- cgit v1.2.3 From 334e90333df4bddf464cb9b6dc30f30961ea82de Mon Sep 17 00:00:00 2001 From: montellese Date: Mon, 22 Jul 2013 16:09:18 +0200 Subject: video: move "Mark as watched/unwatched" context menu entry under new "Manage ..." entry --- xbmc/music/windows/GUIWindowMusicNav.cpp | 4 +- xbmc/video/dialogs/GUIDialogVideoInfo.cpp | 81 +++++++++++++++++++++++++++++++ xbmc/video/dialogs/GUIDialogVideoInfo.h | 1 + xbmc/video/windows/GUIWindowVideoBase.cpp | 57 +--------------------- xbmc/video/windows/GUIWindowVideoBase.h | 1 - xbmc/video/windows/GUIWindowVideoNav.cpp | 23 +++++---- 6 files changed, 100 insertions(+), 67 deletions(-) diff --git a/xbmc/music/windows/GUIWindowMusicNav.cpp b/xbmc/music/windows/GUIWindowMusicNav.cpp index a409672768..61cbd57939 100644 --- a/xbmc/music/windows/GUIWindowMusicNav.cpp +++ b/xbmc/music/windows/GUIWindowMusicNav.cpp @@ -646,13 +646,13 @@ bool CGUIWindowMusicNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button) } case CONTEXT_BUTTON_MARK_WATCHED: - CGUIWindowVideoBase::MarkWatched(item,true); + CGUIDialogVideoInfo::MarkWatched(item, true); CUtil::DeleteVideoDatabaseDirectoryCache(); Refresh(); return true; case CONTEXT_BUTTON_MARK_UNWATCHED: - CGUIWindowVideoBase::MarkWatched(item,false); + CGUIDialogVideoInfo::MarkWatched(item, false); CUtil::DeleteVideoDatabaseDirectoryCache(); Refresh(); return true; diff --git a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp index 3ac95b90e8..30288203eb 100644 --- a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp @@ -53,6 +53,9 @@ #include "video/VideoThumbLoader.h" #include "filesystem/Directory.h" #include "filesystem/VideoDatabaseDirectory.h" +#ifdef HAS_UPNP +#include "network/upnp/UPnP.h" +#endif using namespace std; using namespace XFILE; @@ -946,6 +949,20 @@ int CGUIDialogVideoInfo::ManageVideoItem(const CFileItemPtr &item) CContextButtons buttons; buttons.Add(CONTEXT_BUTTON_EDIT, 16105); + if (item->m_bIsFolder) + { + // Have both options for folders since we don't know whether all childs are watched/unwatched + buttons.Add(CONTEXT_BUTTON_MARK_UNWATCHED, 16104); //Mark as UnWatched + buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103); //Mark as Watched + } + else + { + if (item->GetOverlayImage().Equals("OverlayWatched.png")) + buttons.Add(CONTEXT_BUTTON_MARK_UNWATCHED, 16104); //Mark as UnWatched + else + buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103); //Mark as Watched + } + if (type == VIDEODB_CONTENT_MOVIES) { // only show link/unlink if there are tvshows available @@ -970,6 +987,14 @@ int CGUIDialogVideoInfo::ManageVideoItem(const CFileItemPtr &item) result = UpdateVideoItemTitle(item); break; + case CONTEXT_BUTTON_MARK_WATCHED: + result = MarkWatched(item, true); + break; + + case CONTEXT_BUTTON_MARK_UNWATCHED: + result = MarkWatched(item, false); + break; + case CONTEXT_BUTTON_LINK_MOVIE: result = LinkMovieToTvShow(item, false, database); break; @@ -1036,6 +1061,62 @@ bool CGUIDialogVideoInfo::UpdateVideoItemTitle(const CFileItemPtr &pItem) return true; } +bool CGUIDialogVideoInfo::MarkWatched(const CFileItemPtr &item, bool bMark) +{ + if (!CProfilesManager::Get().GetCurrentProfile().canWriteDatabases()) + return false; + + // dont allow update while scanning + if (g_application.IsVideoScanning()) + { + CGUIDialogOK::ShowAndGetInput(257, 0, 14057, 0); + return false; + } + + CVideoDatabase database; + if (!database.Open()) + return false; + + CFileItemList items; + if (item->m_bIsFolder) + { + CStdString strPath = item->GetPath(); + CDirectory::GetDirectory(strPath, items); + } + else + items.Add(item); + + for (int i = 0; i < items.Size(); ++i) + { + CFileItemPtr pTmpItem = items[i]; + if (pTmpItem->m_bIsFolder) + { + MarkWatched(pTmpItem, bMark); + continue; + } + + if (pTmpItem->HasVideoInfoTag() && + ((bMark && pTmpItem->GetVideoInfoTag()->m_playCount) || + (!bMark && !pTmpItem->GetVideoInfoTag()->m_playCount))) + continue; + +#ifdef HAS_UPNP + if (!URIUtils::IsUPnP(item->GetPath()) || !UPNP::CUPnP::MarkWatched(*pTmpItem, bMark)) +#endif + { + // Clear resume bookmark + if (bMark) + database.ClearBookMarksOfFile(pTmpItem->GetPath(), CBookmark::RESUME); + + database.SetPlayCount(*pTmpItem, bMark ? 1 : 0); + } + } + + database.Close(); + + return true; +} + bool CGUIDialogVideoInfo::GetMoviesForSet(const CFileItem *setItem, CFileItemList &originalMovies, CFileItemList &selectedMovies) { CVideoDatabase videodb; diff --git a/xbmc/video/dialogs/GUIDialogVideoInfo.h b/xbmc/video/dialogs/GUIDialogVideoInfo.h index c22938a3b1..80aa2c5f99 100644 --- a/xbmc/video/dialogs/GUIDialogVideoInfo.h +++ b/xbmc/video/dialogs/GUIDialogVideoInfo.h @@ -48,6 +48,7 @@ public: static int ManageVideoItem(const CFileItemPtr &item); static bool UpdateVideoItemTitle(const CFileItemPtr &pItem); + static bool MarkWatched(const CFileItemPtr &item, bool bMark); static bool GetMoviesForSet(const CFileItem *setItem, CFileItemList &originalMovies, CFileItemList &selectedMovies); static bool GetSetForMovie(const CFileItem *movieItem, CFileItemPtr &selectedSet); diff --git a/xbmc/video/windows/GUIWindowVideoBase.cpp b/xbmc/video/windows/GUIWindowVideoBase.cpp index 4165fbe7f9..ad6f626897 100644 --- a/xbmc/video/windows/GUIWindowVideoBase.cpp +++ b/xbmc/video/windows/GUIWindowVideoBase.cpp @@ -1438,7 +1438,7 @@ bool CGUIWindowVideoBase::OnContextButton(int itemNumber, CONTEXT_BUTTON button) case CONTEXT_BUTTON_MARK_WATCHED: { int newSelection = m_viewControl.GetSelectedItem() + 1; - MarkWatched(item,true); + CGUIDialogVideoInfo::MarkWatched(item, true); m_viewControl.SetSelectedItem(newSelection); CUtil::DeleteVideoDatabaseDirectoryCache(); @@ -1446,7 +1446,7 @@ bool CGUIWindowVideoBase::OnContextButton(int itemNumber, CONTEXT_BUTTON button) return true; } case CONTEXT_BUTTON_MARK_UNWATCHED: - MarkWatched(item,false); + CGUIDialogVideoInfo::MarkWatched(item, false); CUtil::DeleteVideoDatabaseDirectoryCache(); Refresh(); return true; @@ -1621,59 +1621,6 @@ void CGUIWindowVideoBase::OnDeleteItem(CFileItemPtr item) CFileUtils::DeleteItem(item); } -void CGUIWindowVideoBase::MarkWatched(const CFileItemPtr &item, bool bMark) -{ - if (!CProfilesManager::Get().GetCurrentProfile().canWriteDatabases()) - return; - // dont allow update while scanning - if (g_application.IsVideoScanning()) - { - CGUIDialogOK::ShowAndGetInput(257, 0, 14057, 0); - return; - } - - CVideoDatabase database; - if (database.Open()) - { - CFileItemList items; - if (item->m_bIsFolder) - { - CStdString strPath = item->GetPath(); - CDirectory::GetDirectory(strPath, items); - } - else - items.Add(item); - - for (int i=0;im_bIsFolder) - { - MarkWatched(pItem, bMark); - continue; - } - - if (pItem->HasVideoInfoTag() && - (( bMark && pItem->GetVideoInfoTag()->m_playCount) || - (!bMark && !(pItem->GetVideoInfoTag()->m_playCount)))) - continue; - -#ifdef HAS_UPNP - if (!URIUtils::IsUPnP(item->GetPath()) || !UPNP::CUPnP::MarkWatched(*pItem, bMark)) -#endif - { - // Clear resume bookmark - if (bMark) - database.ClearBookMarksOfFile(pItem->GetPath(), CBookmark::RESUME); - - database.SetPlayCount(*pItem, bMark ? 1 : 0); - } - } - - database.Close(); - } -} - void CGUIWindowVideoBase::LoadPlayList(const CStdString& strPlayList, int iPlayList /* = PLAYLIST_VIDEO */) { // if partymode is active, we disable it diff --git a/xbmc/video/windows/GUIWindowVideoBase.h b/xbmc/video/windows/GUIWindowVideoBase.h index f10498d885..1559934cd6 100644 --- a/xbmc/video/windows/GUIWindowVideoBase.h +++ b/xbmc/video/windows/GUIWindowVideoBase.h @@ -50,7 +50,6 @@ public: void AddToDatabase(int iItem); virtual void OnInfo(CFileItem* pItem, const ADDON::ScraperPtr& scraper); - static void MarkWatched(const CFileItemPtr &pItem, bool bMark); /*! \brief Show dialog allowing selection of wanted playback item */ static bool ShowPlaySelection(CFileItemPtr& item); diff --git a/xbmc/video/windows/GUIWindowVideoNav.cpp b/xbmc/video/windows/GUIWindowVideoNav.cpp index 41f791f6ee..38bd1b8695 100644 --- a/xbmc/video/windows/GUIWindowVideoNav.cpp +++ b/xbmc/video/windows/GUIWindowVideoNav.cpp @@ -956,10 +956,15 @@ void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &butt else buttons.Add(CONTEXT_BUTTON_SCAN, 13349); } - if (!item->IsPlugin() && !item->IsScript() && !item->IsLiveTV() && !item->IsAddonsPath() && - item->GetPath() != "sources://video/" && item->GetPath() != "special://videoplaylists/" && - item->GetPath().Left(19) != "newsmartplaylist://" && item->GetPath().Left(14) != "newplaylist://" && - item->GetPath().Left(9) != "newtag://") + if (!g_application.IsVideoScanning() && item->IsVideoDb() && item->HasVideoInfoTag() && + (!item->m_bIsFolder || m_vecItems->GetContent().Equals("movies") || m_vecItems->GetContent().Equals("tvshows"))) + { + buttons.Add(CONTEXT_BUTTON_EDIT, 16106); + } + else if (!item->IsPlugin() && !item->IsScript() && !item->IsLiveTV() && !item->IsAddonsPath() && + item->GetPath() != "sources://video/" && item->GetPath() != "special://videoplaylists/" && + item->GetPath().Left(19) != "newsmartplaylist://" && item->GetPath().Left(14) != "newplaylist://" && + item->GetPath().Left(9) != "newtag://") { if (item->m_bIsFolder) { @@ -975,11 +980,6 @@ void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &butt buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103); //Mark as Watched } } - if (!g_application.IsVideoScanning() && item->IsVideoDb() && item->HasVideoInfoTag() && - (!item->m_bIsFolder || m_vecItems->GetContent().Equals("movies") || m_vecItems->GetContent().Equals("tvshows"))) - { - buttons.Add(CONTEXT_BUTTON_EDIT, 16106); - } if (node == NODE_TYPE_SEASONS && item->m_bIsFolder) buttons.Add(CONTEXT_BUTTON_SET_SEASON_ART, 13511); @@ -1087,7 +1087,12 @@ bool CGUIWindowVideoNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button) { CONTEXT_BUTTON ret = (CONTEXT_BUTTON)CGUIDialogVideoInfo::ManageVideoItem(item); if (ret >= 0) + { + if (ret == CONTEXT_BUTTON_MARK_WATCHED) + m_viewControl.SetSelectedItem(itemNumber + 1); + Refresh(true); + } return true; } -- cgit v1.2.3 From 5bf2a988a7929cc398721ede0a4a76bdc3599d32 Mon Sep 17 00:00:00 2001 From: montellese Date: Mon, 22 Jul 2013 16:39:30 +0200 Subject: video: move "Remove episode bookmark" context menu entry under new "Manage ..." entry --- xbmc/video/dialogs/GUIDialogVideoInfo.cpp | 9 +++++++++ xbmc/video/windows/GUIWindowVideoNav.cpp | 20 -------------------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp index 30288203eb..322ae2fcef 100644 --- a/xbmc/video/dialogs/GUIDialogVideoInfo.cpp +++ b/xbmc/video/dialogs/GUIDialogVideoInfo.cpp @@ -977,6 +977,10 @@ int CGUIDialogVideoInfo::ManageVideoItem(const CFileItemPtr &item) buttons.Add(CONTEXT_BUTTON_SET_MOVIESET, 20465); } + if (type == VIDEODB_CONTENT_EPISODES && + item->GetVideoInfoTag()->m_iBookmarkId > 0) + buttons.Add(CONTEXT_BUTTON_UNLINK_BOOKMARK, 20405); + bool result = false; int button = CGUIDialogContextMenu::ShowAndGetChoice(buttons); if (button >= 0) @@ -1011,6 +1015,11 @@ int CGUIDialogVideoInfo::ManageVideoItem(const CFileItemPtr &item) break; } + case CONTEXT_BUTTON_UNLINK_BOOKMARK: + database.DeleteBookMarkForEpisode(*item->GetVideoInfoTag()); + result = true; + break; + default: result = false; break; diff --git a/xbmc/video/windows/GUIWindowVideoNav.cpp b/xbmc/video/windows/GUIWindowVideoNav.cpp index 38bd1b8695..62a9e38e11 100644 --- a/xbmc/video/windows/GUIWindowVideoNav.cpp +++ b/xbmc/video/windows/GUIWindowVideoNav.cpp @@ -1015,17 +1015,7 @@ void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &butt } if (item->IsVideoDb() && item->HasVideoInfoTag() && (!item->m_bIsFolder || node == NODE_TYPE_TITLE_TVSHOWS)) - { - if (info && info->Content() == CONTENT_TVSHOWS) - { - if(item->GetVideoInfoTag()->m_iBookmarkId != -1 && - item->GetVideoInfoTag()->m_iBookmarkId != 0) - { - buttons.Add(CONTEXT_BUTTON_UNLINK_BOOKMARK, 20405); - } - } buttons.Add(CONTEXT_BUTTON_DELETE, 646); - } } if (!m_vecItems->IsVideoDb() && !m_vecItems->IsVirtualDirectoryRoot()) @@ -1388,16 +1378,6 @@ bool CGUIWindowVideoNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button) return true; } - case CONTEXT_BUTTON_UNLINK_BOOKMARK: - { - m_database.Open(); - m_database.DeleteBookMarkForEpisode(*m_vecItems->Get(itemNumber)->GetVideoInfoTag()); - m_database.Close(); - CUtil::DeleteVideoDatabaseDirectoryCache(); - Refresh(); - return true; - } - default: break; -- cgit v1.2.3 From 8848f57475ca4f33eac9be7b17b139bac5163336 Mon Sep 17 00:00:00 2001 From: montellese Date: Mon, 22 Jul 2013 23:03:36 +0200 Subject: video: move "Stack" toggle to settings --- addons/skin.confluence/720p/MyVideoNav.xml | 6 ------ language/English/strings.po | 7 +++++-- system/settings/settings.xml | 4 ++-- xbmc/video/windows/GUIWindowVideoBase.cpp | 17 +++-------------- 4 files changed, 10 insertions(+), 24 deletions(-) diff --git a/addons/skin.confluence/720p/MyVideoNav.xml b/addons/skin.confluence/720p/MyVideoNav.xml index e3e0e56b01..a7256ee450 100644 --- a/addons/skin.confluence/720p/MyVideoNav.xml +++ b/addons/skin.confluence/720p/MyVideoNav.xml @@ -143,12 +143,6 @@ ButtonCommonValues - - Stack Toggle - 170 - ButtonCommonValues - - Flatten 170 diff --git a/language/English/strings.po b/language/English/strings.po index 920fda6ed9..1a9ffe5ed1 100644 --- a/language/English/strings.po +++ b/language/English/strings.po @@ -9976,7 +9976,10 @@ msgctxt "#20434" msgid "Sets" msgstr "" -#empty string with id 20435 +#: system/settings/settings.xml +msgctxt "#20435" +msgid "Combine split video items" +msgstr "" msgctxt "#20436" msgid "Export actor thumbs?" @@ -12967,7 +12970,7 @@ msgstr "" #: system/settings/settings.xml msgctxt "#36182" -msgid "No info available yet." +msgid "Enables direct playback of videos that are in folders, without having to open those folders first, as well as displaying multi-part video files as single items in non-library views." msgstr "" #: system/settings/settings.xml diff --git a/system/settings/settings.xml b/system/settings/settings.xml index d1e5effd1e..6b901e0ecc 100644 --- a/system/settings/settings.xml +++ b/system/settings/settings.xml @@ -598,8 +598,8 @@ 4 100024 - - 4 + + 1 false diff --git a/xbmc/video/windows/GUIWindowVideoBase.cpp b/xbmc/video/windows/GUIWindowVideoBase.cpp index ad6f626897..08f6f16c4b 100644 --- a/xbmc/video/windows/GUIWindowVideoBase.cpp +++ b/xbmc/video/windows/GUIWindowVideoBase.cpp @@ -92,7 +92,6 @@ using namespace PVR; #define CONTROL_LABELFILES 12 #define CONTROL_PLAY_DVD 6 -#define CONTROL_STACK 7 #define CONTROL_BTNSCAN 8 #define PROPERTY_GROUP_BY "group.by" @@ -156,21 +155,15 @@ bool CGUIWindowVideoBase::OnMessage(CGUIMessage& message) case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); - if (iControl == CONTROL_STACK) - { - CSettings::Get().ToggleBool("myvideos.stackvideos"); - CSettings::Get().Save(); - UpdateButtons(); - Update( m_vecItems->GetPath() ); - } #if defined(HAS_DVD_DRIVE) - else if (iControl == CONTROL_PLAY_DVD) + if (iControl == CONTROL_PLAY_DVD) { // play movie... MEDIA_DETECT::CAutorun::PlayDiscAskResume(g_mediaManager.TranslateDevicePath("")); } + else #endif - else if (iControl == CONTROL_BTNTYPE) + if (iControl == CONTROL_BTNTYPE) { CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_BTNTYPE); g_windowManager.SendMessage(msg); @@ -271,10 +264,6 @@ void CGUIWindowVideoBase::UpdateButtons() CONTROL_SELECT_ITEM(CONTROL_BTNTYPE, nWindow); CONTROL_ENABLE(CONTROL_BTNSCAN); - - SET_CONTROL_LABEL(CONTROL_STACK, 14000); // Stack - SET_CONTROL_SELECTED(GetID(), CONTROL_STACK, CSettings::Get().GetBool("myvideos.stackvideos")); - CONTROL_ENABLE_ON_CONDITION(CONTROL_STACK, m_stackingAvailable); CGUIMediaWindow::UpdateButtons(); } -- cgit v1.2.3 From bbf063f1408459d99e55443cf3d3cc24c0f31b26 Mon Sep 17 00:00:00 2001 From: montellese Date: Mon, 22 Jul 2013 23:06:23 +0200 Subject: CGUIWindowVideoBase: remove unused CONTROL_BTNSCAN --- xbmc/video/windows/GUIWindowVideoBase.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/xbmc/video/windows/GUIWindowVideoBase.cpp b/xbmc/video/windows/GUIWindowVideoBase.cpp index 08f6f16c4b..b95b2ae7f4 100644 --- a/xbmc/video/windows/GUIWindowVideoBase.cpp +++ b/xbmc/video/windows/GUIWindowVideoBase.cpp @@ -92,7 +92,6 @@ using namespace PVR; #define CONTROL_LABELFILES 12 #define CONTROL_PLAY_DVD 6 -#define CONTROL_BTNSCAN 8 #define PROPERTY_GROUP_BY "group.by" #define PROPERTY_GROUP_MIXED "group.mixed" @@ -262,8 +261,6 @@ void CGUIWindowVideoBase::UpdateButtons() // Select the current window as default item int nWindow = CSettings::Get().GetInt("myvideos.startwindow")-WINDOW_VIDEO_FILES; CONTROL_SELECT_ITEM(CONTROL_BTNTYPE, nWindow); - - CONTROL_ENABLE(CONTROL_BTNSCAN); CGUIMediaWindow::UpdateButtons(); } -- cgit v1.2.3 From 68829f47f4dba0d059d2f3d72a03c907e88011ea Mon Sep 17 00:00:00 2001 From: montellese Date: Mon, 22 Jul 2013 23:37:40 +0200 Subject: video: move "Flatten" toggle to settings --- addons/skin.confluence/720p/MyVideoNav.xml | 6 ------ language/English/strings.po | 7 +++++-- system/settings/settings.xml | 4 ++-- xbmc/video/windows/GUIWindowVideoNav.cpp | 13 ------------- 4 files changed, 7 insertions(+), 23 deletions(-) diff --git a/addons/skin.confluence/720p/MyVideoNav.xml b/addons/skin.confluence/720p/MyVideoNav.xml index a7256ee450..6b2a7ffe6c 100644 --- a/addons/skin.confluence/720p/MyVideoNav.xml +++ b/addons/skin.confluence/720p/MyVideoNav.xml @@ -143,12 +143,6 @@ ButtonCommonValues - - Flatten - 170 - ButtonCommonValues - - PartyMode diff --git a/language/English/strings.po b/language/English/strings.po index 1a9ffe5ed1..d578a1dee9 100644 --- a/language/English/strings.po +++ b/language/English/strings.po @@ -10068,7 +10068,10 @@ msgctxt "#20455" msgid "Listeners" msgstr "" -#empty string with id 20456 +#: system/settings/settings.xml +msgctxt "#20456" +msgid "Flatten library hierarchy" +msgstr "" msgctxt "#20457" msgid "Movie set" @@ -12975,7 +12978,7 @@ msgstr "" #: system/settings/settings.xml msgctxt "#36183" -msgid "No info available yet." +msgid "Removes the title, genre etc nodes from the library view. Selecting a category takes you straight to the title view." msgstr "" #: system/settings/settings.xml diff --git a/system/settings/settings.xml b/system/settings/settings.xml index 6b901e0ecc..38850e9362 100644 --- a/system/settings/settings.xml +++ b/system/settings/settings.xml @@ -602,8 +602,8 @@ 1 false - - 4 + + 1 false diff --git a/xbmc/video/windows/GUIWindowVideoNav.cpp b/xbmc/video/windows/GUIWindowVideoNav.cpp index 62a9e38e11..73e349b88e 100644 --- a/xbmc/video/windows/GUIWindowVideoNav.cpp +++ b/xbmc/video/windows/GUIWindowVideoNav.cpp @@ -77,7 +77,6 @@ using namespace std; #define CONTROL_FILTER 15 #define CONTROL_BTNPARTYMODE 16 -#define CONTROL_BTNFLATTEN 17 #define CONTROL_LABELEMPTY 18 #define CONTROL_UPDATE_LIBRARY 20 @@ -171,16 +170,6 @@ bool CGUIWindowVideoNav::OnMessage(CGUIMessage& message) OnFilterItems(GetProperty("filter").asString()); return true; } - else if (iControl == CONTROL_BTNFLATTEN) - { - CSettings::Get().ToggleBool("myvideos.flatten"); - CSettings::Get().Save(); - SetProperty("flattened", CSettings::Get().GetBool("myvideos.flatten")); - CUtil::DeleteVideoDatabaseDirectoryCache(); - SetupShares(); - Update(""); - return true; - } else if (iControl == CONTROL_BTNSHOWALL) { if (CMediaSettings::Get().GetWatchedMode(m_vecItems->GetContent()) == WatchedModeAll) @@ -552,8 +541,6 @@ void CGUIWindowVideoNav::UpdateButtons() SET_CONTROL_SELECTED(GetID(),CONTROL_BTNPARTYMODE, g_partyModeManager.IsEnabled()); - SET_CONTROL_SELECTED(GetID(),CONTROL_BTNFLATTEN, CSettings::Get().GetBool("myvideos.flatten")); - CONTROL_ENABLE_ON_CONDITION(CONTROL_UPDATE_LIBRARY, !m_vecItems->IsAddonsPath() && !m_vecItems->IsPlugin() && !m_vecItems->IsScript()); } -- cgit v1.2.3 From 4b726b644c3bb4fcd9c23f2c99944afa7e529542 Mon Sep 17 00:00:00 2001 From: montellese Date: Mon, 22 Jul 2013 23:38:54 +0200 Subject: video: add "Edit sort title" to "Manage ..." context menu entry --- language/English/strings.po | 6 +++++- xbmc/dialogs/GUIDialogContextMenu.h | 1 + xbmc/video/VideoDatabase.cpp | 27 ++++++++++++++++++++++++ xbmc/video/VideoDatabase.h | 1 + xbmc/video/dialogs/GUIDialogVideoInfo.cpp | 35 +++++++++++++++++++++++++++++++ xbmc/video/dialogs/GUIDialogVideoInfo.h | 1 + 6 files changed, 70 insertions(+), 1 deletion(-) 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; -- cgit v1.2.3