TorrentDelegateMin.cc
TorrentFilter.cc
TorrentModel.cc
+ TorrentView.cc
TrackerDelegate.cc
TrackerModel.cc
TrackerModelFilter.cc
TorrentDelegateMin.h
TorrentFilter.h
TorrentModel.h
+ TorrentView.h
TrackerDelegate.h
TrackerModel.h
TrackerModelFilter.h
QHBoxLayout * h = new QHBoxLayout (this);
h->setContentsMargins (3, 3, 3, 3);
- myCountLabel = new QLabel (this);
+ myCountLabel = new QLabel (tr ("Show:"), this);
h->addWidget (myCountLabel);
myActivityCombo = createActivityCombo ();
connect (&myPrefs, SIGNAL (changed (int)), this, SLOT (refreshPref (int)));
connect (myActivityCombo, SIGNAL (currentIndexChanged (int)), this, SLOT (onActivityIndexChanged (int)));
connect (myTrackerCombo, SIGNAL (currentIndexChanged (int)), this, SLOT (onTrackerIndexChanged (int)));
- connect (&myFilter, SIGNAL (rowsInserted (QModelIndex, int, int)), this, SLOT (refreshCountLabel ()));
- connect (&myFilter, SIGNAL (rowsRemoved (QModelIndex, int, int)), this, SLOT (refreshCountLabel ()));
connect (&myTorrents, SIGNAL (modelReset ()), this, SLOT (recountSoon ()));
connect (&myTorrents, SIGNAL (rowsInserted (QModelIndex, int, int)), this, SLOT (recountSoon ()));
connect (&myTorrents, SIGNAL (rowsRemoved (QModelIndex, int, int)), this, SLOT (recountSoon ()));
recountSoon ();
refreshTrackers ();
- refreshCountLabel ();
myIsBootstrapping = false;
// initialize our state
}
refreshTrackers ();
- refreshCountLabel ();
}
QString
{
return QString::fromLatin1 ("%L1").arg (n);
}
-
-void
-FilterBar::refreshCountLabel ()
-{
- const int visibleCount = myFilter.rowCount ();
- const int trackerCount = myTrackerCombo->currentCount ();
- const int activityCount = myActivityCombo->currentCount ();
-
- if ((visibleCount == activityCount) || (visibleCount == trackerCount))
- myCountLabel->setText (tr("Show:"));
- else
- myCountLabel->setText (tr("Show %Ln of:", 0, visibleCount));
-}
void recountSoon ();
void recount ();
void refreshPref (int key);
- void refreshCountLabel ();
void onActivityIndexChanged (int index);
void onTrackerIndexChanged (int index);
void onTextChanged (const QString&);
initStatusBar ();
ui.verticalLayout->insertWidget (0, myFilterBar = new FilterBar (myPrefs, myModel, myFilterModel));
+ connect (&myModel, SIGNAL (rowsInserted (QModelIndex, int, int)), SLOT (refreshTorrentViewHeader ()));
+ connect (&myModel, SIGNAL (rowsRemoved (QModelIndex, int, int)), SLOT (refreshTorrentViewHeader ()));
+ connect (&myFilterModel, SIGNAL (rowsInserted (QModelIndex, int, int)), SLOT (refreshTorrentViewHeader ()));
+ connect (&myFilterModel, SIGNAL (rowsRemoved (QModelIndex, int, int)), SLOT (refreshTorrentViewHeader ()));
+
QList<int> initKeys;
initKeys << Prefs::MAIN_WINDOW_X
<< Prefs::SHOW_TRAY_ICON
refreshTrayIconSoon ();
refreshStatusBar ();
refreshTitle ();
+ refreshTorrentViewHeader ();
}
MainWindow::~MainWindow ()
ui.statsLabel->setText (str);
}
+void
+MainWindow::refreshTorrentViewHeader ()
+{
+ const int totalCount = myModel.rowCount ();
+ const int visibleCount = myFilterModel.rowCount ();
+ if (visibleCount == totalCount)
+ ui.listView->setHeaderText (QString ());
+ else
+ ui.listView->setHeaderText (tr ("Showing %L1 of %Ln torrent(s)", 0, totalCount).arg (visibleCount));
+}
void
MainWindow::refreshActionSensitivitySoon ()
void refreshStatusBar ();
void refreshTrayIcon ();
void refreshTrayIconSoon ();
+ void refreshTorrentViewHeader ();
void openTorrent ();
void openURL ();
void newTorrent ();
<number>0</number>
</property>
<item>
- <widget class="QListView" name="listView">
+ <widget class="TorrentView" name="listView">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<extends>QToolButton</extends>
<header>IconToolButton.h</header>
</customwidget>
+ <customwidget>
+ <class>TorrentView</class>
+ <extends>QListView</extends>
+ <header>TorrentView.h</header>
+ </customwidget>
</customwidgets>
<resources>
<include location="application.qrc"/>
--- /dev/null
+/*
+ * This file Copyright (C) 2015 Mnemosyne LLC
+ *
+ * It may be used under the GNU GPL versions 2 or 3
+ * or any future license endorsed by Mnemosyne LLC.
+ *
+ * $Id$
+ */
+
+#include <QApplication>
+#include <QStyleOptionHeader>
+#include <QStylePainter>
+
+#include "TorrentView.h"
+
+class TorrentView::HeaderWidget: public QWidget
+{
+ public:
+ HeaderWidget (QWidget * parent):
+ QWidget (parent),
+ myText ()
+ {
+ setFont (qApp->font ("QMiniFont"));
+ }
+
+ void setText (const QString& text)
+ {
+ myText = text;
+ update ();
+ }
+
+ // QWidget
+ virtual QSize sizeHint () const
+ {
+ QStyleOptionHeader option;
+ option.rect = QRect (0, 0, 100, 100);
+
+ const QRect labelRect = style ()->subElementRect (QStyle::SE_HeaderLabel, &option, this);
+
+ return QSize (100, fontMetrics ().height () + (option.rect.height () - labelRect.height ()));
+ }
+
+ protected:
+ // QWidget
+ virtual void paintEvent (QPaintEvent * /*event*/)
+ {
+ QStyleOptionHeader option;
+ option.initFrom (this);
+ option.state = QStyle::State_Enabled;
+ option.position = QStyleOptionHeader::OnlyOneSection;
+
+ QStylePainter painter (this);
+ painter.drawControl (QStyle::CE_HeaderSection, option);
+
+ option.rect = style ()->subElementRect (QStyle::SE_HeaderLabel, &option, this);
+ painter.drawItemText (option.rect, Qt::AlignCenter, option.palette, true, myText, QPalette::ButtonText);
+ }
+
+ private:
+ QString myText;
+};
+
+TorrentView::TorrentView (QWidget * parent):
+ QListView (parent),
+ myHeaderWidget (new HeaderWidget (this))
+{
+}
+
+void
+TorrentView::setHeaderText (const QString& text)
+{
+ const bool headerVisible = !text.isEmpty ();
+
+ myHeaderWidget->setText (text);
+ myHeaderWidget->setVisible (headerVisible);
+
+ if (headerVisible)
+ adjustHeaderPosition ();
+
+ setViewportMargins (0, headerVisible ? myHeaderWidget->height () : 0, 0, 0);
+}
+
+void
+TorrentView::resizeEvent (QResizeEvent * event)
+{
+ QListView::resizeEvent (event);
+
+ if (myHeaderWidget->isVisible ())
+ adjustHeaderPosition ();
+}
+
+void
+TorrentView::adjustHeaderPosition ()
+{
+ QRect headerWidgetRect = contentsRect ();
+ headerWidgetRect.setWidth (viewport ()->width ());
+ headerWidgetRect.setHeight (myHeaderWidget->sizeHint ().height ());
+ myHeaderWidget->setGeometry (headerWidgetRect);
+}
--- /dev/null
+/*
+ * This file Copyright (C) 2015 Mnemosyne LLC
+ *
+ * It may be used under the GNU GPL versions 2 or 3
+ * or any future license endorsed by Mnemosyne LLC.
+ *
+ * $Id$
+ */
+
+#ifndef QTR_TORRENT_VIEW_H
+#define QTR_TORRENT_VIEW_H
+
+#include <QListView>
+
+class TorrentView: public QListView
+{
+ Q_OBJECT
+
+ public:
+ TorrentView (QWidget * parent = nullptr);
+
+ public slots:
+ void setHeaderText (const QString& text);
+
+ protected:
+ virtual void resizeEvent (QResizeEvent * event);
+
+ private:
+ class HeaderWidget;
+
+ private:
+ void adjustHeaderPosition ();
+
+ private:
+ HeaderWidget * const myHeaderWidget;
+};
+
+#endif // QTR_TORRENT_VIEW_H
TorrentDelegateMin.cc \
TorrentFilter.cc \
TorrentModel.cc \
+ TorrentView.cc \
TrackerDelegate.cc \
TrackerModel.cc \
TrackerModelFilter.cc \
<context>
<name>Application</name>
<message>
- <location filename="../Application.cc" line="+300"/>
+ <location filename="../Application.cc" line="+304"/>
<source><b>Transmission is a file sharing program.</b></source>
<translation type="unfinished"></translation>
</message>
<context>
<name>FileTreeItem</name>
<message>
- <location filename="../FileTreeItem.cc" line="+256"/>
- <location filename="../FileTreeView.cc" line="+110"/>
- <location line="+263"/>
+ <location filename="../FileTreeItem.cc" line="+271"/>
+ <location filename="../FileTreeView.cc" line="+105"/>
+ <location line="+257"/>
<source>Low</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+1"/>
- <location filename="../FileTreeView.cc" line="-262"/>
- <location line="+260"/>
+ <location filename="../FileTreeView.cc" line="-256"/>
+ <location line="+254"/>
<source>High</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+1"/>
- <location filename="../FileTreeView.cc" line="-261"/>
- <location line="+262"/>
+ <location filename="../FileTreeView.cc" line="-255"/>
+ <location line="+256"/>
<source>Normal</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+1"/>
- <location filename="../FileTreeView.cc" line="-261"/>
+ <location filename="../FileTreeView.cc" line="-255"/>
<source>Mixed</source>
<translation type="unfinished"></translation>
</message>
<context>
<name>FileTreeView</name>
<message>
- <location filename="../FileTreeView.cc" line="+253"/>
- <source>Check selected</source>
+ <location filename="../FileTreeView.cc" line="+247"/>
+ <source>Check Selected</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+1"/>
- <source>Uncheck selected</source>
+ <source>Uncheck Selected</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+1"/>
- <source>Only check selected</source>
+ <source>Only Check Selected</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Finished</source>
<translation type="unfinished"></translation>
</message>
- <message numerus="yes">
- <location line="+326"/>
- <source>Show %Ln of:</source>
- <translation type="unfinished">
- <numerusform></numerusform>
- <numerusform></numerusform>
- </translation>
- </message>
<message>
- <location line="-322"/>
+ <location line="+4"/>
<source>Verifying</source>
<translation type="unfinished"></translation>
</message>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+316"/>
+ <location line="+141"/>
<source>Show:</source>
<translation type="unfinished"></translation>
</message>
</message>
<message>
<location line="-161"/>
- <location filename="../MainWindow.cc" line="+1442"/>
<source>Queue</source>
<translation type="unfinished"></translation>
</message>
<translation type="unfinished"></translation>
</message>
<message>
- <location filename="../MainWindow.cc" line="-1015"/>
+ <location filename="../MainWindow.cc" line="+433"/>
<source>Limit Download Speed</source>
<translation type="unfinished"></translation>
</message>
</message>
<message>
<location line="+6"/>
- <location line="+615"/>
+ <location line="+641"/>
<location line="+8"/>
<source>Limited at %1</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="-573"/>
+ <location line="-599"/>
<source>Limit Upload Speed</source>
<translation type="unfinished"></translation>
</message>
</message>
<message>
<location line="+6"/>
- <location line="+601"/>
+ <location line="+627"/>
<source>Stop at Ratio (%1)</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="-378"/>
+ <location line="-393"/>
<source> - %1:%2</source>
<extracomment>Second (optional) part of main window title "Transmission - host:port" (added when connected to remote session); notice that leading space (before the dash) is included here</extracomment>
<translation type="unfinished"></translation>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+406"/>
+ <location line="+421"/>
<source>Torrent Files (*.torrent);;All Files (*.*)</source>
<translation type="unfinished"></translation>
</message>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="-885"/>
+ <location line="-917"/>
<source>Speed Limits</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+431"/>
+ <location line="+448"/>
<source>Network Error</source>
<translation type="unfinished"></translation>
</message>
<message>
- <location line="+418"/>
+ <location line="+433"/>
<source>Click to disable Temporary Speed Limits
(%1 down, %2 up)</source>
<translation type="unfinished"></translation>
</translation>
</message>
<message numerus="yes">
- <location line="+6"/>
+ <location line="-499"/>
+ <source>Showing %L1 of %Ln torrent(s)</source>
+ <translation type="unfinished">
+ <numerusform>Showing %L1 of %Ln torrent</numerusform>
+ <numerusform>Showing %L1 of %Ln torrents</numerusform>
+ </translation>
+ </message>
+ <message numerus="yes">
+ <location line="+505"/>
<source>Delete these %Ln torrent(s)' downloaded files?</source>
<translation>
<numerusform>Delete this %Ln torrent's downloaded files?</numerusform>