File indexing completed on 2024-05-19 04:48:24

0001 #include "sourcesmodel.h"
0002 #include <MauiKit3/FileBrowsing/fmstatic.h>
0003 #include <QDebug>
0004 #include <QDir>
0005 
0006 SourcesModel::SourcesModel(QObject *parent) : MauiList(parent)
0007 {
0008 
0009 }
0010 
0011 void SourcesModel::setData(const QList<QUrl> &data, const QUrl &baseUrl)
0012 {
0013   this->m_list.clear ();
0014     emit this->preListChanged();
0015     for(const auto &url : data)
0016     {
0017         qDebug() << "Getting model sources data";
0018         auto localUrl = QUrl::fromLocalFile(url.toString());
0019         auto item = FMStatic::getFileInfoModel(localUrl);
0020         item[FMH::MODEL_KEY::PLACE] = (FMStatic::fileDir (localUrl).toLocalFile ()).replace (baseUrl.toLocalFile ()+"/", "");
0021         item[FMH::MODEL_KEY::SOURCE] = baseUrl.toString ();
0022         m_list << item;
0023     }
0024     emit this->postListChanged();
0025 }
0026 
0027 const FMH::MODEL_LIST &SourcesModel::items() const
0028 {
0029     return m_list;
0030 }