mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-20 00:41:23 +00:00
Added KBookmark::standaloneBookmark so that Carsten can easily create
a KBookmark from thin air :) Used it in KBookmarkDrag when receiving a URL drop. svn path=/trunk/kdebase/libkonq/; revision=74017
This commit is contained in:
parent
f1060ec395
commit
4a87e5595e
|
@ -265,3 +265,13 @@ QString KBookmark::address() const
|
|||
return "ERROR";
|
||||
}
|
||||
}
|
||||
|
||||
static KBookmark KBookmark::standaloneBookmark( const QString & text, const KURL & url )
|
||||
{
|
||||
QDomDocument doc("xbel");
|
||||
QDomElement elem = doc.createElement("xbel");
|
||||
doc.appendChild( elem );
|
||||
KBookmarkGroup grp( elem );
|
||||
grp.addBookmark( text, url );
|
||||
return grp.first();
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@ class KBookmark
|
|||
public:
|
||||
KBookmark( QDomElement elem ) : element(elem) {}
|
||||
|
||||
static KBookmark standaloneBookmark( const QString & text, const KURL & url );
|
||||
|
||||
/**
|
||||
* Whether the bookmark is a group or a normal bookmark
|
||||
*/
|
||||
|
|
|
@ -61,7 +61,7 @@ QByteArray KBookmarkDrag::encodedData( const char* mime ) const
|
|||
return QUriDrag::encodedData( mime );
|
||||
else if ( mimetype == "application/x-xbel" )
|
||||
{
|
||||
QDomDocument doc("xbel"); // plan for the future :)
|
||||
QDomDocument doc("xbel");
|
||||
QDomElement elem = doc.createElement("xbel");
|
||||
doc.appendChild( elem );
|
||||
elem.appendChild( m_bookmark.internalElement().cloneNode( true /* deep */ ) );
|
||||
|
@ -94,15 +94,10 @@ KBookmark KBookmarkDrag::decode( const QMimeSource * e )
|
|||
KURL::List m_lstDragURLs;
|
||||
if ( KURLDrag::decode( e, m_lstDragURLs ) )
|
||||
{
|
||||
QDomDocument doc("xbel");
|
||||
QDomElement elem = doc.createElement("xbel");
|
||||
doc.appendChild( elem );
|
||||
if ( m_lstDragURLs.count() > 1 )
|
||||
kdWarning() << "Only first URL inserted, known limitation" << endl;
|
||||
//kdDebug() << "KBookmarkDrag::decode url=" << m_lstDragURLs.first().url() << endl;
|
||||
KBookmarkGroup grp( elem );
|
||||
grp.addBookmark( m_lstDragURLs.first().fileName(), m_lstDragURLs.first().url() );
|
||||
return grp.first();
|
||||
return KBookmark::standaloneBookmark( m_lstDragURLs.first().fileName(), m_lstDragURLs.first() );
|
||||
}
|
||||
}
|
||||
return KBookmark(QDomElement());
|
||||
|
|
Loading…
Reference in a new issue