[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/multimedia/amarok
From:       Andrew Turner <andrewturner512+kdebugs () googlemail ! com>
Date:       2006-06-30 23:11:11
Message-ID: 1151709071.416479.14255.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 556627 by aturner:

Fix pressing return in the search bar of the Collection Browser so that it always \
acts on the search string typed, rather than on the currently displayed items (which \
may not yet have been updated to reflect a change in the string).


 M  +2 -0      ChangeLog  
 M  +30 -8     src/collectionbrowser.cpp  
 M  +3 -0      src/collectionbrowser.h  


--- trunk/extragear/multimedia/amarok/ChangeLog #556626:556627
@@ -19,6 +19,8 @@
     * The Extended Info panel in the playlistbrowser is now resizeable.
 
   BUGFIXES:
+    * Pressing return in the search bar of the Collection Browser immediately
+      after typing a query no longer appends the wrong items to the playlist.
     * Fix crash when pressing Back or Forward buttons multiple times quickly
       in Artist tab. Patch by Thomas Lindroth <tholi945@student.liu.se>.
     * Fix problems where blanks would be added to data if SQLite was busy.
--- trunk/extragear/multimedia/amarok/src/collectionbrowser.cpp #556626:556627
@@ -78,6 +78,7 @@
     , m_cat2Menu( new KPopupMenu( this ) )
     , m_cat3Menu( new KPopupMenu( this ) )
     , m_timer( new QTimer( this ) )
+    , m_returnPressed( false )
 {
     setSpacing( 4 );
 
@@ -178,7 +179,6 @@
 
     connect( m_timer, SIGNAL( timeout() ), SLOT( slotSetFilter() ) );
     connect( m_searchEdit, SIGNAL( textChanged( const QString& ) ), SLOT( \
                slotSetFilterTimeout() ) );
-    connect( m_searchEdit, SIGNAL( returnPressed() ), SLOT( slotSetFilter() ) );
     connect( m_timeFilter, SIGNAL( activated( int ) ), SLOT( slotSetFilter() ) );
 
     setFocusProxy( m_view ); //default object to get focus
@@ -187,6 +187,7 @@
 void
 CollectionBrowser::slotSetFilterTimeout() //SLOT
 {
+    m_returnPressed = false;
     m_timer->start( 280, true ); //stops the timer for us first
 }
 
@@ -198,6 +199,9 @@
     m_view->setFilter( m_searchEdit->text() );
     m_view->setTimeFilter( m_timeFilter->currentItem() );
     m_view->renderView();
+    if ( m_returnPressed )
+        appendSearchResults();
+    m_returnPressed = false;
 }
 
 void
@@ -212,6 +216,18 @@
     m_view->setShowDivider( m_showDividerAction->isChecked() );
 }
 
+void
+CollectionBrowser::appendSearchResults()
+{
+    //If we are not filtering, or the search string has changed recently, do nothing
+    if ( m_searchEdit->text().stripWhiteSpace().isEmpty() || m_timer->isActive() )
+        return;
+    m_view->selectAll();
+    Playlist::instance()->insertMedia( m_view->listSelected(), Playlist::Unique | \
Playlist::Append ); +    m_view->clearSelection();
+    m_searchEdit->clear();
+}
+
 bool
 CollectionBrowser::eventFilter( QObject *o, QEvent *e )
 {
@@ -243,12 +259,18 @@
 
             case Key_Return:
             case Key_Enter:
-                if ( m_searchEdit->text().stripWhiteSpace().isEmpty() )
-                    return true;
-                m_view->selectAll();
-                Playlist::instance()->insertMedia( m_view->listSelected(), \
                Playlist::Unique | Playlist::Append );
-                m_view->clearSelection();
-                m_searchEdit->clear();
+                if ( m_timer->isActive() )
+                {
+                    //Immediately filter and add results
+                    m_timer->stop();
+                    m_returnPressed = true;
+                    QTimer::singleShot( 0, this, SLOT( slotSetFilter() ) );
+                }
+                else
+                {
+                    //Add current results
+                    appendSearchResults();
+                }
                 return true;
 
             default:
@@ -1329,7 +1351,7 @@
 void
 CollectionView::invokeItem( QListViewItem* item ) //SLOT
 {
-    if ( !item || dynamic_cast<DividerItem*>(item))
+    if ( !item || dynamic_cast<DividerItem*>(item) )
         return;
 
     item->setSelected( true );
--- trunk/extragear/multimedia/amarok/src/collectionbrowser.h #556626:556627
@@ -59,6 +59,7 @@
 
     private:
         void layoutToolbar();
+        void appendSearchResults();
 
         //attributes:
         enum CatMenuId { IdAlbum = 1, IdArtist = 2, IdGenre = 4, IdYear = 8 , IdScan \
= 16, IdNone = 32, @@ -82,6 +83,8 @@
         CollectionView* m_view;
         QTimer*     m_timer;
 
+        bool m_returnPressed;
+
     // for CatMenuId
     friend class CollectionItem;
     friend class DividerItem;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic