int m_checkusmVerified;
int m_signatureVerified;
FileItem *m_parent;
+
+ friend class TorrentFileModel;
};
/**
QVariant data(const QModelIndex &index, int role) const;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
- Qt::ItemFlags flags(const QModelIndex &index) const;
+ virtual Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
QModelIndex index(const KUrl &file, int column);
return i18n("Unknown error");
}
+class TorrentFileModel : public FileModel
+{
+public:
+ TorrentFileModel(const QList<KUrl> &files, const KUrl &destDirectory, QObject *parent, const Job::Status status);
+ Qt::ItemFlags flags(const QModelIndex &index) const final;
+
+private:
+ Job::Status m_status;
+};
+
+TorrentFileModel::TorrentFileModel(const QList<KUrl> &files, const KUrl &destDirectory, QObject *parent, const Job::Status status)
+ : FileModel(files, destDirectory, parent), m_status(status)
+{
+}
+
+Qt::ItemFlags TorrentFileModel::flags(const QModelIndex &index) const
+{
+ if (!index.isValid()) {
+ return 0;
+ }
+
+ // TODO: this really should be done for other transfer plugins too, it does
+ // not make sense to disable file transfers once it is already finished
+ if (m_status == Job::Finished || m_status == Job::FinishedKeepAlive) {
+ return 0;
+ }
+
+ return FileModel::flags(index);
+}
+
TransferTorrent::TransferTorrent(TransferGroup* parent, TransferFactory* factory,
Scheduler* scheduler, const KUrl &source, const KUrl &dest,
const QDomElement* e)
m_filemodel = nullptr;
}
if (!m_filemodel) {
- m_filemodel = new FileModel(files(), directory(), this);
+ const Job::Status transferstatus = status();
+ m_filemodel = new TorrentFileModel(files(), directory(), this, transferstatus);
connect(m_filemodel, SIGNAL(checkStateChanged()), this, SLOT(slotCheckStateChanged()));
if (m_lthandle.torrent_file()) {
for (int i = 0; i < ltstorage.num_files(); i++) {
const KUrl fileurl = KUrl(ltstorage.file_path(i).c_str());
- Job::Status filestatus = status();
+ Job::Status filestatus = transferstatus;
// priority has no effect on finished/seeded torrents
const int ltpriority = (m_priorities.size() > i ? m_priorities.at(i) : LTPriorities::NormalPriority);
const lt::torrent_status ltstatus = m_lthandle.status();
if (ltstatus.state == lt::torrent_status::seeding || ltstatus.state == lt::torrent_status::finished) {
filestatus = Job::Finished;
- // TODO: disable checkbox via custom file model class for finished/seeded files
}
if (ltpriority == LTPriorities::Disabled) {
filestatus = Job::Stopped;