]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Minor layout and coding style cleanups
authorPeter Penz <peter.penz19@gmail.com>
Fri, 16 Dec 2011 22:37:49 +0000 (23:37 +0100)
committerPeter Penz <peter.penz19@gmail.com>
Fri, 16 Dec 2011 22:39:57 +0000 (23:39 +0100)
- Disable performance debugging output
- Force a synchronous layout during scrolling. This prevents having a jerky
  scroll-animation if there are pending operations ongoing in parallel.
- Minor coding style cleanups

src/kitemviews/kfileitemlistview.cpp
src/kitemviews/kfileitemlistwidget.cpp
src/kitemviews/kfileitemmodel.cpp
src/kitemviews/kfileitemmodelrolesupdater.cpp
src/kitemviews/kitemlistview.cpp
src/kitemviews/kitemlistview.h
src/kitemviews/kitemlistviewlayouter.cpp

index d7dd5cf67f43f568f7b750c38bca5f7bfea6f37e..e2bde3b12edc70b5f5cbf0915f7c5d9466c607ae 100644 (file)
@@ -34,7 +34,7 @@
 #include <QTextLine>
 #include <QTimer>
 
-#define KFILEITEMLISTVIEW_DEBUG
+// #define KFILEITEMLISTVIEW_DEBUG
 
 namespace {
     const int ShortInterval = 50;
index 7fce4b74ddbf8517ebbe4b93aa869c98c67353fe..7a36214b65f20f84e9968c53642dfa326c4c4990 100644 (file)
@@ -38,7 +38,7 @@
 #include <QTextLayout>
 #include <QTextLine>
 
-//#define KFILEITEMLISTWIDGET_DEBUG
+// #define KFILEITEMLISTWIDGET_DEBUG
 
 KFileItemListWidget::KFileItemListWidget(QGraphicsItem* parent) :
     KItemListWidget(parent),
index e3b61d47597e697772c627668039ae8b7daff430..86ec5de89f379118bb55ec1d09e55f06209a0971 100644 (file)
@@ -28,7 +28,7 @@
 #include <QMimeData>
 #include <QTimer>
 
-#define KFILEITEMMODEL_DEBUG
+// #define KFILEITEMMODEL_DEBUG
 
 KFileItemModel::KFileItemModel(KDirLister* dirLister, QObject* parent) :
     KItemModelBase("name", parent),
index 5175b371ca600a81227aeb2e04c895e94723b5aa..4fe45624c607ba651fb5179b35389d3988a30b7b 100644 (file)
@@ -41,7 +41,7 @@
     #include <QFile>
 #endif
 
-#define KFILEITEMMODELROLESUPDATER_DEBUG
+// #define KFILEITEMMODELROLESUPDATER_DEBUG
 
 namespace {
     // Maximum time in ms that the KFileItemModelRolesUpdater
index 15e0340c0c5a50ec95940f1fd4597ed0dee55d1e..bda559d2c499578a7c7e3e0aafb5426fe4eabde6 100644 (file)
@@ -127,7 +127,7 @@ void KItemListView::setScrollOrientation(Qt::Orientation orientation)
         }
     }
 
-    doLayout(Animation, 0, 0);
+    doLayout(Animation);
 
     onScrollOrientationChanged(orientation, previousOrientation);
     emit scrollOrientationChanged(orientation, previousOrientation);
@@ -159,7 +159,7 @@ void KItemListView::setItemSize(const QSizeF& itemSize)
     }
 
     m_sizeHintResolver->clearCache();
-    doLayout(Animation, 0, 0);
+    doLayout(Animation);
     onItemSizeChanged(itemSize, previousSize);
 }
 
@@ -181,9 +181,11 @@ void KItemListView::setScrollOffset(qreal offset)
 
     m_layouter->setScrollOffset(offset);
     m_animation->setScrollOffset(offset);
-    if (!m_layoutTimer->isActive()) {
-        doLayout(NoAnimation, 0, 0);
-    }
+
+    // Don't check whether the m_layoutTimer is active: Changing the
+    // scroll offset must always trigger a synchronous layout, otherwise
+    // the smooth-scrolling might get jerky.
+    doLayout(NoAnimation);
     onScrollOffsetChanged(offset, previousOffset);
 }
 
@@ -204,7 +206,7 @@ void KItemListView::setItemOffset(qreal offset)
         m_header->setPos(-offset, 0);
     }
     if (!m_layoutTimer->isActive()) {
-        doLayout(NoAnimation, 0, 0);
+        doLayout(NoAnimation);
     }
 }
 
@@ -241,7 +243,7 @@ void KItemListView::setVisibleRoles(const QList<QByteArray>& roles)
     }
 
     updateVisibleRolesSizes();
-    doLayout(Animation, 0, 0);
+    doLayout(Animation);
 
     onVisibleRolesChanged(roles, previousRoles);
 }
@@ -330,7 +332,7 @@ void KItemListView::setStyleOption(const KItemListStyleOption& option)
     }
 
     m_sizeHintResolver->clearCache();
-    doLayout(Animation, 0, 0);
+    doLayout(Animation);
     onStyleOptionChanged(option, previousOption);
 }
 
@@ -506,7 +508,7 @@ void KItemListView::endTransaction()
 
     if (m_activeTransactions == 0) {
         onTransactionEnd();
-        doLayout(Animation, 0, 0);
+        doLayout(Animation);
     }
 }
 
