]> cloud.milkyroute.net Git - dolphin.git/commitdiff
With latest code at slotLayoutChanged is not more necessary
authorRafael Fernández López <ereslibre@kde.org>
Sat, 13 Oct 2007 02:15:01 +0000 (02:15 +0000)
committerRafael Fernández López <ereslibre@kde.org>
Sat, 13 Oct 2007 02:15:01 +0000 (02:15 +0000)
slotLayoutAboutToBeChanged. Reacts as it should when removing items

svn path=/trunk/KDE/kdebase/apps/; revision=724693

src/kcategorizedview.cpp
src/kcategorizedview.h

index bb014b31e7819c219468c0c54882ae4af97356d0..d0d51ef2f44ec0d770d977ba54a14f1491796ad9 100644 (file)
@@ -476,10 +476,6 @@ void KCategorizedView::setModel(QAbstractItemModel *model)
 
     if (d->proxyModel)
     {
-        QObject::disconnect(d->proxyModel,
-                            SIGNAL(layoutAboutToBeChanged()),
-                            this, SLOT(slotLayoutAboutToBeChanged()));
-
         QObject::disconnect(d->proxyModel,
                             SIGNAL(layoutChanged()),
                             this, SLOT(slotLayoutChanged()));
@@ -487,6 +483,10 @@ void KCategorizedView::setModel(QAbstractItemModel *model)
         QObject::disconnect(d->proxyModel,
                             SIGNAL(dataChanged(QModelIndex,QModelIndex)),
                             this, SLOT(slotLayoutChanged()));
+
+        QObject::disconnect(d->proxyModel,
+                            SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                            this, SLOT(rowsRemoved(QModelIndex,int,int)));
     }
 
     QListView::setModel(model);
@@ -499,10 +499,6 @@ void KCategorizedView::setModel(QAbstractItemModel *model)
         d->modelSortColumn = d->proxyModel->sortColumn();
         d->modelSortOrder = d->proxyModel->sortOrder();
 
-        QObject::connect(d->proxyModel,
-                         SIGNAL(layoutAboutToBeChanged()),
-                         this, SLOT(slotLayoutAboutToBeChanged()));
-
         QObject::connect(d->proxyModel,
                          SIGNAL(layoutChanged()),
                          this, SLOT(slotLayoutChanged()));
@@ -510,6 +506,15 @@ void KCategorizedView::setModel(QAbstractItemModel *model)
         QObject::connect(d->proxyModel,
                          SIGNAL(dataChanged(QModelIndex,QModelIndex)),
                          this, SLOT(slotLayoutChanged()));
+
+        QObject::connect(d->proxyModel,
+                         SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                         this, SLOT(rowsRemoved(QModelIndex,int,int)));
+
+        if (d->proxyModel->rowCount())
+        {
+            rowsInsertedArtifficial(QModelIndex(), 0, d->proxyModel->rowCount() - 1);
+        }
     }
 }
 
@@ -551,10 +556,6 @@ void KCategorizedView::setCategoryDrawer(KCategoryDrawer *categoryDrawer)
 
     if (!categoryDrawer && d->proxyModel)
     {
-        QObject::disconnect(d->proxyModel,
-                            SIGNAL(layoutAboutToBeChanged()),
-                            this, SLOT(slotLayoutAboutToBeChanged()));
-
         QObject::disconnect(d->proxyModel,
                             SIGNAL(layoutChanged()),
                             this, SLOT(slotLayoutChanged()));
@@ -562,13 +563,13 @@ void KCategorizedView::setCategoryDrawer(KCategoryDrawer *categoryDrawer)
         QObject::disconnect(d->proxyModel,
                             SIGNAL(dataChanged(QModelIndex,QModelIndex)),
                             this, SLOT(slotLayoutChanged()));
+
+        QObject::disconnect(d->proxyModel,
+                            SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                            this, SLOT(rowsRemoved(QModelIndex,int,int)));
     }
     else if (categoryDrawer && d->proxyModel)
     {
-        QObject::connect(d->proxyModel,
-                         SIGNAL(layoutAboutToBeChanged()),
-                         this, SLOT(slotLayoutAboutToBeChanged()));
-
         QObject::connect(d->proxyModel,
                          SIGNAL(layoutChanged()),
                          this, SLOT(slotLayoutChanged()));
@@ -576,6 +577,10 @@ void KCategorizedView::setCategoryDrawer(KCategoryDrawer *categoryDrawer)
         QObject::connect(d->proxyModel,
                          SIGNAL(dataChanged(QModelIndex,QModelIndex)),
                          this, SLOT(slotLayoutChanged()));
+
+        QObject::connect(d->proxyModel,
+                         SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                         this, SLOT(rowsRemoved(QModelIndex,int,int)));
     }
 
     d->categoryDrawer = categoryDrawer;
@@ -1225,8 +1230,8 @@ void KCategorizedView::rowsInserted(const QModelIndex &parent,
 }
 
 void KCategorizedView::rowsInsertedArtifficial(const QModelIndex &parent,
-                                        int start,
-                                        int end)
+                                               int start,
+                                               int end)
 {
     Q_UNUSED(parent);
 
@@ -1299,14 +1304,14 @@ void KCategorizedView::rowsInsertedArtifficial(const QModelIndex &parent,
 }
 
 void KCategorizedView::rowsRemoved(const QModelIndex &parent,
-                            int start,
-                            int end)
+                                   int start,
+                                   int end)
 {
     if ((viewMode() == KCategorizedView::IconMode) && d->proxyModel &&
         d->categoryDrawer && d->proxyModel->isCategorizedModel())
     {
         // Force the view to update all elements
-        rowsInsertedArtifficial(parent, start, end);
+        rowsInsertedArtifficial(QModelIndex(), 0, d->proxyModel->rowCount() - 1);
     }
 }
 
@@ -1324,17 +1329,6 @@ void KCategorizedView::updateGeometries()
     QAbstractItemView::updateGeometries();
 }
 
-void KCategorizedView::slotLayoutAboutToBeChanged()
-{
-    if ((viewMode() == KCategorizedView::IconMode) && d->proxyModel &&
-        d->categoryDrawer && d->proxyModel->isCategorizedModel())
-    {
-        d->modelSortRole = d->proxyModel->sortRole();
-        d->modelSortColumn = d->proxyModel->sortColumn();
-        d->modelSortOrder = d->proxyModel->sortOrder();
-    }
-}
-
 void KCategorizedView::slotLayoutChanged()
 {
     if ((viewMode() == KCategorizedView::IconMode) && d->proxyModel &&
index d5afb666cc80c627f1a306e40ca53af2a2ad2f3c..8544392d99e64d921bf321e37ccf6cce1e5b31e4 100644 (file)
@@ -103,7 +103,6 @@ protected Q_SLOTS:
 
     virtual void updateGeometries();
 
-    virtual void slotLayoutAboutToBeChanged();
     virtual void slotLayoutChanged();