Skip to content

Conversation

@codewithvk
Copy link
Contributor

  • Resolves: #
  • Target version: master

Summary

TODO

  • ...

Checklist

  • I have run make prettier-write and formatted the code.
  • All commits have Change-Id
  • I have run tests with make check
  • I have issued make run and manually verified that everything looks okay
  • Documentation (manuals or wiki) has been updated or is not required

Signed-off-by: codewithvk <[email protected]>
Change-Id: I10fcc6a5dbbdfa2c5d657466b6dc4d94ae676957
@codewithvk codewithvk force-pushed the private/codewithvk/recent_doc_in_starter_screen branch from 286d837 to cc5a087 Compare December 17, 2025 11:28
@codewithvk codewithvk marked this pull request as ready for review December 17, 2025 11:29
@Darshan-upadhyay1110 Darshan-upadhyay1110 requested review from Quwex and stbergmann and removed request for Quwex December 18, 2025 10:29
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;
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sense.


std::sort(allDocs.begin(), allDocs.end(),
[](const DocumentEntry& a, const DocumentEntry& b) {
return a.timestamp > b.timestamp;
Copy link
Contributor

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)

Copy link
Contributor Author

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

});

Poco::JSON::Array::Ptr recentDocs = new Poco::JSON::Array();
int limit = qMin(static_cast<int>(allDocs.size()), MAX_RECENT);
Copy link
Contributor

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() to int, play it safe and instead cast MAX_RECENT to std::size_t (or make MAX_RECENT be of that type to begin with) and let the resulting limit be of std::size_t?
  • instead of qMin, use std::min? (and now I notice you already use qMin elsewhere in this file, too, which could be some follow-up cleanup commit)

Copy link
Contributor Author

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
@codewithvk codewithvk force-pushed the private/codewithvk/recent_doc_in_starter_screen branch from cc5a087 to 1f2ef6d Compare December 20, 2025 09:09
Signed-off-by: codewithvk <[email protected]>
Change-Id: I7dff4ea2372dab2b3031c9c60dc89d5fa98f5b1d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To Review

Development

Successfully merging this pull request may close these issues.

2 participants