Commit 2fc0667f authored by Boudhayan Gupta's avatar Boudhayan Gupta
Browse files

Change from KUrl to QUrl

parent 619b57c5
......@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12)
project(libkcompactdisc)
include(FeatureSummary)
find_package(Qt5 REQUIRED COMPONENTS Core Qml Quick OpenGL)
find_package(Qt5 REQUIRED COMPONENTS Core)
find_package(ECM 1.7.0 NO_MODULE REQUIRED)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
......
......@@ -23,16 +23,16 @@
#include "kcompactdisc_p.h"
#include <QtDBus>
#include <QUrl>
#include <kdebug.h>
#include <kurl.h>
#include <klocale.h>
#include <solid/device.h>
#include <solid/block.h>
#include <solid/opticaldrive.h>
static QMap<QString, KUrl> cdromsNameToDeviceUrl;
static QMap<QString, QUrl> cdromsNameToDeviceUrl;
static QMap<QString, QString> cdromsNameToUdi;
static QString ___null = QString();
......@@ -41,7 +41,7 @@ static void refreshListOfCdromDevices()
cdromsNameToDeviceUrl.clear();
cdromsNameToUdi.clear();
QString name, type;
KUrl url;
QUrl url;
//get a list of all devices that are Cdrom
foreach(const Solid::Device &device, Solid::Device::listFromType(Solid::DeviceInterface::OpticalDrive)) {
......@@ -55,7 +55,7 @@ static void refreshListOfCdromDevices()
const Solid::OpticalDrive *o = device.as<Solid::OpticalDrive>();
Solid::OpticalDrive::MediumTypes mediumType = o->supportedMedia();
url = KUrl::fromPath(QLatin1String( b->device().toLatin1() ));
url = QUrl::fromUserInput(QLatin1String( b->device().toLatin1() ));
//TODO translate them ?
if(mediumType < Solid::OpticalDrive::Cdrw) {
type = QLatin1String( "CD-ROM" );
......@@ -81,12 +81,12 @@ static void refreshListOfCdromDevices()
}
#if 0
if(cdromsNameToDeviceUrl.empty()) {
cdromsNameToDeviceUrl.insert(QString("Generic CDROM []"), KUrl::fromPath(wm_drive_default_device()));
cdromsNameToDeviceUrl.insert(QString("Generic CDROM []"), QUrl::fromPath(wm_drive_default_device()));
}
#endif
}
static QMap<QString, KUrl> &getListOfCdromDevicesNamesAndUrl()
static QMap<QString, QUrl> &getListOfCdromDevicesNamesAndUrl()
{
if(cdromsNameToDeviceUrl.empty())
refreshListOfCdromDevices();
......@@ -102,9 +102,9 @@ static QMap<QString, QString> &getListOfCdromDevicesNamesAndUdi()
return cdromsNameToUdi;
}
QString KCompactDisc::urlToDevice(const KUrl& deviceUrl)
QString KCompactDisc::urlToDevice(const QUrl &deviceUrl)
{
if(deviceUrl.protocol() == QLatin1String( "media" ) || deviceUrl.protocol() == QLatin1String( "system" )) {
if(deviceUrl.scheme() == QLatin1String( "media" ) || deviceUrl.scheme() == QLatin1String( "system" )) {
kDebug() << "Asking mediamanager for " << deviceUrl.fileName();
QDBusInterface mediamanager( QLatin1String( "org.kde.kded" ), QLatin1String( "/modules/mediamanager" ), QLatin1String( "org.kde.MediaManager" ) );
......@@ -118,7 +118,7 @@ QString KCompactDisc::urlToDevice(const KUrl& deviceUrl)
kDebug() << "Reply from mediamanager " << properties[5];
return properties[5];
}
} else if(deviceUrl.protocol() == QLatin1String( "file" )) {
} else if(deviceUrl.scheme() == QLatin1String( "file" )) {
return deviceUrl.path();
} else {
return QString();
......@@ -152,21 +152,21 @@ const QString KCompactDisc::defaultCdromDeviceName()
else return QString();
}
const KUrl KCompactDisc::defaultCdromDeviceUrl()
const QUrl KCompactDisc::defaultCdromDeviceUrl()
{
const QList<KUrl> urls = getListOfCdromDevicesNamesAndUrl().values();
const QList<QUrl> urls = getListOfCdromDevicesNamesAndUrl().values();
if (!urls.isEmpty()) return urls[0];
else return KUrl();
else return QUrl();
}
const KUrl KCompactDisc::cdromDeviceUrl(const QString &cdromDeviceName)
const QUrl KCompactDisc::cdromDeviceUrl(const QString &cdromDeviceName)
{
const QMap<QString, KUrl> &nameUrls = getListOfCdromDevicesNamesAndUrl();
KUrl result = nameUrls.value(cdromDeviceName);
const QMap<QString, QUrl> &nameUrls = getListOfCdromDevicesNamesAndUrl();
QUrl result = nameUrls.value(cdromDeviceName);
if (!result.isValid())
{
const KUrl passedUrl(cdromDeviceName);
foreach(const KUrl &url, nameUrls)
const QUrl passedUrl(cdromDeviceName);
foreach(const QUrl &url, nameUrls)
{
if (url == passedUrl)
{
......@@ -227,7 +227,7 @@ const QString &KCompactDisc::deviceName()
return d->m_deviceName;
}
const KUrl KCompactDisc::deviceUrl()
const QUrl KCompactDisc::deviceUrl()
{
Q_D(KCompactDisc);
return KCompactDisc::cdromDeviceUrl(d->m_deviceName);
......
......@@ -22,12 +22,12 @@
#ifndef KCOMPACTDISC_H
#define KCOMPACTDISC_H
#include <QtCore/QObject>
#include <QtCore/QTimer>
#include <QtCore/QStringList>
#include <QObject>
#include <QStringList>
#include <QUrl>
#include <QTimer>
#include <kdemacros.h>
#include <kurl.h>
#if defined Q_OS_WIN
......@@ -191,7 +191,7 @@ public:
* If the url is a media:/ or system:/ URL returns
* the device it represents, otherwise returns device
*/
static QString urlToDevice(const KUrl& url);
static QString urlToDevice(const QUrl& url);
/**
* All installed audio backends.
......@@ -211,12 +211,12 @@ public:
/**
* The Url of default CDROM device for this system.
*/
static const KUrl defaultCdromDeviceUrl();
static const QUrl defaultCdromDeviceUrl();
/**
* The Url of named CDROM device for this system.
*/
static const KUrl cdromDeviceUrl(const QString &);
static const QUrl cdromDeviceUrl(const QString &);
/**
* The Udi of default CDROM device for this system.
......@@ -257,9 +257,9 @@ public:
const QString &deviceName();
/**
* Current device as Kurl.
* Current device as QUrl.
*/
const KUrl deviceUrl();
const QUrl deviceUrl();
/**
* Current disc, 0 if no disc or impossible to calculate id.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment