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

@@ -38,15 +38,24 @@ MtpConnection::MtpConnection(const QUrl &url) : device_(nullptr) {
// Parse the URL
QRegExp host_re("^usb-(\\d+)-(\\d+)$");
if (host_re.indexIn(hostname) == -1) {
unsigned int bus_location = 0;
unsigned int device_num = 0;
QUrlQuery url_query(url);
if (host_re.indexIn(hostname) >= 0) {
bus_location = host_re.cap(1).toUInt();
device_num = host_re.cap(2).toUInt();
}
else if (url_query.hasQueryItem("busnum")) {
bus_location = url_query.queryItemValue("busnum").toUInt();
device_num = url_query.queryItemValue("devnum").toUInt();
}
else {
qLog(Warning) << "Invalid MTP device:" << hostname;
return;
}
const unsigned int bus_location = host_re.cap(1).toInt();
const unsigned int device_num = host_re.cap(2).toInt();
QUrlQuery url_query(url);
if (url_query.hasQueryItem("vendor")) {
LIBMTP_raw_device_t *raw_device = (LIBMTP_raw_device_t*)malloc(sizeof(LIBMTP_raw_device_t));
raw_device->device_entry.vendor = url_query.queryItemValue("vendor").toLatin1().data();