File indexing completed on 2024-11-17 05:01:38

0001 /*
0002     SPDX-FileCopyrightText: 2001, 2002 Carsten Pfeiffer <pfeiffer@kde.org>
0003     SPDX-FileCopyrightText: 2001 Michael Jarrett <michaelj@corel.com>
0004     SPDX-FileCopyrightText: 2009 Shaun Reich <shaun.reich@kdemail.net>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-only
0007 */
0008 
0009 #include "kdirselectdialog_p.h"
0010 
0011 #include <QDebug>
0012 #include <QDialogButtonBox>
0013 #include <QDir>
0014 #include <QFileDialog>
0015 #include <QInputDialog>
0016 #include <QLayout>
0017 #include <QMenu>
0018 #include <QPushButton>
0019 #include <QSplitter>
0020 #include <QStandardPaths>
0021 #include <QStringList>
0022 #include <QUrl>
0023 
0024 #include <KActionCollection>
0025 #include <KAuthorized>
0026 #include <KConfig>
0027 #include <KConfigGroup>
0028 #include <KFileItemDelegate>
0029 #include <KFileUtils>
0030 #include <KFileWidget>
0031 #include <KHistoryComboBox>
0032 #include <KIO/CopyJob>
0033 #include <KIO/DeleteJob>
0034 #include <KIO/DeleteOrTrashJob>
0035 #include <KIO/Job>
0036 #include <KIO/JobUiDelegate>
0037 #include <KIO/MkdirJob>
0038 #include <KJobWidgets>
0039 #include <KLocalizedString>
0040 #include <KMessageBox>
0041 #include <KPropertiesDialog>
0042 #include <KRecentDirs>
0043 #include <KService>
0044 #include <KSharedConfig>
0045 #include <KStandardShortcut>
0046 #include <KToggleAction>
0047 #include <KUrlCompletion>
0048 
0049 #include "kfiletreeview_p.h"
0050 #include <KFilePlacesModel>
0051 #include <KFilePlacesView>
0052 // ### add mutator for treeview!
0053 
0054 class KDirSelectDialog::Private
0055 {
0056 public:
0057     Private(bool localOnly, KDirSelectDialog *parent)
0058         : m_parent(parent)
0059         , m_localOnly(localOnly)
0060         , m_comboLocked(false)
0061     {
0062     }
0063 
0064     void readConfig(const KSharedConfigPtr &config, const QString &group);
0065     void saveConfig(KSharedConfigPtr config, const QString &group);
0066     void slotMkdir();
0067 
0068     void slotCurrentChanged(const QUrl &url);
0069     void slotExpand(const QModelIndex &);
0070     void slotUrlActivated(const QString &);
0071     void slotComboTextChanged(const QString &);
0072     void slotContextMenuRequested(const QPoint &);
0073     void slotMoveToTrash();
0074     void slotDelete();
0075     void slotProperties();
0076 
0077     KDirSelectDialog *const m_parent;
0078     bool m_localOnly : 1;
0079     bool m_comboLocked : 1;
0080     QUrl m_rootUrl;
0081     QUrl m_startDir;
0082     KFileTreeView *m_treeView = nullptr;
0083     QMenu *m_contextMenu = nullptr;
0084     KActionCollection *m_actions = nullptr;
0085     KFilePlacesView *m_placesView = nullptr;
0086     KHistoryComboBox *m_urlCombo = nullptr;
0087     QString m_recentDirClass;
0088     QUrl m_startURL;
0089     QAction *moveToTrash = nullptr;
0090     QAction *deleteAction = nullptr;
0091     QAction *showHiddenFoldersAction = nullptr;
0092     QDialogButtonBox *m_buttons = nullptr;
0093 };
0094 
0095 void KDirSelectDialog::Private::readConfig(const KSharedConfig::Ptr &config, const QString &group)
0096 {
0097     m_urlCombo->clear();
0098 
0099     KConfigGroup conf(config, group);
0100     m_urlCombo->setHistoryItems(conf.readPathEntry("History Items", QStringList()));
0101 
0102     const QSize size = conf.readEntry("DirSelectDialog Size", QSize());
0103     if (size.isValid()) {
0104         m_parent->resize(size);
0105     }
0106 }
0107 
0108 void KDirSelectDialog::Private::saveConfig(KSharedConfig::Ptr config, const QString &group)
0109 {
0110     KConfigGroup conf(config, group);
0111     KConfigGroup::WriteConfigFlags flags(KConfigGroup::Persistent | KConfigGroup::Global);
0112     conf.writePathEntry("History Items", m_urlCombo->historyItems(), flags);
0113     conf.writeEntry("DirSelectDialog Size", m_parent->size(), flags);
0114 
0115     config->sync();
0116 }
0117 
0118 void KDirSelectDialog::Private::slotMkdir()
0119 {
0120     bool ok;
0121     QString where = m_parent->url().toDisplayString(QUrl::PreferLocalFile);
0122     QString name = i18nc("folder name", "New Folder");
0123     if (m_parent->url().isLocalFile() && QFileInfo::exists(m_parent->url().toLocalFile() + QLatin1Char('/') + name)) {
0124         name = KFileUtils::suggestName(m_parent->url(), name);
0125     }
0126 
0127     const QString directory = QInputDialog::getText(m_parent,
0128                                                     i18nc("@title:window", "New Folder"),
0129                                                     i18nc("@label:textbox", "Create new folder in:\n%1", where),
0130                                                     QLineEdit::Normal,
0131                                                     name,
0132                                                     &ok);
0133     if (!ok) {
0134         return;
0135     }
0136 
0137     bool writeOk = false;
0138     bool exists = false;
0139     QUrl folderurl(m_parent->url());
0140 
0141     const QStringList dirs = directory.split(QLatin1Char('/'), Qt::SkipEmptyParts);
0142     QStringList::ConstIterator it = dirs.begin();
0143 
0144     for (; it != dirs.end(); ++it) {
0145         folderurl.setPath(folderurl.path() + QLatin1Char('/') + *it);
0146         KIO::StatJob *job = KIO::stat(folderurl);
0147         KJobWidgets::setWindow(job, m_parent);
0148         job->setDetails(KIO::StatNoDetails); // We only want to know if it exists
0149         job->setSide(KIO::StatJob::DestinationSide);
0150         exists = job->exec();
0151         if (!exists) {
0152             KIO::MkdirJob *job = KIO::mkdir(folderurl);
0153             KJobWidgets::setWindow(job, m_parent);
0154             writeOk = job->exec();
0155         }
0156     }
0157 
0158     if (exists) { // url was already existent
0159         QString which = folderurl.toDisplayString(QUrl::PreferLocalFile);
0160         KMessageBox::error(m_parent, i18n("A file or folder named %1 already exists.", which));
0161         // Select the existing dir (if a file with that name exists, it won't be selected since
0162         // we only show dirs here, this is cheaper than checking if the existing item is a file
0163         // or folder).
0164         m_parent->setCurrentUrl(folderurl);
0165         return;
0166     }
0167 
0168     if (!writeOk) {
0169         KMessageBox::error(m_parent, i18n("You do not have permission to create that folder."));
0170         return;
0171     }
0172 
0173     // Select the newly created dir
0174     m_parent->setCurrentUrl(folderurl);
0175 }
0176 
0177 void KDirSelectDialog::Private::slotCurrentChanged(const QUrl &url)
0178 {
0179     if (m_comboLocked) {
0180         return;
0181     }
0182 
0183     if (url.isValid()) {
0184         m_urlCombo->setEditText(url.toDisplayString(QUrl::PreferLocalFile));
0185     } else {
0186         m_urlCombo->setEditText(QString());
0187     }
0188 }
0189 
0190 void KDirSelectDialog::Private::slotUrlActivated(const QString &text)
0191 {
0192     if (text.isEmpty()) {
0193         return;
0194     }
0195 
0196     const QUrl url = QUrl::fromUserInput(text);
0197     m_urlCombo->addToHistory(url.toDisplayString());
0198 
0199     if (m_parent->localOnly() && !url.isLocalFile()) {
0200         return; // FIXME: messagebox for the user
0201     }
0202 
0203     QUrl oldUrl = m_treeView->currentUrl();
0204     if (oldUrl.isEmpty()) {
0205         oldUrl = m_startDir;
0206     }
0207 
0208     m_parent->setCurrentUrl(oldUrl);
0209 }
0210 
0211 void KDirSelectDialog::Private::slotComboTextChanged(const QString &text)
0212 {
0213     m_treeView->blockSignals(true);
0214     QUrl url = QUrl::fromUserInput(text);
0215 #ifdef Q_OS_WIN
0216     QUrl rootUrl(m_treeView->rootUrl());
0217     if (url.isLocalFile() && !rootUrl.isParentOf(url) && !rootUrl.matches(url, QUrl::StripTrailingSlash)) {
0218         QUrl tmp = KIO::upUrl(url);
0219         while (tmp.path().length() > 1) {
0220             url = tmp;
0221             tmp = KIO::upUrl(url);
0222         }
0223         m_treeView->setRootUrl(url);
0224     }
0225 #endif
0226     m_treeView->setCurrentUrl(url);
0227     m_treeView->blockSignals(false);
0228 }
0229 
0230 void KDirSelectDialog::Private::slotContextMenuRequested(const QPoint &pos)
0231 {
0232     m_contextMenu->popup(m_treeView->viewport()->mapToGlobal(pos));
0233 }
0234 
0235 void KDirSelectDialog::Private::slotExpand(const QModelIndex &index)
0236 {
0237     m_treeView->setExpanded(index, !m_treeView->isExpanded(index));
0238 }
0239 
0240 void KDirSelectDialog::Private::slotMoveToTrash()
0241 {
0242     const QUrl url = m_treeView->selectedUrl();
0243     using Iface = KIO::AskUserActionInterface;
0244     auto *trashJob = new KIO::DeleteOrTrashJob({url}, Iface::Trash, Iface::DefaultConfirmation, m_parent);
0245     trashJob->start();
0246 }
0247 
0248 void KDirSelectDialog::Private::slotDelete()
0249 {
0250     const QUrl url = m_treeView->selectedUrl();
0251     using Iface = KIO::AskUserActionInterface;
0252     auto *deleteJob = new KIO::DeleteOrTrashJob({url}, Iface::Delete, Iface::DefaultConfirmation, m_parent);
0253     deleteJob->start();
0254 }
0255 
0256 void KDirSelectDialog::Private::slotProperties()
0257 {
0258     KPropertiesDialog *dialog = new KPropertiesDialog(m_treeView->selectedUrl(), this->m_parent);
0259     dialog->setAttribute(Qt::WA_DeleteOnClose);
0260     dialog->show();
0261 }
0262 
0263 KDirSelectDialog::KDirSelectDialog(const QUrl &startDir, bool localOnly, QWidget *parent)
0264     // #ifdef Q_OS_WIN
0265     //     : QDialog(parent, Qt::WindowMinMaxButtonsHint),
0266     // #else
0267     //     : QDialog(parent),
0268     // #endif
0269     : d(new Private(localOnly, this))
0270 {
0271     setWindowTitle(i18nc("@title:window", "Select Folder"));
0272     setMinimumSize({200, 200});
0273 
0274     QVBoxLayout *topLayout = new QVBoxLayout;
0275     topLayout->setContentsMargins({});
0276     setLayout(topLayout);
0277 
0278     QPushButton *folderButton = new QPushButton(this);
0279     KGuiItem::assign(folderButton, KGuiItem(i18nc("@action:button", "New Folder..."), QStringLiteral("folder-new")));
0280     connect(folderButton, &QPushButton::clicked, this, [this]() {
0281         d->slotMkdir();
0282     });
0283 
0284     auto splitter = new QSplitter(this);
0285     splitter->setChildrenCollapsible(false);
0286     splitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
0287     topLayout->addWidget(splitter);
0288 
0289     auto mainWidget = new QWidget(splitter);
0290     QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget);
0291     mainLayout->setContentsMargins({});
0292 
0293     d->m_actions = new KActionCollection(this);
0294     d->m_actions->addAssociatedWidget(this);
0295     d->m_placesView = new KFilePlacesView(splitter);
0296     d->m_placesView->setModel(new KFilePlacesModel(d->m_placesView));
0297     d->m_placesView->setObjectName(QStringLiteral("speedbar"));
0298     d->m_placesView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
0299     d->m_placesView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
0300     d->m_placesView->setMinimumSize(250, 200);
0301     connect(d->m_placesView, &KFilePlacesView::urlChanged, this, &KDirSelectDialog::setCurrentUrl);
0302 
0303     splitter->addWidget(d->m_placesView);
0304     splitter->addWidget(mainWidget);
0305 
0306     d->m_treeView = new KFileTreeView(splitter);
0307     d->m_treeView->setDirOnlyMode(true);
0308     d->m_treeView->setContextMenuPolicy(Qt::CustomContextMenu);
0309     d->m_treeView->setProperty("_breeze_borders_sides", QVariant::fromValue(QFlags{Qt::TopEdge | Qt::BottomEdge}));
0310 
0311     for (int i = 1; i < d->m_treeView->model()->columnCount(); ++i) {
0312         d->m_treeView->hideColumn(i);
0313     }
0314 
0315     auto urlComboWrapper = new QWidget(splitter);
0316     auto urlComboWrapperLayout = new QVBoxLayout(urlComboWrapper);
0317     urlComboWrapperLayout->setContentsMargins(style()->pixelMetric(QStyle::PM_LayoutLeftMargin), 0, style()->pixelMetric(QStyle::PM_LayoutRightMargin), 0);
0318 
0319     d->m_urlCombo = new KHistoryComboBox(urlComboWrapper);
0320     d->m_urlCombo->setContentsMargins({});
0321     d->m_urlCombo->setLayoutDirection(Qt::LeftToRight);
0322     d->m_urlCombo->setSizeAdjustPolicy(QComboBox::AdjustToContents);
0323     d->m_urlCombo->setTrapReturnKey(true);
0324     d->m_urlCombo->setIconProvider([](const QString &name) {
0325         return QIcon::fromTheme(KIO::iconNameForUrl(QUrl::fromUserInput(name)));
0326     });
0327     KUrlCompletion *comp = new KUrlCompletion();
0328     comp->setMode(KUrlCompletion::DirCompletion);
0329     d->m_urlCombo->setCompletionObject(comp, true);
0330     d->m_urlCombo->setAutoDeleteCompletionObject(true);
0331     d->m_urlCombo->setDuplicatesEnabled(false);
0332     urlComboWrapperLayout->addWidget(d->m_urlCombo);
0333 
0334     d->m_contextMenu = new QMenu(this);
0335 
0336     QAction *newFolder = new QAction(i18nc("@action:inmenu", "New Folder..."), this);
0337     d->m_actions->addAction(newFolder->objectName(), newFolder);
0338     newFolder->setIcon(QIcon::fromTheme(QStringLiteral("folder-new")));
0339     newFolder->setShortcuts(KStandardShortcut::createFolder());
0340     connect(newFolder, &QAction::triggered, this, [this]() {
0341         d->slotMkdir();
0342     });
0343     d->m_contextMenu->addAction(newFolder);
0344 
0345     d->moveToTrash = new QAction(i18nc("@action:inmenu", "Move to Trash"), this);
0346     d->m_actions->addAction(d->moveToTrash->objectName(), d->moveToTrash);
0347     d->moveToTrash->setIcon(QIcon::fromTheme(QStringLiteral("user-trash")));
0348     d->moveToTrash->setShortcut(Qt::Key_Delete);
0349     connect(d->moveToTrash, &QAction::triggered, this, [this]() {
0350         d->slotMoveToTrash();
0351     });
0352     d->m_contextMenu->addAction(d->moveToTrash);
0353 
0354     d->deleteAction = new QAction(i18nc("@action:inmenu", "Delete"), this);
0355     d->m_actions->addAction(d->deleteAction->objectName(), d->deleteAction);
0356     d->deleteAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-delete")));
0357     d->deleteAction->setShortcut(Qt::SHIFT | Qt::Key_Delete);
0358     connect(d->deleteAction, &QAction::triggered, this, [this]() {
0359         d->slotDelete();
0360     });
0361     d->m_contextMenu->addAction(d->deleteAction);
0362 
0363     d->m_contextMenu->addSeparator();
0364 
0365     d->showHiddenFoldersAction = new KToggleAction(i18nc("@option:check", "Show Hidden Folders"), this);
0366     d->m_actions->addAction(d->showHiddenFoldersAction->objectName(), d->showHiddenFoldersAction);
0367     d->showHiddenFoldersAction->setShortcuts(KStandardShortcut::showHideHiddenFiles());
0368     connect(d->showHiddenFoldersAction, &QAction::triggered, d->m_treeView, &KFileTreeView::setShowHiddenFiles);
0369     d->m_contextMenu->addAction(d->showHiddenFoldersAction);
0370     d->m_contextMenu->addSeparator();
0371 
0372     QAction *propertiesAction = new QAction(i18nc("@action:inmenu", "Properties"), this);
0373     d->m_actions->addAction(propertiesAction->objectName(), propertiesAction);
0374     propertiesAction->setIcon(QIcon::fromTheme(QStringLiteral("document-properties")));
0375     propertiesAction->setShortcut(Qt::ALT | Qt::Key_Return);
0376     connect(propertiesAction, &QAction::triggered, this, [this]() {
0377         d->slotProperties();
0378     });
0379     d->m_contextMenu->addAction(propertiesAction);
0380 
0381     d->m_startURL = KFileWidget::getStartUrl(startDir, d->m_recentDirClass);
0382     if (localOnly && !d->m_startURL.isLocalFile()) {
0383         QString docPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
0384         if (QDir(docPath).exists()) {
0385             d->m_startURL = QUrl::fromLocalFile(docPath);
0386         } else {
0387             d->m_startURL = QUrl::fromLocalFile(QDir::homePath());
0388         }
0389     }
0390 
0391     d->m_startDir = d->m_startURL;
0392     d->m_rootUrl = d->m_treeView->rootUrl();
0393 
0394     d->readConfig(KSharedConfig::openConfig(), QStringLiteral("DirSelect Dialog"));
0395 
0396     d->m_buttons = new QDialogButtonBox(mainWidget);
0397     d->m_buttons->setContentsMargins(style()->pixelMetric(QStyle::PM_LayoutLeftMargin),
0398                                      0,
0399                                      style()->pixelMetric(QStyle::PM_LayoutRightMargin),
0400                                      style()->pixelMetric(QStyle::PM_LayoutBottomMargin));
0401     d->m_buttons->addButton(folderButton, QDialogButtonBox::ActionRole);
0402     d->m_buttons->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
0403     connect(d->m_buttons, &QDialogButtonBox::accepted, this, &QDialog::accept);
0404     connect(d->m_buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
0405 
0406     mainLayout->addWidget(d->m_treeView, 1);
0407     mainLayout->addWidget(urlComboWrapper, 0);
0408     mainLayout->addWidget(d->m_buttons);
0409 
0410     connect(d->m_treeView, &KFileTreeView::currentUrlChanged, this, [this](const QUrl &url) {
0411         d->slotCurrentChanged(url);
0412     });
0413 
0414     connect(d->m_treeView, &QAbstractItemView::activated, this, [this](const QModelIndex &index) {
0415         d->slotExpand(index);
0416     });
0417 
0418     connect(d->m_treeView, &QWidget::customContextMenuRequested, this, [this](const QPoint &pos) {
0419         d->slotContextMenuRequested(pos);
0420     });
0421 
0422     connect(d->m_urlCombo, &QComboBox::editTextChanged, this, [this](const QString &text) {
0423         d->slotComboTextChanged(text);
0424     });
0425 
0426     connect(d->m_urlCombo, &QComboBox::textActivated, this, [this](const QString &text) {
0427         d->slotUrlActivated(text);
0428     });
0429 
0430     connect(d->m_urlCombo, QOverload<const QString &>::of(&KComboBox::returnPressed), this, [this](const QString &text) {
0431         d->slotUrlActivated(text);
0432     });
0433 
0434     setCurrentUrl(d->m_startURL);
0435 }
0436 
0437 KDirSelectDialog::~KDirSelectDialog()
0438 {
0439     delete d;
0440 }
0441 
0442 QUrl KDirSelectDialog::url() const
0443 {
0444     QUrl comboUrl = QUrl::fromUserInput(d->m_urlCombo->currentText());
0445 
0446     if (comboUrl.isValid()) {
0447         KIO::StatJob *statJob = KIO::stat(comboUrl, KIO::HideProgressInfo);
0448         KJobWidgets::setWindow(statJob, d->m_parent);
0449         const bool ok = statJob->exec();
0450         if (ok && statJob->statResult().isDir()) {
0451             return comboUrl;
0452         }
0453     }
0454 
0455     // qDebug() << comboUrl.path() << " is not an accessible directory";
0456     return d->m_treeView->currentUrl();
0457 }
0458 
0459 QUrl KDirSelectDialog::rootUrl() const
0460 {
0461     return d->m_rootUrl;
0462 }
0463 
0464 QAbstractItemView *KDirSelectDialog::view() const
0465 {
0466     return d->m_treeView;
0467 }
0468 
0469 bool KDirSelectDialog::localOnly() const
0470 {
0471     return d->m_localOnly;
0472 }
0473 
0474 QUrl KDirSelectDialog::startDir() const
0475 {
0476     return d->m_startDir;
0477 }
0478 
0479 void KDirSelectDialog::setCurrentUrl(const QUrl &url)
0480 {
0481     if (!url.isValid()) {
0482         return;
0483     }
0484 
0485     if (url.scheme() != d->m_rootUrl.scheme()) {
0486         QUrl u(url);
0487         // We need the url to end with / because some code ahead (kdirmodel) is expecting
0488         // to find the / separator. It can happen that a valid url like smb: does not have
0489         // one so we should add it.
0490         if (!u.toString().endsWith(QLatin1Char('/'))) {
0491             u.setPath(QStringLiteral("/"));
0492         }
0493 
0494         d->m_treeView->setRootUrl(u);
0495         d->m_rootUrl = u;
0496     }
0497 
0498     // Check if url represents a hidden folder and enable showing them
0499     QString fileName = url.fileName();
0500     // TODO a better hidden file check?
0501     bool isHidden = fileName.length() > 1 && fileName[0] == QLatin1Char('.') && (fileName.length() > 2 ? fileName[1] != QLatin1Char('.') : true);
0502     bool showHiddenFiles = isHidden && !d->m_treeView->showHiddenFiles();
0503     if (showHiddenFiles) {
0504         d->showHiddenFoldersAction->setChecked(true);
0505         d->m_treeView->setShowHiddenFiles(true);
0506     }
0507 
0508     d->m_treeView->setCurrentUrl(url);
0509 }
0510 
0511 void KDirSelectDialog::accept()
0512 {
0513     QUrl selectedUrl = url();
0514     if (!selectedUrl.isValid()) {
0515         return;
0516     }
0517 
0518     if (!d->m_recentDirClass.isEmpty()) {
0519         KRecentDirs::add(d->m_recentDirClass, selectedUrl.toString());
0520     }
0521 
0522     d->m_urlCombo->addToHistory(selectedUrl.toDisplayString());
0523     KFileWidget::setStartDir(url());
0524 
0525     QDialog::accept();
0526 }
0527 
0528 void KDirSelectDialog::hideEvent(QHideEvent *event)
0529 {
0530     d->saveConfig(KSharedConfig::openConfig(), QStringLiteral("DirSelect Dialog"));
0531 
0532     QDialog::hideEvent(event);
0533 }
0534 
0535 // static
0536 QUrl KDirSelectDialog::selectDirectory(const QUrl &startDir, bool localOnly, QWidget *parent, const QString &caption)
0537 {
0538     KDirSelectDialog myDialog(startDir, localOnly, parent);
0539 
0540     if (!caption.isNull()) {
0541         myDialog.setWindowTitle(caption);
0542     }
0543 
0544     if (myDialog.exec() == QDialog::Accepted) {
0545         QUrl url = myDialog.url();
0546 
0547         // Returning the most local url
0548         if (url.isLocalFile()) {
0549             return url;
0550         }
0551 
0552         KIO::StatJob *job = KIO::stat(url);
0553         KJobWidgets::setWindow(job, parent);
0554 
0555         if (!job->exec()) {
0556             return url;
0557         }
0558 
0559         KIO::UDSEntry entry = job->statResult();
0560         const QString path = entry.stringValue(KIO::UDSEntry::UDS_LOCAL_PATH);
0561 
0562         return path.isEmpty() ? url : QUrl::fromLocalFile(path);
0563     } else {
0564         return QUrl();
0565     }
0566 }
0567 
0568 QUrl KDirSelectDialog::directory()
0569 {
0570     return url();
0571 }
0572 
0573 QList<QUrl> KDirSelectDialog::selectedFiles()
0574 {
0575     return QList<QUrl>() << url();
0576 }
0577 
0578 void KDirSelectDialog::setOkButtonText(const QString &text)
0579 {
0580     d->m_buttons->button(QDialogButtonBox::Ok)->setText(text);
0581 }
0582 
0583 void KDirSelectDialog::setCancelButtonText(const QString &text)
0584 {
0585     d->m_buttons->button(QDialogButtonBox::Cancel)->setText(text);
0586 }
0587 
0588 void KDirSelectDialog::setDirectory(const QUrl &directory)
0589 {
0590     setCurrentUrl(directory);
0591 }
0592 
0593 QString KDirSelectDialog::selectedMimeTypeFilter()
0594 {
0595     return QString();
0596 }
0597 
0598 QString KDirSelectDialog::selectedNameFilter()
0599 {
0600     return QString();
0601 }
0602 
0603 QString KDirSelectDialog::currentFilterText()
0604 {
0605     return QString();
0606 }
0607 
0608 void KDirSelectDialog::selectFile(const QUrl &filename)
0609 {
0610     Q_UNUSED(filename)
0611 }
0612 
0613 void KDirSelectDialog::selectMimeTypeFilter(const QString &filter)
0614 {
0615     Q_UNUSED(filter)
0616 }
0617 
0618 void KDirSelectDialog::selectNameFilter(const QString &filter)
0619 {
0620     Q_UNUSED(filter)
0621 }
0622 
0623 #include "moc_kdirselectdialog_p.cpp"