Changeset 14000


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

(qt) #5285 'Qt client's file tree should have a size column like the GTK+ client's': done.

Location:
trunk/qt
Files:
4 edited

Legend:

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

    r13998 r14000  
    3333  COL_NAME,
    3434  FIRST_VISIBLE_COLUMN = COL_NAME,
     35  COL_SIZE,
    3536  COL_PROGRESS,
    3637  COL_WANTED,
     
    122123  if (column == COL_FILE_INDEX)
    123124    {
    124       return myFileIndex;
     125      value.setValue (myFileIndex);
    125126    }
    126127  else if (role == Qt::EditRole)
     
    128129      if (column == 0)
    129130        value.setValue (name());
     131    }
     132  else if ((role == Qt::TextAlignmentRole) && column == COL_SIZE)
     133    {
     134      value = Qt::AlignRight + Qt::AlignVCenter;
    130135    }
    131136  else if (role == Qt::DisplayRole)
     
    134139       {
    135140         case COL_NAME:
    136            value.setValue (fileSizeName());
     141           value.setValue (name());
     142           break;
     143
     144         case COL_SIZE:
     145           value.setValue (sizeString() + "  ");
    137146           break;
    138147
     
    181190
    182191QString
    183 FileTreeItem :: fileSizeName () const
    184 {
    185   uint64_t have = 0;
    186   uint64_t total = 0;
     192FileTreeItem :: sizeString () const
     193{
     194  QString str;
    187195
    188196  if (myChildren.isEmpty())
    189     total = myTotalSize;
     197    {
     198      str = Formatter::sizeToString (myTotalSize);
     199    }
    190200  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;
    194209}
    195210
     
    202217{
    203218  int changed_count = 0;
    204   int changed_columns[3];
     219  int changed_columns[4];
    205220
    206221  if (myName != name)
     
    213228    }
    214229
     230  if (myHaveSize != haveSize)
     231    {
     232      myHaveSize = haveSize;
     233      changed_columns[changed_count++] = COL_PROGRESS;
     234    }
     235
    215236  if (fileIndex() != -1)
    216237    {
    217       if (myHaveSize != haveSize)
    218         myHaveSize = haveSize;
    219 
    220238      if (updateFields)
    221239        {
     
    448466          case COL_NAME:
    449467            data.setValue (tr("File"));
     468            break;
     469
     470          case COL_SIZE:
     471            data.setValue (tr("Size"));
    450472            break;
    451473
     
    695717
    696718      // 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);
    698720      dataChanged (nameSibling, nameSibling);
    699       parentsChanged (nameSibling, COL_NAME);
     721      parentsChanged (nameSibling, COL_SIZE);
    700722
    701723      dataChanged (index, index);
     
    733755        {
    734756          const QFontMetrics fm(item.font);
    735           const QString text = index.data().toString();
    736757          const int iconSize = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
    737758          size.rwidth() = HIG::PAD_SMALL + iconSize;
     
    863884  installEventFilter (this);
    864885
    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    }
    872891
    873892  connect (this, SIGNAL(clicked(const QModelIndex&)),
     
    914933            continue;
    915934
    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 += "    ";
    917941          const int width = fontMetrics.size (0, header).width();
    918942          setColumnWidth (column, width);
  • trunk/qt/file-tree.h

    r13998 r14000  
    7474    void setSubtreeWanted (bool, QSet<int>& fileIds);
    7575    QString priorityString () const;
     76    QString sizeString () const;
    7677    void getSubtreeWantedSize (uint64_t& have, uint64_t& total) const;
    77     QString fileSizeName () const;
    7878    double progress () const;
    7979    int priority () const;
  • trunk/qt/freespace-label.cc

    r13992 r14000  
    8383  tr_variantDictFindInt (arguments, TR_KEY_size_bytes, &bytes);
    8484  if (bytes < 0)
    85     str = tr("Error: %1").arg(result);
     85    str = tr("<i>Error: %1</i>").arg(result);
    8686  else
    8787    str = tr("%1 free").arg(Formatter::sizeToString (bytes));
    88   setText (QString("<i>%1</i>").arg(str));
     88  setText (str);
    8989
    9090  // update the tooltip
  • trunk/qt/options.cc

    r13992 r14000  
    147147    l = myFreespaceLabel;
    148148    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);
    150150
    151151    myTree = new FileTreeView (0, false);
    152152    layout->addWidget( myTree, ++row, 0, 1, 2 );
    153153    if( !session.isLocal( ) )
    154         myTree->hideColumn( 1 ); // hide the % done, since we've no way of knowing
     154        myTree->hideColumn( 2 ); // hide the % done, since we've no way of knowing
    155155
    156156    QComboBox * m = new QComboBox;
Note: See TracChangeset for help on using the changeset viewer.