mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-20 00:41:23 +00:00
Fixes for the XBEL bookmark format
svn path=/trunk/kdebase/konqueror/keditbookmarks/; revision=72755
This commit is contained in:
parent
decf76b874
commit
8e22035e40
|
@ -44,6 +44,7 @@ void MoveCommand::execute()
|
|||
//kdDebug() << "MoveCommand::execute parentAddress=" << parentAddress << " posInNewParent=" << posInNewParent << endl;
|
||||
KBookmark newParentBk = KBookmarkManager::self()->findByAddress( parentAddress );
|
||||
ASSERT( !newParentBk.isNull() );
|
||||
ASSERT( newParentBk.isGroup() );
|
||||
|
||||
if ( posInNewParent == 0 ) // First child
|
||||
{
|
||||
|
@ -55,8 +56,8 @@ void MoveCommand::execute()
|
|||
kdDebug() << "MoveCommand::execute afterAddress=" << afterAddress << endl;
|
||||
KBookmark afterNow = KBookmarkManager::self()->findByAddress( afterAddress );
|
||||
ASSERT(!afterNow.isNull());
|
||||
QDomNode result = newParentBk.internalElement().insertAfter( bk.internalElement(), afterNow.internalElement() );
|
||||
ASSERT(!result.isNull());
|
||||
bool result = newParentBk.toGroup().moveItem( bk, afterNow );
|
||||
ASSERT(result);
|
||||
kdDebug() << "MoveCommand::execute after moving in the dom tree : item=" << bk.address() << endl;
|
||||
}
|
||||
|
||||
|
@ -103,7 +104,7 @@ void CreateCommand::execute()
|
|||
bk = parentGroup.createNewFolder( m_text );
|
||||
m_text = bk.fullText(); // remember it, we won't have to ask it again
|
||||
kdDebug() << "CreateCommand::execute " << m_group << " open : " << m_open << endl;
|
||||
bk.internalElement().setAttribute( "OPEN", m_open ? 1 : 0 );
|
||||
bk.internalElement().setAttribute( "folded", m_open ? "no" : "yes" );
|
||||
}
|
||||
else
|
||||
bk = parentGroup.addBookmark( m_text, m_url );
|
||||
|
@ -116,7 +117,7 @@ void CreateCommand::execute()
|
|||
{
|
||||
kdDebug() << "Opening parent" << endl;
|
||||
// Open the parent (useful if it was empty) - only for manual commands
|
||||
parentGroup.internalElement().setAttribute( "OPEN", 1 );
|
||||
parentGroup.internalElement().setAttribute( "folded", "no" );
|
||||
}
|
||||
ASSERT( bk.address() == m_to );
|
||||
}
|
||||
|
@ -151,7 +152,7 @@ void DeleteCommand::execute()
|
|||
if ( bk.isGroup() )
|
||||
{
|
||||
m_cmd = new CreateCommand(QString::null, m_from, bk.fullText(),
|
||||
bk.internalElement().attribute("OPEN")=="1");
|
||||
bk.internalElement().attribute("folded")=="no");
|
||||
m_subCmd = deleteAll( bk.toGroup() );
|
||||
m_subCmd->execute();
|
||||
}
|
||||
|
@ -215,11 +216,7 @@ void RenameCommand::execute()
|
|||
KBookmark bk = KBookmarkManager::self()->findByAddress( m_address );
|
||||
ASSERT( !bk.isNull() );
|
||||
|
||||
QDomText domtext;
|
||||
if (bk.isGroup())
|
||||
domtext = bk.internalElement().elementsByTagName("TEXT").item(0).firstChild().toText();
|
||||
else
|
||||
domtext = bk.internalElement().firstChild().toText();
|
||||
QDomText domtext = bk.internalElement().elementsByTagName("title").item(0).firstChild().toText();
|
||||
|
||||
m_oldText = domtext.data();
|
||||
domtext.setData( m_newText );
|
||||
|
@ -303,7 +300,7 @@ void ImportCommand::execute()
|
|||
// Find or create "Netscape Bookmarks" toplevel item
|
||||
// Hmm, let's just create it. The user will clean up if he imports twice.
|
||||
netscapeGroup = KBookmarkManager::self()->root().createNewFolder(m_folder);
|
||||
netscapeGroup.internalElement().setAttribute("ICON", m_icon);
|
||||
netscapeGroup.internalElement().setAttribute("icon", m_icon);
|
||||
m_group = netscapeGroup.address();
|
||||
} else
|
||||
{
|
||||
|
@ -357,7 +354,7 @@ void ImportCommand::newBookmark( const QString & text, const QCString & url, con
|
|||
{
|
||||
KBookmark bk = mstack.top()->addBookmark( text, QString::fromUtf8(url) );
|
||||
// Store additionnal info
|
||||
bk.internalElement().setAttribute("NETSCAPEINFO",additionnalInfo);
|
||||
bk.internalElement().setAttribute("netscapeinfo",additionnalInfo);
|
||||
}
|
||||
|
||||
void ImportCommand::newFolder( const QString & text, bool open, const QString & additionnalInfo )
|
||||
|
@ -367,8 +364,8 @@ void ImportCommand::newFolder( const QString & text, bool open, const QString &
|
|||
mstack.push( &(mlist.last()) );
|
||||
// Store additionnal info
|
||||
QDomElement element = mlist.last().internalElement();
|
||||
element.setAttribute("NETSCAPEINFO",additionnalInfo);
|
||||
element.setAttribute("OPEN",open?"1":"0");
|
||||
element.setAttribute("netscapeinfo",additionnalInfo);
|
||||
element.setAttribute("folded",open?"no":"yes");
|
||||
}
|
||||
|
||||
void ImportCommand::newSeparator()
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
|
||||
// Create a bookmark
|
||||
CreateCommand( const QString & name, const QString & address,
|
||||
const QString & text, const QString & url )
|
||||
const QString & text, const KURL & url )
|
||||
: KCommand(name), m_to(address), m_text(text), m_url(url),
|
||||
m_group(false), m_separator(false), m_originalBookmark(QDomElement())
|
||||
{}
|
||||
|
@ -77,7 +77,7 @@ public:
|
|||
private:
|
||||
QString m_to;
|
||||
QString m_text;
|
||||
QString m_url;
|
||||
KURL m_url;
|
||||
bool m_group:1;
|
||||
bool m_separator:1;
|
||||
bool m_open:1;
|
||||
|
|
|
@ -50,14 +50,14 @@ KEBListViewItem::KEBListViewItem(QListView *parent, const KBookmark & group )
|
|||
|
||||
// bookmark (first of its group)
|
||||
KEBListViewItem::KEBListViewItem(KEBListViewItem *parent, const KBookmark & bk )
|
||||
: QListViewItem(parent, bk.fullText(), bk.url()), m_bookmark(bk)
|
||||
: QListViewItem(parent, bk.fullText(), bk.url().prettyURL()), m_bookmark(bk)
|
||||
{
|
||||
init(bk);
|
||||
}
|
||||
|
||||
// bookmark (after another)
|
||||
KEBListViewItem::KEBListViewItem(KEBListViewItem *parent, QListViewItem *after, const KBookmark & bk )
|
||||
: QListViewItem(parent, after, bk.fullText(), bk.url()), m_bookmark(bk)
|
||||
: QListViewItem(parent, after, bk.fullText(), bk.url().prettyURL()), m_bookmark(bk)
|
||||
{
|
||||
init(bk);
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ void KEBListViewItem::init( const KBookmark & bk )
|
|||
|
||||
void KEBListViewItem::setOpen( bool open )
|
||||
{
|
||||
m_bookmark.internalElement().setAttribute( "OPEN", open ? 1 : 0 );
|
||||
m_bookmark.internalElement().setAttribute( "folded", open ? "no" : "yes" );
|
||||
QListViewItem::setOpen( open );
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ public:
|
|||
KEBTopLevel * KEBTopLevel::s_topLevel = 0L;
|
||||
|
||||
KEBTopLevel::KEBTopLevel( const QString & bookmarksFile )
|
||||
: KMainWindow(), m_commandHistory( actionCollection() )
|
||||
: KMainWindow(), m_bIsSaving( false ), m_commandHistory( actionCollection() )
|
||||
{
|
||||
// Create the bookmark manager.
|
||||
// It will be available in KBookmarkManager::self() from now.
|
||||
|
@ -195,8 +195,6 @@ KEBTopLevel::KEBTopLevel( const QString & bookmarksFile )
|
|||
|
||||
KEBTopLevel::~KEBTopLevel()
|
||||
{
|
||||
//if ( kapp->clipboard()->ownsSelection() )
|
||||
// kapp->clipboard()->clear();
|
||||
s_topLevel = 0L;
|
||||
}
|
||||
|
||||
|
@ -247,17 +245,16 @@ void KEBTopLevel::slotSave()
|
|||
|
||||
bool KEBTopLevel::save()
|
||||
{
|
||||
m_bIsSaving = true;
|
||||
bool ok = KBookmarkManager::self()->save();
|
||||
if (ok)
|
||||
{
|
||||
QByteArray data;
|
||||
// We don't want to notify ourselves (keditbookmarks), because this would
|
||||
// call slotBookmarksChanged, which clears the history.
|
||||
// There's probably a better solution than hardcoding konq/kdesktop, but not at 4:47am.
|
||||
kapp->dcopClient()->send( "konqueror*", "KBookmarkManager", "notifyCompleteChange()", data );
|
||||
kapp->dcopClient()->send( "kdesktop", "KBookmarkManager", "notifyCompleteChange()", data );
|
||||
// We'll get the notification ourselves as well, that's why we use m_bIsSaving
|
||||
kapp->dcopClient()->send( "*", "KBookmarkManager", "notifyCompleteChange()", data );
|
||||
setModified( false );
|
||||
}
|
||||
m_bIsSaving = false;
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
@ -308,16 +305,6 @@ void KEBTopLevel::slotDelete()
|
|||
return;
|
||||
}
|
||||
KBookmark bk = selectedBookmark();
|
||||
#if 0
|
||||
kdDebug() << "KEBTopLevel::slotDelete child count=" << bk.internalElement().childNodes().count() << endl;
|
||||
if ( bk.isGroup() && bk.internalElement().childNodes().count() > 1 /*there's always "TEXT"*/ )
|
||||
{
|
||||
if ( KMessageBox::questionYesNo( this, i18n("This is a bookmark folder. Are you sure you want to delete it ?\nThis operation can't be undone."),
|
||||
i18n("Confirmation required") ) == KMessageBox::No )
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
DeleteCommand * cmd = new DeleteCommand( i18n("Delete item"), bk.address() );
|
||||
m_commandHistory.addCommand( cmd );
|
||||
}
|
||||
|
@ -403,7 +390,7 @@ void KEBTopLevel::pasteData( const QString & cmdName, QMimeSource * data, const
|
|||
if ( KEBDrag::canDecode( data ) )
|
||||
{
|
||||
KBookmark bk = KEBDrag::decode( data );
|
||||
kdDebug() << "KEBTopLevel::slotPaste url=" << bk.url() << endl;
|
||||
kdDebug() << "KEBTopLevel::slotPaste url=" << bk.url().prettyURL() << endl;
|
||||
CreateCommand * cmd = new CreateCommand( cmdName, insertionAddress, bk );
|
||||
m_commandHistory.addCommand( cmd );
|
||||
}
|
||||
|
@ -462,8 +449,8 @@ void KEBTopLevel::slotShowNS()
|
|||
{
|
||||
kdDebug() << "KEBTopLevel::slotShowNS" << endl;
|
||||
QDomElement rootElem = KBookmarkManager::self()->root().internalElement();
|
||||
QString attr = "HIDE_NSBK";
|
||||
rootElem.setAttribute(attr, rootElem.attribute(attr) == "1" ? "0" : "1");
|
||||
QString attr = "hide_nsbk";
|
||||
rootElem.setAttribute(attr, rootElem.attribute(attr) == "yes" ? "no" : "yes");
|
||||
setModified(); // one will need to save, to get konq to notice the change
|
||||
// If that's bad, then we need to put this flag in a KConfig.
|
||||
}
|
||||
|
@ -607,10 +594,13 @@ void KEBTopLevel::slotContextMenu( KListView *, QListViewItem * _item, const QPo
|
|||
|
||||
void KEBTopLevel::slotBookmarksChanged()
|
||||
{
|
||||
kdDebug() << "KEBTopLevel::slotBookmarksChanged" << endl;
|
||||
// This is called when someone changes bookmarks in konqueror....
|
||||
m_commandHistory.clear();
|
||||
fillListView();
|
||||
if ( ! m_bIsSaving )
|
||||
{
|
||||
kdDebug() << "KEBTopLevel::slotBookmarksChanged" << endl;
|
||||
m_commandHistory.clear();
|
||||
fillListView();
|
||||
}
|
||||
}
|
||||
|
||||
void KEBTopLevel::update()
|
||||
|
@ -657,7 +647,7 @@ void KEBTopLevel::fillGroup( KEBListViewItem * parentItem, KBookmarkGroup group
|
|||
KBookmarkGroup grp = bk.toGroup();
|
||||
KEBListViewItem * item = new KEBListViewItem( parentItem, lastItem, grp );
|
||||
fillGroup( item, grp );
|
||||
if (grp.internalElement().attribute("OPEN") == "1")
|
||||
if (grp.isOpen())
|
||||
item->QListViewItem::setOpen(true); // no need to save it again :)
|
||||
lastItem = item;
|
||||
}
|
||||
|
|
|
@ -114,6 +114,7 @@ protected:
|
|||
|
||||
bool m_bModified;
|
||||
bool m_bCanPaste;
|
||||
bool m_bIsSaving;
|
||||
KToggleAction * m_taShowNS;
|
||||
KListView * m_pListView;
|
||||
KCommandHistory m_commandHistory;
|
||||
|
|
Loading…
Reference in a new issue