Changeset 11073


Ignore:
Timestamp:
Jul 31, 2010, 12:03:59 AM (12 years ago)
Author:
charles
Message:

(trunk qt) fix filterbar issue reported by Lacrocivious

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/filterbar.cc

    r11072 r11073  
    1111 */
    1212
     13#include <iostream>
     14
    1315#include <QString>
    1416#include <QtGui>
     
    465467        case Prefs :: FILTER_TRACKERS: {
    466468            const QString tracker = myPrefs.getString( key );
    467             QList<QStandardItem*> rows = myTrackerModel->findItems( tracker );
    468             if( !rows.isEmpty( )  )
    469                 myTrackerCombo->setCurrentIndex( rows.first()->row() );
    470             else if( myTorrents.rowCount( ) > 0 ) // uh-oh... we don't have this tracker anymore.  best use "show all" as a fallback
    471                 myPrefs.set( key, "" );
     469            QModelIndexList indices = myTrackerModel->match( myTrackerModel->index(0,0), TrackerRole, tracker, 1, Qt::MatchFixedString );
     470            if( !indices.isEmpty( )  )
     471                myTrackerCombo->setCurrentIndex( indices.first().row() );
     472            else { // hm, we don't seem to have this tracker anymore...
     473                const bool isBootstrapping = myTrackerModel->rowCount( ) <= 2;
     474                if( !isBootstrapping )
     475                    myPrefs.set( key, "" );
     476            }
    472477            break;
    473478        }
     
    490495{
    491496    if( !myIsBootstrapping )
    492         myPrefs.set( Prefs::FILTER_TRACKERS, myTrackerCombo->itemData( i, Qt::DisplayRole ).toString( ) );
     497    {
     498        QString str;
     499        const bool isTracker = !myTrackerCombo->itemData(i,TrackerRole).toString().isEmpty();
     500        if( isTracker )
     501            str = myTrackerCombo->itemData(i,TrackerRole).toString();
     502        else // show all
     503            str = "";
     504        myPrefs.set( Prefs::FILTER_TRACKERS, str );
     505    }
    493506}
    494507
Note: See TracChangeset for help on using the changeset viewer.