• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KFile

  • sources
  • kde-4.12
  • kdelibs
  • kfile
kurlnavigator.cpp
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (C) 2006-2010 by Peter Penz <peter.penz@gmx.at> *
3  * Copyright (C) 2006 by Aaron J. Seigo <aseigo@kde.org> *
4  * Copyright (C) 2007 by Kevin Ottens <ervin@kde.org> *
5  * Copyright (C) 2007 by Urs Wolfer <uwolfer @ kde.org> *
6  * *
7  * This library is free software; you can redistribute it and/or *
8  * modify it under the terms of the GNU Library General Public *
9  * License as published by the Free Software Foundation; either *
10  * version 2 of the License, or (at your option) any later version. *
11  * *
12  * This library is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
15  * Library General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU Library General Public License *
18  * along with this library; see the file COPYING.LIB. If not, write to *
19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
20  * Boston, MA 02110-1301, USA. *
21  *****************************************************************************/
22 
23 #include "kurlnavigator.h"
24 
25 #include "kurlnavigatorplacesselector_p.h"
26 #include "kurlnavigatorprotocolcombo_p.h"
27 #include "kurlnavigatordropdownbutton_p.h"
28 #include "kurlnavigatorbutton_p.h"
29 #include "kurlnavigatortogglebutton_p.h"
30 
31 #include <kfileitem.h>
32 #include <kfileplacesmodel.h>
33 #include <kglobalsettings.h>
34 #include <kicon.h>
35 #include <klocale.h>
36 #include <kmenu.h>
37 #include <kprotocolinfo.h>
38 #include <kurlcombobox.h>
39 #include <kurlcompletion.h>
40 #include <kurifilter.h>
41 
42 #include <QtCore/QDir>
43 #include <QtCore/QLinkedList>
44 #include <QtCore/QTimer>
45 #include <QtGui/QApplication>
46 #include <QtGui/QBoxLayout>
47 #include <QtGui/QClipboard>
48 #include <QtGui/QDropEvent>
49 #include <QtGui/QKeyEvent>
50 #include <QtGui/QLabel>
51 #include <QtGui/QPainter>
52 #include <QtGui/QStyleOption>
53 
54 #include <fixx11h.h>
55 
56 using namespace KDEPrivate;
57 
58 struct LocationData
59 {
60  KUrl url;
61 #ifndef KDE_NO_DEPRECATED
62  KUrl rootUrl; // KDE5: remove after the deprecated methods have been removed
63  QPoint pos; // KDE5: remove after the deprecated methods have been removed
64 #endif
65  QByteArray state;
66 };
67 
68 class KUrlNavigator::Private
69 {
70 public:
71  Private(KUrlNavigator* q, KFilePlacesModel* placesModel);
72 
73  void initialize(const KUrl& url);
74 
75  void slotReturnPressed();
76  void slotProtocolChanged(const QString&);
77  void openPathSelectorMenu();
78 
84  void appendWidget(QWidget* widget, int stretch = 0);
85 
91  void switchView();
92 
94  void dropUrls(const KUrl& destination, QDropEvent* event);
95 
101  void slotNavigatorButtonClicked(const KUrl& url, Qt::MouseButton button);
102 
103  void openContextMenu();
104 
105  void slotPathBoxChanged(const QString& text);
106 
107  void updateContent();
108 
117  void updateButtons(int startIndex);
118 
124  void updateButtonVisibility();
125 
129  QString firstButtonText() const;
130 
134  KUrl buttonUrl(int index) const;
135 
136  void switchToBreadcrumbMode();
137 
142  void deleteButtons();
143 
151  QString retrievePlacePath() const;
152 
157  bool isCompressedPath(const KUrl& path) const;
158 
159  void removeTrailingSlash(QString& url) const;
160 
168  int adjustedHistoryIndex(int historyIndex) const;
169 
170  bool m_editable : 1;
171  bool m_active : 1;
172  bool m_showPlacesSelector : 1;
173  bool m_showFullPath : 1;
174  int m_historyIndex;
175 
176  QHBoxLayout* m_layout;
177 
178  QList<LocationData> m_history;
179  KUrlNavigatorPlacesSelector* m_placesSelector;
180  KUrlComboBox* m_pathBox;
181  KUrlNavigatorProtocolCombo* m_protocols;
182  KUrlNavigatorDropDownButton* m_dropDownButton;
183  QList<KUrlNavigatorButton*> m_navButtons;
184  KUrlNavigatorButtonBase* m_toggleEditableMode;
185  KUrl m_homeUrl;
186  QStringList m_customProtocols;
187  KUrlNavigator* q;
188 };
189 
190 
191 KUrlNavigator::Private::Private(KUrlNavigator* q, KFilePlacesModel* placesModel) :
192  m_editable(false),
193  m_active(true),
194  m_showPlacesSelector(placesModel != 0),
195  m_showFullPath(false),
196  m_historyIndex(0),
197  m_layout(new QHBoxLayout),
198  m_placesSelector(0),
199  m_pathBox(0),
200  m_protocols(0),
201  m_dropDownButton(0),
202  m_navButtons(),
203  m_toggleEditableMode(0),
204  m_homeUrl(),
205  m_customProtocols(QStringList()),
206  q(q)
207 {
208  m_layout->setSpacing(0);
209  m_layout->setMargin(0);
210 
211  // initialize the places selector
212  q->setAutoFillBackground(false);
213 
214  if (placesModel != 0) {
215  m_placesSelector = new KUrlNavigatorPlacesSelector(q, placesModel);
216  connect(m_placesSelector, SIGNAL(placeActivated(KUrl)),
217  q, SLOT(setLocationUrl(KUrl)));
218 
219  connect(placesModel, SIGNAL(rowsInserted(QModelIndex,int,int)),
220  q, SLOT(updateContent()));
221  connect(placesModel, SIGNAL(rowsRemoved(QModelIndex,int,int)),
222  q, SLOT(updateContent()));
223  connect(placesModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
224  q, SLOT(updateContent()));
225  }
226 
227  // create protocol combo
228  m_protocols = new KUrlNavigatorProtocolCombo(QString(), q);
229  connect(m_protocols, SIGNAL(activated(QString)),
230  q, SLOT(slotProtocolChanged(QString)));
231 
232  // create drop down button for accessing all paths of the URL
233  m_dropDownButton = new KUrlNavigatorDropDownButton(q);
234  m_dropDownButton->setForegroundRole(QPalette::WindowText);
235  m_dropDownButton->installEventFilter(q);
236  connect(m_dropDownButton, SIGNAL(clicked()),
237  q, SLOT(openPathSelectorMenu()));
238 
239  // initialize the path box of the traditional view
240  m_pathBox = new KUrlComboBox(KUrlComboBox::Directories, true, q);
241  m_pathBox->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
242  m_pathBox->installEventFilter(q);
243 
244  KUrlCompletion* kurlCompletion = new KUrlCompletion(KUrlCompletion::DirCompletion);
245  m_pathBox->setCompletionObject(kurlCompletion);
246  m_pathBox->setAutoDeleteCompletionObject(true);
247 
248  connect(m_pathBox, SIGNAL(returnPressed()),
249  q, SLOT(slotReturnPressed()));
250  connect(m_pathBox, SIGNAL(urlActivated(KUrl)),
251  q, SLOT(setLocationUrl(KUrl)));
252  connect(m_pathBox, SIGNAL(editTextChanged(QString)),
253  q, SLOT(slotPathBoxChanged(QString)));
254 
255  // create toggle button which allows to switch between
256  // the breadcrumb and traditional view
257  m_toggleEditableMode = new KUrlNavigatorToggleButton(q);
258  m_toggleEditableMode->installEventFilter(q);
259  m_toggleEditableMode->setMinimumWidth(20);
260  connect(m_toggleEditableMode, SIGNAL(clicked()),
261  q, SLOT(switchView()));
262 
263  if (m_placesSelector != 0) {
264  m_layout->addWidget(m_placesSelector);
265  }
266  m_layout->addWidget(m_protocols);
267  m_layout->addWidget(m_dropDownButton);
268  m_layout->addWidget(m_pathBox, 1);
269  m_layout->addWidget(m_toggleEditableMode);
270 
271  q->setContextMenuPolicy(Qt::CustomContextMenu);
272  connect(q, SIGNAL(customContextMenuRequested(QPoint)),
273  q, SLOT(openContextMenu()));
274 }
275 
276 void KUrlNavigator::Private::initialize(const KUrl& url)
277 {
278  LocationData data;
279  data.url = url;
280  m_history.prepend(data);
281 
282  q->setLayoutDirection(Qt::LeftToRight);
283 
284  const int minHeight = m_pathBox->sizeHint().height();
285  q->setMinimumHeight(minHeight);
286 
287  q->setLayout(m_layout);
288  q->setMinimumWidth(100);
289 
290  updateContent();
291 }
292 
293 void KUrlNavigator::Private::appendWidget(QWidget* widget, int stretch)
294 {
295  m_layout->insertWidget(m_layout->count() - 1, widget, stretch);
296 }
297 
298 void KUrlNavigator::Private::slotReturnPressed()
299 {
300  // Parts of the following code have been taken
301  // from the class KateFileSelector located in
302  // kate/app/katefileselector.hpp of Kate.
303  // Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
304  // Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
305  // Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
306 
307  const KUrl typedUrl = q->uncommittedUrl();
308  QStringList urls = m_pathBox->urls();
309  urls.removeAll(typedUrl.url());
310  urls.prepend(typedUrl.url());
311  m_pathBox->setUrls(urls, KUrlComboBox::RemoveBottom);
312 
313  q->setLocationUrl(typedUrl);
314  // The URL might have been adjusted by KUrlNavigator::setUrl(), hence
315  // synchronize the result in the path box.
316  const KUrl currentUrl = q->locationUrl();
317  m_pathBox->setUrl(currentUrl);
318 
319  emit q->returnPressed();
320 
321  if (QApplication::keyboardModifiers() & Qt::ControlModifier) {
322  // Pressing Ctrl+Return automatically switches back to the breadcrumb mode.
323  // The switch must be done asynchronously, as we are in the context of the
324  // editor.
325  QMetaObject::invokeMethod(q, "switchToBreadcrumbMode", Qt::QueuedConnection);
326  }
327 }
328 
329 void KUrlNavigator::Private::slotProtocolChanged(const QString& protocol)
330 {
331  Q_ASSERT(m_editable);
332 
333  KUrl url;
334  url.setProtocol(protocol);
335  url.setPath((protocol == QLatin1String("file")) ? QLatin1String("/") : QLatin1String("//"));
336 
337  m_pathBox->setEditUrl(url);
338 }
339 
340 void KUrlNavigator::Private::openPathSelectorMenu()
341 {
342  if (m_navButtons.count() <= 0) {
343  return;
344  }
345 
346  const KUrl firstVisibleUrl = m_navButtons.first()->url();
347 
348  QString spacer;
349  KMenu* popup = new KMenu(q);
350  popup->setLayoutDirection(Qt::LeftToRight);
351 
352  const QString placePath = retrievePlacePath();
353  int idx = placePath.count(QLatin1Char('/')); // idx points to the first directory
354  // after the place path
355 
356  const QString path = m_history[m_historyIndex].url.pathOrUrl();
357  QString dirName = path.section(QLatin1Char('/'), idx, idx);
358  if (dirName.isEmpty()) {
359  dirName = QLatin1Char('/');
360  }
361  do {
362  const QString text = spacer + dirName;
363 
364  QAction* action = new QAction(text, popup);
365  const KUrl currentUrl = buttonUrl(idx);
366  if (currentUrl == firstVisibleUrl) {
367  popup->addSeparator();
368  }
369  action->setData(QVariant(currentUrl.prettyUrl()));
370  popup->addAction(action);
371 
372  ++idx;
373  spacer.append(" ");
374  dirName = path.section('/', idx, idx);
375  } while (!dirName.isEmpty());
376 
377  const QPoint pos = q->mapToGlobal(m_dropDownButton->geometry().bottomRight());
378  const QAction* activatedAction = popup->exec(pos);
379  if (activatedAction != 0) {
380  const KUrl url = KUrl(activatedAction->data().toString());
381  q->setLocationUrl(url);
382  }
383 
384  popup->deleteLater();
385 }
386 
387 void KUrlNavigator::Private::switchView()
388 {
389  m_toggleEditableMode->setFocus();
390  m_editable = !m_editable;
391  m_toggleEditableMode->setChecked(m_editable);
392  updateContent();
393  if (q->isUrlEditable()) {
394  m_pathBox->setFocus();
395  }
396 
397  emit q->requestActivation();
398  emit q->editableStateChanged(m_editable);
399 }
400 
401 void KUrlNavigator::Private::dropUrls(const KUrl& destination, QDropEvent* event)
402 {
403  const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
404  if (!urls.isEmpty()) {
405  emit q->urlsDropped(destination, event);
406 
407 #ifndef KDE_NO_DEPRECATED
408  // KDE5: remove, as the signal has been replaced by
409  // urlsDropped(const KUrl& destination, QDropEvent* event)
410  emit q->urlsDropped(urls, destination);
411 #endif
412  }
413 }
414 
415 void KUrlNavigator::Private::slotNavigatorButtonClicked(const KUrl& url, Qt::MouseButton button)
416 {
417  if (button & Qt::LeftButton) {
418  q->setLocationUrl(url);
419  } else if (button & Qt::MidButton) {
420  emit q->tabRequested(url);
421  }
422 }
423 
424 void KUrlNavigator::Private::openContextMenu()
425 {
426  q->setActive(true);
427 
428  KMenu popup(q);
429 
430  // provide 'Copy' action, which copies the current URL of
431  // the URL navigator into the clipboard
432  QAction* copyAction = popup.addAction(KIcon("edit-copy"), i18n("Copy"));
433 
434  // provide 'Paste' action, which copies the current clipboard text
435  // into the URL navigator
436  QAction* pasteAction = popup.addAction(KIcon("edit-paste"), i18n("Paste"));
437  QClipboard* clipboard = QApplication::clipboard();
438  pasteAction->setEnabled(!clipboard->text().isEmpty());
439 
440  popup.addSeparator();
441 
442  // provide radiobuttons for toggling between the edit and the navigation mode
443  QAction* editAction = popup.addAction(i18n("Edit"));
444  editAction->setCheckable(true);
445 
446  QAction* navigateAction = popup.addAction(i18n("Navigate"));
447  navigateAction->setCheckable(true);
448 
449  QActionGroup* modeGroup = new QActionGroup(&popup);
450  modeGroup->addAction(editAction);
451  modeGroup->addAction(navigateAction);
452  if (q->isUrlEditable()) {
453  editAction->setChecked(true);
454  } else {
455  navigateAction->setChecked(true);
456  }
457 
458  popup.addSeparator();
459 
460  // allow showing of the full path
461  QAction* showFullPathAction = popup.addAction(i18n("Show Full Path"));
462  showFullPathAction->setCheckable(true);
463  showFullPathAction->setChecked(q->showFullPath());
464 
465  QAction* activatedAction = popup.exec(QCursor::pos());
466  if (activatedAction == copyAction) {
467  QMimeData* mimeData = new QMimeData();
468  mimeData->setText(q->locationUrl().pathOrUrl());
469  clipboard->setMimeData(mimeData);
470  } else if (activatedAction == pasteAction) {
471  q->setLocationUrl(KUrl(clipboard->text()));
472  } else if (activatedAction == editAction) {
473  q->setUrlEditable(true);
474  } else if (activatedAction == navigateAction) {
475  q->setUrlEditable(false);
476  } else if (activatedAction == showFullPathAction) {
477  q->setShowFullPath(showFullPathAction->isChecked());
478  }
479 }
480 
481 void KUrlNavigator::Private::slotPathBoxChanged(const QString& text)
482 {
483  if (text.isEmpty()) {
484  const QString protocol = q->locationUrl().protocol();
485  m_protocols->setProtocol(protocol);
486  m_protocols->show();
487  } else {
488  m_protocols->hide();
489  }
490 }
491 
492 void KUrlNavigator::Private::updateContent()
493 {
494  const KUrl currentUrl = q->locationUrl();
495  if (m_placesSelector != 0) {
496  m_placesSelector->updateSelection(currentUrl);
497  }
498 
499  if (m_editable) {
500  m_protocols->hide();
501  m_dropDownButton->hide();
502 
503  deleteButtons();
504  m_toggleEditableMode->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
505  q->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
506 
507  m_pathBox->show();
508  m_pathBox->setUrl(currentUrl);
509  } else {
510  m_pathBox->hide();
511 
512  m_protocols->hide();
513 
514  m_toggleEditableMode->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
515  q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
516 
517  // Calculate the start index for the directories that should be shown as buttons
518  // and create the buttons
519  KUrl placeUrl;
520  if ((m_placesSelector != 0) && !m_showFullPath) {
521  placeUrl = m_placesSelector->selectedPlaceUrl();
522  }
523 
524  QString placePath = placeUrl.isValid() ? placeUrl.pathOrUrl() : retrievePlacePath();
525  removeTrailingSlash(placePath);
526 
527  const int startIndex = placePath.count('/');
528  updateButtons(startIndex);
529  }
530 }
531 
532 void KUrlNavigator::Private::updateButtons(int startIndex)
533 {
534  KUrl currentUrl = q->locationUrl();
535 
536  const QString path = currentUrl.pathOrUrl();
537 
538  bool createButton = false;
539  const int oldButtonCount = m_navButtons.count();
540 
541  int idx = startIndex;
542  bool hasNext = true;
543  do {
544  createButton = (idx - startIndex >= oldButtonCount);
545  const bool isFirstButton = (idx == startIndex);
546  const QString dirName = path.section(QLatin1Char('/'), idx, idx);
547  hasNext = isFirstButton || !dirName.isEmpty();
548  if (hasNext) {
549  KUrlNavigatorButton* button = 0;
550  if (createButton) {
551  button = new KUrlNavigatorButton(buttonUrl(idx), q);
552  button->installEventFilter(q);
553  button->setForegroundRole(QPalette::WindowText);
554  connect(button, SIGNAL(urlsDropped(KUrl,QDropEvent*)),
555  q, SLOT(dropUrls(KUrl,QDropEvent*)));
556  connect(button, SIGNAL(clicked(KUrl,Qt::MouseButton)),
557  q, SLOT(slotNavigatorButtonClicked(KUrl,Qt::MouseButton)));
558  connect(button, SIGNAL(finishedTextResolving()),
559  q, SLOT(updateButtonVisibility()));
560  appendWidget(button);
561  } else {
562  button = m_navButtons[idx - startIndex];
563  button->setUrl(buttonUrl(idx));
564  }
565 
566  if (isFirstButton) {
567  button->setText(firstButtonText());
568  }
569  button->setActive(q->isActive());
570 
571  if (createButton) {
572  if (!isFirstButton) {
573  setTabOrder(m_navButtons.last(), button);
574  }
575  m_navButtons.append(button);
576  }
577 
578  ++idx;
579  button->setActiveSubDirectory(path.section(QLatin1Char('/'), idx, idx));
580  }
581  } while (hasNext);
582 
583  // delete buttons which are not used anymore
584  const int newButtonCount = idx - startIndex;
585  if (newButtonCount < oldButtonCount) {
586  const QList<KUrlNavigatorButton*>::iterator itBegin = m_navButtons.begin() + newButtonCount;
587  const QList<KUrlNavigatorButton*>::iterator itEnd = m_navButtons.end();
588  QList<KUrlNavigatorButton*>::iterator it = itBegin;
589  while (it != itEnd) {
590  (*it)->hide();
591  (*it)->deleteLater();
592  ++it;
593  }
594  m_navButtons.erase(itBegin, itEnd);
595  }
596 
597  setTabOrder(m_dropDownButton, m_navButtons.first());
598  setTabOrder(m_navButtons.last(), m_toggleEditableMode);
599 
600  updateButtonVisibility();
601 }
602 
603 void KUrlNavigator::Private::updateButtonVisibility()
604 {
605  if (m_editable) {
606  return;
607  }
608 
609  const int buttonsCount = m_navButtons.count();
610  if (buttonsCount == 0) {
611  m_dropDownButton->hide();
612  return;
613  }
614 
615  // Subtract all widgets from the available width, that must be shown anyway
616  int availableWidth = q->width() - m_toggleEditableMode->minimumWidth();
617 
618  if ((m_placesSelector != 0) && m_placesSelector->isVisible()) {
619  availableWidth -= m_placesSelector->width();
620  }
621 
622  if ((m_protocols != 0) && m_protocols->isVisible()) {
623  availableWidth -= m_protocols->width();
624  }
625 
626  // Check whether buttons must be hidden at all...
627  int requiredButtonWidth = 0;
628  foreach (const KUrlNavigatorButton* button, m_navButtons) {
629  requiredButtonWidth += button->minimumWidth();
630  }
631 
632  if (requiredButtonWidth > availableWidth) {
633  // At least one button must be hidden. This implies that the
634  // drop-down button must get visible, which again decreases the
635  // available width.
636  availableWidth -= m_dropDownButton->width();
637  }
638 
639  // Hide buttons...
640  QList<KUrlNavigatorButton*>::const_iterator it = m_navButtons.constEnd();
641  const QList<KUrlNavigatorButton*>::const_iterator itBegin = m_navButtons.constBegin();
642  bool isLastButton = true;
643  bool hasHiddenButtons = false;
644 
645  QLinkedList<KUrlNavigatorButton*> buttonsToShow;
646  while (it != itBegin) {
647  --it;
648  KUrlNavigatorButton* button = (*it);
649  availableWidth -= button->minimumWidth();
650  if ((availableWidth <= 0) && !isLastButton) {
651  button->hide();
652  hasHiddenButtons = true;
653  }
654  else {
655  // Don't show the button immediately, as setActive()
656  // might change the size and a relayout gets triggered
657  // after showing the button. So the showing of all buttons
658  // is postponed until all buttons have the correct
659  // activation state.
660  buttonsToShow.append(button);
661  }
662  isLastButton = false;
663  }
664 
665  // All buttons have the correct activation state and
666  // can be shown now
667  foreach (KUrlNavigatorButton* button, buttonsToShow) {
668  button->show();
669  }
670 
671  if (hasHiddenButtons) {
672  m_dropDownButton->show();
673  } else {
674  // Check whether going upwards is possible. If this is the case, show the drop-down button.
675  KUrl url = m_navButtons.front()->url();
676  url.adjustPath(KUrl::AddTrailingSlash);
677  const bool visible = !url.equals(url.upUrl()) && (url.protocol() != "nepomuksearch");
678  m_dropDownButton->setVisible(visible);
679  }
680 }
681 
682 QString KUrlNavigator::Private::firstButtonText() const
683 {
684  QString text;
685 
686  // The first URL navigator button should get the name of the
687  // place instead of the directory name
688  if ((m_placesSelector != 0) && !m_showFullPath) {
689  const KUrl placeUrl = m_placesSelector->selectedPlaceUrl();
690  text = m_placesSelector->selectedPlaceText();
691  }
692 
693  if (text.isEmpty()) {
694  const KUrl currentUrl = q->locationUrl();
695  if (currentUrl.isLocalFile()) {
696 #ifdef Q_OS_WIN
697  text = currentUrl.path().length() > 1 ? currentUrl.path().left(2) : QDir::rootPath();
698 #else
699  text = m_showFullPath ? QLatin1String("/") : i18n("Custom Path");
700 #endif
701  } else {
702  text = currentUrl.protocol() + QLatin1Char(':');
703  if (!currentUrl.host().isEmpty()) {
704  text += QLatin1Char(' ') + currentUrl.host();
705  }
706  }
707  }
708 
709  return text;
710 }
711 
712 KUrl KUrlNavigator::Private::buttonUrl(int index) const
713 {
714  if (index < 0) {
715  index = 0;
716  }
717 
718  // Keep scheme, hostname etc. as this is needed for e. g. browsing
719  // FTP directories
720  const KUrl currentUrl = q->locationUrl();
721  KUrl newUrl = currentUrl;
722  newUrl.setPath(QString());
723 
724  QString pathOrUrl = currentUrl.pathOrUrl();
725  if (!pathOrUrl.isEmpty()) {
726  if (index == 0) {
727  // prevent the last "/" from being stripped
728  // or we end up with an empty path
729 #ifdef Q_OS_WIN
730  pathOrUrl = pathOrUrl.length() > 1 ? pathOrUrl.left(2) : QDir::rootPath();
731 #else
732  pathOrUrl = QLatin1String("/");
733 #endif
734  } else {
735  pathOrUrl = pathOrUrl.section('/', 0, index);
736  }
737  }
738 
739  newUrl.setPath(KUrl(pathOrUrl).path());
740  return newUrl;
741 }
742 
743 void KUrlNavigator::Private::switchToBreadcrumbMode()
744 {
745  q->setUrlEditable(false);
746 }
747 
748 void KUrlNavigator::Private::deleteButtons()
749 {
750  foreach (KUrlNavigatorButton* button, m_navButtons) {
751  button->hide();
752  button->deleteLater();
753  }
754  m_navButtons.clear();
755 }
756 
757 QString KUrlNavigator::Private::retrievePlacePath() const
758 {
759  const KUrl currentUrl = q->locationUrl();
760  const QString path = currentUrl.pathOrUrl();
761  int idx = path.indexOf(QLatin1String("///"));
762  if (idx >= 0) {
763  idx += 3;
764  } else {
765  idx = path.indexOf(QLatin1String("//"));
766  idx = path.indexOf(QLatin1Char('/'), (idx < 0) ? 0 : idx + 2);
767  }
768 
769  QString placePath = (idx < 0) ? path : path.left(idx);
770  removeTrailingSlash(placePath);
771  return placePath;
772 }
773 
774 bool KUrlNavigator::Private::isCompressedPath(const KUrl& url) const
775 {
776  const KMimeType::Ptr mime = KMimeType::findByPath(url.path(KUrl::RemoveTrailingSlash));
777  // Note: this list of MIME types depends on the protocols implemented by kio_archive
778  return mime->is("application/x-compressed-tar") ||
779  mime->is("application/x-bzip-compressed-tar") ||
780  mime->is("application/x-lzma-compressed-tar") ||
781  mime->is("application/x-xz-compressed-tar") ||
782  mime->is("application/x-tar") ||
783  mime->is("application/x-tarz") ||
784  mime->is("application/x-tzo") || // (not sure KTar supports those?)
785  mime->is("application/zip") ||
786  mime->is("application/x-archive");
787 }
788 
789 void KUrlNavigator::Private::removeTrailingSlash(QString& url) const
790 {
791  const int length = url.length();
792  if ((length > 0) && (url.at(length - 1) == QChar('/'))) {
793  url.remove(length - 1, 1);
794  }
795 }
796 
797 int KUrlNavigator::Private::adjustedHistoryIndex(int historyIndex) const
798 {
799  if (historyIndex < 0) {
800  historyIndex = m_historyIndex;
801  } else if (historyIndex >= m_history.size()) {
802  historyIndex = m_history.size() - 1;
803  Q_ASSERT(historyIndex >= 0); // m_history.size() must always be > 0
804  }
805  return historyIndex;
806 }
807 
808 // ------------------------------------------------------------------------------------------------
809 
810 KUrlNavigator::KUrlNavigator(QWidget* parent) :
811  QWidget(parent),
812  d(new Private(this, 0))
813 {
814  d->initialize(KUrl());
815 }
816 
817 KUrlNavigator::KUrlNavigator(KFilePlacesModel* placesModel,
818  const KUrl& url,
819  QWidget* parent) :
820  QWidget(parent),
821  d(new Private(this, placesModel))
822 {
823  d->initialize(url);
824 }
825 
826 KUrlNavigator::~KUrlNavigator()
827 {
828  delete d;
829 }
830 
831 KUrl KUrlNavigator::locationUrl(int historyIndex) const
832 {
833  historyIndex = d->adjustedHistoryIndex(historyIndex);
834  return d->m_history[historyIndex].url;
835 }
836 
837 void KUrlNavigator::saveLocationState(const QByteArray& state)
838 {
839  d->m_history[d->m_historyIndex].state = state;
840 }
841 
842 QByteArray KUrlNavigator::locationState(int historyIndex) const
843 {
844  historyIndex = d->adjustedHistoryIndex(historyIndex);
845  return d->m_history[historyIndex].state;
846 }
847 
848 bool KUrlNavigator::goBack()
849 {
850  const int count = d->m_history.count();
851  if (d->m_historyIndex < count - 1) {
852  const KUrl newUrl = locationUrl(d->m_historyIndex + 1);
853  emit urlAboutToBeChanged(newUrl);
854 
855  ++d->m_historyIndex;
856  d->updateContent();
857 
858  emit historyChanged();
859  emit urlChanged(locationUrl());
860  return true;
861  }
862 
863  return false;
864 }
865 
866 bool KUrlNavigator::goForward()
867 {
868  if (d->m_historyIndex > 0) {
869  const KUrl newUrl = locationUrl(d->m_historyIndex - 1);
870  emit urlAboutToBeChanged(newUrl);
871 
872  --d->m_historyIndex;
873  d->updateContent();
874 
875  emit historyChanged();
876  emit urlChanged(locationUrl());
877  return true;
878  }
879 
880  return false;
881 }
882 
883 bool KUrlNavigator::goUp()
884 {
885  const KUrl currentUrl = locationUrl();
886  const KUrl upUrl = currentUrl.upUrl();
887  if (upUrl != currentUrl) {
888  setLocationUrl(upUrl);
889  return true;
890  }
891 
892  return false;
893 }
894 
895 void KUrlNavigator::goHome()
896 {
897  if (d->m_homeUrl.isEmpty() || !d->m_homeUrl.isValid()) {
898  setLocationUrl(KUrl(QDir::homePath()));
899  } else {
900  setLocationUrl(d->m_homeUrl);
901  }
902 }
903 
904 void KUrlNavigator::setHomeUrl(const KUrl& url)
905 {
906  d->m_homeUrl = url;
907 }
908 
909 KUrl KUrlNavigator::homeUrl() const
910 {
911  return d->m_homeUrl;
912 }
913 
914 void KUrlNavigator::setUrlEditable(bool editable)
915 {
916  if (d->m_editable != editable) {
917  d->switchView();
918  }
919 }
920 
921 bool KUrlNavigator::isUrlEditable() const
922 {
923  return d->m_editable;
924 }
925 
926 void KUrlNavigator::setShowFullPath(bool show)
927 {
928  if (d->m_showFullPath != show) {
929  d->m_showFullPath = show;
930  d->updateContent();
931  }
932 }
933 
934 bool KUrlNavigator::showFullPath() const
935 {
936  return d->m_showFullPath;
937 }
938 
939 
940 void KUrlNavigator::setActive(bool active)
941 {
942  if (active != d->m_active) {
943  d->m_active = active;
944 
945  d->m_dropDownButton->setActive(active);
946  foreach(KUrlNavigatorButton* button, d->m_navButtons) {
947  button->setActive(active);
948  }
949 
950  update();
951  if (active) {
952  emit activated();
953  }
954  }
955 }
956 
957 bool KUrlNavigator::isActive() const
958 {
959  return d->m_active;
960 }
961 
962 void KUrlNavigator::setPlacesSelectorVisible(bool visible)
963 {
964  if (visible == d->m_showPlacesSelector) {
965  return;
966  }
967 
968  if (visible && (d->m_placesSelector == 0)) {
969  // the places selector cannot get visible as no
970  // places model is available
971  return;
972  }
973 
974  d->m_showPlacesSelector = visible;
975  d->m_placesSelector->setVisible(visible);
976 }
977 
978 bool KUrlNavigator::isPlacesSelectorVisible() const
979 {
980  return d->m_showPlacesSelector;
981 }
982 
983 KUrl KUrlNavigator::uncommittedUrl() const
984 {
985  KUriFilterData filteredData(d->m_pathBox->currentText().trimmed());
986  filteredData.setCheckForExecutables(false);
987  if (KUriFilter::self()->filterUri(filteredData, QStringList() << "kshorturifilter" << "kurisearchfilter")) {
988  return filteredData.uri();
989  }
990  else {
991  return KUrl(filteredData.typedString());
992  }
993 }
994 
995 void KUrlNavigator::setLocationUrl(const KUrl& newUrl)
996 {
997  if (newUrl == locationUrl()) {
998  return;
999  }
1000 
1001  KUrl url = newUrl;
1002  url.cleanPath();
1003 
1004  if ((url.protocol() == QLatin1String("tar")) || (url.protocol() == QLatin1String("zip"))) {
1005  // The URL represents a tar- or zip-file. Check whether
1006  // the URL is really part of the tar- or zip-file, otherwise
1007  // replace it by the local path again.
1008  bool insideCompressedPath = d->isCompressedPath(url);
1009  if (!insideCompressedPath) {
1010  KUrl prevUrl = url;
1011  KUrl parentUrl = url.upUrl();
1012  while (parentUrl != prevUrl) {
1013  if (d->isCompressedPath(parentUrl)) {
1014  insideCompressedPath = true;
1015  break;
1016  }
1017  prevUrl = parentUrl;
1018  parentUrl = parentUrl.upUrl();
1019  }
1020  }
1021  if (!insideCompressedPath) {
1022  // drop the tar: or zip: protocol since we are not
1023  // inside the compressed path
1024  url.setProtocol("file");
1025  }
1026  }
1027 
1028  // Check whether current history element has the same URL.
1029  // If this is the case, just ignore setting the URL.
1030  const LocationData& data = d->m_history[d->m_historyIndex];
1031  const bool isUrlEqual = url.equals(locationUrl(), KUrl::CompareWithoutTrailingSlash) ||
1032  (!url.isValid() && url.equals(data.url, KUrl::CompareWithoutTrailingSlash));
1033  if (isUrlEqual) {
1034  return;
1035  }
1036 
1037  emit urlAboutToBeChanged(url);
1038 
1039  if (d->m_historyIndex > 0) {
1040  // If an URL is set when the history index is not at the end (= 0),
1041  // then clear all previous history elements so that a new history
1042  // tree is started from the current position.
1043  QList<LocationData>::iterator begin = d->m_history.begin();
1044  QList<LocationData>::iterator end = begin + d->m_historyIndex;
1045  d->m_history.erase(begin, end);
1046  d->m_historyIndex = 0;
1047  }
1048 
1049  Q_ASSERT(d->m_historyIndex == 0);
1050  LocationData newData;
1051  newData.url = url;
1052  d->m_history.insert(0, newData);
1053 
1054  // Prevent an endless growing of the history: remembering
1055  // the last 100 Urls should be enough...
1056  const int historyMax = 100;
1057  if (d->m_history.size() > historyMax) {
1058  QList<LocationData>::iterator begin = d->m_history.begin() + historyMax;
1059  QList<LocationData>::iterator end = d->m_history.end();
1060  d->m_history.erase(begin, end);
1061  }
1062 
1063  emit historyChanged();
1064  emit urlChanged(url);
1065 
1066  d->updateContent();
1067 
1068  requestActivation();
1069 }
1070 
1071 void KUrlNavigator::requestActivation()
1072 {
1073  setActive(true);
1074 }
1075 
1076 void KUrlNavigator::setFocus()
1077 {
1078  if (isUrlEditable()) {
1079  d->m_pathBox->setFocus();
1080  } else {
1081  QWidget::setFocus();
1082  }
1083 }
1084 
1085 #ifndef KDE_NO_DEPRECATED
1086 void KUrlNavigator::setUrl(const KUrl& url)
1087 {
1088  // deprecated
1089  setLocationUrl(url);
1090 }
1091 #endif
1092 
1093 #ifndef KDE_NO_DEPRECATED
1094 void KUrlNavigator::saveRootUrl(const KUrl& url)
1095 {
1096  // deprecated
1097  d->m_history[d->m_historyIndex].rootUrl = url;
1098 }
1099 #endif
1100 
1101 #ifndef KDE_NO_DEPRECATED
1102 void KUrlNavigator::savePosition(int x, int y)
1103 {
1104  // deprecated
1105  d->m_history[d->m_historyIndex].pos = QPoint(x, y);
1106 }
1107 #endif
1108 
1109 void KUrlNavigator::keyPressEvent(QKeyEvent* event)
1110 {
1111  if (isUrlEditable() && (event->key() == Qt::Key_Escape)) {
1112  setUrlEditable(false);
1113  } else {
1114  QWidget::keyPressEvent(event);
1115  }
1116 }
1117 
1118 void KUrlNavigator::keyReleaseEvent(QKeyEvent* event)
1119 {
1120  QWidget::keyReleaseEvent(event);
1121 }
1122 
1123 void KUrlNavigator::mouseReleaseEvent(QMouseEvent* event)
1124 {
1125  if (event->button() == Qt::MidButton) {
1126  const QRect bounds = d->m_toggleEditableMode->geometry();
1127  if (bounds.contains(event->pos())) {
1128  // The middle mouse button has been clicked above the
1129  // toggle-editable-mode-button. Paste the clipboard content
1130  // as location URL.
1131  QClipboard* clipboard = QApplication::clipboard();
1132  const QMimeData* mimeData = clipboard->mimeData();
1133  if (mimeData->hasText()) {
1134  const QString text = mimeData->text();
1135  setLocationUrl(KUrl(text));
1136  }
1137  }
1138  }
1139  QWidget::mouseReleaseEvent(event);
1140 }
1141 
1142 void KUrlNavigator::resizeEvent(QResizeEvent* event)
1143 {
1144  QTimer::singleShot(0, this, SLOT(updateButtonVisibility()));
1145  QWidget::resizeEvent(event);
1146 }
1147 
1148 void KUrlNavigator::wheelEvent(QWheelEvent* event)
1149 {
1150  setActive(true);
1151  QWidget::wheelEvent(event);
1152 }
1153 
1154 bool KUrlNavigator::eventFilter(QObject* watched, QEvent* event)
1155 {
1156  switch (event->type()) {
1157  case QEvent::FocusIn:
1158  if (watched == d->m_pathBox) {
1159  requestActivation();
1160  setFocus();
1161  }
1162  foreach (KUrlNavigatorButton* button, d->m_navButtons) {
1163  button->setShowMnemonic(true);
1164  }
1165  break;
1166 
1167  case QEvent::FocusOut:
1168  foreach (KUrlNavigatorButton* button, d->m_navButtons) {
1169  button->setShowMnemonic(false);
1170  }
1171  break;
1172 
1173  default:
1174  break;
1175  }
1176 
1177  return QWidget::eventFilter(watched, event);
1178 }
1179 
1180 int KUrlNavigator::historySize() const
1181 {
1182  return d->m_history.count();
1183 }
1184 
1185 int KUrlNavigator::historyIndex() const
1186 {
1187  return d->m_historyIndex;
1188 }
1189 
1190 KUrlComboBox* KUrlNavigator::editor() const
1191 {
1192  return d->m_pathBox;
1193 }
1194 
1195 void KUrlNavigator::setCustomProtocols(const QStringList &protocols)
1196 {
1197  d->m_customProtocols = protocols;
1198  d->m_protocols->setCustomProtocols(d->m_customProtocols);
1199 }
1200 
1201 QStringList KUrlNavigator::customProtocols() const
1202 {
1203  return d->m_customProtocols;
1204 }
1205 
1206 #ifndef KDE_NO_DEPRECATED
1207 const KUrl& KUrlNavigator::url() const
1208 {
1209  // deprecated
1210 
1211  // Workaround required because of flawed interface ('const KUrl&' is returned
1212  // instead of 'KUrl'): remember the URL to prevent a dangling pointer
1213  static KUrl url;
1214  url = locationUrl();
1215  return url;
1216 }
1217 #endif
1218 
1219 #ifndef KDE_NO_DEPRECATED
1220 KUrl KUrlNavigator::url(int index) const
1221 {
1222  // deprecated
1223  return d->buttonUrl(index);
1224 }
1225 #endif
1226 
1227 #ifndef KDE_NO_DEPRECATED
1228 KUrl KUrlNavigator::historyUrl(int historyIndex) const
1229 {
1230  // deprecated
1231  return locationUrl(historyIndex);
1232 }
1233 #endif
1234 
1235 #ifndef KDE_NO_DEPRECATED
1236 const KUrl& KUrlNavigator::savedRootUrl() const
1237 {
1238  // deprecated
1239 
1240  // Workaround required because of flawed interface ('const KUrl&' is returned
1241  // instead of 'KUrl'): remember the root URL to prevent a dangling pointer
1242  static KUrl rootUrl;
1243  rootUrl = d->m_history[d->m_historyIndex].rootUrl;
1244  return rootUrl;
1245 }
1246 #endif
1247 
1248 #ifndef KDE_NO_DEPRECATED
1249 QPoint KUrlNavigator::savedPosition() const
1250 {
1251  // deprecated
1252  return d->m_history[d->m_historyIndex].pos;
1253 }
1254 #endif
1255 
1256 #ifndef KDE_NO_DEPRECATED
1257 void KUrlNavigator::setHomeUrl(const QString& homeUrl)
1258 {
1259  // deprecated
1260  setLocationUrl(KUrl(homeUrl));
1261 }
1262 #endif
1263 
1264 #include "kurlnavigator.moc"
QVariant
KUrlNavigator::editableStateChanged
void editableStateChanged(bool editable)
Is emitted, if the editable state for the URL has been changed (see KUrlNavigator::setUrlEditable())...
i18n
QString i18n(const char *text)
kurlnavigatorprotocolcombo_p.h
KUrlNavigator::urlAboutToBeChanged
void urlAboutToBeChanged(const KUrl &newUrl)
Is emitted, before the location URL is going to be changed to newUrl.
KUrl::adjustPath
void adjustPath(AdjustPathOption trailing)
KUrlNavigator::goUp
bool goUp()
Goes up one step of the URL path and remembers the old path in the history.
Definition: kurlnavigator.cpp:883
KUrlNavigator::setActive
void setActive(bool active)
Set the URL navigator to the active mode, if active is true.
Definition: kurlnavigator.cpp:940
KUrlNavigator::customProtocols
QStringList customProtocols() const
Definition: kurlnavigator.cpp:1201
KUrl::RemoveTrailingSlash
KUrlNavigator::locationState
QByteArray locationState(int historyIndex=-1) const
Definition: kurlnavigator.cpp:842
KDEPrivate::KUrlNavigatorDropDownButton
Button of the URL navigator which offers a drop down menu of hidden paths.
Definition: kurlnavigatordropdownbutton_p.h:35
KDEPrivate::KUrlNavigatorButton::setText
void setText(const QString &text)
Definition: kurlnavigatorbutton.cpp:104
KUrl::AddTrailingSlash
kglobalsettings.h
KUrlNavigator::setCustomProtocols
void setCustomProtocols(const QStringList &protocols)
If an application supports only some special protocols, they can be set with protocols ...
Definition: kurlnavigator.cpp:1195
kurlnavigatordropdownbutton_p.h
KUrlNavigator::locationUrl
KUrl locationUrl(int historyIndex=-1) const
Definition: kurlnavigator.cpp:831
KUrlNavigator::historyIndex
int historyIndex() const
Definition: kurlnavigator.cpp:1185
KMenu
KUrlNavigator::uncommittedUrl
KUrl uncommittedUrl() const
Definition: kurlnavigator.cpp:983
QWidget
KUrl::cleanPath
void cleanPath(const CleanPathOption &options=SimplifyDirSeparators)
KUrlNavigator::setHomeUrl
void setHomeUrl(const KUrl &url)
Sets the home URL used by KUrlNavigator::goHome().
Definition: kurlnavigator.cpp:904
KDEPrivate::KUrlNavigatorButtonBase
Base class for buttons of the URL navigator.
Definition: kurlnavigatorbuttonbase_p.h:39
KUrlNavigator::urlsDropped
void urlsDropped(const KUrl &destination, QDropEvent *event)
Is emitted if a dropping has been done above the destination destination.
QString
KUrlNavigator::goHome
void goHome()
Goes to the home URL and remembers the old URL in the history.
Definition: kurlnavigator.cpp:895
KUrl::CompareWithoutTrailingSlash
QObject
klocale.h
KUrlNavigator::setLocationUrl
void setLocationUrl(const KUrl &url)
Sets the location to url.
Definition: kurlnavigator.cpp:995
kurlnavigatorbutton_p.h
kurifilter.h
KUrl
KUrlComboBox
KDEPrivate::KUrlNavigatorPlacesSelector
Allows to select a bookmark from a popup menu.
Definition: kurlnavigatorplacesselector_p.h:44
KUrl::setPath
void setPath(const QString &path)
KUrlNavigator::isUrlEditable
bool isUrlEditable() const
Definition: kurlnavigator.cpp:921
KUrl::setProtocol
void setProtocol(const QString &proto)
KUrl::List::fromMimeData
static KUrl::List fromMimeData(const QMimeData *mimeData, KUrl::MetaDataMap *metaData=0)
kmenu.h
KUrlComboBox::RemoveBottom
KUrlNavigator::isActive
bool isActive() const
Definition: kurlnavigator.cpp:957
KUrl::protocol
QString protocol() const
KUrl::upUrl
KUrl upUrl() const
KDEPrivate::KUrlNavigatorToggleButton
Represents the button of the URL navigator to switch to the editable mode.
Definition: kurlnavigatortogglebutton_p.h:35
QStringList
KUrl::pathOrUrl
QString pathOrUrl() const
KUrlNavigator::~KUrlNavigator
virtual ~KUrlNavigator()
Definition: kurlnavigator.cpp:826
kurlnavigatorplacesselector_p.h
KIcon
kfileplacesmodel.h
KUrlNavigator::showFullPath
bool showFullPath() const
Definition: kurlnavigator.cpp:934
KUrlNavigator::historySize
int historySize() const
Definition: kurlnavigator.cpp:1180
KUrlNavigator::goBack
bool goBack()
Goes back one step in the URL history.
Definition: kurlnavigator.cpp:848
KUrlNavigator::setShowFullPath
void setShowFullPath(bool show)
Shows the full path of the URL even if a place represents a part of the URL.
Definition: kurlnavigator.cpp:926
kurlnavigatortogglebutton_p.h
KUrl::path
QString path(AdjustPathOption trailing=LeaveTrailingSlash) const
KDEPrivate::KUrlNavigatorButton::setShowMnemonic
void setShowMnemonic(bool show)
Definition: kurlnavigatorbutton.cpp:145
KUrlNavigator::activated
void activated()
Is emitted, if the URL navigator has been activated by an user interaction.
KUriFilterData
KUrlNavigator::saveLocationState
void saveLocationState(const QByteArray &state)
Saves the location state described by state for the current location.
Definition: kurlnavigator.cpp:837
kprotocolinfo.h
KUrlComboBox::Directories
KUriFilter::self
static KUriFilter * self()
KUrlNavigator::isPlacesSelectorVisible
bool isPlacesSelectorVisible() const
Definition: kurlnavigator.cpp:978
fixx11h.h
KDEPrivate::KUrlNavigatorProtocolCombo
A combobox listing available protocols.
Definition: kurlnavigatorprotocolcombo_p.h:41
kurlcombobox.h
KUrl::List
KUrlNavigator::tabRequested
void tabRequested(const KUrl &url)
Is emitted if the URL url should be opened in a new tab because the user clicked on a breadcrumb with...
QPoint
KUrlNavigator::editor
KUrlComboBox * editor() const
Definition: kurlnavigator.cpp:1190
KUrlNavigator::homeUrl
KUrl homeUrl() const
Definition: kurlnavigator.cpp:909
KUrlNavigator::goForward
bool goForward()
Goes forward one step in the URL history.
Definition: kurlnavigator.cpp:866
KUrlNavigator::returnPressed
void returnPressed()
This signal is emitted when the Return or Enter key is pressed.
KUrlNavigator::historyChanged
void historyChanged()
Is emitted, if the history has been changed.
QRect
KDEPrivate::KUrlNavigatorButton::setUrl
void setUrl(const KUrl &url)
Definition: kurlnavigatorbutton.cpp:71
KDEPrivate::KUrlNavigatorButton::setActiveSubDirectory
void setActiveSubDirectory(const QString &subDir)
Sets the name of the sub directory that should be marked when opening the sub directories popup...
Definition: kurlnavigatorbutton.cpp:121
KUrlNavigator::KUrlNavigator
KUrlNavigator(QWidget *parent=0)
Definition: kurlnavigator.cpp:810
KUrl::url
QString url(AdjustPathOption trailing=LeaveTrailingSlash) const
KUrlNavigator::setPlacesSelectorVisible
void setPlacesSelectorVisible(bool visible)
Sets the places selector visible, if visible is true.
Definition: kurlnavigator.cpp:962
KUrlNavigator
Widget that allows to navigate through the paths of an URL.
Definition: kurlnavigator.h:75
KUrlNavigator::setUrlEditable
void setUrlEditable(bool editable)
Allows to edit the URL of the navigation bar if editable is true, and sets the focus accordingly...
Definition: kurlnavigator.cpp:914
KUrlNavigator::requestActivation
void requestActivation()
Activates the URL navigator (KUrlNavigator::isActive() will return true) and emits the signal KUrlNav...
Definition: kurlnavigator.cpp:1071
KDEPrivate::KUrlNavigatorButton
Button of the URL navigator which contains one part of an URL.
Definition: kurlnavigatorbutton_p.h:53
kicon.h
KUrlNavigator::urlChanged
void urlChanged(const KUrl &url)
Is emitted, if the location URL has been changed e.
KUrl::isLocalFile
bool isLocalFile() const
KDEPrivate::KUrlNavigatorButtonBase::setActive
void setActive(bool active)
When having several URL navigator instances, it is important to provide a visual difference to indica...
Definition: kurlnavigatorbuttonbase.cpp:54
end
const KShortcut & end()
KUrl::equals
bool equals(const KUrl &u, const EqualsOptions &options=0) const
kfileitem.h
KUrl::prettyUrl
QString prettyUrl(AdjustPathOption trailing=LeaveTrailingSlash) const
kurlnavigator.h
KUriFilterData::setCheckForExecutables
void setCheckForExecutables(bool check)
QAction
KUrlCompletion
QList< LocationData >
begin
const KShortcut & begin()
kurlcompletion.h
KFilePlacesModel
This class is a list view model.
Definition: kfileplacesmodel.h:40
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:52:28 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KFile

Skip menu "KFile"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal