Changeset 13927
- Timestamp:
- Feb 1, 2013, 8:58:55 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gtk/filter.c
r13732 r13927 792 792 GtkWidget * tracker; 793 793 GtkWidget * entry; 794 GtkWidget * show_lb; 794 795 GtkTreeModel * filter_model; 795 796 int active_activity_type; … … 855 856 } 856 857 858 /*** 859 **** 860 ***/ 861 862 static void 863 update_count_label (struct filter_data * data) 864 { 865 char buf[512]; 866 GtkTreeModel * tmodel = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (data->filter_model)); 867 const int torrentCount = gtk_tree_model_iter_n_children (tmodel, NULL); 868 const int visibleCount = gtk_tree_model_iter_n_children (data->filter_model, NULL); 869 870 /* set the text */ 871 if (visibleCount == torrentCount) 872 g_snprintf (buf, sizeof(buf), _("_Show:")); 873 else 874 g_snprintf (buf, sizeof(buf), _("_Show %'d:"), visibleCount); 875 gtk_label_set_markup_with_mnemonic (GTK_LABEL (data->show_lb), buf); 876 } 877 878 static void 879 on_filter_model_row_inserted (GtkTreeModel * tree_model UNUSED, 880 GtkTreePath * path UNUSED, 881 GtkTreeIter * iter UNUSED, 882 gpointer data) 883 { 884 update_count_label (data); 885 } 886 887 static void 888 on_filter_model_row_deleted (GtkTreeModel * tree_model UNUSED, 889 GtkTreePath * path UNUSED, 890 gpointer data UNUSED) 891 { 892 update_count_label (data); 893 } 894 895 /*** 896 **** 897 ***/ 898 857 899 GtkWidget * 858 900 gtr_filter_bar_new (tr_session * session, GtkTreeModel * tmodel, GtkTreeModel ** filter_model) … … 865 907 GtkWidget * tracker; 866 908 GtkBox * h_box; 867 const char * str;868 909 struct filter_data * data; 869 910 … … 875 916 876 917 data = g_new0 (struct filter_data, 1); 918 data->show_lb = gtk_label_new (NULL); 877 919 data->activity = activity = activity_combo_box_new (tmodel); 878 920 data->tracker = tracker = tracker_combo_box_new (tmodel); 879 921 data->filter_model = gtk_tree_model_filter_new (tmodel, NULL); 922 g_signal_connect (data->filter_model, "row-deleted", G_CALLBACK(on_filter_model_row_deleted), data); 923 g_signal_connect (data->filter_model, "row-inserted", G_CALLBACK(on_filter_model_row_inserted), data); 880 924 881 925 g_object_set (G_OBJECT (data->tracker), "width-request", 170, NULL); … … 893 937 894 938 /* add the activity combobox */ 895 str = _("_Show:");896 939 w = activity; 897 l = gtk_label_new (NULL); 898 gtk_label_set_markup_with_mnemonic (GTK_LABEL (l), str); 940 l = data->show_lb; 899 941 gtk_label_set_mnemonic_widget (GTK_LABEL (l), w); 900 942 gtk_box_pack_start (h_box, l, FALSE, FALSE, 0); … … 925 967 926 968 *filter_model = data->filter_model; 969 update_count_label (data); 927 970 return h; 928 971 } -
trunk/gtk/tr-window.c
r13897 r13927 57 57 GtkLabel * freespace_lb; 58 58 GtkWidget * freespace_icon; 59 GtkLabel * count_lb;60 59 GtkWidget * alt_speed_image; 61 60 GtkWidget * alt_speed_button; … … 717 716 sibling = w; 718 717 719 /* torrent count */720 w = gtk_label_new ("N Torrents");721 p->count_lb = GTK_LABEL (w);722 gtk_label_set_single_line_mode (p->count_lb, TRUE);723 gtk_grid_attach_next_to (grid, w, sibling, GTK_POS_RIGHT, 1, 1);724 sibling = w;725 726 718 /* freespace */ 719 w = gtk_image_new_from_stock (GTK_STOCK_HARDDISK, GTK_ICON_SIZE_MENU); 720 p->freespace_icon = w; 721 g_object_set (G_OBJECT(w), "margin-left", GUI_PAD, NULL); 722 gtk_grid_attach_next_to (grid, w, sibling, GTK_POS_RIGHT, 1, 1); 723 sibling = w; 727 724 w = gtk_label_new (NULL); 728 725 g_object_set (G_OBJECT(w), "margin-left", GUI_PAD_BIG*2, NULL); 729 726 p->freespace_lb = GTK_LABEL (w); 730 727 gtk_label_set_single_line_mode (p->freespace_lb, TRUE); 731 gtk_grid_attach_next_to (grid, w, sibling, GTK_POS_RIGHT, 1, 1);732 sibling = w;733 w = gtk_image_new_from_stock (GTK_STOCK_HARDDISK, GTK_ICON_SIZE_MENU);734 p->freespace_icon = w;735 g_object_set (G_OBJECT(w), "margin-left", GUI_PAD, NULL);736 728 gtk_grid_attach_next_to (grid, w, sibling, GTK_POS_RIGHT, 1, 1); 737 729 sibling = w; … … 831 823 832 824 static void 833 updateTorrentCount (PrivateData * p)834 {835 bool visible = false;836 837 g_return_if_fail (p != NULL);838 839 if (p->core != NULL)840 {841 const int torrentCount = gtk_tree_model_iter_n_children (gtr_core_model (p->core), NULL);842 const int visibleCount = gtk_tree_model_iter_n_children (p->filter_model, NULL);843 844 visible = torrentCount > 0;845 846 if (visible)847 {848 char countStr[512];849 850 if (torrentCount != visibleCount)851 g_snprintf (countStr, sizeof (countStr),852 ngettext ("%1$'d of %2$'d Torrent",853 "%1$'d of %2$'d Torrents",854 torrentCount),855 visibleCount, torrentCount);856 else857 g_snprintf (countStr, sizeof (countStr),858 ngettext ("%'d Torrent", "%'d Torrents", torrentCount),859 torrentCount);860 861 gtr_label_set_text (p->count_lb, countStr);862 }863 }864 865 gtk_widget_set_visible (GTK_WIDGET(p->count_lb), visible);866 }867 868 static void869 825 updateFreeSpace (PrivateData * p) 870 826 { … … 888 844 char * tip; 889 845 char sizeStr[32]; 846 890 847 tr_strlsize (sizeStr, n, sizeof(sizeStr)); 891 848 gtk_label_set_text (p->freespace_lb, sizeStr); 849 892 850 tip = tr_strdup_printf (_("Download folder \"%1$s\" has %2$s free"), downloadDir, sizeStr); 893 851 gtk_widget_set_tooltip_text (w, tip); … … 990 948 { 991 949 updateSpeeds (p); 992 updateTorrentCount (p);993 950 updateStats (p); 994 951 updateFreeSpace (p); -
trunk/qt/filterbar.cc
r13869 r13927 407 407 const int hmargin = qMax (int (HIG::PAD), style ()->pixelMetric (QStyle::PM_LayoutHorizontalSpacing)); 408 408 409 myCountLabel = new QLabel; 409 410 h->setSpacing (0); 410 411 h->setContentsMargins (2, 2, 2, 2); 411 h->addWidget ( new QLabel (tr ("Show:"), this));412 h->addWidget (myCountLabel); 412 413 h->addSpacing (hmargin); 413 414 … … 438 439 connect (myActivityCombo, SIGNAL (currentIndexChanged (int)), this, SLOT (onActivityIndexChanged (int))); 439 440 connect (myTrackerCombo, SIGNAL (currentIndexChanged (int)), this, SLOT (onTrackerIndexChanged (int))); 441 connect (&myFilter, SIGNAL (rowsInserted (const QModelIndex&,int,int)), this, SLOT (refreshCountLabel ())); 442 connect (&myFilter, SIGNAL (rowsRemoved (const QModelIndex&,int,int)), this, SLOT (refreshCountLabel ())); 440 443 connect (&myTorrents, SIGNAL (modelReset ()), this, SLOT (onTorrentModelReset ())); 441 444 connect (&myTorrents, SIGNAL (rowsInserted (const QModelIndex&,int,int)), this, SLOT (onTorrentModelRowsInserted (const QModelIndex&,int,int))); … … 446 449 recountSoon (); 447 450 refreshTrackers (); 451 refreshCountLabel (); 448 452 myIsBootstrapping = false; 449 453 … … 579 583 return QString ("%L1").arg (n); 580 584 } 585 586 void 587 FilterBar :: refreshCountLabel () 588 { 589 const int visibleCount = myFilter.rowCount (); 590 const int torrentCount = visibleCount + myFilter.hiddenRowCount (); 591 592 if (visibleCount == torrentCount) 593 myCountLabel->setText (tr("Show:")); 594 else 595 myCountLabel->setText (tr("Show %Ln:", 0, visibleCount)); 596 } -
trunk/qt/filterbar.h
r13869 r13927 18 18 #include <QWidget> 19 19 20 class QLabel; 20 21 class QLineEdit; 21 22 class QPaintEvent; … … 80 81 QComboBox * myActivityCombo; 81 82 QComboBox * myTrackerCombo; 83 QLabel * myCountLabel; 82 84 QStandardItemModel * myTrackerModel; 83 85 QTimer * myRecountTimer; … … 88 90 void recount (); 89 91 void refreshPref (int key); 92 void refreshCountLabel (); 90 93 void onActivityIndexChanged (int index); 91 94 void onTrackerIndexChanged (int index); -
trunk/qt/mainwin.cc
r13897 r13927 203 203 connect (ui.action_DeselectAll, SIGNAL (triggered ()), ui.listView, SLOT (clearSelection ())); 204 204 205 connect (&myFilterModel, SIGNAL (rowsInserted (const QModelIndex&,int,int)), this, SLOT (refreshVisibleCount ()));206 connect (&myFilterModel, SIGNAL (rowsRemoved (const QModelIndex&,int,int)), this, SLOT (refreshVisibleCount ()));207 205 connect (&myFilterModel, SIGNAL (rowsInserted (const QModelIndex&,int,int)), this, SLOT (refreshActionSensitivitySoon ())); 208 206 connect (&myFilterModel, SIGNAL (rowsRemoved (const QModelIndex&,int,int)), this, SLOT (refreshActionSensitivitySoon ())); … … 308 306 refreshFreeSpace (); 309 307 refreshTitle (); 310 refreshVisibleCount ();311 308 } 312 309 … … 329 326 { 330 327 refreshTitle (); 331 refreshVisibleCount ();332 328 refreshActionSensitivitySoon (); 333 329 refreshStatusBar (); … … 396 392 h->addStretch (1); 397 393 398 l = myVisibleCountLabel = new QLabel (this); 394 l = myFreeSpaceIconLabel = new QLabel (this); 395 l->setPixmap (getStockIcon ("drive-harddisk", QStyle::SP_DriveHDIcon).pixmap (smallIconSize)); 399 396 h->addWidget (l); 400 401 h->addSpacing (HIG::PAD_BIG);402 403 397 l = myFreeSpaceTextLabel = new QLabel (this); 404 398 const int minimumFreeSpaceWidth = l->fontMetrics ().width (Formatter::sizeToString (1024 * 1024)); 405 399 l->setMinimumWidth (minimumFreeSpaceWidth); 406 h->addWidget (l);407 l = myFreeSpaceIconLabel = new QLabel (this);408 l->setPixmap (getStockIcon ("drive-harddisk", QStyle::SP_DriveHDIcon).pixmap (smallIconSize));409 400 h->addWidget (l); 410 401 … … 729 720 730 721 void 731 TrMainWindow :: refreshVisibleCount ()732 {733 const int visibleCount (myFilterModel.rowCount ());734 const int totalCount (visibleCount + myFilterModel.hiddenRowCount ());735 QString str;736 if (visibleCount == totalCount)737 str = tr ("%Ln Torrent (s)", 0, totalCount);738 else739 str = tr ("%L1 of %Ln Torrent (s)", 0, totalCount).arg (visibleCount);740 myVisibleCountLabel->setText (str);741 myVisibleCountLabel->setVisible (totalCount > 0);742 }743 744 void745 722 TrMainWindow :: refreshFreeSpace () 746 723 { … … 749 726 if (bytes >= 0) 750 727 { 751 const QString text= Formatter::sizeToString (bytes);728 const QString sizeStr = Formatter::sizeToString (bytes); 752 729 753 730 const QString tip = tr ("Download folder \"%1\" has %2 free") 754 731 .arg (myPrefs.getString (Prefs::DOWNLOAD_DIR)) 755 .arg ( text);756 757 myFreeSpaceTextLabel->setText ( text);732 .arg (sizeStr); 733 734 myFreeSpaceTextLabel->setText (sizeStr); 758 735 myFreeSpaceTextLabel->setToolTip (tip); 759 736 myFreeSpaceIconLabel->setToolTip (tip); -
trunk/qt/mainwin.h
r13886 r13927 105 105 void showSessionRatio (); 106 106 void showSessionTransfer (); 107 void refreshVisibleCount ();108 107 void refreshFreeSpace (); 109 108 void refreshTitle (); … … 156 155 QAction * myAltSpeedAction; 157 156 QPushButton * myOptionsButton; 158 QLabel * myVisibleCountLabel;159 157 QPushButton * myStatsModeButton; 160 158 QLabel * myStatsLabel;
Note: See TracChangeset
for help on using the changeset viewer.