Fix bug reported by Stephane <s.nicolas@videotron.ca>.

"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
This commit is contained in:
David Faure 2001-02-13 11:53:49 +00:00
parent 86ae490139
commit 27d33c95b5
2 changed files with 14 additions and 3 deletions

View file

@ -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" );
}

View file

@ -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()