2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
21 #include "GUIDialogVideoInfo.h"
22 #include "Application.h"
23 #include "guilib/GUIWindow.h"
25 #include "guilib/GUIImage.h"
26 #include "utils/StringUtils.h"
27 #include "utils/URIUtils.h"
28 #include "video/windows/GUIWindowVideoNav.h"
29 #include "dialogs/GUIDialogFileBrowser.h"
30 #include "video/VideoInfoScanner.h"
31 #include "ApplicationMessenger.h"
32 #include "video/VideoInfoTag.h"
33 #include "guilib/GUIKeyboardFactory.h"
34 #include "guilib/GUIWindowManager.h"
35 #include "dialogs/GUIDialogOK.h"
36 #include "dialogs/GUIDialogYesNo.h"
37 #include "dialogs/GUIDialogSelect.h"
38 #include "dialogs/GUIDialogProgress.h"
39 #include "filesystem/File.h"
41 #include "storage/MediaManager.h"
42 #include "utils/AsyncFileCopy.h"
43 #include "profiles/ProfilesManager.h"
44 #include "settings/AdvancedSettings.h"
45 #include "settings/MediaSourceSettings.h"
46 #include "settings/Settings.h"
47 #include "guilib/Key.h"
48 #include "guilib/LocalizeStrings.h"
49 #include "GUIUserMessages.h"
50 #include "TextureCache.h"
51 #include "music/MusicDatabase.h"
53 #include "video/VideoThumbLoader.h"
54 #include "filesystem/Directory.h"
55 #include "filesystem/VideoDatabaseDirectory.h"
57 #include "network/upnp/UPnP.h"
61 using namespace XFILE;
63 #define CONTROL_IMAGE 3
64 #define CONTROL_TEXTAREA 4
65 #define CONTROL_BTN_TRACKS 5
66 #define CONTROL_BTN_REFRESH 6
67 #define CONTROL_BTN_PLAY 8
68 #define CONTROL_BTN_RESUME 9
69 #define CONTROL_BTN_GET_THUMB 10
70 #define CONTROL_BTN_PLAY_TRAILER 11
71 #define CONTROL_BTN_GET_FANART 12
72 #define CONTROL_BTN_DIRECTOR 13
74 #define CONTROL_LIST 50
76 CGUIDialogVideoInfo::CGUIDialogVideoInfo(void)
77 : CGUIDialog(WINDOW_DIALOG_VIDEO_INFO, "DialogVideoInfo.xml")
78 , m_movieItem(new CFileItem)
82 m_hasUpdatedThumb = false;
83 m_castList = new CFileItemList;
84 m_loadType = KEEP_IN_MEMORY;
87 CGUIDialogVideoInfo::~CGUIDialogVideoInfo(void)
92 bool CGUIDialogVideoInfo::OnMessage(CGUIMessage& message)
94 switch ( message.GetMessage() )
96 case GUI_MSG_WINDOW_DEINIT:
102 case GUI_MSG_CLICKED:
104 int iControl = message.GetSenderId();
105 if (iControl == CONTROL_BTN_REFRESH)
107 if (m_movieItem->GetVideoInfoTag()->m_iSeason < 0 && !m_movieItem->GetVideoInfoTag()->m_strShowTitle.empty()) // tv show
109 bool bCanceled=false;
110 if (CGUIDialogYesNo::ShowAndGetInput(20377,20378,-1,-1,bCanceled))
112 m_bRefreshAll = true;
116 db.SetPathHash(m_movieItem->GetVideoInfoTag()->m_strPath,"");
121 m_bRefreshAll = false;
130 else if (iControl == CONTROL_BTN_TRACKS)
132 m_bViewReview = !m_bViewReview;
135 else if (iControl == CONTROL_BTN_PLAY)
139 else if (iControl == CONTROL_BTN_RESUME)
143 else if (iControl == CONTROL_BTN_GET_THUMB)
147 else if (iControl == CONTROL_BTN_PLAY_TRAILER)
151 else if (iControl == CONTROL_BTN_GET_FANART)
155 else if (iControl == CONTROL_BTN_DIRECTOR)
157 CStdString strDirector = StringUtils::Join(m_movieItem->GetVideoInfoTag()->m_director, g_advancedSettings.m_videoItemSeparator);
158 OnSearch(strDirector);
160 else if (iControl == CONTROL_LIST)
162 int iAction = message.GetParam1();
163 if (ACTION_SELECT_ITEM == iAction || ACTION_MOUSE_LEFT_CLICK == iAction)
165 CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), iControl);
167 int iItem = msg.GetParam1();
168 if (iItem < 0 || iItem >= m_castList->Size())
170 CStdString strItem = m_castList->Get(iItem)->GetLabel();
171 CStdString strFind = StringUtils::Format(" %s ",g_localizeStrings.Get(20347).c_str());
172 size_t iPos = strItem.find(strFind);
173 if (iPos == std::string::npos)
174 iPos = strItem.size();
175 CStdString tmp = strItem.substr(0, iPos);
181 case GUI_MSG_NOTIFY_ALL:
183 if (IsActive() && message.GetParam1() == GUI_MSG_UPDATE_ITEM && message.GetItem())
185 CFileItemPtr item = boost::static_pointer_cast<CFileItem>(message.GetItem());
186 if (item && m_movieItem->GetPath().Equals(item->GetPath()))
187 { // Just copy over the stream details and the thumb if we don't already have one
188 if (!m_movieItem->HasArt("thumb"))
189 m_movieItem->SetArt("thumb", item->GetArt("thumb"));
190 m_movieItem->GetVideoInfoTag()->m_streamDetails = item->GetVideoInfoTag()->m_streamDetails;
197 return CGUIDialog::OnMessage(message);
200 void CGUIDialogVideoInfo::OnInitWindow()
203 m_bRefreshAll = true;
204 m_hasUpdatedThumb = false;
205 m_bViewReview = true;
207 CVideoDatabase database;
208 ADDON::ScraperPtr scraper;
212 scraper = database.GetScraperForPath(m_movieItem->GetVideoInfoTag()->GetPath());
216 CONTROL_ENABLE_ON_CONDITION(CONTROL_BTN_REFRESH, (CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) && !StringUtils::StartsWithNoCase(m_movieItem->GetVideoInfoTag()->m_strIMDBNumber, "xx") && scraper);
217 CONTROL_ENABLE_ON_CONDITION(CONTROL_BTN_GET_THUMB, (CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) && !StringUtils::StartsWithNoCase(m_movieItem->GetVideoInfoTag()->m_strIMDBNumber.c_str() + 2, "plugin"));
219 VIDEODB_CONTENT_TYPE type = (VIDEODB_CONTENT_TYPE)m_movieItem->GetVideoContentType();
220 if (type == VIDEODB_CONTENT_TVSHOWS || type == VIDEODB_CONTENT_MOVIES)
221 CONTROL_ENABLE_ON_CONDITION(CONTROL_BTN_GET_FANART, (CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) && !StringUtils::StartsWithNoCase(m_movieItem->GetVideoInfoTag()->m_strIMDBNumber.c_str() + 2, "plugin"));
223 CONTROL_DISABLE(CONTROL_BTN_GET_FANART);
227 CGUIDialog::OnInitWindow();
230 bool CGUIDialogVideoInfo::OnAction(const CAction &action)
232 if (action.GetID() == ACTION_SHOW_INFO)
237 return CGUIDialog::OnAction(action);
240 void CGUIDialogVideoInfo::SetMovie(const CFileItem *item)
242 *m_movieItem = *item;
243 // setup cast list + determine type. We need to do this here as it makes
244 // sure that content type (among other things) is set correctly for the
245 // old fixed id labels that we have floating around (they may be using
246 // content type to determine visibility, so we'll set the wrong label)
248 VIDEODB_CONTENT_TYPE type = (VIDEODB_CONTENT_TYPE)m_movieItem->GetVideoContentType();
249 if (type == VIDEODB_CONTENT_MUSICVIDEOS)
251 CMusicDatabase database;
253 const std::vector<std::string> &artists = m_movieItem->GetVideoInfoTag()->m_artist;
254 for (std::vector<std::string>::const_iterator it = artists.begin(); it != artists.end(); ++it)
256 int idArtist = database.GetArtistByName(*it);
257 CStdString thumb = database.GetArtForItem(idArtist, "artist", "thumb");
258 CFileItemPtr item(new CFileItem(*it));
260 item->SetArt("thumb", thumb);
261 item->SetIconImage("DefaultArtist.png");
262 m_castList->Add(item);
264 m_castList->SetContent("musicvideos");
267 { // movie/show/episode
268 for (CVideoInfoTag::iCast it = m_movieItem->GetVideoInfoTag()->m_cast.begin(); it != m_movieItem->GetVideoInfoTag()->m_cast.end(); ++it)
270 CStdString character;
271 if (it->strRole.empty())
272 character = it->strName;
274 character = StringUtils::Format("%s %s %s", it->strName.c_str(), g_localizeStrings.Get(20347).c_str(), it->strRole.c_str());
275 CFileItemPtr item(new CFileItem(it->strName));
276 if (!it->thumb.empty())
277 item->SetArt("thumb", it->thumb);
278 else if (CSettings::Get().GetBool("videolibrary.actorthumbs"))
279 { // backward compatibility
280 CStdString thumb = CScraperUrl::GetThumbURL(it->thumbUrl.GetFirstThumb());
283 item->SetArt("thumb", thumb);
284 CTextureCache::Get().BackgroundCacheImage(thumb);
287 item->SetIconImage("DefaultActor.png");
288 item->SetLabel(character);
289 m_castList->Add(item);
292 if (type == VIDEODB_CONTENT_TVSHOWS)
294 m_castList->SetContent("tvshows");
295 // special case stuff for shows (not currently retrieved from the library in filemode (ref: GetTvShowInfo vs GetTVShowsByWhere)
296 m_movieItem->m_dateTime = m_movieItem->GetVideoInfoTag()->m_premiered;
297 if(m_movieItem->GetVideoInfoTag()->m_iYear == 0 && m_movieItem->m_dateTime.IsValid())
298 m_movieItem->GetVideoInfoTag()->m_iYear = m_movieItem->m_dateTime.GetYear();
299 m_movieItem->SetProperty("totalepisodes", m_movieItem->GetVideoInfoTag()->m_iEpisode);
300 m_movieItem->SetProperty("numepisodes", m_movieItem->GetVideoInfoTag()->m_iEpisode); // info view has no concept of current watched/unwatched filter as we could come here from files view, but set for consistency
301 m_movieItem->SetProperty("watchedepisodes", m_movieItem->GetVideoInfoTag()->m_playCount);
302 m_movieItem->SetProperty("unwatchedepisodes", m_movieItem->GetVideoInfoTag()->m_iEpisode - m_movieItem->GetVideoInfoTag()->m_playCount);
303 m_movieItem->GetVideoInfoTag()->m_playCount = (m_movieItem->GetVideoInfoTag()->m_iEpisode == m_movieItem->GetVideoInfoTag()->m_playCount) ? 1 : 0;
305 else if (type == VIDEODB_CONTENT_EPISODES)
307 m_castList->SetContent("episodes");
308 // special case stuff for episodes (not currently retrieved from the library in filemode (ref: GetEpisodeInfo vs GetEpisodesByWhere)
309 m_movieItem->m_dateTime = m_movieItem->GetVideoInfoTag()->m_firstAired;
310 if(m_movieItem->GetVideoInfoTag()->m_iYear == 0 && m_movieItem->m_dateTime.IsValid())
311 m_movieItem->GetVideoInfoTag()->m_iYear = m_movieItem->m_dateTime.GetYear();
312 // retrieve the season thumb.
313 // TODO: should we use the thumbloader for this?
317 if (m_movieItem->GetVideoInfoTag()->m_iSeason > -1)
319 int seasonID = m_movieItem->GetVideoInfoTag()->m_iIdSeason;
321 seasonID = db.GetSeasonId(m_movieItem->GetVideoInfoTag()->m_iIdShow,
322 m_movieItem->GetVideoInfoTag()->m_iSeason);
323 CGUIListItem::ArtMap thumbs;
324 if (db.GetArtForItem(seasonID, "season", thumbs))
326 for (CGUIListItem::ArtMap::iterator i = thumbs.begin(); i != thumbs.end(); i++)
327 m_movieItem->SetArt("season." + i->first, i->second);
333 else if (type == VIDEODB_CONTENT_MOVIES)
335 m_castList->SetContent("movies");
337 // local trailers should always override non-local, so check
338 // for a local one if the registered trailer is online
339 if (m_movieItem->GetVideoInfoTag()->m_strTrailer.empty() ||
340 URIUtils::IsInternetStream(m_movieItem->GetVideoInfoTag()->m_strTrailer))
342 CStdString localTrailer = m_movieItem->FindTrailer();
343 if (!localTrailer.empty())
345 m_movieItem->GetVideoInfoTag()->m_strTrailer = localTrailer;
346 CVideoDatabase database;
349 database.SetSingleValue(VIDEODB_CONTENT_MOVIES, VIDEODB_ID_TRAILER,
350 m_movieItem->GetVideoInfoTag()->m_iDbId,
351 m_movieItem->GetVideoInfoTag()->m_strTrailer);
353 CUtil::DeleteVideoDatabaseDirectoryCache();
359 CVideoThumbLoader loader;
360 loader.LoadItem(m_movieItem.get());
363 void CGUIDialogVideoInfo::Update()
365 // setup plot text area
366 CStdString strTmp = m_movieItem->GetVideoInfoTag()->m_strPlot;
367 if (!(!m_movieItem->GetVideoInfoTag()->m_strShowTitle.empty() && m_movieItem->GetVideoInfoTag()->m_iSeason == 0)) // dont apply to tvshows
368 if (m_movieItem->GetVideoInfoTag()->m_playCount == 0 && !CSettings::Get().GetBool("videolibrary.showunwatchedplots"))
369 strTmp = g_localizeStrings.Get(20370);
371 StringUtils::Trim(strTmp);
372 SetLabel(CONTROL_TEXTAREA, strTmp);
374 CGUIMessage msg(GUI_MSG_LABEL_BIND, GetID(), CONTROL_LIST, 0, 0, m_castList);
377 if (GetControl(CONTROL_BTN_TRACKS)) // if no CONTROL_BTN_TRACKS found - allow skinner full visibility control over CONTROL_TEXTAREA and CONTROL_LIST
381 if (!m_movieItem->GetVideoInfoTag()->m_artist.empty())
383 SET_CONTROL_LABEL(CONTROL_BTN_TRACKS, 133);
387 SET_CONTROL_LABEL(CONTROL_BTN_TRACKS, 206);
390 SET_CONTROL_HIDDEN(CONTROL_LIST);
391 SET_CONTROL_VISIBLE(CONTROL_TEXTAREA);
395 SET_CONTROL_LABEL(CONTROL_BTN_TRACKS, 207);
397 SET_CONTROL_HIDDEN(CONTROL_TEXTAREA);
398 SET_CONTROL_VISIBLE(CONTROL_LIST);
402 // Check for resumability
403 if (m_movieItem->GetVideoInfoTag()->m_resumePoint.timeInSeconds > 0.0)
404 CONTROL_ENABLE(CONTROL_BTN_RESUME);
406 CONTROL_DISABLE(CONTROL_BTN_RESUME);
408 CONTROL_ENABLE(CONTROL_BTN_PLAY);
410 // update the thumbnail
411 const CGUIControl* pControl = GetControl(CONTROL_IMAGE);
414 CGUIImage* pImageControl = (CGUIImage*)pControl;
415 pImageControl->FreeResources();
416 pImageControl->SetFileName(m_movieItem->GetArt("thumb"));
418 // tell our GUI to completely reload all controls (as some of them
419 // are likely to have had this image in use so will need refreshing)
420 if (m_hasUpdatedThumb)
422 CGUIMessage reload(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_REFRESH_THUMBS);
423 g_windowManager.SendMessage(reload);
427 bool CGUIDialogVideoInfo::NeedRefresh() const
432 bool CGUIDialogVideoInfo::RefreshAll() const
434 return m_bRefreshAll;
437 /// \brief Search the current directory for a string got from the virtual keyboard
438 void CGUIDialogVideoInfo::OnSearch(CStdString& strSearch)
440 CGUIDialogProgress *progress = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
443 progress->SetHeading(194);
444 progress->SetLine(0, strSearch);
445 progress->SetLine(1, "");
446 progress->SetLine(2, "");
447 progress->StartModal();
448 progress->Progress();
451 DoSearch(strSearch, items);
458 CGUIDialogSelect* pDlgSelect = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
460 pDlgSelect->SetHeading(283);
462 for (int i = 0; i < (int)items.Size(); i++)
464 CFileItemPtr pItem = items[i];
465 pDlgSelect->Add(pItem->GetLabel());
468 pDlgSelect->DoModal();
470 int iItem = pDlgSelect->GetSelectedLabel();
474 CFileItem* pSelItem = new CFileItem(*items[iItem]);
476 OnSearchItemFound(pSelItem);
482 CGUIDialogOK::ShowAndGetInput(194, 284, 0, 0);
486 /// \brief Make the actual search for the OnSearch function.
487 /// \param strSearch The search string
488 /// \param items Items Found
489 void CGUIDialogVideoInfo::DoSearch(CStdString& strSearch, CFileItemList& items)
495 CFileItemList movies;
496 db.GetMoviesByActor(strSearch, movies);
497 for (int i = 0; i < movies.Size(); ++i)
499 CStdString label = movies[i]->GetVideoInfoTag()->m_strTitle;
500 if (movies[i]->GetVideoInfoTag()->m_iYear > 0)
501 label += StringUtils::Format(" (%i)", movies[i]->GetVideoInfoTag()->m_iYear);
502 movies[i]->SetLabel(label);
504 CGUIWindowVideoBase::AppendAndClearSearchItems(movies, "[" + g_localizeStrings.Get(20338) + "] ", items);
506 db.GetTvShowsByActor(strSearch, movies);
507 for (int i = 0; i < movies.Size(); ++i)
509 CStdString label = movies[i]->GetVideoInfoTag()->m_strShowTitle;
510 if (movies[i]->GetVideoInfoTag()->m_iYear > 0)
511 label += StringUtils::Format(" (%i)", movies[i]->GetVideoInfoTag()->m_iYear);
512 movies[i]->SetLabel(label);
514 CGUIWindowVideoBase::AppendAndClearSearchItems(movies, "[" + g_localizeStrings.Get(20364) + "] ", items);
516 db.GetEpisodesByActor(strSearch, movies);
517 for (int i = 0; i < movies.Size(); ++i)
519 CStdString label = movies[i]->GetVideoInfoTag()->m_strTitle + " (" + movies[i]->GetVideoInfoTag()->m_strShowTitle + ")";
520 movies[i]->SetLabel(label);
522 CGUIWindowVideoBase::AppendAndClearSearchItems(movies, "[" + g_localizeStrings.Get(20359) + "] ", items);
524 db.GetMusicVideosByArtist(strSearch, movies);
525 for (int i = 0; i < movies.Size(); ++i)
527 CStdString label = StringUtils::Join(movies[i]->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator) + " - " + movies[i]->GetVideoInfoTag()->m_strTitle;
528 if (movies[i]->GetVideoInfoTag()->m_iYear > 0)
529 label += StringUtils::Format(" (%i)", movies[i]->GetVideoInfoTag()->m_iYear);
530 movies[i]->SetLabel(label);
532 CGUIWindowVideoBase::AppendAndClearSearchItems(movies, "[" + g_localizeStrings.Get(20391) + "] ", items);
536 /// \brief React on the selected search item
537 /// \param pItem Search result item
538 void CGUIDialogVideoInfo::OnSearchItemFound(const CFileItem* pItem)
540 VIDEODB_CONTENT_TYPE type = (VIDEODB_CONTENT_TYPE)pItem->GetVideoContentType();
546 CVideoInfoTag movieDetails;
547 if (type == VIDEODB_CONTENT_MOVIES)
548 db.GetMovieInfo(pItem->GetPath(), movieDetails, pItem->GetVideoInfoTag()->m_iDbId);
549 if (type == VIDEODB_CONTENT_EPISODES)
550 db.GetEpisodeInfo(pItem->GetPath(), movieDetails, pItem->GetVideoInfoTag()->m_iDbId);
551 if (type == VIDEODB_CONTENT_TVSHOWS)
552 db.GetTvShowInfo(pItem->GetPath(), movieDetails, pItem->GetVideoInfoTag()->m_iDbId);
553 if (type == VIDEODB_CONTENT_MUSICVIDEOS)
554 db.GetMusicVideoInfo(pItem->GetPath(), movieDetails, pItem->GetVideoInfoTag()->m_iDbId);
557 CFileItem item(*pItem);
558 *item.GetVideoInfoTag() = movieDetails;
560 // refresh our window entirely
565 void CGUIDialogVideoInfo::ClearCastList()
567 CGUIMessage msg(GUI_MSG_LABEL_RESET, GetID(), CONTROL_LIST);
572 void CGUIDialogVideoInfo::Play(bool resume)
574 if (!m_movieItem->GetVideoInfoTag()->m_strEpisodeGuide.empty())
576 CStdString strPath = StringUtils::Format("videodb://tvshows/titles/%i/",m_movieItem->GetVideoInfoTag()->m_iDbId);
578 g_windowManager.ActivateWindow(WINDOW_VIDEO_NAV,strPath);
582 CFileItem movie(*m_movieItem->GetVideoInfoTag());
583 if (m_movieItem->GetVideoInfoTag()->m_strFileNameAndPath.empty())
584 movie.SetPath(m_movieItem->GetPath());
585 CGUIWindowVideoNav* pWindow = (CGUIWindowVideoNav*)g_windowManager.GetWindow(WINDOW_VIDEO_NAV);
591 movie.m_lStartOffset = STARTOFFSET_RESUME;
592 else if (!CGUIWindowVideoBase::ShowResumeMenu(movie))
594 // The Resume dialog was closed without any choice
598 pWindow->PlayMovie(&movie);
602 string CGUIDialogVideoInfo::ChooseArtType(const CFileItem &videoItem, map<string, string> ¤tArt)
605 CGUIDialogSelect *dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
606 if (!dialog || !videoItem.HasVideoInfoTag())
610 dialog->SetHeading(13511);
612 dialog->SetUseDetails(true);
613 dialog->EnableButton(true, 13516);
618 vector<string> artTypes = CVideoThumbLoader::GetArtTypes(videoItem.GetVideoInfoTag()->m_type);
620 // add in any stored art for this item that is non-empty.
621 db.GetArtForItem(videoItem.GetVideoInfoTag()->m_iDbId, videoItem.GetVideoInfoTag()->m_type, currentArt);
622 for (CGUIListItem::ArtMap::iterator i = currentArt.begin(); i != currentArt.end(); ++i)
624 if (!i->second.empty() && find(artTypes.begin(), artTypes.end(), i->first) == artTypes.end())
625 artTypes.push_back(i->first);
628 // add any art types that exist for other media items of the same type
629 vector<string> dbArtTypes;
630 db.GetArtTypes(videoItem.GetVideoInfoTag()->m_type, dbArtTypes);
631 for (vector<string>::const_iterator it = dbArtTypes.begin(); it != dbArtTypes.end(); it++)
633 if (find(artTypes.begin(), artTypes.end(), *it) == artTypes.end())
634 artTypes.push_back(*it);
637 for (vector<string>::const_iterator i = artTypes.begin(); i != artTypes.end(); ++i)
640 CFileItemPtr item(new CFileItem(type, "false"));
641 item->SetLabel(type);
642 if (videoItem.HasArt(type))
643 item->SetArt("thumb", videoItem.GetArt(type));
647 dialog->SetItems(&items);
650 if (dialog->IsButtonPressed())
652 // Get the new artwork name
653 CStdString strArtworkName;
654 if (!CGUIKeyboardFactory::ShowAndGetInput(strArtworkName, g_localizeStrings.Get(13516), false))
657 return strArtworkName;
660 return dialog->GetSelectedItem()->GetLabel();
663 void CGUIDialogVideoInfo::OnGetArt()
665 map<string, string> currentArt;
666 string type = ChooseArtType(*m_movieItem, currentArt);
670 // TODO: this can be removed once these are unified.
671 if (type == "fanart")
678 if (m_movieItem->HasArt(type))
680 CFileItemPtr item(new CFileItem("thumb://Current", false));
681 item->SetArt("thumb", m_movieItem->GetArt(type));
682 item->SetLabel(g_localizeStrings.Get(13512));
685 else if ((type == "poster" || type == "banner") && currentArt.find("thumb") != currentArt.end())
686 { // add the 'thumb' type in
687 CFileItemPtr item(new CFileItem("thumb://Thumb", false));
688 item->SetArt("thumb", currentArt["thumb"]);
689 item->SetLabel(g_localizeStrings.Get(13512));
693 // Grab the thumbnails from the web
694 vector<CStdString> thumbs;
695 int season = (m_movieItem->GetVideoInfoTag()->m_type == "season") ? m_movieItem->GetVideoInfoTag()->m_iSeason : -1;
696 m_movieItem->GetVideoInfoTag()->m_strPictureURL.GetThumbURLs(thumbs, type, season);
698 for (unsigned int i = 0; i < thumbs.size(); ++i)
700 CStdString strItemPath = StringUtils::Format("thumb://Remote%i", i);
701 CFileItemPtr item(new CFileItem(strItemPath, false));
702 item->SetArt("thumb", thumbs[i]);
703 item->SetIconImage("DefaultPicture.png");
704 item->SetLabel(g_localizeStrings.Get(13513));
706 // TODO: Do we need to clear the cached image?
707 // CTextureCache::Get().ClearCachedImage(thumb);
711 CStdString localThumb = CVideoThumbLoader::GetLocalArt(*m_movieItem, type);
712 if (!localThumb.empty())
714 CFileItemPtr item(new CFileItem("thumb://Local", false));
715 item->SetArt("thumb", localThumb);
716 item->SetLabel(g_localizeStrings.Get(13514));
720 { // no local thumb exists, so we are just using the IMDb thumb or cached thumb
721 // which is probably the IMDb thumb. These could be wrong, so allow the user
722 // to delete the incorrect thumb
723 CFileItemPtr item(new CFileItem("thumb://None", false));
724 item->SetIconImage("DefaultVideo.png");
725 item->SetLabel(g_localizeStrings.Get(13515));
730 VECSOURCES sources(*CMediaSourceSettings::Get().GetSources("video"));
731 AddItemPathToFileBrowserSources(sources, *m_movieItem);
732 g_mediaManager.GetLocalDrives(sources);
733 if (CGUIDialogFileBrowser::ShowAndGetImage(items, sources, g_localizeStrings.Get(13511), result) &&
734 result != "thumb://Current") // user didn't choose the one they have
737 if (StringUtils::StartsWith(result, "thumb://Remote"))
739 int number = atoi(result.substr(14).c_str());
740 newThumb = thumbs[number];
742 else if (result == "thumb://Thumb")
743 newThumb = currentArt["thumb"];
744 else if (result == "thumb://Local")
745 newThumb = localThumb;
746 else if (CFile::Exists(result))
751 // update thumb in the database
755 db.SetArtForItem(m_movieItem->GetVideoInfoTag()->m_iDbId, m_movieItem->GetVideoInfoTag()->m_type, type, newThumb);
758 CUtil::DeleteVideoDatabaseDirectoryCache(); // to get them new thumbs to show
759 m_movieItem->SetArt(type, newThumb);
760 if (m_movieItem->HasProperty("set_folder_thumb"))
761 { // have a folder thumb to set as well
762 VIDEO::CVideoInfoScanner::ApplyThumbToFolder(m_movieItem->GetProperty("set_folder_thumb").asString(), newThumb);
764 m_hasUpdatedThumb = true;
771 // re-open the art selection dialog as we come back from
772 // the image selection dialog
776 // Allow user to select a Fanart
777 void CGUIDialogVideoInfo::OnGetFanart()
781 CFileItem item(*m_movieItem->GetVideoInfoTag());
782 if (item.HasArt("fanart"))
784 CFileItemPtr itemCurrent(new CFileItem("fanart://Current",false));
785 itemCurrent->SetArt("thumb", item.GetArt("fanart"));
786 itemCurrent->SetLabel(g_localizeStrings.Get(20440));
787 items.Add(itemCurrent);
790 // ensure the fanart is unpacked
791 m_movieItem->GetVideoInfoTag()->m_fanart.Unpack();
793 // Grab the thumbnails from the web
794 for (unsigned int i = 0; i < m_movieItem->GetVideoInfoTag()->m_fanart.GetNumFanarts(); i++)
796 CStdString strItemPath = StringUtils::Format("fanart://Remote%i",i);
797 CFileItemPtr item(new CFileItem(strItemPath, false));
798 CStdString thumb = m_movieItem->GetVideoInfoTag()->m_fanart.GetPreviewURL(i);
799 item->SetArt("thumb", CTextureUtils::GetWrappedThumbURL(thumb));
800 item->SetIconImage("DefaultPicture.png");
801 item->SetLabel(g_localizeStrings.Get(20441));
803 // TODO: Do we need to clear the cached image?
804 // CTextureCache::Get().ClearCachedImage(thumb);
808 CStdString strLocal = item.GetLocalFanart();
809 if (!strLocal.empty())
811 CFileItemPtr itemLocal(new CFileItem("fanart://Local",false));
812 itemLocal->SetArt("thumb", strLocal);
813 itemLocal->SetLabel(g_localizeStrings.Get(20438));
815 // TODO: Do we need to clear the cached image?
816 CTextureCache::Get().ClearCachedImage(strLocal);
817 items.Add(itemLocal);
821 CFileItemPtr itemNone(new CFileItem("fanart://None", false));
822 itemNone->SetIconImage("DefaultVideo.png");
823 itemNone->SetLabel(g_localizeStrings.Get(20439));
828 VECSOURCES sources(*CMediaSourceSettings::Get().GetSources("video"));
829 AddItemPathToFileBrowserSources(sources, item);
830 g_mediaManager.GetLocalDrives(sources);
832 if (!CGUIDialogFileBrowser::ShowAndGetImage(items, sources, g_localizeStrings.Get(20437), result, &flip, 20445) || result.Equals("fanart://Current"))
833 return; // user cancelled
835 if (result.Equals("fanart://Local"))
838 if (StringUtils::StartsWith(result, "fanart://Remote"))
840 int iFanart = atoi(result.substr(15).c_str());
841 // set new primary fanart, and update our database accordingly
842 m_movieItem->GetVideoInfoTag()->m_fanart.SetPrimaryFanart(iFanart);
846 db.UpdateFanart(*m_movieItem, (VIDEODB_CONTENT_TYPE)m_movieItem->GetVideoContentType());
849 result = m_movieItem->GetVideoInfoTag()->m_fanart.GetImageURL();
851 else if (result.Equals("fanart://None") || !CFile::Exists(result))
854 // set the fanart image
855 if (flip && !result.empty())
856 result = CTextureUtils::GetWrappedImageURL(result, "", "flipped");
860 db.SetArtForItem(m_movieItem->GetVideoInfoTag()->m_iDbId, m_movieItem->GetVideoInfoTag()->m_type, "fanart", result);
864 CUtil::DeleteVideoDatabaseDirectoryCache(); // to get them new thumbs to show
865 m_movieItem->SetArt("fanart", result);
866 m_hasUpdatedThumb = true;
872 void CGUIDialogVideoInfo::PlayTrailer()
875 item.SetPath(m_movieItem->GetVideoInfoTag()->m_strTrailer);
876 *item.GetVideoInfoTag() = *m_movieItem->GetVideoInfoTag();
877 item.GetVideoInfoTag()->m_streamDetails.Reset();
878 item.GetVideoInfoTag()->m_strTitle = StringUtils::Format("%s (%s)",
879 m_movieItem->GetVideoInfoTag()->m_strTitle.c_str(),
880 g_localizeStrings.Get(20410).c_str());
881 CVideoThumbLoader::SetArt(item, m_movieItem->GetArt());
882 item.GetVideoInfoTag()->m_iDbId = -1;
883 item.GetVideoInfoTag()->m_iFileId = -1;
888 if (item.IsPlayList())
889 CApplicationMessenger::Get().MediaPlay(item);
891 CApplicationMessenger::Get().PlayFile(item);
894 void CGUIDialogVideoInfo::SetLabel(int iControl, const CStdString &strLabel)
896 if (strLabel.empty())
898 SET_CONTROL_LABEL(iControl, 416); // "Not available"
902 SET_CONTROL_LABEL(iControl, strLabel);
906 std::string CGUIDialogVideoInfo::GetThumbnail() const
908 return m_movieItem->GetArt("thumb");
911 void CGUIDialogVideoInfo::AddItemPathToFileBrowserSources(VECSOURCES &sources, const CFileItem &item)
913 if (!item.HasVideoInfoTag())
916 CStdString itemDir = item.GetVideoInfoTag()->m_basePath;
920 itemDir = item.GetVideoInfoTag()->GetPath();
922 CFileItem itemTmp(itemDir, false);
923 if (itemTmp.IsVideo())
924 itemDir = URIUtils::GetParentPath(itemDir);
926 if (!itemDir.empty() && CDirectory::Exists(itemDir))
928 CMediaSource itemSource;
929 itemSource.strName = g_localizeStrings.Get(36041);
930 itemSource.strPath = itemDir;
931 sources.push_back(itemSource);
935 int CGUIDialogVideoInfo::ManageVideoItem(const CFileItemPtr &item)
937 if (item == NULL || !item->IsVideoDb() || !item->HasVideoInfoTag() || item->GetVideoInfoTag()->m_iDbId < 0)
940 CVideoDatabase database;
941 if (!database.Open())
944 VIDEODB_CONTENT_TYPE type = (VIDEODB_CONTENT_TYPE)item->GetVideoContentType();
945 int dbId = item->GetVideoInfoTag()->m_iDbId;
947 CContextButtons buttons;
948 buttons.Add(CONTEXT_BUTTON_EDIT, 16105);
950 if (type == VIDEODB_CONTENT_MOVIES || type == VIDEODB_CONTENT_TVSHOWS)
951 buttons.Add(CONTEXT_BUTTON_EDIT_SORTTITLE, 16107);
953 if (item->m_bIsFolder)
955 // Have both options for folders since we don't know whether all childs are watched/unwatched
956 buttons.Add(CONTEXT_BUTTON_MARK_UNWATCHED, 16104); //Mark as UnWatched
957 buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103); //Mark as Watched
961 if (item->GetOverlayImage().Equals("OverlayWatched.png"))
962 buttons.Add(CONTEXT_BUTTON_MARK_UNWATCHED, 16104); //Mark as UnWatched
964 buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103); //Mark as Watched
967 if (type == VIDEODB_CONTENT_MOVIES)
969 // only show link/unlink if there are tvshows available
970 if (database.HasContent(VIDEODB_CONTENT_TVSHOWS))
972 buttons.Add(CONTEXT_BUTTON_LINK_MOVIE, 20384);
973 if (database.IsLinkedToTvshow(dbId))
974 buttons.Add(CONTEXT_BUTTON_UNLINK_MOVIE, 20385);
977 // set or change movie set the movie belongs to
978 buttons.Add(CONTEXT_BUTTON_SET_MOVIESET, 20465);
981 if (type == VIDEODB_CONTENT_EPISODES &&
982 item->GetVideoInfoTag()->m_iBookmarkId > 0)
983 buttons.Add(CONTEXT_BUTTON_UNLINK_BOOKMARK, 20405);
986 int button = CGUIDialogContextMenu::ShowAndGetChoice(buttons);
989 switch ((CONTEXT_BUTTON)button)
991 case CONTEXT_BUTTON_EDIT:
992 result = UpdateVideoItemTitle(item);
995 case CONTEXT_BUTTON_EDIT_SORTTITLE:
996 result = UpdateVideoItemSortTitle(item);
999 case CONTEXT_BUTTON_MARK_WATCHED:
1000 result = MarkWatched(item, true);
1003 case CONTEXT_BUTTON_MARK_UNWATCHED:
1004 result = MarkWatched(item, false);
1007 case CONTEXT_BUTTON_LINK_MOVIE:
1008 result = LinkMovieToTvShow(item, false, database);
1011 case CONTEXT_BUTTON_UNLINK_MOVIE:
1012 result = LinkMovieToTvShow(item, true, database);
1015 case CONTEXT_BUTTON_SET_MOVIESET:
1017 CFileItemPtr selectedSet;
1018 if (GetSetForMovie(item.get(), selectedSet))
1019 result = SetMovieSet(item.get(), selectedSet.get());
1023 case CONTEXT_BUTTON_UNLINK_BOOKMARK:
1024 database.DeleteBookMarkForEpisode(*item->GetVideoInfoTag());
1042 //Add change a title's name
1043 bool CGUIDialogVideoInfo::UpdateVideoItemTitle(const CFileItemPtr &pItem)
1045 // dont allow update while scanning
1046 if (g_application.IsVideoScanning())
1048 CGUIDialogOK::ShowAndGetInput(257, 0, 14057, 0);
1052 CVideoDatabase database;
1053 if (!database.Open())
1056 int iDbId = pItem->GetVideoInfoTag()->m_iDbId;
1057 CVideoInfoTag detail;
1058 VIDEODB_CONTENT_TYPE iType = (VIDEODB_CONTENT_TYPE)pItem->GetVideoContentType();
1059 if (iType == VIDEODB_CONTENT_MOVIES)
1060 database.GetMovieInfo("", detail, iDbId);
1061 else if (iType == VIDEODB_CONTENT_MOVIE_SETS)
1062 database.GetSetInfo(iDbId, detail);
1063 else if (iType == VIDEODB_CONTENT_EPISODES)
1064 database.GetEpisodeInfo(pItem->GetPath(), detail, iDbId);
1065 else if (iType == VIDEODB_CONTENT_TVSHOWS)
1066 database.GetTvShowInfo(pItem->GetVideoInfoTag()->m_strFileNameAndPath, detail, iDbId);
1067 else if (iType == VIDEODB_CONTENT_MUSICVIDEOS)
1068 database.GetMusicVideoInfo(pItem->GetVideoInfoTag()->m_strFileNameAndPath, detail, iDbId);
1070 // get the new title
1071 if (!CGUIKeyboardFactory::ShowAndGetInput(detail.m_strTitle, g_localizeStrings.Get(16105), false))
1074 database.UpdateMovieTitle(iDbId, detail.m_strTitle, iType);
1078 bool CGUIDialogVideoInfo::MarkWatched(const CFileItemPtr &item, bool bMark)
1080 if (!CProfilesManager::Get().GetCurrentProfile().canWriteDatabases())
1083 // dont allow update while scanning
1084 if (g_application.IsVideoScanning())
1086 CGUIDialogOK::ShowAndGetInput(257, 0, 14057, 0);
1090 CVideoDatabase database;
1091 if (!database.Open())
1094 CFileItemList items;
1095 if (item->m_bIsFolder)
1097 CStdString strPath = item->GetPath();
1098 CDirectory::GetDirectory(strPath, items);
1103 for (int i = 0; i < items.Size(); ++i)
1105 CFileItemPtr pTmpItem = items[i];
1106 if (pTmpItem->m_bIsFolder)
1108 MarkWatched(pTmpItem, bMark);
1112 if (pTmpItem->HasVideoInfoTag() &&
1113 ((bMark && pTmpItem->GetVideoInfoTag()->m_playCount) ||
1114 (!bMark && !pTmpItem->GetVideoInfoTag()->m_playCount)))
1118 if (!URIUtils::IsUPnP(item->GetPath()) || !UPNP::CUPnP::MarkWatched(*pTmpItem, bMark))
1121 // Clear resume bookmark
1123 database.ClearBookMarksOfFile(pTmpItem->GetPath(), CBookmark::RESUME);
1125 database.SetPlayCount(*pTmpItem, bMark ? 1 : 0);
1134 bool CGUIDialogVideoInfo::GetMoviesForSet(const CFileItem *setItem, CFileItemList &originalMovies, CFileItemList &selectedMovies)
1136 CVideoDatabase videodb;
1137 if (!videodb.Open())
1140 CStdString strHeading = StringUtils::Format(g_localizeStrings.Get(20457));
1141 CStdString baseDir = StringUtils::Format("videodb://movies/sets/%d", setItem->GetVideoInfoTag()->m_iDbId);
1143 if (!CDirectory::GetDirectory(baseDir, originalMovies) || originalMovies.Size() <= 0) // keep a copy of the original members of the set
1146 CFileItemList listItems;
1147 if (!videodb.GetSortedVideos(MediaTypeMovie, "videodb://movies", SortDescription(), listItems) || listItems.Size() <= 0)
1150 CGUIDialogSelect *dialog = (CGUIDialogSelect *)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
1154 listItems.Sort(SortByLabel, SortOrderAscending, SortAttributeIgnoreArticle);
1157 dialog->SetMultiSelection(true);
1158 dialog->SetHeading(strHeading);
1159 dialog->SetItems(&listItems);
1160 vector<int> selectedIndices;
1161 for (int i = 0; i < originalMovies.Size(); i++)
1163 for (int listIndex = 0; listIndex < listItems.Size(); listIndex++)
1165 if (listItems.Get(listIndex)->GetVideoInfoTag()->m_iDbId == originalMovies[i]->GetVideoInfoTag()->m_iDbId)
1167 selectedIndices.push_back(listIndex);
1172 dialog->SetSelected(selectedIndices);
1173 dialog->EnableButton(true, 186);
1176 if (dialog->IsConfirmed())
1178 selectedMovies.Copy(dialog->GetSelectedItems());
1179 return (selectedMovies.Size() > 0);
1185 bool CGUIDialogVideoInfo::GetSetForMovie(const CFileItem *movieItem, CFileItemPtr &selectedSet)
1187 CVideoDatabase videodb;
1188 if (!videodb.Open())
1191 CFileItemList listItems;
1192 CStdString baseDir = "videodb://movies/sets/";
1193 if (!CDirectory::GetDirectory(baseDir, listItems) || listItems.Size() <= 0)
1195 listItems.Sort(SortByLabel, SortOrderAscending, SortAttributeIgnoreArticle);
1197 int currentSetId = 0;
1198 CStdString currentSetLabel;
1200 if (movieItem->GetVideoInfoTag()->m_iSetId > currentSetId)
1202 currentSetId = movieItem->GetVideoInfoTag()->m_iSetId;
1203 currentSetLabel = videodb.GetSetById(currentSetId);
1206 if (currentSetId > 0)
1209 CStdString strClear = StringUtils::Format(g_localizeStrings.Get(20467), currentSetLabel.c_str());
1210 CFileItemPtr clearItem(new CFileItem(strClear));
1211 clearItem->GetVideoInfoTag()->m_iDbId = -1; // -1 will be used to clear set
1212 listItems.AddFront(clearItem, 0);
1213 // add keep current set item
1214 CStdString strKeep = StringUtils::Format(g_localizeStrings.Get(20469), currentSetLabel.c_str());
1215 CFileItemPtr keepItem(new CFileItem(strKeep));
1216 keepItem->GetVideoInfoTag()->m_iDbId = currentSetId;
1217 listItems.AddFront(keepItem, 1);
1220 CGUIDialogSelect *dialog = (CGUIDialogSelect *)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
1224 CStdString strHeading = StringUtils::Format(g_localizeStrings.Get(20466));
1226 dialog->SetHeading(strHeading);
1227 dialog->SetItems(&listItems);
1228 if (currentSetId >= 0)
1230 for (int listIndex = 0; listIndex < listItems.Size(); listIndex++)
1232 if (listItems.Get(listIndex)->GetVideoInfoTag()->m_iDbId == currentSetId)
1234 dialog->SetSelected(listIndex);
1239 dialog->EnableButton(true, 20468); // new set via button
1242 if (dialog->IsButtonPressed())
1243 { // creating new set
1244 CStdString newSetTitle;
1245 if (!CGUIKeyboardFactory::ShowAndGetInput(newSetTitle, g_localizeStrings.Get(20468), false))
1247 int idSet = videodb.AddSet(newSetTitle);
1248 map<string, string> movieArt, setArt;
1249 if (!videodb.GetArtForItem(idSet, "set", setArt))
1251 videodb.GetArtForItem(movieItem->GetVideoInfoTag()->m_iDbId, "movie", movieArt);
1252 videodb.SetArtForItem(idSet, "set", movieArt);
1254 CFileItemPtr newSet(new CFileItem(newSetTitle));
1255 newSet->GetVideoInfoTag()->m_iDbId = idSet;
1256 selectedSet = newSet;
1259 else if (dialog->IsConfirmed())
1261 selectedSet = dialog->GetSelectedItem();
1262 return (selectedSet != NULL);
1268 bool CGUIDialogVideoInfo::SetMovieSet(const CFileItem *movieItem, const CFileItem *selectedSet)
1270 CVideoDatabase videodb;
1271 if (!videodb.Open())
1274 videodb.SetMovieSet(movieItem->GetVideoInfoTag()->m_iDbId, selectedSet->GetVideoInfoTag()->m_iDbId);
1278 bool CGUIDialogVideoInfo::UpdateVideoItemSortTitle(const CFileItemPtr &pItem)
1280 // dont allow update while scanning
1281 if (g_application.IsVideoScanning())
1283 CGUIDialogOK::ShowAndGetInput(257, 0, 14057, 0);
1287 CVideoDatabase database;
1288 if (!database.Open())
1291 int iDbId = pItem->GetVideoInfoTag()->m_iDbId;
1292 CVideoInfoTag detail;
1293 VIDEODB_CONTENT_TYPE iType = (VIDEODB_CONTENT_TYPE)pItem->GetVideoContentType();
1294 if (iType == VIDEODB_CONTENT_MOVIES)
1295 database.GetMovieInfo("", detail, iDbId);
1296 else if (iType == VIDEODB_CONTENT_TVSHOWS)
1297 database.GetTvShowInfo(pItem->GetVideoInfoTag()->m_strFileNameAndPath, detail, iDbId);
1299 CStdString currentTitle;
1300 if (detail.m_strSortTitle.empty())
1301 currentTitle = detail.m_strTitle;
1303 currentTitle = detail.m_strSortTitle;
1305 // get the new sort title
1306 if (!CGUIKeyboardFactory::ShowAndGetInput(currentTitle, g_localizeStrings.Get(16107), false))
1309 return database.UpdateVideoSortTitle(iDbId, currentTitle, iType);
1312 bool CGUIDialogVideoInfo::LinkMovieToTvShow(const CFileItemPtr &item, bool bRemove, CVideoDatabase &database)
1314 int dbId = item->GetVideoInfoTag()->m_iDbId;
1320 if (!database.GetLinksToTvShow(dbId, ids))
1323 for (unsigned int i = 0; i < ids.size(); ++i)
1326 database.GetTvShowInfo("", tag, ids[i]);
1327 CFileItemPtr show(new CFileItem(tag));
1333 database.GetTvShowsNav("videodb://tvshows/titles", list);
1335 // remove already linked shows
1337 if (!database.GetLinksToTvShow(dbId, ids))
1340 for (int i = 0; i < list.Size(); )
1343 for (j = 0; j < ids.size(); ++j)
1345 if (list[i]->GetVideoInfoTag()->m_iDbId == ids[j])
1348 if (j == ids.size())
1355 int iSelectedLabel = 0;
1356 if (list.Size() > 1)
1358 list.Sort(SortByLabel, SortOrderAscending, CSettings::Get().GetBool("filelists.ignorethewhensorting") ? SortAttributeIgnoreArticle : SortAttributeNone);
1359 CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
1361 pDialog->SetItems(&list);
1362 pDialog->SetHeading(20356);
1364 iSelectedLabel = pDialog->GetSelectedLabel();
1367 if (iSelectedLabel > -1)
1368 return database.LinkMovieToTvshow(dbId, list[iSelectedLabel]->GetVideoInfoTag()->m_iDbId, bRemove);