28 #include <ktoolinvocation.h>
29 #include <kautomount.h>
30 #include <kmountpoint.h>
31 #include <kinputdialog.h>
33 #include <kmessagebox.h>
34 #include <knotification.h>
38 #include <kshortcut.h>
39 #include <kprotocolmanager.h>
40 #include <kio/deletejob.h>
41 #include <kio/fileundomanager.h>
43 #include <kio/jobuidelegate.h>
44 #include <kio/jobclasses.h>
45 #include <kio/copyjob.h>
46 #include <kio/paste.h>
47 #include <kio/renamedialog.h>
48 #include <kdirnotify.h>
49 #include <kuiserverjobtracker.h>
50 #include <kstandarddirs.h>
53 #include <kauthorized.h>
55 #include <kglobalsettings.h>
57 #include <kfileitem.h>
58 #include <kdesktopfile.h>
61 #include <kfileitemlistproperties.h>
63 #include <kmimetypetrader.h>
67 #include <QApplication>
75 #include <kconfiggroup.h>
77 static const KCatalogLoader
loader(
"libkonq");
81 m_method( UNKNOWN ), m_info(0), m_pasteInfo(0)
83 setObjectName( QLatin1String(
"KonqOperations" ) );
94 QString keditfiletype = QLatin1String(
"keditfiletype");
95 KRun::runCommand( keditfiletype
96 +
" --parent " + QString::number( (qptrdiff)parent->winId())
97 +
' ' + KShell::quoteArg(mimeType),
98 keditfiletype, keditfiletype , parent );
103 kDebug(1203) << parent->metaObject()->className();
104 if ( selectedUrls.isEmpty() )
106 kWarning(1203) <<
"Empty URL list !" ;
112 op->_del( method, selectedUrls, confirmation );
124 op->_restoreTrashedItems( urls );
129 KIO::SimpleJob * job = KIO::mkdir(url);
130 job->ui()->setWindow(parent);
131 job->ui()->setAutoErrorHandlingEnabled(
true);
132 KIO::FileUndoManager::self()->recordJob( KIO::FileUndoManager::Mkdir, KUrl(), url, job );
143 QClipboard *clipboard = QApplication::clipboard();
144 const QMimeData *data = clipboard->mimeData();
147 KIO::Job *job = KIO::pasteClipboard(destUrl, parent, move);
150 KIOPasteInfo *pi =
new KIOPasteInfo;
152 op->setPasteInfo(pi);
153 KIO::CopyJob *copyJob = qobject_cast<KIO::CopyJob*>(job);
155 op->setOperation(job, move ?
MOVE :
COPY, copyJob->destUrl());
157 connect(copyJob, SIGNAL(copyingDone(KIO::Job*,KUrl,KUrl,time_t,
bool,
bool)),
159 connect(copyJob, SIGNAL(copyingLinkDone(KIO::Job*,KUrl,QString,KUrl)),
161 }
else if (KIO::SimpleJob *simpleJob = qobject_cast<KIO::SimpleJob*>(job)) {
162 op->setOperation(job,
PUT, simpleJob->url());
163 KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Put, KUrl::List(), simpleJob->url(), job);
173 kDebug(1203) << parent->metaObject()->className() << selectedUrls << destUrl;
176 kWarning(1203) <<
"Illegal copy method !" ;
179 if ( selectedUrls.isEmpty() )
181 kWarning(1203) <<
"Empty URL list !" ;
188 job = KIO::link( selectedUrls, destUrl );
189 else if (method ==
MOVE)
190 job = KIO::move( selectedUrls, destUrl );
192 job = KIO::copy( selectedUrls, destUrl );
194 connect(job, SIGNAL(copyingDone(KIO::Job*,KUrl,KUrl,time_t,
bool,
bool)),
196 connect(job, SIGNAL(copyingLinkDone(KIO::Job*,KUrl,QString,KUrl)),
199 op->setOperation( job, method, destUrl );
201 KIO::FileUndoManager::self()->recordCopyJob(job);
204 void KonqOperations::_del( Operation method,
const KUrl::List & _selectedUrls, ConfirmationType confirmation )
206 KUrl::List selectedUrls;
207 for (KUrl::List::ConstIterator it = _selectedUrls.begin(); it != _selectedUrls.end(); ++it)
208 if (KProtocolManager::supportsDeleting(*it))
209 selectedUrls.append(*it);
210 if (selectedUrls.isEmpty()) {
224 job = KIO::trash( selectedUrls );
225 KIO::FileUndoManager::self()->recordJob( KIO::FileUndoManager::Trash, selectedUrls, KUrl(
"trash:/"), job );
231 QByteArray packedArgs;
232 QDataStream stream( &packedArgs, QIODevice::WriteOnly );
234 job = KIO::special( KUrl(
"trash:/"), packedArgs );
235 KNotification::event(
"Trash: emptied", QString() , QPixmap() , 0l, KNotification::DefaultEvent );
239 job = KIO::del( selectedUrls );
242 kWarning() <<
"Unknown operation: " << method ;
246 job->ui()->setWindow(parentWidget());
247 connect( job, SIGNAL(result(KJob*)),
254 void KonqOperations::_restoreTrashedItems(
const KUrl::List& urls )
258 job->ui()->setWindow(parentWidget());
259 KIO::getJobTracker()->registerJob(job);
260 connect( job, SIGNAL(result(KJob*)),
266 KIO::JobUiDelegate::DeletionType deletionType;
269 deletionType = KIO::JobUiDelegate::EmptyTrash;
272 deletionType = KIO::JobUiDelegate::Delete;
275 deletionType = KIO::JobUiDelegate::Trash;
279 KIO::JobUiDelegate::ConfirmationType confirmationType = confirmation ==
FORCE_CONFIRMATION ? KIO::JobUiDelegate::ForceConfirmation : KIO::JobUiDelegate::DefaultConfirmation;
280 KIO::JobUiDelegate uiDelegate;
281 uiDelegate.setWindow(widget);
282 return uiDelegate.askDeleteConfirmation(selectedUrls, deletionType, confirmationType);
293 kDebug(1203) <<
"dest:" << dest;
294 QMap<QString, QString> metaData;
296 const KUrl::List lst = KUrl::List::fromMimeData(ev->mimeData(), KUrl::List::PreferLocalUrls, &metaData);
297 if (!lst.isEmpty()) {
304 KUrl::List::ConstIterator it = lst.begin();
305 for (; it != lst.end() ; it++) {
306 kDebug(1203) <<
"URL:" << (*it);
307 if (dest.equals(*it, KUrl::CompareWithoutTrailingSlash)) {
310 if ( !ev->source() || ( ev->source() != parent && ev->source()->parent() != parent ) )
311 KMessageBox::sorry( parent, i18n(
"You cannot drop a folder on to itself") );
312 kDebug(1203) <<
"Dropped on itself";
313 ev->setAccepted(
false );
319 Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();
321 Qt::DropAction action = ev->dropAction();
323 if ( ev->provides(
"application/x-xbel") )
325 modifiers |= Qt::ControlModifier | Qt::ShiftModifier;
326 action = Qt::LinkAction;
327 kDebug(1203) <<
"Bookmark -> emulating Link";
331 op->setDropInfo(
new DropInfo( modifiers, lst, metaData, QCursor::pos(), action, userActions ) );
334 if ( !destItem.isNull() )
339 qRegisterMetaType<KFileItem>(
"KFileItem");
340 QMetaObject::invokeMethod(op,
"asyncDrop", Qt::QueuedConnection, Q_ARG(KFileItem, destItem));
345 op->_statUrl( dest, op, SLOT(
asyncDrop(KFileItem)) );
349 ev->acceptProposedAction();
356 KIO::Job* job = KIO::pasteMimeData(ev->mimeData(), dest,
357 i18n(
"File name for dropped contents:" ),
359 if (KIO::SimpleJob* simpleJob = qobject_cast<KIO::SimpleJob *>(job)) {
360 op->setOperation(job,
PUT, simpleJob->url());
361 KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Put, KUrl::List(), simpleJob->url(), simpleJob);
363 ev->acceptProposedAction();
371 bool m_destIsLocal =
false;
372 m_destUrl = destItem.mostLocalUrl(m_destIsLocal);
376 if ( destItem.isDir() )
381 if ( !m_destIsLocal )
386 kWarning(1203) <<
"Cannot drop onto " << m_destUrl ;
390 if ( destItem.isDesktopFile() )
393 KDesktopFile desktopFile( m_destUrl.path() );
394 KConfigGroup desktopGroup = desktopFile.desktopGroup();
395 if ( desktopFile.hasApplicationType() )
398 const QStringList urlStrList = m_info->urls.toStringList();
399 if ( KToolInvocation::startServiceByDesktopPath( m_destUrl.path(), urlStrList, &error ) > 0 )
400 KMessageBox::error( parentWidget(), error );
405 if ( desktopFile.hasDeviceType() && desktopGroup.hasKey(
"MountPoint") ) {
406 QString point = desktopGroup.readEntry(
"MountPoint" );
407 m_destUrl.setPath( point );
408 QString dev = desktopFile.readDevice();
409 KMountPoint::Ptr mp = KMountPoint::currentMountPoints().findByDevice( dev );
417 const bool ro = desktopGroup.readEntry(
"ReadOnly",
false );
418 const QByteArray fstype = desktopGroup.readEntry(
"FSType" ).toLatin1();
419 KAutoMount* am =
new KAutoMount( ro, fstype, dev, point, m_destUrl.path(), false );
425 else if ( desktopFile.hasLinkType() && desktopGroup.hasKey(
"URL") ) {
426 m_destUrl = desktopGroup.readPathEntry(
"URL", QString());
437 kDebug(1203) << m_destUrl.path() <<
"should be an executable";
438 Q_ASSERT ( access( QFile::encodeName(m_destUrl.path()), X_OK ) == 0 );
441 const KUrl::List lst = m_info->urls;
442 KUrl::List::ConstIterator it = lst.begin();
443 for ( ; it != lst.end() ; it++ )
444 args << (*it).path();
445 kDebug(1203) <<
"starting " << m_destUrl.path() <<
" with " << lst.count() <<
" arguments";
446 KProcess::startDetached( m_destUrl.path(), args );
458 return m_info->mousePos;
464 const KUrl::List lst = m_info->urls;
465 Qt::DropAction action = m_info->action;
466 bool isDesktopFile =
false;
467 bool itemIsOnDesktop =
false;
468 bool allItemsAreFromTrash =
true;
470 for (KUrl::List::ConstIterator it = lst.begin(); it != lst.end(); ++it)
472 bool local = (*it).isLocalFile();
473 if ( KProtocolManager::supportsDeleting( *it ) && (!local || QFileInfo((*it).directory()).isWritable() ))
475 if ( local && KDesktopFile::isDesktopFile((*it).toLocalFile()))
476 isDesktopFile =
true;
477 if ( local && (*it).path().startsWith(KGlobalSettings::desktopPath()))
478 itemIsOnDesktop =
true;
479 if ( local || (*it).protocol() !=
"trash" )
480 allItemsAreFromTrash =
false;
483 bool linkOnly =
false;
484 if (isDesktopFile && !KAuthorized::authorizeKAction(
"run_desktop_files") &&
485 (m_destUrl.path(KUrl::AddTrailingSlash) == KGlobalSettings::desktopPath()) ) {
487 }
else if ( allItemsAreFromTrash && lst.first().path() ==
"/" ) {
492 if ( !mlst.isEmpty() && m_destUrl.protocol() ==
"trash" )
494 if ( itemIsOnDesktop && !KAuthorized::authorizeKAction(
"editable_desktop_icons") )
502 action = Qt::MoveAction;
508 }
else if (!linkOnly && (allItemsAreFromTrash || m_destUrl.protocol() ==
"trash")) {
510 action = Qt::MoveAction;
513 ((m_info->keyboardModifiers & Qt::ControlModifier) == 0) &&
514 ((m_info->keyboardModifiers & Qt::ShiftModifier) == 0) &&
515 ((m_info->keyboardModifiers & Qt::AltModifier) == 0) ) || linkOnly )
521 KonqIconViewWidget *iconView =
dynamic_cast<KonqIconViewWidget*
>(parent());
522 bool bSetWallpaper =
false;
523 if ( iconView && iconView->maySetWallpaper() && lst.count() == 1 )
525 KUrl url = lst.first();
526 KMimeType::Ptr mime = KMimeType::findByUrl( url );
527 if ( mime && ( ( KImageIO::isSupported(mime->name(), KImageIO::Reading) ) ||
528 mime->is(
"image/svg+xml" ) ) )
530 bSetWallpaper =
true;
539 const KUrl url = lst.first();
540 bool sReading = KProtocolManager::supportsReading( url );
541 bool sDeleting = KProtocolManager::supportsDeleting( url );
542 bool sMoving = KProtocolManager::supportsMoving( url );
544 bool dWriting = KProtocolManager::supportsWriting( m_destUrl );
551 bool enableLinking =
true;
560 if (url.isLocalFile() && url.toLocalFile().startsWith(KStandardDirs::locateLocal(
"tmp", QString()))) {
563 enableLinking =
false;
567 QString seq = QKeySequence( Qt::ShiftModifier ).toString();
569 QAction* popupMoveAction =
new QAction(i18n(
"&Move Here" ) +
'\t' + seq,
this);
570 popupMoveAction->setIcon(KIcon(
"go-jump"));
571 seq = QKeySequence( Qt::ControlModifier ).toString();
573 QAction* popupCopyAction =
new QAction(i18n(
"&Copy Here" ) +
'\t' + seq,
this);
574 popupCopyAction->setIcon(KIcon(
"edit-copy"));
575 seq = QKeySequence( Qt::ControlModifier + Qt::ShiftModifier ).toString();
577 QAction* popupLinkAction =
new QAction(i18n(
"&Link Here" ) +
'\t' + seq,
this);
578 popupLinkAction->setIcon(KIcon(
"edit-link"));
579 QAction* popupWallAction =
new QAction( i18n(
"Set as &Wallpaper" ),
this );
580 popupWallAction->setIcon(KIcon(
"preferences-desktop-wallpaper"));
581 QAction* popupCancelAction =
new QAction(i18n(
"C&ancel" ) +
'\t' + QKeySequence( Qt::Key_Escape ).toString(),
this);
582 popupCancelAction->setIcon(KIcon(
"process-stop"));
584 if (!mlst.isEmpty() && (sMoving || (sReading && sDeleting)) && !linkOnly )
586 bool equalDestination =
true;
587 foreach (
const KUrl & src, lst )
589 const bool equalProtocol = ( m_destUrl.protocol() == src.protocol() );
590 if ( !equalProtocol || m_destUrl.path(KUrl::RemoveTrailingSlash) != src.directory() )
592 equalDestination =
false;
597 if ( !equalDestination )
598 popup.addAction(popupMoveAction);
601 if ( sReading && !linkOnly)
602 popup.addAction(popupCopyAction);
605 popup.addAction(popupLinkAction);
609 popup.addAction(popupWallAction);
613 KFileItemList fileItems;
614 foreach(
const KUrl& url, lst) {
615 fileItems.append(KFileItem(
623 KFileItemListProperties info(fileItems);
624 _addPluginActions(pluginActions, m_destUrl, info);
626 if (!m_info->userActions.isEmpty() || !pluginActions.isEmpty()) {
627 popup.addSeparator();
628 popup.addActions(m_info->userActions);
629 popup.addActions(pluginActions);
632 popup.addSeparator();
633 popup.addAction(popupCancelAction);
635 QAction* result = popup.exec( m_info->mousePos );
637 if(result == popupCopyAction)
638 action = Qt::CopyAction;
639 else if(result == popupMoveAction)
640 action = Qt::MoveAction;
641 else if(result == popupLinkAction)
642 action = Qt::LinkAction;
649 KIO::CopyJob * job = 0;
651 case Qt::MoveAction :
652 job = KIO::move( lst, m_destUrl );
653 job->setMetaData( m_info->metaData );
655 KIO::FileUndoManager::self()->recordJob(
657 lst, m_destUrl, job );
659 case Qt::CopyAction :
660 job = KIO::copy( lst, m_destUrl );
661 job->setMetaData( m_info->metaData );
662 setOperation( job,
COPY, m_destUrl );
663 KIO::FileUndoManager::self()->recordCopyJob(job);
665 case Qt::LinkAction :
666 kDebug(1203) <<
"lst.count=" << lst.count();
667 job = KIO::link( lst, m_destUrl );
668 job->setMetaData( m_info->metaData );
669 setOperation( job,
LINK, m_destUrl );
670 KIO::FileUndoManager::self()->recordCopyJob(job);
672 default : kError(1203) <<
"Unknown action " << (int)action << endl;
675 connect(job, SIGNAL(copyingDone(KIO::Job*,KUrl,KUrl,time_t,
bool,
bool)),
677 connect(job, SIGNAL(copyingLinkDone(KIO::Job*,KUrl,QString,KUrl)),
694 void KonqOperations::_addPluginActions(
QList<QAction*>& pluginActions,
const KUrl& destination,
const KFileItemListProperties& info)
697 const QString commonMimeType = info.mimeType();
698 kDebug() << commonMimeType;
699 const KService::List plugin_offers = KMimeTypeTrader::self()->query(commonMimeType.isEmpty() ? QLatin1String(
"application/octet-stream") : commonMimeType,
"KonqDndPopupMenu/Plugin",
"exist Library");
701 KService::List::ConstIterator iterator = plugin_offers.begin();
702 const KService::List::ConstIterator end = plugin_offers.end();
703 for(; iterator != end; ++iterator) {
708 plugin->
setup(info, destination, pluginActions);
715 #ifdef Q_WS_WIN //safer
716 if (!QDir::convertSeparators(path).startsWith(QDir::convertSeparators(homeDir)))
719 if (!path.startsWith(homeDir))
723 int len = homeDir.length();
725 if (len && (path.length() == len || path[len] ==
'/')) {
726 path.replace(0, len, QString::fromLatin1(
"$HOME"));
734 while (path[0] ==
'/' && path[1] ==
'/')
742 const QString homeDir0 = QFile::decodeName(qgetenv(
"HOME"));
743 const QString homeDir1 = QDir::homePath();
744 const QString homeDir2 = QDir(homeDir1).canonicalPath();
761 kDebug(1203) <<
"oldurl=" << oldurl <<
" newurl=" << newurl;
762 if ( oldurl == newurl )
767 KIO::Job * job = KIO::moveAs( oldurl, newurl, oldurl.isLocalFile() ? KIO::HideProgressInfo : KIO::DefaultFlags );
769 op->setOperation( job,
RENAME, newurl );
770 KIO::FileUndoManager::self()->recordJob( KIO::FileUndoManager::Rename, lst, newurl, job );
772 if ( oldurl.isLocalFile() && oldurl.toLocalFile( KUrl::AddTrailingSlash ) == KGlobalSettings::desktopPath() )
774 kDebug(1203) <<
"That rename was the Desktop path, updating config files";
776 const QString userDirsFile(KGlobal::dirs()->localxdgconfdir() + QLatin1String(
"user-dirs.dirs"));
777 KConfig xdgUserConf( userDirsFile, KConfig::SimpleConfig );
778 KConfigGroup g( &xdgUserConf,
"" );
779 g.writeEntry(
"XDG_DESKTOP_DIR", QString(
"\"" +
translatePath( newurl.path() ) +
"\"") );
780 KGlobalSettings::self()->emitChange(KGlobalSettings::SettingsChanged, KGlobalSettings::SETTINGS_PATHS);
786 void KonqOperations::setOperation( KIO::Job * job, Operation method,
const KUrl & dest )
792 job->ui()->setWindow(parentWidget());
793 connect( job, SIGNAL(result(KJob*)),
796 KIO::CopyJob *copyJob =
dynamic_cast<KIO::CopyJob*
>(job);
797 KonqIconViewWidget *iconView =
dynamic_cast<KonqIconViewWidget*
>(parent());
798 if (copyJob && iconView)
814 emit
aboutToCreate( m_info ? m_info->mousePos : m_pasteInfo ? m_pasteInfo->mousePos : QPoint(), files);
821 op->_statUrl( url, receiver, member );
824 void KonqOperations::_statUrl(
const KUrl & url,
const QObject *receiver,
const char *member )
826 connect(
this, SIGNAL(
statFinished(KFileItem)), receiver, member );
827 KIO::StatJob * job = KIO::stat( url );
828 job->ui()->setWindow(parentWidget());
829 connect( job, SIGNAL(result(KJob*)),
837 static_cast<KIO::Job*
>( job )->ui()->showErrorMessage();
841 KIO::StatJob * statJob =
static_cast<KIO::StatJob*
>(job);
842 KFileItem item( statJob->statResult(), statJob->url() );
846 if ( m_method ==
STAT )
852 bool jobFailed =
false;
853 if (job && job->error()) {
854 static_cast<KIO::Job*
>(job)->ui()->showErrorMessage();
860 KIO::SimpleJob *simpleJob = qobject_cast<KIO::SimpleJob*>(job);
861 if (simpleJob && !jobFailed) {
862 m_createdUrls << simpleJob->url();
869 org::kde::KDirNotify::emitFilesAdded(
"trash:/");
872 KIO::CopyJob *renameJob = qobject_cast<KIO::CopyJob*>(job);
873 if (renameJob && jobFailed) {
874 const KUrl oldUrl = renameJob->srcUrls().first();
875 const KUrl newUrl = renameJob->destUrl();
884 if (!m_createdUrls.isEmpty()) {
887 m_createdUrls.clear();
900 KUrl newurl( oldurl );
901 newurl.setPath( oldurl.directory( KUrl::AppendTrailingSlash ) + name );
902 kDebug(1203) <<
"KonqOperations::rename("<<name<<
") called. newurl=" << newurl;
903 return renameV2( parent, oldurl, newurl );
909 KGuiItem continueGuiItem(KStandardGuiItem::cont());
910 continueGuiItem.setText(i18nc(
"@action:button",
"Create directory"));
911 KGuiItem cancelGuiItem(KStandardGuiItem::cancel());
912 cancelGuiItem.setText(i18nc(
"@action:button",
"Enter a different name"));
913 return KMessageBox::warningContinueCancel(
915 i18n(
"The name \"%1\" starts with a dot, so the directory will be hidden by default.", name),
916 i18nc(
"@title:window",
"Create hidden directory?"),
919 "confirm_create_hidden_dir") == KMessageBox::Continue;
924 return newDir(parent, baseUrl, NewDirFlags());
931 QString name = i18nc(
"@label Default name when creating a folder",
"New Folder" );
932 if ( baseUrl.isLocalFile() && QFileInfo( baseUrl.toLocalFile( KUrl::AddTrailingSlash ) + name ).exists() )
933 name = KIO::RenameDialog::suggestName(baseUrl, name);
938 name = KInputDialog::getText ( i18nc(
"@title:window",
"New Folder" ),
939 i18nc(
"@label:textbox",
"Enter folder name:" ), name, &ok, parent );
940 if ( ok && !name.isEmpty() ) {
942 if ((name[0] ==
'/') || (name[0] ==
'~')) {
943 url.setPath(KShell::tildeExpand(name));
946 if (!viewShowsHiddenFiles && name.startsWith(
'.')) {
952 name = KIO::encodeFileName( name );
966 m_urls( urls ), m_urlsIterator( m_urls.begin() ),
969 QTimer::singleShot(0,
this, SLOT(
slotStart()));
970 setUiDelegate(
new KIO::JobUiDelegate);
975 if ( m_urlsIterator == m_urls.begin() )
976 setTotalAmount( KJob::Files, m_urls.count() );
978 if ( m_urlsIterator != m_urls.end() )
980 const KUrl& url = *m_urlsIterator;
983 if ( new_url.protocol()==
"system"
984 && new_url.path().startsWith(
"/trash") )
986 QString path = new_url.path();
988 new_url.setProtocol(
"trash");
989 new_url.setPath(path);
992 Q_ASSERT( new_url.protocol() ==
"trash" );
993 QByteArray packedArgs;
994 QDataStream stream( &packedArgs, QIODevice::WriteOnly );
995 stream << (int)3 << new_url;
996 KIO::Job* job = KIO::special( new_url, packedArgs, KIO::HideProgressInfo );
998 setProcessedAmount(KJob::Files, processedAmount(KJob::Files) + 1);
1002 org::kde::KDirNotify::emitFilesRemoved(m_urls.toStringList() );
1011 KIO::Job::slotResult( job );
1019 emitPercent( m_progress, m_urls.count() );
1023 QWidget* KonqOperations::parentWidget()
const
1025 return static_cast<QWidget *
>( parent() );
1030 QPair<bool, QString> ret;
1031 QClipboard* clipboard = QApplication::clipboard();
1032 const QMimeData* mimeData = clipboard->mimeData();
1034 const bool canPasteData = KIO::canPasteMimeSource(mimeData);
1035 KUrl::List urls = KUrl::List::fromMimeData(mimeData);
1036 if (!urls.isEmpty() || canPasteData) {
1038 KFileItem item(KFileItem::Unknown, KFileItem::Unknown, targetUrl);
1039 ret.first = KFileItemListProperties(KFileItemList() << item).supportsWriting();
1041 if (urls.count() == 1) {
1042 const KFileItem item(KFileItem::Unknown, KFileItem::Unknown, urls.first(),
true);
1043 ret.second = item.isDir() ? i18nc(
"@action:inmenu",
"Paste One Folder") :
1044 i18nc(
"@action:inmenu",
"Paste One File");
1046 }
else if (!urls.isEmpty()) {
1047 ret.second = i18ncp(
"@action:inmenu",
"Paste One Item",
"Paste %1 Items", urls.count());
1049 ret.second = i18nc(
"@action:inmenu",
"Paste Clipboard Contents...");
1053 ret.second = i18nc(
"@action:inmenu",
"Paste");
1059 #include "konq_operations.moc"
static KIO::SimpleJob * newDir(QWidget *parent, const KUrl &baseUrl)
Ask for the name of a new directory and create it.
static QString translatePath(QString path)
static bool cleanHomeDirPath(QString &path, const QString &homeDir)
virtual void slotResult(KJob *job)
Restore multiple trashed files.
KonqOperations(QWidget *parent)
static const KCatalogLoader loader("libkonq")
void asyncDrop(const KFileItem &item)
static void del(QWidget *parent, Operation method, const KUrl::List &selectedUrls)
Delete the selectedUrls if possible.
static bool confirmCreatingHiddenDir(const QString &name, QWidget *parent)
static void copy(QWidget *parent, Operation method, const KUrl::List &selectedUrls, const KUrl &destUrl)
Copy the selectedUrls to the destination destUrl.
static bool decodeIsCutSelection(const QMimeData *mimeData)
Implements file operations (move,del,trash,paste,copy,move,link...) for file managers.
void statFinished(const KFileItem &item)
void slotResult(KJob *job)
static void statUrl(const KUrl &url, const QObject *receiver, const char *member, QWidget *parent)
Get info about a given URL, and when that's done (it's asynchronous!), call a given slot with a const...
virtual ~KonqOperations()
void renamingFailed(const KUrl &oldUrl, const KUrl &newUrl)
static void emptyTrash(QWidget *parent)
Empty the trash.
void slotStatResult(KJob *job)
static KonqOperations * renameV2(QWidget *parent, const KUrl &oldurl, const QString &name)
Do a renaming.
KonqMultiRestoreJob(const KUrl::List &urls)
static void doPaste(QWidget *parent, const KUrl &destUrl, const QPoint &pos=QPoint())
Paste the clipboard contents.
void slotCopyingDone(KIO::Job *job, const KUrl &from, const KUrl &to)
void slotCopyingLinkDone(KIO::Job *job, const KUrl &from, const QString &target, const KUrl &to)
static void doDrop(const KFileItem &destItem, const KUrl &destUrl, QDropEvent *ev, QWidget *parent)
Drop.
static KonqOperations * doPasteV2(QWidget *parent, const KUrl &destUrl, const QPoint &pos=QPoint())
Paste the clipboard contents.
void slotAboutToCreate(KIO::Job *job, const QList< KIO::CopyInfo > &files)
void aboutToCreate(const QPoint &pos, const QList< KIO::CopyInfo > &files)
static bool askDeleteConfirmation(const KUrl::List &selectedUrls, int method, ConfirmationType confirmation, QWidget *widget)
Ask for confirmation before deleting/trashing selectedUrls.
static void editMimeType(const QString &mimeType, QWidget *parent)
Pop up properties dialog for mimetype mimeType.
static void rename(QWidget *parent, const KUrl &oldurl, const QString &name)
Do a renaming.
static void restoreTrashedItems(const KUrl::List &urls, QWidget *parent)
Restore trashed items.
static QPair< bool, QString > pasteInfo(const KUrl &targetUrl)
Returns the state of the paste action: first is whether the action should be enabled second is the te...
KUrl::List droppedUrls() const
Returns the list of dropped URL's.
static KIO::SimpleJob * mkdir(QWidget *parent, const KUrl &url)
Create a directory.
QPoint dropPosition() const
Returns the position where the drop occurred.