Reorganise some code in DolphinView and DolphinViewContainer. This

makes it possible to restore the expanded folders in the Details View
when navigating in history (based on r1056438 and r1079843).

Also remove DolphinView::activateItem(const KUrl&) and DolphinView's
m_loadingDirectory member (they are not needed any more).

This will be in KDE 4.5.

BUG: 169886

svn path=/trunk/KDE/kdebase/apps/; revision=1080549
This commit is contained in:
Frank Reininghaus 2010-01-26 12:18:08 +00:00
parent ad85be955b
commit 17ff26c355
4 changed files with 10 additions and 43 deletions

View file

@ -81,7 +81,6 @@ DolphinView::DolphinView(QWidget* parent,
QWidget(parent),
m_active(true),
m_showPreview(false),
m_loadingDirectory(false),
m_storedCategorizedSorting(false),
m_tabsForFiles(false),
m_isContextMenuOpen(false),
@ -1025,13 +1024,6 @@ bool DolphinView::isTabsForFilesEnabled() const
return m_tabsForFiles;
}
void DolphinView::activateItem(const KUrl& url)
{
// TODO: If DolphinViewContainer uses DolphinView::restoreState(...) to restore the
// view state in KDE 4.5, this function can be removed.
m_activeItemUrl = url;
}
bool DolphinView::itemsExpandable() const
{
return m_viewAccessor.itemsExpandable();
@ -1159,7 +1151,6 @@ void DolphinView::slotDirListerCompleted()
void DolphinView::slotLoadingCompleted()
{
m_expanderActive = false;
m_loadingDirectory = false;
if (!m_activeItemUrl.isEmpty()) {
// assure that the current item remains visible
@ -1218,7 +1209,6 @@ void DolphinView::loadDirectory(const KUrl& url, bool reload)
return;
}
m_loadingDirectory = true;
m_expanderActive = false;
KDirLister* dirLister = m_viewAccessor.dirLister();
@ -1482,11 +1472,6 @@ void DolphinView::ViewAccessor::prepareUrlChange(const KUrl& url)
if (m_columnsContainer != 0) {
m_columnsContainer->showColumn(url);
}
if(!m_detailsViewExpander.isNull()) {
// stop expanding items in the current folder
m_detailsViewExpander->stop();
}
}
QAbstractItemView* DolphinView::ViewAccessor::itemView() const
@ -1552,6 +1537,11 @@ QSet<KUrl> DolphinView::ViewAccessor::expandedUrls() const
const DolphinDetailsViewExpander* DolphinView::ViewAccessor::setExpandedUrls(const QSet<KUrl>& urlsToExpand)
{
if ((m_detailsView != 0) && m_detailsView->itemsExpandable() && !urlsToExpand.isEmpty()) {
// Check if another expander is already active and stop it if necessary.
if(!m_detailsViewExpander.isNull()) {
m_detailsViewExpander->stop();
}
m_detailsViewExpander = new DolphinDetailsViewExpander(m_detailsView, urlsToExpand);
return m_detailsViewExpander;
}
@ -1602,8 +1592,6 @@ void DolphinView::restoreContentsPosition()
Q_ASSERT(view != 0);
view->horizontalScrollBar()->setValue(x);
view->verticalScrollBar()->setValue(y);
m_loadingDirectory = false;
}
}

View file

@ -311,15 +311,6 @@ public:
void setTabsForFilesEnabled(bool tabsForFiles);
bool isTabsForFilesEnabled() const;
/**
* Marks the item \a url as active item as soon as it has
* been loaded by the directory lister. This is useful mark
* the previously visited directory as active when going
* back in history (the URL is known, but the item is not
* loaded yet).
*/
void activateItem(const KUrl& url);
/**
* Returns true if the current view allows folders to be expanded,
* i.e. presents a hierarchical view to the user.
@ -797,7 +788,6 @@ private:
bool m_active : 1;
bool m_showPreview : 1;
bool m_loadingDirectory : 1;
bool m_storedCategorizedSorting : 1;
bool m_tabsForFiles : 1;
bool m_isContextMenuOpen : 1; // TODO: workaround for Qt-issue 207192

View file

@ -307,7 +307,6 @@ void DolphinViewContainer::slotDirListerCompleted()
} else {
updateStatusBar();
}
QMetaObject::invokeMethod(this, "restoreViewState", Qt::QueuedConnection);
// Enable the 'File'->'Create New...' menu only if the directory
// supports writing.
@ -369,13 +368,6 @@ void DolphinViewContainer::setNameFilter(const QString& nameFilter)
delayedStatusBarUpdate();
}
void DolphinViewContainer::restoreViewState()
{
QByteArray locationState = m_urlNavigator->locationState();
QDataStream stream(&locationState, QIODevice::ReadOnly);
m_view->restoreState(stream);
}
void DolphinViewContainer::activate()
{
setActive(true);
@ -458,12 +450,11 @@ void DolphinViewContainer::saveUrlCompletionMode(KGlobalSettings::Completion com
void DolphinViewContainer::slotHistoryChanged()
{
const int index = m_urlNavigator->historyIndex();
if (index > 0) {
// The "Go Forward" action is enabled. Try to mark
// the previous directory as active item:
const KUrl url = m_urlNavigator->locationUrl(index - 1);
m_view->activateItem(url);
QByteArray locationState = m_urlNavigator->locationState();
if (!locationState.isEmpty()) {
QDataStream stream(&locationState, QIODevice::ReadOnly);
m_view->restoreState(stream);
}
}

View file

@ -185,8 +185,6 @@ private slots:
*/
void setNameFilter(const QString& nameFilter);
void restoreViewState();
/**
* Marks the view container as active
* (see DolphinViewContainer::setActive()).