summaryrefslogtreecommitdiffstats
path: root/xbmc/pvr/windows/GUIWindowPVRSearch.h
blob: d6f6a35195274d79046769eb2923097b8195ad9f (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
/*
 *  Copyright (C) 2012-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 "dialogs/GUIDialogContextMenu.h"
#include "pvr/dialogs/GUIDialogPVRGuideSearch.h"
#include "pvr/windows/GUIWindowPVRBase.h"

#include <memory>
#include <string>

class CFileItem;

namespace PVR
{
class CPVREpgSearchFilter;

class CGUIWindowPVRSearchBase : public CGUIWindowPVRBase
{
public:
  CGUIWindowPVRSearchBase(bool bRadio, int id, const std::string& xmlFile);
  ~CGUIWindowPVRSearchBase() override;

  bool OnAction(const CAction& action) override;
  bool OnMessage(CGUIMessage& message) override;
  void GetContextButtons(int itemNumber, CContextButtons& buttons) override;
  bool OnContextButton(int itemNumber, CONTEXT_BUTTON button) override;
  bool Update(const std::string& strDirectory, bool updateFilterPath = true) override;
  void UpdateButtons() override;

  /*!
   * @brief set the item to search similar events for.
   * @param item the epg event to search similar events for.
   */
  void SetItemToSearch(const CFileItem& item);

  /*!
   * @brief Open the search dialog for the given search filter item.
   * @param item the epg search filter.
   * @return The result of the dialog
   */
  CGUIDialogPVRGuideSearch::Result OpenDialogSearch(const CFileItem& item);

protected:
  void OnPrepareFileItems(CFileItemList& items) override;

private:
  bool OnContextButtonClear(CFileItem* item, CONTEXT_BUTTON button);

  CGUIDialogPVRGuideSearch::Result OpenDialogSearch(
      const std::shared_ptr<CPVREpgSearchFilter>& searchFilter);

  void ExecuteSearch();

  void SetSearchFilter(const std::shared_ptr<CPVREpgSearchFilter>& searchFilter);

  bool m_bSearchConfirmed;
  std::shared_ptr<CPVREpgSearchFilter> m_searchfilter;
};

class CGUIWindowPVRTVSearch : public CGUIWindowPVRSearchBase
{
public:
  CGUIWindowPVRTVSearch() : CGUIWindowPVRSearchBase(false, WINDOW_TV_SEARCH, "MyPVRSearch.xml") {}

protected:
  std::string GetRootPath() const override;
  std::string GetStartFolder(const std::string& dir) override;
  std::string GetDirectoryPath() override;
};

class CGUIWindowPVRRadioSearch : public CGUIWindowPVRSearchBase
{
public:
  CGUIWindowPVRRadioSearch() : CGUIWindowPVRSearchBase(true, WINDOW_RADIO_SEARCH, "MyPVRSearch.xml")
  {
  }

protected:
  std::string GetRootPath() const override;
  std::string GetStartFolder(const std::string& dir) override;
  std::string GetDirectoryPath() override;
};
} // namespace PVR