FileListModel.cpp Example File
nfcshare/src/FileListModel.cpp
#include "FileListModel.hpp"
FileListModel::FileListModel(QObject *parent)
{
setParent(parent);
}
QList<QUrl> FileListModel::files() const
{
QList<QUrl> fileList;
for (int row = 0; row < size(); ++row)
fileList << QUrl::fromLocalFile(value(row));
return fileList;
}
void FileListModel::addFile(const QString &filePath)
{
const int pos = indexOf(filePath);
if (pos != -1)
return;
append(filePath);
emit changed();
}
void FileListModel::removeFile(const QString &filePath)
{
const int pos = indexOf(filePath);
if (pos == -1)
return;
removeAt(pos);
emit changed();
}