-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement search filters. Partially closes #972 #3989
Conversation
Demonoid can eventually make use of this function, since it does search in description too. |
Can you please also add screenshot of how it looks with current code at the head's message? |
I made small review for you. This is mostly style though |
int i = 0; | ||
while(val >= 1024. && i < 4) { | ||
val /= 1024.; | ||
while(rawVal >= 1024. && i < 4) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while (
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Placing each condition in the parentheses improves the readability of the code, IMO.
while ((rawVal >= 1024.) && (i < 4))
Thanks to all of you for the edits and suggestions. It seems to me that rebasing commits from PR #3832 on top of this one is easier than vice-versa. |
Yes, please. (Screenshot moved into the top post) |
@@ -47,6 +47,22 @@ namespace Utils | |||
{ | |||
namespace Misc | |||
{ | |||
// use Binary prefix standards from IEC 60027-2 | |||
// see http://en.wikipedia.org/wiki/Kilobyte | |||
enum class SizeUnit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, since you began to use enum class, you can even put it outside Utils::Misc namespace (Utils child namespaces are intended for the functions - that was the idea).
It will be fine. Just SizeUnit::Byte etc.
I don't think so. Usually, when there is simultaneous change and move, have to manually add some things. |
Yes, I meant that resolving a conflict before the files got renamed and split should be easier. |
// use Binary prefix standards from IEC 60027-2 | ||
// see http://en.wikipedia.org/wiki/Kilobyte | ||
// value must be given in bytes | ||
// to send numbers instead of strings with suffixes | ||
QString Utils::Misc::friendlyUnit(qreal val, bool is_speed) | ||
bool Utils::Misc::friendlyUnit(qreal rawVal, qreal &val, Utils::Misc::SizeUnit &unit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qreal is wrong input type for this function. We expect there some amount of bytes that shouldn't be neither fractional nor negative. So qlonglong will be right here. And return void, of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean quint64
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess there are negative sizes somewhere, and they are used to represent unknown size, because someone even created a translatable string for this case. For the same reason the function has to signal about incorrect size, so it returns bool
.
The very first action of this function will be the conversion of integral input into floating point value, but since everybody want cleaner interface, let's change both function signatures to qint64
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But does double
has any meaning for this function at all?
It is just being used as qint64
and so it is not really has any meaning since you're passing qint64
in all cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess qreal
was used for parameter to avoid declaring a local variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean quint64?
Yes. I made a typo. I mean qulonglong, which is the same.
But does double has any meaning for this function at all?
We can't have a fractional number of bytes, but we can have fractional number of kibibytes, etc. So return type of qreal is correct.
I guess there are negative sizes somewhere, and they are used to represent unknown size
This logic should be placed where it is required. Not here!
I looked over picture and in my opinion it looks good without extending vertically space for filter bar. UPD: |
@DoumanAsh can you suggest something, please? Because I can't understand what style do you mean. |
@evsh Sorry. Green is name and red is value. At least for me. |
@DoumanAsh thank toy for the illustration. Do you mean that the label in "Names only" is at the right side from the value widget, while all other labels are at the left side? If so, I do not know what can I do about this. QCheckBox looks like it looks, I do not want to change it. Neither I want to move all other label to the right side. What to you want to change? |
@DoumanAsh is right here. You need to put the label before the checkbox (you never seen one?). |
} | ||
|
||
if (m_minLeechs > 0 || m_maxLeechs >= 0) { | ||
int leechs = sourceModel()->data(sourceModel()->index(sourceRow, LEECHS)).toInt(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The correct plural of the word leech is "leeches". Please correct all variations of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and of course add the source parent.
Btw, wouldn't it be beneficial to hold the sourceModel() in a tmp variable at the top of the function? (for optimization and readability purposes).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The correct plural of the word leech is "leeches". Please correct all variations of it.
I probably wanted to follow the enumerator identifier. Let's correct that too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. From a quick look these need correction:
- LEECHS
- m_minLeechs
- m_maxLeechs
- leechs
- setLeechsFilter (and doxygen comments)
- search is your friend :p
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK.
@sledgehammer999, thank you for the suggestions! |
I am done with the review. I have left some comments that are easy to fix. @ everyone |
I forgot to mention that I didn't compile/run this. It will be my final step before merging. I hope I don't find any UI weirdness. |
m_searchTerm = searchTerm; | ||
if (searchTerm.length() > 2 | ||
&& searchTerm.at(0) == QLatin1Char('"') && searchTerm.at(searchTerm.length() - 1) == QLatin1Char('"')) { | ||
m_searchTermWords.append(m_searchTerm.mid(1, m_searchTerm.length() - 2)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What a nice bug! It exists, but does not expose itself. Wish they all learn from this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean you should assign and not append? I admit I didn't catch too :S
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Obviously, the list was flooded with the copy of this word :)
On 4 April 2016 at 00:25, sledgehammer999 notifications@github.com wrote:
In src/gui/search/searchsortmodel.cpp
#3989 (comment)
:{
}+void SearchSortModel::enableNameFilter(bool enable)
+{
- m_isNameFilterEnabled = enable;
+}
+void SearchSortModel::setNameFilter(const QString &searchTerm)
+{
- m_searchTerm = searchTerm;
- if (searchTerm.length() > 2
&& searchTerm.at(0) == QLatin1Char('"') && searchTerm.at(searchTerm.length() - 1) == QLatin1Char('"')) {
m_searchTermWords.append(m_searchTerm.mid(1, m_searchTerm.length() - 2));
Do you mean you should assign and not append? I admit I didn't catch too :S
—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/qbittorrent/qBittorrent/pull/3989/files/e5b9855c7860a6ea54383758200bbb7f91116e04#r58318785
@sledgehammer999 |
Ups... Checks failed |
Since we already have searchtab.ui, let's set up all the widgets there. Additionally, save a bit of vertical space by putting results label in a row with the filter widgets.
I've replaced model file include in the #include <QMetaType>
#include <QWidget> in |
If somebody wants to help to sort it out, to reproduce just replace #include <QVariant> with #include <QMetaType> in |
@sledgehammer999, I think this can be merged as it is, with the crazy include. |
Works fine for me. |
I think everything works fine. Thank you for the work. PS: qt4+qmake+QMetaType works for me on Windows and Debian unstable. But isn't very important to find out why travis(ubuntu trusty) fails. |
I agree with you that the icons are ugly. AFAIK they were made without designer. We can take an icon from another theme. |
No need. On linux it should use the ones from the system's theme. On Windows/OSX see #4253 |
Unfortunately, those names ("task-") are specific to the Oxygen style. |
Oh, I see now your question there. OK. Thank you! |
As per discussion in issue #3812, here we propose a filtering panel for the search tab. The panel's widgets control state of the search results proxy model to filter out unneeded items. The filtering currently includes seeds number, torrent size and a flag to perform matching the search pattern against torrent names only, or include file names matches as returned by some of the search engines.
This replaces filtering in the BTDigg and TorrentReactor search plugins.
Thanks to all the participants of the discussion in issue #3812 and especially to @ngosang.
Screenshot: