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());
}
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();
}
}
#include <QPoint>
#include <QScrollBar>
#include <QTimeLine>
+#include <QTimer>
DolphinColumnViewContainer::DolphinColumnViewContainer(QWidget* parent,
DolphinController* controller) :
m_columns(),
m_emptyViewport(0),
m_animation(0),
- m_dragSource(0)
+ m_dragSource(0),
+ m_activeUrlTimer(0)
{
Q_ASSERT(controller != 0);
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);
m_emptyViewport->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
updateColumnsBackground(true);
+
}
DolphinColumnViewContainer::~DolphinColumnViewContainer()
}
}
+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())) {
m_columns[m_index]->setActive(true);
assureVisibleActiveColumn();
+ m_activeUrlTimer->start(); // calls slot updateActiveUrl()
}
void DolphinColumnViewContainer::layoutColumns()
class DolphinController;
class QFrame;
class QTimeLine;
+class QTimer;
/**
* @brief Represents a container for columns represented as instances
*/
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
QTimeLine* m_animation;
QAbstractItemView* m_dragSource;
+ QTimer* m_activeUrlTimer;
+
friend class DolphinColumnView;
};
}
}
-void DolphinController::triggerUrlChangeRequest(const KUrl& url)
-{
- if (m_url != url) {
- emit requestUrlChange(url);
- }
-}
-
void DolphinController::triggerContextMenuRequest(const QPoint& pos,
const QList<QAction*>& customActions)
{
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.
* The communication of the view implementations to the abstract view is done by:
* - triggerContextMenuRequest()
* - requestActivation()
- * - triggerUrlChangeRequest()
* - indicateDroppedUrls()
* - indicateSortingChange()
* - indicateSortOrderChanged()
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
*/
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.
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)));