• Skip to content
  • Skip to link menu
KDE 4.2 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     KIO::RenameDialog_Result res = static_cast<RenameDialog_Result>(dlg.exec());
00083     newDest = dlg.newDestUrl().path();
00084     return res;
00085 }
00086 
00087 KIO::SkipDialog_Result KIO::JobUiDelegate::askSkip(KJob *,
00088                                               bool multi,
00089                                               const QString & error_text)
00090 {
00091     // We now do it in process. So this method is a useless wrapper around KIO::open_RenameDialog.
00092     KIO::SkipDialog dlg( window(), multi, error_text );
00093     return static_cast<KIO::SkipDialog_Result>(dlg.exec());
00094 }
00095 
00096 bool KIO::JobUiDelegate::askDeleteConfirmation(const KUrl::List& urls,
00097                                                DeletionType deletionType,
00098                                                ConfirmationType confirmationType)
00099 {
00100     QString keyName;
00101     bool ask = ( confirmationType == ForceConfirmation );
00102     if (!ask) {
00103         KSharedConfigPtr kioConfig = KSharedConfig::openConfig("kiorc", KConfig::NoGlobals);
00104         keyName = (deletionType == Delete ? "ConfirmDelete" : "ConfirmTrash");
00105         // The default value for confirmations is true (for both delete and trash)
00106         // If you change this, update kdebase/apps/konqueror/settings/konq/behaviour.cpp
00107         const bool defaultValue = true;
00108         ask = kioConfig->group("Confirmations").readEntry(keyName, defaultValue);
00109     }
00110     if (ask) {
00111         QStringList prettyList;
00112         Q_FOREACH(const KUrl& url, urls) {
00113             if ( url.protocol() == "trash" ) {
00114                 QString path = url.path();
00115                 // HACK (#98983): remove "0-foo". Note that it works better than
00116                 // displaying KFileItem::name(), for files under a subdir.
00117                 path.remove(QRegExp("^/[0-9]*-"));
00118                 prettyList.append(path);
00119             } else {
00120                 prettyList.append(url.pathOrUrl());
00121             }
00122         }
00123 
00124         QWidget* widget = window();
00125         int result;
00126         switch(deletionType) {
00127         case Delete:
00128             result = KMessageBox::warningContinueCancelList(
00129                 widget,
00130                 i18np("Do you really want to delete this item?", "Do you really want to delete these %1 items?", prettyList.count()),
00131                 prettyList,
00132         i18n("Delete Files"),
00133         KStandardGuiItem::del(),
00134         KStandardGuiItem::cancel(),
00135         keyName, KMessageBox::Notify);
00136             break;
00137 
00138         case Trash:
00139         default:
00140             result = KMessageBox::warningContinueCancelList(
00141                 widget,
00142                 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()),
00143                 prettyList,
00144         i18n("Move to Trash"),
00145         KGuiItem(i18nc("Verb", "&Trash"), "user-trash"),
00146         KStandardGuiItem::cancel(),
00147         keyName, KMessageBox::Notify);
00148         }
00149         if (!keyName.isEmpty()) {
00150             // Check kmessagebox setting... erase & copy to konquerorrc.
00151             KSharedConfig::Ptr config = KGlobal::config();
00152             KConfigGroup notificationGroup(config, "Notification Messages");
00153             if (!notificationGroup.readEntry(keyName, true)) {
00154                 notificationGroup.writeEntry(keyName, true);
00155                 notificationGroup.sync();
00156 
00157                 KSharedConfigPtr kioConfig = KSharedConfig::openConfig("kiorc", KConfig::NoGlobals);
00158                 kioConfig->group("Confirmations").writeEntry(keyName, false);
00159             }
00160         }
00161         return (result == KMessageBox::Continue);
00162     }
00163     return true;
00164 }
00165 
00166 #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
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
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