Thiago Macieira wrote:
> On Thursday, 18 de August de 2011 18:59:09 Giuseppe D'Angelo wrote:
> > > What about the QUrl(QString) constructor? Can you make it parse in
> > > tolerant mode? Ideally, could it accept both local paths and urls,
> > > like KUrl does? This is extremely convenient, compared to having
> > > to sprinkle the code with fromLocalFile() everywhere, and getting
> > > runtime bugs when forgetting to do so.
> > 
> > But, how should
> >   QUrl url("c:/tmp/foo #123.wav");
> > be parsed then?
> 
> If the constructor parses as URL only, then it's a URL with scheme
> "c", path "/tmp/foo " and fragment "123.wav".
> 
> If the constructor parses as URL-or-path, then on Windows it's
> definitely the file path.
> 
> The question would be what to do on other systems if we parse as
> url-or-path.

Are there use cases where you need to accept all sorts of URLs (absolute
and relative) as well as local file paths (again, relative or absolute)?

I can see a media player (or some other content browser/viewer) that
wants to handle URLs and local files transparently, without forcing the
user to use "file://" prefixes. But I don't see what it would do with a
relative URL.

So, I see this not so much as Strict vs Tolerant parsing, but a very
specific type of parsing geared towards user input that is either an
absolute URL or a file path (we may still want to allow relative paths,
here).

    QUrl url(fileOrUrl, QUrl::UserInput);
    if (url.isFilePath())
        doSomethingDifferent();

QUrl can then quickly determine which one it is and process the string
accordingly.

In other use cases (say, when picking a[href] from a webpage), I would
prefer that relative URLs are not implicitly parsed or used as local
file paths.

Explicit is better than implicit.

Cheers,


João
_______________________________________________
Qt5-feedback mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback

Reply via email to