File indexing completed on 2025-01-05 04:25:20

0001 #include "foldersmodel.h"
0002 #include <MauiKit3/FileBrowsing/fmstatic.h>
0003 
0004 FoldersModel::FoldersModel(QObject *parent) : MauiList(parent)
0005 {}
0006 
0007 const FMH::MODEL_LIST &FoldersModel::items() const
0008 {
0009     return this->list;
0010 }
0011 
0012 void FoldersModel::setFolders(const QList<QUrl> &folders)
0013 {
0014     if(m_folders == folders)
0015         return;
0016 
0017     m_folders = folders;
0018 
0019     Q_EMIT foldersChanged();
0020 }
0021 
0022 QList<QUrl> FoldersModel::folders() const
0023 {
0024     return m_folders;
0025 }
0026 
0027 
0028 void FoldersModel::componentComplete()
0029 {
0030     connect(this, &FoldersModel::foldersChanged, this, &FoldersModel::setList);
0031     this->setList();
0032 }
0033 
0034 void FoldersModel::setList()
0035 {
0036     if(m_folders.isEmpty())
0037     {
0038         return;
0039     }
0040 
0041     Q_EMIT this->preListChanged();
0042     this->list.clear();
0043 
0044     for(const auto &folder : std::as_const(m_folders))
0045     {
0046         this->list << FMStatic::getFileInfoModel(folder);
0047     }
0048     Q_EMIT this->postListChanged();
0049     Q_EMIT this->countChanged();
0050 }