]> granicus.if.org Git - transmission/commitdiff
(qt) #5284 'file tree should show the wanted size of the subtree, not the entire...
authorJordan Lee <jordan@transmissionbt.com>
Sat, 9 Feb 2013 19:16:16 +0000 (19:16 +0000)
committerJordan Lee <jordan@transmissionbt.com>
Sat, 9 Feb 2013 19:16:16 +0000 (19:16 +0000)
qt/file-tree.cc
qt/file-tree.h

index 881f0ccc591489c6b320e254fca3f3ebf81edb9b..4b89d987db160ffbdf04c0b7e7953d2132233cb6 100644 (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);
index 6dbe4ac4c31db0322eedc1bccc9497f31abc074d..216be089013cbb15b6d46107efcbe5d7ab5e8e69 100644 (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;