Commit 9b0b5ec1 authored by Dawit Alemayehu's avatar Dawit Alemayehu
Browse files

Fix unintended runtime dependency introduced when fixing #134960.

REVIEW: 111776
CCBUG: 134960
CCBUG: 318757
parent 1a4ba954
......@@ -28,12 +28,10 @@
using namespace KIO;
ClipboardUpdater::ClipboardUpdater(Job* job, Mode mode)
:QObject(job),
m_mode(mode)
static bool canUseClipboard()
{
Q_ASSERT(job);
connect(job, SIGNAL(result(KJob*)), this, SLOT(slotResult(KJob*)));
return QApplication::type() != QApplication::Tty;
}
static void overwriteUrlsInClipboard(KJob* job)
......@@ -156,8 +154,26 @@ void ClipboardUpdater::slotResult(KJob* job)
}
}
void ClipboardUpdater::setMode(ClipboardUpdater::Mode mode)
{
m_mode = mode;
}
ClipboardUpdater* ClipboardUpdater::create(Job* job, ClipboardUpdater::Mode mode)
{
if (canUseClipboard()) {
return new ClipboardUpdater(job, mode);
}
return 0;
}
void ClipboardUpdater::update(const KUrl& srcUrl, const KUrl& destUrl)
{
if (!canUseClipboard()) {
return;
}
QClipboard* clipboard = QApplication::clipboard();
if (clipboard->mimeData()->hasUrls()) {
KUrl::List clipboardUrls = KUrl::List::fromMimeData(clipboard->mimeData());
......@@ -171,7 +187,10 @@ void ClipboardUpdater::update(const KUrl& srcUrl, const KUrl& destUrl)
}
}
void ClipboardUpdater::setMode(ClipboardUpdater::Mode mode)
ClipboardUpdater::ClipboardUpdater(Job* job, Mode mode)
:QObject(job),
m_mode(mode)
{
m_mode = mode;
Q_ASSERT(job);
connect(job, SIGNAL(result(KJob*)), this, SLOT(slotResult(KJob*)));
}
......@@ -57,10 +57,15 @@ namespace KIO {
RemoveContent
};
explicit ClipboardUpdater(Job* job, Mode mode);
/**
* Returns an instance of clipboard updater if QApplication::type() does
* not return a tty. Otherwise, it returns null.
*/
static ClipboardUpdater* create(Job* job, Mode mode);
/**
* Convenience function that allows renaming of a single url in the clipboard.
* Note that this function does nothing if QApplication::type() returns tty.
*/
static void update(const KUrl& srcUrl, const KUrl& destUrl);
......@@ -73,6 +78,7 @@ namespace KIO {
void slotResult(KJob* job);
private:
explicit ClipboardUpdater(Job* job, Mode mode);
Mode m_mode;
};
}
......
......@@ -2187,7 +2187,7 @@ CopyJob *KIO::move(const KUrl& src, const KUrl& dest, JobFlags flags)
KUrl::List srcList;
srcList.append( src );
CopyJob* job = CopyJobPrivate::newJob(srcList, dest, CopyJob::Move, false, flags);
new ClipboardUpdater(job, ClipboardUpdater::UpdateContent);
ClipboardUpdater::create(job, ClipboardUpdater::UpdateContent);
return job;
}
......@@ -2197,7 +2197,7 @@ CopyJob *KIO::moveAs(const KUrl& src, const KUrl& dest, JobFlags flags)
KUrl::List srcList;
srcList.append( src );
CopyJob* job = CopyJobPrivate::newJob(srcList, dest, CopyJob::Move, true, flags);
new ClipboardUpdater(job, ClipboardUpdater::UpdateContent);
ClipboardUpdater::create(job, ClipboardUpdater::UpdateContent);
return job;
}
......@@ -2205,7 +2205,7 @@ CopyJob *KIO::move( const KUrl::List& src, const KUrl& dest, JobFlags flags)
{
//kDebug(7007) << src << dest;
CopyJob* job = CopyJobPrivate::newJob(src, dest, CopyJob::Move, false, flags);
new ClipboardUpdater(job, ClipboardUpdater::UpdateContent);
ClipboardUpdater::create(job, ClipboardUpdater::UpdateContent);
return job;
}
......
......@@ -487,14 +487,14 @@ DeleteJob *KIO::del( const KUrl& src, JobFlags flags )
KUrl::List srcList;
srcList.append( src );
DeleteJob* job = DeleteJobPrivate::newJob(srcList, flags);
new ClipboardUpdater(job, ClipboardUpdater::RemoveContent);
ClipboardUpdater::create(job, ClipboardUpdater::RemoveContent);
return job;
}
DeleteJob *KIO::del( const KUrl::List& src, JobFlags flags )
{
DeleteJob* job = DeleteJobPrivate::newJob(src, flags);
new ClipboardUpdater(job, ClipboardUpdater::RemoveContent);
ClipboardUpdater::create(job, ClipboardUpdater::RemoveContent);
return job;
}
......
......@@ -538,7 +538,7 @@ void FileUndoManagerPrivate::stepMovingFiles()
{
kDebug(1203) << "file_move" << op.m_dst << op.m_src;
m_currentJob = KIO::file_move(op.m_dst, op.m_src, -1, KIO::Overwrite | KIO::HideProgressInfo);
new KIO::ClipboardUpdater(m_currentJob, KIO::ClipboardUpdater::UpdateContent);
KIO::ClipboardUpdater::create(m_currentJob, KIO::ClipboardUpdater::UpdateContent);
m_undoJob->emitMoving(op.m_dst, op.m_src);
}
......
......@@ -2483,7 +2483,7 @@ FileCopyJob *KIO::file_move( const KUrl& src, const KUrl& dest, int permissions,
JobFlags flags )
{
FileCopyJob* job = FileCopyJobPrivate::newJob(src, dest, permissions, true, flags);
new ClipboardUpdater(job, ClipboardUpdater::UpdateContent);
ClipboardUpdater::create(job, ClipboardUpdater::UpdateContent);
return job;
}
......@@ -2491,7 +2491,7 @@ SimpleJob *KIO::file_delete( const KUrl& src, JobFlags flags )
{
KIO_ARGS << src << qint8(true); // isFile
SimpleJob* job = SimpleJobPrivate::newJob(src, CMD_DEL, packedArgs, flags);
new ClipboardUpdater(job, ClipboardUpdater::RemoveContent);
ClipboardUpdater::create(job, ClipboardUpdater::RemoveContent);
return job;
}
......
......@@ -69,8 +69,9 @@ static KIO::Job *pasteClipboardUrls(const QMimeData* mimeData, const KUrl& destD
if (move) {
job = KIO::move(urls, destDir, flags);
KIO::ClipboardUpdater* clipboardUpdater = job->findChild<KIO::ClipboardUpdater *>();
Q_ASSERT(clipboardUpdater);
clipboardUpdater->setMode(KIO::ClipboardUpdater::OverwriteContent);
if (clipboardUpdater) {
clipboardUpdater->setMode(KIO::ClipboardUpdater::OverwriteContent);
}
}
else
job = KIO::copy(urls, destDir, flags);
......
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