| 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 |
/*! |
| 12 |
\file GUIWindowMusicBase.h |
| 13 |
\brief |
| 14 |
*/ |
| 15 |
|
| 16 |
#include "music/MusicDatabase.h" |
| 17 |
#include "music/MusicInfoLoader.h" |
| 18 |
#include "music/MusicThumbLoader.h" |
| 19 |
#include "music/infoscanner/MusicInfoScraper.h" |
| 20 |
#include "windows/GUIMediaWindow.h" |
| 21 |
|
| 22 |
#include <vector> |
| 23 |
|
| 24 |
enum MusicSelectAction |
| 25 |
{ |
| 26 |
MUSIC_SELECT_ACTION_PLAY, |
| 27 |
MUSIC_SELECT_ACTION_RESUME, |
| 28 |
}; |
| 29 |
|
| 30 |
/*! |
| 31 |
\ingroup windows |
| 32 |
\brief The base class for music windows |
| 33 |
|
| 34 |
CGUIWindowMusicBase is the base class for |
| 35 |
all music windows. |
| 36 |
*/ |
| 37 |
class CGUIWindowMusicBase : public CGUIMediaWindow, public IBackgroundLoaderObserver |
| 38 |
{ |
| 39 |
public: |
| 40 |
CGUIWindowMusicBase(int id, const std::string &xmlFile); |
| 41 |
~CGUIWindowMusicBase(void) override; |
| 42 |
bool OnMessage(CGUIMessage& message) override; |
| 43 |
bool OnAction(const CAction &action) override; |
| 44 |
bool OnBack(int actionID) override; |
| 45 |
|
| 46 |
void DoScan(const std::string &strPath, bool bRescan = false); |
| 47 |
void RefreshContent(const std::string& strContent); |
| 48 |
|
| 49 |
/*! \brief Once a music source is added, store source in library, and prompt |
| 50 |
the user to scan this folder into the library |
| 51 |
\param oldName the original music source name |
| 52 |
\param source details of the music source (just added or edited) |
| 53 |
*/ |
| 54 |
static void OnAssignContent(const std::string& oldName, const CMediaSource& source); |
| 55 |
|
| 56 |
protected: |
| 57 |
void OnInitWindow() override; |
| 58 |
/*! |
| 59 |
\brief Will be called when an popup context menu has been asked for |
| 60 |
\param itemNumber List/thumb control item that has been clicked on |
| 61 |
*/ |
| 62 |
void GetContextButtons(int itemNumber, CContextButtons &buttons) override; |
| 63 |
void GetNonContextButtons(CContextButtons &buttons); |
| 64 |
bool OnContextButton(int itemNumber, CONTEXT_BUTTON button) override; |
| 65 |
bool OnAddMediaSource() override; |
| 66 |
/*! |
| 67 |
\brief Overwrite to update your gui buttons (visible, enable,...) |
| 68 |
*/ |
| 69 |
void UpdateButtons() override; |
| 70 |
|
| 71 |
bool GetDirectory(const std::string &strDirectory, CFileItemList &items) override; |
| 72 |
virtual void OnRetrieveMusicInfo(CFileItemList& items); |
| 73 |
void OnPrepareFileItems(CFileItemList& items) override; |
| 74 |
void OnRipCD(); |
| 75 |
std::string GetStartFolder(const std::string &dir) override; |
| 76 |
void OnItemLoaded(CFileItem* pItem) override {} |
| 77 |
|
| 78 |
virtual void OnScan(int iItem, bool bPromptRescan = false); |
| 79 |
|
| 80 |
bool CheckFilterAdvanced(CFileItemList &items) const override; |
| 81 |
bool CanContainFilter(const std::string &strDirectory) const override; |
| 82 |
|
| 83 |
bool OnSelect(int iItem) override; |
| 84 |
|
| 85 |
// new methods |
| 86 |
virtual void PlayItem(int iItem); |
| 87 |
bool OnPlayMedia(int iItem, const std::string &player = "") override; |
| 88 |
|
| 89 |
void RetrieveMusicInfo(); |
| 90 |
void OnItemInfo(int iItem); |
| 91 |
void OnItemInfoAll(const std::string& strPath, bool refresh = false); |
| 92 |
virtual void OnQueueItem(int iItem, bool first = false); |
| 93 |
enum ALLOW_SELECTION { SELECTION_ALLOWED = 0, SELECTION_AUTO, SELECTION_FORCED }; |
| 94 |
|
| 95 |
void OnRipTrack(int iItem); |
| 96 |
void LoadPlayList(const std::string& strPlayList) override; |
| 97 |
virtual void OnRemoveSource(int iItem); |
| 98 |
|
| 99 |
typedef std::vector <CFileItem*>::iterator ivecItems; ///< CFileItem* vector Iterator |
| 100 |
CGUIDialogProgress* m_dlgProgress; ///< Progress dialog |
| 101 |
|
| 102 |
CMusicDatabase m_musicdatabase; |
| 103 |
MUSIC_INFO::CMusicInfoLoader m_musicInfoLoader; |
| 104 |
|
| 105 |
CMusicThumbLoader m_thumbLoader; |
| 106 |
}; |