]> cloud.milkyroute.net Git - dolphin.git/commitdiff
simplify code + fix activation issue when reloading columns
authorPeter Penz <peter.penz19@gmail.com>
Mon, 24 Sep 2007 16:13:19 +0000 (16:13 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Mon, 24 Sep 2007 16:13:19 +0000 (16:13 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=716381

src/dolphincolumnview.cpp
src/dolphincolumnview.h

index 7a3bda86de9b78c695965e6349a3978aa6934625..ee217b2bd3177faa012fcb4ac3a9e8e8a72ef895 100644 (file)
@@ -295,7 +295,7 @@ void ColumnWidget::keyPressEvent(QKeyEvent* event)
                              && (event->key() == Qt::Key_Return)
                              && (selModel->selectedIndexes().count() <= 1);
     if (triggerItem) {
-        m_view->triggerItem(currentIndex);
+        m_view->m_controller->triggerItem(currentIndex);
     }
 }
 
@@ -337,10 +337,10 @@ void ColumnWidget::activate()
     // necessary connecting the signal 'singleClick()' or 'doubleClick'.
     if (KGlobalSettings::singleClick()) {
         connect(this, SIGNAL(clicked(const QModelIndex&)),
-                m_view, SLOT(triggerItem(const QModelIndex&)));
+                m_view->m_controller, SLOT(triggerItem(const QModelIndex&)));
     } else {
         connect(this, SIGNAL(doubleClicked(const QModelIndex&)),
-                m_view, SLOT(triggerItem(const QModelIndex&)));
+                m_view->m_controller, SLOT(triggerItem(const QModelIndex&)));
     }
 
     const QColor bgColor = KColorScheme(QPalette::Active, KColorScheme::View).background().color();
@@ -366,10 +366,10 @@ void ColumnWidget::deactivate()
     // necessary connecting the signal 'singleClick()' or 'doubleClick'.
     if (KGlobalSettings::singleClick()) {
         disconnect(this, SIGNAL(clicked(const QModelIndex&)),
-                   m_view, SLOT(triggerItem(const QModelIndex&)));
+                   m_view->m_controller, SLOT(triggerItem(const QModelIndex&)));
     } else {
         disconnect(this, SIGNAL(doubleClicked(const QModelIndex&)),
-                   m_view, SLOT(triggerItem(const QModelIndex&)));
+                   m_view->m_controller, SLOT(triggerItem(const QModelIndex&)));
     }
 
     const QPalette palette = m_view->viewport()->palette();
@@ -576,7 +576,7 @@ void DolphinColumnView::showColumn(const KUrl& url)
             ColumnWidget* column = new ColumnWidget(viewport(), this, childUrl);
             column->setModel(model());
             column->setRootIndex(proxyIndex);
-            column->setActive(columnIndex == lastIndex);
+            column->setActive(false);
 
             m_columns.append(column);
 
@@ -587,6 +587,13 @@ void DolphinColumnView::showColumn(const KUrl& url)
             layoutColumns();
         }
     }
+
+    // set the last column as active column without modifying the controller
+    // and hence the history
+    activeColumn()->setActive(false);
+    m_index = columnIndex;
+    activeColumn()->setActive(true);
+
     expandToActiveUrl();
 }
 
@@ -699,41 +706,6 @@ void DolphinColumnView::zoomOut()
     }
 }
 
-void DolphinColumnView::triggerItem(const QModelIndex& index)
-{
-    m_controller->triggerItem(index);
-
-    const Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();
-    if ((modifiers & Qt::ControlModifier) || (modifiers & Qt::ShiftModifier)) {
-        return;
-    }
-
-    const KFileItem item = m_dolphinModel->itemForIndex(m_proxyModel->mapToSource(index));
-    if ((item.url() != activeColumn()->url()) && item.isDir()) {
-        deleteInactiveChildColumns();
-
-        const KUrl& childUrl = m_controller->url();
-        activeColumn()->setChildUrl(childUrl);
-
-        ColumnWidget* column = new ColumnWidget(viewport(), this, childUrl);
-        column->setModel(model());
-        column->setRootIndex(index);
-
-        m_columns.append(column);
-
-        setActiveColumnIndex(m_index + 1);
-
-        // Before invoking layoutColumns() the column must be shown. To prevent
-        // a flickering the initial geometry is set to be invisible.
-        column->setGeometry(QRect(-1, -1, 1, 1));
-        column->show();
-
-        layoutColumns();
-        updateScrollBar();
-        assureVisibleActiveColumn();
-    }
-}
-
 void DolphinColumnView::moveContentHorizontally(int x)
 {
     m_contentX = -x;
index 2b393e4666c28f9ae4641aa0d5d8f047dacf353f..71ac894687a0a594b45f5999f06dcf4f3c1394fa 100644 (file)
@@ -78,7 +78,6 @@ protected:
 private slots:
     void zoomIn();
     void zoomOut();
-    void triggerItem(const QModelIndex& index);
 
     /**
      * Moves the content of the columns view to represent