Changeset 12611
- Timestamp:
- Aug 2, 2011, 3:59:54 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gtk/actions.c
r12607 r12611 50 50 { "sort-by-name", NULL, N_( "Sort by _Name" ), NULL, NULL, 1 }, 51 51 { "sort-by-progress", NULL, N_( "Sort by _Progress" ), NULL, NULL, 2 }, 52 { "sort-by-ratio", NULL, N_( "Sort by Rati_o" ), NULL, NULL, 3 }, 53 { "sort-by-state", NULL, N_( "Sort by Stat_e" ), NULL, NULL, 4 }, 54 { "sort-by-age", NULL, N_( "Sort by A_ge" ), NULL, NULL, 5 }, 55 { "sort-by-time-left", NULL, N_( "Sort by Time _Left" ), NULL, NULL, 6 }, 56 { "sort-by-size", NULL, N_( "Sort by Si_ze" ), NULL, NULL, 7 } 52 { "sort-by-queue", NULL, N_( "Sort by _Queue" ), NULL, NULL, 3 }, 53 { "sort-by-ratio", NULL, N_( "Sort by Rati_o" ), NULL, NULL, 4 }, 54 { "sort-by-state", NULL, N_( "Sort by Stat_e" ), NULL, NULL, 5 }, 55 { "sort-by-age", NULL, N_( "Sort by A_ge" ), NULL, NULL, 6 }, 56 { "sort-by-time-left", NULL, N_( "Sort by Time _Left" ), NULL, NULL, 7 }, 57 { "sort-by-size", NULL, N_( "Sort by Si_ze" ), NULL, NULL, 8 } 57 58 }; 58 59 -
trunk/gtk/main.c
r12607 r12611 248 248 { 249 249 int total_count; 250 int active_count;251 250 int queued_count; 252 251 int stopped_count; … … 258 257 { 259 258 int activity = 0; 260 int queuePosition = -1;261 259 struct counts_data * counts = user_data; 262 260 … … 265 263 gtk_tree_model_get( model, iter, MC_ACTIVITY, &activity, -1 ); 266 264 267 if( activity == TR_STATUS_DOWNLOAD_WAIT)265 if( ( activity == TR_STATUS_DOWNLOAD_WAIT ) || ( activity == TR_STATUS_SEED_WAIT ) ) 268 266 ++counts->queued_count; 269 267 270 if( ( activity == TR_STATUS_STOPPED ) && ( queuePosition < 0 ))268 if( activity == TR_STATUS_STOPPED ) 271 269 ++counts->stopped_count; 272 else273 ++counts->active_count;274 270 } 275 271 … … 278 274 { 279 275 counts->total_count = 0; 280 counts->active_count = 0;281 276 counts->queued_count = 0; 282 277 counts->stopped_count = 0; … … 303 298 const size_t active = gtr_core_get_active_torrent_count( data->core ); 304 299 const int torrent_count = gtk_tree_model_iter_n_children( gtr_core_model( data->core ), NULL ); 305 const tr_session * session = gtr_core_session( data->core ); 306 const bool queue_enabled = tr_sessionGetQueueEnabled( session, TR_DOWN ) 307 || tr_sessionGetQueueEnabled( session, TR_UP ); 300 bool has_selection; 301 302 get_selected_torrent_counts( data, &sel_counts ); 303 has_selection = sel_counts.total_count > 0; 308 304 309 305 gtr_action_set_sensitive( "select-all", torrent_count != 0 ); … … 312 308 gtr_action_set_sensitive( "start-all-torrents", active != total ); 313 309 314 get_selected_torrent_counts( data, &sel_counts ); 315 gtr_action_set_sensitive( "torrent-stop", ( sel_counts.active_count + sel_counts.queued_count ) > 0 ); 310 gtr_action_set_sensitive( "torrent-stop", ( sel_counts.stopped_count < sel_counts.total_count ) ); 316 311 gtr_action_set_sensitive( "torrent-start", ( sel_counts.stopped_count ) > 0 ); 317 312 gtr_action_set_sensitive( "torrent-start-now", ( sel_counts.stopped_count + sel_counts.queued_count ) > 0 ); 318 gtr_action_set_sensitive( "torrent-verify", sel_counts.total_count != 0 ); 319 gtr_action_set_sensitive( "remove-torrent", sel_counts.total_count != 0 ); 320 gtr_action_set_sensitive( "delete-torrent", sel_counts.total_count != 0 ); 321 gtr_action_set_sensitive( "relocate-torrent", sel_counts.total_count != 0 ); 322 gtr_action_set_sensitive( "show-torrent-properties", sel_counts.total_count != 0 ); 313 gtr_action_set_sensitive( "torrent-verify", has_selection ); 314 gtr_action_set_sensitive( "remove-torrent", has_selection ); 315 gtr_action_set_sensitive( "delete-torrent", has_selection ); 316 gtr_action_set_sensitive( "relocate-torrent", has_selection ); 317 gtr_action_set_sensitive( "queue-move-top", has_selection ); 318 gtr_action_set_sensitive( "queue-move-up", has_selection ); 319 gtr_action_set_sensitive( "queue-move-down", has_selection ); 320 gtr_action_set_sensitive( "queue-move-bottom", has_selection ); 321 gtr_action_set_sensitive( "show-torrent-properties", has_selection ); 323 322 gtr_action_set_sensitive( "open-torrent-folder", sel_counts.total_count == 1 ); 324 323 gtr_action_set_sensitive( "copy-magnet-link-to-clipboard", sel_counts.total_count == 1 ); 325 gtr_action_set_sensitive( "queue-move-top", queue_enabled && ( sel_counts.queued_count > 0 ) );326 gtr_action_set_sensitive( "queue-move-up", queue_enabled && ( sel_counts.queued_count > 0 ) );327 gtr_action_set_sensitive( "queue-move-down", queue_enabled && ( sel_counts.queued_count > 0 ) );328 gtr_action_set_sensitive( "queue-move-bottom", queue_enabled && ( sel_counts.queued_count > 0 ) );329 324 330 325 canUpdate = 0; -
trunk/gtk/torrent-cell-renderer.c
r12609 r12611 229 229 230 230 case TR_STATUS_DOWNLOAD_WAIT: 231 g_string_append _printf( gstr, _( "Download queue #%d" ), st->queuePosition + 1);231 g_string_append( gstr, _( "Waiting to download" ) ); 232 232 break; 233 234 233 case TR_STATUS_SEED_WAIT: 235 g_string_append _printf( gstr, _( "Seed queue #%d" ), st->queuePosition + 1);234 g_string_append( gstr, _( "Waiting to seed" ) ); 236 235 break; 237 236 … … 686 685 gtr_cell_renderer_render( p->icon_renderer, window, widget, &icon_area, flags ); 687 686 g_object_set( p->progress_renderer, "value", (int)(percentDone*100.0), "text", NULL, 688 "sensitive", sensitive || ( st->queuePosition >= 0 ),687 "sensitive", sensitive, 689 688 #if GTK_CHECK_VERSION( 3,0,0 ) 690 689 "inverted", seed, … … 806 805 g_object_set( p->text_renderer, "text", gstr_prog->str, "scale", SMALL_SCALE, "weight", PANGO_WEIGHT_NORMAL, NULL ); 807 806 gtr_cell_renderer_render( p->text_renderer, window, widget, &prog_area, flags ); 808 g_object_set( p->progress_renderer, "value", (int)(percentDone*100.0), "text", "", "sensitive", ( sensitive || st->queuePosition >= 0 ),807 g_object_set( p->progress_renderer, "value", (int)(percentDone*100.0), "text", "", "sensitive", sensitive, 809 808 #if GTK_CHECK_VERSION( 3,0,0 ) 810 809 "inverted", seed, -
trunk/gtk/tr-core.c
r12607 r12611 460 460 461 461 static int 462 compare_by_queue( const tr_stat * a, const tr_stat * b ) 463 { 464 const bool a_is_queued = a->queuePosition >= 0; 465 const bool b_is_queued = b->queuePosition >= 0; 466 if( a_is_queued != b_is_queued ) return a_is_queued ? -1 : 1; 467 return b->queuePosition - a->queuePosition; 468 } 469 470 static int 471 compare_by_ratio( GtkTreeModel* m, GtkTreeIter * a, GtkTreeIter * b, gpointer user_data ) 472 { 473 int ret = 0; 462 compare_by_queue( GtkTreeModel * m, GtkTreeIter * a, GtkTreeIter * b, gpointer user_data UNUSED ) 463 { 474 464 tr_torrent *ta, *tb; 475 465 const tr_stat *sa, *sb; … … 480 470 sb = tr_torrentStatCached( tb ); 481 471 472 return sb->queuePosition - sa->queuePosition; 473 } 474 475 static int 476 compare_by_ratio( GtkTreeModel* m, GtkTreeIter * a, GtkTreeIter * b, gpointer user_data ) 477 { 478 int ret = 0; 479 tr_torrent *ta, *tb; 480 const tr_stat *sa, *sb; 481 482 gtk_tree_model_get( m, a, MC_TORRENT, &ta, -1 ); 483 sa = tr_torrentStatCached( ta ); 484 gtk_tree_model_get( m, b, MC_TORRENT, &tb, -1 ); 485 sb = tr_torrentStatCached( tb ); 486 482 487 if( !ret ) ret = compare_ratio( sa->ratio, sb->ratio ); 483 if( !ret ) ret = compare_by_queue( sa, sb ); 484 if( !ret ) ret = compare_by_name( m, a, b, user_data ); 488 if( !ret ) ret = compare_by_queue( m, a, b, user_data ); 485 489 return ret; 486 490 } … … 507 511 if( !ret ) ret = compare_double( aUp+aDown, bUp+bDown ); 508 512 if( !ret ) ret = compare_uint64( sa->uploadedEver, sb->uploadedEver ); 509 if( !ret ) ret = compare_by_queue( sa, sb ); 510 if( !ret ) ret = compare_by_name( m, a, b, user_data ); 513 if( !ret ) ret = compare_by_queue( m, a, b, user_data ); 511 514 return ret; 512 515 } … … 588 591 589 592 if( !ret ) ret = compare_int( sa, sb ); 590 if( !ret ) ret = compare_by_queue( tr_torrentStatCached( ta ), tr_torrentStatCached( tb ) ); 591 if( !ret ) ret = compare_by_progress( m, a, b, u ); 593 if( !ret ) ret = compare_by_queue( m, a, b, u ); 592 594 return ret; 593 595 } … … 607 609 else if( !strcmp( mode, "sort-by-progress" ) ) 608 610 sort_func = compare_by_progress; 611 else if( !strcmp( mode, "sort-by-queue" ) ) 612 sort_func = compare_by_queue; 609 613 else if( !strcmp( mode, "sort-by-time-left" ) ) 610 614 sort_func = compare_by_eta; -
trunk/gtk/ui.h
r12607 r12611 51 51 " <menuitem action='sort-by-name'/>\n" 52 52 " <menuitem action='sort-by-progress'/>\n" 53 " <menuitem action='sort-by-queue'/>\n" 53 54 " <menuitem action='sort-by-ratio'/>\n" 54 55 " <menuitem action='sort-by-size'/>\n" -
trunk/libtransmission/rpcimpl.c
r12609 r12611 314 314 tr_torrent * tor = torrents[i]; 315 315 316 if( tor->isRunning || ( tor->queuePosition >= 0) )316 if( tor->isRunning || tr_torrentIsQueued( tor ) ) 317 317 { 318 318 tor->isStopping = true; -
trunk/libtransmission/session.c
r12607 r12611 2693 2693 assert( tr_isDirection( direction ) ); 2694 2694 2695 while(( tor = tr_torrentNext( session, tor ))) { 2696 if( !tor->isRunning && ( direction == tr_torrentGetQueueDirection( tor ) ) ) { 2697 const int position = tr_torrentGetQueuePosition( tor ); 2698 if( ( position >= 0 ) && ( best_position > position ) ) { 2699 best_position = position; 2700 best_tor = tor; 2701 } 2695 while(( tor = tr_torrentNext( session, tor ))) 2696 { 2697 int position; 2698 2699 if( !tr_torrentIsQueued( tor ) ) 2700 continue; 2701 if( direction != tr_torrentGetQueueDirection( tor ) ) 2702 continue; 2703 2704 position = tr_torrentGetQueuePosition( tor ); 2705 if( best_position > position ) { 2706 best_position = position; 2707 best_tor = tor; 2702 2708 } 2703 2709 } … … 2712 2718 int active_count; 2713 2719 const int max = tr_sessionGetQueueSize( session, dir ); 2714 const tr_torrent_activity activity = TR_UP ? TR_STATUS_SEED : TR_STATUS_DOWNLOAD;2720 const tr_torrent_activity activity = dir == TR_UP ? TR_STATUS_SEED : TR_STATUS_DOWNLOAD; 2715 2721 2716 2722 if( !tr_sessionGetQueueEnabled( session, dir ) ) -
trunk/libtransmission/torrent.c
r12609 r12611 803 803 tor->uniqueId = nextUniqueId++; 804 804 tor->magicNumber = TORRENT_MAGIC_NUMBER; 805 tor->queuePosition = -1;805 tor->queuePosition = session->torrentCount; 806 806 807 807 tr_peerIdInit( tor->peer_id ); … … 871 871 872 872 /* add the torrent to tr_session.torrentList */ 873 ++session->torrentCount;873 session->torrentCount++; 874 874 if( session->torrentList == NULL ) 875 875 session->torrentList = tor; … … 1106 1106 return is_seed ? TR_STATUS_SEED : TR_STATUS_DOWNLOAD; 1107 1107 1108 if( t or->queuePosition >= 0) {1108 if( tr_torrentIsQueued( tor ) ) { 1109 1109 if( is_seed && tr_sessionGetQueueEnabled( tor->session, TR_UP ) ) 1110 1110 return TR_STATUS_SEED_WAIT; … … 1497 1497 ***/ 1498 1498 1499 static bool queueIsSequenced( tr_session * ); 1500 1499 1501 static void 1500 1502 freeTorrent( tr_torrent * tor ) … … 1503 1505 tr_session * session = tor->session; 1504 1506 tr_info * inf = &tor->info; 1507 const time_t now = tr_time( ); 1505 1508 1506 1509 assert( !tor->isRunning ); … … 1526 1529 } 1527 1530 1531 /* decrement the torrent count */ 1528 1532 assert( session->torrentCount >= 1 ); 1529 1533 session->torrentCount--; 1534 1535 /* resequence the queue positions */ 1536 t = NULL; 1537 while(( t = tr_torrentNext( session, tor ))) { 1538 if( t->queuePosition > tor->queuePosition ) { 1539 t->queuePosition--; 1540 t->anyDate = now; 1541 } 1542 } 1543 assert( queueIsSequenced( session ) ); 1530 1544 1531 1545 tr_bandwidthDestruct( &tor->bandwidth ); … … 1541 1555 **/ 1542 1556 1543 static void queueRemove( tr_torrent * tor);1557 static void torrentSetQueued( tr_torrent * tor, bool queued ); 1544 1558 1545 1559 static void … … 1554 1568 1555 1569 tr_torrentRecheckCompleteness( tor ); 1556 queueRemove( tor);1570 torrentSetQueued( tor, false ); 1557 1571 1558 1572 now = tr_time( ); … … 1602 1616 return tr_sessionCountQueueFreeSlots( tor->session, dir ) == 0; 1603 1617 } 1604 1605 static void queueAppend( tr_torrent * tor );1606 1618 1607 1619 static void … … 1631 1643 case TR_STATUS_STOPPED: 1632 1644 if( !bypass_queue && torrentShouldQueue( tor ) ) { 1633 queueAppend( tor);1645 torrentSetQueued( tor, true ); 1634 1646 return; 1635 1647 } … … 1755 1767 1756 1768 tr_verifyRemove( tor ); 1757 queueRemove( tor);1769 torrentSetQueued( tor, false ); 1758 1770 tr_peerMgrStopTorrent( tor ); 1759 1771 tr_announcerTorrentStopped( tor ); … … 3175 3187 3176 3188 static bool 3177 queueIsSequenced( tr_ torrent * tor)3189 queueIsSequenced( tr_session * session ) 3178 3190 { 3179 3191 int i ; 3180 3192 int n ; 3181 3193 bool is_sequenced = true; 3182 tr_session * session = tor->session; 3183 tr_direction direction = tr_torrentGetQueueDirection( tor ); 3194 tr_torrent * tor; 3184 3195 tr_torrent ** tmp = tr_new( tr_torrent *, session->torrentCount ); 3185 3196 3186 /* get all the torrents in that queue*/3197 /* get all the torrents */ 3187 3198 n = 0; 3188 3199 tor = NULL; 3189 3200 while(( tor = tr_torrentNext( session, tor ))) 3190 if( tr_torrentIsQueued( tor ) && ( direction == tr_torrentGetQueueDirection( tor ) ) ) 3191 tmp[n++] = tor; 3201 tmp[n++] = tor; 3192 3202 3193 3203 /* sort them by position */ … … 3195 3205 3196 3206 #if 0 3197 /* print them */ 3198 fprintf( stderr, "sequence: " ); 3207 fprintf( stderr, "%s", "queue: " ); 3199 3208 for( i=0; i<n; ++i ) 3200 3209 fprintf( stderr, "%d ", tmp[i]->queuePosition ); 3201 fp rintf( stderr, "\n");3210 fputc( '\n', stderr ); 3202 3211 #endif 3203 3212 … … 3220 3229 tr_torrentSetQueuePosition( tr_torrent * tor, int pos ) 3221 3230 { 3222 if( tr_torrentIsQueued( tor ) ) 3223 { 3224 int back = -1; 3225 tr_torrent * walk; 3226 const tr_direction direction = tr_torrentGetQueueDirection( tor ); 3227 const int old_pos = tor->queuePosition; 3228 const time_t now = tr_time( ); 3229 3230 if( pos < 0 ) 3231 pos = 0; 3232 3233 tor->queuePosition = -1; 3234 3235 walk = NULL; 3236 while(( walk = tr_torrentNext( tor->session, walk ))) 3237 { 3238 if( tr_torrentIsQueued( walk ) && ( tr_torrentGetQueueDirection( walk ) == direction ) ) 3239 { 3240 if( old_pos < pos ) { 3241 if( ( old_pos <= walk->queuePosition ) && ( walk->queuePosition <= pos ) ) { 3242 walk->queuePosition--; 3243 walk->anyDate = now; 3244 } 3245 } 3246 3247 if( old_pos > pos ) { 3248 if( ( pos <= walk->queuePosition ) && ( walk->queuePosition < old_pos ) ) { 3249 walk->queuePosition++; 3250 walk->anyDate = now; 3251 } 3252 } 3253 3254 if( back < walk->queuePosition ) 3255 back = walk->queuePosition; 3231 int back = -1; 3232 tr_torrent * walk; 3233 const int old_pos = tor->queuePosition; 3234 const time_t now = tr_time( ); 3235 3236 if( pos < 0 ) 3237 pos = 0; 3238 3239 tor->queuePosition = -1; 3240 3241 walk = NULL; 3242 while(( walk = tr_torrentNext( tor->session, walk ))) 3243 { 3244 if( old_pos < pos ) { 3245 if( ( old_pos <= walk->queuePosition ) && ( walk->queuePosition <= pos ) ) { 3246 walk->queuePosition--; 3247 walk->anyDate = now; 3256 3248 } 3257 3249 } 3258 3250 3259 tor->queuePosition = MIN( pos, (back+1) ); 3260 tor->anyDate = now; 3261 } 3262 3263 assert( queueIsSequenced( tor ) ); 3251 if( old_pos > pos ) { 3252 if( ( pos <= walk->queuePosition ) && ( walk->queuePosition < old_pos ) ) { 3253 walk->queuePosition++; 3254 walk->anyDate = now; 3255 } 3256 } 3257 3258 if( back < walk->queuePosition ) 3259 back = walk->queuePosition; 3260 } 3261 3262 tor->queuePosition = MIN( pos, (back+1) ); 3263 tor->anyDate = now; 3264 3265 assert( queueIsSequenced( tor->session ) ); 3264 3266 } 3265 3267 … … 3308 3310 } 3309 3311 3310 /* Ensure that the torrents queued for downloads have queuePositions contiguous from [0...n] */3311 3312 static void 3312 queueResequence( tr_session * session, tr_direction direction ) 3313 { 3314 int i; 3315 int n; 3316 tr_torrent * tor = NULL; 3317 tr_torrent ** tmp = tr_new( tr_torrent *, session->torrentCount ); 3318 const time_t now = tr_time( ); 3319 3320 assert( tr_isSession( session ) ); 3321 assert( tr_isDirection( direction ) ); 3322 3323 /* get all the torrents in that queue */ 3324 n = 0; 3325 while(( tor = tr_torrentNext( session, tor ))) { 3326 if( direction == tr_torrentGetQueueDirection( tor )) { 3327 const int position = tr_torrentGetQueuePosition( tor ); 3328 if( position >= 0 ) 3329 tmp[n++] = tor; 3330 } 3331 } 3332 3333 /* sort them by position */ 3334 qsort( tmp, n, sizeof( tr_torrent * ), compareTorrentByQueuePosition ); 3335 3336 /* sequence them... */ 3337 for( i=0; i<n; ++i ) { 3338 tr_torrent * tor = tmp[i]; 3339 if( tor->queuePosition != i ) { 3340 tor->queuePosition = i; 3341 tor->anyDate = now; 3342 } 3343 } 3344 3345 tr_free( tmp ); 3346 } 3347 3348 static void 3349 queueRemove( tr_torrent * tor ) 3350 { 3351 if( tr_torrentIsQueued( tor ) ) 3352 { 3353 tor->queuePosition = -1; 3354 queueResequence( tor->session, tr_torrentGetQueueDirection( tor ) ); 3355 } 3356 } 3357 3358 static void 3359 queueAppend( tr_torrent * tor ) 3360 { 3361 if( !tr_torrentIsQueued( tor ) ) 3362 { 3363 /* tr_torrentSetQueuePosition() requres the torrent to be queued, 3364 so init tor->queuePosition to the back... */ 3365 tor->queuePosition = INT_MAX; 3366 3367 tr_torrentSetQueuePosition( tor, INT_MAX ); 3368 } 3369 } 3313 torrentSetQueued( tr_torrent * tor, bool queued ) 3314 { 3315 assert( tr_isTorrent( tor ) ); 3316 assert( tr_isBool( queued ) ); 3317 3318 if( tr_torrentIsQueued( tor ) != queued ) 3319 { 3320 tor->isQueued = queued; 3321 tor->anyDate = tr_time( ); 3322 } 3323 } -
trunk/libtransmission/torrent.h
r12607 r12611 242 242 bool startAfterVerify; 243 243 bool isDirty; 244 bool isQueued; 244 245 245 246 bool infoDictOffsetIsCached; … … 434 435 tr_torrentIsQueued( const tr_torrent * tor ) 435 436 { 436 return tor-> queuePosition >= 0;437 return tor->isQueued; 437 438 } 438 439 -
trunk/libtransmission/transmission.h
r12609 r12611 1998 1998 bool finished; 1999 1999 2000 /** Th e position of this torrent in the download queue.2001 This will be >= 0 if the torrent is queued; -1 otherwise. */2000 /** This torrent's queue position. 2001 All torrents have a queue position, even if it's not queued. */ 2002 2002 int queuePosition; 2003 2003 -
trunk/qt/filters.cc
r12607 r12611 40 40 "sort-by-name", 41 41 "sort-by-progress", 42 "sort-by-queue" 42 43 "sort-by-ratio", 43 44 "sort-by-size", -
trunk/qt/filters.h
r12607 r12611 43 43 static const QString names[]; 44 44 enum { SORT_BY_ACTIVITY, SORT_BY_AGE, SORT_BY_ETA, SORT_BY_NAME, 45 SORT_BY_PROGRESS, SORT_BY_ RATIO, SORT_BY_SIZE,45 SORT_BY_PROGRESS, SORT_BY_QUEUE, SORT_BY_RATIO, SORT_BY_SIZE, 46 46 SORT_BY_STATE, SORT_BY_ID, NUM_MODES }; 47 47 static int modeFromName( const QString& name ); -
trunk/qt/mainwin.cc
r12607 r12611 141 141 connect( ui.action_SortByName, SIGNAL(toggled(bool)), this, SLOT(onSortByNameToggled(bool))); 142 142 connect( ui.action_SortByProgress, SIGNAL(toggled(bool)), this, SLOT(onSortByProgressToggled(bool))); 143 connect( ui.action_SortByQueue, SIGNAL(toggled(bool)), this, SLOT(onSortByQueueToggled(bool))); 143 144 connect( ui.action_SortByRatio, SIGNAL(toggled(bool)), this, SLOT(onSortByRatioToggled(bool))); 144 145 connect( ui.action_SortBySize, SIGNAL(toggled(bool)), this, SLOT(onSortBySizeToggled(bool))); … … 521 522 void TrMainWindow :: onSortByNameToggled ( bool b ) { if( b ) setSortPref( SortMode::SORT_BY_NAME ); } 522 523 void TrMainWindow :: onSortByProgressToggled ( bool b ) { if( b ) setSortPref( SortMode::SORT_BY_PROGRESS ); } 524 void TrMainWindow :: onSortByQueueToggled ( bool b ) { if( b ) setSortPref( SortMode::SORT_BY_QUEUE ); } 523 525 void TrMainWindow :: onSortByRatioToggled ( bool b ) { if( b ) setSortPref( SortMode::SORT_BY_RATIO ); } 524 526 void TrMainWindow :: onSortBySizeToggled ( bool b ) { if( b ) setSortPref( SortMode::SORT_BY_SIZE ); } … … 759 761 ui.action_Announce->setEnabled( selected > 0 && ( canAnnounce == selected ) ); 760 762 761 ui.action_QueueMoveTop->setEnabled( selectedAndQueued > 0);762 ui.action_QueueMoveUp->setEnabled( selectedAndQueued > 0);763 ui.action_QueueMoveDown->setEnabled( selectedAndQueued > 0);764 ui.action_QueueMoveBottom->setEnabled( selectedAndQueued > 0);763 ui.action_QueueMoveTop->setEnabled( haveSelection ); 764 ui.action_QueueMoveUp->setEnabled( haveSelection ); 765 ui.action_QueueMoveDown->setEnabled( haveSelection ); 766 ui.action_QueueMoveBottom->setEnabled( haveSelection ); 765 767 766 768 if( myDetailsDialog ) … … 960 962 ui.action_SortByName->setChecked ( i == SortMode::SORT_BY_NAME ); 961 963 ui.action_SortByProgress->setChecked ( i == SortMode::SORT_BY_PROGRESS ); 964 ui.action_SortByQueue->setChecked ( i == SortMode::SORT_BY_QUEUE ); 962 965 ui.action_SortByRatio->setChecked ( i == SortMode::SORT_BY_RATIO ); 963 966 ui.action_SortBySize->setChecked ( i == SortMode::SORT_BY_SIZE ); -
trunk/qt/mainwin.h
r12607 r12611 139 139 void onSortByNameToggled ( bool ); 140 140 void onSortByProgressToggled ( bool ); 141 void onSortByQueueToggled ( bool ); 141 142 void onSortByRatioToggled ( bool ); 142 143 void onSortBySizeToggled ( bool ); -
trunk/qt/mainwin.ui
r12607 r12611 127 127 <addaction name="action_SortByName"/> 128 128 <addaction name="action_SortByProgress"/> 129 <addaction name="action_SortByQueue"/> 129 130 <addaction name="action_SortByRatio"/> 130 131 <addaction name="action_SortBySize"/> … … 633 634 </property> 634 635 </action> 636 <action name="action_SortByQueue"> 637 <property name="checkable"> 638 <bool>true</bool> 639 </property> 640 <property name="text"> 641 <string>Sort by &Queue</string> 642 </property> 643 </action> 635 644 </widget> 636 645 <resources> -
trunk/qt/torrent-filter.cc
r12610 r12611 86 86 switch( myPrefs.get<SortMode>(Prefs::SORT_MODE).mode() ) 87 87 { 88 case SortMode :: SORT_BY_QUEUE: 89 if( !val ) val = -compare( a->queuePosition(), b->queuePosition() ); 90 break; 88 91 case SortMode :: SORT_BY_SIZE: 89 92 if( !val ) val = compare( a->sizeWhenDone(), b->sizeWhenDone() ); … … 102 105 if( !val ) val = compare( a->hasError(), b->hasError() ); 103 106 if( !val ) val = compare( a->getActivity(), b->getActivity() ); 104 if( !val ) val = a->compareQueue( *b);107 if( !val ) val = -compare( a->queuePosition(), b->queuePosition() ); 105 108 // fall through 106 109 case SortMode :: SORT_BY_PROGRESS: 107 110 if( !val ) val = compare( a->percentComplete(), b->percentComplete() ); 108 111 if( !val ) val = a->compareSeedRatio( *b ); 109 if( !val ) val = a->compareQueue( *b);112 if( !val ) val = -compare( a->queuePosition(), b->queuePosition() ); 110 113 case SortMode :: SORT_BY_RATIO: 111 114 if( !val ) val = a->compareRatio( *b ); -
trunk/qt/torrent.cc
r12609 r12611 369 369 return true; 370 370 return false; 371 }372 373 int374 Torrent :: compareQueue( const Torrent& that ) const375 {376 const bool a_is_queued = isQueued( );377 const bool b_is_queued = that.isQueued( );378 379 if( a_is_queued != b_is_queued )380 return a_is_queued ? -1 : 1;381 382 return that.queuePosition() - queuePosition();383 371 } 384 372 … … 719 707 case TR_STATUS_CHECK_WAIT: str = tr( "Waiting to verify local data" ); break; 720 708 case TR_STATUS_CHECK: str = tr( "Verifying local data" ); break; 721 case TR_STATUS_DOWNLOAD_WAIT: str = tr( " Download queue #%1" ).arg( queuePosition() + 1); break;722 case TR_STATUS_DOWNLOAD: str = tr( "Downloading" ); 723 case TR_STATUS_SEED_WAIT: str = tr( " Seed queue #%1" ).arg( queuePosition() + 1); break;724 case TR_STATUS_SEED: str = tr( " Seeding" ); break;709 case TR_STATUS_DOWNLOAD_WAIT: str = tr( "Waiting to download" ); break; 710 case TR_STATUS_DOWNLOAD: str = tr( "Downloading" ); break; 711 case TR_STATUS_SEED_WAIT: str = tr( "Queued" ); break; 712 case TR_STATUS_SEED: str = tr( "Waiting to seed" ); break; 725 713 } 726 714 -
trunk/qt/torrent.h
r12609 r12611 274 274 int compareSeedRatio( const Torrent& ) const; 275 275 int compareRatio( const Torrent& ) const; 276 int compareQueue( const Torrent& ) const;277 276 int compareETA( const Torrent& ) const; 278 277 bool hasETA( ) const { return getETA( ) >= 0; } … … 309 308 const FileList& files( ) const { return myFiles; } 310 309 int queuePosition( ) const { return getInt( QUEUE_POSITION ); } 311 bool isQueued( ) const { return queuePosition( ) >= 0; }312 310 bool isStalled( ) const { return getBool( IS_STALLED ); } 313 311 … … 324 322 bool isWaitingToSeed( ) const { return getActivity( ) == TR_STATUS_SEED_WAIT; } 325 323 bool isReadyToTransfer( ) const { return getActivity()==TR_STATUS_DOWNLOAD || getActivity()==TR_STATUS_SEED; } 324 bool isQueued( ) const { return isWaitingToDownload() || isWaitingToSeed(); } 326 325 void notifyComplete( ) const; 327 326 -
trunk/web/index.html
r12607 r12611 527 527 <li id="sort_by_percent_completed">Progress</li> 528 528 <li id="sort_by_ratio">Ratio</li> 529 <li id="sort_by_queue_order">Queue Order</li> 529 530 <li id="sort_by_state">State</li> 530 531 <li class="separator"></li> -
trunk/web/javascript/common.js
r12607 r12611 234 234 Prefs._SortByActivity = 'activity'; 235 235 Prefs._SortByName = 'name'; 236 Prefs._SortByQueue = 'queue_order'; 236 237 Prefs._SortByProgress = 'percent_completed'; 237 238 Prefs._SortByRatio = 'ratio'; -
trunk/web/javascript/torrent.js
r12607 r12611 253 253 name: function() { return this._name; }, 254 254 queuePosition: function() { return this._queue_position; }, 255 isQueued: function() { return this.queuePosition() >= 0; }, 255 isQueued: function() { return ( this.state() == Torrent._StatusSeedWait ) 256 || ( this.state() == Torrent._StatusDownloadWait ); }, 256 257 webseedsSendingToUs: function() { return this._webseeds_sending_to_us; }, 257 258 peersSendingToUs: function() { return this._peers_sending_to_us; }, … … 273 274 case Torrent._StatusCheckWait: return 'Waiting to verify local data'; 274 275 case Torrent._StatusCheck: return 'Verifying local data'; 275 case Torrent._StatusDownloadWait: return 'Waiting to download #' + (this.queuePosition()+1);276 case Torrent._StatusDownloadWait: return 'Waiting to download'; 276 277 case Torrent._StatusDownload: return 'Downloading'; 277 case Torrent._StatusSeedWait: return 'Waiting to seed #' + (this.queuePosition()+1);278 case Torrent._StatusSeedWait: return 'Waiting to seed'; 278 279 case Torrent._StatusSeed: return 'Seeding'; 279 280 default: return 'error'; … … 771 772 Torrent.compareByQueue = function( a, b ) 772 773 { 773 var a_is_queued = a.isQueued( ); 774 var b_is_queued = b.isQueued( ); 775 if( a_is_queued != b_is_queued ) 776 return a_is_queued ? -1 : 1; 777 778 var a_pos = a.queuePosition( ); 779 var b_pos = b.queuePosition( ); 780 if( a_pos != b_pos ) 781 return a_pos - b_pos; 782 783 return Torrent.compareByName( a, b ); 774 return a.queuePosition( ) - b.queuePosition(); 784 775 }; 785 776 … … 846 837 case Prefs._SortByAge: 847 838 torrents.sort( this.compareByAge ); 839 break; 840 case Prefs._SortByQueue: 841 torrents.sort( this.compareByQueue ); 848 842 break; 849 843 case Prefs._SortByProgress:
Note: See TracChangeset
for help on using the changeset viewer.