xbmc
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  ~CGUIDialogSelect(void) override;
25  bool OnMessage(CGUIMessage& message) override;
26  bool OnBack(int actionID) override;
27 
28  void Reset();
29  int Add(const std::string& strLabel);
30  int Add(const CFileItem& item);
31  void SetItems(const CFileItemList& items);
32  const CFileItemPtr GetSelectedFileItem() const;
33  int GetSelectedItem() const;
34  const std::vector<int>& GetSelectedItems() const;
35  void EnableButton(bool enable, int label);
36  void EnableButton(bool enable, const std::string& label);
37  void EnableButton2(bool enable, int label);
38  void EnableButton2(bool enable, const std::string& label);
39  bool IsButtonPressed();
40  bool IsButton2Pressed();
41  void Sort(bool bSortOrder = true);
42  void SetSelected(int iSelected);
43  void SetSelected(const std::string &strSelectedLabel);
44  void SetSelected(const std::vector<int>& selectedIndexes);
45  void SetSelected(const std::vector<std::string> &selectedLabels);
46  void SetUseDetails(bool useDetails);
47  void SetMultiSelection(bool multiSelection);
48  void SetButtonFocus(bool buttonFocus);
49 
50 protected:
51  explicit CGUIDialogSelect(int windowid);
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:341
Represents a list of files.
Definition: FileItem.h:721
Base class for controls.
Definition: GUIControl.h:75
Definition: GUIDialogSelect.h:20
Definition: GUIMessage.h:365
Definition: GUIDialogBoxBase.h:27
Represents a file on a share.
Definition: FileItem.h:102