Beside that this simplifies the code it also fixes a regression of having empty tabs.
svn path=/trunk/KDE/kdebase/apps/; revision=813828
m_dirLister(dirLister),
m_proxyModel(proxyModel),
m_iconManager(0),
m_dirLister(dirLister),
m_proxyModel(proxyModel),
m_iconManager(0),
+ m_toolTipManager(0),
+ m_rootUrl(),
+ m_currentItemUrl()
{
m_topLayout = new QVBoxLayout(this);
m_topLayout->setSpacing(0);
{
m_topLayout = new QVBoxLayout(this);
m_topLayout->setSpacing(0);
connect(m_controller, SIGNAL(viewportEntered()),
this, SLOT(clearHoverInformation()));
connect(m_controller, SIGNAL(viewportEntered()),
this, SLOT(clearHoverInformation()));
+ connect(m_dirLister, SIGNAL(completed()),
+ this, SLOT(restoreCurrentItem()));
+
applyViewProperties(url);
m_topLayout->addWidget(itemView());
}
applyViewProperties(url);
m_topLayout->addWidget(itemView());
}
-void DolphinView::setCurrentItem(const KUrl& url)
-{
- const QModelIndex dirIndex = m_dolphinModel->indexForUrl(url);
- if (dirIndex.isValid()) {
- const QModelIndex proxyIndex = m_proxyModel->mapFromSource(dirIndex);
- QAbstractItemView* view = itemView();
- const bool clearSelection = !hasSelection();
- view->setCurrentIndex(proxyIndex);
- if (clearSelection) {
- view->clearSelection();
- }
- }
-}
-
void DolphinView::zoomIn()
{
m_controller->triggerZoomIn();
void DolphinView::zoomIn()
{
m_controller->triggerZoomIn();
void DolphinView::setUrl(const KUrl& url)
{
void DolphinView::setUrl(const KUrl& url)
{
+ // remember current item candidate (see restoreCurrentItem())
+ m_currentItemUrl = url;
updateView(url, KUrl());
}
updateView(url, KUrl());
}
+
+void DolphinView::restoreCurrentItem()
+{
+ const QModelIndex dirIndex = m_dolphinModel->indexForUrl(m_currentItemUrl);
+ if (dirIndex.isValid()) {
+ const QModelIndex proxyIndex = m_proxyModel->mapFromSource(dirIndex);
+ QAbstractItemView* view = itemView();
+ const bool clearSelection = !hasSelection();
+ view->setCurrentIndex(proxyIndex);
+ if (clearSelection) {
+ view->clearSelection();
+ }
+ }
+}
+
void DolphinView::loadDirectory(const KUrl& url, bool reload)
{
if (!url.isValid()) {
void DolphinView::loadDirectory(const KUrl& url, bool reload)
{
if (!url.isValid()) {
/** Returns the upper left position of the view content. */
QPoint contentsPosition() const;
/** Returns the upper left position of the view content. */
QPoint contentsPosition() const;
- /**
- * Sets the current item (= item that has the keyboard focus) to
- * the item with the URL \a url.
- */
- void setCurrentItem(const KUrl& url);
-
/** Increases the size of the current set view mode. */
void zoomIn();
/** Increases the size of the current set view mode. */
void zoomIn();
*/
void slotDeleteFileFinished(KJob* job);
*/
void slotDeleteFileFinished(KJob* job);
+ /**
+ * Restores the current item (= item that has the keyboard focus)
+ * to m_currentItemUrl.
+ */
+ void restoreCurrentItem();
+
private:
void loadDirectory(const KUrl& url, bool reload = false);
private:
void loadDirectory(const KUrl& url, bool reload = false);
ToolTipManager* m_toolTipManager;
KUrl m_rootUrl;
ToolTipManager* m_toolTipManager;
KUrl m_rootUrl;
};
/// Allow using DolphinView::Mode in QVariant
};
/// Allow using DolphinView::Mode in QVariant
m_filterBar(0),
m_statusBar(0),
m_dirLister(0),
m_filterBar(0),
m_statusBar(0),
m_dirLister(0),
- m_proxyModel(0),
- m_previousUrl(),
- m_currentUrl()
void DolphinViewContainer::setUrl(const KUrl& newUrl)
{
void DolphinViewContainer::setUrl(const KUrl& newUrl)
{
- if (newUrl != m_currentUrl) {
- m_previousUrl = m_currentUrl;
- m_currentUrl = newUrl;
- m_urlNavigator->setUrl(newUrl);
- }
+ m_urlNavigator->setUrl(newUrl);
}
const KUrl& DolphinViewContainer::url() const
{
}
const KUrl& DolphinViewContainer::url() const
{
+ return m_urlNavigator->url();
}
void DolphinViewContainer::setActive(bool active)
}
void DolphinViewContainer::setActive(bool active)
- m_view->setCurrentItem(m_previousUrl);
QTimer::singleShot(100, this, SLOT(restoreContentsPos()));
}
QTimer::singleShot(100, this, SLOT(restoreContentsPos()));
}
DolphinModel* m_dolphinModel;
DolphinDirLister* m_dirLister;
DolphinSortFilterProxyModel* m_proxyModel;
DolphinModel* m_dolphinModel;
DolphinDirLister* m_dirLister;
DolphinSortFilterProxyModel* m_proxyModel;
-
- KUrl m_previousUrl;
- KUrl m_currentUrl;
};
inline const DolphinStatusBar* DolphinViewContainer::statusBar() const
};
inline const DolphinStatusBar* DolphinViewContainer::statusBar() const