From 27d33c95b52e2afeefcb1054c6ec747b30631894 Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 13 Feb 2001 11:53:49 +0000 Subject: [PATCH] Fix bug reported by Stephane . "Create New Folder", and then Cancel, was still creating the undo command, so pressing undo would delete a bookmark :( svn path=/trunk/kdebase/konqueror/keditbookmarks/; revision=82612 --- keditbookmarks/commands.cpp | 2 +- keditbookmarks/toplevel.cpp | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/keditbookmarks/commands.cpp b/keditbookmarks/commands.cpp index aebd493211..41d741d610 100644 --- a/keditbookmarks/commands.cpp +++ b/keditbookmarks/commands.cpp @@ -101,8 +101,8 @@ void CreateCommand::execute() else if (m_group) { + ASSERT( !m_text.isEmpty() ); 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( "folded", m_open ? "no" : "yes" ); } diff --git a/keditbookmarks/toplevel.cpp b/keditbookmarks/toplevel.cpp index 64469c7f8a..ea98fed782 100644 --- a/keditbookmarks/toplevel.cpp +++ b/keditbookmarks/toplevel.cpp @@ -312,8 +312,19 @@ void KEBTopLevel::slotDelete() void KEBTopLevel::slotNewFolder() { - CreateCommand * cmd = new CreateCommand( i18n("Create Folder"), insertionAddress(), QString::null, true /*open*/ ); - m_commandHistory.addCommand( cmd ); + // EVIL HACK + // We need to ask for the folder name before creating the command, in case of "Cancel". + // But in message-freeze time, impossible to add i18n()s. So... we have to call the existing code : + QDomDocument doc("xbel"); // Dummy document + QDomElement elem = doc.createElement("xbel"); + doc.appendChild( elem ); + KBookmarkGroup grp( elem ); // Dummy group + KBookmark bk = grp.createNewFolder( QString::null ); // Asks for the name + if ( !bk.fullText().isEmpty() ) // Not canceled + { + CreateCommand * cmd = new CreateCommand( i18n("Create Folder"), insertionAddress(), bk.fullText(), true /*open*/ ); + m_commandHistory.addCommand( cmd ); + } } void KEBTopLevel::slotInsertSeparator()