• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KIO

jobuidelegate.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002     Copyright (C) 2000 Stephan Kulow <coolo@kde.org>
00003                        David Faure <faure@kde.org>
00004     Copyright (C) 2006 Kevin Ottens <ervin@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #include "jobuidelegate.h"
00023 
00024 #include <kdebug.h>
00025 #include <kjob.h>
00026 #include <klocale.h>
00027 #include <kmessagebox.h>
00028 #include <ksharedconfig.h>
00029 
00030 #include <QPointer>
00031 #include <QWidget>
00032 
00033 #include "kio/scheduler.h"
00034 
00035 #if defined Q_WS_X11
00036 #include <QX11Info>
00037 #include <netwm.h>
00038 #endif
00039 
00040 class KIO::JobUiDelegate::Private
00041 {
00042 public:
00043 };
00044 
00045 KIO::JobUiDelegate::JobUiDelegate()
00046     : d(new Private())
00047 {
00048 }
00049 
00050 KIO::JobUiDelegate::~JobUiDelegate()
00051 {
00052     delete d;
00053 }
00054 
00055 void KIO::JobUiDelegate::setWindow(QWidget *window)
00056 {
00057     KDialogJobUiDelegate::setWindow(window);
00058     KIO::Scheduler::registerWindow(window);
00059 }
00060 
00061 KIO::RenameDialog_Result KIO::JobUiDelegate::askFileRename(KJob * job,
00062                                                            const QString & caption,
00063                                                            const QString& src,
00064                                                            const QString & dest,
00065                                                            KIO::RenameDialog_Mode mode,
00066                                                            QString& newDest,
00067                                                            KIO::filesize_t sizeSrc,
00068                                                            KIO::filesize_t sizeDest,
00069                                                            time_t ctimeSrc,
00070                                                            time_t ctimeDest,
00071                                                            time_t mtimeSrc,
00072                                                            time_t mtimeDest)
00073 {
00074     Q_UNUSED(job);
00075     //kDebug() << "job=" << job;
00076     // We now do it in process, so that opening the rename dialog
00077     // doesn't start uiserver for nothing if progressId=0 (e.g. F2 in konq)
00078     KIO::RenameDialog dlg( window(), caption, src, dest, mode,
00079                                                      sizeSrc, sizeDest,
00080                                                      ctimeSrc, ctimeDest, mtimeSrc,
00081                                                      mtimeDest);
00082     connect(job, SIGNAL(finished(KJob*)), &dlg, SLOT(reject())); // #192976
00083     KIO::RenameDialog_Result res = static_cast<RenameDialog_Result>(dlg.exec());
00084     newDest = dlg.newDestUrl().path();
00085     return res;
00086 }
00087 
00088 KIO::SkipDialog_Result KIO::JobUiDelegate::askSkip(KJob *job,
00089                                               bool multi,
00090                                               const QString & error_text)
00091 {
00092     // We now do it in process. So this method is a useless wrapper around KIO::open_RenameDialog.
00093     KIO::SkipDialog dlg( window(), multi, error_text );
00094     connect(job, SIGNAL(finished(KJob*)), &dlg, SLOT(reject())); // #192976
00095     return static_cast<KIO::SkipDialog_Result>(dlg.exec());
00096 }
00097 
00098 bool KIO::JobUiDelegate::askDeleteConfirmation(const KUrl::List& urls,
00099                                                DeletionType deletionType,
00100                                                ConfirmationType confirmationType)
00101 {
00102     QString keyName;
00103     bool ask = ( confirmationType == ForceConfirmation );
00104     if (!ask) {
00105         KSharedConfigPtr kioConfig = KSharedConfig::openConfig("kiorc", KConfig::NoGlobals);
00106         keyName = (deletionType == Delete ? "ConfirmDelete" : "ConfirmTrash");
00107         // The default value for confirmations is true (for both delete and trash)
00108         // If you change this, update kdebase/apps/konqueror/settings/konq/behaviour.cpp
00109         const bool defaultValue = true;
00110         ask = kioConfig->group("Confirmations").readEntry(keyName, defaultValue);
00111     }
00112     if (ask) {
00113         QStringList prettyList;
00114         Q_FOREACH(const KUrl& url, urls) {
00115             if ( url.protocol() == "trash" ) {
00116                 QString path = url.path();
00117                 // HACK (#98983): remove "0-foo". Note that it works better than
00118                 // displaying KFileItem::name(), for files under a subdir.
00119                 path.remove(QRegExp("^/[0-9]*-"));
00120                 prettyList.append(path);
00121             } else {
00122                 prettyList.append(url.pathOrUrl());
00123             }
00124         }
00125 
00126         QWidget* widget = window();
00127         int result;
00128         switch(deletionType) {
00129         case Delete:
00130             result = KMessageBox::warningContinueCancelList(
00131                 widget,
00132                 i18np("Do you really want to delete this item?", "Do you really want to delete these %1 items?", prettyList.count()),
00133                 prettyList,
00134         i18n("Delete Files"),
00135         KStandardGuiItem::del(),
00136         KStandardGuiItem::cancel(),
00137         keyName, KMessageBox::Notify);
00138             break;
00139 
00140         case Trash:
00141         default:
00142             result = KMessageBox::warningContinueCancelList(
00143                 widget,
00144                 i18np("Do you really want to move this item to the trash?", "Do you really want to move these %1 items to the trash?", prettyList.count()),
00145                 prettyList,
00146         i18n("Move to Trash"),
00147         KGuiItem(i18nc("Verb", "&Trash"), "user-trash"),
00148         KStandardGuiItem::cancel(),
00149         keyName, KMessageBox::Notify);
00150         }
00151         if (!keyName.isEmpty()) {
00152             // Check kmessagebox setting... erase & copy to konquerorrc.
00153             KSharedConfig::Ptr config = KGlobal::config();
00154             KConfigGroup notificationGroup(config, "Notification Messages");
00155             if (!notificationGroup.readEntry(keyName, true)) {
00156                 notificationGroup.writeEntry(keyName, true);
00157                 notificationGroup.sync();
00158 
00159                 KSharedConfigPtr kioConfig = KSharedConfig::openConfig("kiorc", KConfig::NoGlobals);
00160                 kioConfig->group("Confirmations").writeEntry(keyName, false);
00161             }
00162         }
00163         return (result == KMessageBox::Continue);
00164     }
00165     return true;
00166 }
00167 
00168 #include "jobuidelegate.moc"

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal