{"action":"created","issue":{"url":"https://api.github.com/repos/sailfishos/sailfish-office/issues/47","labels_url":"https://api.github.com/repos/sailfishos/sailfish-office/issues/47/labels{/name}","comments_url":"https://api.github.com/repos/sailfishos/sailfish-office/issues/47/comments","events_url":"https://api.github.com/repos/sailfishos/sailfish-office/issues/47/events","html_url":"https://github.com/sailfishos/sailfish-office/pull/47","id":109767534,"number":47,"title":"Remember last page position for PDF documents","user":{"login":"dcaliste","id":5889532,"avatar_url":"https://avatars.githubusercontent.com/u/5889532?v=3","gravatar_id":"","url":"https://api.github.com/users/dcaliste","html_url":"https://github.com/dcaliste","followers_url":"https://api.github.com/users/dcaliste/followers","following_url":"https://api.github.com/users/dcaliste/following{/other_user}","gists_url":"https://api.github.com/users/dcaliste/gists{/gist_id}","starred_url":"https://api.github.com/users/dcaliste/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcaliste/subscriptions","organizations_url":"https://api.github.com/users/dcaliste/orgs","repos_url":"https://api.github.com/users/dcaliste/repos","events_url":"https://api.github.com/users/dcaliste/events{/privacy}","received_events_url":"https://api.github.com/users/dcaliste/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-05T10:14:23Z","updated_at":"2015-10-05T11:47:23Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/sailfishos/sailfish-office/pulls/47","html_url":"https://github.com/sailfishos/sailfish-office/pull/47","diff_url":"https://github.com/sailfishos/sailfish-office/pull/47.diff","patch_url":"https://github.com/sailfishos/sailfish-office/pull/47.patch"},"body":"As described in the [TJC post](https://together.jolla.com/question/90317/help-improve-document-application/#lastpage), I propose here an implementation for the feature to remember last page position for PDF documents. It is based on :\r\n* the use of a local SQlite database (see plugins/PDFStorage.js) with a table indexed by file path, containing the page index, the position in the page (in reduced coordinates) and the actual width of the page in pixel. I prefered to store these (more) abstract data, than the actual contentX, contentY and width, height of the PDFCanvas object, to be sure that the last position is properly reproduced when opening a file in landscape while position was stored in portrait (or vice-versa).\r\n* I open a database connection every time a PDF file is taped and loaded to fetch for the possibly stored position data. I don't know if it's clever or not. I prefered this than a global variable owned by the document list and passed to the PDFView instance. Like that it is self contained in PDFView.\r\n* the loading of the stored settings is done on the first emission of the pageLayoutChanged signal and not on Component.completed since, it's only after this signal that page geometries are known.\r\n* the storing to the database is done on Component destruction. But there's a trick here I don't like. If I put the Component.onDestruction handler in the PDFCanvas instance, when triggered, the properties have been already destroyed (_settings attribute is null there). While putting the signal handler in the parent (the PDFView instance), the child is not destroyed yet, and I can do things with _settings. It's fragile IMHO since the Qt documentation explicitly says that the order of destroying is not guaranteed. But I have no other idea. I've tried in fact to react on the page transition, which works fine, but saving is not done when we quit the application directly, which is a no go of course.\r\n* Finally the PR is divided into two commits, one to bring all the machinery for storing the page data, the other one to add a setting for the document application to enable or not this feature (that may be disturbing first to go back on a big zoom level in a middle page while not knowing about this, so it's an opt-in feature).\r\n\r\nSorry, long text, but for this feature that seems so simple (even to implement), it finally requires many explanations since many choices were done."},"comment":{"url":"https://api.github.com/repos/sailfishos/sailfish-office/issues/comments/145503541","html_url":"https://github.com/sailfishos/sailfish-office/pull/47#issuecomment-145503541","issue_url":"https://api.github.com/repos/sailfishos/sailfish-office/issues/47","id":145503541,"user":{"login":"pvuorela","id":2478615,"avatar_url":"https://avatars.githubusercontent.com/u/2478615?v=3","gravatar_id":"","url":"https://api.github.com/users/pvuorela","html_url":"https://github.com/pvuorela","followers_url":"https://api.github.com/users/pvuorela/followers","following_url":"https://api.github.com/users/pvuorela/following{/other_user}","gists_url":"https://api.github.com/users/pvuorela/gists{/gist_id}","starred_url":"https://api.github.com/users/pvuorela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pvuorela/subscriptions","organizations_url":"https://api.github.com/users/pvuorela/orgs","repos_url":"https://api.github.com/users/pvuorela/repos","events_url":"https://api.github.com/users/pvuorela/events{/privacy}","received_events_url":"https://api.github.com/users/pvuorela/received_events","type":"User","site_admin":false},"created_at":"2015-10-05T11:47:23Z","updated_at":"2015-10-05T11:47:23Z","body":"Talked with Vappu/design that there doesn't seem enough need for having a separate setting. Not something too many people should be expected to change. If restoring page with zooming is disturbing, can as well avoid zooming. Should be enough already if current page number is restored.\r\n"}}