19class QAbstractItemModel;
20class QStandardItemModel;
21class QSortFilterProxyModel;
22class QFileSystemWatcher;
73 QStringList LocalPrefixesChain_;
74 QStringList GlobalPrefixesChain_;
75 QString RelativePath_;
77 QHash<QString, QStringList> Entry2Paths_;
79 QStandardItemModel *SubElemModel_;
80 QStringList NameFilters_;
81 QDir::Filters AttrFilters_ = QDir::Dirs | QDir::NoDotAndDotDot | QDir::Readable;
82 QSortFilterProxyModel *SortModel_;
84 QFileSystemWatcher *Watcher_;
86 QTimer *CacheFlushTimer_;
87 mutable QCache<QString, QByteArray> CachePathContents_ { 0 };
88 mutable QCache<QString, QPixmap> CachePixmaps_ { 0 };
90 bool Verbose_ =
false;
98 explicit ResourceLoader (
const QString& relPath, QObject* obj =
nullptr);
157 QFileInfoList
List (
const QString& option,
158 const QStringList& names = {},
159 QDir::Filters filters = QDir::NoFilter)
const;
185 QString
GetPath (
const QStringList& pathVariants)
const;
204 QString
GetIconPath (
const QString& basename)
const;
265 QPixmap
LoadPixmap (
const QString& basename)
const;
328 void ScanPath (
const QString&);
329 void HandleDirectoryChanged (
const QString&);
void SetCacheParams(int size, int timeout)
Sets the caching parameters of this loader.
void watchedDirectoriesChanged()
QAbstractItemModel * GetSubElemModel() const
Returns the subelement model with the contents of registered paths.
void FlushCache()
Forcefully flushes the cache.
QIODevice_ptr Load(const QStringList &pathVariants, bool open=false) const
Returns the QIODevice for the corresponding resource.
void SetAttrFilters(QDir::Filters)
Sets the attribute filters for the subelement model.
QString GetPath(const QStringList &pathVariants) const
Returns the first found path for the list of variants.
void AddGlobalPrefix()
Registers global OS-dependent prefixes.
ResourceLoader(const QString &relPath, QObject *obj=nullptr)
Initializes the loader with the given path.
QFileInfoList List(const QString &option, const QStringList &names={}, QDir::Filters filters=QDir::NoFilter) const
Lists the available files for the given option.
QString GetIconPath(const QString &basename) const
Calls GetPath() with standard variants for the icon extensions.
QPixmap LoadPixmap(const QString &basename) const
Returns the pixmap for the given basename.
QIODevice_ptr GetIconDevice(const QString &basename, bool open=false) const
Returns the QIODevice for the corresponding icon.
void SetNameFilters(const QStringList &)
Sets the name filters for the subelement model.
void SetVerbose(bool verbose)
Control whether the ResourceLoader prints what it is doing to the logs.
void AddLocalPrefix(QString prefix=QString())
Registers a local search prefix.
std::shared_ptr< QIODevice > QIODevice_ptr