Changeset 13998


Ignore:
Timestamp:
Feb 9, 2013, 7:16:16 PM (8 years ago)
Author:
jordan
Message:

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

Location:
trunk/qt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/file-tree.cc

    r13931 r13998  
    155155
    156156void
    157 FileTreeItem :: getSubtreeSize (uint64_t& have, uint64_t& total) const
    158 {
    159   have += myHaveSize;
    160   total += myTotalSize;
     157FileTreeItem :: getSubtreeWantedSize (uint64_t& have, uint64_t& total) const
     158{
     159  if (myIsWanted)
     160    {
     161      have += myHaveSize;
     162      total += myTotalSize;
     163    }
    161164
    162165  foreach(const FileTreeItem * i, myChildren)
    163     i->getSubtreeSize(have, total);
     166    i->getSubtreeWantedSize(have, total);
    164167}
    165168
     
    170173  uint64_t have(0), total(0);
    171174
    172   getSubtreeSize(have, total);
     175  getSubtreeWantedSize (have, total);
    173176  if (total)
    174177    d = have / (double)total;
     
    180183FileTreeItem :: fileSizeName () const
    181184{
    182   uint64_t have(0), total(0);
    183   QString str;
    184   getSubtreeSize(have, total);
    185   str = QString(name() + " (%1)").arg(Formatter::sizeToString(total));
    186   return str;
     185  uint64_t have = 0;
     186  uint64_t total = 0;
     187
     188  if (myChildren.isEmpty())
     189    total = myTotalSize;
     190  else
     191    getSubtreeWantedSize (have, total);
     192
     193  return QString("%1 (%2)").arg(name()).arg(Formatter::sizeToString(total));
    187194}
    188195
     
    686693      item->twiddleWanted (file_ids, want);
    687694      emit wantedChanged (file_ids, want);
     695
     696      // this changes the name column's parenthetical size-wanted string too...
     697      QModelIndex nameSibling = index.sibling (index.row(), COL_NAME);
     698      dataChanged (nameSibling, nameSibling);
     699      parentsChanged (nameSibling, COL_NAME);
    688700
    689701      dataChanged (index, index);
  • trunk/qt/file-tree.h

    r13930 r13998  
    7474    void setSubtreeWanted (bool, QSet<int>& fileIds);
    7575    QString priorityString () const;
    76     void getSubtreeSize (uint64_t& have, uint64_t& total) const;
     76    void getSubtreeWantedSize (uint64_t& have, uint64_t& total) const;
    7777    QString fileSizeName () const;
    7878    double progress () const;
Note: See TracChangeset for help on using the changeset viewer.