Dont allow copy music to optical drives

Fixes #387
This commit is contained in:
Jonas Kvinge
2020-03-17 20:44:51 +01:00
parent d1f5cbea4a
commit 973229cf4e
5 changed files with 9 additions and 1 deletions

View File

@@ -52,6 +52,7 @@ class CddaLister : public DeviceLister {
void UnmountDevice(const QString&);
void UpdateDeviceFreeSpace(const QString&);
bool Init();
bool CopyMusic() { return false; }
private:
QStringList devices_list_;

View File

@@ -69,6 +69,8 @@ class DeviceLister : public QObject {
// Do whatever needs to be done to safely remove the device.
virtual void UnmountDeviceAsync(const QString &id);
virtual bool CopyMusic() { return true; }
public slots:
virtual void UpdateDeviceFreeSpace(const QString &id) = 0;
virtual void ShutDown() {}

View File

@@ -385,6 +385,10 @@ QVariant DeviceManager::data(const QModelIndex &idx, int role) const {
if (!info->device_) return QVariant();
return info->device_->song_count();
case Role_CopyMusic:
if (info->BestBackend() && info->BestBackend()->lister_) return info->BestBackend()->lister_->CopyMusic();
else return false;
default:
return QVariant();
}

View File

@@ -73,6 +73,7 @@ class DeviceManager : public SimpleTreeModel<DeviceInfo> {
Role_TranscodeMode,
Role_TranscodeFormat,
Role_SongCount,
Role_CopyMusic,
LastRole,
};

View File

@@ -40,7 +40,7 @@ DeviceStateFilterModel::DeviceStateFilterModel(QObject *parent, DeviceManager::S
}
bool DeviceStateFilterModel::filterAcceptsRow(int row, const QModelIndex&) const {
return sourceModel()->index(row, 0).data(DeviceManager::Role_State).toInt() != state_;
return sourceModel()->index(row, 0).data(DeviceManager::Role_State).toInt() != state_ && sourceModel()->index(row, 0).data(DeviceManager::Role_CopyMusic).toBool();
}
void DeviceStateFilterModel::ProxyRowCountChanged() {