Compare commits
7 Commits
b76bd73056
...
aedcb202f1
Author | SHA1 | Date |
---|---|---|
Cœur | aedcb202f1 | |
Cœur | e9bc4bea4d | |
Cœur | 5a7dd36f12 | |
Christian Muehlhaeuser | db713ee6fa | |
Pooyan Khanjankhani | 821a6816ef | |
Dzmitry Neviadomski | ef18816b7f | |
Dzmitry Neviadomski | 0e25584e78 |
|
@ -41,7 +41,7 @@ On macOS, Transmission is usually built with Xcode. Everywhere else, it's CMake
|
||||||
- Prefer `enum class` over `enum`
|
- Prefer `enum class` over `enum`
|
||||||
- Prefer new-style headers, e.g. `<cstring>` over `<string.h>`
|
- Prefer new-style headers, e.g. `<cstring>` over `<string.h>`
|
||||||
- Fix any warnings in new code before merging
|
- Fix any warnings in new code before merging
|
||||||
- Run `./code-style.sh` on your code to ensure the whole codebase has consistent indentation.
|
- Run `./code_style.sh` on your code to ensure the whole codebase has consistent indentation.
|
||||||
|
|
||||||
Note that Transmission existed in C for over a decade and those idioms don't change overnight. "Follow the C++ core guidelines" can be difficult when working with older code, and the maintainers will understand that when reviewing your PRs. :smiley:
|
Note that Transmission existed in C for over a decade and those idioms don't change overnight. "Follow the C++ core guidelines" can be difficult when working with older code, and the maintainers will understand that when reviewing your PRs. :smiley:
|
||||||
|
|
||||||
|
|
|
@ -404,7 +404,7 @@ struct tr_socket_address
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
class std::hash<tr_socket_address>
|
struct std::hash<tr_socket_address>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::size_t operator()(tr_socket_address const& socket_address) const noexcept
|
std::size_t operator()(tr_socket_address const& socket_address) const noexcept
|
||||||
|
|
|
@ -75,6 +75,26 @@ void TorrentFilter::refilter()
|
||||||
****
|
****
|
||||||
***/
|
***/
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
int compareState(Torrent const* left, Torrent const* right)
|
||||||
|
{
|
||||||
|
if (auto const val = tr_compare_3way(left->hasError(), right->hasError()); val != 0)
|
||||||
|
{
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
if (auto const val = tr_compare_3way(left->isFinished(), right->isFinished()); val != 0)
|
||||||
|
{
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
if (auto const val = -tr_compare_3way(left->isPaused(), right->isPaused()); val != 0)
|
||||||
|
{
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
return -tr_compare_3way(!left->hasMetadata(), !right->hasMetadata());
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
bool TorrentFilter::lessThan(QModelIndex const& left, QModelIndex const& right) const
|
bool TorrentFilter::lessThan(QModelIndex const& left, QModelIndex const& right) const
|
||||||
{
|
{
|
||||||
int val = 0;
|
int val = 0;
|
||||||
|
@ -84,37 +104,30 @@ bool TorrentFilter::lessThan(QModelIndex const& left, QModelIndex const& right)
|
||||||
switch (prefs_.get<SortMode>(Prefs::SORT_MODE).mode())
|
switch (prefs_.get<SortMode>(Prefs::SORT_MODE).mode())
|
||||||
{
|
{
|
||||||
case SortMode::SORT_BY_QUEUE:
|
case SortMode::SORT_BY_QUEUE:
|
||||||
if (val == 0)
|
val = -tr_compare_3way(a->queuePosition(), b->queuePosition());
|
||||||
{
|
|
||||||
val = -tr_compare_3way(a->queuePosition(), b->queuePosition());
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SortMode::SORT_BY_SIZE:
|
case SortMode::SORT_BY_SIZE:
|
||||||
if (val == 0)
|
val = tr_compare_3way(a->sizeWhenDone(), b->sizeWhenDone());
|
||||||
{
|
|
||||||
val = tr_compare_3way(a->sizeWhenDone(), b->sizeWhenDone());
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SortMode::SORT_BY_AGE:
|
case SortMode::SORT_BY_AGE:
|
||||||
if (val == 0)
|
val = tr_compare_3way(a->dateAdded(), b->dateAdded());
|
||||||
{
|
|
||||||
val = tr_compare_3way(a->dateAdded(), b->dateAdded());
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SortMode::SORT_BY_ID:
|
case SortMode::SORT_BY_ID:
|
||||||
if (val == 0)
|
val = tr_compare_3way(a->id(), b->id());
|
||||||
{
|
|
||||||
val = tr_compare_3way(a->id(), b->id());
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SortMode::SORT_BY_ETA:
|
||||||
|
val = a->compareETA(*b);
|
||||||
|
|
||||||
|
[[fallthrough]];
|
||||||
|
|
||||||
case SortMode::SORT_BY_ACTIVITY:
|
case SortMode::SORT_BY_ACTIVITY:
|
||||||
if (val == 0)
|
if (val == 0)
|
||||||
{
|
{
|
||||||
|
@ -124,8 +137,8 @@ bool TorrentFilter::lessThan(QModelIndex const& left, QModelIndex const& right)
|
||||||
if (val == 0)
|
if (val == 0)
|
||||||
{
|
{
|
||||||
val = tr_compare_3way(
|
val = tr_compare_3way(
|
||||||
a->peersWeAreUploadingTo() + a->webseedsWeAreDownloadingFrom(),
|
a->peersWeAreUploadingTo() + a->peersWeAreDownloadingFrom() + a->webseedsWeAreDownloadingFrom(),
|
||||||
b->peersWeAreUploadingTo() + b->webseedsWeAreDownloadingFrom());
|
b->peersWeAreUploadingTo() + b->peersWeAreDownloadingFrom() + b->webseedsWeAreDownloadingFrom());
|
||||||
}
|
}
|
||||||
|
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
|
@ -133,22 +146,7 @@ bool TorrentFilter::lessThan(QModelIndex const& left, QModelIndex const& right)
|
||||||
case SortMode::SORT_BY_STATE:
|
case SortMode::SORT_BY_STATE:
|
||||||
if (val == 0)
|
if (val == 0)
|
||||||
{
|
{
|
||||||
val = -tr_compare_3way(a->isPaused(), b->isPaused());
|
val = compareState(a, b);
|
||||||
}
|
|
||||||
|
|
||||||
if (val == 0)
|
|
||||||
{
|
|
||||||
val = tr_compare_3way(a->getActivity(), b->getActivity());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (val == 0)
|
|
||||||
{
|
|
||||||
val = -tr_compare_3way(a->queuePosition(), b->queuePosition());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (val == 0)
|
|
||||||
{
|
|
||||||
val = tr_compare_3way(a->hasError(), b->hasError());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
|
@ -161,12 +159,12 @@ bool TorrentFilter::lessThan(QModelIndex const& left, QModelIndex const& right)
|
||||||
|
|
||||||
if (val == 0)
|
if (val == 0)
|
||||||
{
|
{
|
||||||
val = tr_compare_3way(a->percentComplete(), b->percentComplete());
|
val = a->compareSeedProgress(*b);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (val == 0)
|
if (val == 0)
|
||||||
{
|
{
|
||||||
val = a->compareSeedProgress(*b);
|
val = tr_compare_3way(a->getActivity(), b->getActivity());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (val == 0)
|
if (val == 0)
|
||||||
|
@ -174,9 +172,10 @@ bool TorrentFilter::lessThan(QModelIndex const& left, QModelIndex const& right)
|
||||||
val = -tr_compare_3way(a->queuePosition(), b->queuePosition());
|
val = -tr_compare_3way(a->queuePosition(), b->queuePosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
[[fallthrough]];
|
break;
|
||||||
|
|
||||||
case SortMode::SORT_BY_RATIO:
|
case SortMode::SORT_BY_RATIO:
|
||||||
|
val = -tr_compare_3way(!a->hasMetadata(), !b->hasMetadata());
|
||||||
if (val == 0)
|
if (val == 0)
|
||||||
{
|
{
|
||||||
val = a->compareRatio(*b);
|
val = a->compareRatio(*b);
|
||||||
|
@ -184,14 +183,12 @@ bool TorrentFilter::lessThan(QModelIndex const& left, QModelIndex const& right)
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SortMode::SORT_BY_ETA:
|
case SortMode::SORT_BY_NAME:
|
||||||
if (val == 0)
|
// nothing to do: sorting by name is done after the switch
|
||||||
{
|
|
||||||
val = a->compareETA(*b);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// TODO(coeur): SORT_BY_TRACKER
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,7 +150,7 @@ Get a file list for the current torrent(s)
|
||||||
.It Fl g Fl -get Ar all | file-index | files
|
.It Fl g Fl -get Ar all | file-index | files
|
||||||
Mark file(s) for download.
|
Mark file(s) for download.
|
||||||
.Ar all
|
.Ar all
|
||||||
marks all all of the torrent's files for downloading,
|
marks all of the torrent's files for downloading,
|
||||||
.Ar file-index
|
.Ar file-index
|
||||||
adds a single file to the download list, and
|
adds a single file to the download list, and
|
||||||
.Ar files
|
.Ar files
|
||||||
|
|
Loading…
Reference in New Issue