-
Notifications
You must be signed in to change notification settings - Fork 940
Private/codewithvk/recent doc in starter screen #13866
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
base: distro/collabora/coda-25.04
Are you sure you want to change the base?
Private/codewithvk/recent doc in starter screen #13866
Conversation
Signed-off-by: codewithvk <[email protected]> Change-Id: I10fcc6a5dbbdfa2c5d657466b6dc4d94ae676957
286d837 to
cc5a087
Compare
qt/coda-qt.cpp
Outdated
| lok::Document* loKitDoc = DocumentData::get(_document._appDocId).loKitDocument; | ||
| if (loKitDoc) { | ||
| docType = static_cast<LibreOfficeKitDocumentType>(loKitDoc->getDocumentType()); | ||
| LibreOfficeKitDocumentType docType = LOK_DOCTYPE_OTHER; |
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.
use std::optional<LibreOfficeKitDocumentType>, with an empty one representing "all types", rather than "misusing" LOC_DOCTYPE_OTHER for that?
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.
make sense.
qt/RecentDocuments.cpp
Outdated
|
|
||
| std::sort(allDocs.begin(), allDocs.end(), | ||
| [](const DocumentEntry& a, const DocumentEntry& b) { | ||
| return a.timestamp > b.timestamp; |
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'd use a predicate here that takes into account all four members of DocumentEntry (so that the non-stable order into which std::sort puts equivalent elements doesn't lead to random results)
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.
Agree, but practically it’s very rare to have the same timestamps. Still, I’ve implemented the ordering like this:
timestamp -> uri -> name -> type
qt/RecentDocuments.cpp
Outdated
| }); | ||
|
|
||
| Poco::JSON::Array::Ptr recentDocs = new Poco::JSON::Array(); | ||
| int limit = qMin(static_cast<int>(allDocs.size()), MAX_RECENT); |
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.
- instead of using a potentially lossy cast of
allDocs.size()toint, play it safe and instead castMAX_RECENTtostd::size_t(or makeMAX_RECENTbe of that type to begin with) and let the resultinglimitbe ofstd::size_t? - instead of
qMin, usestd::min? (and now I notice you already useqMinelsewhere in this file, too, which could be some follow-up cleanup commit)
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.
Done.
Signed-off-by: codewithvk <[email protected]> Change-Id: I5df2177f79ac6cb2a833e834dabf87b77347a047
cc5a087 to
1f2ef6d
Compare
Signed-off-by: codewithvk <[email protected]> Change-Id: I7dff4ea2372dab2b3031c9c60dc89d5fa98f5b1d
Summary
TODO
Checklist
make prettier-writeand formatted the code.make checkmake runand manually verified that everything looks okay