summaryrefslogtreecommitdiffstats
path: root/xbmc/video/dialogs/GUIDialogVideoInfo.h
blob: ac19e98abe446c1cdea3f42953888dcbaca3cf8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
 *  Copyright (C) 2005-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#pragma once

#include "MediaSource.h"
#include "guilib/GUIDialog.h"
#include "media/MediaType.h"

#include <memory>

class CFileItem;
class CFileItemList;
class CVideoDatabase;

class CGUIDialogVideoInfo :
      public CGUIDialog
{
public:
  CGUIDialogVideoInfo(void);
  ~CGUIDialogVideoInfo(void) override;
  bool OnMessage(CGUIMessage& message) override;
  bool OnAction(const CAction &action) override;
  void SetMovie(const CFileItem *item);
  bool NeedRefresh() const;
  bool RefreshAll() const;
  bool HasUpdatedThumb() const { return m_hasUpdatedThumb; }
  bool HasUpdatedUserrating() const { return m_hasUpdatedUserrating; }

  std::string GetThumbnail() const;
  std::shared_ptr<CFileItem> GetCurrentListItem(int offset = 0) override { return m_movieItem; }
  const CFileItemList& CurrentDirectory() const { return *m_castList; }
  bool HasListItems() const override { return true; }

  static void AddItemPathToFileBrowserSources(VECSOURCES &sources, const CFileItem &item);

  static int ManageVideoItem(const std::shared_ptr<CFileItem>& item);
  static bool UpdateVideoItemTitle(const std::shared_ptr<CFileItem>& pItem);
  static bool CanDeleteVideoItem(const std::shared_ptr<CFileItem>& item);
  static bool DeleteVideoItemFromDatabase(const std::shared_ptr<CFileItem>& item,
                                          bool unavailable = false);
  static bool DeleteVideoItem(const std::shared_ptr<CFileItem>& item, bool unavailable = false);

  static bool ManageMovieSets(const std::shared_ptr<CFileItem>& item);
  static bool GetMoviesForSet(const CFileItem *setItem, CFileItemList &originalMovies, CFileItemList &selectedMovies);
  static bool GetSetForMovie(const CFileItem* movieItem, std::shared_ptr<CFileItem>& selectedSet);
  static bool SetMovieSet(const CFileItem *movieItem, const CFileItem *selectedSet);

  static bool GetItemsForTag(const std::string &strHeading, const std::string &type, CFileItemList &items, int idTag = -1, bool showAll = true);
  static bool AddItemsToTag(const std::shared_ptr<CFileItem>& tagItem);
  static bool RemoveItemsFromTag(const std::shared_ptr<CFileItem>& tagItem);

  static bool ManageVideoItemArtwork(const std::shared_ptr<CFileItem>& item, const MediaType& type);

  static std::string GetLocalizedVideoType(const std::string &strType);

  static void ShowFor(const CFileItem& item);

protected:
  void OnInitWindow() override;
  void Update();
  void SetLabel(int iControl, const std::string& strLabel);
  void SetUserrating(int userrating) const;

  // link cast to movies
  void ClearCastList();
  /**
   * \brief Search the current directory for a string got from the virtual keyboard
   * \param strSearch The search string
   */
  void OnSearch(std::string& strSearch);
  /**
   * \brief Make the actual search for the OnSearch function.
   * \param strSearch The search string
   * \param items Items Found
   */
  void DoSearch(std::string& strSearch, CFileItemList& items) const;
  /**
   * \brief React on the selected search item
   * \param pItem Search result item
   */
  void OnSearchItemFound(const CFileItem* pItem);
  void Play(bool resume = false);
  void OnGetArt();
  void OnGetFanart();
  void OnSetUserrating() const;
  void PlayTrailer();

  static bool UpdateVideoItemSortTitle(const std::shared_ptr<CFileItem>& pItem);
  static bool LinkMovieToTvShow(const std::shared_ptr<CFileItem>& item,
                                bool bRemove,
                                CVideoDatabase& database);

  /*! \brief Pop up a fanart chooser. Does not utilise remote URLs.
   \param videoItem the item to choose fanart for.
   */
  static bool OnGetFanart(const std::shared_ptr<CFileItem>& videoItem);

  std::shared_ptr<CFileItem> m_movieItem;
  CFileItemList *m_castList;
  bool m_bViewReview = false;
  bool m_bRefresh = false;
  bool m_bRefreshAll = true;
  bool m_hasUpdatedThumb = false;
  bool m_hasUpdatedUserrating = false;
  int m_startUserrating = -1;

private:
  static std::string ChooseArtType(const CFileItem& item);
};