10#include "kurlnavigator.h"
11#include "kcoreurlnavigator.h"
13#include "../utils_p.h"
14#include "kurlnavigatorbutton_p.h"
15#include "kurlnavigatordropdownbutton_p.h"
16#include "kurlnavigatorpathselectoreventfilter_p.h"
17#include "kurlnavigatorplacesselector_p.h"
18#include "kurlnavigatorschemecombo_p.h"
19#include "kurlnavigatortogglebutton_p.h"
22#include <KLocalizedString>
24#include <kfileplacesmodel.h>
25#include <kprotocolinfo.h>
26#include <kurifilter.h>
27#include <kurlcombobox.h>
28#include <kurlcompletion.h>
30#include <QActionGroup>
31#include <QApplication>
40#include <QMimeDatabase>
50using namespace KDEPrivate;
52struct KUrlNavigatorData {
55Q_DECLARE_METATYPE(KUrlNavigatorData)
57class KUrlNavigatorPrivate
60 KUrlNavigatorPrivate(
const QUrl &url, KUrlNavigator *qq, KFilePlacesModel *placesModel);
62 ~KUrlNavigatorPrivate()
64 m_dropDownButton->removeEventFilter(q);
65 m_pathBox->removeEventFilter(q);
66 m_toggleEditableMode->removeEventFilter(q);
68 for (KUrlNavigatorButton *button : std::as_const(m_navButtons)) {
69 button->removeEventFilter(q);
73 enum class ApplyUrlMethod {
81 void applyUncommittedUrl(ApplyUrlMethod method);
82 void slotApplyUrl(QUrl url);
86 std::optional<QUrl> checkFilters(
const QString &text);
88 void slotReturnPressed();
89 void slotSchemeChanged(
const QString &);
90 void openPathSelectorMenu();
97 void appendWidget(QWidget *widget,
int stretch = 0);
103 void slotToggleEditableButtonPressed();
112 void dropUrls(
const QUrl &destination, QDropEvent *event, KUrlNavigatorButton *dropButton);
125 void openContextMenu(
const QPoint &p);
127 void slotPathBoxChanged(
const QString &text);
129 void updateContent();
139 void updateButtons(
int startIndex);
146 void updateButtonVisibility();
154 void updateTabOrder();
159 QString firstButtonText()
const;
164 QUrl buttonUrl(
int index)
const;
166 void switchToBreadcrumbMode();
172 void deleteButtons();
181 QUrl retrievePlaceUrl()
const;
183 KUrlNavigator *
const q;
185 QHBoxLayout *m_layout =
new QHBoxLayout(q);
186 KCoreUrlNavigator *m_coreUrlNavigator =
nullptr;
187 QList<KUrlNavigatorButton *> m_navButtons;
188 QStringList m_supportedSchemes;
190 KUrlNavigatorPlacesSelector *m_placesSelector =
nullptr;
191 KUrlComboBox *m_pathBox =
nullptr;
192 KUrlNavigatorSchemeCombo *m_schemes =
nullptr;
193 KUrlNavigatorDropDownButton *m_dropDownButton =
nullptr;
194 KUrlNavigatorButtonBase *m_toggleEditableMode =
nullptr;
195 QWidget *m_dropWidget =
nullptr;
196 QWidget *m_badgeWidgetContainer =
nullptr;
198 bool m_editable =
false;
199 bool m_active =
true;
200 bool m_showPlacesSelector =
false;
201 bool m_showFullPath =
false;
206 bool showHidden =
false;
207 bool sortHiddenLast =
false;
208 } m_subfolderOptions;
214 , m_showPlacesSelector(placesModel != nullptr)
216 m_layout->setSpacing(0);
217 m_layout->setContentsMargins(0, 0, 0, 0);
219 q->connect(m_coreUrlNavigator, &KCoreUrlNavigator::currentLocationUrlChanged, q, [
this]() {
220 Q_EMIT q->urlChanged(m_coreUrlNavigator->currentLocationUrl());
223 Q_EMIT q->urlAboutToBeChanged(url);
225 q->connect(m_coreUrlNavigator, &KCoreUrlNavigator::historySizeChanged, q, [
this]() {
226 Q_EMIT q->historyChanged();
228 q->connect(m_coreUrlNavigator, &KCoreUrlNavigator::historyIndexChanged, q, [
this]() {
229 Q_EMIT q->historyChanged();
232 Q_EMIT q->historyChanged();
235 Q_EMIT q->urlSelectionRequested(url);
239 q->setAutoFillBackground(
false);
241 if (placesModel !=
nullptr) {
242 m_placesSelector =
new KUrlNavigatorPlacesSelector(q, placesModel);
246 auto updateContentFunc = [
this]() {
255 m_schemes =
new KUrlNavigatorSchemeCombo(
QString(), q);
256 q->connect(m_schemes, &KUrlNavigatorSchemeCombo::activated, q, [
this](
const QString &schene) {
257 slotSchemeChanged(schene);
261 m_dropDownButton =
new KUrlNavigatorDropDownButton(q);
263 m_dropDownButton->installEventFilter(q);
264 q->connect(m_dropDownButton, &KUrlNavigatorDropDownButton::clicked, q, [
this]() {
265 openPathSelectorMenu();
269 m_pathBox =
new KUrlComboBox(KUrlComboBox::Directories,
true, q);
271 m_pathBox->installEventFilter(q);
272 m_pathBox->setAutoFillBackground(
false);
274 m_pathBox->setFrame(
false);
277 m_pathBox->setCompletionObject(kurlCompletion);
278 m_pathBox->setAutoDeleteCompletionObject(
true);
286 slotPathBoxChanged(text);
289 m_badgeWidgetContainer =
new QWidget(q);
290 auto badgeLayout =
new QHBoxLayout(m_badgeWidgetContainer);
291 badgeLayout->setContentsMargins(0, 0, 0, 0);
295 m_toggleEditableMode =
new KUrlNavigatorToggleButton(q);
296 m_toggleEditableMode->installEventFilter(q);
297 m_toggleEditableMode->setMinimumWidth(20);
298 q->connect(m_toggleEditableMode, &KUrlNavigatorToggleButton::clicked, q, [
this]() {
299 slotToggleEditableButtonPressed();
302 if (m_placesSelector !=
nullptr) {
303 m_layout->addWidget(m_placesSelector);
305 m_layout->addWidget(m_schemes);
306 m_layout->addWidget(m_dropDownButton);
307 m_layout->addWidget(m_pathBox, 1);
308 m_layout->addWidget(m_badgeWidgetContainer);
309 m_layout->addWidget(m_toggleEditableMode);
319 q->setContentsMargins(paddingLeft, 0, paddingRight, 0);
320 m_pathBox->setContentsMargins(paddingLeft, 0, paddingRight, 0);
323void KUrlNavigatorPrivate::appendWidget(
QWidget *widget,
int stretch)
326 m_layout->insertWidget(m_layout->count() - 2, widget, stretch);
329void KUrlNavigatorPrivate::slotApplyUrl(
QUrl url)
339 url.
setPath(QStringLiteral(
"/"));
343 QStringList urls = m_pathBox->urls();
346 m_pathBox->setUrls(urls, KUrlComboBox::RemoveBottom);
348 q->setLocationUrl(url);
351 m_pathBox->setUrl(q->locationUrl());
354std::optional<QUrl> KUrlNavigatorPrivate::checkFilters(
const QString &text)
356 KUriFilterData filteredData(text);
357 filteredData.setCheckForExecutables(
false);
359 const auto filtersList = QStringList{QStringLiteral(
"kshorturifilter")};
362 return filteredData.uri();
367void KUrlNavigatorPrivate::applyUncommittedUrl(ApplyUrlMethod method)
369 const QString text = m_pathBox->currentText().
trimmed();
370 QUrl url = q->locationUrl();
372 auto applyUrl = [
this, method](
const QUrl &url) {
374 case ApplyUrlMethod::Apply:
377 case ApplyUrlMethod::Tab:
378 Q_EMIT q->tabRequested(url);
380 case ApplyUrlMethod::ActiveTab:
381 Q_EMIT q->activeTabRequested(url);
383 case ApplyUrlMethod::NewWindow:
384 Q_EMIT q->newWindowRequested(url);
394 if (
const auto filteredUrl = checkFilters(text); filteredUrl) {
395 applyUrl(*filteredUrl);
411 q->connect(job, &
KJob::result, q, [
this, job, text, applyUrl]() {
415 if (!job->error() && job->statResult().isDir()) {
416 applyUrl(job->url());
421 if (
const auto filteredUrl = checkFilters(text); filteredUrl) {
422 applyUrl(*filteredUrl);
431void KUrlNavigatorPrivate::slotReturnPressed()
437 applyUncommittedUrl(ApplyUrlMethod::Tab);
439 applyUncommittedUrl(ApplyUrlMethod::ActiveTab);
442 applyUncommittedUrl(ApplyUrlMethod::NewWindow);
444 applyUncommittedUrl(ApplyUrlMethod::Apply);
446 Q_EMIT q->returnPressed();
453 auto switchModeFunc = [
this]() {
454 switchToBreadcrumbMode();
460void KUrlNavigatorPrivate::slotSchemeChanged(
const QString &scheme)
462 Q_ASSERT(m_editable);
470 url.
setPath(QStringLiteral(
"/"));
477 m_pathBox->setEditUrl(url);
480void KUrlNavigatorPrivate::openPathSelectorMenu()
482 if (m_navButtons.count() <= 0) {
486 const QUrl firstVisibleUrl = m_navButtons.constFirst()->url();
489 QPointer<QMenu> popup =
new QMenu(q);
491 auto *popupFilter =
new KUrlNavigatorPathSelectorEventFilter(popup.
data());
493 popup->installEventFilter(popupFilter);
495 const QUrl placeUrl = retrievePlaceUrl();
496 int idx = placeUrl.
path().
count(QLatin1Char(
'/'));
499 const QString
path = m_coreUrlNavigator->locationUrl(m_coreUrlNavigator->historyIndex()).path();
500 QString dirName =
path.
section(QLatin1Char(
'/'), idx, idx);
503 dirName = QStringLiteral(
"/");
509 const QString text = spacer + dirName;
511 QAction *action =
new QAction(text, popup);
512 const QUrl currentUrl = buttonUrl(idx);
513 if (currentUrl == firstVisibleUrl) {
514 popup->addSeparator();
517 popup->addAction(action);
520 spacer.
append(QLatin1String(
" "));
521 dirName =
path.
section(QLatin1Char(
'/'), idx, idx);
522 }
while (!dirName.isEmpty());
524 const QPoint pos = q->mapToGlobal(m_dropDownButton->geometry().bottomRight());
525 const QAction *activatedAction = popup->exec(pos);
526 if (activatedAction !=
nullptr) {
528 q->setLocationUrl(url);
533 popup->deleteLater();
537void KUrlNavigatorPrivate::slotToggleEditableButtonPressed()
540 applyUncommittedUrl(ApplyUrlMethod::Apply);
546void KUrlNavigatorPrivate::switchView()
548 m_toggleEditableMode->setFocus();
549 m_editable = !m_editable;
550 m_toggleEditableMode->setChecked(m_editable);
552 if (q->isUrlEditable()) {
553 m_pathBox->setFocus();
556 q->requestActivation();
557 Q_EMIT q->editableStateChanged(m_editable);
560void KUrlNavigatorPrivate::dropUrls(
const QUrl &destination,
QDropEvent *event, KUrlNavigatorButton *dropButton)
562 if (
event->mimeData()->hasUrls()) {
563 m_dropWidget = qobject_cast<QWidget *>(dropButton);
564 Q_EMIT q->urlsDropped(destination, event);
571 Q_EMIT q->activeTabRequested(url);
573 Q_EMIT q->tabRequested(url);
575 Q_EMIT q->newWindowRequested(url);
577 q->setLocationUrl(url);
581void KUrlNavigatorPrivate::openContextMenu(
const QPoint &p)
585 QPointer<QMenu> popup =
new QMenu(q);
589 QAction *copyAction = popup->addAction(
QIcon::fromTheme(QStringLiteral(
"edit-copy")),
i18n(
"Copy"));
593 QAction *pasteAction = popup->addAction(
QIcon::fromTheme(QStringLiteral(
"edit-paste")),
i18n(
"Paste"));
597 popup->addSeparator();
603 if (isTabSignal || isWindowSignal) {
604 auto it = std::find_if(m_navButtons.cbegin(), m_navButtons.cend(), [&p](
const KUrlNavigatorButton *button) {
605 return button->geometry().contains(p);
607 if (it != m_navButtons.cend()) {
608 const auto *button = *it;
609 const QUrl url = button->
url();
610 const QString text = button->text();
613 QAction *openInTab = popup->addAction(
QIcon::fromTheme(QStringLiteral(
"tab-new")),
i18nc(
"@item:inmenu",
"Open \"%1\" in New Tab", text));
615 Q_EMIT q->tabRequested(url);
619 if (isWindowSignal) {
620 QAction *openInWindow =
621 popup->addAction(
QIcon::fromTheme(QStringLiteral(
"window-new")),
i18nc(
"@item:inmenu",
"Open \"%1\" in New Window", text));
623 Q_EMIT q->newWindowRequested(url);
630 QAction *editAction = popup->addAction(
i18n(
"Edit"));
633 QAction *navigateAction = popup->addAction(
i18n(
"Navigate"));
636 QActionGroup *modeGroup =
new QActionGroup(popup);
639 if (q->isUrlEditable()) {
645 popup->addSeparator();
648 QAction *showFullPathAction = popup->addAction(
i18n(
"Show Full Path"));
650 showFullPathAction->
setChecked(q->showFullPath());
653 if (activatedAction == copyAction) {
654 QMimeData *mimeData =
new QMimeData();
657 }
else if (activatedAction == pasteAction) {
659 }
else if (activatedAction == editAction) {
660 q->setUrlEditable(
true);
661 }
else if (activatedAction == navigateAction) {
662 q->setUrlEditable(
false);
663 }
else if (activatedAction == showFullPathAction) {
664 q->setShowFullPath(showFullPathAction->
isChecked());
669 popup->deleteLater();
673void KUrlNavigatorPrivate::slotPathBoxChanged(
const QString &text)
676 const QString scheme = q->locationUrl().scheme();
677 m_schemes->setScheme(scheme);
678 if (m_supportedSchemes.count() != 1) {
688void KUrlNavigatorPrivate::updateContent()
690 const QUrl currentUrl = q->locationUrl();
691 if (m_placesSelector !=
nullptr) {
692 m_placesSelector->updateSelection(currentUrl);
697 m_dropDownButton->hide();
698 m_badgeWidgetContainer->hide();
705 m_pathBox->setUrl(currentUrl);
707 q->setTabOrder(m_pathBox, m_toggleEditableMode);
711 m_badgeWidgetContainer->show();
721 if ((m_placesSelector !=
nullptr) && !m_showFullPath) {
722 placeUrl = m_placesSelector->selectedPlaceUrl();
726 placeUrl = retrievePlaceUrl();
728 QString placePath = Utils::trailingSlashRemoved(placeUrl.
path());
730 const int startIndex = placePath.
count(QLatin1Char(
'/'));
731 updateButtons(startIndex);
735void KUrlNavigatorPrivate::updateButtons(
int startIndex)
737 QUrl currentUrl = q->locationUrl();
742 const QString
path = currentUrl.
path();
744 const int oldButtonCount = m_navButtons.
count();
746 int idx = startIndex;
749 const bool createButton = (idx - startIndex) >= oldButtonCount;
750 const bool isFirstButton = (idx == startIndex);
751 const QString dirName =
path.
section(QLatin1Char(
'/'), idx, idx);
752 hasNext = isFirstButton || !dirName.
isEmpty();
754 KUrlNavigatorButton *button =
nullptr;
756 button =
new KUrlNavigatorButton(buttonUrl(idx), q);
757 button->installEventFilter(q);
759 q->connect(button, &KUrlNavigatorButton::urlsDroppedOnNavButton, q, [
this, button](
const QUrl &destination, QDropEvent *event) {
760 dropUrls(destination, event, button);
764 slotNavigatorButtonClicked(url, btn, modifiers);
766 q->connect(button, &KUrlNavigatorButton::navigatorButtonActivated, q, activatedFunc);
768 q->connect(button, &KUrlNavigatorButton::finishedTextResolving, q, [
this]() {
769 updateButtonVisibility();
772 appendWidget(button);
774 button = m_navButtons[idx - startIndex];
775 button->setUrl(buttonUrl(idx));
779 button->setText(firstButtonText());
781 button->setActive(q->isActive());
784 if (!isFirstButton) {
785 q->setTabOrder(m_navButtons.constLast(), button);
787 m_navButtons.append(button);
791 button->setActiveSubDirectory(
path.
section(QLatin1Char(
'/'), idx, idx));
796 const int newButtonCount = idx - startIndex;
797 if (newButtonCount < oldButtonCount) {
798 const auto itBegin = m_navButtons.begin() + newButtonCount;
799 const auto itEnd = m_navButtons.end();
800 for (
auto it = itBegin; it != itEnd; ++it) {
803 navBtn->deleteLater();
805 m_navButtons.erase(itBegin, itEnd);
808 m_dropDownButton->setToolTip(
xi18nc(
"@info:tooltip for button. 1 is path",
809 "Go to any location on the path <filename>%1</filename>",
811 .
replace(QStringLiteral(
"///"), QStringLiteral(
"/")));
812 updateButtonVisibility();
815void KUrlNavigatorPrivate::updateButtonVisibility()
821 const int buttonsCount = m_navButtons.count();
822 if (buttonsCount == 0) {
823 m_dropDownButton->hide();
829 int availableWidth = q->width() - (m_padding * 2) - m_toggleEditableMode->minimumWidth();
831 availableWidth -= m_badgeWidgetContainer->width();
833 if ((m_placesSelector !=
nullptr) && m_placesSelector->isVisible()) {
834 availableWidth -= m_placesSelector->width();
837 if ((m_schemes !=
nullptr) && m_schemes->isVisible()) {
838 availableWidth -= m_schemes->width();
842 int requiredButtonWidth = 0;
843 for (
const auto *button : std::as_const(m_navButtons)) {
844 requiredButtonWidth += button->minimumWidth();
847 if (requiredButtonWidth > availableWidth) {
851 availableWidth -= m_dropDownButton->width();
855 bool isLastButton =
true;
856 bool hasHiddenButtons =
false;
857 QList<KUrlNavigatorButton *> buttonsToShow;
858 for (
auto it = m_navButtons.crbegin(); it != m_navButtons.crend(); ++it) {
859 KUrlNavigatorButton *button = *it;
860 availableWidth -= button->minimumWidth();
861 if ((availableWidth <= 0) && !isLastButton) {
863 hasHiddenButtons =
true;
870 buttonsToShow.
append(button);
872 isLastButton =
false;
877 for (KUrlNavigatorButton *button : std::as_const(buttonsToShow)) {
881 if (hasHiddenButtons) {
882 m_dropDownButton->show();
885 QUrl url(m_navButtons.front()->url());
887 && url.
scheme() != QLatin1String(
"baloosearch")
888 && url.
scheme() != QLatin1String(
"filenamesearch");
889 m_dropDownButton->setVisible(visible);
892 auto lastButton = m_navButtons.last();
893 for (
const auto &button : m_navButtons) {
894 if (button != lastButton) {
895 button->setDrawSeparator(
true);
897 button->setDrawSeparator(
false);
904void KUrlNavigatorPrivate::updateTabOrder()
906 QMultiMap<int, QWidget *> visibleChildrenSortedByX;
907 const auto childWidgets = q->findChildren<QWidget *>();
908 for (
auto childWidget : childWidgets) {
909 if (childWidget->isVisible()) {
911 visibleChildrenSortedByX.
insert(childWidget->x(), childWidget);
913 visibleChildrenSortedByX.
insert(-childWidget->x(), childWidget);
918 if (visibleChildrenSortedByX.
isEmpty()) {
921 q->setFocusProxy(visibleChildrenSortedByX.
first());
922 auto it = visibleChildrenSortedByX.
begin();
923 auto nextIt = ++visibleChildrenSortedByX.
begin();
924 while (nextIt != visibleChildrenSortedByX.
end()) {
925 q->setTabOrder(*it, *nextIt);
929 Q_EMIT q->layoutChanged();
932QString KUrlNavigatorPrivate::firstButtonText()
const
938 if ((m_placesSelector !=
nullptr) && !m_showFullPath) {
939 text = m_placesSelector->selectedPlaceText();
942 const QUrl currentUrl = q->locationUrl();
949 text = QStringLiteral(
"/");
955 if (currentUrl.
path().
isEmpty() || currentUrl.
path() == QLatin1Char(
'/')) {
956 QUrlQuery
query(currentUrl);
962 text = currentUrl.
scheme() + QLatin1Char(
':');
964 text += QLatin1Char(
' ') + currentUrl.
host();
971QUrl KUrlNavigatorPrivate::buttonUrl(
int index)
const
979 QUrl url = q->locationUrl();
989 path = QStringLiteral(
"/");
1000void KUrlNavigatorPrivate::switchToBreadcrumbMode()
1002 q->setUrlEditable(
false);
1005void KUrlNavigatorPrivate::deleteButtons()
1007 for (KUrlNavigatorButton *button : std::as_const(m_navButtons)) {
1009 button->deleteLater();
1011 m_navButtons.
clear();
1014QUrl KUrlNavigatorPrivate::retrievePlaceUrl()
const
1016 QUrl currentUrl = q->locationUrl();
1017 currentUrl.
setPath(QString());
1030 , d(new KUrlNavigatorPrivate(url, this, placesModel))
1032 const int minHeight = d->m_pathBox->sizeHint().
height();
1039 d->updateTabOrder();
1042KUrlNavigator::~KUrlNavigator()
1044 d->m_dropDownButton->removeEventFilter(
this);
1045 d->m_pathBox->removeEventFilter(
this);
1046 for (
auto *button : std::as_const(d->m_navButtons)) {
1047 button->removeEventFilter(
this);
1054 return d->m_coreUrlNavigator->locationUrl(
historyIndex);
1059 auto current = d->m_coreUrlNavigator->locationState().value<KUrlNavigatorData>();
1060 current.state = state;
1066 return d->m_coreUrlNavigator->locationState(
historyIndex).value<KUrlNavigatorData>().state;
1071 return d->m_coreUrlNavigator->goBack();
1076 return d->m_coreUrlNavigator->goForward();
1081 return d->m_coreUrlNavigator->goUp();
1086 if (d->m_homeUrl.isEmpty() || !d->m_homeUrl.isValid()) {
1098QUrl KUrlNavigator::homeUrl()
const
1100 return d->m_homeUrl;
1105 if (d->m_editable != editable) {
1112 return d->m_editable;
1117 if (d->m_showFullPath !=
show) {
1118 d->m_showFullPath =
show;
1125 return d->m_showFullPath;
1130 if (active != d->m_active) {
1131 d->m_active = active;
1133 d->m_dropDownButton->setActive(active);
1134 for (KUrlNavigatorButton *button : std::as_const(d->m_navButtons)) {
1135 button->setActive(active);
1152 if (
visible == d->m_showPlacesSelector) {
1156 if (
visible && (d->m_placesSelector ==
nullptr)) {
1162 d->m_showPlacesSelector =
visible;
1164 if (d->m_placesSelector) {
1165 d->m_placesSelector->setVisible(
visible);
1166 d->updateTabOrder();
1172 return d->m_showPlacesSelector;
1177 KUriFilterData filteredData(d->m_pathBox->currentText().trimmed());
1180 return filteredData.
uri();
1188 d->m_coreUrlNavigator->setCurrentLocationUrl(newUrl);
1203 d->m_pathBox->setFocus();
1234 const QRect bounds = d->m_toggleEditableMode->geometry();
1240 const QMimeData *mimeData = clipboard->
mimeData(QClipboard::Mode::Selection);
1241 if (mimeData && mimeData->
hasText()) {
1242 const QString text = mimeData->
text();
1243 const auto currentUrl = d->m_coreUrlNavigator->currentLocationUrl();
1244 QString workindDirectory;
1261 d->updateButtonVisibility();
1274 d->updateTabOrder();
1280 switch (
event->type()) {
1282 if (watched == d->m_pathBox) {
1286 for (KUrlNavigatorButton *button : std::as_const(d->m_navButtons)) {
1287 button->setShowMnemonic(
true);
1293 for (KUrlNavigatorButton *button : std::as_const(d->m_navButtons)) {
1294 button->setShowMnemonic(
false);
1310#if KIO_VERSION < QT_VERSION_CHECK(7, 0, 0)
1318 if (watched ==
this) {
1319 auto *pEvent =
static_cast<QPaintEvent *
>(
event);
1338 return d->m_coreUrlNavigator->historySize();
1343 return d->m_coreUrlNavigator->historyIndex();
1348 return d->m_pathBox;
1353 d->m_supportedSchemes = schemes;
1354 d->m_schemes->setSupportedSchemes(d->m_supportedSchemes);
1359 return d->m_supportedSchemes;
1364 return d->m_dropWidget;
1374 return d->m_subfolderOptions.showHidden;
1384 return d->m_subfolderOptions.sortHiddenLast;
1391 if (widget == oldWidget) {
1394 d->m_badgeWidgetContainer->layout()->replaceWidget(oldWidget, widget);
1397 d->m_badgeWidgetContainer->layout()->addWidget(widget);
1424 option.rect = option.rect.adjusted(1, 0, -1, 0);
1429#include "moc_kurlnavigator.cpp"
void returnPressed(const QString &text)
Object that helps with keeping track of URLs in file-manager like interfaces.
Q_SIGNAL void urlSelectionRequested(const QUrl &url)
When the URL is changed and the new URL (e.g. /home/user1/) is a parent of the previous URL (e....
Q_SIGNAL void currentUrlAboutToChange(const QUrl &newUrl)
Is emitted, before the location URL is going to be changed to newUrl.
Q_SIGNAL void historyChanged()
Is emitted, if the history has been changed.
This class is a list view model.
static QString protocolClass(const QString &protocol)
Returns the protocol class for the specified protocol.
This class is a basic messaging class used to exchange filtering information between the filter plugi...
QUrl uri() const
Returns the filtered or the original URL.
QString typedString() const
The string as typed by the user, before any URL processing is done.
void setCheckForExecutables(bool check)
Check whether the provided uri is executable or not.
static KUriFilter * self()
Returns an instance of KUriFilter.
bool filterUri(KUriFilterData &data, const QStringList &filters=QStringList())
Filters data using the specified filters.
This combobox shows a number of recent URLs/directories, as well as some default directories.
void urlActivated(const QUrl &url)
Emitted when an item was clicked at.
This class does completion of URLs including user directories (~user) and environment variables.
Widget that allows to navigate through the paths of an URL.
void newWindowRequested(const QUrl &url)
Is emitted if the URL url should be opened in a new window because the user left-clicked on a breadcr...
void setShowFullPath(bool show)
Shows the full path of the URL even if a place represents a part of the URL.
void setBadgeWidget(QWidget *widget)
Puts widget to the right of the breadcrumb.
void setSortHiddenFoldersLast(bool sortHiddenFoldersLast)
Sets whether to sort hidden folders in the subdirectories popup last.
void setPlacesSelectorVisible(bool visible)
Sets the places selector visible, if visible is true.
void setLocationUrl(const QUrl &url)
Sets the location to url.
bool goUp()
Goes up one step of the URL path and remembers the old path in the history.
bool showHiddenFolders() const
Returns whether to show hidden folders in the subdirectories popup.
QUrl uncommittedUrl() const
KUrlComboBox * editor() const
QStringList supportedSchemes() const
Returns the URL schemes that the navigator should allow navigating to.
KUrlNavigator(QWidget *parent=nullptr)
bool sortHiddenFoldersLast() const
Returns whether to sort hidden folders in the subdirectories popup last.
void tabRequested(const QUrl &url)
Is emitted if the URL url should be opened in a new inactive tab because the user clicked on a breadc...
void saveLocationState(const QByteArray &state)
Saves the location state described by state for the current location.
void goHome()
Goes to the home URL and remembers the old URL in the history.
void setHomeUrl(const QUrl &url)
Sets the home URL used by KUrlNavigator::goHome().
QWidget * badgeWidget() const
Returns the badge widget set by setBadgeWidget().
bool goBack()
Goes back one step in the URL history.
QUrl locationUrl(int historyIndex=-1) const
void requestActivation()
Activates the URL navigator (KUrlNavigator::isActive() will return true) and emits the signal KUrlNav...
void setUrlEditable(bool editable)
Allows to edit the URL of the navigation bar if editable is true, and sets the focus accordingly.
bool isPlacesSelectorVisible() const
bool showFullPath() const
bool goForward()
Goes forward one step in the URL history.
void setShowHiddenFolders(bool showHiddenFolders)
Sets whether to show hidden folders in the subdirectories popup.
void setActive(bool active)
Set the URL navigator to the active mode, if active is true.
QWidget * dropWidget() const
The child widget that received the QDropEvent when dropping on the URL navigator.
void activated()
Is emitted, if the URL navigator has been activated by an user interaction.
QByteArray locationState(int historyIndex=-1) const
bool isUrlEditable() const
void setSupportedSchemes(const QStringList &schemes)
Set the URL schemes that the navigator should allow navigating to.
QString xi18nc(const char *context, const char *text, const TYPE &arg...)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
AKONADI_CALENDAR_EXPORT KCalendarCore::Event::Ptr event(const Akonadi::Item &item)
KSERVICE_EXPORT KService::List query(FilterFunc filterFunc)
KIOCORE_EXPORT StatJob * stat(const QUrl &url, JobFlags flags=DefaultFlags)
Find all details for one file or directory.
KIOCORE_EXPORT QUrl upUrl(const QUrl &url)
This function is useful to implement the "Up" button in a file manager for example.
@ HideProgressInfo
Hide progress information dialog, i.e. don't show a GUI.
@ StatBasic
Filename, access, type, size, linkdest.
@ StatResolveSymlink
Resolve symlinks.
QString path(const QString &relativePath)
const QList< QKeySequence > & openContextMenu()
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles)
void rowsInserted(const QModelIndex &parent, int first, int last)
void rowsRemoved(const QModelIndex &parent, int first, int last)
QVariant data() const const
void setData(const QVariant &data)
void triggered(bool checked)
QAction * addAction(QAction *action)
const QMimeData * mimeData(Mode mode) const const
void setMimeData(QMimeData *src, Mode mode)
QString text(Mode mode) const const
AdjustToContentsOnFirstShow
void editTextChanged(const QString &text)
Qt::KeyboardModifiers keyboardModifiers()
QIcon fromTheme(const QString &name)
virtual QLayoutItem * itemAt(int index) const const=0
virtual QLayout * layout()
void append(QList< T > &&value)
void prepend(parameter_type value)
qsizetype removeAll(const AT &t)
bool hasText() const const
void setText(const QString &text)
QString text() const const
iterator insert(const Key &key, const T &value)
bool isEmpty() const const
virtual bool event(QEvent *e)
virtual bool eventFilter(QObject *watched, QEvent *event)
void installEventFilter(QObject *filterObj)
QObject * parent() const const
void removeEventFilter(QObject *obj)
bool contains(const QPoint &point, bool proper) const const
qsizetype count() const const
QString & append(QChar ch)
bool isEmpty() const const
QString left(qsizetype n) const const
qsizetype length() const const
QString & replace(QChar before, QChar after, Qt::CaseSensitivity cs)
QString section(QChar sep, qsizetype start, qsizetype end, SectionFlags flags) const const
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
QString trimmed() const const
virtual void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const const=0
void initFrom(const QWidget *widget)
typedef KeyboardModifiers
void keyEvent(KeyAction action, QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier, int delay)
QUrl fromLocalFile(const QString &localFile)
QString host(ComponentFormattingOptions options) const const
bool isEmpty() const const
bool isLocalFile() const const
bool isValid() const const
bool matches(const QUrl &url, FormattingOptions options) const const
QString path(ComponentFormattingOptions options) const const
QString scheme() const const
void setAuthority(const QString &authority, ParsingMode mode)
void setPath(const QString &path, ParsingMode mode)
void setScheme(const QString &scheme)
QString toDisplayString(FormattingOptions options) const const
QString toLocalFile() const const
QString toString(FormattingOptions options) const const
QString url(FormattingOptions options) const const
QVariant fromValue(T &&value)
QString toString() const const