@ -53,6 +53,11 @@ TorrentContentModelFolder::~TorrentContentModelFolder()
@@ -53,6 +53,11 @@ TorrentContentModelFolder::~TorrentContentModelFolder()
qDeleteAll ( m_childItems ) ;
}
TorrentContentModelItem : : ItemType TorrentContentModelFolder : : itemType ( ) const
{
return FolderType ;
}
void TorrentContentModelFolder : : deleteAllChildren ( )
{
Q_ASSERT ( isRootItem ( ) ) ;
@ -81,10 +86,9 @@ TorrentContentModelItem* TorrentContentModelFolder::child(int row) const
@@ -81,10 +86,9 @@ TorrentContentModelItem* TorrentContentModelFolder::child(int row) const
TorrentContentModelFolder * TorrentContentModelFolder : : childFolderWithName ( const QString & name ) const
{
foreach ( TorrentContentModelItem * child , m_childItems ) {
if ( child - > itemType ( ) = = FolderType & & child - > name ( ) = = name )
foreach ( TorrentContentModelItem * child , m_childItems )
if ( ( child - > itemType ( ) = = FolderType ) & & ( child - > name ( ) = = name ) )
return static_cast < TorrentContentModelFolder * > ( child ) ;
}
return 0 ;
}
@ -116,23 +120,22 @@ void TorrentContentModelFolder::updatePriority()
@@ -116,23 +120,22 @@ void TorrentContentModelFolder::updatePriority()
setPriority ( prio ) ;
}
void TorrentContentModelFolder : : setPriority ( int new_prio , bool update_p arent )
void TorrentContentModelFolder : : setPriority ( int newPriority , bool updateP arent )
{
if ( m_priority = = new_prio )
if ( m_priority = = newPriority )
return ;
m_priority = new_prio ;
m_priority = newPriority ;
// Update parent priority
if ( update_p arent )
if ( updateP arent )
m_parentItem - > updatePriority ( ) ;
// Update children
if ( m_priority ! = prio : : MIXED ) {
if ( m_priority ! = prio : : MIXED )
foreach ( TorrentContentModelItem * child , m_childItems )
child - > setPriority ( m_priority , false ) ;
}
}
void TorrentContentModelFolder : : recalculateProgress ( )
{
@ -149,7 +152,7 @@ void TorrentContentModelFolder::recalculateProgress()
@@ -149,7 +152,7 @@ void TorrentContentModelFolder::recalculateProgress()
}
}
if ( ! isRootItem ( ) & & tSize > 0 ) {
if ( ! isRootItem ( ) & & ( tSize > 0 ) ) {
m_progress = tProgress / tSize ;
m_remaining = tRemaining ;
Q_ASSERT ( m_progress < = 1. ) ;