Changeset 14000
- Timestamp:
- Feb 9, 2013, 8:51:17 PM (10 years ago)
- Location:
- trunk/qt
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/qt/file-tree.cc
r13998 r14000 33 33 COL_NAME, 34 34 FIRST_VISIBLE_COLUMN = COL_NAME, 35 COL_SIZE, 35 36 COL_PROGRESS, 36 37 COL_WANTED, … … 122 123 if (column == COL_FILE_INDEX) 123 124 { 124 return myFileIndex;125 value.setValue (myFileIndex); 125 126 } 126 127 else if (role == Qt::EditRole) … … 128 129 if (column == 0) 129 130 value.setValue (name()); 131 } 132 else if ((role == Qt::TextAlignmentRole) && column == COL_SIZE) 133 { 134 value = Qt::AlignRight + Qt::AlignVCenter; 130 135 } 131 136 else if (role == Qt::DisplayRole) … … 134 139 { 135 140 case COL_NAME: 136 value.setValue (fileSizeName()); 141 value.setValue (name()); 142 break; 143 144 case COL_SIZE: 145 value.setValue (sizeString() + " "); 137 146 break; 138 147 … … 181 190 182 191 QString 183 FileTreeItem :: fileSizeName () const 184 { 185 uint64_t have = 0; 186 uint64_t total = 0; 192 FileTreeItem :: sizeString () const 193 { 194 QString str; 187 195 188 196 if (myChildren.isEmpty()) 189 total = myTotalSize; 197 { 198 str = Formatter::sizeToString (myTotalSize); 199 } 190 200 else 191 getSubtreeWantedSize (have, total); 192 193 return QString("%1 (%2)").arg(name()).arg(Formatter::sizeToString(total)); 201 { 202 uint64_t have = 0; 203 uint64_t total = 0; 204 getSubtreeWantedSize (have, total); 205 str = Formatter::sizeToString (total); 206 } 207 208 return str; 194 209 } 195 210 … … 202 217 { 203 218 int changed_count = 0; 204 int changed_columns[ 3];219 int changed_columns[4]; 205 220 206 221 if (myName != name) … … 213 228 } 214 229 230 if (myHaveSize != haveSize) 231 { 232 myHaveSize = haveSize; 233 changed_columns[changed_count++] = COL_PROGRESS; 234 } 235 215 236 if (fileIndex() != -1) 216 237 { 217 if (myHaveSize != haveSize)218 myHaveSize = haveSize;219 220 238 if (updateFields) 221 239 { … … 448 466 case COL_NAME: 449 467 data.setValue (tr("File")); 468 break; 469 470 case COL_SIZE: 471 data.setValue (tr("Size")); 450 472 break; 451 473 … … 695 717 696 718 // this changes the name column's parenthetical size-wanted string too... 697 QModelIndex nameSibling = index.sibling (index.row(), COL_ NAME);719 QModelIndex nameSibling = index.sibling (index.row(), COL_SIZE); 698 720 dataChanged (nameSibling, nameSibling); 699 parentsChanged (nameSibling, COL_ NAME);721 parentsChanged (nameSibling, COL_SIZE); 700 722 701 723 dataChanged (index, index); … … 733 755 { 734 756 const QFontMetrics fm(item.font); 735 const QString text = index.data().toString();736 757 const int iconSize = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize); 737 758 size.rwidth() = HIG::PAD_SMALL + iconSize; … … 863 884 installEventFilter (this); 864 885 865 for (int i=0; i<FIRST_VISIBLE_COLUMN; ++i) 866 hideColumn (i); 867 for (int i=LAST_VISIBLE_COLUMN+1; i<NUM_COLUMNS; ++i) 868 hideColumn (i); 869 870 for (int i=FIRST_VISIBLE_COLUMN; i<=LAST_VISIBLE_COLUMN; ++i) 871 header()->setResizeMode(i, QHeaderView::Interactive); 886 for (int i=0; i<NUM_COLUMNS; ++i) 887 { 888 setColumnHidden (i, (i<FIRST_VISIBLE_COLUMN) || (LAST_VISIBLE_COLUMN<i)); 889 header()->setResizeMode(i, QHeaderView::Interactive); 890 } 872 891 873 892 connect (this, SIGNAL(clicked(const QModelIndex&)), … … 914 933 continue; 915 934 916 const QString header = myModel.headerData (column, Qt::Horizontal).toString() + " "; 935 QString header; 936 if (column == COL_SIZE) 937 header = "999.9 KiB"; 938 else 939 header = myModel.headerData (column, Qt::Horizontal).toString(); 940 header += " "; 917 941 const int width = fontMetrics.size (0, header).width(); 918 942 setColumnWidth (column, width); -
trunk/qt/file-tree.h
r13998 r14000 74 74 void setSubtreeWanted (bool, QSet<int>& fileIds); 75 75 QString priorityString () const; 76 QString sizeString () const; 76 77 void getSubtreeWantedSize (uint64_t& have, uint64_t& total) const; 77 QString fileSizeName () const;78 78 double progress () const; 79 79 int priority () const; -
trunk/qt/freespace-label.cc
r13992 r14000 83 83 tr_variantDictFindInt (arguments, TR_KEY_size_bytes, &bytes); 84 84 if (bytes < 0) 85 str = tr(" Error: %1").arg(result);85 str = tr("<i>Error: %1</i>").arg(result); 86 86 else 87 87 str = tr("%1 free").arg(Formatter::sizeToString (bytes)); 88 setText ( QString("<i>%1</i>").arg(str));88 setText (str); 89 89 90 90 // update the tooltip -
trunk/qt/options.cc
r13992 r14000 147 147 l = myFreespaceLabel; 148 148 layout->addWidget (l, ++row, 0, 1, 2, Qt::Alignment (Qt::AlignRight | Qt::AlignTop)); 149 layout->setRowMinimumHeight (row, l->height() + HIG::PAD );149 layout->setRowMinimumHeight (row, l->height() + HIG::PAD_SMALL); 150 150 151 151 myTree = new FileTreeView (0, false); 152 152 layout->addWidget( myTree, ++row, 0, 1, 2 ); 153 153 if( !session.isLocal( ) ) 154 myTree->hideColumn( 1); // hide the % done, since we've no way of knowing154 myTree->hideColumn( 2 ); // hide the % done, since we've no way of knowing 155 155 156 156 QComboBox * m = new QComboBox;
Note: See TracChangeset
for help on using the changeset viewer.