diff options
| author | Peter Penz <[email protected]> | 2008-11-08 16:22:30 +0000 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2008-11-08 16:22:30 +0000 |
| commit | a7838db28e24e9618a39954524f055dc3335f7a9 (patch) | |
| tree | c4c653405a259e87ac34163efd0d51db07ba242d /src/draganddrophelper.cpp | |
| parent | d5bc6cfa74e21668788d42721dcdb4818a072366 (diff) | |
* implement the DragAndDropHelper as singleton derived from QObject, so that emitting of signals is possible
* show an information message in the statusbar, if items are dragged into the same directory
TODO: although the signal seems to get connected correctly, the slot DolphinMainWindow::showInformationMessage() is not invoked when the signal is emitted -> will debug this later, it is important that the new string is added before the message freeze
svn path=/trunk/KDE/kdebase/apps/; revision=881627
Diffstat (limited to 'src/draganddrophelper.cpp')
| -rw-r--r-- | src/draganddrophelper.cpp | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/src/draganddrophelper.cpp b/src/draganddrophelper.cpp index ded92bf04..a4971a62c 100644 --- a/src/draganddrophelper.cpp +++ b/src/draganddrophelper.cpp @@ -24,6 +24,7 @@ #include <kdirmodel.h> #include <kfileitem.h> #include <kicon.h> +#include <klocale.h> #include <konq_operations.h> #include <QAbstractItemView> @@ -31,7 +32,19 @@ #include <QtDBus> #include <QDrag> -bool DragAndDropHelper::isMimeDataSupported(const QMimeData* mimeData) +class DragAndDropHelperSingleton +{ +public: + DragAndDropHelper instance; +}; +K_GLOBAL_STATIC(DragAndDropHelperSingleton, s_dragAndDropHelper) + +DragAndDropHelper& DragAndDropHelper::instance() +{ + return s_dragAndDropHelper->instance; +} + +bool DragAndDropHelper::isMimeDataSupported(const QMimeData* mimeData) const { return mimeData->hasUrls() || mimeData->hasFormat("application/x-kde-dndextract"); } @@ -87,12 +100,22 @@ void DragAndDropHelper::dropUrls(const KFileItem& destItem, } else { const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData()); const KUrl sourceDir = KUrl(urls.first().directory()); - if (sourceDir != destination) { - if (dropToItem) { - KonqOperations::doDrop(destItem, destination, event, widget); - } else { - KonqOperations::doDrop(KFileItem(), destination, event, widget); - } + if (sourceDir == destination) { + const QString msg = i18ncp("@info:status", + "The dropped item is already inside the folder %2", + "The dropped items are already inside the folder %2", + urls.count(), destination.fileName()); + emit informationMessage(msg); + } else if (dropToItem) { + KonqOperations::doDrop(destItem, destination, event, widget); + } else { + KonqOperations::doDrop(KFileItem(), destination, event, widget); } } } + +DragAndDropHelper::DragAndDropHelper() +{ +} + +#include "draganddrophelper.moc" |
