Changeset View
Changeset View
Standalone View
Standalone View
src/filewidgets/kurlnavigator.cpp
Show First 20 Lines • Show All 186 Lines • ▼ Show 20 Line(s) | 68 | public: | |||
---|---|---|---|---|---|
187 | KUrlNavigatorProtocolCombo *m_protocols; | 187 | KUrlNavigatorProtocolCombo *m_protocols; | ||
188 | KUrlNavigatorDropDownButton *m_dropDownButton; | 188 | KUrlNavigatorDropDownButton *m_dropDownButton; | ||
189 | QList<KUrlNavigatorButton *> m_navButtons; | 189 | QList<KUrlNavigatorButton *> m_navButtons; | ||
190 | KUrlNavigatorButtonBase *m_toggleEditableMode; | 190 | KUrlNavigatorButtonBase *m_toggleEditableMode; | ||
191 | QUrl m_homeUrl; | 191 | QUrl m_homeUrl; | ||
192 | QStringList m_customProtocols; | 192 | QStringList m_customProtocols; | ||
193 | QWidget *m_dropWidget; | 193 | QWidget *m_dropWidget; | ||
194 | KUrlNavigator *q; | 194 | KUrlNavigator *q; | ||
195 | KUrlCompletion *m_urlCompletion; | ||||
195 | }; | 196 | }; | ||
196 | 197 | | |||
197 | KUrlNavigator::Private::Private(KUrlNavigator *q, KFilePlacesModel *placesModel) : | 198 | KUrlNavigator::Private::Private(KUrlNavigator *q, KFilePlacesModel *placesModel) : | ||
198 | m_editable(false), | 199 | m_editable(false), | ||
199 | m_active(true), | 200 | m_active(true), | ||
200 | m_showPlacesSelector(placesModel != nullptr), | 201 | m_showPlacesSelector(placesModel != nullptr), | ||
201 | m_showFullPath(false), | 202 | m_showFullPath(false), | ||
202 | m_historyIndex(0), | 203 | m_historyIndex(0), | ||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 215 | { | |||
245 | connect(m_dropDownButton, SIGNAL(clicked()), | 246 | connect(m_dropDownButton, SIGNAL(clicked()), | ||
246 | q, SLOT(openPathSelectorMenu())); | 247 | q, SLOT(openPathSelectorMenu())); | ||
247 | 248 | | |||
248 | // initialize the path box of the traditional view | 249 | // initialize the path box of the traditional view | ||
249 | m_pathBox = new KUrlComboBox(KUrlComboBox::Directories, true, q); | 250 | m_pathBox = new KUrlComboBox(KUrlComboBox::Directories, true, q); | ||
250 | m_pathBox->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength); | 251 | m_pathBox->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength); | ||
251 | m_pathBox->installEventFilter(q); | 252 | m_pathBox->installEventFilter(q); | ||
252 | 253 | | |||
253 | KUrlCompletion *kurlCompletion = new KUrlCompletion(KUrlCompletion::DirCompletion); | 254 | m_urlCompletion = new KUrlCompletion(KUrlCompletion::DirCompletion); | ||
254 | m_pathBox->setCompletionObject(kurlCompletion); | 255 | m_pathBox->setCompletionObject(m_urlCompletion); | ||
255 | m_pathBox->setAutoDeleteCompletionObject(true); | 256 | m_pathBox->setAutoDeleteCompletionObject(true); | ||
256 | 257 | | |||
257 | connect(m_pathBox, SIGNAL(returnPressed()), | 258 | connect(m_pathBox, SIGNAL(returnPressed()), | ||
258 | q, SLOT(slotReturnPressed())); | 259 | q, SLOT(slotReturnPressed())); | ||
259 | connect(m_pathBox, SIGNAL(urlActivated(QUrl)), | 260 | connect(m_pathBox, SIGNAL(urlActivated(QUrl)), | ||
260 | q, SLOT(setLocationUrl(QUrl))); | 261 | q, SLOT(setLocationUrl(QUrl))); | ||
261 | connect(m_pathBox, SIGNAL(editTextChanged(QString)), | 262 | connect(m_pathBox, SIGNAL(editTextChanged(QString)), | ||
262 | q, SLOT(slotPathBoxChanged(QString))); | 263 | q, SLOT(slotPathBoxChanged(QString))); | ||
▲ Show 20 Lines • Show All 734 Lines • ▼ Show 20 Line(s) | |||||
997 | 998 | | |||
998 | bool KUrlNavigator::isPlacesSelectorVisible() const | 999 | bool KUrlNavigator::isPlacesSelectorVisible() const | ||
999 | { | 1000 | { | ||
1000 | return d->m_showPlacesSelector; | 1001 | return d->m_showPlacesSelector; | ||
1001 | } | 1002 | } | ||
1002 | 1003 | | |||
1003 | QUrl KUrlNavigator::uncommittedUrl() const | 1004 | QUrl KUrlNavigator::uncommittedUrl() const | ||
1004 | { | 1005 | { | ||
1005 | KUriFilterData filteredData(d->m_pathBox->currentText().trimmed()); | 1006 | QString input = d->m_pathBox->currentText().trimmed(); | ||
1007 | | ||||
1008 | // Always expand starting ~/ to $HOME. We want all inputs starting with it to point home directory. | ||||
1009 | // The reason this expansion is performed here, is that kshorturifilter will not return the desired result | ||||
dfaure: This is written like kshorturifilter is buggy...
I looked into it to see if there was a good… | |||||
1010 | // if said directory does not exist. | ||||
1011 | if (input.startsWith(QStringLiteral("~/"))) { | ||||
1012 | input.replace(0, 1, QDir::homePath()); | ||||
1013 | } | ||||
1014 | | ||||
1015 | const QUrl url = QUrl::fromUserInput(input, directory().path(), QUrl::AssumeLocalFile); | ||||
1016 | KUriFilterData filteredData(url, input); | ||||
1006 | filteredData.setCheckForExecutables(false); | 1017 | filteredData.setCheckForExecutables(false); | ||
1018 | | ||||
1007 | if (KUriFilter::self()->filterUri(filteredData, QStringList() << QStringLiteral("kshorturifilter") << QStringLiteral("kurisearchfilter"))) { | 1019 | if (KUriFilter::self()->filterUri(filteredData, QStringList() << QStringLiteral("kshorturifilter") << QStringLiteral("kurisearchfilter"))) { | ||
1008 | return filteredData.uri(); | 1020 | return filteredData.uri(); | ||
1009 | } else { | | |||
1010 | return QUrl::fromUserInput(filteredData.typedString()); | | |||
1011 | } | 1021 | } | ||
1022 | | ||||
1023 | return url; | ||||
1012 | } | 1024 | } | ||
1013 | 1025 | | |||
1014 | void KUrlNavigator::setLocationUrl(const QUrl &newUrl) | 1026 | void KUrlNavigator::setLocationUrl(const QUrl &newUrl) | ||
1015 | { | 1027 | { | ||
1016 | if (newUrl == locationUrl()) { | 1028 | if (newUrl == locationUrl()) { | ||
1017 | return; | 1029 | return; | ||
1018 | } | 1030 | } | ||
1019 | 1031 | | |||
▲ Show 20 Lines • Show All 209 Lines • ▼ Show 20 Line(s) | 1240 | { | |||
1229 | return d->m_customProtocols; | 1241 | return d->m_customProtocols; | ||
1230 | } | 1242 | } | ||
1231 | 1243 | | |||
1232 | QWidget *KUrlNavigator::dropWidget() const | 1244 | QWidget *KUrlNavigator::dropWidget() const | ||
1233 | { | 1245 | { | ||
1234 | return d->m_dropWidget; | 1246 | return d->m_dropWidget; | ||
1235 | } | 1247 | } | ||
1236 | 1248 | | |||
1249 | void KUrlNavigator::setDirectory(const QUrl &url) | ||||
1250 | { | ||||
1251 | d->m_urlCompletion->setDir(url); | ||||
1252 | } | ||||
1253 | | ||||
1254 | QUrl KUrlNavigator::directory() const | ||||
1255 | { | ||||
1256 | return d->m_urlCompletion->dir(); | ||||
1257 | } | ||||
1258 | | ||||
1259 | | ||||
1237 | #ifndef KIOFILEWIDGETS_NO_DEPRECATED | 1260 | #ifndef KIOFILEWIDGETS_NO_DEPRECATED | ||
1238 | const QUrl &KUrlNavigator::url() const | 1261 | const QUrl &KUrlNavigator::url() const | ||
1239 | { | 1262 | { | ||
1240 | // deprecated | 1263 | // deprecated | ||
1241 | 1264 | | |||
1242 | // Workaround required because of flawed interface ('const QUrl&' is returned | 1265 | // Workaround required because of flawed interface ('const QUrl&' is returned | ||
1243 | // instead of 'QUrl'): remember the URL to prevent a dangling pointer | 1266 | // instead of 'QUrl'): remember the URL to prevent a dangling pointer | ||
1244 | static QUrl url; | 1267 | static QUrl url; | ||
▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines |
This is written like kshorturifilter is buggy...
I looked into it to see if there was a good reason why kshorturifilter returns Error in case of a non-existing local path, but in fact.... it doesn't really have to.
If the user types a non-existing path in a URL bar then opening that path will error anyway, there's no need to catch that at the kurifilter level.
I'm working on a fix for kshorturifilter.