1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-01-31 03:12:44 +00:00

(qt) #5284 'file tree should show the wanted size of the subtree, not the entire size': done.

This commit is contained in:
Jordan Lee 2013-02-09 19:16:16 +00:00
parent c2bde75718
commit d03de26e13
2 changed files with 23 additions and 11 deletions

View file

@ -154,13 +154,16 @@ FileTreeItem :: data (int column, int role) const
}
void
FileTreeItem :: getSubtreeSize (uint64_t& have, uint64_t& total) const
FileTreeItem :: getSubtreeWantedSize (uint64_t& have, uint64_t& total) const
{
have += myHaveSize;
total += myTotalSize;
if (myIsWanted)
{
have += myHaveSize;
total += myTotalSize;
}
foreach(const FileTreeItem * i, myChildren)
i->getSubtreeSize(have, total);
i->getSubtreeWantedSize(have, total);
}
double
@ -169,7 +172,7 @@ FileTreeItem :: progress () const
double d(0);
uint64_t have(0), total(0);
getSubtreeSize(have, total);
getSubtreeWantedSize (have, total);
if (total)
d = have / (double)total;
@ -179,11 +182,15 @@ FileTreeItem :: progress () const
QString
FileTreeItem :: fileSizeName () const
{
uint64_t have(0), total(0);
QString str;
getSubtreeSize(have, total);
str = QString(name() + " (%1)").arg(Formatter::sizeToString(total));
return str;
uint64_t have = 0;
uint64_t total = 0;
if (myChildren.isEmpty())
total = myTotalSize;
else
getSubtreeWantedSize (have, total);
return QString("%1 (%2)").arg(name()).arg(Formatter::sizeToString(total));
}
std::pair<int,int>
@ -686,6 +693,11 @@ FileTreeModel :: clicked (const QModelIndex& index)
item->twiddleWanted (file_ids, want);
emit wantedChanged (file_ids, want);
// this changes the name column's parenthetical size-wanted string too...
QModelIndex nameSibling = index.sibling (index.row(), COL_NAME);
dataChanged (nameSibling, nameSibling);
parentsChanged (nameSibling, COL_NAME);
dataChanged (index, index);
parentsChanged (index, column);
subtreeChanged (index, column);

View file

@ -73,7 +73,7 @@ class FileTreeItem: public QObject
void setSubtreePriority (int priority, QSet<int>& fileIds);
void setSubtreeWanted (bool, QSet<int>& fileIds);
QString priorityString () const;
void getSubtreeSize (uint64_t& have, uint64_t& total) const;
void getSubtreeWantedSize (uint64_t& have, uint64_t& total) const;
QString fileSizeName () const;
double progress () const;
int priority () const;