Changeset 10771
- Timestamp:
- Jun 16, 2010, 3:02:17 AM (12 years ago)
- Location:
- trunk/qt
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/qt/details.cc
r10721 r10771 208 208 { 209 209 if( !myIds.empty( ) ) 210 { 211 QSet<int> infos; 212 foreach( int id, myIds ) { 213 const Torrent * tor = myModel.getTorrentFromId( id ); 214 if( tor->isMagnet() ) 215 infos.insert( tor->id() ); 216 } 217 if( !infos.isEmpty() ) 218 mySession.initTorrents( infos ); 210 219 mySession.refreshExtraStats( myIds ); 220 } 211 221 } 212 222 -
trunk/qt/torrent-delegate-min.cc
r9890 r10771 53 53 QFont nameFont( option.font ); 54 54 const QFontMetrics nameFM( nameFont ); 55 const QString nameStr( tor.name( ) ); 55 const bool isMagnet( !tor.hasMetadata( ) ); 56 const QString nameStr = (isMagnet ? progressString( tor ) : tor.name( ) ); 56 57 const QSize nameSize( nameFM.size( 0, nameStr ) ); 57 58 … … 77 78 QFont nameFont( option.font ); 78 79 const QFontMetrics nameFM( nameFont ); 79 const QString nameStr( tor.name( ) ); 80 const bool isMagnet( !tor.hasMetadata( ) ); 81 const QString nameStr = (isMagnet ? progressString( tor ) : tor.name( ) ); 80 82 const QSize nameSize( nameFM.size( 0, nameStr ) ); 81 83 … … 154 156 myProgressBarStyle->palette.setCurrentColorGroup( cg ); 155 157 myProgressBarStyle->state = progressBarState; 156 myProgressBarStyle->progress = int(myProgressBarStyle->minimum + (( tor.percentDone() * (myProgressBarStyle->maximum - myProgressBarStyle->minimum))));158 myProgressBarStyle->progress = int(myProgressBarStyle->minimum + (((isMagnet ? tor.metadataPercentDone() : tor.percentDone()) * (myProgressBarStyle->maximum - myProgressBarStyle->minimum)))); 157 159 style->drawControl( QStyle::CE_ProgressBar, myProgressBarStyle, painter ); 158 160 -
trunk/qt/torrent-delegate.cc
r10713 r10771 63 63 TorrentDelegate :: progressString( const Torrent& tor ) const 64 64 { 65 const bool isMagnet( !tor.hasMetadata( ) ); 65 66 const bool isDone( tor.isDone( ) ); 66 67 const bool isSeed( tor.isSeed( ) ); … … 70 71 const bool hasSeedRatio( tor.getSeedRatio( seedRatio ) ); 71 72 72 if( !isDone ) // downloading 73 if( isMagnet ) // magnet link with no metadata 74 { 75 /* %1 is the percentage of torrent metadata downloaded */ 76 str = tr( "Magnetized transfer - retrieving metadata ( %1% )" ) 77 .arg( tor.metadataPercentDone() ); 78 } 79 else if( !isDone ) // downloading 73 80 { 74 81 /* %1 is how much we've got, … … 387 394 painter->setFont( progressFont ); 388 395 painter->drawText( progArea, 0, progressFM.elidedText( progressStr, Qt::ElideRight, progArea.width( ) ) ); 396 const bool isMagnet( !tor.hasMetadata( ) ); 389 397 myProgressBarStyle->rect = barArea; 390 398 myProgressBarStyle->direction = option.direction; … … 392 400 myProgressBarStyle->palette.setCurrentColorGroup( cg ); 393 401 myProgressBarStyle->state = progressBarState; 394 myProgressBarStyle->progress = int(myProgressBarStyle->minimum + (( tor.percentDone() * (myProgressBarStyle->maximum - myProgressBarStyle->minimum))));402 myProgressBarStyle->progress = int(myProgressBarStyle->minimum + (((isMagnet ? tor.metadataPercentDone() : tor.percentDone()) * (myProgressBarStyle->maximum - myProgressBarStyle->minimum)))); 395 403 style->drawControl( QStyle::CE_ProgressBar, myProgressBarStyle, painter ); 396 404 -
trunk/qt/torrent-model.cc
r10486 r10771 141 141 QList<Torrent*> newTorrents; 142 142 QSet<int> oldIds( getIds( ) ); 143 QSet<int> addIds; 143 144 QSet<int> newIds; 144 145 int updatedCount = 0; … … 160 161 tor = new Torrent( myPrefs, id ); 161 162 tor->update( child ); 163 if( !tor->hasMetadata() ) 164 tor->setMagnet( true ); 162 165 newTorrents.append( tor ); 163 166 connect( tor, SIGNAL(torrentChanged(int)), this, SLOT(onTorrentChanged(int))); … … 167 170 tor->update( child ); 168 171 ++updatedCount; 172 if( tor->isMagnet() && tor->hasMetadata() ) 173 { 174 addIds.insert( tor->id() ); 175 tor->setMagnet( false ); 176 } 169 177 } 170 178 } … … 182 190 foreach( Torrent * tor, newTorrents ) { 183 191 addTorrent( tor ); 184 ids.insert( tor->id( ) );192 addIds.insert( tor->id( ) ); 185 193 } 186 194 endInsertRows( ); 187 188 emit torrentsAdded( ids ); 189 } 195 } 196 197 if( !addIds.isEmpty() ) 198 emit torrentsAdded( addIds ); 190 199 191 200 if( isCompleteList ) -
trunk/qt/torrent.h
r10713 r10771 199 199 static Property myProperties[]; 200 200 201 bool magnetTorrent; 202 201 203 public: 202 204 typedef QList<const char*> KeyList; … … 252 254 uint64_t pieceSize( ) const { return getSize( PIECE_SIZE ); } 253 255 bool hasMetadata( ) const { return getDouble( METADATA_PERCENT_DONE ) >= 1.0; } 256 bool isMagnet( ) const { return magnetTorrent; } 254 257 int pieceCount( ) const { return getInt( PIECE_COUNT ); } 255 258 double ratio( ) const { return getDouble( RATIO ); } … … 306 309 public: 307 310 void update( tr_benc * dict ); 311 void setMagnet( bool magnet ) { magnetTorrent = magnet; } 308 312 309 313 private:
Note: See TracChangeset
for help on using the changeset viewer.