[Interest] QEvent::FileOpen : opening single vs. multiple documents
Jake Petroules
Jake.Petroules at qt.io
Mon Jan 29 05:58:16 CET 2018
> On Jan 27, 2018, at 1:31 PM, René J.V. Bertin <rjvbertin at gmail.com> wrote:
>
> On Saturday January 27 2018 20:24:04 Jake Petroules wrote:
>
>> What we should do instead is allow QFileOpenEvent to store a list of files instead of just a single one.
>
> That probably should have been done from the onset, because introducing this now almost certainly means new API.
It does, but that's not a problem in and of itself - it's the correct solution. The original/current API simply has a design oversight which should be fixed.
Probably we would just add plural versions of the existing methods on QFileOpenEvent: urls() and files(), which return a QList<QUrl> and QStringList, respectively. We could document the existing url() and file() methods to return empty objects if the QFileOpenEvent is storing a *list* of opened files (or return the first item in the list), and the new methods are self-explanatory.
The behavior change of firing a single event for multiple documents instead of multiple events could be documented in the changelog.
> There's no time or serial stamp on QEvents that could be used for grouping?
>
>> Trying to re-group the events after the fact is probably not a good idea.
>
> At the least it's extra work that requires a certain amount of guessing which events go together (except those that are pending when you create the QApplication instance).
>
>
> A rough outline of solution I could see for the current way QFileOpenEvents come in :
>
> - store each incoming file URL in a QList
> - set or restart a timer to empty that list after a time that's (much?) shorter than the average time after which the user could queued another request via LaunchServices
>
> Not really difficult, but not really fun to write either and possibly brittle. But I don't see another way that's easier and/or more reliable - is there?
>
> R.
--
Jake Petroules - jake.petroules at qt.io
The Qt Company - Silicon Valley
Qbs build tool evangelist - qbs.io
More information about the Interest
mailing list