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 IsDiscImage() const;
218 bool IsOpticalMediaFile() const;
219 bool IsDVDFile(bool bVobs
= true, bool bIfos
= true) const;
220 bool IsBDFile() const;
221 bool IsBluray() const;
222 bool IsProtectedBlurayDisc() const;
228 bool IsISO9660() const;
231 bool IsOnDVD() const;
232 bool IsOnLAN() const;
235 bool IsRemote() const;
238 bool IsStack() const;
239 bool IsFavourite() const;
240 bool IsMultiPath() const;
241 bool IsMusicDb() const;
242 bool IsVideoDb() const;
244 bool IsPVRChannel() const;
245 bool IsPVRChannelGroup() const;
246 bool IsPVRRecording() const;
247 bool IsUsablePVRRecording() const;
248 bool IsDeletedPVRRecording() const;
249 bool IsInProgressPVRRecording() const;
250 bool IsPVRTimer() const;
251 bool IsType(const char *ext
) const;
252 bool IsVirtualDirectoryRoot() const;
253 bool IsReadOnly() const;
254 bool CanQueue() const;
255 void SetCanQueue(bool bYesNo
);
256 bool IsParentFolder() const;
257 bool IsFileFolder(EFileFolderType types
= EFILEFOLDER_MASK_ALL
) const;
258 bool IsRemovable() const;
260 bool IsLiveTV() const;
262 bool IsAndroidApp() const;
264 void RemoveExtension();
266 void FillInDefaultIcon();
267 void SetFileSizeLabel();
268 void SetLabel(const std::string
&strLabel
) override
;
269 VideoDbContentType
GetVideoContentType() const;
270 bool IsLabelPreformatted() const { return m_bLabelPreformatted
; }
271 void SetLabelPreformatted(bool bYesNo
) { m_bLabelPreformatted
=bYesNo
; }
272 bool SortsOnTop() const { return m_specialSort
== SortSpecialOnTop
; }
273 bool SortsOnBottom() const { return m_specialSort
== SortSpecialOnBottom
; }
274 void SetSpecialSort(SortSpecial sort
) { m_specialSort
= sort
; }
276 inline bool HasMusicInfoTag() const
278 return m_musicInfoTag
!= NULL
;
281 MUSIC_INFO::CMusicInfoTag
* GetMusicInfoTag();
283 inline const MUSIC_INFO::CMusicInfoTag
* GetMusicInfoTag() const
285 return m_musicInfoTag
;
288 bool HasVideoInfoTag() const;
290 CVideoInfoTag
* GetVideoInfoTag();
292 const CVideoInfoTag
* GetVideoInfoTag() const;
294 inline bool HasEPGInfoTag() const
296 return m_epgInfoTag
.get() != NULL
;
299 inline const std::shared_ptr
<PVR::CPVREpgInfoTag
> GetEPGInfoTag() const
304 bool HasEPGSearchFilter() const { return m_epgSearchFilter
!= nullptr; }
306 const std::shared_ptr
<PVR::CPVREpgSearchFilter
> GetEPGSearchFilter() const
308 return m_epgSearchFilter
;
311 inline bool HasPVRChannelGroupMemberInfoTag() const
313 return m_pvrChannelGroupMemberInfoTag
.get() != nullptr;
316 inline const std::shared_ptr
<PVR::CPVRChannelGroupMember
> GetPVRChannelGroupMemberInfoTag() const
318 return m_pvrChannelGroupMemberInfoTag
;
321 bool HasPVRChannelInfoTag() const;
322 const std::shared_ptr
<PVR::CPVRChannel
> GetPVRChannelInfoTag() const;
324 inline bool HasPVRRecordingInfoTag() const
326 return m_pvrRecordingInfoTag
.get() != NULL
;
329 inline const std::shared_ptr
<PVR::CPVRRecording
> GetPVRRecordingInfoTag() const
331 return m_pvrRecordingInfoTag
;
334 inline bool HasPVRTimerInfoTag() const
336 return m_pvrTimerInfoTag
!= NULL
;
339 inline const std::shared_ptr
<PVR::CPVRTimerInfoTag
> GetPVRTimerInfoTag() const
341 return m_pvrTimerInfoTag
;
345 \brief return the item to play. will be almost 'this', but can be different (e.g. "Play recording" from PVR EPG grid window)
346 \return the item to play
348 CFileItem
GetItemToPlay() const;
351 \brief Test if this item has a valid resume point set.
352 \return True if this item has a resume point and it is set, false otherwise.
354 bool IsResumePointSet() const;
357 \brief Return the current resume time.
358 \return The time in seconds from the start to resume playing from.
360 double GetCurrentResumeTime() const;
363 \brief Return the current resume time and part.
364 \param startOffset will be filled with the resume time offset in seconds if item has a resume point set, is unchanged otherwise
365 \param partNumber will be filled with the part number if item has a resume point set, is unchanged otherwise
366 \return True if the item has a resume point set, false otherwise.
368 bool GetCurrentResumeTimeAndPartNumber(int64_t& startOffset
, int& partNumber
) const;
371 * \brief Test if this item type can be resumed.
372 * \return True if this item can be resumed, false otherwise.
374 bool IsResumable() const;
377 * \brief Get the offset where start the playback.
378 * \return The offset value as ms.
379 * Can return also special value -1, see define STARTOFFSET_RESUME.
381 int64_t GetStartOffset() const { return m_lStartOffset
; }
384 * \brief Set the offset where start the playback.
385 * \param offset Set the offset value as ms,
386 or the special value STARTOFFSET_RESUME.
388 void SetStartOffset(const int64_t offset
) { m_lStartOffset
= offset
; }
391 * \brief Get the end offset.
392 * \return The offset value as ms.
394 int64_t GetEndOffset() const { return m_lEndOffset
; }
397 * \brief Set the end offset.
398 * \param offset Set the offset as ms.
400 void SetEndOffset(const int64_t offset
) { m_lEndOffset
= offset
; }
402 inline bool HasPictureInfoTag() const
404 return m_pictureInfoTag
!= NULL
;
407 inline const CPictureInfoTag
* GetPictureInfoTag() const
409 return m_pictureInfoTag
;
412 bool HasAddonInfo() const { return m_addonInfo
!= nullptr; }
413 const std::shared_ptr
<const ADDON::IAddon
> GetAddonInfo() const { return m_addonInfo
; }
415 inline bool HasGameInfoTag() const
417 return m_gameInfoTag
!= NULL
;
420 KODI::GAME::CGameInfoTag
* GetGameInfoTag();
422 inline const KODI::GAME::CGameInfoTag
* GetGameInfoTag() const
424 return m_gameInfoTag
;
427 CPictureInfoTag
* GetPictureInfoTag();
430 \brief Get the local fanart for this item if it exists
431 \return path to the local fanart for this item, or empty if none exists
432 \sa GetFolderThumb, GetTBNFile
434 std::string
GetLocalFanart() const;
437 \brief Assemble the base filename of local artwork for an item,
438 accounting for archives, stacks and multi-paths, and BDMV/VIDEO_TS folders.
439 `useFolder` is set to false
440 \return the path to the base filename for artwork lookup.
443 std::string
GetLocalArtBaseFilename() const;
445 \brief Assemble the base filename of local artwork for an item,
446 accounting for archives, stacks and multi-paths, and BDMV/VIDEO_TS folders.
447 \param useFolder whether to look in the folder for the art file. Defaults to false.
448 \return the path to the base filename for artwork lookup.
451 std::string
GetLocalArtBaseFilename(bool& useFolder
) const;
453 /*! \brief Assemble the filename of a particular piece of local artwork for an item.
454 No file existence check is typically performed.
455 \param artFile the art file to search for.
456 \param useFolder whether to look in the folder for the art file. Defaults to false.
457 \return the path to the local artwork.
460 std::string
GetLocalArt(const std::string
& artFile
, bool useFolder
= false) const;
462 /*! \brief Assemble the filename of a particular piece of local artwork for an item,
463 and check for file existence.
464 \param artFile the art file to search for.
465 \param useFolder whether to look in the folder for the art file. Defaults to false.
466 \return the path to the local artwork if it exists, empty otherwise.
469 std::string
FindLocalArt(const std::string
&artFile
, bool useFolder
) const;
471 /*! \brief Whether or not to skip searching for local art.
472 \return true if local art should be skipped for this item, false otherwise.
473 \sa GetLocalArt, FindLocalArt
475 bool SkipLocalArt() const;
477 /*! \brief Get the thumb for the item, but hide it to prevent spoilers if
478 the user has set 'Show information for unwatched items' appropriately.
479 \param item the item to get the thumb image for.
480 \return fanart or spoiler overlay if item is an unwatched episode, thumb art otherwise.
482 std::string
GetThumbHideIfUnwatched(const CFileItem
* item
) const;
484 // Gets the .tbn file associated with this item
485 std::string
GetTBNFile() const;
486 // Gets the folder image associated with this item (defaults to folder.jpg)
487 std::string
GetFolderThumb(const std::string
&folderJPG
= "folder.jpg") const;
488 // Gets the correct movie title
489 std::string
GetMovieName(bool bUseFolderNames
= false) const;
491 /*! \brief Find the base movie path (i.e. the item the user expects us to use to lookup the movie)
492 For folder items, with "use foldernames for lookups" it returns the folder.
493 Regardless of settings, for VIDEO_TS/BDMV it returns the parent of the VIDEO_TS/BDMV folder (if present)
495 \param useFolderNames whether we're using foldernames for lookups
496 \return the base movie folder
498 std::string
GetBaseMoviePath(bool useFolderNames
) const;
500 // Gets the user thumb, if it exists
501 std::string
GetUserMusicThumb(bool alwaysCheckRemote
= false, bool fallbackToFolder
= false) const;
503 /*! \brief Get the path where we expect local metadata to reside.
504 For a folder, this is just the existing path (eg tvshow folder)
505 For a file, this is the parent path, with exceptions made for VIDEO_TS and BDMV files
507 Three cases are handled:
509 /foo/bar/movie_name/file_name -> /foo/bar/movie_name/
510 /foo/bar/movie_name/VIDEO_TS/file_name -> /foo/bar/movie_name/
511 /foo/bar/movie_name/BDMV/file_name -> /foo/bar/movie_name/
513 \sa URIUtils::GetParentPath
515 std::string
GetLocalMetadataPath() const;
517 // finds a matching local trailer file
518 std::string
FindTrailer() const;
523 /*! \brief Load detailed data for an item constructed with only a path and a folder flag
524 Fills item's video info tag, sets item properties.
526 \return true on success, false otherwise.
530 /* Returns the content type of this item if known */
531 const std::string
& GetMimeType() const { return m_mimetype
; }
533 /* sets the mime-type if known beforehand */
534 void SetMimeType(const std::string
& mimetype
) { m_mimetype
= mimetype
; } ;
536 /*! \brief Resolve the MIME type based on file extension or a web lookup
537 If m_mimetype is already set (non-empty), this function has no effect. For
538 http:// and shout:// streams, this will query the stream (blocking operation).
539 Set lookup=false to skip any internet lookups and always return immediately.
541 void FillInMimeType(bool lookup
= true);
544 \brief Some sources do not support HTTP HEAD request to determine i.e. mime type
545 \return false if HEAD requests have to be avoided
547 bool ContentLookup() { return m_doContentLookup
; }
550 \brief (Re)set the mime-type for internet files if allowed (m_doContentLookup)
551 Some sources do not support HTTP HEAD request to determine i.e. mime type
553 void SetMimeTypeForInternetFile();
556 *\brief Lookup via HTTP HEAD request might not be needed, use this setter to
557 * disable ContentLookup.
559 void SetContentLookup(bool enable
) { m_doContentLookup
= enable
; }
561 /* general extra info about the contents of the item, not for display */
562 void SetExtraInfo(const std::string
& info
) { m_extrainfo
= info
; }
563 const std::string
& GetExtraInfo() const { return m_extrainfo
; }
565 /*! \brief Update an item with information from another item
566 We take metadata information from the given item and supplement the current item
567 with that info. If tags exist in the new item we use the entire tag information.
568 Properties are appended, and labels, thumbnail and icon are updated if non-empty
570 \param item the item used to supplement information
571 \param replaceLabels whether to replace labels (defaults to true)
573 void UpdateInfo(const CFileItem
&item
, bool replaceLabels
= true);
575 /*! \brief Merge an item with information from another item
576 We take metadata/art information from the given item and supplement the current
577 item with that info. If tags exist in the new item we only merge the missing
578 tag information. Properties are appended, and labels are updated if non-empty
581 void MergeInfo(const CFileItem
&item
);
583 bool IsSamePath(const CFileItem
*item
) const;
585 bool IsAlbum() const;
587 /*! \brief Sets details using the information from the CVideoInfoTag object
588 Sets the videoinfotag and uses its information to set the label and path.
589 \param video video details to use and set
591 void SetFromVideoInfoTag(const CVideoInfoTag
&video
);
593 /*! \brief Sets details using the information from the CMusicInfoTag object
594 Sets the musicinfotag and uses its information to set the label and path.
595 \param music music details to use and set
597 void SetFromMusicInfoTag(const MUSIC_INFO::CMusicInfoTag
&music
);
599 /*! \brief Sets details using the information from the CAlbum object
600 Sets the album in the music info tag and uses its information to set the
601 label and album-specific properties.
602 \param album album details to use and set
604 void SetFromAlbum(const CAlbum
&album
);
605 /*! \brief Sets details using the information from the CSong object
606 Sets the song in the music info tag and uses its information to set the
607 label, path, song-specific properties and artwork.
608 \param song song details to use and set
610 void SetFromSong(const CSong
&song
);
612 bool m_bIsShareOrDrive
; ///< is this a root share/drive
613 int m_iDriveType
; ///< If \e m_bIsShareOrDrive is \e true, use to get the share type. Types see: CMediaSource::m_iDriveType
614 CDateTime m_dateTime
; ///< file creation date & time
615 int64_t m_dwSize
; ///< file size (0 for folders)
616 std::string m_strDVDLabel
;
617 std::string m_strTitle
;
620 int m_lStartPartNumber
;
621 LockType m_iLockMode
;
622 std::string m_strLockCode
;
623 int m_iHasLock
; // 0 - no lock 1 - lock, but unlocked 2 - locked
626 void SetCueDocument(const CCueDocumentPtr
& cuePtr
);
627 void LoadEmbeddedCue();
628 bool HasCueDocument() const;
629 bool LoadTracksFromCueDocument(CFileItemList
& scannedItems
);
631 /*! \brief initialize all members of this class (not CGUIListItem members) to default values.
632 Called from constructors, and from Reset()
633 \sa Reset, CGUIListItem
638 \brief Return the current resume point for this item.
639 \return The resume point.
641 CBookmark
GetResumePoint() const;
644 \brief Fill item's music tag from given epg tag.
646 void FillMusicInfoTag(const std::shared_ptr
<PVR::CPVREpgInfoTag
>& tag
);
648 std::string m_strPath
; ///< complete path to item
649 std::string m_strDynPath
;
651 SortSpecial m_specialSort
;
652 bool m_bIsParentFolder
;
654 bool m_bLabelPreformatted
;
655 std::string m_mimetype
;
656 std::string m_extrainfo
;
657 bool m_doContentLookup
;
658 MUSIC_INFO::CMusicInfoTag
* m_musicInfoTag
;
659 CVideoInfoTag
* m_videoInfoTag
;
660 std::shared_ptr
<PVR::CPVREpgInfoTag
> m_epgInfoTag
;
661 std::shared_ptr
<PVR::CPVREpgSearchFilter
> m_epgSearchFilter
;
662 std::shared_ptr
<PVR::CPVRRecording
> m_pvrRecordingInfoTag
;
663 std::shared_ptr
<PVR::CPVRTimerInfoTag
> m_pvrTimerInfoTag
;
664 std::shared_ptr
<PVR::CPVRChannelGroupMember
> m_pvrChannelGroupMemberInfoTag
;
665 CPictureInfoTag
* m_pictureInfoTag
;
666 std::shared_ptr
<const ADDON::IAddon
> m_addonInfo
;
667 KODI::GAME::CGameInfoTag
* m_gameInfoTag
;
668 EventPtr m_eventLogEntry
;
670 int64_t m_lStartOffset
;
671 int64_t m_lEndOffset
;
673 CCueDocumentPtr m_cueDocument
;
677 \brief A shared pointer to CFileItem
680 typedef std::shared_ptr
<CFileItem
> CFileItemPtr
;
683 \brief A vector of pointer to CFileItem
686 typedef std::vector
< CFileItemPtr
> VECFILEITEMS
;
689 \brief Iterator for VECFILEITEMS
692 typedef std::vector
< CFileItemPtr
>::iterator IVECFILEITEMS
;
695 \brief A map of pointers to CFileItem
698 typedef std::map
<std::string
, CFileItemPtr
> MAPFILEITEMS
;
701 \brief Pair for MAPFILEITEMS
704 typedef std::pair
<std::string
, CFileItemPtr
> MAPFILEITEMSPAIR
;
706 typedef bool (*FILEITEMLISTCOMPARISONFUNC
) (const CFileItemPtr
&pItem1
, const CFileItemPtr
&pItem2
);
707 typedef void (*FILEITEMFILLFUNC
) (CFileItemPtr
&item
);
710 \brief Represents a list of files
711 \sa CFileItemList, CFileItem
713 class CFileItemList
: public CFileItem
716 enum CACHE_TYPE
{ CACHE_NEVER
= 0, CACHE_IF_SLOW
, CACHE_ALWAYS
};
719 explicit CFileItemList(const std::string
& strPath
);
720 ~CFileItemList() override
;
721 void Archive(CArchive
& ar
) override
;
722 CFileItemPtr
operator[] (int iItem
);
723 const CFileItemPtr
operator[] (int iItem
) const;
724 CFileItemPtr
operator[] (const std::string
& strPath
);
725 const CFileItemPtr
operator[] (const std::string
& strPath
) const;
728 void Add(CFileItemPtr item
);
729 void Add(CFileItem
&& item
);
730 void AddFront(const CFileItemPtr
&pItem
, int itemPosition
);
731 void Remove(CFileItem
* pItem
);
732 void Remove(int iItem
);
733 CFileItemPtr
Get(int iItem
) const;
734 const VECFILEITEMS
& GetList() const { return m_items
; }
735 CFileItemPtr
Get(const std::string
& strPath
) const;
737 bool IsEmpty() const;
738 void Append(const CFileItemList
& itemlist
);
739 void Assign(const CFileItemList
& itemlist
, bool append
= false);
740 bool Copy (const CFileItemList
& item
, bool copyItems
= true);
741 void Reserve(size_t iCount
);
742 void Sort(SortBy sortBy
, SortOrder sortOrder
, SortAttribute sortAttributes
= SortAttributeNone
);
743 /* \brief Sorts the items based on the given sorting options
745 In contrast to Sort (see above) this does not change the internal
746 state by storing the sorting method and order used and therefore
747 will always execute the sorting even if the list of items has
748 already been sorted with the same options before.
750 void Sort(SortDescription sortDescription
);
752 void FillInDefaultIcons();
753 int GetFolderCount() const;
754 int GetFileCount() const;
755 int GetSelectedCount() const;
756 int GetObjectCount() const;
757 void FilterCueItems();
758 void RemoveExtensions();
759 void SetIgnoreURLOptions(bool ignoreURLOptions
);
760 void SetFastLookup(bool fastLookup
);
761 bool Contains(const std::string
& fileName
) const;
762 bool GetFastLookup() const { return m_fastLookup
; }
764 /*! \brief stack a CFileItemList
765 By default we stack all items (files and folders) in a CFileItemList
766 \param stackFiles whether to stack all items or just collapse folders (defaults to true)
767 \sa StackFiles,StackFolders
769 void Stack(bool stackFiles
= true);
771 SortOrder
GetSortOrder() const { return m_sortDescription
.sortOrder
; }
772 SortBy
GetSortMethod() const { return m_sortDescription
.sortBy
; }
773 void SetSortOrder(SortOrder sortOrder
) { m_sortDescription
.sortOrder
= sortOrder
; }
774 void SetSortMethod(SortBy sortBy
) { m_sortDescription
.sortBy
= sortBy
; }
776 /*! \brief load a CFileItemList out of the cache
778 The file list may be cached based on which window we're viewing in, as different
779 windows will be listing different portions of the same URL (eg viewing music files
780 versus viewing video files)
782 \param windowID id of the window that's loading this list (defaults to 0)
783 \return true if we loaded from the cache, false otherwise.
784 \sa Save,RemoveDiscCache
786 bool Load(int windowID
= 0);
788 /*! \brief save a CFileItemList to 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 saving this list (defaults to 0)
795 \return true if successful, false otherwise.
796 \sa Load,RemoveDiscCache
798 bool Save(int windowID
= 0);
799 void SetCacheToDisc(CACHE_TYPE cacheToDisc
) { m_cacheToDisc
= cacheToDisc
; }
800 bool CacheToDiscAlways() const { return m_cacheToDisc
== CACHE_ALWAYS
; }
801 bool CacheToDiscIfSlow() const { return m_cacheToDisc
== CACHE_IF_SLOW
; }
802 /*! \brief remove a previously cached CFileItemList from the cache
804 The file list may be cached based on which window we're viewing in, as different
805 windows will be listing different portions of the same URL (eg viewing music files
806 versus viewing video files)
808 \param windowID id of the window whose cache we which to remove (defaults to 0)
811 void RemoveDiscCache(int windowID
= 0) const;
812 void RemoveDiscCache(const std::string
& cachefile
) const;
813 void RemoveDiscCacheCRC(const std::string
& crc
) const;
814 bool AlwaysCache() const;
816 void Swap(unsigned int item1
, unsigned int item2
);
818 /*! \brief Update an item in the item list
819 \param item the new item, which we match based on path to an existing item in the list
820 \return true if the item exists in the list (and was thus updated), false otherwise.
822 bool UpdateItem(const CFileItem
*item
);
824 void AddSortMethod(SortBy sortBy
, int buttonLabel
, const LABEL_MASKS
&labelMasks
, SortAttribute sortAttributes
= SortAttributeNone
);
825 void AddSortMethod(SortBy sortBy
, SortAttribute sortAttributes
, int buttonLabel
, const LABEL_MASKS
&labelMasks
);
826 void AddSortMethod(SortDescription sortDescription
, int buttonLabel
, const LABEL_MASKS
&labelMasks
);
827 bool HasSortDetails() const { return m_sortDetails
.size() != 0; }
828 const std::vector
<GUIViewSortDetails
> &GetSortDetails() const { return m_sortDetails
; }
830 /*! \brief Specify whether this list should be sorted with folders separate from files
831 By default we sort with folders listed (and sorted separately) except for those sort modes
832 which should be explicitly sorted with folders interleaved with files (eg SORT_METHOD_FILES).
833 With this set the folder state will be ignored, allowing folders and files to sort interleaved.
834 \param sort whether to ignore the folder state.
836 void SetSortIgnoreFolders(bool sort
) { m_sortIgnoreFolders
= sort
; }
837 bool GetReplaceListing() const { return m_replaceListing
; }
838 void SetReplaceListing(bool replace
);
839 void SetContent(const std::string
& content
) { m_content
= content
; }
840 const std::string
& GetContent() const { return m_content
; }
842 void ClearSortState();
844 VECFILEITEMS::iterator
begin() { return m_items
.begin(); }
845 VECFILEITEMS::iterator
end() { return m_items
.end(); }
846 VECFILEITEMS::iterator
erase(VECFILEITEMS::iterator first
, VECFILEITEMS::iterator last
);
847 VECFILEITEMS::const_iterator
begin() const { return m_items
.begin(); }
848 VECFILEITEMS::const_iterator
end() const { return m_items
.end(); }
849 VECFILEITEMS::const_iterator
cbegin() const { return m_items
.cbegin(); }
850 VECFILEITEMS::const_iterator
cend() const { return m_items
.cend(); }
851 std::reverse_iterator
<VECFILEITEMS::const_iterator
> rbegin() const { return m_items
.rbegin(); }
852 std::reverse_iterator
<VECFILEITEMS::const_iterator
> rend() const { return m_items
.rend(); }
855 void Sort(FILEITEMLISTCOMPARISONFUNC func
);
856 void FillSortFields(FILEITEMFILLFUNC func
);
857 std::string
GetDiscFileCache(int windowID
) const;
860 \brief stack files in a CFileItemList
866 \brief stack folders in a CFileItemList
871 VECFILEITEMS m_items
;
873 bool m_ignoreURLOptions
= false;
874 bool m_fastLookup
= false;
875 SortDescription m_sortDescription
;
876 bool m_sortIgnoreFolders
= false;
877 CACHE_TYPE m_cacheToDisc
= CACHE_IF_SLOW
;
878 bool m_replaceListing
= false;
879 std::string m_content
;
881 std::vector
<GUIViewSortDetails
> m_sortDetails
;
883 mutable CCriticalSection m_lock
;