Summary: | Relative and absolute data file paths in kst | ||
---|---|---|---|
Product: | [Applications] kst | Reporter: | Nicolas Brisset <nicolas.brisset> |
Component: | general | Assignee: | kst |
Status: | RESOLVED FIXED | ||
Severity: | wishlist | CC: | syntheticpp |
Priority: | NOR | ||
Version: | 2.0.0 | ||
Target Milestone: | 2.0.0 | ||
Platform: | unspecified | ||
OS: | Microsoft Windows | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: | Change kst's CWD when loading a .kst file |
Description
Nicolas Brisset
2010-01-07 18:12:59 UTC
(copy/pasted from Don's email on the list http://mail.kde.org/pipermail/kst/2009-September/016558.html) I'd like to see a kst with a flexible, adaptable approach to paths. Specifically: 1) kst should honour the method by which users specify paths. An absolute path specified should be saved as absolute: $ kst -y 1 /tmp/datafile as should a relative one: $ kst -y 1 ./datafile (Presumably the user has a better understanding of whether absolute or relative is more appropriate.) 2) Store paths to files selected with the file selection widget relative to some known base; store the base path, too. Store kst's cwd in the file, too, while your at it. Then, when the .kst file is loaded later, attempt to find a data source specified by relative path by trying different bases (in some specified order, though not necessarily this one): * the base path to the relative file stored in the .kst file (this is effectively and absolute path) * the current working directory (kst 2.x style) * the cwd stored in the .kst file (another form of "absolute path") * the directory containing the .kst file (Josh style) 3) If this is done, there needs to be a facility in kst to allow users to rewrite data source paths, so that they can change absolute paths to relative ones, &c. Bottom line: there are cases were absolute paths work best, and cases where relative paths work best. Restricting yourself to one or the other will always create problems. Be flexible. Now, my comments to that: 1) I agree: whether the data file is passed from the command line or from the wizard, it should be kept relative if relative and absolute if absolute (which is as far as I know what happens right now, at least for the wizard) 2) sounds a bit too complex to me. Based on experience, I'd suggest something a bit more simple: when loading data, if the file is relative then look for it from the current path (which implies changing kst's cwd to that of the just opened file before processing the contents, anything else would be plain crazy) and if it is absolute then load it as absolute. In fact, I have a one-line patch locally that does just that and it works very well. 3) as a complement to 2), you indeed need to be able to "rewrite" paths. Firing up an editor is of course always possible, but I don't think we want to force that on the average user. I'd rather suggest a "Use relative paths to data files" checkbox in the save dialog, which would save the paths relative to the directory where the .kst is being saved in. Default would probably be relative paths, but that has to be discussed. And of course, there is an underlying assumption which is that an average user will never need to mix absolute and relative paths (!), which I think we can live with. If we go for that, I think my use cases would be catered for. And the implementation would be pretty trivial: the one-line patch I'm going to attach and a custom save dialog, and checking that relative/absolute paths are handled correctly, which I believe is the case right now already. What do you think? Created attachment 39656 [details]
Change kst's CWD when loading a .kst file
Could we apply the proposed patch, as it allows working with relative file paths conveniently? It wouldn't close the bug as a user-friendly way of choosing between relative and absolute paths is still needed, but it is still definitely an improvement (I even think trying to load a .kst with relative file paths from the wrong dir crashes kst without that patch). SVN commit 1117077 by brisset: Simple one-liner to allow working with relative paths to datasources. I'm tired of keeping it around locally, and it seems to work well enough to commit. This path allows loading files with absolute file paths. For complete functionality, we should also be able to save them :-) I think it would be nice to provide an option for that in the file save dialog. Note that it is already possible to have relative paths in 2 ways: - hand-edit the .kst, after all xml is ASCII and easy to edit! - use in the data wizard only relative paths, they are then stored as such. But I still think an option when saving the .kst could/should be added. CCBUG: 221689 M +1 -1 mainwindow.cpp WebSVN link: http://websvn.kde.org/?view=rev&revision=1117077 SVN commit 1162736 by kuemmel: better data source path handling: - save absolute and relative path if possible - when loading try relative path for data sources first - fall back to absolute path if relative path does not exists CCBUG: 221689 M +16 -2 libkst/dataprimitive.cpp M +3 -1 libkstapp/mainwindow.cpp WebSVN link: http://websvn.kde.org/?view=rev&revision=1162736 Change version from 2.0.0_devel to 2.0.0 to simplify version numbering. See commit 1162736. These bugs are solved with 2.0.0 |