Changeset 11072


Ignore:
Timestamp:
Jul 30, 2010, 10:31:31 PM (12 years ago)
Author:
charles
Message:

(trunk qt) #3459 "Qt client's filterbar should be updated to match the GTK+ client's" -- fixed

Location:
trunk/qt
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/filters.cc

    r9868 r11072  
    1313#include "filters.h"
    1414
    15 const QString FilterMode::names[NUM_MODES] = {
     15const QString FilterMode::names[NUM_MODES] =
     16{
    1617    "show-all",
    1718    "show-active",
    1819    "show-downloading",
    1920    "show-seeding",
    20     "show-paused"
     21    "show-paused",
     22    "show-queued",
     23    "show-verifying",
     24    "show-error",
    2125};
    2226
  • trunk/qt/filters.h

    r9868 r11072  
    2626        FilterMode( const QString& name ): myMode(modeFromName(name)) { }
    2727        static const QString names[];
    28         enum { SHOW_ALL, SHOW_ACTIVE, SHOW_DOWNLOADING, SHOW_SEEDING, SHOW_PAUSED, NUM_MODES };
     28        enum { SHOW_ALL, SHOW_ACTIVE, SHOW_DOWNLOADING, SHOW_SEEDING, SHOW_PAUSED,
     29               SHOW_QUEUED, SHOW_VERIFYING, SHOW_ERROR, NUM_MODES };
    2930        static int modeFromName( const QString& name );
    3031        static const QString& nameFromMode( int mode ) { return names[mode]; }
  • trunk/qt/mainwin.cc

    r10937 r11072  
    3434#include "about.h"
    3535#include "details.h"
     36#include "filterbar.h"
    3637#include "filters.h"
    3738#include "formatter.h"
     
    247248
    248249    ui.verticalLayout->addWidget( createStatusBar( ) );
    249     ui.verticalLayout->insertWidget( 0, createFilterBar( ) );
     250    ui.verticalLayout->insertWidget( 0, myFilterBar = new FilterBar( myPrefs, myModel, myFilterModel ) );
    250251
    251252    QList<int> initKeys;
     
    254255             << Prefs :: SORT_REVERSED
    255256             << Prefs :: SORT_MODE
    256              << Prefs :: FILTER_MODE
    257257             << Prefs :: FILTERBAR
    258258             << Prefs :: STATUSBAR
     
    352352
    353353#define SHOW_KEY "show-mode"
    354 
    355 void
    356 TrMainWindow :: onShowModeClicked( )
    357 {
    358     setShowMode( sender()->property(SHOW_KEY).toInt() );
    359 }
    360 
    361 QWidget *
    362 TrMainWindow :: createFilterBar( )
    363 {
    364     int i;
    365     QMenu * m;
    366     QLineEdit * e;
    367     QPushButton * p;
    368     QHBoxLayout * h;
    369     QActionGroup * a;
    370     const int smallSize = style( )->pixelMetric( QStyle::PM_SmallIconSize, 0, this );
    371     const QSize smallIconSize( smallSize, smallSize );
    372 
    373     QWidget * top = myFilterBar = new QWidget;
    374     h = new QHBoxLayout( top );
    375     h->setContentsMargins( HIG::PAD_SMALL, HIG::PAD_SMALL, HIG::PAD_SMALL, HIG::PAD_SMALL );
    376     h->setSpacing( HIG::PAD_SMALL );
    377 #ifdef Q_OS_MAC
    378     top->setStyleSheet( "QPushButton{ "
    379                         "  border-radius: 10px; "
    380                         "  padding: 0 5px; "
    381                         "  border: 1px none; "
    382                         "} "
    383                         "QPushButton:pressed, QPushButton:checked{ "
    384                         "  border-width: 1px; "
    385                         "  border-style: solid; "
    386                         "  border-color: #5f5f5f #979797 #979797; "
    387                         "  background-color: #979797; "
    388                         "  color: white; "
    389                         "} ");
    390 #endif
    391 
    392         QList<QString> titles;
    393         titles << tr( "A&ll" ) << tr( "&Active" ) << tr( "&Downloading" ) << tr( "&Seeding" ) << tr( "&Paused" );
    394         for( i=0; i<titles.size(); ++i ) {
    395             p = myFilterButtons[i] = new QPushButton( titles[i] );
    396             p->setProperty( SHOW_KEY, i );
    397             p->setFlat( true );
    398             p->setCheckable( true );
    399             p->setMaximumSize( calculateTextButtonSizeHint( p ) );
    400             connect( p, SIGNAL(clicked()), this, SLOT(onShowModeClicked()));
    401             h->addWidget( p );
    402         }
    403 
    404     h->addStretch( 1 );
    405 
    406         a = new QActionGroup( this );
    407         a->addAction( ui.action_FilterByName );
    408         a->addAction( ui.action_FilterByFiles );
    409         a->addAction( ui.action_FilterByTracker );
    410         m = new QMenu( );
    411         m->addAction( ui.action_FilterByName );
    412         m->addAction( ui.action_FilterByFiles );
    413         m->addAction( ui.action_FilterByTracker );
    414         connect( ui.action_FilterByName, SIGNAL(triggered()), this, SLOT(filterByName()));
    415         connect( ui.action_FilterByFiles, SIGNAL(triggered()), this, SLOT(filterByFiles()));
    416         connect( ui.action_FilterByTracker, SIGNAL(triggered()), this, SLOT(filterByTracker()));
    417         ui.action_FilterByName->setChecked( true );
    418         p = myFilterTextButton = new TrIconPushButton;
    419         p->setIcon( getStockIcon( "edit-find", QStyle::SP_ArrowForward ) );
    420         p->setFlat( true );
    421         p->setMenu( m );
    422         h->addWidget( p );
    423 
    424         e = myFilterTextLineEdit = new QLineEdit;
    425         connect( e, SIGNAL(textChanged(QString)), &myFilterModel, SLOT(setText(QString)));
    426         h->addWidget( e );
    427 
    428         p = myFilterTextButton = new TrIconPushButton;
    429         p->setIcon( getStockIcon( "edit-clear", QStyle::SP_DialogCloseButton ) );
    430         p->setFlat( true );
    431         connect( p, SIGNAL(clicked()), myFilterTextLineEdit, SLOT(clear()));
    432         h->addWidget( p );
    433 
    434     return top;
    435 }
    436354
    437355QWidget *
     
    836754    foreach( QModelIndex index, ui.listView->selectionModel( )->selectedRows( ) )
    837755    {
    838         const Torrent * tor( index.model()->data( index, TorrentModel::TorrentRole ).value<const Torrent*>( ) );
     756        const Torrent * tor( index.data( TorrentModel::TorrentRole ).value<const Torrent*>( ) );
    839757        ids.insert( tor->id( ) );
    840758    }
     
    887805***
    888806**/
    889 
    890 void TrMainWindow :: setShowMode     ( int i ) { myPrefs.set( Prefs::FILTER_MODE, FilterMode( i ) ); }
    891 void TrMainWindow :: showAll         ( ) { setShowMode( FilterMode :: SHOW_ALL ); }
    892 void TrMainWindow :: showActive      ( ) { setShowMode( FilterMode :: SHOW_ACTIVE ); }
    893 void TrMainWindow :: showDownloading ( ) { setShowMode( FilterMode :: SHOW_DOWNLOADING ); }
    894 void TrMainWindow :: showSeeding     ( ) { setShowMode( FilterMode :: SHOW_SEEDING ); }
    895 void TrMainWindow :: showPaused      ( ) { setShowMode( FilterMode :: SHOW_PAUSED ); }
    896 
    897 void TrMainWindow :: filterByName    ( ) { myFilterModel.setTextMode( TorrentFilter :: FILTER_BY_NAME ); }
    898 void TrMainWindow :: filterByTracker ( ) { myFilterModel.setTextMode( TorrentFilter :: FILTER_BY_TRACKER ); }
    899 void TrMainWindow :: filterByFiles   ( ) { myFilterModel.setTextMode( TorrentFilter :: FILTER_BY_FILES ); }
    900807
    901808void TrMainWindow :: showTotalRatio      ( ) { myPrefs.set( Prefs::STATUSBAR_STATS, "total-ratio"); }
     
    954861        if ( !isVisible( ) ) show( );
    955862        if ( isMinimized( ) ) showNormal( );
    956         activateWindow( );
     863        //activateWindow( );
    957864        raise( );
     865        QApplication::setActiveWindow( this );
    958866    }
    959867}
     
    1029937        case Prefs::RATIO:
    1030938            myRatioOnAction->setText( tr( "Stop at Ratio (%1)" ).arg( Formatter::ratioToString( myPrefs.get<double>(key) ) ) );
    1031             break;
    1032 
    1033         case Prefs::FILTER_MODE:
    1034             i = myPrefs.get<FilterMode>(key).mode( );
    1035             for( int j=0; j<FilterMode::NUM_MODES; ++j )
    1036                 myFilterButtons[j]->setChecked( i==j );
    1037939            break;
    1038940
     
    11841086    foreach( QModelIndex index, ui.listView->selectionModel( )->selectedRows( ) )
    11851087    {
    1186         const Torrent * tor( index.model()->data( index, TorrentModel::TorrentRole ).value<const Torrent*>( ) );
     1088        const Torrent * tor( index.data( TorrentModel::TorrentRole ).value<const Torrent*>( ) );
    11871089        ids.insert( tor->id( ) );
    11881090        if( tor->connectedPeers( ) )
  • trunk/qt/mainwin.h

    r10859 r11072  
    4646class QModelIndex;
    4747class QSortFilterProxyModel;
     48class Filterbar;
    4849
    4950class TrMainWindow: public QMainWindow
     
    8687
    8788    private:
    88         void setShowMode( int );
    8989        QSet<int> getSelectedTorrents( ) const;
    9090        void updateNetworkIcon( );
     
    9898        void openPreferences( );
    9999        void onDetailsDestroyed( );
    100         void onShowModeClicked( );
    101         void showAll( );
    102         void showActive( );
    103         void showDownloading( );
    104         void showSeeding( );
    105         void showPaused( );
    106         void filterByName( );
    107         void filterByFiles( );
    108         void filterByTracker( );
    109100        void showTotalRatio( );
    110101        void showTotalTransfer( );
     
    149140
    150141    private:
    151         QWidget * createFilterBar( void );
    152142        QWidget * myFilterBar;
    153         QPushButton * myFilterButtons[FilterMode::NUM_MODES];
    154         QPushButton * myFilterTextButton;
    155         QLineEdit * myFilterTextLineEdit;
    156143
    157144    private:
  • trunk/qt/prefs.cc

    r11061 r11072  
    5757    { MAIN_WINDOW_Y, "main-window-y", QVariant::Int },
    5858    { FILTER_MODE, "filter-mode", TrTypes::FilterModeType },
     59    { FILTER_TRACKERS, "filter-trackers", QVariant::String },
     60    { FILTER_TEXT, "filter-text", QVariant::String },
    5961    { SESSION_IS_REMOTE, "remote-session-enabled", QVariant::Bool },
    6062    { SESSION_REMOTE_HOST, "remote-session-host", QVariant::String },
     
    134136        assert( myItems[i].id == i );
    135137
     138    // these are the prefs that don't get saved to settings.json
     139    // when the application exits.
     140    myTemporaryPrefs << FILTER_TEXT;
     141
    136142    tr_benc top;
    137143    tr_bencInitDict( &top, 0 );
     
    198204
    199205    /* merge our own settings with the ones already in the file */
    200     for( int i=0; i<PREFS_COUNT; ++i ) {
     206    for( int i=0; i<PREFS_COUNT; ++i )
     207    {
     208        if( myTemporaryPrefs.contains( i ) )
     209            continue;
     210
    201211        const char * key = myItems[i].key;
    202212        const QVariant& val = myValues[i];
    203         switch( myItems[i].type ) {
     213
     214        switch( myItems[i].type )
     215        {
    204216            case QVariant::Int:
    205217                tr_bencDictAddInt( &top, key, val.toInt() );
  • trunk/qt/prefs.h

    r11061 r11072  
    1616#include <QDateTime>
    1717#include <QObject>
     18#include <QSet>
    1819#include <QString>
    1920#include <QVariant>
     
    6061            MAIN_WINDOW_Y,
    6162            FILTER_MODE,
     63            FILTER_TRACKERS,
     64            FILTER_TEXT,
    6265            SESSION_IS_REMOTE,
    6366            SESSION_REMOTE_HOST,
     
    141144
    142145    private:
     146        QSet<int> myTemporaryPrefs;
    143147        QString myConfigDir;
    144148        QVariant myValues[PREFS_COUNT];
  • trunk/qt/qtr.pro

    r11061 r11072  
    3232RESOURCES += application.qrc
    3333SOURCES += about.cc app.cc dbus-adaptor.cc details.cc favicon.cc file-tree.cc \
    34            filters.cc formatter.cc hig.cc license.cc mainwin.cc \
     34           filterbar.cc filters.cc formatter.cc hig.cc license.cc mainwin.cc \
    3535           make-dialog.cc options.cc prefs.cc prefs-dialog.cc qticonloader.cc \
    3636           relocate.cc session.cc session-dialog.cc squeezelabel.cc \
  • trunk/qt/torrent-filter.h

    r9868 r11072  
    1818#include <QVariant>
    1919
     20class QString;
     21class QWidget;
    2022
    21 struct Prefs;
    22 struct QString;
     23class FilterMode;
     24class Prefs;
     25class Torrent;
    2326
    2427class TorrentFilter: public QSortFilterProxyModel
     
    3235    public:
    3336        enum TextMode { FILTER_BY_NAME, FILTER_BY_FILES, FILTER_BY_TRACKER };
    34         TextMode getTextMode( ) const { return myTextMode; }
    3537        int hiddenRowCount( ) const;
    36 
    37     public slots:
    38         void setTextMode( int textMode );
    39         void setText( QString );
    4038
    4139    private slots:
     
    4745
    4846    private:
     47        bool activityFilterAcceptsTorrent( const Torrent * tor, const FilterMode& mode ) const;
     48        bool trackerFilterAcceptsTorrent( const Torrent * tor, const QString& tracker ) const;
     49
     50    public:
     51        int count( const FilterMode& ) const;
     52
     53    private:
    4954        Prefs& myPrefs;
    50         TextMode myTextMode;
    51         QString myText;
    5255};
    5356
  • trunk/qt/torrent-model.cc

    r10771 r11072  
    120120    if( row >= 0 ) {
    121121        QModelIndex qmi( index( row, 0 ) );
    122         dataChanged( qmi, qmi );
     122        emit dataChanged( qmi, qmi );
    123123    }
    124124}
  • trunk/qt/torrent.h

    r11059 r11072  
    300300        tr_idlelimit seedIdleMode( ) const { return (tr_idlelimit) getInt( SEED_IDLE_MODE ); }
    301301        TrackerStatsList trackerStats( ) const{ return myValues[TRACKERSTATS].value<TrackerStatsList>(); }
     302        QStringList trackers() const { return myValues[TRACKERS].value<QStringList>(); }
    302303        PeerList peers( ) const{ return myValues[PEERS].value<PeerList>(); }
    303304        const FileList& files( ) const { return myFiles; }
  • trunk/qt/tracker-delegate.cc

    r11061 r11072  
    7777                             const QModelIndex           & index ) const
    7878{
    79     const TrackerInfo trackerInfo = index.model()->data( index, TrackerModel::TrackerRole ).value<TrackerInfo>();
     79    const TrackerInfo trackerInfo = index.data( TrackerModel::TrackerRole ).value<TrackerInfo>();
    8080    return sizeHint( option, trackerInfo );
    8181}
     
    8686                          const QModelIndex           & index) const
    8787{
    88     const TrackerInfo trackerInfo = index.model()->data( index, TrackerModel::TrackerRole ).value<TrackerInfo>();
     88    const TrackerInfo trackerInfo = index.data( TrackerModel::TrackerRole ).value<TrackerInfo>();
    8989    painter->save( );
    9090    painter->setClipRect( option.rect );
Note: See TracChangeset for help on using the changeset viewer.