diff options
| -rw-r--r-- | src/bookmarkselector.cpp | 22 | ||||
| -rw-r--r-- | src/bookmarkselector.h | 9 | ||||
| -rw-r--r-- | src/dolphinmainwindow.cpp | 1 | ||||
| -rw-r--r-- | src/dolphinview.cpp | 28 | ||||
| -rw-r--r-- | src/dolphinview.h | 17 | ||||
| -rw-r--r-- | src/urlbutton.cpp | 17 | ||||
| -rw-r--r-- | src/urlbutton.h | 2 | ||||
| -rw-r--r-- | src/urlnavigator.cpp | 216 | ||||
| -rw-r--r-- | src/urlnavigator.h | 88 | ||||
| -rw-r--r-- | src/urlnavigatorbutton.cpp | 38 | ||||
| -rw-r--r-- | src/urlnavigatorbutton.h | 11 |
11 files changed, 245 insertions, 204 deletions
diff --git a/src/bookmarkselector.cpp b/src/bookmarkselector.cpp index 59f30e30a..44b705594 100644 --- a/src/bookmarkselector.cpp +++ b/src/bookmarkselector.cpp @@ -1,6 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006 by Peter Penz * - * [email protected] * + * Copyright (C) 2006 by Peter Penz ([email protected]) * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -18,6 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ +#include "bookmarkselector.h" #include <assert.h> #include <q3popupmenu.h> @@ -28,15 +28,13 @@ #include <kglobalsettings.h> #include <kbookmarkmanager.h> -#include "bookmarkselector.h" #include "dolphinsettings.h" -#include "dolphinview.h" -#include "dolphinmainwindow.h" #include "urlnavigator.h" BookmarkSelector::BookmarkSelector(UrlNavigator* parent) : UrlButton(parent), - m_selectedIndex(0) + m_selectedIndex(0), + m_urlNavigator(parent) { setFocusPolicy(Qt::NoFocus); @@ -113,7 +111,7 @@ QSize BookmarkSelector::sizeHint() const return QSize(height, height); } -void BookmarkSelector::paintEvent(QPaintEvent* event) +void BookmarkSelector::paintEvent(QPaintEvent* /*event*/) { QPainter painter(this); @@ -134,10 +132,7 @@ void BookmarkSelector::paintEvent(QPaintEvent* event) } // dimm the colors if the parent view does not have the focus - const DolphinView* parentView = urlNavigator()->dolphinView(); - const DolphinMainWindow* dolphin = parentView->mainWindow(); - - const bool isActive = (dolphin->activeView() == parentView); + const bool isActive = m_urlNavigator->isActive(); if (!isActive) { QColor dimmColor(palette().brush(QPalette::Background).color()); foregroundColor = mixColors(foregroundColor, dimmColor); @@ -168,10 +163,9 @@ void BookmarkSelector::slotBookmarkActivated(int index) { m_selectedIndex = index; - KBookmark bookmark = selectedBookmark(); + const KBookmark bookmark = selectedBookmark(); setPixmap(SmallIcon(bookmark.icon())); - - emit bookmarkActivated(index); + emit bookmarkActivated(bookmark.url()); } #include "bookmarkselector.moc" diff --git a/src/bookmarkselector.h b/src/bookmarkselector.h index c662618ec..50fc2e3e5 100644 --- a/src/bookmarkselector.h +++ b/src/bookmarkselector.h @@ -1,6 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006 by Peter Penz * - * [email protected] * + * Copyright (C) 2006 by Peter Penz ([email protected]) * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -35,7 +34,6 @@ class KUrl; * inside the bookmark selector. * * @see UrlNavigator - * @author Peter Penz <[email protected]> */ class BookmarkSelector : public UrlButton { @@ -74,9 +72,9 @@ public: signals: /** * Is send when a bookmark has been activated by the user. - * @param index Index of the selected bookmark. + * @param url URL of the selected bookmark. */ - void bookmarkActivated(int index); + void bookmarkActivated(const KUrl& url); protected: /** @@ -94,6 +92,7 @@ private slots: private: int m_selectedIndex; + UrlNavigator* m_urlNavigator; Q3PopupMenu* m_bookmarksMenu; }; diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 262bc8558..e8071ac44 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -702,6 +702,7 @@ void DolphinMainWindow::toggleSplitView() setActiveView(m_view[PrimaryIdx]);
}
}
+ emit activeViewChanged();
}
void DolphinMainWindow::reloadView()
diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 58c33b250..86b864583 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -79,9 +79,18 @@ DolphinView::DolphinView(DolphinMainWindow* mainWindow, m_topLayout->setSpacing(0); m_topLayout->setMargin(0); + connect(m_mainWindow, SIGNAL(activeViewChanged()), + this, SLOT(updateActivationState())); + m_urlNavigator = new UrlNavigator(url, this); connect(m_urlNavigator, SIGNAL(urlChanged(const KUrl&)), this, SLOT(loadDirectory(const KUrl&))); + connect(m_urlNavigator, SIGNAL(urlsDropped(const KUrl::List&, const KUrl&)), + this, SLOT(dropUrls(const KUrl::List&, const KUrl&))); + connect(m_urlNavigator, SIGNAL(activated()), + this, SLOT(requestActivation())); + connect(this, SIGNAL(contentsMoved(int, int)), + m_urlNavigator, SLOT(storeContentsPosition(int, int))); m_statusBar = new DolphinStatusBar(this); @@ -165,7 +174,7 @@ const KUrl& DolphinView::url() const bool DolphinView::isActive() const { - return (mainWindow()->activeView() == this); + return m_mainWindow->activeView() == this; } void DolphinView::setMode(Mode mode) @@ -554,11 +563,6 @@ void DolphinView::reload() startDirLister(m_urlNavigator->url(), true); } -void DolphinView::declareViewActive() -{ - mainWindow()->setActiveView( this ); -} - void DolphinView::mouseReleaseEvent(QMouseEvent* event) { QWidget::mouseReleaseEvent(event); @@ -886,9 +890,16 @@ void DolphinView::dropUrls(const KUrl::List& urls, const KUrl& destination = (directory == 0) ? url() : directory->url(); + dropUrls(urls, destination); +} + +void DolphinView::dropUrls(const KUrl::List& urls, + const KUrl& destination) +{ m_mainWindow->dropUrls(urls, destination); } + void DolphinView::updateSorting(DolphinView::Sorting sorting) { ViewProperties props(url()); @@ -914,6 +925,11 @@ void DolphinView::emitContentsMoved() emit contentsMoved(contentsX(), contentsY()); } +void DolphinView::updateActivationState() +{ + m_urlNavigator->setActive(isActive()); +} + void DolphinView::createView() { // delete current view diff --git a/src/dolphinview.h b/src/dolphinview.h index 4bb254f42..cffa52880 100644 --- a/src/dolphinview.h +++ b/src/dolphinview.h @@ -327,11 +327,6 @@ public: /** Reloads the current directory. */ void reload(); - /** - * Declare this View as the activeview of the mainWindow() - */ - void declareViewActive(); - public slots: /** * Popups the filter bar above the status bar if \a show is true. @@ -446,6 +441,12 @@ private slots: const QPoint& pos); /** + * Drops the URLs \a urls at the + * destination \a destination. + */ + void dropUrls(const KUrl::List& urls, + const KUrl& destination); + /** * Updates the view properties of the current URL to the * sorting given by \a sorting. */ @@ -463,6 +464,12 @@ private slots: */ void emitContentsMoved(); + /** + * Updates the activation state of the view by checking whether + * the currently active view is this view. + */ + void updateActivationState(); + private: void startDirLister(const KUrl& url, bool reload = false); diff --git a/src/urlbutton.cpp b/src/urlbutton.cpp index f2bf8ccda..b1faae393 100644 --- a/src/urlbutton.cpp +++ b/src/urlbutton.cpp @@ -32,29 +32,22 @@ #include "dolphinmainwindow.h" -UrlButton::UrlButton(UrlNavigator* parent) -: QPushButton(parent), - m_displayHint(0), - m_urlNavigator(parent) +UrlButton::UrlButton(UrlNavigator* parent) : + QPushButton(parent), + m_displayHint(0), + m_urlNavigator(parent) { setFocusPolicy(Qt::NoFocus); setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); setMinimumHeight(parent->minimumHeight()); - connect(this, SIGNAL(clicked()), parent, SLOT(slotRequestActivation())); - connect(parent->dolphinView()->mainWindow(), SIGNAL(activeViewChanged()), - this, SLOT(update())); + connect(this, SIGNAL(clicked()), parent, SLOT(requestActivation())); } UrlButton::~UrlButton() { } -UrlNavigator* UrlButton::urlNavigator() const -{ - return m_urlNavigator; -} - void UrlButton::setDisplayHintEnabled(DisplayHint hint, bool enable) { diff --git a/src/urlbutton.h b/src/urlbutton.h index 4c88a7d3a..06da18aba 100644 --- a/src/urlbutton.h +++ b/src/urlbutton.h @@ -44,7 +44,7 @@ public: explicit UrlButton(UrlNavigator* parent); virtual ~UrlButton(); - UrlNavigator* urlNavigator() const; + UrlNavigator* urlNavigator() const { return m_urlNavigator; } protected: enum DisplayHint { diff --git a/src/urlnavigator.cpp b/src/urlnavigator.cpp index d7c586961..93de43e67 100644 --- a/src/urlnavigator.cpp +++ b/src/urlnavigator.cpp @@ -34,6 +34,7 @@ #include <qsizepolicy.h> #include <qtooltip.h> //Added by qt3to4: +#include <QDir> #include <Q3ValueList> #include <QKeyEvent> #include <QCheckBox> @@ -42,6 +43,7 @@ #include <kactioncollection.h> #include <kiconloader.h> #include <kio/job.h> +#include <kfileitem.h> #include <klocale.h> #include <kprotocolinfo.h> #include <kurl.h> @@ -51,24 +53,21 @@ #include <kvbox.h> #include "bookmarkselector.h" -#include "dolphinmainwindow.h" #include "dolphinsettings.h" -#include "dolphinstatusbar.h" -#include "dolphinview.h" #include "generalsettings.h" #include "protocolcombo.h" #include "urlnavigatorbutton.h" -UrlNavigator::HistoryElem::HistoryElem() - : m_url(), +UrlNavigator::HistoryElem::HistoryElem() : + m_url(), m_currentFileName(), m_contentsX(0), m_contentsY(0) { } -UrlNavigator::HistoryElem::HistoryElem(const KUrl& url) - : m_url(url), +UrlNavigator::HistoryElem::HistoryElem(const KUrl& url) : + m_url(url), m_currentFileName(), m_contentsX(0), m_contentsY(0) @@ -80,10 +79,10 @@ UrlNavigator::HistoryElem::~HistoryElem() } UrlNavigator::UrlNavigator(const KUrl& url, - DolphinView* dolphinView) : - KHBox(dolphinView), + QWidget* parent) : + KHBox(parent), + m_active(true), m_historyIndex(0), - m_dolphinView(dolphinView), m_protocols(0), m_protocolSeparator(0), m_host(0) @@ -105,8 +104,8 @@ UrlNavigator::UrlNavigator(const KUrl& url, } m_bookmarkSelector = new BookmarkSelector(this); - connect(m_bookmarkSelector, SIGNAL(bookmarkActivated(int)), - this, SLOT(slotBookmarkActivated(int))); + connect(m_bookmarkSelector, SIGNAL(bookmarkActivated(const KUrl&)), + this, SLOT(setUrl(const KUrl&))); m_pathBox = new KUrlComboBox(KUrlComboBox::Directories, true, this); @@ -119,12 +118,8 @@ UrlNavigator::UrlNavigator(const KUrl& url, connect(m_pathBox, SIGNAL(urlActivated(const KUrl&)), this, SLOT(slotUrlActivated(const KUrl&))); - connect(dolphinView, SIGNAL(contentsMoved(int, int)), - this, SLOT(slotContentsMoved(int, int))); - connect(dolphinView, SIGNAL(redirection(const KUrl&, const KUrl&)), - this, SLOT(slotRedirection(const KUrl&, const KUrl&))); -/* connect(dolphinView, SIGNAL(redirection(const KUrl&)), - this, SLOT(slotRedirection(const KUrl&)));*/ + //connect(dolphinView, SIGNAL(redirection(const KUrl&, const KUrl&)), + // this, SLOT(slotRedirection(const KUrl&, const KUrl&))); updateContent(); } @@ -132,65 +127,6 @@ UrlNavigator::~UrlNavigator() { } -void UrlNavigator::setUrl(const KUrl& url) -{ - QString urlStr(url.pathOrUrl()); - //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. - const KUrl& nextUrl = m_history[m_historyIndex - 1].url(); - if (transformedUrl == nextUrl) { - goForward(); -// kDebug() << "goin' forward in history" << endl; - return; - } - } - - const KUrl& currUrl = m_history[m_historyIndex].url(); - if (currUrl == transformedUrl) { - // don't insert duplicate history elements -// kDebug() << "currUrl == transformedUrl" << endl; - return; - } - - updateHistoryElem(); - - const Q3ValueListIterator<UrlNavigator::HistoryElem> it = m_history.at(m_historyIndex); - 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) - { - kDebug() << i << ": " << (*it).url() << endl; - } - kDebug() << "history done ========================" << endl;*/ -} - const KUrl& UrlNavigator::url() const { assert(!m_history.empty()); @@ -273,9 +209,95 @@ void UrlNavigator::editUrl(bool editOrBrowse) } } -DolphinView* UrlNavigator::dolphinView() const +void UrlNavigator::setActive(bool active) +{ + if (active != m_active) { + m_active = active; + update(); + if (active) { + emit activated(); + } + } +} + +void UrlNavigator::dropUrls(const KUrl::List& urls, + const KUrl& destination) +{ + kDebug() << "------------------- URLS dropped" << endl; + emit urlsDropped(urls, destination); +} + +void UrlNavigator::setUrl(const KUrl& url) +{ + QString urlStr(url.pathOrUrl()); + //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. + const KUrl& nextUrl = m_history[m_historyIndex - 1].url(); + if (transformedUrl == nextUrl) { + goForward(); +// kDebug() << "goin' forward in history" << endl; + return; + } + } + + const KUrl& currUrl = m_history[m_historyIndex].url(); + if (currUrl == transformedUrl) { + // don't insert duplicate history elements +// kDebug() << "currUrl == transformedUrl" << endl; + return; + } + + updateHistoryElem(); + + const Q3ValueListIterator<UrlNavigator::HistoryElem> it = m_history.at(m_historyIndex); + 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) + { + kDebug() << i << ": " << (*it).url() << endl; + } + kDebug() << "history done ========================" << endl;*/ + + requestActivation(); +} + +void UrlNavigator::requestActivation() +{ + kDebug() << "--------------------------- request activation" << endl; + setActive(true); +} + +void UrlNavigator::storeContentsPosition(int x, int y) { - return m_dolphinView; + m_history[m_historyIndex].setContentsX(x); + m_history[m_historyIndex].setContentsY(y); } void UrlNavigator::keyReleaseEvent(QKeyEvent* event) @@ -399,20 +421,6 @@ void UrlNavigator::slotProtocolChanged(const QString& protocol) } } -void UrlNavigator::slotRequestActivation() -{ - m_dolphinView->requestActivation(); -} - -void UrlNavigator::slotBookmarkActivated(int index) -{ - m_dolphinView->statusBar()->clear(); - m_dolphinView->requestActivation(); - - KBookmark bookmark = DolphinSettings::instance().bookmark(index); - m_dolphinView->setUrl(bookmark.url()); -} - void UrlNavigator::slotRedirection(const KUrl& oldUrl, const KUrl& newUrl) { // kDebug() << "received redirection to " << newUrl << endl; @@ -426,12 +434,6 @@ kDebug() << "received redirection from " << oldUrl << " to " << newUrl << endl; m_urls.append(newUrl);*/ } -void UrlNavigator::slotContentsMoved(int x, int y) -{ - m_history[m_historyIndex].setContentsX(x); - m_history[m_historyIndex].setContentsY(y); -} - void UrlNavigator::slotClicked() { if (isUrlEditable()) { @@ -440,7 +442,7 @@ void UrlNavigator::slotClicked() } else { setUrl(m_pathBox->currentText()); - m_dolphinView->setFocus(); + emit requestActivation(); } } @@ -451,8 +453,6 @@ void UrlNavigator::updateHistoryElem() if (item != 0) { m_history[m_historyIndex].setCurrentFileName(item->name()); } - m_history[m_historyIndex].setContentsX(m_dolphinView->contentsX()); - m_history[m_historyIndex].setContentsY(m_dolphinView->contentsY()); } void UrlNavigator::updateContent() @@ -470,22 +470,26 @@ void UrlNavigator::updateContent() m_toggleButton->setToolTip(QString()); QString path(url().pathOrUrl()); - const QAction* action = dolphinView()->mainWindow()->actionCollection()->action("editable_location"); + + // TODO: prevent accessing the DolphinMainWindow out from this scope + //const QAction* action = dolphinView()->mainWindow()->actionCollection()->action("editable_location"); // TODO: registry of default shortcuts - QString shortcut = action? action->shortcut().toString() : "Ctrl+L"; + //QString shortcut = action? action->shortcut().toString() : "Ctrl+L"; + const QString shortcut = "Ctrl+L"; + if (m_toggleButton->isChecked()) { delete m_protocols; m_protocols = 0; delete m_protocolSeparator; m_protocolSeparator = 0; delete m_host; m_host = 0; - m_toggleButton->setToolTip(i18n("Browse (%1, Escape)",shortcut)); + m_toggleButton->setToolTip(i18n("Browse (%1, Escape)", shortcut)); setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); m_pathBox->show(); m_pathBox->setUrl(url()); } else { - m_toggleButton->setToolTip(i18n("Edit location (%1)",shortcut)); + m_toggleButton->setToolTip(i18n("Edit location (%1)", shortcut)); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); m_pathBox->hide(); diff --git a/src/urlnavigator.h b/src/urlnavigator.h index 5e7477a1c..bafece2ea 100644 --- a/src/urlnavigator.h +++ b/src/urlnavigator.h @@ -42,7 +42,6 @@ class KFileItem; class KUrlComboBox; class BookmarkSelector; -class DolphinView; class ProtocolCombo; /** @@ -103,16 +102,9 @@ public: int m_contentsY; }; - UrlNavigator(const KUrl& url, DolphinView* dolphinView); + UrlNavigator(const KUrl& url, QWidget* parent); virtual ~UrlNavigator(); - /** - * Sets the current active Url. - * The signals UrlNavigator::urlChanged and UrlNavigator::historyChanged - * are submitted. - */ - void setUrl(const KUrl& url); - /** Returns the current active Url. */ const KUrl& url() const; @@ -167,12 +159,75 @@ public: */ void editUrl(bool editOrBrowse); //TODO: switch to an enum - DolphinView* dolphinView() const; + /** + * Set the URL navigator to the active mode, if \a active + * is true. The active mode is default. Using the URL navigator + * in the inactive mode is useful when having split views, + * where the inactive view is indicated by a an inactive URL + * navigator visually. + */ + void setActive(bool active); + + /** + * Returns true, if the URL navigator is in the active mode. + * @see UrlNavigator::setActive() + */ + bool isActive() const { return m_active; } + + /** + * Handles the dropping of the URLs \a urls to the given + * destination \a destination and emits the signal urlsDropped. + */ + void dropUrls(const KUrl::List& urls, + const KUrl& destination); + +public slots: + /** + * Sets the current active URL. + * The signals UrlNavigator::urlChanged and UrlNavigator::historyChanged + * are submitted. + */ + void setUrl(const KUrl& url); + + /** + * Activates the URL navigator (UrlNavigator::isActive() will return true) + * and emits the signal 'activationChanged()'. + */ + void requestActivation(); + + /** + * Stores the coordinates of the contents into + * the current history element. + */ + void storeContentsPosition(int x, int y); signals: + /** + * Is emitted, if the URL navigator has been activated by + * a user interaction. + */ + void activated(); + + /** + * Is emitted, if the URL has been changed e. g. by + * the user. + * @see setUrl() + */ void urlChanged(const KUrl& url); + + /** + * Is emitted, if the history has been changed. Usually + * the history is changed if a new URL has been selected. + */ void historyChanged(); + /** + * Is emitted if the URLs \a urls have been dropped + * to the destination \a destination. + */ + void urlsDropped(const KUrl::List& urls, + const KUrl& destination); + protected: /** If the Escape key is pressed, the navigation bar should switch to the browse mode. */ @@ -183,20 +238,9 @@ private slots: void slotUrlActivated(const KUrl& url); void slotRemoteHostActivated(); void slotProtocolChanged(const QString& protocol); - - void slotRequestActivation(); - void slotBookmarkActivated(int index); - void slotRedirection(const KUrl&, const KUrl&); /** - * Stores the coordinates of the moved content into - * the current history element. Is usually triggered - * by the signal 'contentsMoved' emitted by DolphinView. - */ - void slotContentsMoved(int x, int y); - - /** * Switches the navigation bar between the editable and noneditable * state (see setUrlEditable()) and is connected to the clicked signal * of the navigation bar button. @@ -204,8 +248,8 @@ private slots: void slotClicked(); private: + bool m_active; int m_historyIndex; - DolphinView* m_dolphinView; Q3ValueList<HistoryElem> m_history; QCheckBox* m_toggleButton; BookmarkSelector* m_bookmarkSelector; diff --git a/src/urlnavigatorbutton.cpp b/src/urlnavigatorbutton.cpp index 9fe2186da..9616558a5 100644 --- a/src/urlnavigatorbutton.cpp +++ b/src/urlnavigatorbutton.cpp @@ -19,32 +19,26 @@ ***************************************************************************/ #include "urlnavigatorbutton.h" -#include <qcursor.h> -#include <qfontmetrics.h> -#include <qpainter.h> -#include <qtimer.h> -#include <qtooltip.h> -//Added by qt3to4: -#include <QDropEvent> -#include <QDragLeaveEvent> -#include <Q3PopupMenu> -#include <QEvent> -#include <QDragEnterEvent> + +#include <assert.h> + +#include "urlnavigator.h" #include <kglobalsettings.h> #include <kiconloader.h> +#include <kio/job.h> #include <kio/jobclasses.h> #include <klocale.h> #include <kurl.h> -#include <assert.h> -#include "urlnavigator.h" -#include "dolphinview.h" -#include "dolphinmainwindow.h" +#include <Q3PopupMenu> +#include <QPainter> +#include <QTimer> UrlNavigatorButton::UrlNavigatorButton(int index, UrlNavigator* parent) : UrlButton(parent), m_index(-1), + m_popupDelay(0), m_listJob(0) { setAcceptDrops(true); @@ -117,10 +111,7 @@ void UrlNavigatorButton::paintEvent(QPaintEvent* event) } // dimm the colors if the parent view does not have the focus - const DolphinView* parentView = urlNavigator()->dolphinView(); - const DolphinMainWindow* dolphin = parentView->mainWindow(); - - const bool isActive = (dolphin->activeView() == parentView); + const bool isActive = urlNavigator()->isActive(); if (!isActive) { QColor dimmColor(palette().brush(QPalette::Background).color()); foregroundColor = mixColors(foregroundColor, dimmColor); @@ -218,8 +209,7 @@ void UrlNavigatorButton::dropEvent(QDropEvent* event) QString path(urlNavigator()->url().prettyUrl()); path = path.section('/', 0, m_index + 2); - DolphinMainWindow* win = urlNavigator()->dolphinView()->mainWindow(); - win->dropUrls(urls, KUrl(path)); + urlNavigator()->dropUrls(urls, KUrl(path)); setDisplayHintEnabled(DraggedHint, false); update(); @@ -251,9 +241,7 @@ void UrlNavigatorButton::updateNavigatorUrl() return; } - UrlNavigator* navigator = urlNavigator(); - assert(navigator != 0); - navigator->setUrl(navigator->url(m_index)); + urlNavigator()->setUrl(urlNavigator()->url(m_index)); } void UrlNavigatorButton::startPopupDelay() @@ -300,7 +288,7 @@ void UrlNavigatorButton::entriesList(KIO::Job* job, const KIO::UDSEntryList& ent KIO::UDSEntryList::const_iterator itEnd = entries.constEnd(); while (it != itEnd) { QString name; - bool isDir = false; + //bool isDir = false; KIO::UDSEntry entry = *it; /* KDE3 reference: diff --git a/src/urlnavigatorbutton.h b/src/urlnavigatorbutton.h index 0ddaf66a3..9234f0b10 100644 --- a/src/urlnavigatorbutton.h +++ b/src/urlnavigatorbutton.h @@ -20,16 +20,10 @@ #ifndef UrlNAVIGATORBUTTON_H #define UrlNAVIGATORBUTTON_H -#include <qstringlist.h> -#include <QEvent> -#include <QDragLeaveEvent> -#include <QDropEvent> -#include <QDragEnterEvent> - #include <kio/global.h> - #include <urlbutton.h> +class KJob; class KUrl; class UrlNavigator; class QPainter; @@ -52,7 +46,7 @@ class UrlNavigatorButton : public UrlButton Q_OBJECT public: - explicit UrlNavigatorButton(int index, UrlNavigator* parent = 0); + explicit UrlNavigatorButton(int index, UrlNavigator* parent); virtual ~UrlNavigatorButton(); void setIndex(int index); int index() const { return m_index; } @@ -80,6 +74,7 @@ private: int arrowWidth() const; bool isTextClipped() const; +private: int m_index; QTimer* m_popupDelay; KIO::Job* m_listJob; |
