Expose path to Qt Quick in SyncthingDownloadModel
This commit is contained in:
parent
408f77f844
commit
d103ceaae1
|
@ -21,7 +21,7 @@ public:
|
|||
DirectoryStatusColor,
|
||||
DirectoryId,
|
||||
DirectoryPath,
|
||||
DirectoryDetail
|
||||
DirectoryDetail,
|
||||
};
|
||||
|
||||
explicit SyncthingDirectoryModel(SyncthingConnection &connection, QObject *parent = nullptr);
|
||||
|
|
|
@ -29,6 +29,7 @@ QHash<int, QByteArray> SyncthingDownloadModel::initRoleNames()
|
|||
roles[Qt::DecorationRole] = "fileIcon";
|
||||
roles[ItemPercentage] = "percentage";
|
||||
roles[ItemProgressLabel] = "progressLabel";
|
||||
roles[ItemPath] = "path";
|
||||
return roles;
|
||||
}
|
||||
|
||||
|
@ -132,6 +133,8 @@ QVariant SyncthingDownloadModel::data(const QModelIndex &index, int role) const
|
|||
return progress.downloadPercentage;
|
||||
case ItemProgressLabel:
|
||||
return progress.label;
|
||||
case ItemPath:
|
||||
return dir.path + progress.relativePath;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
|
@ -162,6 +165,8 @@ QVariant SyncthingDownloadModel::data(const QModelIndex &index, int role) const
|
|||
return dir.downloadPercentage;
|
||||
case ItemProgressLabel:
|
||||
return dir.downloadLabel;
|
||||
case ItemPath:
|
||||
return dir.path;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
|
@ -221,8 +226,8 @@ void SyncthingDownloadModel::downloadProgressChanged()
|
|||
}
|
||||
} else {
|
||||
if (pendingIterator != m_pendingDirs.end()) {
|
||||
static const QVector<int> roles(
|
||||
{ Qt::DisplayRole, Qt::EditRole, Qt::DecorationRole, Qt::ForegroundRole, Qt::ToolTipRole, ItemPercentage, ItemProgressLabel });
|
||||
static const QVector<int> roles({ Qt::DisplayRole, Qt::EditRole, Qt::DecorationRole, Qt::ForegroundRole, Qt::ToolTipRole,
|
||||
ItemPercentage, ItemProgressLabel, ItemPath });
|
||||
const QModelIndex parentIndex(index(row, 0));
|
||||
emit dataChanged(parentIndex, index(row, 1), roles);
|
||||
emit dataChanged(index(0, 0, parentIndex), index(static_cast<int>(dirInfo.downloadingItems.size()), 1, parentIndex), roles);
|
||||
|
|
|
@ -20,7 +20,7 @@ class LIB_SYNCTHING_MODEL_EXPORT SyncthingDownloadModel : public SyncthingModel
|
|||
public:
|
||||
explicit SyncthingDownloadModel(SyncthingConnection &connection, QObject *parent = nullptr);
|
||||
|
||||
enum SyncthingDownloadModelRole { ItemPercentage = Qt::UserRole + 1, ItemProgressLabel };
|
||||
enum SyncthingDownloadModelRole { ItemPercentage = Qt::UserRole + 1, ItemProgressLabel, ItemPath };
|
||||
|
||||
public Q_SLOTS:
|
||||
QHash<int, QByteArray> roleNames() const;
|
||||
|
|
Loading…
Reference in New Issue