summaryrefslogtreecommitdiffstats
path: root/kdeui
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-01-31 18:54:54 -0600
committerSlávek Banko <slavek.banko@axis.cz>2015-12-23 02:22:26 +0100
commit7cd5f2324d0ed56357f2df73a8f6cb359bb5b02e (patch)
tree3bafa4921cdfbe7ea2c08459c69c80fc74ae1d47 /kdeui
parent6999f571c6255e157b7ced0dd3017412ed691d7c (diff)
downloadtdelibs-7cd5f2324d0ed56357f2df73a8f6cb359bb5b02e.tar.gz
tdelibs-7cd5f2324d0ed56357f2df73a8f6cb359bb5b02e.zip
Use new Qt hidden items for iconview searches
(cherry picked from commit 5c8a387bfeced1fd11de5e5d355aa10e0da0c1ab)
Diffstat (limited to 'kdeui')
-rw-r--r--kdeui/kiconviewsearchline.cpp84
-rw-r--r--kdeui/kiconviewsearchline.h3
2 files changed, 20 insertions, 67 deletions
diff --git a/kdeui/kiconviewsearchline.cpp b/kdeui/kiconviewsearchline.cpp
index 701e15428..aa97dc923 100644
--- a/kdeui/kiconviewsearchline.cpp
+++ b/kdeui/kiconviewsearchline.cpp
@@ -42,7 +42,6 @@ public:
iconView( 0 ),
caseSensitive( DEFAULT_CASESENSITIVE ),
activeSearch( false ),
- hiddenListChanged( 0 ),
queuedSearches( 0 ) {}
TQIconView *iconView;
@@ -50,8 +49,6 @@ public:
bool activeSearch;
TQString search;
int queuedSearches;
- int hiddenListChanged;
- QIconViewItemList hiddenItems;
};
/******************************************************************************
@@ -116,26 +113,13 @@ void KIconViewSearchLine::updateSearch( const TQString &s )
if ( item == currentItem )
currentItem = NULL; // It's not in iconView anymore.
}
- }
-
- // Add Matching items, remove from hidden list
- original_count = d->hiddenItems.count();
- original_hiddenListChanged = d->hiddenListChanged;
- for (QIconViewItemList::iterator it=d->hiddenItems.begin();it!=d->hiddenItems.end();++it) {
- item = *it;
- if ((original_count != d->hiddenItems.count()) || (original_hiddenListChanged != d->hiddenListChanged)) {
- // The list has changed; pointers are now most likely invalid
- // ABORT, but restart the search at the beginning
- original_count = d->hiddenItems.count();
- original_hiddenListChanged = d->hiddenListChanged;
- it=d->hiddenItems.begin();
- }
else {
- if ( itemMatches( item, search ) )
- showItem( item );
+ showItem( item );
}
}
+
d->iconView->sort();
+ d->iconView->arrangeItemsInGrid(true);
if ( currentItem != NULL )
d->iconView->ensureItemVisible( currentItem );
@@ -143,49 +127,23 @@ void KIconViewSearchLine::updateSearch( const TQString &s )
void KIconViewSearchLine::clear()
{
- // Clear hidden list, give items back to TQIconView, if it still exists
- TQIconViewItem *item = NULL;
- QIconViewItemList::iterator it = d->hiddenItems.begin();
- while ( it != d->hiddenItems.end() )
- {
- item = *it;
- ++it;
- if ( item != NULL )
- {
- if ( d->iconView != NULL )
- showItem( item );
- else
- delete item;
+ // Clear hidden list, give items back to TQIconView, if it still exists
+ TQIconViewItem *item = NULL;
+
+ TQIconViewItem *i = d->iconView->firstItem();
+ while ( i != NULL ) {
+ item = i;
+ i = i->nextItem(); // Point to next, otherwise will loose it.
+ showItem( item );
}
- }
- if ( ! d->hiddenItems.isEmpty() )
- kdDebug() << __FILE__ << ":" << __LINE__ <<
- "hiddenItems is not empty as it should be. " <<
- d->hiddenItems.count() << " items are still there.\n" << endl;
-
- d->search = "";
- d->queuedSearches = 0;
- KLineEdit::clear();
+
+ d->search = "";
+ d->queuedSearches = 0;
+ KLineEdit::clear();
}
void KIconViewSearchLine::iconDeleted(const TQString &filename) {
- // Clear hidden list, give items back to TQIconView, if it still exists
- TQIconViewItem *item = NULL;
- QIconViewItemList::iterator it = d->hiddenItems.begin();
- while ( it != d->hiddenItems.end() )
- {
- item = *it;
- ++it;
- if ( item != NULL )
- {
- if (item->text() == filename) {
- if (d->iconView != NULL)
- showItem( item );
- else
- delete item;
- }
- }
- }
+ // Do nothing...
}
void KIconViewSearchLine::setCaseSensitive( bool cs )
@@ -252,9 +210,7 @@ void KIconViewSearchLine::hideItem( TQIconViewItem *item )
if ( ( item == NULL ) || ( d->iconView == NULL ) )
return;
- d->hiddenListChanged++;
- d->hiddenItems.append( item );
- d->iconView->takeItem( item );
+ item->setVisible(false);
}
void KIconViewSearchLine::showItem( TQIconViewItem *item )
@@ -266,10 +222,8 @@ void KIconViewSearchLine::showItem( TQIconViewItem *item )
endl;
return;
}
- d->hiddenListChanged++;
- d->iconView->insertItem( item );
- d->hiddenItems.remove( item );
- item->setText(item->text());
+
+ item->setVisible(true);
}
/******************************************************************************
diff --git a/kdeui/kiconviewsearchline.h b/kdeui/kiconviewsearchline.h
index 9b11c5f2d..bff5d285b 100644
--- a/kdeui/kiconviewsearchline.h
+++ b/kdeui/kiconviewsearchline.h
@@ -107,11 +107,10 @@ public slots:
void clear();
/**
- * Must be called before updateSearch() whenever an icon is deleted.
+ * Should be called before updateSearch() whenever an icon is deleted.
*/
void iconDeleted(const TQString &filename);
-
protected:
/**
* Returns true if \a item matches the search \a s. This will be evaluated