This makes the categorized view amazingly fast in directories with a huge number of files (tested with a folder with 10000 files here)

CCMAIL: peter.penz@gmx.at

svn path=/trunk/KDE/kdebase/apps/; revision=724536
This commit is contained in:
Rafael Fernández López 2007-10-12 15:36:29 +00:00
parent 8d4fb36089
commit a4e558c546
3 changed files with 41 additions and 3 deletions

View file

@ -476,6 +476,10 @@ 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()));
@ -491,6 +495,14 @@ void KCategorizedView::setModel(QAbstractItemModel *model)
if (d->proxyModel)
{
d->modelSortRole = d->proxyModel->sortRole();
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()));
@ -539,6 +551,10 @@ 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()));
@ -549,6 +565,10 @@ void KCategorizedView::setCategoryDrawer(KCategoryDrawer *categoryDrawer)
}
else if (categoryDrawer && d->proxyModel)
{
QObject::connect(d->proxyModel,
SIGNAL(layoutAboutToBeChanged()),
this, SLOT(slotLayoutAboutToBeChanged()));
QObject::connect(d->proxyModel,
SIGNAL(layoutChanged()),
this, SLOT(slotLayoutChanged()));
@ -1176,8 +1196,8 @@ QModelIndex KCategorizedView::moveCursor(CursorAction cursorAction,
}
void KCategorizedView::rowsInserted(const QModelIndex &parent,
int start,
int end)
int start,
int end)
{
QListView::rowsInserted(parent, start, end);
@ -1304,10 +1324,24 @@ void KCategorizedView::updateGeometries()
QAbstractItemView::updateGeometries();
}
void KCategorizedView::slotLayoutChanged()
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 &&
d->categoryDrawer && d->proxyModel->isCategorizedModel() &&
((d->modelSortRole != d->proxyModel->sortRole()) ||
(d->modelSortColumn != d->proxyModel->sortColumn()) ||
(d->modelSortOrder != d->proxyModel->sortOrder())))
{
// Force the view to update all elements
rowsInsertedArtifficial(QModelIndex(), 0, d->proxyModel->rowCount() - 1);

View file

@ -103,6 +103,7 @@ protected Q_SLOTS:
virtual void updateGeometries();
virtual void slotLayoutAboutToBeChanged();
virtual void slotLayoutChanged();

View file

@ -149,6 +149,9 @@ public:
QModelIndexList intersectedIndexes;
QRect lastDraggedItemsRect;
QRect lastSelectionRect;
int modelSortRole;
int modelSortColumn;
Qt::SortOrder modelSortOrder;
// Attributes for speed reasons
KCategorizedSortFilterProxyModel *proxyModel;