From kde-commits Wed Oct 31 22:58:26 2012 From: Alex Fiestas Date: Wed, 31 Oct 2012 22:58:26 +0000 To: kde-commits Subject: [kdelibs/KDE/4.9] kfile: Fix/add support for mtp devices Message-Id: <20121031225826.B449DA6078 () git ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=135172431631594 Git commit fa90ceda3812b75e67368899dcc5e715e9bc74d5 by Alex Fiestas. Committed on 31/10/2012 at 23:58. Pushed by afiestas into branch 'KDE/4.9'. Fix/add support for mtp devices In case kio_mtp is installed, list them as a deviceO M +6 -0 kfile/kfileplacesitem.cpp M +2 -0 kfile/kfileplacesitem_p.h M +11 -2 kfile/kfileplacesmodel.cpp http://commits.kde.org/kdelibs/fa90ceda3812b75e67368899dcc5e715e9bc74d5 diff --git a/kfile/kfileplacesitem.cpp b/kfile/kfileplacesitem.cpp index d571955..119ccc0 100644 --- a/kfile/kfileplacesitem.cpp +++ b/kfile/kfileplacesitem.cpp @@ -32,6 +32,7 @@ #include #include #include +#include = = KFilePlacesItem::KFilePlacesItem(KBookmarkManager *manager, @@ -58,6 +59,7 @@ KFilePlacesItem::KFilePlacesItem(KBookmarkManager *manage= r, m_access =3D m_device.as(); m_volume =3D m_device.as(); m_disc =3D m_device.as(); + m_mtp =3D m_device.as(); if (m_access) { connect(m_access, SIGNAL(accessibilityChanged(bool,QString)), this, SLOT(onAccessibilityChanged(bool))); @@ -115,10 +117,12 @@ Solid::Device KFilePlacesItem::device() const m_access =3D m_device.as(); m_volume =3D m_device.as(); m_disc =3D m_device.as(); + m_mtp =3D m_device.as(); } else { m_access =3D 0; m_volume =3D 0; m_disc =3D 0; + m_mtp =3D 0; } } return m_device; @@ -183,6 +187,8 @@ QVariant KFilePlacesItem::deviceData(int role) const } else if (m_disc && (m_disc->availableContent() & Solid::Opti= calDisc::Audio)!=3D0) { QString device =3D d.as()->device(); return QUrl(QString("audiocd:/?device=3D%1").arg(device)); + } else if (m_mtp) { + return QUrl(QString("mtp:udi=3D%1").arg(d.udi())); } else { return QVariant(); } diff --git a/kfile/kfileplacesitem_p.h b/kfile/kfileplacesitem_p.h index dec3e64..b50cec4 100644 --- a/kfile/kfileplacesitem_p.h +++ b/kfile/kfileplacesitem_p.h @@ -34,6 +34,7 @@ namespace Solid class StorageAccess; class StorageVolume; class OpticalDisc; +class PortableMediaPlayer; } = class KFilePlacesItem : public QObject @@ -93,6 +94,7 @@ private: mutable QPointer m_access; mutable QPointer m_volume; mutable QPointer m_disc; + mutable QPointer m_mtp; QString m_iconPath; QStringList m_emblems; }; diff --git a/kfile/kfileplacesmodel.cpp b/kfile/kfileplacesmodel.cpp index 99e7597..0192926 100644 --- a/kfile/kfileplacesmodel.cpp +++ b/kfile/kfileplacesmodel.cpp @@ -47,6 +47,7 @@ #include = #include +#include = #include #include @@ -54,6 +55,7 @@ #include #include #include +#include #include = class KFilePlacesModel::Private @@ -147,14 +149,21 @@ KFilePlacesModel::KFilePlacesModel(QObject *parent) // create after, so if we have own places, they are added afterwards, = in case of equal priorities d->sharedBookmarks =3D new KFilePlacesSharedBookmarks(d->bookmarkManag= er); = - d->predicate =3D Solid::Predicate::fromString( - "[[[[ StorageVolume.ignored =3D=3D false AND [ StorageVolume.usage= =3D=3D 'FileSystem' OR StorageVolume.usage =3D=3D 'Encrypted' ]]" + QString predicate("[[[[ StorageVolume.ignored =3D=3D false AND [ Stora= geVolume.usage =3D=3D 'FileSystem' OR StorageVolume.usage =3D=3D 'Encrypted= ' ]]" " OR " "[ IS StorageAccess AND StorageDrive.driveType =3D=3D 'Floppy' ]]" " OR " "OpticalDisc.availableContent & 'Audio' ]" " OR " "StorageAccess.ignored =3D=3D false ]"); + + if (KProtocolInfo::isKnownProtocol("mtp")) { + predicate.prepend("["); + predicate.append(" OR PortableMediaPlayer.supportedProtocols =3D= =3D 'mtp']"); + } + + d->predicate =3D Solid::Predicate::fromString(predicate); + Q_ASSERT(d->predicate.isValid()); = connect(d->bookmarkManager, SIGNAL(changed(QString,QString)),