]> cloud.milkyroute.net Git - dolphin.git/blob - src/urlnavigator.cpp
Added setters in urlnavigator to remove dependency on dolphinsettings.
[dolphin.git] / src / urlnavigator.cpp
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz (<peter.penz@gmx.at>) *
3 * Copyright (C) 2006 by Aaron J. Seigo (<aseigo@kde.org>) *
4 * Copyright (C) 2006 by Patrice Tremblay *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20 ***************************************************************************/
21
22 #include "urlnavigator.h"
23
24 #include "bookmarkselector.h"
25 #include "protocolcombo.h"
26 #include "urlnavigatorbutton.h"
27
28 #include <assert.h>
29
30 #include <kfileitem.h>
31 #include <kicon.h>
32 #include <klocale.h>
33 #include <kprotocolinfo.h>
34 #include <kurlcombobox.h>
35 #include <kurlcompletion.h>
36
37 #include <QApplication>
38 #include <QClipboard>
39 #include <QDir>
40 #include <QHBoxLayout>
41 #include <QLabel>
42 #include <QLineEdit>
43 #include <QLinkedList>
44 #include <QMouseEvent>
45 #include <QToolButton>
46
47 UrlNavigator::HistoryElem::HistoryElem() :
48 m_url(),
49 m_currentFileName(),
50 m_contentsX(0),
51 m_contentsY(0)
52 {
53 }
54
55 UrlNavigator::HistoryElem::HistoryElem(const KUrl& url) :
56 m_url(url),
57 m_currentFileName(),
58 m_contentsX(0),
59 m_contentsY(0)
60 {
61 }
62
63 UrlNavigator::HistoryElem::~HistoryElem()
64 {
65 }
66
67 class UrlNavigator::Private
68 {
69 public:
70 Private(UrlNavigator* q, KBookmarkManager* bookmarkManager);
71
72 void slotReturnPressed(const QString&);
73 void slotRemoteHostActivated();
74 void slotProtocolChanged(const QString&);
75
76 /**
77 * Appends the widget at the end of the URL navigator. It is assured
78 * that the filler widget remains as last widget to fill the remaining
79 * width.
80 */
81 void appendWidget(QWidget* widget);
82
83 /**
84 * Switches the navigation bar between the breadcrumb view and the
85 * traditional view (see setUrlEditable()) and is connected to the clicked signal
86 * of the navigation bar button.
87 */
88 void switchView();
89
90 /**
91 * Updates the history element with the current file item
92 * and the contents position.
93 */
94 void updateHistoryElem();
95 void updateContent();
96
97 /**
98 * Updates all buttons to have one button for each part of the
99 * path \a path. Existing buttons, which are available by m_navButtons,
100 * are reused if possible. If the path is longer, new buttons will be
101 * created, if the path is shorter, the remaining buttons will be deleted.
102 * @param startIndex Start index of path part (/), where the buttons
103 * should be created for each following part.
104 */
105 void updateButtons(const QString& path, int startIndex);
106
107 /**
108 * Deletes all URL navigator buttons. m_navButtons is
109 * empty after this operation.
110 */
111 void deleteButtons();
112
113
114 bool m_active;
115 bool m_showHiddenFiles;
116 int m_historyIndex;
117
118 QHBoxLayout* m_layout;
119
120 QList<HistoryElem> m_history;
121 QToolButton* m_toggleButton;
122 BookmarkSelector* m_bookmarkSelector;
123 KUrlComboBox* m_pathBox;
124 ProtocolCombo* m_protocols;
125 QLabel* m_protocolSeparator;
126 QLineEdit* m_host;
127 QLinkedList<UrlNavigatorButton*> m_navButtons;
128 QWidget* m_filler;
129 QString m_homeUrl;
130 UrlNavigator* q;
131 };
132
133
134 UrlNavigator::Private::Private(UrlNavigator* q, KBookmarkManager* bookmarkManager)
135 :
136 m_active(true),
137 m_showHiddenFiles(false),
138 m_historyIndex(0),
139 m_layout(new QHBoxLayout),
140 m_protocols(0),
141 m_protocolSeparator(0),
142 m_host(0),
143 m_filler(0),
144 q(q)
145 {
146 m_layout->setSpacing(0);
147 m_layout->setMargin(0);
148
149 // initialize toggle button which switches between the breadcrumb view
150 // and the traditional view
151 m_toggleButton = new QToolButton();
152 m_toggleButton->setCheckable(true);
153 m_toggleButton->setAutoRaise(true);
154 m_toggleButton->setIcon(KIcon("editinput")); // TODO: is just a placeholder icon (?)
155 m_toggleButton->setFocusPolicy(Qt::NoFocus);
156 m_toggleButton->setMinimumHeight(q->minimumHeight());
157 connect(m_toggleButton, SIGNAL(clicked()),
158 q, SLOT(switchView()));
159
160 // initialize the bookmark selector
161 m_bookmarkSelector = new BookmarkSelector(q, bookmarkManager);
162 connect(m_bookmarkSelector, SIGNAL(bookmarkActivated(const KUrl&)),
163 q, SLOT(setUrl(const KUrl&)));
164
165 // initialize the path box of the traditional view
166 m_pathBox = new KUrlComboBox(KUrlComboBox::Directories, true, q);
167
168 KUrlCompletion* kurlCompletion = new KUrlCompletion(KUrlCompletion::DirCompletion);
169 m_pathBox->setCompletionObject(kurlCompletion);
170 m_pathBox->setAutoDeleteCompletionObject(true);
171
172 connect(m_pathBox, SIGNAL(returnPressed(QString)),
173 q, SLOT(slotReturnPressed(QString)));
174 connect(m_pathBox, SIGNAL(urlActivated(KUrl)),
175 q, SLOT(setUrl(KUrl)));
176
177 // Append a filler widget at the end, which automatically resizes to the
178 // maximum available width. This assures that the URL navigator uses the
179 // whole width, so that the clipboard content can be dropped.
180 m_filler = new QWidget();
181 m_filler->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
182
183 m_layout->addWidget(m_toggleButton);
184 m_layout->addWidget(m_bookmarkSelector);
185 m_layout->addWidget(m_pathBox);
186 m_layout->addWidget(m_filler);
187 }
188
189 void UrlNavigator::Private::appendWidget(QWidget* widget)
190 {
191 m_layout->insertWidget(m_layout->count() - 1, widget);
192 }
193
194 void UrlNavigator::Private::slotReturnPressed(const QString& text)
195 {
196 // Parts of the following code have been taken
197 // from the class KateFileSelector located in
198 // kate/app/katefileselector.hpp of Kate.
199 // Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
200 // Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
201 // Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
202
203 KUrl typedUrl(text);
204 if (typedUrl.hasPass()) {
205 typedUrl.setPass(QString());
206 }
207
208 QStringList urls = m_pathBox->urls();
209 urls.removeAll(typedUrl.url());
210 urls.prepend(typedUrl.url());
211 m_pathBox->setUrls(urls, KUrlComboBox::RemoveBottom);
212
213 q->setUrl(typedUrl);
214 // The URL might have been adjusted by UrlNavigator::setUrl(), hence
215 // synchronize the result in the path box.
216 m_pathBox->setUrl(q->url());
217 }
218
219 void UrlNavigator::Private::slotRemoteHostActivated()
220 {
221 KUrl u = q->url();
222
223 QString host = m_host->text();
224 QString user;
225
226 int marker = host.indexOf("@");
227 if (marker != -1)
228 {
229 user = host.left(marker);
230 u.setUser(user);
231 host = host.right(host.length() - marker - 1);
232 }
233
234 marker = host.indexOf("/");
235 if (marker != -1)
236 {
237 u.setPath(host.right(host.length() - marker));
238 host.truncate(marker);
239 }
240 else
241 {
242 u.setPath("");
243 }
244
245 if (m_protocols->currentProtocol() != u.protocol() ||
246 host != u.host() ||
247 user != u.user())
248 {
249 u.setProtocol(m_protocols->currentProtocol());
250 u.setHost(m_host->text());
251
252 //TODO: get rid of this HACK for file:///!
253 if (u.protocol() == "file")
254 {
255 u.setHost("");
256 if (u.path().isEmpty())
257 {
258 u.setPath("/");
259 }
260 }
261
262 q->setUrl(u);
263 }
264 }
265
266 void UrlNavigator::Private::slotProtocolChanged(const QString& protocol)
267 {
268 KUrl url;
269 url.setProtocol(protocol);
270 //url.setPath(KProtocolInfo::protocolClass(protocol) == ":local" ? "/" : "");
271 url.setPath("/");
272 QLinkedList<UrlNavigatorButton*>::const_iterator it = m_navButtons.begin();
273 const QLinkedList<UrlNavigatorButton*>::const_iterator itEnd = m_navButtons.end();
274 while (it != itEnd) {
275 (*it)->close();
276 (*it)->deleteLater();
277 ++it;
278 }
279 m_navButtons.clear();
280
281 if (KProtocolInfo::protocolClass(protocol) == ":local") {
282 q->setUrl(url);
283 }
284 else {
285 if (!m_host) {
286 m_protocolSeparator = new QLabel("://", q);
287 appendWidget(m_protocolSeparator);
288 m_host = new QLineEdit(q);
289 appendWidget(m_host);
290
291 connect(m_host, SIGNAL(lostFocus()),
292 q, SLOT(slotRemoteHostActivated()));
293 connect(m_host, SIGNAL(returnPressed()),
294 q, SLOT(slotRemoteHostActivated()));
295 }
296 else {
297 m_host->setText("");
298 }
299 m_protocolSeparator->show();
300 m_host->show();
301 m_host->setFocus();
302 }
303 }
304
305 #if 0
306 void UrlNavigator::slotRedirection(const KUrl& oldUrl, const KUrl& newUrl)
307 {
308 // kDebug() << "received redirection to " << newUrl << endl;
309 kDebug() << "received redirection from " << oldUrl << " to " << newUrl << endl;
310 /* UrlStack::iterator it = m_urls.find(oldUrl);
311 if (it != m_urls.end())
312 {
313 m_urls.erase(++it, m_urls.end());
314 }
315
316 m_urls.append(newUrl);*/
317 }
318 #endif
319
320 void UrlNavigator::Private::switchView()
321 {
322 updateContent();
323 if (q->isUrlEditable()) {
324 m_pathBox->setFocus();
325 } else {
326 q->setUrl(m_pathBox->currentText());
327 }
328 emit q->requestActivation();
329 }
330
331 void UrlNavigator::Private::updateHistoryElem()
332 {
333 assert(m_historyIndex >= 0);
334 const KFileItem* item = 0; // TODO: m_dolphinView->currentFileItem();
335 if (item != 0) {
336 HistoryElem& hist = m_history[m_historyIndex];
337 hist.setCurrentFileName(item->name());
338 }
339 }
340
341 void UrlNavigator::Private::updateContent()
342 {
343 m_bookmarkSelector->updateSelection(q->url());
344
345 m_toggleButton->setToolTip(QString());
346 QString path(q->url().pathOrUrl());
347
348 // TODO: prevent accessing the DolphinMainWindow out from this scope
349 //const QAction* action = dolphinView()->mainWindow()->actionCollection()->action("editable_location");
350 // TODO: registry of default shortcuts
351 //QString shortcut = action? action->shortcut().toString() : "Ctrl+L";
352 const QString shortcut = "Ctrl+L";
353
354 if (m_toggleButton->isChecked()) {
355 delete m_protocols; m_protocols = 0;
356 delete m_protocolSeparator; m_protocolSeparator = 0;
357 delete m_host; m_host = 0;
358 deleteButtons();
359 m_filler->hide();
360
361 m_toggleButton->setToolTip(i18n("Browse (%1, Escape)", shortcut));
362
363 q->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
364 m_pathBox->show();
365 m_pathBox->setUrl(q->url());
366 }
367 else {
368 m_toggleButton->setToolTip(i18n("Edit location (%1)", shortcut));
369
370 q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
371 m_pathBox->hide();
372 m_filler->show();
373
374 // get the data from the currently selected bookmark
375 KBookmark bookmark = m_bookmarkSelector->selectedBookmark();
376
377 QString bookmarkPath;
378 if (bookmark.isNull()) {
379 // No bookmark is a part of the current Url.
380 // The following code tries to guess the bookmark
381 // path. E. g. "fish://root@192.168.0.2/var/lib" writes
382 // "fish://root@192.168.0.2" to 'bookmarkPath', which leads to the
383 // navigation indication 'Custom Path > var > lib".
384 int idx = path.indexOf(QString("//"));
385 idx = path.indexOf("/", (idx < 0) ? 0 : idx + 2);
386 bookmarkPath = (idx < 0) ? path : path.left(idx);
387 }
388 else {
389 bookmarkPath = bookmark.url().pathOrUrl();
390 }
391 const uint len = bookmarkPath.length();
392
393 // calculate the start point for the URL navigator buttons by counting
394 // the slashs inside the bookmark URL
395 int slashCount = 0;
396 for (uint i = 0; i < len; ++i) {
397 if (bookmarkPath.at(i) == QChar('/')) {
398 ++slashCount;
399 }
400 }
401 if ((len > 0) && bookmarkPath.at(len - 1) == QChar('/')) {
402 assert(slashCount > 0);
403 --slashCount;
404 }
405
406 const KUrl currentUrl = q->url();
407 if (!currentUrl.isLocalFile() && bookmark.isNull()) {
408 QString protocol = currentUrl.protocol();
409 if (!m_protocols) {
410 deleteButtons();
411 m_protocols = new ProtocolCombo(protocol, q);
412 appendWidget(m_protocols);
413 connect(m_protocols, SIGNAL(activated(QString)),
414 q, SLOT(slotProtocolChanged(QString)));
415 }
416 else {
417 m_protocols->setProtocol(protocol);
418 }
419 m_protocols->show();
420
421 if (KProtocolInfo::protocolClass(protocol) != ":local") {
422 QString hostText = currentUrl.host();
423
424 if (!currentUrl.user().isEmpty()) {
425 hostText = currentUrl.user() + '@' + hostText;
426 }
427
428 if (!m_host) {
429 // ######### TODO: this code is duplicated from slotProtocolChanged!
430 m_protocolSeparator = new QLabel("://", q);
431 appendWidget(m_protocolSeparator);
432 m_host = new QLineEdit(hostText, q);
433 appendWidget(m_host);
434
435 connect(m_host, SIGNAL(lostFocus()),
436 q, SLOT(slotRemoteHostActivated()));
437 connect(m_host, SIGNAL(returnPressed()),
438 q, SLOT(slotRemoteHostActivated()));
439 }
440 else {
441 m_host->setText(hostText);
442 }
443 m_protocolSeparator->show();
444 m_host->show();
445 }
446 else {
447 delete m_protocolSeparator; m_protocolSeparator = 0;
448 delete m_host; m_host = 0;
449 }
450 }
451 else if (m_protocols) {
452 m_protocols->hide();
453
454 if (m_host) {
455 m_protocolSeparator->hide();
456 m_host->hide();
457 }
458 }
459
460 updateButtons(path, slashCount);
461 }
462 }
463
464 void UrlNavigator::Private::updateButtons(const QString& path, int startIndex)
465 {
466 QLinkedList<UrlNavigatorButton*>::iterator it = m_navButtons.begin();
467 const QLinkedList<UrlNavigatorButton*>::const_iterator itEnd = m_navButtons.end();
468 bool createButton = false;
469 const KUrl currentUrl = q->url();
470
471 int idx = startIndex;
472 bool hasNext = true;
473 do {
474 createButton = (it == itEnd);
475
476 const QString dirName = path.section('/', idx, idx);
477 const bool isFirstButton = (idx == startIndex);
478 hasNext = isFirstButton || !dirName.isEmpty();
479 if (hasNext) {
480 QString text;
481 if (isFirstButton) {
482 // the first URL navigator button should get the name of the
483 // bookmark instead of the directory name
484 const KBookmark bookmark = m_bookmarkSelector->selectedBookmark();
485 text = bookmark.text();
486 if (text.isEmpty()) {
487 if (currentUrl.isLocalFile()) {
488 text = i18n("Custom Path");
489 }
490 else {
491 ++idx;
492 continue;
493 }
494 }
495 }
496
497 UrlNavigatorButton* button = 0;
498 if (createButton) {
499 button = new UrlNavigatorButton(idx, q);
500 appendWidget(button);
501 }
502 else {
503 button = *it;
504 button->setIndex(idx);
505 }
506
507 if (isFirstButton) {
508 button->setText(text);
509 }
510
511 if (createButton) {
512 button->show();
513 m_navButtons.append(button);
514 }
515 else {
516 ++it;
517 }
518 ++idx;
519 }
520 } while (hasNext);
521
522 // delete buttons which are not used anymore
523 QLinkedList<UrlNavigatorButton*>::iterator itBegin = it;
524 while (it != itEnd) {
525 (*it)->close();
526 (*it)->deleteLater();
527 ++it;
528 }
529 m_navButtons.erase(itBegin, m_navButtons.end());
530 }
531
532 void UrlNavigator::Private::deleteButtons()
533 {
534 QLinkedList<UrlNavigatorButton*>::iterator itBegin = m_navButtons.begin();
535 QLinkedList<UrlNavigatorButton*>::iterator itEnd = m_navButtons.end();
536 QLinkedList<UrlNavigatorButton*>::iterator it = itBegin;
537 while (it != itEnd) {
538 (*it)->close();
539 (*it)->deleteLater();
540 ++it;
541 }
542 m_navButtons.erase(itBegin, itEnd);
543 }
544
545 ////
546
547
548 UrlNavigator::UrlNavigator(KBookmarkManager* bookmarkManager,
549 const KUrl& url,
550 QWidget* parent) :
551 QWidget(parent),
552 d( new Private(this, bookmarkManager) )
553 {
554 d->m_history.prepend(HistoryElem(url));
555
556 QFontMetrics fontMetrics(font());
557 setMinimumHeight(fontMetrics.height() + 10);
558
559 setLayout(d->m_layout);
560
561 d->updateContent();
562 }
563
564 UrlNavigator::~UrlNavigator()
565 {
566 delete d;
567 }
568
569 const KUrl& UrlNavigator::url() const
570 {
571 assert(!d->m_history.empty());
572 return d->m_history[d->m_historyIndex].url();
573 }
574
575 KUrl UrlNavigator::url(int index) const
576 {
577 assert(index >= 0);
578 // keep scheme, hostname etc. maybe we will need this in the future
579 // for e.g. browsing ftp repositories.
580 KUrl newurl(url());
581 newurl.setPath(QString());
582 QString path(url().path());
583
584 if (!path.isEmpty()) {
585 if (index == 0) //prevent the last "/" from being stripped
586 path = "/"; //or we end up with an empty path
587 else
588 path = path.section('/', 0, index);
589 }
590
591 newurl.setPath(path);
592 return newurl;
593 }
594
595 UrlNavigator::HistoryElem UrlNavigator::currentHistoryItem() const
596 {
597 return d->m_history[d->m_historyIndex];
598 }
599
600 int UrlNavigator::historySize() const
601 {
602 return d->m_history.count();
603 }
604
605 void UrlNavigator::goBack()
606 {
607 d->updateHistoryElem();
608
609 const int count = d->m_history.count();
610 if (d->m_historyIndex < count - 1) {
611 ++d->m_historyIndex;
612 d->updateContent();
613 emit urlChanged(url());
614 emit historyChanged();
615 }
616 }
617
618 void UrlNavigator::goForward()
619 {
620 if (d->m_historyIndex > 0) {
621 --d->m_historyIndex;
622 d->updateContent();
623 emit urlChanged(url());
624 emit historyChanged();
625 }
626 }
627
628 void UrlNavigator::goUp()
629 {
630 setUrl(url().upUrl());
631 }
632
633 void UrlNavigator::goHome()
634 {
635 if (d->m_homeUrl.isEmpty())
636 setUrl(QDir::homePath());
637 else
638 setUrl(d->m_homeUrl);
639 }
640
641 bool UrlNavigator::isUrlEditable() const
642 {
643 return d->m_toggleButton->isChecked();
644 }
645
646 void UrlNavigator::setUrlEditable(bool editable)
647 {
648 if (isUrlEditable() != editable) {
649 d->m_toggleButton->toggle();
650 d->switchView();
651 }
652 }
653
654 void UrlNavigator::setActive(bool active)
655 {
656 if (active != d->m_active) {
657 d->m_active = active;
658 update();
659 if (active) {
660 emit activated();
661 }
662 }
663 }
664
665 void UrlNavigator::setShowHiddenFiles( bool show )
666 {
667 d->m_showHiddenFiles = show;
668 }
669
670 void UrlNavigator::dropUrls(const KUrl::List& urls,
671 const KUrl& destination)
672 {
673 emit urlsDropped(urls, destination);
674 }
675
676 void UrlNavigator::setUrl(const KUrl& url)
677 {
678 QString urlStr(url.pathOrUrl());
679
680 // TODO: a patch has been submitted by Filip Brcic which adjusts
681 // the URL for tar and zip files. See https://bugs.kde.org/show_bug.cgi?id=142781
682 // for details. The URL navigator part of the patch has not been committed yet,
683 // as the URL navigator will be subject of change and
684 // we might think of a more generic approach to check the protocol + MIME type for
685 // this use case.
686
687 //kDebug() << "setUrl(" << url << ")" << endl;
688 if ( urlStr.length() > 0 && urlStr.at(0) == '~') {
689 // replace '~' by the home directory
690 urlStr.remove(0, 1);
691 urlStr.insert(0, QDir::homePath());
692 }
693
694 const KUrl transformedUrl(urlStr);
695
696 if (d->m_historyIndex > 0) {
697 // Check whether the previous element of the history has the same Url.
698 // If yes, just go forward instead of inserting a duplicate history
699 // element.
700 HistoryElem& prevHistoryElem = d->m_history[d->m_historyIndex - 1];
701 if (transformedUrl == prevHistoryElem.url()) {
702 goForward();
703 // kDebug() << "goin' forward in history" << endl;
704 return;
705 }
706 }
707
708 if (this->url() == transformedUrl) {
709 // don't insert duplicate history elements
710 // kDebug() << "current url == transformedUrl" << endl;
711 return;
712 }
713
714 d->updateHistoryElem();
715 d->m_history.insert(d->m_historyIndex, HistoryElem(transformedUrl));
716
717 d->updateContent();
718
719 emit urlChanged(transformedUrl);
720 emit historyChanged();
721
722 // Prevent an endless growing of the history: remembering
723 // the last 100 Urls should be enough...
724 if (d->m_historyIndex > 100) {
725 d->m_history.removeFirst();
726 --d->m_historyIndex;
727 }
728
729 /* kDebug() << "history starting ====================" << endl;
730 int i = 0;
731 for (QValueListIterator<UrlNavigator::HistoryElem> it = d->m_history.begin();
732 it != d->m_history.end();
733 ++it, ++i)
734 {
735 kDebug() << i << ": " << (*it).url() << endl;
736 }
737 kDebug() << "history done ========================" << endl;*/
738
739 requestActivation();
740 }
741
742 void UrlNavigator::requestActivation()
743 {
744 setActive(true);
745 }
746
747 void UrlNavigator::storeContentsPosition(int x, int y)
748 {
749 HistoryElem& hist = d->m_history[d->m_historyIndex];
750 hist.setContentsX(x);
751 hist.setContentsY(y);
752 }
753
754 void UrlNavigator::keyReleaseEvent(QKeyEvent* event)
755 {
756 QWidget::keyReleaseEvent(event);
757 if (isUrlEditable() && (event->key() == Qt::Key_Escape)) {
758 setUrlEditable(false);
759 }
760 }
761
762 void UrlNavigator::mouseReleaseEvent(QMouseEvent* event)
763 {
764 if (event->button() == Qt::MidButton) {
765 QClipboard* clipboard = QApplication::clipboard();
766 const QMimeData* mimeData = clipboard->mimeData();
767 if (mimeData->hasText()) {
768 const QString text = mimeData->text();
769 setUrl(KUrl(text));
770 }
771 }
772 QWidget::mouseReleaseEvent(event);
773 }
774
775 bool UrlNavigator::isActive() const
776 {
777 return d->m_active;
778 }
779
780 bool UrlNavigator::showHiddenFiles() const
781 {
782 return d->m_showHiddenFiles;
783 }
784
785 void UrlNavigator::setHomeUrl(const QString& homeUrl)
786 {
787 d->m_homeUrl = homeUrl;
788 }
789
790 #include "urlnavigator.moc"