Browse Source

Replace a series of `if()` by `switch()`

adaptive-webui-19844
Chocobo1 5 years ago
parent
commit
bb73fa5dbe
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 12
      src/gui/transferlistfilterswidget.cpp
  2. 2
      src/gui/transferlistfilterswidget.h

12
src/gui/transferlistfilterswidget.cpp

@ -583,17 +583,19 @@ QString TrackerFiltersList::getHost(const QString &tracker) const
return longHost.mid(index + 1); return longHost.mid(index + 1);
} }
QStringList TrackerFiltersList::getHashes(int row) QStringList TrackerFiltersList::getHashes(const int row) const
{ {
if (row == 1) switch (row) {
case 1:
return m_trackers.value(""); return m_trackers.value("");
if (row == 2) case 2:
return m_errors.keys(); return m_errors.keys();
if (row == 3) case 3:
return m_warnings.keys(); return m_warnings.keys();
default:
return m_trackers.value(trackerFromRow(row)); return m_trackers.value(trackerFromRow(row));
} }
}
TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferListWidget *transferList, const bool downloadFavicon) TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferListWidget *transferList, const bool downloadFavicon)
: QFrame(parent) : QFrame(parent)

2
src/gui/transferlistfilterswidget.h

@ -126,7 +126,7 @@ private:
QString trackerFromRow(int row) const; QString trackerFromRow(int row) const;
int rowFromTracker(const QString &tracker) const; int rowFromTracker(const QString &tracker) const;
QString getHost(const QString &tracker) const; QString getHost(const QString &tracker) const;
QStringList getHashes(int row); QStringList getHashes(int row) const;
void downloadFavicon(const QString &url); void downloadFavicon(const QString &url);
QHash<QString, QStringList> m_trackers; QHash<QString, QStringList> m_trackers;

Loading…
Cancel
Save