Fix change compression when editing fields: showBookmark was committing changes

and notifyManagers() was leading to a third save and a second full-tree-reload.
Removed these calls, since command::redo does it already.

Also fixed change compression messing up the "old value", so undo didn't restore
the orig value.

FIXED-IN: 4.6.1
BUG: 242884
(cherry picked from commit 1a509e8dea)
This commit is contained in:
David Faure 2011-02-02 23:47:08 +01:00
parent 9379223f96
commit c2c3a87985
2 changed files with 20 additions and 21 deletions

View file

@ -38,7 +38,12 @@
#include <kbookmark.h>
// SHUFFLE all these functions around, the order is just plain stupid
void BookmarkInfoWidget::showBookmark(const KBookmark &bk) {
void BookmarkInfoWidget::showBookmark(const KBookmark &bk)
{
// Fast exit if already shown, otherwise editing a title leads to a command after each keypress
if (m_bk == bk)
return;
commitChanges();
m_bk = bk;
@ -126,11 +131,8 @@ void BookmarkInfoWidget::commitChanges()
void BookmarkInfoWidget::commitTitle()
{
if(titlecmd)
{
m_model->notifyManagers(GlobalBookmarkManager::bookmarkAt(titlecmd->affectedBookmarks()).toGroup());
titlecmd = 0;
}
// no more change compression
titlecmd = 0;
}
void BookmarkInfoWidget::slotTextChangedTitle(const QString &str)
@ -154,11 +156,7 @@ void BookmarkInfoWidget::slotTextChangedTitle(const QString &str)
void BookmarkInfoWidget::commitURL()
{
if(urlcmd)
{
m_model->notifyManagers(GlobalBookmarkManager::bookmarkAt(urlcmd->affectedBookmarks()).toGroup());
urlcmd = 0;
}
urlcmd = 0;
}
void BookmarkInfoWidget::slotTextChangedURL(const QString &str) {
@ -181,11 +179,7 @@ void BookmarkInfoWidget::slotTextChangedURL(const QString &str) {
void BookmarkInfoWidget::commitComment()
{
if(commentcmd)
{
m_model->notifyManagers( GlobalBookmarkManager::bookmarkAt( commentcmd->affectedBookmarks() ).toGroup());
commentcmd = 0;
}
commentcmd = 0;
}
void BookmarkInfoWidget::slotTextChangedComment(const QString &str) {

View file

@ -194,30 +194,35 @@ void EditCommand::redo()
KBookmark bk = m_model->bookmarkManager()->findByAddress(mAddress);
if(mCol==-2)
{
mOldValue = bk.internalElement().attribute("toolbar");
if (mOldValue.isEmpty())
mOldValue = bk.internalElement().attribute("toolbar");
bk.internalElement().setAttribute("toolbar", mNewValue);
}
else if(mCol==-1)
{
mOldValue = bk.icon();
if (mOldValue.isEmpty())
mOldValue = bk.icon();
bk.setIcon(mNewValue);
}
else if(mCol==0)
{
mOldValue = bk.fullText();
if (mOldValue.isEmpty()) // only the first time, not when compressing changes in modify()
mOldValue = bk.fullText();
kDebug() << "mOldValue=" << mOldValue;
bk.setFullText(mNewValue);
}
else if(mCol==1)
{
mOldValue = bk.url().prettyUrl();
if (mOldValue.isEmpty())
mOldValue = bk.url().prettyUrl();
const KUrl newUrl(mNewValue);
if (!(newUrl.isEmpty() && !mNewValue.isEmpty())) // prevent emptied line if the currently entered url is invalid
bk.setUrl(newUrl);
}
else if(mCol==2)
{
mOldValue = bk.description();
if (mOldValue.isEmpty())
mOldValue = bk.description();
bk.setDescription(mNewValue);
}
m_model->emitDataChanged(bk);