@@ -41,7 +41,7 @@ CddaDevice::CddaDevice(const QUrl &url, DeviceLister *lister, const QString &uni
|
||||
QObject::connect(&cdda_song_loader_, &CddaSongLoader::SongsLoaded, this, &CddaDevice::SongsLoaded);
|
||||
QObject::connect(&cdda_song_loader_, &CddaSongLoader::SongsDurationLoaded, this, &CddaDevice::SongsLoaded);
|
||||
QObject::connect(&cdda_song_loader_, &CddaSongLoader::SongsMetadataLoaded, this, &CddaDevice::SongsLoaded);
|
||||
QObject::connect(this, &CddaDevice::SongsDiscovered, model_, &CollectionModel::SongsDiscovered);
|
||||
QObject::connect(this, &CddaDevice::SongsDiscovered, model_, &CollectionModel::AddReAddOrUpdate);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,6 @@ ConnectedDevice::ConnectedDevice(const QUrl &url, DeviceLister *lister, const QS
|
||||
app_->task_manager(),
|
||||
Song::Source::Device,
|
||||
QStringLiteral("device_%1_songs").arg(database_id),
|
||||
QStringLiteral("device_%1_fts").arg(database_id),
|
||||
QStringLiteral("device_%1_directories").arg(database_id),
|
||||
QStringLiteral("device_%1_subdirectories").arg(database_id));
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ void DeviceDatabaseBackend::RemoveDevice(const int id) {
|
||||
|
||||
{
|
||||
SqlQuery q(db);
|
||||
q.prepare(QStringLiteral("DROP TABLE device_%1_fts").arg(id));
|
||||
q.prepare(QStringLiteral("DROP TABLE IF EXISTS device_%1_fts").arg(id));
|
||||
if (!q.Exec()) {
|
||||
db_->ReportErrors(q);
|
||||
return;
|
||||
|
||||
@@ -55,13 +55,14 @@ class ConnectedDevice;
|
||||
class DeviceInfo : public SimpleTreeItem<DeviceInfo> {
|
||||
|
||||
public:
|
||||
enum Type {
|
||||
Type_Root,
|
||||
Type_Device,
|
||||
enum class Type {
|
||||
Root,
|
||||
Device,
|
||||
};
|
||||
|
||||
explicit DeviceInfo(SimpleTreeModel<DeviceInfo> *_model)
|
||||
: SimpleTreeItem<DeviceInfo>(Type_Root, _model),
|
||||
: SimpleTreeItem<DeviceInfo>(_model),
|
||||
type_(Type::Root),
|
||||
database_id_(-1),
|
||||
size_(0),
|
||||
transcode_mode_(MusicStorage::TranscodeMode::Transcode_Unsupported),
|
||||
@@ -71,7 +72,8 @@ class DeviceInfo : public SimpleTreeItem<DeviceInfo> {
|
||||
forget_(false) {}
|
||||
|
||||
explicit DeviceInfo(const Type _type, DeviceInfo *_parent = nullptr)
|
||||
: SimpleTreeItem<DeviceInfo>(_type, _parent),
|
||||
: SimpleTreeItem<DeviceInfo>(_parent),
|
||||
type_(_type),
|
||||
database_id_(-1),
|
||||
size_(0),
|
||||
transcode_mode_(MusicStorage::TranscodeMode::Transcode_Unsupported),
|
||||
@@ -101,6 +103,7 @@ class DeviceInfo : public SimpleTreeItem<DeviceInfo> {
|
||||
// Gets the best backend available (the one with the highest priority)
|
||||
const Backend *BestBackend() const;
|
||||
|
||||
Type type_;
|
||||
int database_id_; // -1 if not remembered in the database
|
||||
SharedPtr<ConnectedDevice> device_; // nullptr if not connected
|
||||
QList<Backend> backends_;
|
||||
@@ -122,4 +125,6 @@ class DeviceInfo : public SimpleTreeItem<DeviceInfo> {
|
||||
Q_DISABLE_COPY(DeviceInfo)
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(DeviceInfo::Type)
|
||||
|
||||
#endif // DEVICEINFO_H
|
||||
|
||||
@@ -233,7 +233,7 @@ void DeviceManager::LoadAllDevices() {
|
||||
|
||||
DeviceDatabaseBackend::DeviceList devices = backend_->GetAllDevices();
|
||||
for (const DeviceDatabaseBackend::Device &device : devices) {
|
||||
DeviceInfo *info = new DeviceInfo(DeviceInfo::Type_Device, root_);
|
||||
DeviceInfo *info = new DeviceInfo(DeviceInfo::Type::Device, root_);
|
||||
info->InitFromDb(device);
|
||||
emit DeviceCreatedFromDB(info);
|
||||
}
|
||||
@@ -479,7 +479,7 @@ void DeviceManager::PhysicalDeviceAdded(const QString &id) {
|
||||
}
|
||||
else {
|
||||
// It's a completely new device
|
||||
info = new DeviceInfo(DeviceInfo::Type_Device, root_);
|
||||
info = new DeviceInfo(DeviceInfo::Type::Device, root_);
|
||||
info->backends_ << DeviceInfo::Backend(lister, id);
|
||||
info->friendly_name_ = lister->MakeFriendlyName(id);
|
||||
info->size_ = lister->DeviceCapacity(id);
|
||||
|
||||
Reference in New Issue
Block a user