From: Peter Penz Date: Tue, 8 Mar 2011 21:25:53 +0000 (+0100) Subject: Prevent unnecessary reloading of KDirLister on startup X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/39911cad181a168b917b67fb2963e8ebb942210c Prevent unnecessary reloading of KDirLister on startup When Dolphin is started with a directory as argument unnecessary reload operations of KDirListers are done. The patch improves this by just letting the DolphinView internally do a loading as soon as it gets visible (and without reloading). Also in case if only one directory is passed as argument the current tab gets reused instead of creating new tabs and removing the current tab. Thanks a lot to David Faure for pointing out this unefficient handling. --- diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index c50a42a40..e0f6019c0 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -163,6 +163,11 @@ void DolphinMainWindow::openDirectories(const QList& dirs) return; } + if (dirs.count() == 1) { + m_activeViewContainer->setUrl(dirs.first()); + return; + } + const int oldOpenTabsCount = m_viewTab.count(); const GeneralSettings* generalSettings = DolphinSettings::instance().generalSettings(); @@ -419,7 +424,6 @@ void DolphinMainWindow::openNewTab(const KUrl& url) viewTab.primaryView = new DolphinViewContainer(url, viewTab.splitter); viewTab.primaryView->setActive(false); connectViewSignals(viewTab.primaryView); - viewTab.primaryView->view()->reload(); m_viewTab.append(viewTab); @@ -1307,7 +1311,6 @@ void DolphinMainWindow::init() m_activeViewContainer = m_viewTab[m_tabIndex].primaryView; connectViewSignals(m_activeViewContainer); DolphinView* view = m_activeViewContainer->view(); - view->reload(); m_activeViewContainer->show(); m_actionHandler->setCurrentView(view); @@ -1924,7 +1927,6 @@ void DolphinMainWindow::createSecondaryView(int tabIndex) splitter->addWidget(m_viewTab[tabIndex].secondaryView); splitter->setSizes(QList() << newWidth << newWidth); connectViewSignals(m_viewTab[tabIndex].secondaryView); - m_viewTab[tabIndex].secondaryView->view()->reload(); m_viewTab[tabIndex].secondaryView->setActive(false); m_viewTab[tabIndex].secondaryView->show(); } diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 4ab16e052..6108c9d4a 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -768,6 +768,14 @@ bool DolphinView::eventFilter(QObject* watched, QEvent* event) return QWidget::eventFilter(watched, event); } +void DolphinView::showEvent(QShowEvent* event) +{ + QWidget::showEvent(event); + if (!event->spontaneous()) { + loadDirectory(url()); + } +} + void DolphinView::activate() { setActive(true); diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h index 1d1d316ea..48967e62b 100644 --- a/src/views/dolphinview.h +++ b/src/views/dolphinview.h @@ -559,6 +559,7 @@ protected: /** @see QWidget::mouseReleaseEvent */ virtual void mouseReleaseEvent(QMouseEvent* event); virtual bool eventFilter(QObject* watched, QEvent* event); + virtual void showEvent(QShowEvent* event); private slots: /**