]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Prevent unnecessary reloading of KDirLister on startup
authorPeter Penz <peter.penz19@gmail.com>
Tue, 8 Mar 2011 21:25:53 +0000 (22:25 +0100)
committerPeter Penz <peter.penz19@gmail.com>
Tue, 8 Mar 2011 21:32:49 +0000 (22:32 +0100)
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.

src/dolphinmainwindow.cpp
src/views/dolphinview.cpp
src/views/dolphinview.h

index c50a42a404f9e4675a18ed7b5e4dbd83980f967b..e0f6019c001ae5185d9da10fa375bfbc671809ec 100644 (file)
@@ -163,6 +163,11 @@ void DolphinMainWindow::openDirectories(const QList<KUrl>& 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<int>() << newWidth << newWidth);
     connectViewSignals(m_viewTab[tabIndex].secondaryView);
-    m_viewTab[tabIndex].secondaryView->view()->reload();
     m_viewTab[tabIndex].secondaryView->setActive(false);
     m_viewTab[tabIndex].secondaryView->show();
 }
index 4ab16e0528a7eb3e4a8ae98c3cc25437c673ad61..6108c9d4a105475fe9b50c0831a8175543d12edf 100644 (file)
@@ -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);
index 1d1d316ea19f34ef50a2516b249d157328a77cde..48967e62bacd5a18d68be8f509e05a13ba5fcc83 100644 (file)
@@ -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:
     /**