Changeset 13937
- Timestamp:
- Feb 2, 2013, 10:29:14 PM (8 years ago)
- Location:
- trunk/qt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/qt/filterbar.cc
r13927 r13937 32 32 enum 33 33 { 34 TorrentCountRole = Qt::UserRole + 1, 35 ActivityRole, 36 TrackerRole 34 TorrentCountRole = Qt::UserRole + 1, 35 TorrentCountStringRole, 36 ActivityRole, 37 TrackerRole 37 38 }; 38 39 … … 99 100 boundingBox.setLeft (decorationRect.right () + hmargin); 100 101 101 QRect countRect = rect (option, index, TorrentCount Role);102 QRect countRect = rect (option, index, TorrentCountStringRole); 102 103 countRect = QStyle::alignedRect (Qt::LeftToRight, 103 104 Qt::AlignRight|Qt::AlignVCenter, … … 111 112 drawDecoration (painter, option, decorationRect, decoration (option2,index.data (Qt::DecorationRole))); 112 113 drawDisplay (painter, option, displayRect, index.data (Qt::DisplayRole).toString ()); 113 drawDisplay (painter, disabledOption, countRect, index.data (TorrentCount Role).toString ());114 drawDisplay (painter, disabledOption, countRect, index.data (TorrentCountStringRole).toString ()); 114 115 drawFocus (painter, option, displayRect|countRect); 115 116 } … … 133 134 size.setHeight (qMax (size.height (), myCombo->iconSize ().height () + 6)); 134 135 size.rwidth () += s->pixelMetric (QStyle::PM_FocusFrameHMargin, 0, myCombo); 135 size.rwidth () += rect (option,index,TorrentCount Role).width ();136 size.rwidth () += rect (option,index,TorrentCountStringRole).width (); 136 137 size.rwidth () += hmargin * 4; 137 138 return size; … … 146 147 QComboBox (parent) 147 148 { 149 } 150 151 int 152 FilterBarComboBox :: currentCount () const 153 { 154 int count = 0; 155 156 const QModelIndex modelIndex = model ()->index (currentIndex (), 0, rootModelIndex ()); 157 if (modelIndex.isValid ()) 158 count = modelIndex.data (TorrentCountRole).toInt (); 159 160 return count; 148 161 } 149 162 … … 186 199 187 200 // draw the count 188 QString text = modelIndex.data (TorrentCount Role).toString ();201 QString text = modelIndex.data (TorrentCountStringRole).toString (); 189 202 if (!text.isEmpty ()) 190 203 { … … 210 223 ****/ 211 224 212 QComboBox*225 FilterBarComboBox * 213 226 FilterBar :: createActivityCombo () 214 227 { 215 QComboBox * c = new FilterBarComboBox (this);228 FilterBarComboBox * c = new FilterBarComboBox (this); 216 229 FilterBarComboBoxDelegate * delegate = new FilterBarComboBoxDelegate (0, c); 217 230 c->setItemDelegate (delegate); … … 319 332 320 333 // update the "All" row 321 myTrackerModel->setData (myTrackerModel->index (0,0), getCountString (myTorrents.rowCount ()), TorrentCountRole); 334 myTrackerModel->setData (myTrackerModel->index (0,0), myTorrents.rowCount (), TorrentCountRole); 335 myTrackerModel->setData (myTrackerModel->index (0,0), getCountString (myTorrents.rowCount ()), TorrentCountStringRole); 322 336 323 337 // rows to update … … 326 340 const QString name = readableHostName (host); 327 341 QStandardItem * row = myTrackerModel->findItems (name).front (); 328 row->setData (getCountString (torrentsPerHost[name]), TorrentCountRole); 342 const int count = torrentsPerHost[name]; 343 row->setData (count, TorrentCountRole); 344 row->setData (getCountString (count), TorrentCountStringRole); 329 345 row->setData (favicons.findFromHost (host), Qt::DecorationRole); 330 346 } … … 359 375 // add the row 360 376 QStandardItem * row = new QStandardItem (favicons.findFromHost (host), name); 361 row->setData (getCountString (torrentsPerHost[host]), TorrentCountRole); 377 const int count = torrentsPerHost[host]; 378 row->setData (count, TorrentCountRole); 379 row->setData (getCountString (count), TorrentCountStringRole); 362 380 row->setData (favicons.findFromHost (host), Qt::DecorationRole); 363 381 row->setData (host, TrackerRole); … … 371 389 372 390 373 QComboBox*391 FilterBarComboBox * 374 392 FilterBar :: createTrackerCombo (QStandardItemModel * model) 375 393 { 376 QComboBox * c = new FilterBarComboBox (this);394 FilterBarComboBox * c = new FilterBarComboBox (this); 377 395 FilterBarComboBoxDelegate * delegate = new FilterBarComboBoxDelegate (0, c); 378 396 c->setItemDelegate (delegate); … … 380 398 QStandardItem * row = new QStandardItem (tr ("All")); 381 399 row->setData ("", TrackerRole); 382 row->setData (getCountString (myTorrents.rowCount ()), TorrentCountRole); 400 const int count = myTorrents.rowCount (); 401 row->setData (count, TorrentCountRole); 402 row->setData (getCountString (count), TorrentCountStringRole); 383 403 model->appendRow (row); 384 404 … … 572 592 QModelIndex index = model->index (row, 0); 573 593 const int mode = index.data (ActivityRole).toInt (); 574 model->setData (index, getCountString (torrentsPerMode[mode]), TorrentCountRole); 594 const int count = torrentsPerMode [mode]; 595 model->setData (index, count, TorrentCountRole); 596 model->setData (index, getCountString (count), TorrentCountStringRole); 575 597 } 576 598 577 599 refreshTrackers (); 600 refreshCountLabel (); 578 601 } 579 602 … … 588 611 { 589 612 const int visibleCount = myFilter.rowCount (); 590 const int torrentCount = visibleCount + myFilter.hiddenRowCount (); 591 592 if (visibleCount == torrentCount) 613 const int trackerCount = myTrackerCombo->currentCount (); 614 const int activityCount = myActivityCombo->currentCount (); 615 616 if ((visibleCount == activityCount) || (visibleCount == trackerCount)) 593 617 myCountLabel->setText (tr("Show:")); 594 618 else 595 myCountLabel->setText (tr("Show %Ln :", 0, visibleCount));596 } 619 myCountLabel->setText (tr("Show %Ln of:", 0, visibleCount)); 620 } -
trunk/qt/filterbar.h
r13927 r13937 54 54 public: 55 55 FilterBarComboBox (QWidget * parent = 0); 56 int currentCount () const; 56 57 57 58 protected: … … 69 70 70 71 private: 71 QComboBox * createTrackerCombo (QStandardItemModel * );72 QComboBox * createActivityCombo ();72 FilterBarComboBox * createTrackerCombo (QStandardItemModel * ); 73 FilterBarComboBox * createActivityCombo (); 73 74 void recountSoon (); 74 75 void refreshTrackers (); … … 79 80 TorrentModel& myTorrents; 80 81 TorrentFilter& myFilter; 81 QComboBox * myActivityCombo;82 QComboBox * myTrackerCombo;82 FilterBarComboBox * myActivityCombo; 83 FilterBarComboBox * myTrackerCombo; 83 84 QLabel * myCountLabel; 84 85 QStandardItemModel * myTrackerModel;
Note: See TracChangeset
for help on using the changeset viewer.