Commit b729730b authored by David Faure's avatar David Faure

add_definitions(-DQT_NO_URL_CAST_FROM_STRING) + fix compilation

The code in kalarm was rethought and simplified, in particular.
parent df686b66
......@@ -232,6 +232,8 @@ else()
include_directories(${kdepim_SOURCE_DIR} ${kdepim_BINARY_DIR})
add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
find_package(KF5AkonadiSearch "5.2.41" CONFIG REQUIRED)
set_package_properties(KF5AkonadiSearch PROPERTIES DESCRIPTION "The Akonadi Search libraries" URL "http://www.kde.org" TYPE REQUIRED PURPOSE "Provides search capabilities in KMail and Akonadi")
......
......@@ -471,7 +471,7 @@ QString Article::authorAsHtml() const
QUrl Article::link() const
{
return d->archive->link(d->guid);
return QUrl(d->archive->link(d->guid));
}
QString Article::description() const
......@@ -492,7 +492,7 @@ QString Article::guid() const
QUrl Article::commentsLink() const
{
return d->archive->commentsLink(d->guid);
return QUrl(d->archive->commentsLink(d->guid));
}
int Article::comments() const
......
......@@ -680,7 +680,7 @@ void Akregator::Feed::tryFetch()
Syndication::FeedPtr,
Syndication::ErrorCode)));
//connect(d->loader, SIGNAL(progress(ulong)), this, SLOT(slotSetProgress(ulong)));
d->loader->loadFrom(d->xmlUrl);
d->loader->loadFrom(QUrl(d->xmlUrl));
}
void Akregator::Feed::slotImageFetched(const QPixmap &image)
......
......@@ -948,7 +948,7 @@ void MainWidget::slotOpenHomepage()
QUrl url(feed->htmlUrl());
if (url.isValid()) {
OpenUrlRequest req(feed->htmlUrl());
OpenUrlRequest req(url);
req.setOptions(OpenUrlRequest::ExternalBrowser);
Kernel::self()->frameManager()->slotOpenUrlRequest(req);
}
......
......@@ -389,7 +389,7 @@ QMimeData *SubscriptionListModel::mimeData(const QModelIndexList &indexes) const
QList<QUrl> urls;
Q_FOREACH (const QModelIndex &i, indexes) {
const QUrl url = i.data(LinkRole).toString();
const QUrl url(i.data(LinkRole).toString());
if (!url.isEmpty()) {
urls << url;
}
......
......@@ -185,7 +185,7 @@ void AddEditBlog::autoConfigure()
return;
}
qCDebug(BLOGILO_LOG) << "Trying to guess API type by Homepage contents";
KIO::StoredTransferJob *httpGetJob = KIO::storedGet(d->ui.txtUrl->text(), KIO::NoReload, KIO::HideProgressInfo);
KIO::StoredTransferJob *httpGetJob = KIO::storedGet(QUrl(d->ui.txtUrl->text()), KIO::NoReload, KIO::HideProgressInfo);
connect(httpGetJob, &KIO::StoredTransferJob::result, this, &AddEditBlog::gotHtml);
d->mFetchAPITimer = new QTimer(this);
d->mFetchAPITimer->setSingleShot(true);
......@@ -250,7 +250,7 @@ void AddEditBlog::gotHtml(KJob *job)
while (textUrl.endsWith(QLatin1Char('/'))) {
textUrl.remove(textUrl.length() - 1, 1);
}
KIO::StoredTransferJob *testXmlRpcJob = KIO::storedGet(QStringLiteral("%1/xmlrpc.php").arg(textUrl),
KIO::StoredTransferJob *testXmlRpcJob = KIO::storedGet(QUrl(QStringLiteral("%1/xmlrpc.php").arg(textUrl)),
KIO::NoReload, KIO::HideProgressInfo);
connect(testXmlRpcJob, &KIO::StoredTransferJob::result, this, &AddEditBlog::gotXmlRpcTest);
......
......@@ -284,7 +284,7 @@ void Backend::mediaUploaded(KBlog::BlogMedia *media)
Q_EMIT sigMediaError(tmp, m);
return;
}
m->setRemoteUrl(QUrl(media->url().url()).toString());
m->setRemoteUrl(QUrl(media->url().url()));
m->setUploaded(true);
qCDebug(BLOGILO_LOG) << "Emitting sigMediaUploaded...";
Q_EMIT sigMediaUploaded(m);
......
......@@ -520,9 +520,9 @@ void Toolbox::openPostInBrowser()
BilboPost post = DBMan::self()->getPostInfo(lstEntriesList->currentItem()->data(BlogEntryID).toInt());
QUrl url;
if (!post.permaLink().isEmpty()) {
url = post.permaLink().url();
url = post.permaLink();
} else if (!post.link().isEmpty()) {
url = post.link().url();
url = post.link();
} else {
url = QUrl(DBMan::self()->blogList().value(d->mCurrentBlogId)->blogUrl());
}
......
......@@ -266,7 +266,7 @@ ContactList GMXXXPort::importContacts() const
addressee->insertEmail(itemList[10], preferred);
if (!itemList[11].isEmpty()) {
KContacts::ResourceLocatorUrl url;
url.setUrl(itemList[11]);
url.setUrl(QUrl(itemList[11]));
addressee->setUrl(url);
}
if (!itemList[12].isEmpty()) {
......
......@@ -200,7 +200,7 @@ bool AlarmCalendar::open()
// Check for file's existence, assuming that it does exist when uncertain,
// to avoid overwriting it.
auto statJob = KIO::stat(mUrl.url(), KIO::StatJob::SourceSide, 2);
auto statJob = KIO::stat(mUrl, KIO::StatJob::SourceSide, 2);
KJobWidgets::setWindow(statJob, MainWindow::mainMainWindow());
if (!statJob->exec() || load() == 0)
{
......@@ -247,7 +247,7 @@ int AlarmCalendar::load()
QString filename;
qCDebug(KALARM_LOG) << mUrl.toDisplayString();
if (!mUrl.isLocalFile()) {
auto getJob = KIO::storedGet(mUrl.url());
auto getJob = KIO::storedGet(mUrl);
KJobWidgets::setWindow(getJob, MainWindow::mainMainWindow());
if (!getJob->exec())
{
......@@ -348,7 +348,7 @@ bool AlarmCalendar::saveCal(const QString& newFile)
{
QFile file(saveFilename);
file.open(QIODevice::ReadOnly);
auto putJob = KIO::storedPut(&file, mICalUrl.url(), -1);
auto putJob = KIO::storedPut(&file, mICalUrl, -1);
KJobWidgets::setWindow(putJob, MainWindow::mainMainWindow());
if (!putJob->exec())
{
......@@ -622,7 +622,7 @@ bool AlarmCalendar::importAlarms(QWidget* parent, Collection* collection)
}
else
{
auto getJob = KIO::storedGet(url.url());
auto getJob = KIO::storedGet(url);
KJobWidgets::setWindow(getJob, MainWindow::mainMainWindow());
if (!getJob->exec())
{
......@@ -744,7 +744,7 @@ bool AlarmCalendar::exportAlarms(const KAEvent::List& events, QWidget* parent)
if (append && !calStorage->load())
{
KIO::UDSEntry uds;
auto statJob = KIO::stat(url.url(), KIO::StatJob::SourceSide, 2);
auto statJob = KIO::stat(url, KIO::StatJob::SourceSide, 2);
KJobWidgets::setWindow(statJob, parent);
statJob->exec();
KFileItem fi(statJob->statResult(), url);
......@@ -799,7 +799,7 @@ bool AlarmCalendar::exportAlarms(const KAEvent::List& events, QWidget* parent)
{
QFile qFile(file);
qFile.open(QIODevice::ReadOnly);
auto uploadJob = KIO::storedPut(&qFile, url.url(), -1);
auto uploadJob = KIO::storedPut(&qFile, url, -1);
KJobWidgets::setWindow(uploadJob, parent);
if (!uploadJob->exec())
{
......
......@@ -1625,20 +1625,18 @@ FileType fileType(const QMimeType& mimetype)
*/
FileErr checkFileExists(QString& filename, QUrl& url)
{
url = QUrl();
FileErr err = FileErr_None;
QString file = filename;
QRegExp f(QStringLiteral("^file:/+"));
if (f.indexIn(file) >= 0)
file = file.mid(f.matchedLength() - 1);
// Convert any relative file path to absolute
// (using home directory as the default)
int i = file.indexOf(QLatin1Char('/'));
if (i > 0 && file[i - 1] == QLatin1Char(':'))
// This also supports absolute paths and absolute urls
url = QUrl::fromUserInput(filename, QDir::homePath());
FileErr err = FileErr_None;
if (filename.isEmpty())
{
err = FileErr_Blank; // blank file name
}
else if (!url.isLocalFile())
{
url = file;
const QString displayStr = url.toDisplayString();
filename = displayStr.mid(displayStr.lastIndexOf(QLatin1Char('/')) + 1);
filename = url.toDisplayString();
auto statJob = KIO::stat(url, KIO::StatJob::SourceSide, 2);
KJobWidgets::setWindow(statJob, MainWindow::mainMainWindow());
if (!statJob->exec())
......@@ -1650,15 +1648,11 @@ FileErr checkFileExists(QString& filename, QUrl& url)
else if (!fi.isReadable()) err = FileErr_Unreadable;
}
}
else if (file.isEmpty())
err = FileErr_Blank; // blank file name
else
{
// It's a local file - convert to absolute path & check validity
QFileInfo info(file);
QDir::setCurrent(QDir::homePath());
filename = info.absoluteFilePath();
url.setPath(filename);
// It's a local file
filename = url.toLocalFile();
QFileInfo info(filename);
if (info.isDir()) err = FileErr_Directory;
else if (!info.exists()) err = FileErr_Nonexistent;
else if (!info.isReadable()) err = FileErr_Unreadable;
......@@ -1740,7 +1734,7 @@ QString browseFile(const QString& caption, QString& defaultDir, const QString& i
// Use AutoQPointer to guard against crash on application exit while
// the dialogue is still open. It prevents double deletion (both on
// deletion of parent, and on return from this function).
AutoQPointer<KFileDialog> fileDlg = new KFileDialog(initialDir, filter, parent);
AutoQPointer<KFileDialog> fileDlg = new KFileDialog(QUrl::fromLocalFile(initialDir), filter, parent);
fileDlg->setOperationMode(mode & KFile::ExistingOnly ? KFileDialog::Opening : KFileDialog::Saving);
fileDlg->setMode(KFile::File | mode);
fileDlg->setWindowTitle(caption);
......
......@@ -420,7 +420,7 @@ QString KAMail::appendBodyAttachments(KMime::Message& message, JobData& data)
}
// Read the file contents
auto downloadJob = KIO::storedGet(url.url());
auto downloadJob = KIO::storedGet(url);
KJobWidgets::setWindow(downloadJob, MainWindow::mainMainWindow());
if (!downloadJob->exec())
{
......
......@@ -498,7 +498,6 @@ bool SoundWidget::validate(bool showErrorMessage) const
return true;
if (err == KAlarm::FileErr_Nonexistent)
{
mUrl = QUrl::fromUserInput(file, QString(), QUrl::AssumeLocalFile);
if (mUrl.isLocalFile() && !file.startsWith(QStringLiteral("/")))
{
// It's a relative path.
......@@ -513,8 +512,7 @@ bool SoundWidget::validate(bool showErrorMessage) const
dir = soundDirs[i];
if (dir.isReadable() && dir.count() > 2)
{
mUrl.setPath(soundDirs[i] + QDir::separator() + file);
QString f = mUrl.toLocalFile();
QString f = soundDirs[i] + QDir::separator() + file;
err = KAlarm::checkFileExists(f, mUrl);
if (err == KAlarm::FileErr_None)
return true;
......@@ -528,8 +526,7 @@ bool SoundWidget::validate(bool showErrorMessage) const
}
if (err == KAlarm::FileErr_Nonexistent)
{
mUrl.setPath(QDir::homePath() + QDir::separator() + file);
QString f = mUrl.toLocalFile();
QString f = QDir::homePath() + QDir::separator() + file;
err = KAlarm::checkFileExists(f, mUrl);
if (err == KAlarm::FileErr_None)
return true;
......
......@@ -127,7 +127,7 @@ void KMCommandsTest::testMailtoReply()
const KIdentityManagement::Identity &ident = mKernel->identityManager()->defaultIdentity();
Akonadi::Item item(createItem(ident));
KMMailtoReplyCommand *cmd(new KMMailtoReplyCommand(Q_NULLPTR, QStringLiteral("mailto:test@example.com"), item, QString()));
KMMailtoReplyCommand *cmd(new KMMailtoReplyCommand(Q_NULLPTR, QUrl(QStringLiteral("mailto:test@example.com")), item, QString()));
cmd->start();
verifySignature(true);
waitForMainWindowToClose();
......@@ -137,7 +137,7 @@ void KMCommandsTest::testMailtoReply()
const KIdentityManagement::Identity &ident = mKernel->identityManager()->identityForAddress(QStringLiteral("secundus@example.com"));
Akonadi::Item item(createItem(ident));
KMMailtoReplyCommand *cmd(new KMMailtoReplyCommand(Q_NULLPTR, QStringLiteral("mailto:test@example.com"), item, QString()));
KMMailtoReplyCommand *cmd(new KMMailtoReplyCommand(Q_NULLPTR, QUrl(QStringLiteral("mailto:test@example.com")), item, QString()));
cmd->start();
verifySignature(false);
waitForMainWindowToClose();
......@@ -147,7 +147,7 @@ void KMCommandsTest::testMailtoReply()
const KIdentityManagement::Identity &ident = mKernel->identityManager()->identityForAddress(QStringLiteral("drei@example.com"));
Akonadi::Item item(createItem(ident));
KMMailtoReplyCommand *cmd(new KMMailtoReplyCommand(Q_NULLPTR, QStringLiteral("mailto:test@example.com"), item, QString()));
KMMailtoReplyCommand *cmd(new KMMailtoReplyCommand(Q_NULLPTR, QUrl(QStringLiteral("mailto:test@example.com")), item, QString()));
cmd->start();
verifySignature(true);
waitForMainWindowToClose();
......
......@@ -171,7 +171,7 @@ void ArchiveFolderDialog::setFolder(const Akonadi::Collection &defaultCollection
{
mFolderRequester->setCollection(defaultCollection);
// TODO: what if the file already exists?
mUrlRequester->setUrl(standardArchivePath(defaultCollection.name()));
mUrlRequester->setUrl(QUrl::fromLocalFile(standardArchivePath(defaultCollection.name())));
const QSharedPointer<FolderCollection> folder = FolderCollection::forCollection(defaultCollection, false);
mDeleteCheckBox->setEnabled(allowToDeleteFolders(defaultCollection));
mOkButton->setEnabled(defaultCollection.isValid() && folder && !folder->isStructural());
......@@ -218,7 +218,7 @@ void ArchiveFolderDialog::slotFixFileExtension()
// Now, we've got a filename without an extension, simply append the correct one
fileName += QLatin1String(extensions[mFormatComboBox->currentIndex()]);
mUrlRequester->setUrl(fileName);
mUrlRequester->setUrl(QUrl::fromLocalFile(fileName));
}
void ArchiveFolderDialog::slotUrlChanged(const QString &url)
......
......@@ -223,7 +223,7 @@ void XFaceConfigurator::slotSelectFile()
Q_FOREACH (const QByteArray &mime, mimeTypes) {
filter += QString::fromLatin1(mime);
}
const QUrl url = QFileDialog::getOpenFileUrl(this, QString(), QString(), i18n("Image (%1)", filter));
const QUrl url = QFileDialog::getOpenFileUrl(this, QString(), QUrl(), i18n("Image (%1)", filter));
if (!url.isEmpty()) {
setXfaceFromFile(url);
}
......@@ -263,7 +263,7 @@ void XFaceConfigurator::slotDelayedSelectFromAddressbook(KJob *job)
}
} else {
const QUrl url = contact.photo().url();
const QUrl url(contact.photo().url());
if (!url.isEmpty()) {
setXfaceFromFile(url);
} else {
......
......@@ -533,9 +533,9 @@ KMCommand::Result KMUrlSaveCommand::execute()
return OK;
}
QString recentDirClass;
const QUrl saveUrl = QFileDialog::getSaveFileUrl(parentWidget()
, KFileWidget::getStartUrl(QUrl(QStringLiteral("kfiledialog:///OpenMessage")), recentDirClass).toLocalFile()
, mUrl.fileName());
QUrl startUrl = KFileWidget::getStartUrl(QUrl(QStringLiteral("kfiledialog:///OpenMessage")), recentDirClass);
startUrl.setPath(startUrl.path() + QLatin1Char('/') + mUrl.fileName());
const QUrl saveUrl = QFileDialog::getSaveFileUrl(parentWidget(), i18n("Save To File"), startUrl);
if (saveUrl.isEmpty()) {
return Canceled;
}
......
......@@ -182,7 +182,7 @@ Akonadi::Tag::List TagSelectDialog::selectedTag() const
for (int i = 0; i < numberOfItems; ++i) {
QListWidgetItem *item = mListTag->item(i);
if (item->checkState() == Qt::Checked) {
lst.append(Akonadi::Tag::fromUrl(item->data(UrlTag).toString()));
lst.append(Akonadi::Tag::fromUrl(QUrl(item->data(UrlTag).toString())));
}
}
return lst;
......
......@@ -1012,7 +1012,7 @@ void AlarmDialog::removeFromConfig(const QList<Akonadi::Item::Id> &ids)
KConfigGroup incGroup(config, group);
const QString uid = incGroup.readEntry("UID");
const QDateTime remindAtDate = incGroup.readEntry("RemindAt", QDateTime());
const QUrl akonadiUrl = incGroup.readEntry("AkonadiUrl");
const QUrl akonadiUrl(incGroup.readEntry("AkonadiUrl"));
const Akonadi::Item::Id id = Akonadi::Item::fromUrl(akonadiUrl).id();
if (!ids.contains(id)) {
ConfItem ci;
......
......@@ -114,7 +114,7 @@ void KOAlarmClient::deferredInit()
const QString group(QStringLiteral("Incidence-%1").arg(i));
const KConfigGroup incGroup(KSharedConfig::openConfig(), group);
const QUrl url = incGroup.readEntry("AkonadiUrl");
const QUrl url(incGroup.readEntry("AkonadiUrl"));
Akonadi::Item::Id akonadiItemId = -1;
if (!url.isValid()) {
// logic to migrate old KOrganizer incidence uid's to a Akonadi item.
......
......@@ -1168,7 +1168,7 @@ bool ActionManager::saveModifiedURL()
QUrl ActionManager::getSaveURL()
{
QUrl url =
QFileDialog::getSaveFileUrl(dialogParent(), QString(), QString(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/korganizer/")),
QFileDialog::getSaveFileUrl(dialogParent(), QString(), QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/korganizer/")),
i18n("*.ics *.vcs|Calendar Files")
);
......
......@@ -193,8 +193,7 @@ void KCMDesignerFields::deleteFile()
this,
i18n("<qt>Do you really want to delete '<b>%1</b>'?</qt>",
pageItem->text(0)), QString(), KStandardGuiItem::del()) == KMessageBox::Continue) {
auto job = KIO::del(pageItem->path());
job->exec();
QFile::remove(pageItem->path());
}
}
// The actual view refresh will be done automagically by the slots connected to kdirwatch
......@@ -442,9 +441,7 @@ void KCMDesignerFields::startDesigner()
// check if path exists and create one if not.
QString cepPath = localUiDir();
if (!QDir(cepPath).exists()) {
auto job = KIO::mkdir(cepPath);
KJobWidgets::setWindow(job, this);
job->exec();
QDir().mkdir(cepPath);
}
// finally jump there
......
......@@ -320,7 +320,7 @@ void KOEventPopupMenu::createNote()
note.setText(incidence->description(), incidence->descriptionIsRich() ? Qt::RichText : Qt::PlainText);
note.setFrom(QCoreApplication::applicationName() + QCoreApplication::applicationVersion());
note.setLastModifiedDate(QDateTime::currentDateTimeUtc());
Akonadi::NoteUtils::Attachment attachment(mCurrentIncidence.url().url(), mCurrentIncidence.mimeType());
Akonadi::NoteUtils::Attachment attachment(mCurrentIncidence.url(), mCurrentIncidence.mimeType());
note.attachments().append(attachment);
Akonadi::Item newNoteItem;
newNoteItem.setMimeType(Akonadi::NoteUtils::noteMimeType());
......
......@@ -623,7 +623,7 @@ void SDSummaryWidget::updateView()
void SDSummaryWidget::mailContact(const QString &url)
{
const Akonadi::Item item = Akonadi::Item::fromUrl(url);
const Akonadi::Item item = Akonadi::Item::fromUrl(QUrl(url));
if (!item.isValid()) {
qCDebug(KORGANIZER_KONTACTPLUGINS_SPECIALDATES_LOG) << QStringLiteral("Invalid item found");
return;
......@@ -651,7 +651,7 @@ void SDSummaryWidget::slotItemFetchJobDone(KJob *job)
void SDSummaryWidget::viewContact(const QString &url)
{
const Akonadi::Item item = Akonadi::Item::fromUrl(url);
const Akonadi::Item item = Akonadi::Item::fromUrl(QUrl(url));
if (!item.isValid()) {
qCDebug(KORGANIZER_KONTACTPLUGINS_SPECIALDATES_LOG) << "Invalid item found";
return;
......
......@@ -154,7 +154,7 @@ QUrl KOrganizerPart::getCurrentURL() const
bool KOrganizerPart::openFile()
{
mActionManager->importCalendar(localFilePath());
mActionManager->importCalendar(QUrl::fromLocalFile(localFilePath()));
return true;
}
......
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