Disable automatic conversions to QUrl from strings.

This commit is contained in:
John Maguire 2012-09-26 17:09:13 +02:00
parent f98f1ff6df
commit 606bf71208
18 changed files with 21 additions and 18 deletions

View File

@ -24,6 +24,7 @@ if (QT_VERSION_MINOR GREATER 5)
add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
endif(QT_VERSION_MINOR GREATER 7)
endif(QT_VERSION_MINOR GREATER 5)
add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
if(ENABLE_IMOBILEDEVICE AND IMOBILEDEVICE_VERSION VERSION_GREATER 1.1.1)
set(IMOBILEDEVICE_USES_UDIDS ON)

View File

@ -224,7 +224,7 @@ bool CommandlineOptions::Parse() {
if (file_info.exists())
urls_ << QUrl::fromLocalFile(file_info.canonicalFilePath());
else
urls_ << value;
urls_ << QUrl::fromUserInput(value);
}
return true;

View File

@ -588,7 +588,7 @@ void Song::InitFromLastFM(const lastfm::Track& track) {
filename.replace(':', '/');
if (prefix.contains("://")) {
d->url_ = prefix + filename;
d->url_ = QUrl(prefix + filename);
} else {
d->url_ = QUrl::fromLocalFile(prefix + filename);
}

View File

@ -27,6 +27,7 @@
#include <QNetworkAccessManager>
#include <QObject>
#include <QQueue>
#include <QUrl>
#include <boost/scoped_ptr.hpp>
@ -63,7 +64,7 @@ struct CoverSearchResult {
QString description;
// an URL of a cover image described by this CoverSearchResult
QString image_url;
QUrl image_url;
};
Q_DECLARE_METATYPE(CoverSearchResult);

View File

@ -162,7 +162,8 @@ AlbumCoverLoader::TryLoadResult AlbumCoverLoader::TryLoadImage(
}
if (filename.toLower().startsWith("http://")) {
QNetworkReply* reply = network_->get(QNetworkRequest(filename));
QUrl url(filename);
QNetworkReply* reply = network_->get(QNetworkRequest(url));
connect(reply, SIGNAL(finished()), SLOT(RemoteFetchFinished()));
remote_tasks_.insert(reply, task);

View File

@ -129,7 +129,7 @@ void AmazonCoverProvider::ReadLargeImage(QXmlStreamReader* reader, CoverSearchRe
case QXmlStreamReader::StartElement:
if (reader->name() == "URL") {
CoverSearchResult result;
result.image_url = reader->readElementText();
result.image_url = QUrl(reader->readElementText());
results->append(result);
} else {
reader->skipCurrentElement();

View File

@ -134,7 +134,7 @@ void DiscogsCoverProvider::HandleSearchReply(QNetworkReply* reply, int id) {
// constructing the primary image's url from the thmub's url.
if (result_map.contains("thumb")) {
CoverSearchResult cover_result;
cover_result.image_url = result_map["thumb"].toString().replace("R-90-", "R-");
cover_result.image_url = QUrl(result_map["thumb"].toString().replace("R-90-", "R-"));
if (result_map.contains("title")) {
cover_result.description = result_map["title"].toString();
}

View File

@ -57,7 +57,7 @@ void LastFmCoverProvider::QueryFinished() {
foreach (const lastfm::XmlQuery& element, elements) {
CoverSearchResult result;
result.description = element["artist"].text() + " - " + element["name"].text();
result.image_url = element["image size=extralarge"].text();
result.image_url = QUrl(element["image size=extralarge"].text());
results << result;
}
} else {

View File

@ -160,7 +160,7 @@ void Client::ListFilesFinished(ListFilesResponse* response, QNetworkReply* reply
GetFileResponse* Client::GetFile(const QString& file_id) {
GetFileResponse* ret = new GetFileResponse(file_id, this);
QString url = QString(kGoogleDriveFile).arg(file_id);
QUrl url(QString(kGoogleDriveFile).arg(file_id));
QNetworkRequest request = QNetworkRequest(url);
AddAuthorizationHeader(&request);

View File

@ -212,7 +212,7 @@ void GoogleDriveService::ReadTagsFinished(TagReaderClient::ReplyType* reply,
song.set_ctime(metadata.created_date().toTime_t());
song.set_comment(metadata.description());
song.set_directory_id(0);
song.set_url(url);
song.set_url(QUrl(url));
// Use the Google Drive title if we couldn't read tags from the file.
if (song.title().isEmpty()) {

View File

@ -1731,7 +1731,7 @@ Song GroovesharkService::ExtractSong(const QVariantMap& result_song) {
// play, we generate a fake URL for now, and we will create a real streaming
// URL when user will actually play the song (through url handler)
// URL is grooveshark://artist_id/album_id/song_id
song.set_url(QString("grooveshark://%1/%2/%3").arg(artist_id).arg(album_id).arg(song_id));
song.set_url(QUrl(QString("grooveshark://%1/%2/%3").arg(artist_id).arg(album_id).arg(song_id)));
}
return song;
}

View File

@ -118,7 +118,7 @@ IcecastBackend::StationList IcecastBackend::GetStations(const QString& filter,
while (q.next()) {
Station station;
station.name = q.value(0).toString();
station.url = q.value(1).toString();
station.url = QUrl(q.value(1).toString());
station.mime_type = q.value(2).toString();
station.bitrate = q.value(3).toInt();
station.channels = q.value(4).toInt();

View File

@ -875,7 +875,7 @@ void LastFMService::FetchMoreTracksFinished() {
const XmlQuery& playlist = query["playlist"];
foreach (const XmlQuery& q, playlist["trackList"].children("track")) {
lastfm::MutableTrack t;
t.setUrl(q["location"].text());
t.setUrl(QUrl(q["location"].text()));
t.setExtra("trackauth", q["extension"]["trackauth"].text());
t.setTitle(q["title"].text());
t.setArtist(q["creator"].text());

View File

@ -119,7 +119,7 @@ void MagnatuneDownloadDialog::DownloadNext() {
QString sku = item->data(0, Qt::UserRole).toString();
item->setData(1, Qt::DisplayRole, tr("Starting..."));
QUrl url = QString(MagnatuneService::kDownloadUrl);
QUrl url(MagnatuneService::kDownloadUrl);
url.setUserName(service_->username());
url.setPassword(service_->password());
url.addQueryItem("id", MagnatuneService::kPartnerId);

View File

@ -72,7 +72,7 @@ void SavedRadio::LoadStreams() {
int count = s.beginReadArray("streams");
for (int i=0 ; i<count ; ++i) {
s.setArrayIndex(i);
streams_ << Stream(s.value("url").toString(), s.value("name").toString());
streams_ << Stream(QUrl(s.value("url").toString()), s.value("name").toString());
}
s.endArray();
}

View File

@ -95,8 +95,8 @@ void ITunesSearchPage::SearchFinished(QNetworkReply* reply) {
podcast.set_title(result["trackName"].toString());
podcast.set_url(result["feedUrl"].toUrl());
podcast.set_link(result["trackViewUrl"].toUrl());
podcast.set_image_url_small(result["artworkUrl30"].toString());
podcast.set_image_url_large(result["artworkUrl100"].toString());
podcast.set_image_url_small(QUrl(result["artworkUrl30"].toString()));
podcast.set_image_url_large(QUrl(result["artworkUrl100"].toString()));
model()->appendRow(model()->CreatePodcastItem(podcast));
}

View File

@ -185,7 +185,7 @@ void AlbumCoverSearcher::SearchFinished(quint64 id, const CoverSearchResults& re
continue;
quint64 id = app_->album_cover_loader()->LoadImageAsync(
options_, result.image_url, QString());
options_, result.image_url.toString(), QString());
QStandardItem* item = new QStandardItem;
item->setIcon(no_cover_icon_);

View File

@ -1843,7 +1843,7 @@ void MainWindow::PlaylistOpenInBrowser() {
foreach (const QModelIndex& proxy_index, proxy_indexes) {
const QModelIndex index = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index);
urls << index.sibling(index.row(), Playlist::Column_Filename).data().toString();
urls << QUrl(index.sibling(index.row(), Playlist::Column_Filename).data().toString());
}
Utilities::OpenInFileBrowser(urls);