Convert devicemanager to QAbstractItemModel

This commit is contained in:
Jonas Kvinge
2018-12-29 02:57:22 +01:00
parent fc9f93791d
commit 404283be19
35 changed files with 574 additions and 379 deletions

View File

@@ -40,7 +40,14 @@ MtpLoader::MtpLoader(const QUrl &url, TaskManager *task_manager, CollectionBacke
original_thread_ = thread();
}
MtpLoader::~MtpLoader() {}
MtpLoader::~MtpLoader() {
delete connection_;
}
bool MtpLoader::Init() {
connection_ = new MtpConnection(url_);
return connection_->is_valid();
}
void MtpLoader::LoadDatabase() {
@@ -58,15 +65,9 @@ void MtpLoader::LoadDatabase() {
bool MtpLoader::TryLoad() {
MtpConnection dev(url_);
if (!dev.is_valid()) {
emit Error(tr("Error connecting MTP device"));
return false;
}
// Load the list of songs on the device
SongList songs;
LIBMTP_track_t *tracks = LIBMTP_Get_Tracklisting_With_Callback(dev.device(), nullptr, nullptr);
LIBMTP_track_t* tracks = LIBMTP_Get_Tracklisting_With_Callback(connection_->device(), nullptr, nullptr);
while (tracks) {
LIBMTP_track_t *track = tracks;