+void UrlNavigator::setActive(bool active)
+{
+ if (active != m_active) {
+ m_active = active;
+ update();
+ if (active) {
+ emit activated();
+ }
+ }
+}
+
+void UrlNavigator::setShowHiddenFiles( bool show )
+{
+ m_showHiddenFiles = show;
+}
+
+void UrlNavigator::dropUrls(const KUrl::List& urls,
+ const KUrl& destination)
+{
+ emit urlsDropped(urls, destination);
+}
+
+void UrlNavigator::setUrl(const KUrl& url)
+{
+ QString urlStr(url.pathOrUrl());
+
+ // TODO: a patch has been submitted by Filip Brcic which adjusts
+ // the URL for tar and zip files. See https://bugs.kde.org/show_bug.cgi?id=142781
+ // for details. The URL navigator part of the patch has not been committed yet,
+ // as the URL navigator will be subject of change and
+ // we might think of a more generic approach to check the protocol + MIME type for
+ // this use case.
+
+ //kDebug() << "setUrl(" << url << ")" << endl;
+ if ( urlStr.length() > 0 && urlStr.at(0) == '~') {
+ // replace '~' by the home directory
+ urlStr.remove(0, 1);
+ urlStr.insert(0, QDir::home().path());
+ }
+
+ const KUrl transformedUrl(urlStr);
+
+ if (m_historyIndex > 0) {
+ // Check whether the previous element of the history has the same Url.
+ // If yes, just go forward instead of inserting a duplicate history
+ // element.
+ QLinkedList<HistoryElem>::const_iterator it = m_history.begin();
+ it += m_historyIndex - 1;
+ const KUrl& nextUrl = (*it).url();
+ if (transformedUrl == nextUrl) {
+ goForward();
+// kDebug() << "goin' forward in history" << endl;
+ return;
+ }
+ }
+
+ QLinkedList<HistoryElem>::iterator it = m_history.begin() + m_historyIndex;
+ const KUrl& currUrl = (*it).url();
+ if (currUrl == transformedUrl) {
+ // don't insert duplicate history elements
+// kDebug() << "currUrl == transformedUrl" << endl;
+ return;
+ }
+
+ updateHistoryElem();
+ m_history.insert(it, HistoryElem(transformedUrl));
+
+ updateContent();
+
+ emit urlChanged(transformedUrl);
+ emit historyChanged();
+
+ // Prevent an endless growing of the history: remembering
+ // the last 100 Urls should be enough...
+ if (m_historyIndex > 100) {
+ m_history.erase(m_history.begin());
+ --m_historyIndex;
+ }
+
+/* kDebug() << "history starting ====================" << endl;
+ int i = 0;
+ for (QValueListIterator<UrlNavigator::HistoryElem> it = m_history.begin();
+ it != m_history.end();
+ ++it, ++i)