* Assure that the URL navigator is synchronized with the active column.

* Removed obsolete triggerUrlChangeRequest() method + signal in the DolphinController. This is not needed anymore because of the refactored column view.

svn path=/trunk/KDE/kdebase/apps/; revision=1080351
This commit is contained in:
Peter Penz 2010-01-26 08:27:42 +00:00
parent 5accf42fc8
commit e536466ac7
6 changed files with 29 additions and 40 deletions

View file

@ -334,13 +334,7 @@ void DolphinColumnView::keyPressEvent(QKeyEvent* event)
void DolphinColumnView::contextMenuEvent(QContextMenuEvent* event)
{
if (!m_active) {
m_container->requestActivation(this);
Q_ASSERT(m_container->m_controller->itemView() == this);
m_container->m_controller->triggerUrlChangeRequest(m_url);
}
Q_ASSERT(m_active);
requestActivation();
QListView::contextMenuEvent(event);
m_container->m_controller->triggerContextMenuRequest(event->pos());
}
@ -390,11 +384,8 @@ void DolphinColumnView::slotEntered(const QModelIndex& index)
void DolphinColumnView::requestActivation()
{
m_container->m_controller->setItemView(this);
m_container->m_controller->requestActivation();
if (!m_active) {
m_container->requestActivation(this);
m_container->m_controller->triggerUrlChangeRequest(m_url);
selectionModel()->clear();
}
}

View file

@ -30,6 +30,7 @@
#include <QPoint>
#include <QScrollBar>
#include <QTimeLine>
#include <QTimer>
DolphinColumnViewContainer::DolphinColumnViewContainer(QWidget* parent,
DolphinController* controller) :
@ -41,7 +42,8 @@ DolphinColumnViewContainer::DolphinColumnViewContainer(QWidget* parent,
m_columns(),
m_emptyViewport(0),
m_animation(0),
m_dragSource(0)
m_dragSource(0),
m_activeUrlTimer(0)
{
Q_ASSERT(controller != 0);
@ -59,6 +61,12 @@ DolphinColumnViewContainer::DolphinColumnViewContainer(QWidget* parent,
m_animation = new QTimeLine(500, this);
connect(m_animation, SIGNAL(frameChanged(int)), horizontalScrollBar(), SLOT(setValue(int)));
m_activeUrlTimer = new QTimer(this);
m_activeUrlTimer->setSingleShot(true);
m_activeUrlTimer->setInterval(200);
connect(m_activeUrlTimer, SIGNAL(timeout()),
this, SLOT(updateActiveUrl()));
DolphinColumnView* column = new DolphinColumnView(viewport(), this, m_controller->url());
m_columns.append(column);
setActiveColumnIndex(0);
@ -67,6 +75,7 @@ DolphinColumnViewContainer::DolphinColumnViewContainer(QWidget* parent,
m_emptyViewport->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
updateColumnsBackground(true);
}
DolphinColumnViewContainer::~DolphinColumnViewContainer()
@ -233,6 +242,12 @@ void DolphinColumnViewContainer::updateColumnsBackground(bool active)
}
}
void DolphinColumnViewContainer::updateActiveUrl()
{
const KUrl activeUrl = m_columns[m_index]->url();
m_controller->setUrl(activeUrl);
}
void DolphinColumnViewContainer::setActiveColumnIndex(int index)
{
if ((m_index == index) || (index < 0) || (index >= m_columns.count())) {
@ -248,6 +263,7 @@ void DolphinColumnViewContainer::setActiveColumnIndex(int index)
m_columns[m_index]->setActive(true);
assureVisibleActiveColumn();
m_activeUrlTimer->start(); // calls slot updateActiveUrl()
}
void DolphinColumnViewContainer::layoutColumns()

View file

@ -32,6 +32,7 @@ class DolphinColumnView;
class DolphinController;
class QFrame;
class QTimeLine;
class QTimer;
/**
* @brief Represents a container for columns represented as instances
@ -77,6 +78,14 @@ private slots:
*/
void updateColumnsBackground(bool active);
/**
* Tells the Dolphin controller to update the active URL
* to m_activeUrl. The slot is called asynchronously with a
* small delay, as this prevents a flickering when a directory
* from an inactive column gets selected.
*/
void updateActiveUrl();
private:
/**
* Deactivates the currently active column and activates
@ -127,6 +136,8 @@ private:
QTimeLine* m_animation;
QAbstractItemView* m_dragSource;
QTimer* m_activeUrlTimer;
friend class DolphinColumnView;
};

View file

@ -75,13 +75,6 @@ void DolphinController::setItemView(QAbstractItemView* view)
}
}
void DolphinController::triggerUrlChangeRequest(const KUrl& url)
{
if (m_url != url) {
emit requestUrlChange(url);
}
}
void DolphinController::triggerContextMenuRequest(const QPoint& pos,
const QList<QAction*>& customActions)
{

View file

@ -30,9 +30,6 @@ class DolphinView;
class KUrl;
class QPoint;
// TODO: get rid of all the state duplications in the controller and allow read access
// to the Dolphin view for all view implementations
/**
* @brief Acts as mediator between the abstract Dolphin view and the view
* implementations.
@ -52,7 +49,6 @@ class QPoint;
* The communication of the view implementations to the abstract view is done by:
* - triggerContextMenuRequest()
* - requestActivation()
* - triggerUrlChangeRequest()
* - indicateDroppedUrls()
* - indicateSortingChange()
* - indicateSortOrderChanged()
@ -111,16 +107,6 @@ public:
QAbstractItemView* itemView() const;
/**
* Allows a view implementation to request an URL change to \a url.
* The signal requestUrlChange() is emitted and the abstract Dolphin view
* will assure that the URL of the Dolphin Controller will be updated
* later. Invoking this method makes only sense if the view implementation
* shows a hierarchy of URLs and allows to change the URL within
* the view (e. g. this is the case in the column view).
*/
void triggerUrlChangeRequest(const KUrl& url);
/**
* Requests a context menu for the position \a pos. This method
* should be invoked by the view implementation when a context
@ -299,12 +285,6 @@ signals:
*/
void urlChanged(const KUrl& url);
/**
* Is emitted if the view implementation requests a changing of the current
* URL to \a url (see triggerUrlChangeRequest()).
*/
void requestUrlChange(const KUrl& url);
/**
* Is emitted if a context menu should be opened (see triggerContextMenuRequest()).
* The abstract Dolphin view connects to this signal and will open the context menu.

View file

@ -85,8 +85,6 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
this, SLOT(dropUrls(const KUrl&, QDropEvent*)));
connect(m_urlNavigator, SIGNAL(activated()),
this, SLOT(activate()));
//connect(m_urlNavigator, SIGNAL(tabRequested(const KUrl&)),
// this,
connect(m_urlNavigator->editor(), SIGNAL(completionModeChanged(KGlobalSettings::Completion)),
this, SLOT(saveUrlCompletionMode(KGlobalSettings::Completion)));