]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphincolumnviewcontainer.cpp
Disallow renaming to names containing '/', names being equal to "." or "..".
[dolphin.git] / src / views / dolphincolumnviewcontainer.cpp
index 7346532a16f4274e380ccdd0e4a0093eb0080005..3216dd2b6643b74e8ef1262c159359b3881ccc4a 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2007-2009 by Peter Penz <peter.penz@gmx.at>             *
+ *   Copyright (C) 2007-2009 by Peter Penz <peter.penz19@gmail.com>        *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -49,8 +49,8 @@ DolphinColumnViewContainer::DolphinColumnViewContainer(QWidget* parent,
     m_activeUrlTimer(0),
     m_assureVisibleActiveColumnTimer(0)
 {
-    Q_ASSERT(dolphinViewController != 0);
-    Q_ASSERT(viewModeController != 0);
+    Q_ASSERT(dolphinViewController);
+    Q_ASSERT(viewModeController);
 
     setAcceptDrops(true);
     setFocusPolicy(Qt::NoFocus);
@@ -259,19 +259,19 @@ void DolphinColumnViewContainer::slotAssureVisibleActiveColumn()
     const int viewportWidth = viewport()->width();
     const int x = activeColumn()->x();
 
-    // When a column that is partly visible on the left side gets activated,
-    // it is useful to also assure that the previous column is partly visible.
-    // This allows the user to scroll to the first column without using the
+    // When a column that is partly visible gets activated,
+    // it is useful to also assure that the neighbor column is partly visible.
+    // This allows the user to scroll to the first/last column without using the
     // scrollbar and drag & drop operations to invisible columns.
-    const int previousColumnGap = 3 * style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, verticalScrollBar());
+    const int neighborColumnGap = 3 * style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, verticalScrollBar());
 
     const int width = activeColumn()->maximumWidth();
     if (x + width > viewportWidth) {
         const int newContentX = m_contentX - x - width + viewportWidth;
         if (isRightToLeft()) {
-            m_animation->setFrameRange(m_contentX, newContentX + previousColumnGap);
+            m_animation->setFrameRange(m_contentX, newContentX + neighborColumnGap);
         } else {
-            m_animation->setFrameRange(-m_contentX, -newContentX);
+            m_animation->setFrameRange(-m_contentX, -newContentX + neighborColumnGap);
         }
         if (m_animation->state() != QTimeLine::Running) {
            m_animation->start();
@@ -279,9 +279,9 @@ void DolphinColumnViewContainer::slotAssureVisibleActiveColumn()
     } else if (x < 0) {
         const int newContentX = m_contentX - x;
         if (isRightToLeft()) {
-            m_animation->setFrameRange(m_contentX, newContentX);
+            m_animation->setFrameRange(m_contentX, newContentX - neighborColumnGap);
         } else {
-            m_animation->setFrameRange(-m_contentX, -newContentX - previousColumnGap);
+            m_animation->setFrameRange(-m_contentX, -newContentX - neighborColumnGap);
         }
         if (m_animation->state() != QTimeLine::Running) {
            m_animation->start();
@@ -331,15 +331,12 @@ void DolphinColumnViewContainer::layoutColumns()
         contentWidth += column->maximumWidth();
     }
 
-    if (horizontalScrollBar()->pageStep() != contentWidth) {
-        disconnect(horizontalScrollBar(), SIGNAL(valueChanged(int)),
-                this, SLOT(moveContentHorizontally(int)));
-
+    const int scrollBarMax = contentWidth - viewport()->width();
+    const bool updateScrollBar =    (horizontalScrollBar()->pageStep() != contentWidth)
+                                 || (horizontalScrollBar()->maximum()  != scrollBarMax);
+    if (updateScrollBar) {
         horizontalScrollBar()->setPageStep(contentWidth);
-        horizontalScrollBar()->setRange(0, contentWidth - viewport()->width());
-
-        connect(horizontalScrollBar(), SIGNAL(valueChanged(int)),
-                this, SLOT(moveContentHorizontally(int)));
+        horizontalScrollBar()->setRange(0, scrollBarMax);
     }
 }
 
@@ -351,13 +348,13 @@ void DolphinColumnViewContainer::requestActivation(DolphinColumnView* column)
     if (focusProxy() != column) {
         setFocusProxy(column);
     }
-    
+
     if (!column->isActive()) {
         // Deactivate the currently active column
         if (m_index >= 0) {
             m_columns[m_index]->setActive(false);
         }
-        
+
         // Get the index of the column that should get activated
         int index = 0;
         foreach (DolphinColumnView* currColumn, m_columns) {
@@ -395,7 +392,7 @@ void DolphinColumnViewContainer::removeAllColumns()
 
 void DolphinColumnViewContainer::deleteColumn(DolphinColumnView* column)
 {
-    if (column == 0) {
+    if (!column) {
         return;
     }
 
@@ -415,7 +412,7 @@ void DolphinColumnViewContainer::deleteColumn(DolphinColumnView* column)
         // during drag operations" is used). Deleting the view
         // during an ongoing drag operation is not allowed, so
         // this will postponed.
-        if (m_dragSource != 0) {
+        if (m_dragSource) {
             // the old stored view is obviously not the drag source anymore
             m_dragSource->deleteLater();
             m_dragSource = 0;