Changeset View
Changeset View
Standalone View
Standalone View
src/filewidgets/kdiroperator.cpp
Show First 20 Lines • Show All 181 Lines • ▼ Show 20 Line(s) | 171 | public: | |||
---|---|---|---|---|---|
182 | bool checkPreviewInternal() const; | 182 | bool checkPreviewInternal() const; | ||
183 | void checkPath(const QString &txt, bool takeFiles = false); | 183 | void checkPath(const QString &txt, bool takeFiles = false); | ||
184 | bool openUrl(const QUrl &url, KDirLister::OpenUrlFlags flags = KDirLister::NoFlags); | 184 | bool openUrl(const QUrl &url, KDirLister::OpenUrlFlags flags = KDirLister::NoFlags); | ||
185 | int sortColumn() const; | 185 | int sortColumn() const; | ||
186 | Qt::SortOrder sortOrder() const; | 186 | Qt::SortOrder sortOrder() const; | ||
187 | void updateSorting(QDir::SortFlags sort); | 187 | void updateSorting(QDir::SortFlags sort); | ||
188 | 188 | | |||
189 | static bool isReadable(const QUrl &url); | 189 | static bool isReadable(const QUrl &url); | ||
190 | bool isSchemeSupported(const QString &scheme) const; | ||||
190 | 191 | | |||
191 | KFile::FileView allViews(); | 192 | KFile::FileView allViews(); | ||
192 | 193 | | |||
193 | // private slots | 194 | // private slots | ||
194 | void _k_slotDetailedView(); | 195 | void _k_slotDetailedView(); | ||
195 | void _k_slotSimpleView(); | 196 | void _k_slotSimpleView(); | ||
196 | void _k_slotTreeView(); | 197 | void _k_slotTreeView(); | ||
197 | void _k_slotDetailedTreeView(); | 198 | void _k_slotDetailedTreeView(); | ||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Line(s) | |||||
284 | 285 | | |||
285 | bool isSaving; | 286 | bool isSaving; | ||
286 | 287 | | |||
287 | KActionMenu *decorationMenu; | 288 | KActionMenu *decorationMenu; | ||
288 | KToggleAction *leftAction; | 289 | KToggleAction *leftAction; | ||
289 | QList<QUrl> itemsToBeSetAsCurrent; | 290 | QList<QUrl> itemsToBeSetAsCurrent; | ||
290 | bool shouldFetchForItems; | 291 | bool shouldFetchForItems; | ||
291 | InlinePreviewState inlinePreviewState; | 292 | InlinePreviewState inlinePreviewState; | ||
293 | QStringList supportedSchemes; | ||||
292 | }; | 294 | }; | ||
293 | 295 | | |||
294 | KDirOperator::Private::Private(KDirOperator *_parent) : | 296 | KDirOperator::Private::Private(KDirOperator *_parent) : | ||
295 | parent(_parent), | 297 | parent(_parent), | ||
296 | dirLister(nullptr), | 298 | dirLister(nullptr), | ||
297 | decorationPosition(QStyleOptionViewItem::Left), | 299 | decorationPosition(QStyleOptionViewItem::Left), | ||
298 | splitter(nullptr), | 300 | splitter(nullptr), | ||
299 | itemView(nullptr), | 301 | itemView(nullptr), | ||
▲ Show 20 Lines • Show All 693 Lines • ▼ Show 20 Line(s) | 994 | if (!newurl.path().isEmpty() && !newurl.path().endsWith(QLatin1Char('/'))) { | |||
993 | newurl.setPath(newurl.path() + QLatin1Char('/')); | 995 | newurl.setPath(newurl.path() + QLatin1Char('/')); | ||
994 | } | 996 | } | ||
995 | 997 | | |||
996 | // already set | 998 | // already set | ||
997 | if (newurl.matches(d->currUrl, QUrl::StripTrailingSlash)) { | 999 | if (newurl.matches(d->currUrl, QUrl::StripTrailingSlash)) { | ||
998 | return; | 1000 | return; | ||
999 | } | 1001 | } | ||
1000 | 1002 | | |||
1003 | if (!d->isSchemeSupported(newurl.scheme())) | ||||
1004 | return; | ||||
1005 | | ||||
1001 | if (!Private::isReadable(newurl)) { | 1006 | if (!Private::isReadable(newurl)) { | ||
1002 | // maybe newurl is a file? check its parent directory | 1007 | // maybe newurl is a file? check its parent directory | ||
1003 | newurl = newurl.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash); | 1008 | newurl = newurl.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash); | ||
1004 | if (newurl.matches(d->currUrl, QUrl::StripTrailingSlash)) { | 1009 | if (newurl.matches(d->currUrl, QUrl::StripTrailingSlash)) { | ||
1005 | return; // parent is current dir, nothing to do (fixes #173454, too) | 1010 | return; // parent is current dir, nothing to do (fixes #173454, too) | ||
1006 | } | 1011 | } | ||
1007 | KIO::StatJob *job = KIO::stat(newurl); | 1012 | KIO::StatJob *job = KIO::stat(newurl); | ||
1008 | KJobWidgets::setWindow(job, this); | 1013 | KJobWidgets::setWindow(job, this); | ||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | |||||
1055 | } | 1060 | } | ||
1056 | 1061 | | |||
1057 | void KDirOperator::rereadDir() | 1062 | void KDirOperator::rereadDir() | ||
1058 | { | 1063 | { | ||
1059 | pathChanged(); | 1064 | pathChanged(); | ||
1060 | d->openUrl(d->currUrl, KDirLister::Reload); | 1065 | d->openUrl(d->currUrl, KDirLister::Reload); | ||
1061 | } | 1066 | } | ||
1062 | 1067 | | |||
1068 | bool KDirOperator::Private::isSchemeSupported(const QString &scheme) const | ||||
1069 | { | ||||
1070 | return supportedSchemes.isEmpty() || supportedSchemes.contains(scheme); | ||||
1071 | } | ||||
1072 | | ||||
1063 | bool KDirOperator::Private::openUrl(const QUrl &url, KDirLister::OpenUrlFlags flags) | 1073 | bool KDirOperator::Private::openUrl(const QUrl &url, KDirLister::OpenUrlFlags flags) | ||
1064 | { | 1074 | { | ||
1065 | const bool result = KProtocolManager::supportsListing(url) && dirLister->openUrl(url, flags); | 1075 | const bool result = KProtocolManager::supportsListing(url) | ||
1076 | && isSchemeSupported(url.scheme()) | ||||
1077 | && dirLister->openUrl(url, flags); | ||||
1066 | if (!result) { // in that case, neither completed() nor canceled() will be emitted by KDL | 1078 | if (!result) { // in that case, neither completed() nor canceled() will be emitted by KDL | ||
1067 | _k_slotCanceled(); | 1079 | _k_slotCanceled(); | ||
1068 | } | 1080 | } | ||
1069 | 1081 | | |||
1070 | return result; | 1082 | return result; | ||
1071 | } | 1083 | } | ||
1072 | 1084 | | |||
1073 | int KDirOperator::Private::sortColumn() const | 1085 | int KDirOperator::Private::sortColumn() const | ||
▲ Show 20 Lines • Show All 1555 Lines • ▼ Show 20 Line(s) | 2637 | { | |||
2629 | return QDir(url.toLocalFile()).isReadable(); | 2641 | return QDir(url.toLocalFile()).isReadable(); | ||
2630 | } | 2642 | } | ||
2631 | 2643 | | |||
2632 | void KDirOperator::Private::_k_slotDirectoryCreated(const QUrl &url) | 2644 | void KDirOperator::Private::_k_slotDirectoryCreated(const QUrl &url) | ||
2633 | { | 2645 | { | ||
2634 | parent->setUrl(url, true); | 2646 | parent->setUrl(url, true); | ||
2635 | } | 2647 | } | ||
2636 | 2648 | | |||
2649 | void KDirOperator::setSupportedSchemes(const QStringList &schemes) | ||||
2650 | { | ||||
2651 | d->supportedSchemes = schemes; | ||||
apol: only if d->supportedSchemes != schemes? | |||||
2652 | rereadDir(); | ||||
2653 | } | ||||
2654 | | ||||
2655 | QStringList KDirOperator::supportedSchemes() const | ||||
2656 | { | ||||
2657 | return d->supportedSchemes; | ||||
2658 | } | ||||
2659 | | ||||
2637 | #include "moc_kdiroperator.cpp" | 2660 | #include "moc_kdiroperator.cpp" | ||
2638 | #include "kdiroperator.moc" | 2661 | #include "kdiroperator.moc" |
only if d->supportedSchemes != schemes?