Commit 7ed5a493 authored by David Faure's avatar David Faure
Browse files

Enable -DQT_NO_URL_CAST_FROM_STRING and fix compilation

Many many QString/QUrl confusions in this code, causing a number
of bugs for sure (e.g. URLs to local files without a file scheme).
parent 3bc2fed0
......@@ -65,8 +65,8 @@ if(WIN32)
set(CMAKE_REQUIRED_LIBRARIES ${KDEWIN32_LIBRARIES})
set(CMAKE_REQUIRED_INCLUDES ${KDEWIN32_INCLUDES})
endif(WIN32)
#add_definitions(${QT_DEFINITIONS} ${QT_QTDBUS_DEFINITIONS} ${KDE4_DEFINITIONS})
#add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
......
......@@ -108,7 +108,7 @@ QVariant TransferModelItem::data(int role) const
//store the icon for speed improvements, KIconLoader should make sure, that
//the icon data gets shared
if (m_mimeType.isNull()) {
m_mimeType = QIcon::fromTheme(KIO::iconNameForUrl(m_transferHandler->dest().url()));
m_mimeType = QIcon::fromTheme(KIO::iconNameForUrl(m_transferHandler->dest()));
}
return m_mimeType;
......
......@@ -206,7 +206,7 @@ void KGetPlugin::getLinks(bool selectedOnly)
attr = QL1S("src");
else if (element.hasAttribute(QL1S("data")))
attr = QL1S("data");
const QUrl resolvedUrl (baseUrl.resolved(element.attribute(attr)));
const QUrl resolvedUrl (baseUrl.resolved(QUrl(element.attribute(attr))));
// Only select valid and non-local links for download...
if (resolvedUrl.isValid() && !resolvedUrl.isLocalFile() && !resolvedUrl.host().isEmpty()) {
if (element.hasAttribute(QL1S("type")))
......
......@@ -1204,14 +1204,14 @@ void MainWindow::dropEvent(QDropEvent * event)
KGuiItem(i18n("&Load transfer list"), QIcon::fromTheme("list-add")), KStandardGuiItem::cancel());
if (msgBoxResult == 3) //Download
NewTransferDialogHandler::showNewTransferDialog(list.first().url());
NewTransferDialogHandler::showNewTransferDialog(list.first());
if (msgBoxResult == 4) //Load
KGet::load(list.first().url());
}
else
{
if (list.count() == 1)
NewTransferDialogHandler::showNewTransferDialog(list.first().url());
NewTransferDialogHandler::showNewTransferDialog(list.first());
else
NewTransferDialogHandler::showNewTransferDialog(list);
}
......
......@@ -56,8 +56,8 @@ void BTSettingsWidget::defaults()
portBox->setValue(BittorrentSettings::port());
uploadBox->setValue(BittorrentSettings::uploadLimit());
downloadBox->setValue(BittorrentSettings::downloadLimit());
torrentEdit->setUrl(BittorrentSettings::torrentDir());
tempEdit->setUrl(BittorrentSettings::tmpDir());
torrentEdit->setUrl(QUrl::fromLocalFile(BittorrentSettings::torrentDir()));
tempEdit->setUrl(QUrl::fromLocalFile(BittorrentSettings::tmpDir()));
preallocBox->setChecked(BittorrentSettings::preAlloc());
utpBox->setChecked(BittorrentSettings::enableUTP());
}
......
......@@ -262,12 +262,13 @@ void BTTransfer::addTracker(const QString &url)
return;
}
if(!QUrl(url).isValid()) {
QUrl u(url);
if(!u.isValid()) {
KMessageBox::error(nullptr, i18n("Malformed URL."));
return;
}
torrent->getTrackersList()->addTracker(url,true);
torrent->getTrackersList()->addTracker(u,true);
}
/**Private functions**/
......
......@@ -51,8 +51,8 @@ bool TransferKio::setDirectory(const QUrl& newDirectory)
bool TransferKio::setNewDestination(const QUrl &newDestination)
{
if (newDestination.isValid() && (newDestination != dest())) {
QUrl oldPath = QUrl(m_dest.path() + ".part");
if (oldPath.isValid() && QFile::exists(oldPath.toString())) {
QString oldPath = m_dest.toLocalFile() + ".part";
if (QFile::exists(oldPath)) {
m_movingFile = true;
stop();
setStatus(Job::Moving);
......@@ -67,7 +67,7 @@ bool TransferKio::setNewDestination(const QUrl &newDestination)
m_signature->setDestination(newDestination);
}
KIO::Job *move = KIO::file_move(oldPath, QUrl(newDestination.path() + ".part"), -1, KIO::HideProgressInfo);
KIO::Job *move = KIO::file_move(QUrl::fromLocalFile(oldPath), QUrl::fromLocalFile(newDestination.toLocalFile() + ".part"), -1, KIO::HideProgressInfo);
connect(move, SIGNAL(result(KJob*)), this, SLOT(newDestResult(KJob*)));
connect(move, SIGNAL(infoMessage(KJob*,QString)), this, SLOT(slotInfoMessage(KJob*,QString)));
connect(move, SIGNAL(percent(KJob*,ulong)), this, SLOT(slotPercent(KJob*,ulong)));
......@@ -123,7 +123,7 @@ void TransferKio::deinit(Transfer::DeleteOptions options)
{
if (options & DeleteFiles)//if the transfer is not finished, we delete the *.part-file
{
KIO::Job *del = KIO::del(QString(m_dest.path() + ".part"), KIO::HideProgressInfo);
KIO::Job *del = KIO::del(QUrl::fromLocalFile(m_dest.path() + ".part"), KIO::HideProgressInfo);
if (!del->exec()) {
qCDebug(KGET_DEBUG) << "Could not delete part " << QString(m_dest.path() + ".part");
}
......
......@@ -478,7 +478,8 @@ void AbstractMetalink::filesSelected()
doDownload = false;
//ask the user, unless he has chosen overwriteAll before
} else if (!overwriteAll) {
KIO::RenameDialog dlg(0, i18n("File already exists"), index.data().toString(), dest, KIO::RenameDialog_Options(KIO::RenameDialog_MultipleItems | KIO::RenameDialog_Overwrite | KIO::RenameDialog_Skip));
KIO::RenameDialog dlg(0, i18n("File already exists"), QUrl(index.data().toString()), dest,
KIO::RenameDialog_Options(KIO::RenameDialog_MultipleItems | KIO::RenameDialog_Overwrite | KIO::RenameDialog_Skip));
const int result = dlg.exec();
if (result == KIO::Result_Rename) {
......
......@@ -174,7 +174,7 @@ bool MetalinkHttp::metalinkHttpInit()
{
qDebug() << "m_dest = " << m_dest;
const QUrl tempDest = QUrl(m_dest.adjusted(QUrl::RemoveFilename));
QUrl dest = tempDest.toString() + m_dest.fileName();
QUrl dest = QUrl(tempDest.toString() + m_dest.fileName());
qDebug() << "dest = " << dest;
//sort the urls according to their priority (highest first)
......@@ -225,7 +225,8 @@ bool MetalinkHttp::metalinkHttpInit()
if (!QFileInfo::exists(QStandardPaths::writableLocation(QStandardPaths::DataLocation))) {
QDir().mkpath(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
}
Download *signat_download = new Download(m_signatureUrl, QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QStringLiteral("/metalinks/") + m_source.fileName());
const QString path = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QStringLiteral("/metalinks/") + m_source.fileName();
Download *signat_download = new Download(m_signatureUrl, QUrl::fromLocalFile(path));
connect(signat_download, SIGNAL(finishedSuccessfully(QUrl,QByteArray)), SLOT(setSignature(QUrl,QByteArray)));
}
m_dataSourceFactory[dataFactory->dest()] = dataFactory;
......
......@@ -81,7 +81,8 @@ void MetalinkXml::downloadMetalink()
if (!QFileInfo::exists(QStandardPaths::writableLocation(QStandardPaths::DataLocation))) {
QDir().mkpath(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
}
Download *download = new Download(m_source, QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QStringLiteral("/metalinks/") + m_source.fileName());
const QString path = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QStringLiteral("/metalinks/") + m_source.fileName();
Download *download = new Download(m_source, QUrl::fromLocalFile(path));
connect(download, SIGNAL(finishedSuccessfully(QUrl,QByteArray)), SLOT(metalinkInit(QUrl,QByteArray)));
}
......@@ -100,7 +101,7 @@ bool MetalinkXml::metalinkInit(const QUrl &src, const QByteArray &data)
//try to parse the locally stored metalink-file
if (!m_metalink.isValid() && m_localMetalinkLocation.isValid()) {
KGetMetalink::HandleMetalink::load(m_localMetalinkLocation.toLocalFile(), &m_metalink);
KGetMetalink::HandleMetalink::load(m_localMetalinkLocation, &m_metalink);
}
if (!m_metalink.isValid()) {
......
......@@ -42,5 +42,6 @@ class mirror : public QObject
};
void MirrorSearch ( const QUrl &url, QObject *receiver, const char *member );
void MirrorSearch ( const QString &fileName, QObject *receiver, const char *member );
#endif // MIRROR_H
......@@ -222,7 +222,7 @@ void DropTarget::dropEvent(QDropEvent * event)
KGuiItem(i18n("&Load transfer list"), QIcon::fromTheme("list-add")), KStandardGuiItem::cancel());
if (msgBoxResult == 3) //Download
NewTransferDialogHandler::showNewTransferDialog(list.first().url());
NewTransferDialogHandler::showNewTransferDialog(list.first());
if (msgBoxResult == 4) //Load
KGet::load(list.first().url());
}
......@@ -231,7 +231,7 @@ void DropTarget::dropEvent(QDropEvent * event)
if (list.count() == 1)
{
str = event->mimeData()->text();
NewTransferDialogHandler::showNewTransferDialog(str);
NewTransferDialogHandler::showNewTransferDialog(QUrl(str));
}
else
NewTransferDialogHandler::showNewTransferDialog(list);
......@@ -335,7 +335,7 @@ void DropTarget::toggleSticky()
pop_sticky->setChecked(Settings::dropSticky());
if ( Settings::dropSticky() )
KWindowSystem::setState(winId(), KWindowSystem::SkipTaskbar | KWindowSystem::StaysOnTop | KWindowSystem::Sticky);
KWindowSystem::setState(winId(), KWindowSystem::SkipTaskbar | KWindowSystem::KeepAbove | KWindowSystem::Sticky);
else
KWindowSystem::clearState(winId(), KWindowSystem::Sticky);
}
......
......@@ -25,7 +25,7 @@ GroupSettingsDialog::GroupSettingsDialog(QWidget *parent, TransferGroupHandler *
ui.defaultFolderRequester->setMode(KFile::Directory);
QString path = group->defaultFolder();
ui.defaultFolderRequester->setUrl(path);
ui.defaultFolderRequester->setUrl(QUrl::fromLocalFile(path));
ui.defaultFolderRequester->setStartDir(QUrl(KGet::generalDestDir(true)));
ui.regExpEdit->setText(group->regExp().pattern());
......
......@@ -158,7 +158,7 @@ void TransferHistory::slotWriteDefault()
void TransferHistory::slotDownload()
{
if (!m_iconModeEnabled) {
NewTransferDialogHandler::showNewTransferDialog(((RangeTreeWidget *) m_view)->currentItem(0)->text());
NewTransferDialogHandler::showNewTransferDialog(QUrl(((RangeTreeWidget *) m_view)->currentItem(0)->text()));
}
}
......
......@@ -193,8 +193,8 @@ void TransferHistoryItemDelegate::slotDownload()
{
const QAbstractItemModel *model = static_cast <const QAbstractItemModel *> (m_selectedIndex.model());
NewTransferDialogHandler::showNewTransferDialog(model->data(m_selectedIndex,
TransferHistoryCategorizedDelegate::RoleUrl).toString());
NewTransferDialogHandler::showNewTransferDialog(QUrl(model->data(m_selectedIndex,
TransferHistoryCategorizedDelegate::RoleUrl).toString()));
}
void TransferHistoryItemDelegate::slotDeleteTransfer()
......
......@@ -172,12 +172,12 @@ void KGetLinkView::showLinks(const QStringList &links, bool urlRequestVisible)
const int count = items.count();
int index = items.indexOf(QLatin1String("url"));
if (index > -1 && index+1 < count)
url = items.at(index+1);
url = QUrl(items.at(index+1));
index = items.indexOf(QLatin1String("type"));
if (index > -1 && index+1 < count)
mt = db.mimeTypeForName(items.at(index+1));
} else {
url = linkitem;
url = QUrl(linkitem);
mt = db.mimeTypeForFile(linkitem, QMimeDatabase::MatchExtension);
}
......
......@@ -1389,7 +1389,7 @@ bool KGetMetalink::HttpLinkHeader::operator<(const HttpLinkHeader &other) const
void KGetMetalink::HttpLinkHeader::parseHeaderLine(const QString &line)
{
url = line.mid(line.indexOf("<") + 1,line.indexOf(">") -1).trimmed();
url = QUrl(line.mid(line.indexOf("<") + 1,line.indexOf(">") -1).trimmed());
const QList<QString> attribList = line.split(";");
foreach (const QString str, attribList) {
......
......@@ -155,7 +155,7 @@ void NewTransferDialog::setSource(const QList<QUrl> &sources)
}
if (sources.count() == 1) {
QUrl m_srcUrl = sources.first().url();
QUrl m_srcUrl = sources.first();
ui.urlRequester->clear();
if (m_srcUrl.isEmpty()) {
m_srcUrl = QUrl(QApplication::clipboard()->text(QClipboard::Clipboard).trimmed());
......@@ -182,7 +182,7 @@ void NewTransferDialog::setSource(const QList<QUrl> &sources)
void NewTransferDialog::setDestinationFileName(const QString &filename)
{
ui.destRequester->setUrl(QString(ui.destRequester->url().adjusted(QUrl::RemoveFilename).toString() + filename));
ui.destRequester->setUrl(QUrl(ui.destRequester->url().adjusted(QUrl::RemoveFilename).toString() + filename));
}
void NewTransferDialog::setDestination()
......
......@@ -96,8 +96,9 @@ void SignatureDlg::textChanged()
void SignatureDlg::loadSignatureClicked()
{
const QUrl url = QFileDialog::getOpenFileUrl(this, i18n("Load Signature File"), KGet::generalDestDir(), "*.asc|" + i18n("Detached OpenPGP ASCII signature (*.asc)") + '\n' +
"*.sig|" + i18n("Detached OpenPGP binary signature (*.sig)"));
const QUrl url = QFileDialog::getOpenFileUrl(this, i18n("Load Signature File"), QUrl::fromLocalFile(KGet::generalDestDir()),
"*.asc|" + i18n("Detached OpenPGP ASCII signature (*.asc)") + '\n' +
"*.sig|" + i18n("Detached OpenPGP binary signature (*.sig)"));
if (url.isEmpty()) {
return;
}
......
......@@ -39,7 +39,7 @@ TransferSettingsDialog::TransferSettingsDialog(QWidget *parent, TransferHandler
ui.downloadSpin->setValue(m_transfer->downloadLimit(Transfer::VisibleSpeedLimit));
ui.uploadSpin->setValue(m_transfer->uploadLimit(Transfer::VisibleSpeedLimit));
ui.ratioSpin->setValue(m_transfer->maximumShareRatio());
ui.destination->setUrl(m_transfer->directory().toString());
ui.destination->setUrl(m_transfer->directory());
ui.destination->lineEdit()->setReadOnly(true);
ui.rename->setIcon(QIcon::fromTheme("edit-rename"));
ui.mirrors->setIcon(QIcon::fromTheme("download"));
......
Markdown is supported
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