Review Request 129094: [dolphin] Add text/plain mime data with urls in PrettyDecoded string format

Alexandr Akulich akulichalexander at gmail.com
Tue Oct 4 15:49:50 BST 2016



> On Oct. 4, 2016, 7:09 p.m., Emmanuel Pescosta wrote:
> > Thanks for the patch!
> > 
> > This should be added to `KUrlMimeData::setUrls` instead.
> 
> Alexandr Akulich wrote:
>     I thought that the KUrlMimeData class can be used on Mime object with already exists custom text/plain data.
>     I can add a condition to add the text/plain only if it doesn't exist, will it be OK?
> 
> Alexandr Akulich wrote:
>     Hm. Current behaviour seems to be a bug, because:
>     
>     Comment in KUrlMimeData::setUrls() says: "Export the most local urls as text/uri-list and plain text, for non KDE apps."
>     The methods calls QMimeData::setUrls(), which is documented as "Since Qt 5.0, setUrls also exports the urls as plain text, if setText was not called before, to make it possible to drop them into any lineedit and text editor."
>     
>     We either call setText() or have a bug in Qt.

We call setUrls() on just constructed QMimeData and the source looks like this:

```cpp
/*!
    Sets the URLs stored in the MIME data object to those specified by \a urls.
    URLs correspond to the MIME type \c text/uri-list.
    Since Qt 5.0, setUrls also exports the urls as plain text, if setText
    was not called before, to make it possible to drop them into any lineedit
    and text editor.
    \sa hasUrls(), setData()
*/
void QMimeData::setUrls(const QList<QUrl> &urls)
{
    Q_D(QMimeData);
    QList<QVariant> list;
    const int numUrls = urls.size();
    list.reserve(numUrls);
    for (int i = 0; i < numUrls; ++i)
        list.append(urls.at(i));
    d->setData(textUriListLiteral(), list);
}
```

I can not find a code, which will set text/plain data type, the most thing we have is

```cpp
bool QMimeData::hasText() const
{
    return hasFormat(textPlainLiteral()) || hasUrls();
}
```

I looked at the Qt bugzilla and it seems that this is the root of bug https://bugreports.qt.io/browse/QTBUG-45685 .

I think that this RR can be closed and I should post a different one at https://codereview.qt-project.org


- Alexandr


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/129094/#review99767
-----------------------------------------------------------


On Oct. 4, 2016, 7:04 p.m., Alexandr Akulich wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/129094/
> -----------------------------------------------------------
> 
> (Updated Oct. 4, 2016, 7:04 p.m.)
> 
> 
> Review request for Dolphin.
> 
> 
> Repository: dolphin
> 
> 
> Description
> -------
> 
> Use case: copy file in Dolphin and paste its URL in Firefox
> 
> Some applications (such as QtCreator) are smart enough to use text/uri-list value, but, sadly, other applications (such as Firefox) accepts only text/plain
> 
> 
> Diffs
> -----
> 
>   src/kitemviews/kfileitemmodel.cpp 05f85a6 
> 
> Diff: https://git.reviewboard.kde.org/r/129094/diff/
> 
> 
> Testing
> -------
> 
> Now Ctrl+C on a file in Dolphin and Ctrl+V in the address line in Firefox works as expected.
> 
> 
> Thanks,
> 
> Alexandr Akulich
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20161004/0c112aaa/attachment.htm>


More information about the kfm-devel mailing list