• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • 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     if (res == R_AUTO_RENAME) {
00085         newDest = dlg.autoDestUrl().path();
00086     }
00087     else {
00088         newDest = dlg.newDestUrl().path();
00089     }
00090     return res;
00091 }
00092 
00093 KIO::SkipDialog_Result KIO::JobUiDelegate::askSkip(KJob *job,
00094                                               bool multi,
00095                                               const QString & error_text)
00096 {
00097     // We now do it in process. So this method is a useless wrapper around KIO::open_RenameDialog.
00098     KIO::SkipDialog dlg( window(), multi, error_text );
00099     connect(job, SIGNAL(finished(KJob*)), &dlg, SLOT(reject())); // #192976
00100     return static_cast<KIO::SkipDialog_Result>(dlg.exec());
00101 }
00102 
00103 bool KIO::JobUiDelegate::askDeleteConfirmation(const KUrl::List& urls,
00104                                                DeletionType deletionType,
00105                                                ConfirmationType confirmationType)
00106 {
00107     QString keyName;
00108     bool ask = ( confirmationType == ForceConfirmation );
00109     if (!ask) {
00110         KSharedConfigPtr kioConfig = KSharedConfig::openConfig("kiorc", KConfig::NoGlobals);
00111 
00112     switch (deletionType ) {
00113     case Delete:
00114         keyName = "ConfirmDelete" ;
00115         break;
00116     case Trash:
00117         keyName = "ConfirmTrash" ;
00118         break;
00119     case EmptyTrash:
00120         keyName = "ConfirmEmptyTrash" ;
00121         break;
00122     }
00123 
00124         // The default value for confirmations is true (for both delete and trash)
00125         // If you change this, update kdebase/apps/konqueror/settings/konq/behaviour.cpp
00126         const bool defaultValue = true;
00127         ask = kioConfig->group("Confirmations").readEntry(keyName, defaultValue);
00128     }
00129     if (ask) {
00130         QStringList prettyList;
00131         Q_FOREACH(const KUrl& url, urls) {
00132             if ( url.protocol() == "trash" ) {
00133                 QString path = url.path();
00134                 // HACK (#98983): remove "0-foo". Note that it works better than
00135                 // displaying KFileItem::name(), for files under a subdir.
00136                 path.remove(QRegExp("^/[0-9]*-"));
00137                 prettyList.append(path);
00138             } else {
00139                 prettyList.append(url.pathOrUrl());
00140             }
00141         }
00142 
00143         QWidget* widget = window();
00144         int result;
00145         switch(deletionType) {
00146         case Delete:
00147             result = KMessageBox::warningContinueCancelList(
00148                 widget,
00149                 i18np("Do you really want to delete this item?", "Do you really want to delete these %1 items?", prettyList.count()),
00150                 prettyList,
00151         i18n("Delete Files"),
00152         KStandardGuiItem::del(),
00153         KStandardGuiItem::cancel(),
00154         keyName, KMessageBox::Notify);
00155             break;
00156         case EmptyTrash:
00157         result = KMessageBox::warningContinueCancel(
00158             widget,
00159         i18nc("@info", "Do you want to permanently delete all items from Trash? This action cannot be undone."),
00160         QString(),
00161         KGuiItem(i18nc("@action:button", "Empty Trash"),
00162         KIcon("user-trash")),
00163         KStandardGuiItem::cancel(),
00164         keyName, KMessageBox::Notify);
00165         break;
00166         case Trash:
00167         default:
00168             result = KMessageBox::warningContinueCancelList(
00169                 widget,
00170                 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()),
00171                 prettyList,
00172         i18n("Move to Trash"),
00173         KGuiItem(i18nc("Verb", "&Trash"), "user-trash"),
00174         KStandardGuiItem::cancel(),
00175         keyName, KMessageBox::Notify);
00176         }
00177         if (!keyName.isEmpty()) {
00178             // Check kmessagebox setting... erase & copy to konquerorrc.
00179             KSharedConfig::Ptr config = KGlobal::config();
00180             KConfigGroup notificationGroup(config, "Notification Messages");
00181             if (!notificationGroup.readEntry(keyName, true)) {
00182                 notificationGroup.writeEntry(keyName, true);
00183                 notificationGroup.sync();
00184 
00185                 KSharedConfigPtr kioConfig = KSharedConfig::openConfig("kiorc", KConfig::NoGlobals);
00186                 kioConfig->group("Confirmations").writeEntry(keyName, false);
00187             }
00188         }
00189         return (result == KMessageBox::Continue);
00190     }
00191     return true;
00192 }
00193 
00194 #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
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
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