@@ -775,7 +777,6 @@ void KItemListView::slotItemsInserted(const KItemRangeList& itemRanges)
 
         m_layouter->markAsDirty();
         if (m_model->count() == count && maximumScrollOffset() > size().height()) {
-            kDebug() << "Scrollbar required, skipping layout";
             const int scrollBarExtent = style()->pixelMetric(QStyle::PM_ScrollBarExtent);
             QSizeF layouterSize = m_layouter->size();
             if (scrollOrientation() == Qt::Vertical) {
@@ -903,7 +904,7 @@ void KItemListView::slotItemsMoved(const KItemRange& itemRange, const QList<int>
         }
     }
 
-    doLayout(NoAnimation, 0, 0);
+    doLayout(NoAnimation);
 }
 
 void KItemListView::slotItemsChanged(const KItemRangeList& itemRanges,
@@ -940,7 +941,7 @@ void KItemListView::slotItemsChanged(const KItemRangeList& itemRanges,
             // The sort-role has been changed which might result
             // in modified group headers
             updateVisibleGroupHeaders();
-            doLayout(NoAnimation, 0, 0);
+            doLayout(NoAnimation);
         }
     }
 }
@@ -967,7 +968,7 @@ void KItemListView::slotGroupedSortingChanged(bool current)
         Q_ASSERT(m_visibleGroups.isEmpty());
     }
 
-    doLayout(Animation, 0, 0);
+    doLayout(Animation);
 }
 
 void KItemListView::slotSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous)
@@ -976,7 +977,7 @@ void KItemListView::slotSortOrderChanged(Qt::SortOrder current, Qt::SortOrder pr
     Q_UNUSED(previous);
     if (m_grouped) {
         updateVisibleGroupHeaders();
-        doLayout(Animation, 0, 0);
+        doLayout(Animation);
     }
 }
 
@@ -986,7 +987,7 @@ void KItemListView::slotSortRoleChanged(const QByteArray& current, const QByteAr
     Q_UNUSED(previous);
     if (m_grouped) {
         updateVisibleGroupHeaders();
-        doLayout(Animation, 0, 0);
+        doLayout(Animation);
     }
 }
 
@@ -1060,7 +1061,7 @@ void KItemListView::slotAnimationFinished(QGraphicsWidget* widget,
 void KItemListView::slotLayoutTimerFinished()
 {
     m_layouter->setSize(geometry().size());
-    doLayout(Animation, 0, 0);
+    doLayout(Animation);
 }
 
 void KItemListView::slotRubberBandPosChanged()
@@ -1115,7 +1116,7 @@ void KItemListView::slotVisibleRoleWidthChanged(const QByteArray& role,
             widget->setVisibleRolesSizes(m_stretchedVisibleRolesSizes);
         }
 
-        doLayout(Animation, 0, 0);
+        doLayout(Animation);
     }
 }
 
@@ -1255,7 +1256,6 @@ KItemListRubberBand* KItemListView::rubberBand() const
 void KItemListView::doLayout(LayoutAnimationHint hint, int changedIndex, int changedCount)
 {
     if (m_layoutTimer->isActive()) {
-        kDebug() << "Stopping layout timer, synchronous layout requested";
         m_layoutTimer->stop();
     }
 
@@ -1331,7 +1331,8 @@ void KItemListView::doLayout(LayoutAnimationHint hint, int changedIndex, int cha
 
             if (animate && changedCount < 0) {
                 // Items have been deleted, move the created item to the
-                // imaginary old position.
+                // imaginary old position. They will get animated to the new position
+                // later.
                 const QRectF itemRect = m_layouter->itemRect(i - changedCount);
                 if (itemRect.isEmpty()) {
                     const QPointF invisibleOldPos = (scrollOrientation() == Qt::Vertical)
@@ -1349,7 +1350,6 @@ void KItemListView::doLayout(LayoutAnimationHint hint, int changedIndex, int cha
         if (animate) {
             const bool itemsRemoved = (changedCount < 0);
             const bool itemsInserted = (changedCount > 0);
-
             if (itemsRemoved && (i >= changedIndex + changedCount + 1)) {
                 // The item is located after the removed items. Animate the moving of the position.
                 m_animation->start(widget, KItemListViewAnimation::MovingAnimation, newPos);
index 299e8f60bb25f527790a40a3b7bd4c960bf21f26..90f753087a62f5334e43f6553c06df4bb3ce1cc7 100644 (file)
@@ -354,8 +354,8 @@ private:
 
     KItemListRubberBand* rubberBand() const;
 
-    void doLayout(LayoutAnimationHint hint, int changedIndex, int changedCount);
-    void doGroupHeadersLayout(LayoutAnimationHint hint, int changedIndex, int changedCount);
+    void doLayout(LayoutAnimationHint hint, int changedIndex = 0, int changedCount = 0);
+
     void emitOffsetChanges();
 
     KItemListWidget* createWidget(int index);
index cc7333232bcec44565253b63faca96a121796930..f3c14f53d8ca360ecc5a71466c2071747c6be46b 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <KDebug>
 
-#define KITEMLISTVIEWLAYOUTER_DEBUG
+// #define KITEMLISTVIEWLAYOUTER_DEBUG
 
 KItemListViewLayouter::KItemListViewLayouter(QObject* parent) :
     QObject(parent),