kodi
GUIDialogSelect.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "GUIDialogBoxBase.h"
12 #include "view/GUIViewControl.h"
13 
14 #include <string>
15 #include <vector>
16 
17 class CFileItem;
18 class CFileItemList;
19 
21 {
22 public:
24  explicit CGUIDialogSelect(int windowid);
25  ~CGUIDialogSelect(void) override;
26  bool OnMessage(CGUIMessage& message) override;
27  bool OnBack(int actionID) override;
28 
29  void Reset();
30  int Add(const std::string& strLabel);
31  int Add(const CFileItem& item);
32  void SetItems(const CFileItemList& items);
33  const CFileItemPtr GetSelectedFileItem() const;
34  int GetSelectedItem() const;
35  const std::vector<int>& GetSelectedItems() const;
36  void EnableButton(bool enable, int label);
37  void EnableButton(bool enable, const std::string& label);
38  void EnableButton2(bool enable, int label);
39  void EnableButton2(bool enable, const std::string& label);
40  bool IsButtonPressed();
41  bool IsButton2Pressed();
42  void Sort(bool bSortOrder = true);
43  void SetSelected(int iSelected);
44  void SetSelected(const std::string &strSelectedLabel);
45  void SetSelected(const std::vector<int>& selectedIndexes);
46  void SetSelected(const std::vector<std::string> &selectedLabels);
47  void SetUseDetails(bool useDetails);
48  void SetMultiSelection(bool multiSelection);
49  void SetButtonFocus(bool buttonFocus);
50 
51 protected:
52  CGUIControl *GetFirstFocusableControl(int id) override;
53  void OnWindowLoaded() override;
54  void OnInitWindow() override;
55  void OnDeinitWindow(int nextWindowID) override;
56  void OnWindowUnload() override;
57 
58  virtual void OnSelect(int idx);
59 
60  CFileItemPtr m_selectedItem;
61  std::unique_ptr<CFileItemList> m_vecList;
62  CGUIViewControl m_viewControl;
63 
64 private:
65  bool m_bButtonEnabled;
66  bool m_bButton2Enabled;
67  bool m_bButtonPressed;
68  bool m_bButton2Pressed;
69  std::string m_buttonLabel;
70  std::string m_button2Label;
71  bool m_useDetails;
72  bool m_multiSelection;
73  bool m_focusToButton{};
74 
75  std::vector<int> m_selectedItems;
76 };
Definition: GUIViewControl.h:19
void OnInitWindow() override
Called on window open.
Definition: GUIDialogSelect.cpp:340
Represents a list of files.
Definition: FileItem.h:702
Base class for controls.
Definition: GUIControl.h:83
Definition: GUIDialogSelect.h:20
Definition: GUIMessage.h:365
Definition: GUIDialogBoxBase.h:27
Represents a file on a share.
Definition: FileItem.h:102