-
Notifications
You must be signed in to change notification settings - Fork 796
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
Complete TODO : Show more user friendly labels #1002
base: main
Are you sure you want to change the base?
Conversation
Linux build failed because |
I'll try replacing it with a backwards compatible method later today |
No need, the plan is to switch to newer Qt in 0.7 anyway. |
src/libs/util/readableinterval.h
Outdated
|
||
const qint8 MAX_FIELDS_DISPLAYED = 3; | ||
|
||
QString ZERO_INTERVAL_STRING = "now"; |
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.
All these should just be constant strings in an anonymous namespace in the source file.
src/libs/util/readableinterval.h
Outdated
ReadableInterval(QDateTime timestamp, QDateTime reference); | ||
ReadableInterval(QDateTime timestamp); | ||
|
||
QString toReadableString(); |
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.
Maybe just make the whole thing a static method?
@trollixx Done (I also fixed some clang tidy warnings). Please let me know if there's anything else :) |
This pull request introduces 3 alerts when merging 7d4e43c into d9bb3c5 - view on LGTM.com new alerts:
Comment posted by LGTM.com |
Hey, on the three LGTM warnings of comparing with known value at compile time, how do I transform this snippet to a compile time branch?
Here, the increment occurs only if I think this is a false alert since we depend on the boolean expression short-circuiting to increment the counter. |
src/libs/util/readableinterval.cpp
Outdated
|
||
const qint8 MAX_FIELDS_DISPLAYED = 3; | ||
|
||
const QString ZERO_INTERVAL_STRING = "now"; |
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.
This is dangerous, see static initialization order fiasco and bullet point 3 here.
src/libs/util/readableinterval.cpp
Outdated
|
||
delta = reference.toSecsSinceEpoch() - timestamp.toSecsSinceEpoch(); | ||
|
||
if (delta) { |
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.
Always try to return ASAP, and avoid unnecessary conditional blocks of code.
if (delta == 0) {
return ZERO_INTERVAL_STRING;
}
QStingList list;
...
src/libs/util/readableinterval.cpp
Outdated
|
||
const qint8 MAX_FIELDS_DISPLAYED = 3; | ||
|
||
const QString ZERO_INTERVAL_STRING = "now"; |
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.
Also, it's better to avoid making translatable strings constant. Just put them inside tr()
inline.
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'm leaving plural forms of units with a (s)
. Once we apply translation to this project, qt should automatically detect the quantity and append s
.
http://doc.qt.io/qt-5/i18n-source-translation.html#handling-plurals
I see rightfully LGTM complains about always true conditions. Maybe rewrite the whole thing as a loop? |
I am still thinking on how to implement this in a cleaner way. The current proposal is a bit too heavy for the task it accomplishes. Perhaps, worth checking if we can use |
Hey @trollixx
If you tell me which part of my snippet seems heavy, I can try replacing the same with |
Right, we still need to print generate the text ourselves, but I think |
Sure, let me update this PR with chrono |
rebase-pr1002 Fix Git conflicts of PR zealdocs#1002.
This PR completes the task at
zeal/src/libs/ui/docsetsdialog.cpp
Line 521 in 3bdb8ee