2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
17 #include "XBDateTime.h"
18 #include "guilib/GUIListItem.h"
19 #include "threads/CriticalSection.h"
20 #include "utils/IArchivable.h"
21 #include "utils/ISerializable.h"
22 #include "utils/ISortable.h"
23 #include "utils/SortUtils.h"
31 enum class VideoDbContentType
;
43 class CPictureInfoTag
;
56 class CPVRChannelGroupMember
;
58 class CPVREpgSearchFilter
;
60 class CPVRTimerInfoTag
;
73 typedef std::shared_ptr
<CCueDocument
> CCueDocumentPtr
;
76 typedef std::shared_ptr
<const IEvent
> EventPtr
;
78 /* special startoffset used to indicate that we wish to resume */
79 #define STARTOFFSET_RESUME (-1)
85 enum EFileFolderType
{
86 EFILEFOLDER_TYPE_ALWAYS
= 1<<0,
87 EFILEFOLDER_TYPE_ONCLICK
= 1<<1,
88 EFILEFOLDER_TYPE_ONBROWSE
= 1<<2,
90 EFILEFOLDER_MASK_ALL
= 0xff,
91 EFILEFOLDER_MASK_ONCLICK
= EFILEFOLDER_TYPE_ALWAYS
92 | EFILEFOLDER_TYPE_ONCLICK
,
93 EFILEFOLDER_MASK_ONBROWSE
= EFILEFOLDER_TYPE_ALWAYS
94 | EFILEFOLDER_TYPE_ONCLICK
95 | EFILEFOLDER_TYPE_ONBROWSE
,
99 \brief Represents a file on a share
103 public CGUIListItem
, public IArchivable
, public ISerializable
, public ISortable
107 CFileItem(const CFileItem
& item
);
108 explicit CFileItem(const CGUIListItem
& item
);
109 explicit CFileItem(const std::string
& strLabel
);
110 explicit CFileItem(const char* strLabel
);
111 CFileItem(const CURL
& path
, bool bIsFolder
);
112 CFileItem(const std::string
& strPath
, bool bIsFolder
);
113 explicit CFileItem(const CSong
& song
);
114 CFileItem(const CSong
& song
, const MUSIC_INFO::CMusicInfoTag
& music
);
115 CFileItem(const CURL
&path
, const CAlbum
& album
);
116 CFileItem(const std::string
&path
, const CAlbum
& album
);
117 explicit CFileItem(const CArtist
& artist
);
118 explicit CFileItem(const CGenre
& genre
);
119 explicit CFileItem(const MUSIC_INFO::CMusicInfoTag
& music
);
120 explicit CFileItem(const CVideoInfoTag
& movie
);
121 explicit CFileItem(const std::shared_ptr
<PVR::CPVREpgInfoTag
>& tag
);
122 explicit CFileItem(const std::shared_ptr
<PVR::CPVREpgSearchFilter
>& filter
);
123 explicit CFileItem(const std::shared_ptr
<PVR::CPVRChannelGroupMember
>& channelGroupMember
);
124 explicit CFileItem(const std::shared_ptr
<PVR::CPVRRecording
>& record
);
125 explicit CFileItem(const std::shared_ptr
<PVR::CPVRTimerInfoTag
>& timer
);
126 explicit CFileItem(const CMediaSource
& share
);
127 explicit CFileItem(std::shared_ptr
<const ADDON::IAddon
> addonInfo
);
128 explicit CFileItem(const EventPtr
& eventLogEntry
);
130 ~CFileItem(void) override
;
131 CGUIListItem
* Clone() const override
{ return new CFileItem(*this); }
133 const CURL
GetURL() const;
134 void SetURL(const CURL
& url
);
135 bool IsURL(const CURL
& url
) const;
136 const std::string
& GetPath() const { return m_strPath
; }
137 void SetPath(const std::string
& path
) { m_strPath
= path
; }
138 bool IsPath(const std::string
& path
, bool ignoreURLOptions
= false) const;
140 const CURL
GetDynURL() const;
141 void SetDynURL(const CURL
& url
);
142 const std::string
&GetDynPath() const;
143 void SetDynPath(const std::string
&path
);
145 /*! \brief reset class to it's default values as per construction.
146 Free's all allocated memory.
150 CFileItem
& operator=(const CFileItem
& item
);
151 void Archive(CArchive
& ar
) override
;
152 void Serialize(CVariant
& value
) const override
;
153 void ToSortable(SortItem
&sortable
, Field field
) const override
;
154 void ToSortable(SortItem
&sortable
, const Fields
&fields
) const;
155 bool IsFileItem() const override
{ return true; }
157 bool Exists(bool bUseCache
= true) const;
160 \brief Check whether an item is an optical media folder or its parent.
161 This will return the non-empty path to the playable entry point of the media
162 one or two levels down (VIDEO_TS.IFO for DVDs or index.bdmv for BDs).
163 The returned path will be empty if folder does not meet this criterion.
164 \return non-empty string if item is optical media folder, empty otherwise.
166 std::string
GetOpticalMediaPath() const;
168 \brief Check whether an item is a video item. Note that this returns true for
169 anything with a video info tag, so that may include eg. folders.
170 \return true if item is video, false otherwise.
172 bool IsVideo() const;
174 bool IsDiscStub() const;
177 \brief Check whether an item is a picture item. Note that this returns true for
178 anything with a picture info tag, so that may include eg. folders.
179 \return true if item is picture, false otherwise.
181 bool IsPicture() const;
182 bool IsLyrics() const;
183 bool IsSubtitle() const;
186 \brief Check whether an item is an audio item. Note that this returns true for
187 anything with a music info tag, so that may include eg. folders.
188 \return true if item is audio, false otherwise.
190 bool IsAudio() const;
193 \brief Check whether an item is 'deleted' (for example, a trashed pvr recording).
194 \return true if item is 'deleted', false otherwise.
196 bool IsDeleted() const;
199 \brief Check whether an item is an audio book item.
200 \return true if item is audiobook, false otherwise.
202 bool IsAudioBook() const;
205 bool IsCUESheet() const;
206 bool IsInternetStream(const bool bStrictCheck
= false) const;
207 bool IsStreamedFilesystem() const;
208 bool IsPlayList() const;
209 bool IsSmartPlayList() const;
210 bool IsLibraryFolder() const;
211 bool IsPythonScript() const;
212 bool IsPlugin() const;
213 bool IsScript() const;
214 bool IsAddonsPath() const;
215 bool IsSourcesPath() const;
217 bool IsVideoExtras() const;
218 bool IsDiscImage() const;
219 bool IsOpticalMediaFile() const;
220 bool IsDVDFile(bool bVobs
= true, bool bIfos
= true) const;
221 bool IsBDFile() const;
222 bool IsBluray() const;
223 bool IsProtectedBlurayDisc() const;
229 bool IsISO9660() const;
232 bool IsOnDVD() const;
233 bool IsOnLAN() const;
236 bool IsRemote() const;
239 bool IsStack() const;
240 bool IsFavourite() const;
241 bool IsMultiPath() const;
242 bool IsMusicDb() const;
243 bool IsVideoDb() const;
245 bool IsPVRChannel() const;
246 bool IsPVRChannelGroup() const;
247 bool IsPVRRecording() const;
248 bool IsUsablePVRRecording() const;
249 bool IsDeletedPVRRecording() const;
250 bool IsInProgressPVRRecording() const;
251 bool IsPVRTimer() const;
252 bool IsType(const char *ext
) const;
253 bool IsVirtualDirectoryRoot() const;
254 bool IsReadOnly() const;
255 bool CanQueue() const;
256 void SetCanQueue(bool bYesNo
);
257 bool IsParentFolder() const;
258 bool IsFileFolder(EFileFolderType types
= EFILEFOLDER_MASK_ALL
) const;
259 bool IsRemovable() const;
261 bool IsLiveTV() const;
263 bool IsAndroidApp() const;
265 bool HasVideoVersions() const;
266 bool HasVideoExtras() const;
268 void RemoveExtension();
270 void FillInDefaultIcon();
271 void SetFileSizeLabel();
272 void SetLabel(const std::string
&strLabel
) override
;
273 VideoDbContentType
GetVideoContentType() const;
274 bool IsLabelPreformatted() const { return m_bLabelPreformatted
; }
275 void SetLabelPreformatted(bool bYesNo
) { m_bLabelPreformatted
=bYesNo
; }
276 bool SortsOnTop() const { return m_specialSort
== SortSpecialOnTop
; }
277 bool SortsOnBottom() const { return m_specialSort
== SortSpecialOnBottom
; }
278 void SetSpecialSort(SortSpecial sort
) { m_specialSort
= sort
; }
280 inline bool HasMusicInfoTag() const
282 return m_musicInfoTag
!= NULL
;
285 MUSIC_INFO::CMusicInfoTag
* GetMusicInfoTag();
287 inline const MUSIC_INFO::CMusicInfoTag
* GetMusicInfoTag() const
289 return m_musicInfoTag
;
292 bool HasVideoInfoTag() const;
294 CVideoInfoTag
* GetVideoInfoTag();
296 const CVideoInfoTag
* GetVideoInfoTag() const;
298 inline bool HasEPGInfoTag() const
300 return m_epgInfoTag
.get() != NULL
;
303 inline const std::shared_ptr
<PVR::CPVREpgInfoTag
> GetEPGInfoTag() const
308 bool HasEPGSearchFilter() const { return m_epgSearchFilter
!= nullptr; }
310 const std::shared_ptr
<PVR::CPVREpgSearchFilter
> GetEPGSearchFilter() const
312 return m_epgSearchFilter
;
315 inline bool HasPVRChannelGroupMemberInfoTag() const
317 return m_pvrChannelGroupMemberInfoTag
.get() != nullptr;
320 inline const std::shared_ptr
<PVR::CPVRChannelGroupMember
> GetPVRChannelGroupMemberInfoTag() const
322 return m_pvrChannelGroupMemberInfoTag
;
325 bool HasPVRChannelInfoTag() const;
326 const std::shared_ptr
<PVR::CPVRChannel
> GetPVRChannelInfoTag() const;
328 inline bool HasPVRRecordingInfoTag() const
330 return m_pvrRecordingInfoTag
.get() != NULL
;
333 inline const std::shared_ptr
<PVR::CPVRRecording
> GetPVRRecordingInfoTag() const
335 return m_pvrRecordingInfoTag
;
338 inline bool HasPVRTimerInfoTag() const
340 return m_pvrTimerInfoTag
!= NULL
;
343 inline const std::shared_ptr
<PVR::CPVRTimerInfoTag
> GetPVRTimerInfoTag() const
345 return m_pvrTimerInfoTag
;
349 \brief return the item to play. will be almost 'this', but can be different (e.g. "Play recording" from PVR EPG grid window)
350 \return the item to play
352 CFileItem
GetItemToPlay() const;
355 \brief Test if this item has a valid resume point set.
356 \return True if this item has a resume point and it is set, false otherwise.
358 bool IsResumePointSet() const;
361 \brief Return the current resume time.
362 \return The time in seconds from the start to resume playing from.
364 double GetCurrentResumeTime() const;
367 \brief Return the current resume time and part.
368 \param startOffset will be filled with the resume time offset in seconds if item has a resume point set, is unchanged otherwise
369 \param partNumber will be filled with the part number if item has a resume point set, is unchanged otherwise
370 \return True if the item has a resume point set, false otherwise.
372 bool GetCurrentResumeTimeAndPartNumber(int64_t& startOffset
, int& partNumber
) const;
375 * \brief Test if this item type can be resumed.
376 * \return True if this item is a folder and has at least one child with a partway resume bookmark
377 * or at least one unwatched child or if it is not a folder, if it has a partway resume bookmark,
380 bool IsResumable() const;
383 * \brief Get the offset where start the playback.
384 * \return The offset value as ms.
385 * Can return also special value -1, see define STARTOFFSET_RESUME.
387 int64_t GetStartOffset() const { return m_lStartOffset
; }
390 * \brief Set the offset where start the playback.
391 * \param offset Set the offset value as ms,
392 or the special value STARTOFFSET_RESUME.
394 void SetStartOffset(const int64_t offset
) { m_lStartOffset
= offset
; }
397 * \brief Get the end offset.
398 * \return The offset value as ms.
400 int64_t GetEndOffset() const { return m_lEndOffset
; }
403 * \brief Set the end offset.
404 * \param offset Set the offset as ms.
406 void SetEndOffset(const int64_t offset
) { m_lEndOffset
= offset
; }
408 inline bool HasPictureInfoTag() const
410 return m_pictureInfoTag
!= NULL
;
413 inline const CPictureInfoTag
* GetPictureInfoTag() const
415 return m_pictureInfoTag
;
418 bool HasAddonInfo() const { return m_addonInfo
!= nullptr; }
419 const std::shared_ptr
<const ADDON::IAddon
> GetAddonInfo() const { return m_addonInfo
; }
421 inline bool HasGameInfoTag() const
423 return m_gameInfoTag
!= NULL
;
426 KODI::GAME::CGameInfoTag
* GetGameInfoTag();
428 inline const KODI::GAME::CGameInfoTag
* GetGameInfoTag() const
430 return m_gameInfoTag
;
433 CPictureInfoTag
* GetPictureInfoTag();
436 \brief Get the local fanart for this item if it exists
437 \return path to the local fanart for this item, or empty if none exists
438 \sa GetFolderThumb, GetTBNFile
440 std::string
GetLocalFanart() const;
443 \brief Assemble the base filename of local artwork for an item,
444 accounting for archives, stacks and multi-paths, and BDMV/VIDEO_TS folders.
445 `useFolder` is set to false
446 \return the path to the base filename for artwork lookup.
449 std::string
GetLocalArtBaseFilename() const;
451 \brief Assemble the base filename of local artwork for an item,
452 accounting for archives, stacks and multi-paths, and BDMV/VIDEO_TS folders.
453 \param useFolder whether to look in the folder for the art file. Defaults to false.
454 \return the path to the base filename for artwork lookup.
457 std::string
GetLocalArtBaseFilename(bool& useFolder
) const;
459 /*! \brief Assemble the filename of a particular piece of local artwork for an item.
460 No file existence check is typically performed.
461 \param artFile the art file to search for.
462 \param useFolder whether to look in the folder for the art file. Defaults to false.
463 \return the path to the local artwork.
466 std::string
GetLocalArt(const std::string
& artFile
, bool useFolder
= false) const;
468 /*! \brief Assemble the filename of a particular piece of local artwork for an item,
469 and check for file existence.
470 \param artFile the art file to search for.
471 \param useFolder whether to look in the folder for the art file. Defaults to false.
472 \return the path to the local artwork if it exists, empty otherwise.
475 std::string
FindLocalArt(const std::string
&artFile
, bool useFolder
) const;
477 /*! \brief Whether or not to skip searching for local art.
478 \return true if local art should be skipped for this item, false otherwise.
479 \sa GetLocalArt, FindLocalArt
481 bool SkipLocalArt() const;
483 /*! \brief Get the thumb for the item, but hide it to prevent spoilers if
484 the user has set 'Show information for unwatched items' appropriately.
485 \param item the item to get the thumb image for.
486 \return fanart or spoiler overlay if item is an unwatched episode, thumb art otherwise.
488 std::string
GetThumbHideIfUnwatched(const CFileItem
* item
) const;
490 // Gets the .tbn file associated with this item
491 std::string
GetTBNFile() const;
492 // Gets the folder image associated with this item (defaults to folder.jpg)
493 std::string
GetFolderThumb(const std::string
&folderJPG
= "folder.jpg") const;
494 // Gets the correct movie title
495 std::string
GetMovieName(bool bUseFolderNames
= false) const;
497 /*! \brief Find the base movie path (i.e. the item the user expects us to use to lookup the movie)
498 For folder items, with "use foldernames for lookups" it returns the folder.
499 Regardless of settings, for VIDEO_TS/BDMV it returns the parent of the VIDEO_TS/BDMV folder (if present)
501 \param useFolderNames whether we're using foldernames for lookups
502 \return the base movie folder
504 std::string
GetBaseMoviePath(bool useFolderNames
) const;
506 // Gets the user thumb, if it exists
507 std::string
GetUserMusicThumb(bool alwaysCheckRemote
= false, bool fallbackToFolder
= false) const;
509 /*! \brief Get the path where we expect local metadata to reside.
510 For a folder, this is just the existing path (eg tvshow folder)
511 For a file, this is the parent path, with exceptions made for VIDEO_TS and BDMV files
513 Three cases are handled:
515 /foo/bar/movie_name/file_name -> /foo/bar/movie_name/
516 /foo/bar/movie_name/VIDEO_TS/file_name -> /foo/bar/movie_name/
517 /foo/bar/movie_name/BDMV/file_name -> /foo/bar/movie_name/
519 \sa URIUtils::GetParentPath
521 std::string
GetLocalMetadataPath() const;
523 // finds a matching local trailer file
524 std::string
FindTrailer() const;
529 /*! \brief Load detailed data for an item constructed with only a path and a folder flag
530 Fills item's video info tag, sets item properties.
532 \return true on success, false otherwise.
536 /* Returns the content type of this item if known */
537 const std::string
& GetMimeType() const { return m_mimetype
; }
539 /* sets the mime-type if known beforehand */
540 void SetMimeType(const std::string
& mimetype
) { m_mimetype
= mimetype
; } ;
542 /*! \brief Resolve the MIME type based on file extension or a web lookup
543 If m_mimetype is already set (non-empty), this function has no effect. For
544 http:// and shout:// streams, this will query the stream (blocking operation).
545 Set lookup=false to skip any internet lookups and always return immediately.
547 void FillInMimeType(bool lookup
= true);
550 \brief Some sources do not support HTTP HEAD request to determine i.e. mime type
551 \return false if HEAD requests have to be avoided
553 bool ContentLookup() { return m_doContentLookup
; }
556 \brief (Re)set the mime-type for internet files if allowed (m_doContentLookup)
557 Some sources do not support HTTP HEAD request to determine i.e. mime type
559 void SetMimeTypeForInternetFile();
562 *\brief Lookup via HTTP HEAD request might not be needed, use this setter to
563 * disable ContentLookup.
565 void SetContentLookup(bool enable
) { m_doContentLookup
= enable
; }
567 /* general extra info about the contents of the item, not for display */
568 void SetExtraInfo(const std::string
& info
) { m_extrainfo
= info
; }
569 const std::string
& GetExtraInfo() const { return m_extrainfo
; }
571 /*! \brief Update an item with information from another item
572 We take metadata information from the given item and supplement the current item
573 with that info. If tags exist in the new item we use the entire tag information.
574 Properties are appended, and labels, thumbnail and icon are updated if non-empty
576 \param item the item used to supplement information
577 \param replaceLabels whether to replace labels (defaults to true)
579 void UpdateInfo(const CFileItem
&item
, bool replaceLabels
= true);
581 /*! \brief Merge an item with information from another item
582 We take metadata/art information from the given item and supplement the current
583 item with that info. If tags exist in the new item we only merge the missing
584 tag information. Properties are appended, and labels are updated if non-empty
587 void MergeInfo(const CFileItem
&item
);
589 bool IsSamePath(const CFileItem
*item
) const;
591 bool IsAlbum() const;
593 /*! \brief Sets details using the information from the CVideoInfoTag object
594 Sets the videoinfotag and uses its information to set the label and path.
595 \param video video details to use and set
597 void SetFromVideoInfoTag(const CVideoInfoTag
&video
);
599 /*! \brief Sets details using the information from the CMusicInfoTag object
600 Sets the musicinfotag and uses its information to set the label and path.
601 \param music music details to use and set
603 void SetFromMusicInfoTag(const MUSIC_INFO::CMusicInfoTag
&music
);
605 /*! \brief Sets details using the information from the CAlbum object
606 Sets the album in the music info tag and uses its information to set the
607 label and album-specific properties.
608 \param album album details to use and set
610 void SetFromAlbum(const CAlbum
&album
);
611 /*! \brief Sets details using the information from the CSong object
612 Sets the song in the music info tag and uses its information to set the
613 label, path, song-specific properties and artwork.
614 \param song song details to use and set
616 void SetFromSong(const CSong
&song
);
618 bool m_bIsShareOrDrive
; ///< is this a root share/drive
619 int m_iDriveType
; ///< If \e m_bIsShareOrDrive is \e true, use to get the share type. Types see: CMediaSource::m_iDriveType
620 CDateTime m_dateTime
; ///< file creation date & time
621 int64_t m_dwSize
; ///< file size (0 for folders)
622 std::string m_strDVDLabel
;
623 std::string m_strTitle
;
626 int m_lStartPartNumber
;
627 LockType m_iLockMode
;
628 std::string m_strLockCode
;
629 int m_iHasLock
; // 0 - no lock 1 - lock, but unlocked 2 - locked
632 void SetCueDocument(const CCueDocumentPtr
& cuePtr
);
633 void LoadEmbeddedCue();
634 bool HasCueDocument() const;
635 bool LoadTracksFromCueDocument(CFileItemList
& scannedItems
);
637 /*! \brief initialize all members of this class (not CGUIListItem members) to default values.
638 Called from constructors, and from Reset()
639 \sa Reset, CGUIListItem
643 /*! \brief Recalculate item's MIME type if it is not set or is set to "application/octet-stream".
644 Resolve the MIME type based on file extension or a web lookup.
647 void UpdateMimeType(bool lookup
= true);
650 \brief Return the current resume point for this item.
651 \return The resume point.
653 CBookmark
GetResumePoint() const;
656 \brief Fill item's music tag from given epg tag.
658 void FillMusicInfoTag(const std::shared_ptr
<const PVR::CPVREpgInfoTag
>& tag
);
660 std::string m_strPath
; ///< complete path to item
661 std::string m_strDynPath
;
663 SortSpecial m_specialSort
;
664 bool m_bIsParentFolder
;
666 bool m_bLabelPreformatted
;
667 std::string m_mimetype
;
668 std::string m_extrainfo
;
669 bool m_doContentLookup
;
670 MUSIC_INFO::CMusicInfoTag
* m_musicInfoTag
;
671 CVideoInfoTag
* m_videoInfoTag
;
672 std::shared_ptr
<PVR::CPVREpgInfoTag
> m_epgInfoTag
;
673 std::shared_ptr
<PVR::CPVREpgSearchFilter
> m_epgSearchFilter
;
674 std::shared_ptr
<PVR::CPVRRecording
> m_pvrRecordingInfoTag
;
675 std::shared_ptr
<PVR::CPVRTimerInfoTag
> m_pvrTimerInfoTag
;
676 std::shared_ptr
<PVR::CPVRChannelGroupMember
> m_pvrChannelGroupMemberInfoTag
;
677 CPictureInfoTag
* m_pictureInfoTag
;
678 std::shared_ptr
<const ADDON::IAddon
> m_addonInfo
;
679 KODI::GAME::CGameInfoTag
* m_gameInfoTag
;
680 EventPtr m_eventLogEntry
;
682 int64_t m_lStartOffset
;
683 int64_t m_lEndOffset
;
685 CCueDocumentPtr m_cueDocument
;
689 \brief A shared pointer to CFileItem
692 typedef std::shared_ptr
<CFileItem
> CFileItemPtr
;
695 \brief A vector of pointer to CFileItem
698 typedef std::vector
< CFileItemPtr
> VECFILEITEMS
;
701 \brief Iterator for VECFILEITEMS
704 typedef std::vector
< CFileItemPtr
>::iterator IVECFILEITEMS
;
707 \brief A map of pointers to CFileItem
710 typedef std::map
<std::string
, CFileItemPtr
> MAPFILEITEMS
;
713 \brief Pair for MAPFILEITEMS
716 typedef std::pair
<std::string
, CFileItemPtr
> MAPFILEITEMSPAIR
;
718 typedef bool (*FILEITEMLISTCOMPARISONFUNC
) (const CFileItemPtr
&pItem1
, const CFileItemPtr
&pItem2
);
719 typedef void (*FILEITEMFILLFUNC
) (CFileItemPtr
&item
);
722 \brief Represents a list of files
723 \sa CFileItemList, CFileItem
725 class CFileItemList
: public CFileItem
728 enum CACHE_TYPE
{ CACHE_NEVER
= 0, CACHE_IF_SLOW
, CACHE_ALWAYS
};
731 explicit CFileItemList(const std::string
& strPath
);
732 ~CFileItemList() override
;
733 void Archive(CArchive
& ar
) override
;
734 CFileItemPtr
operator[] (int iItem
);
735 const CFileItemPtr
operator[] (int iItem
) const;
736 CFileItemPtr
operator[] (const std::string
& strPath
);
737 const CFileItemPtr
operator[] (const std::string
& strPath
) const;
740 void Add(CFileItemPtr item
);
741 void Add(CFileItem
&& item
);
742 void AddFront(const CFileItemPtr
&pItem
, int itemPosition
);
743 void Remove(CFileItem
* pItem
);
744 void Remove(int iItem
);
745 CFileItemPtr
Get(int iItem
) const;
746 const VECFILEITEMS
& GetList() const { return m_items
; }
747 CFileItemPtr
Get(const std::string
& strPath
) const;
749 bool IsEmpty() const;
750 void Append(const CFileItemList
& itemlist
);
751 void Assign(const CFileItemList
& itemlist
, bool append
= false);
752 bool Copy (const CFileItemList
& item
, bool copyItems
= true);
753 void Reserve(size_t iCount
);
754 void Sort(SortBy sortBy
, SortOrder sortOrder
, SortAttribute sortAttributes
= SortAttributeNone
);
755 /* \brief Sorts the items based on the given sorting options
757 In contrast to Sort (see above) this does not change the internal
758 state by storing the sorting method and order used and therefore
759 will always execute the sorting even if the list of items has
760 already been sorted with the same options before.
762 void Sort(SortDescription sortDescription
);
764 void FillInDefaultIcons();
765 int GetFolderCount() const;
766 int GetFileCount() const;
767 int GetSelectedCount() const;
768 int GetObjectCount() const;
769 void FilterCueItems();
770 void RemoveExtensions();
771 void SetIgnoreURLOptions(bool ignoreURLOptions
);
772 void SetFastLookup(bool fastLookup
);
773 bool Contains(const std::string
& fileName
) const;
774 bool GetFastLookup() const { return m_fastLookup
; }
776 /*! \brief stack a CFileItemList
777 By default we stack all items (files and folders) in a CFileItemList
778 \param stackFiles whether to stack all items or just collapse folders (defaults to true)
779 \sa StackFiles,StackFolders
781 void Stack(bool stackFiles
= true);
783 SortOrder
GetSortOrder() const { return m_sortDescription
.sortOrder
; }
784 SortBy
GetSortMethod() const { return m_sortDescription
.sortBy
; }
785 void SetSortOrder(SortOrder sortOrder
) { m_sortDescription
.sortOrder
= sortOrder
; }
786 void SetSortMethod(SortBy sortBy
) { m_sortDescription
.sortBy
= sortBy
; }
788 /*! \brief load a CFileItemList out of the cache
790 The file list may be cached based on which window we're viewing in, as different
791 windows will be listing different portions of the same URL (eg viewing music files
792 versus viewing video files)
794 \param windowID id of the window that's loading this list (defaults to 0)
795 \return true if we loaded from the cache, false otherwise.
796 \sa Save,RemoveDiscCache
798 bool Load(int windowID
= 0);
800 /*! \brief save a CFileItemList to the cache
802 The file list may be cached based on which window we're viewing in, as different
803 windows will be listing different portions of the same URL (eg viewing music files
804 versus viewing video files)
806 \param windowID id of the window that's saving this list (defaults to 0)
807 \return true if successful, false otherwise.
808 \sa Load,RemoveDiscCache
810 bool Save(int windowID
= 0);
811 void SetCacheToDisc(CACHE_TYPE cacheToDisc
) { m_cacheToDisc
= cacheToDisc
; }
812 bool CacheToDiscAlways() const { return m_cacheToDisc
== CACHE_ALWAYS
; }
813 bool CacheToDiscIfSlow() const { return m_cacheToDisc
== CACHE_IF_SLOW
; }
814 /*! \brief remove a previously cached CFileItemList from the cache
816 The file list may be cached based on which window we're viewing in, as different
817 windows will be listing different portions of the same URL (eg viewing music files
818 versus viewing video files)
820 \param windowID id of the window whose cache we which to remove (defaults to 0)
823 void RemoveDiscCache(int windowID
= 0) const;
824 void RemoveDiscCache(const std::string
& cachefile
) const;
825 void RemoveDiscCacheCRC(const std::string
& crc
) const;
826 bool AlwaysCache() const;
828 void Swap(unsigned int item1
, unsigned int item2
);
830 /*! \brief Update an item in the item list
831 \param item the new item, which we match based on path to an existing item in the list
832 \return true if the item exists in the list (and was thus updated), false otherwise.
834 bool UpdateItem(const CFileItem
*item
);
836 void AddSortMethod(SortBy sortBy
, int buttonLabel
, const LABEL_MASKS
&labelMasks
, SortAttribute sortAttributes
= SortAttributeNone
);
837 void AddSortMethod(SortBy sortBy
, SortAttribute sortAttributes
, int buttonLabel
, const LABEL_MASKS
&labelMasks
);
838 void AddSortMethod(SortDescription sortDescription
, int buttonLabel
, const LABEL_MASKS
&labelMasks
);
839 bool HasSortDetails() const { return m_sortDetails
.size() != 0; }
840 const std::vector
<GUIViewSortDetails
> &GetSortDetails() const { return m_sortDetails
; }
842 /*! \brief Specify whether this list should be sorted with folders separate from files
843 By default we sort with folders listed (and sorted separately) except for those sort modes
844 which should be explicitly sorted with folders interleaved with files (eg SORT_METHOD_FILES).
845 With this set the folder state will be ignored, allowing folders and files to sort interleaved.
846 \param sort whether to ignore the folder state.
848 void SetSortIgnoreFolders(bool sort
) { m_sortIgnoreFolders
= sort
; }
849 bool GetReplaceListing() const { return m_replaceListing
; }
850 void SetReplaceListing(bool replace
);
851 void SetContent(const std::string
& content
) { m_content
= content
; }
852 const std::string
& GetContent() const { return m_content
; }
854 void ClearSortState();
856 VECFILEITEMS::iterator
begin() { return m_items
.begin(); }
857 VECFILEITEMS::iterator
end() { return m_items
.end(); }
858 VECFILEITEMS::iterator
erase(VECFILEITEMS::iterator first
, VECFILEITEMS::iterator last
);
859 VECFILEITEMS::const_iterator
begin() const { return m_items
.begin(); }
860 VECFILEITEMS::const_iterator
end() const { return m_items
.end(); }
861 VECFILEITEMS::const_iterator
cbegin() const { return m_items
.cbegin(); }
862 VECFILEITEMS::const_iterator
cend() const { return m_items
.cend(); }
863 std::reverse_iterator
<VECFILEITEMS::const_iterator
> rbegin() const { return m_items
.rbegin(); }
864 std::reverse_iterator
<VECFILEITEMS::const_iterator
> rend() const { return m_items
.rend(); }
867 void Sort(FILEITEMLISTCOMPARISONFUNC func
);
868 void FillSortFields(FILEITEMFILLFUNC func
);
869 std::string
GetDiscFileCache(int windowID
) const;
872 \brief stack files in a CFileItemList
878 \brief stack folders in a CFileItemList
883 VECFILEITEMS m_items
;
885 bool m_ignoreURLOptions
= false;
886 bool m_fastLookup
= false;
887 SortDescription m_sortDescription
;
888 bool m_sortIgnoreFolders
= false;
889 CACHE_TYPE m_cacheToDisc
= CACHE_IF_SLOW
;
890 bool m_replaceListing
= false;
891 std::string m_content
;
893 std::vector
<GUIViewSortDetails
> m_sortDetails
;
895 mutable CCriticalSection m_lock
;