diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-05-06 01:16:07 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-05-06 01:16:07 +0000 |
commit | e093d5d571fbd8439907fd85c5ef9e434dcfb8c9 (patch) | |
tree | ecf8250eb5be80127393e998fd7686afcdb58227 /konq-plugins | |
parent | 8237db40749f6affe01cc1de87465ea11d1d9107 (diff) | |
download | tdeaddons-e093d5d571fbd8439907fd85c5ef9e434dcfb8c9.tar.gz tdeaddons-e093d5d571fbd8439907fd85c5ef9e434dcfb8c9.zip |
Fixed bug 180 and bug 146
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeaddons@1123404 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'konq-plugins')
-rw-r--r-- | konq-plugins/dirfilter/dirfilterplugin.cpp | 77 | ||||
-rw-r--r-- | konq-plugins/dirfilter/dirfilterplugin.h | 3 |
2 files changed, 54 insertions, 26 deletions
diff --git a/konq-plugins/dirfilter/dirfilterplugin.cpp b/konq-plugins/dirfilter/dirfilterplugin.cpp index eee1284..3e16bf4 100644 --- a/konq-plugins/dirfilter/dirfilterplugin.cpp +++ b/konq-plugins/dirfilter/dirfilterplugin.cpp @@ -199,11 +199,18 @@ DirFilterPlugin::DirFilterPlugin (QObject* parent, const char* name, KWidgetAction *filterAction = new KWidgetAction(hbox, i18n("Filter Field"), 0, 0, 0, actionCollection(), "toolbar_filter_field"); filterAction->setShortcutConfigurable(false); + + m_refreshTimer = new QTimer( this ); + connect( m_refreshTimer, SIGNAL(timeout()), this, SLOT(activateSearch()) ); + m_refreshTimer->start( 200, FALSE ); // 200 millisecond continuous timer + } DirFilterPlugin::~DirFilterPlugin() { + m_refreshTimer->stop(); delete m_pFilterMenu; + delete m_refreshTimer; } void DirFilterPlugin::slotOpenURL () @@ -396,7 +403,6 @@ void DirFilterPlugin::slotItemsAdded (const KFileItemList& list) { static_cast<KIconViewSearchLine*>(m_searchWidget)->updateSearch(); } - //m_searchWidget->updateSearch(); // Make sure the filter menu is enabled once a named // filter is removed. @@ -415,8 +421,7 @@ void DirFilterPlugin::slotItemsAdded (const KFileItemList& list) { MimeInfo& mimeInfo = m_pMimeInfo[mimeType]; QStringList filters = m_part->mimeFilter (); - mimeInfo.useAsFilter = (!filters.isEmpty () && - filters.contains (mimeType)); + mimeInfo.useAsFilter = (!filters.isEmpty () && filters.contains (mimeType)); mimeInfo.mimeComment = mime->comment(); mimeInfo.iconName = mime->icon(KURL(), false); mimeInfo.filenames.insert(name, false); @@ -430,30 +435,50 @@ void DirFilterPlugin::slotItemsAdded (const KFileItemList& list) void DirFilterPlugin::slotItemRemoved (const KFileItem* item) { - if (!item || !m_part) - return; - - QString mimeType = item->mimetype().stripWhiteSpace(); - - if (m_pMimeInfo.contains (mimeType)) - { - MimeInfo info = m_pMimeInfo [mimeType]; + if (!item || !m_part) + return; + + // Due to the poor implementation of qiconviewitem, there is no way for it to know if an item on the hidden list was deleted + // This *will* eventually cause the kiconviewsearchline to attempt to reference a deleted object, resulting in a crash + // This is illustrated well with two Konqueror windows. Open one, set the filter bar to filter out a file, then delete the filtered file from another window. + // Now clear the search bar (forcing injection of the deleted iconview object pointer from the hidden list). Konqueror will crash! + // If iconDeleted is called, it allows kiconviewsearchline to temporarily add the affected qiconviewitem(s) (by filename) to the iconview so that as far as + // qiconview is concerned the qiconviewitem objects never left. + // NOTE: This bug is NOT present in qlistviewitem + + // HACK around it here... + if ( ::qt_cast<QIconView*>(m_part->scrollWidget()) ) { + static_cast<KIconViewSearchLine*>(m_searchWidget)->iconDeleted(item->name()); + } + + QString mimeType = item->mimetype().stripWhiteSpace(); + + if (m_pMimeInfo.contains (mimeType)) { + MimeInfo info = m_pMimeInfo [mimeType]; + + if (info.filenames.size () > 1) + m_pMimeInfo [mimeType].filenames.remove (item->name ()); + else { + if (info.useAsFilter) { + QStringList filters = m_part->mimeFilter (); + filters.remove (mimeType); + m_part->setMimeFilter (filters); + SessionManager::self()->save (m_part->url(), filters); + QTimer::singleShot( 0, this, SLOT(slotTimeout()) ); + } + m_pMimeInfo.remove (mimeType); + } + } +} - if (info.filenames.size () > 1) - m_pMimeInfo [mimeType].filenames.remove (item->name ()); - else - { - if (info.useAsFilter) - { - QStringList filters = m_part->mimeFilter (); - filters.remove (mimeType); - m_part->setMimeFilter (filters); - SessionManager::self()->save (m_part->url(), filters); - QTimer::singleShot( 0, this, SLOT(slotTimeout()) ); - } - m_pMimeInfo.remove (mimeType); - } - } +void DirFilterPlugin::activateSearch() +{ + if ( ::qt_cast<KListView*>(m_part->scrollWidget()) ) { + static_cast<KListViewSearchLine*>(m_searchWidget)->updateSearch(); + } + else if ( ::qt_cast<QIconView*>(m_part->scrollWidget()) ) { + static_cast<KIconViewSearchLine*>(m_searchWidget)->updateSearch(); + } } void DirFilterPlugin::slotReset() diff --git a/konq-plugins/dirfilter/dirfilterplugin.h b/konq-plugins/dirfilter/dirfilterplugin.h index f1c5b44..74ad8e2 100644 --- a/konq-plugins/dirfilter/dirfilterplugin.h +++ b/konq-plugins/dirfilter/dirfilterplugin.h @@ -20,6 +20,7 @@ #define __DIR_FILTER_PLUGIN_H #include <qmap.h> +#include <qtimer.h> #include <qstringlist.h> @@ -119,10 +120,12 @@ private slots: void slotItemSelected(int); void slotItemRemoved(const KFileItem *); void slotItemsAdded(const KFileItemList &); + void activateSearch(); private: KURL m_pURL; KonqDirPart* m_part; + QTimer *m_refreshTimer; KActionMenu* m_pFilterMenu; KLineEdit *m_searchWidget; |