Changeset 8216 for trunk/qt/mainwin.cc


Ignore:
Timestamp:
Apr 11, 2009, 6:25:12 PM (13 years ago)
Author:
charles
Message:

(qt) better integration of sort & filter modes into the preferences mechanism

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/mainwin.cc

    r8194 r8216  
    2222#include <QSystemTrayIcon>
    2323#include <QUrl>
     24#include <QSignalMapper>
    2425
    2526#include "about.h"
    2627#include "details.h"
     28#include "filters.h"
    2729#include "mainwin.h"
    2830#include "make-dialog.h"
     
    140142
    141143    // ui signals
    142     // ccc
    143144    connect( ui.action_Toolbar, SIGNAL(toggled(bool)), this, SLOT(setToolbarVisible(bool)));
    144145    connect( ui.action_TrayIcon, SIGNAL(toggled(bool)), this, SLOT(setTrayIconVisible(bool)));
     
    146147    connect( ui.action_Statusbar, SIGNAL(toggled(bool)), this, SLOT(setStatusbarVisible(bool)));
    147148    connect( ui.action_MinimalView, SIGNAL(toggled(bool)), this, SLOT(setMinimalView(bool)));
    148     connect( ui.action_SortByActivity, SIGNAL(toggled(bool)), &myFilterModel, SLOT(sortByActivity()) );
    149     connect( ui.action_SortByAge, SIGNAL(toggled(bool)), &myFilterModel, SLOT(sortByAge()) );
    150     connect( ui.action_SortByETA, SIGNAL(toggled(bool)), &myFilterModel, SLOT(sortByETA()));
    151     connect( ui.action_SortByName, SIGNAL(toggled(bool)), &myFilterModel, SLOT(sortByName()));
    152     connect( ui.action_SortByProgress, SIGNAL(toggled(bool)), &myFilterModel, SLOT(sortByProgress()));
    153     connect( ui.action_SortByRatio, SIGNAL(toggled(bool)), &myFilterModel, SLOT(sortByRatio()));
    154     connect( ui.action_SortBySize, SIGNAL(toggled(bool)), &myFilterModel, SLOT(sortBySize()));
    155     connect( ui.action_SortByState, SIGNAL(toggled(bool)), &myFilterModel, SLOT(sortByState()));
    156     connect( ui.action_SortByTracker, SIGNAL(toggled(bool)), &myFilterModel, SLOT(sortByTracker()));
    157     connect( ui.action_ReverseSortOrder, SIGNAL(toggled(bool)), &myFilterModel, SLOT(setAscending(bool)));
     149    connect( ui.action_SortByActivity, SIGNAL(toggled(bool)), this, SLOT(onSortByActivityToggled(bool)));
     150    connect( ui.action_SortByAge,      SIGNAL(toggled(bool)), this, SLOT(onSortByAgeToggled(bool)));
     151    connect( ui.action_SortByETA,      SIGNAL(toggled(bool)), this, SLOT(onSortByETAToggled(bool)));
     152    connect( ui.action_SortByName,     SIGNAL(toggled(bool)), this, SLOT(onSortByNameToggled(bool)));
     153    connect( ui.action_SortByProgress, SIGNAL(toggled(bool)), this, SLOT(onSortByProgressToggled(bool)));
     154    connect( ui.action_SortByRatio,    SIGNAL(toggled(bool)), this, SLOT(onSortByRatioToggled(bool)));
     155    connect( ui.action_SortBySize,     SIGNAL(toggled(bool)), this, SLOT(onSortBySizeToggled(bool)));
     156    connect( ui.action_SortByState,    SIGNAL(toggled(bool)), this, SLOT(onSortByStateToggled(bool)));
     157    connect( ui.action_SortByTracker,  SIGNAL(toggled(bool)), this, SLOT(onSortByTrackerToggled(bool)));
     158    connect( ui.action_ReverseSortOrder, SIGNAL(toggled(bool)), this, SLOT(setSortAscendingPref(bool)));
    158159    connect( ui.action_Start, SIGNAL(triggered()), this, SLOT(startSelected()));
    159160    connect( ui.action_Pause, SIGNAL(triggered()), this, SLOT(pauseSelected()));
     
    205206    setTextButtonSizeHint( ui.filterSeeding );
    206207    setTextButtonSizeHint( ui.filterPaused );
    207     setShowMode( myFilterModel.getShowMode( ) );
    208208
    209209    connect( &myFilterModel, SIGNAL(rowsInserted(const QModelIndex&,int,int)), this, SLOT(refreshVisibleCount()));
     
    321321
    322322void
     323TrMainWindow :: setSortPref( int i )
     324{
     325    myPrefs.set( Prefs::SORT_MODE, SortMode( i ) );
     326}
     327void TrMainWindow :: onSortByActivityToggled ( bool b ) { if( b ) setSortPref( SortMode::SORT_BY_ACTIVITY ); }
     328void TrMainWindow :: onSortByAgeToggled      ( bool b ) { if( b ) setSortPref( SortMode::SORT_BY_AGE );      }
     329void TrMainWindow :: onSortByETAToggled      ( bool b ) { if( b ) setSortPref( SortMode::SORT_BY_ETA );      }
     330void TrMainWindow :: onSortByNameToggled     ( bool b ) { if( b ) setSortPref( SortMode::SORT_BY_NAME );     }
     331void TrMainWindow :: onSortByProgressToggled ( bool b ) { if( b ) setSortPref( SortMode::SORT_BY_PROGRESS ); }
     332void TrMainWindow :: onSortByRatioToggled    ( bool b ) { if( b ) setSortPref( SortMode::SORT_BY_RATIO );    }
     333void TrMainWindow :: onSortBySizeToggled     ( bool b ) { if( b ) setSortPref( SortMode::SORT_BY_SIZE );     }
     334void TrMainWindow :: onSortByStateToggled    ( bool b ) { if( b ) setSortPref( SortMode::SORT_BY_STATE );    }
     335void TrMainWindow :: onSortByTrackerToggled  ( bool b ) { if( b ) setSortPref( SortMode::SORT_BY_TRACKER );  }
     336
     337void
     338TrMainWindow :: setSortAscendingPref( bool b )
     339{
     340    myPrefs.set( Prefs::SORT_REVERSED, b );
     341}
     342
     343/****
     344*****
     345****/
     346
     347void
    323348TrMainWindow :: openProperties( )
    324349{
     
    512537**/
    513538
    514 void
    515 TrMainWindow :: setShowMode( TorrentFilter :: ShowMode mode )
    516 {
    517     ui.filterAll->setChecked         ( mode == TorrentFilter :: SHOW_ALL );
    518     ui.filterActive->setChecked      ( mode == TorrentFilter :: SHOW_ACTIVE );
    519     ui.filterDownloading->setChecked ( mode == TorrentFilter :: SHOW_DOWNLOADING );
    520     ui.filterSeeding->setChecked     ( mode == TorrentFilter :: SHOW_SEEDING );
    521     ui.filterPaused->setChecked      ( mode == TorrentFilter :: SHOW_PAUSED );
    522 
    523     myFilterModel.setShowMode( mode );
    524 }
    525 
    526 void TrMainWindow :: showAll         ( ) { setShowMode( TorrentFilter :: SHOW_ALL ); }
    527 void TrMainWindow :: showActive      ( ) { setShowMode( TorrentFilter :: SHOW_ACTIVE ); }
    528 void TrMainWindow :: showDownloading ( ) { setShowMode( TorrentFilter :: SHOW_DOWNLOADING ); }
    529 void TrMainWindow :: showSeeding     ( ) { setShowMode( TorrentFilter :: SHOW_SEEDING ); }
    530 void TrMainWindow :: showPaused      ( ) { setShowMode( TorrentFilter :: SHOW_PAUSED ); }
     539void TrMainWindow :: setShowMode     ( int i ) { myPrefs.set( Prefs::FILTER_MODE, FilterMode( i ) ); }
     540void TrMainWindow :: showAll         ( ) { setShowMode( FilterMode :: SHOW_ALL ); }
     541void TrMainWindow :: showActive      ( ) { setShowMode( FilterMode :: SHOW_ACTIVE ); }
     542void TrMainWindow :: showDownloading ( ) { setShowMode( FilterMode :: SHOW_DOWNLOADING ); }
     543void TrMainWindow :: showSeeding     ( ) { setShowMode( FilterMode :: SHOW_SEEDING ); }
     544void TrMainWindow :: showPaused      ( ) { setShowMode( FilterMode :: SHOW_PAUSED ); }
    531545
    532546void TrMainWindow :: filterByName    ( ) { myFilterModel.setTextMode( TorrentFilter :: FILTER_BY_NAME ); }
     
    534548void TrMainWindow :: filterByFiles   ( ) { myFilterModel.setTextMode( TorrentFilter :: FILTER_BY_FILES ); }
    535549
    536 void
    537 TrMainWindow :: showTotalRatio( )
    538 {
    539     myPrefs.set( Prefs::STATUSBAR_STATS, "total-ratio" );
    540 }
    541 void
    542 TrMainWindow :: showTotalTransfer( )
    543 {
    544     myPrefs.set( Prefs::STATUSBAR_STATS, "total-transfer" );
    545 }
    546 void
    547 TrMainWindow :: showSessionRatio( )
    548 {
    549     myPrefs.set( Prefs::STATUSBAR_STATS, "session-ratio" );
    550 }
    551 void
    552 TrMainWindow :: showSessionTransfer( )
    553 {
    554     myPrefs.set( Prefs::STATUSBAR_STATS, "session-transfer" );
    555 }
     550void TrMainWindow :: showTotalRatio      ( ) { myPrefs.set( Prefs::STATUSBAR_STATS, "total-ratio"); }
     551void TrMainWindow :: showTotalTransfer   ( ) { myPrefs.set( Prefs::STATUSBAR_STATS, "total-transfer"); }
     552void TrMainWindow :: showSessionRatio    ( ) { myPrefs.set( Prefs::STATUSBAR_STATS, "session-ratio"); }
     553void TrMainWindow :: showSessionTransfer ( ) { myPrefs.set( Prefs::STATUSBAR_STATS, "session-transfer"); }
    556554
    557555/**
     
    631629
    632630        case Prefs::SORT_MODE:
    633             i = myFilterModel.getSortModeFromName( myPrefs.getString( key ) );
    634             ui.action_SortByActivity->setChecked ( i == TorrentFilter::SORT_BY_ACTIVITY );
    635             ui.action_SortByAge->setChecked      ( i == TorrentFilter::SORT_BY_AGE );
    636             ui.action_SortByETA->setChecked      ( i == TorrentFilter::SORT_BY_ETA );
    637             ui.action_SortByName->setChecked     ( i == TorrentFilter::SORT_BY_NAME );
    638             ui.action_SortByProgress->setChecked ( i == TorrentFilter::SORT_BY_PROGRESS );
    639             ui.action_SortByRatio->setChecked    ( i == TorrentFilter::SORT_BY_RATIO );
    640             ui.action_SortBySize->setChecked     ( i == TorrentFilter::SORT_BY_SIZE );
    641             ui.action_SortByState->setChecked    ( i == TorrentFilter::SORT_BY_STATE );
    642             ui.action_SortByTracker->setChecked  ( i == TorrentFilter::SORT_BY_TRACKER );
     631            i = myPrefs.get<SortMode>(key).mode( );
     632            ui.action_SortByActivity->setChecked ( i == SortMode::SORT_BY_ACTIVITY );
     633            ui.action_SortByAge->setChecked      ( i == SortMode::SORT_BY_AGE );
     634            ui.action_SortByETA->setChecked      ( i == SortMode::SORT_BY_ETA );
     635            ui.action_SortByName->setChecked     ( i == SortMode::SORT_BY_NAME );
     636            ui.action_SortByProgress->setChecked ( i == SortMode::SORT_BY_PROGRESS );
     637            ui.action_SortByRatio->setChecked    ( i == SortMode::SORT_BY_RATIO );
     638            ui.action_SortBySize->setChecked     ( i == SortMode::SORT_BY_SIZE );
     639            ui.action_SortByState->setChecked    ( i == SortMode::SORT_BY_STATE );
     640            ui.action_SortByTracker->setChecked  ( i == SortMode::SORT_BY_TRACKER );
    643641            break;
    644642
    645643        case Prefs::FILTER_MODE:
    646             i = myFilterModel.getShowModeFromName( myPrefs.getString( key ) );
    647             ui.filterAll->setChecked         ( i == TorrentFilter::SHOW_ALL );
    648             ui.filterActive->setChecked      ( i == TorrentFilter::SHOW_ACTIVE );
    649             ui.filterDownloading->setChecked ( i == TorrentFilter::SHOW_DOWNLOADING );
    650             ui.filterSeeding->setChecked     ( i == TorrentFilter::SHOW_SEEDING );
    651             ui.filterPaused->setChecked      ( i == TorrentFilter::SHOW_PAUSED );
    652             break;
    653 
     644            i = myPrefs.get<FilterMode>(key).mode( );
     645            ui.filterAll->setChecked         ( i == FilterMode::SHOW_ALL );
     646            ui.filterActive->setChecked      ( i == FilterMode::SHOW_ACTIVE );
     647            ui.filterDownloading->setChecked ( i == FilterMode::SHOW_DOWNLOADING );
     648            ui.filterSeeding->setChecked     ( i == FilterMode::SHOW_SEEDING );
     649            ui.filterPaused->setChecked      ( i == FilterMode::SHOW_PAUSED );
     650            break;
    654651
    655652        case Prefs::FILTERBAR:
Note: See TracChangeset for help on using the changeset viewer.