Browse Source

Fix label filter. Closes #3429.

adaptive-webui-19844
Vladimir Golovnev (Glassez) 10 years ago
parent
commit
d475ab3881
  1. 8
      src/core/torrentfilter.cpp
  2. 15
      src/gui/transferlistfilterswidget.cpp
  3. 11
      src/gui/transferlistwidget.cpp
  4. 1
      src/gui/transferlistwidget.h

8
src/core/torrentfilter.cpp

@ -107,7 +107,10 @@ bool TorrentFilter::setHashSet(const QStringSet &hashSet) @@ -107,7 +107,10 @@ bool TorrentFilter::setHashSet(const QStringSet &hashSet)
bool TorrentFilter::setLabel(const QString &label)
{
if (m_label != label) {
// QString::operator==() doesn't distinguish between empty and null strings.
if ((m_label != label)
|| (m_label.isNull() && !label.isNull())
|| (!m_label.isNull() && label.isNull())) {
m_label = label;
return true;
}
@ -154,6 +157,7 @@ bool TorrentFilter::matchHash(BitTorrent::TorrentHandle *const torrent) const @@ -154,6 +157,7 @@ bool TorrentFilter::matchHash(BitTorrent::TorrentHandle *const torrent) const
bool TorrentFilter::matchLabel(BitTorrent::TorrentHandle *const torrent) const
{
if (m_label == AnyLabel) return true;
if (m_label.isNull()) return true;
else if (m_label.isEmpty()) return torrent->label().isEmpty();
else return (torrent->label() == m_label);
}

15
src/gui/transferlistfilterswidget.cpp

@ -375,16 +375,7 @@ void LabelFiltersList::showMenu(QPoint) @@ -375,16 +375,7 @@ void LabelFiltersList::showMenu(QPoint)
void LabelFiltersList::applyFilter(int row)
{
switch (row) {
case 0:
transferList->applyLabelFilterAll();
break;
case 1:
transferList->applyLabelFilter(QString());
break;
default:
transferList->applyLabelFilter(labelFromRow(row));
}
transferList->applyLabelFilter(labelFromRow(row));
}
void LabelFiltersList::handleNewTorrent(BitTorrent::TorrentHandle *const torrent)
@ -407,7 +398,9 @@ void LabelFiltersList::torrentAboutToBeDeleted(BitTorrent::TorrentHandle *const @@ -407,7 +398,9 @@ void LabelFiltersList::torrentAboutToBeDeleted(BitTorrent::TorrentHandle *const
QString LabelFiltersList::labelFromRow(int row) const
{
Q_ASSERT(row > 1);
if (row == 0) return QString(); // All
if (row == 1) return QLatin1String(""); // Unlabeled
const QString &label = item(row)->text();
QStringList parts = label.split(" ");
Q_ASSERT(parts.size() >= 2);

11
src/gui/transferlistwidget.cpp

@ -843,15 +843,12 @@ void TransferListWidget::currentChanged(const QModelIndex& current, const QModel @@ -843,15 +843,12 @@ void TransferListWidget::currentChanged(const QModelIndex& current, const QModel
emit currentTorrentChanged(torrent);
}
void TransferListWidget::applyLabelFilterAll()
{
nameFilterModel->disableLabelFilter();
}
void TransferListWidget::applyLabelFilter(QString label)
{
qDebug("Applying Label filter: %s", qPrintable(label));
nameFilterModel->setLabelFilter(label);
if (label.isNull())
nameFilterModel->disableLabelFilter();
else
nameFilterModel->setLabelFilter(label);
}
void TransferListWidget::applyTrackerFilterAll()

1
src/gui/transferlistwidget.h

@ -86,7 +86,6 @@ public slots: @@ -86,7 +86,6 @@ public slots:
void displayDLHoSMenu(const QPoint&);
void applyNameFilter(const QString& name);
void applyStatusFilter(int f);
void applyLabelFilterAll();
void applyLabelFilter(QString label);
void applyTrackerFilterAll();
void applyTrackerFilter(const QStringList &hashes);

Loading…
Cancel
Save