Changeset 11742


Ignore:
Timestamp:
Jan 21, 2011, 6:30:08 PM (11 years ago)
Author:
jordan
Message:

(trunk gtk) include the torrent hashcode in the model's collated name.

This simplifies sorting by name by merging the primary and secondary keys (case-insensitive name, and hash string) into a single key.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/tr-core.c

    r11740 r11742  
    324324    }
    325325
    326     if( !ret ) {
    327         tr_torrent * t;
    328         const tr_info *ia, *ib;
    329         gtk_tree_model_get( m, a, MC_TORRENT_RAW, &t, -1 );
    330         ia = tr_torrentInfo( t );
    331         gtk_tree_model_get( m, b, MC_TORRENT_RAW, &t, -1 );
    332         ib = tr_torrentInfo( t );
    333         ret = memcmp( ia->hash, ib->hash, SHA_DIGEST_LENGTH );
    334     }
    335 
    336326    return ret;
    337327}
     
    867857}
    868858
     859static char*
     860get_collated_name( const tr_info * inf )
     861{
     862    char * down = g_utf8_strdown( inf->name ? inf->name : "", -1 );
     863    char * collated = g_strdup_printf( "%s\t%s", down, inf->hashString );
     864    g_free( down );
     865    return collated;
     866}
     867
    869868void
    870869tr_core_add_torrent( TrCore     * self,
     
    875874    const tr_stat * st = tr_torrent_stat( gtor );
    876875    tr_torrent * tor = tr_torrent_handle( gtor );
    877     char *  collated = g_utf8_strdown( inf->name ? inf->name : "", -1 );
     876    char *  collated = get_collated_name( inf );
    878877    char *  trackers = torrentTrackerString( tor );
    879878    GtkListStore *  store = GTK_LIST_STORE( tr_core_model( self ) );
     
    12931292    gboolean oldActive, newActive;
    12941293    const tr_stat * st;
    1295     const tr_info * inf;
    12961294    TrTorrent * gtor;
    12971295    tr_torrent * tor;
     
    13241322    newActivePeerCount = st->peersSendingToUs + st->peersGettingFromUs + st->webseedsSendingToUs;
    13251323    newError = st->error;
    1326     inf = tr_torrent_info( gtor );
    1327     newCollatedName = g_utf8_strdown( inf->name ? inf->name : "", -1 );
     1324    newCollatedName = get_collated_name( tr_torrent_info( gtor ) );
    13281325
    13291326    /* updating the model triggers off resort/refresh,
Note: See TracChangeset for help on using the changeset viewer.