--- khtml/khtmlview.h	2007/06/28 11:22:08	1.17
+++ khtml/khtmlview.h	2007/07/13 08:44:55
@@ -314,6 +314,7 @@
     QStringList formCompletionItems(const QString &name) const;
     void clearCompletionHistory(const QString& name);
     void addFormCompletionItem(const QString &name, const QString &value);
+    void removeFormCompletionItem(const QString &name, const QString &value);
 
     void addNonPasswordStorableSite( const QString& host );
     bool nonPasswordStorableSite( const QString& host ) const;
--- khtml/khtmlview.cpp	2007/06/28 11:22:08	1.17
+++ khtml/khtmlview.cpp	2007/07/13 09:09:51
@@ -3090,6 +3090,16 @@
     d->formCompletions->writeEntry(name, items);
 }
 
+void KHTMLView::removeFormCompletionItem(const QString &name, const QString &value)
+{
+    if (!m_part->settings()->isFormCompletionEnabled())
+        return;
+
+    QStringList items = formCompletionItems(name);
+    if (items.remove(value))
+        d->formCompletions->writeEntry(name, items);
+}
+
 void KHTMLView::addNonPasswordStorableSite(const QString& host)
 {
     if (!d->formCompletions) {
--- khtml/rendering/render_form.h	2007/06/28 13:00:37	1.1
+++ khtml/rendering/render_form.h	2007/07/13 08:42:58
@@ -272,10 +272,12 @@
     void spellCheckerMisspelling( const QString &text, const QStringList &, unsigned int pos);
     void spellCheckerCorrected( const QString &, const QString &, unsigned int );
     void spellCheckerFinished();
+    void slotRemoveFromHistory( const QString & );
 
 private:
     enum LineEditMenuID {
-        ClearHistory
+        ClearHistory,
+        EditHistory
     };
     DOM::HTMLInputElementImpl* m_input;
     KHTMLView* m_view;
--- khtml/rendering/render_form.cpp	2007/06/28 13:00:34	1.1
+++ khtml/rendering/render_form.cpp	2007/07/13 08:56:58
@@ -385,7 +385,9 @@
 
     if (m_input->autoComplete()) {
         popup->insertSeparator();
-        int id = popup->insertItem( SmallIconSet("history_clear"), i18n("Clear &History"), ClearHistory );
+        int id = popup->insertItem( SmallIconSet("edit"), i18n("&Edit History..."), EditHistory );
+        popup->setItemEnabled( id, (compObj() && !compObj()->isEmpty()) );
+        id = popup->insertItem( SmallIconSet("history_clear"), i18n("Clear &History"), ClearHistory );
         popup->setItemEnabled( id, (compObj() && !compObj()->isEmpty()) );
     }
 
@@ -409,11 +411,25 @@
         m_view->clearCompletionHistory(m_input->name().string());
         if (compObj())
           compObj()->clear();
+    case EditHistory:
+      {
+        KHistoryComboEditor dlg( compObj() ? compObj()->items() : QStringList(), this );
+        connect( &dlg, SIGNAL( removeFromHistory(const QString&) ), SLOT( slotRemoveFromHistory(const QString&)) );
+        dlg.exec();
+      }
     default:
         break;
     }
 }
 
+void LineEditWidget::slotRemoveFromHistory(const QString &entry)
+{
+    m_view->removeFormCompletionItem(m_input->name().string(), entry);
+    if (compObj())
+       compObj()->removeItem(entry);
+}
+
+
 bool LineEditWidget::event( QEvent *e )
 {
     if (KLineEdit::event(e))
--- kdeui/kcombobox.h	2007/06/28 11:21:53	1.3
+++ kdeui/kcombobox.h	2007/07/13 08:09:41
@@ -24,8 +24,15 @@
 
 #include <qlineedit.h>
 #include <qcombobox.h>
+#include <qvbox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qtoolbutton.h>
+#include <qheader.h>
 
 #include <kcompletion.h>
+#include <kdialogbase.h>
+#include <klistview.h>
 
 class QListBoxItem;
 class QPopupMenu;
@@ -669,6 +676,12 @@
      */
     void reset() { slotReset(); }
 
+    /**
+     * When enabling it you have to connect to "removed" signal and save changes
+    */
+    void setHistoryEditorEnabled( bool enable );
+    bool isHistoryEditorEnabled() const;
+
 public slots:
     /**
      * Adds an item to the end of the history list and to the completion list.
@@ -702,6 +715,8 @@
      */
     void cleared();
 
+    void removed( const QString& item );
+
 protected:
     /**
      * Handling key-events, the shortcuts to rotate the items.
@@ -741,10 +756,17 @@
     void slotClear();
 
     /**
+     * Called from the popupmenu,
+     */
+    void slotEdit();
+
+    /**
      * Appends our own context menu entry.
      */
     void addContextMenuItems( QPopupMenu* );
 
+    void slotRemoveFromHistory( const QString & );
+
 private:
     void init( bool useCompletion );
     void rotateUp();
@@ -774,6 +796,30 @@
     KHistoryComboPrivate* const d;
 };
 
+class KDEUI_EXPORT KHistoryComboEditor : public KDialogBase
+{
+    Q_OBJECT
+
+public:
+    KHistoryComboEditor( const QStringList& entries, QWidget *parent = 0L );
+    ~KHistoryComboEditor();
+
+signals:
+    void removeFromHistory( const QString& );
+
+protected slots:
+    virtual void slotUser1(); // User1 is "Delete Entry" button
+    void slotSelectionChanged( QListViewItem * item );
+
+protected:
+    virtual void virtual_hook( int id, void* data );
+
+private:
+    KListView *m_pListView;
+
+    class KHistoryComboEditorPrivate;
+    KHistoryComboEditorPrivate* const d;
+};
 
 #endif
 
--- kdeui/kcombobox.cpp	2007/06/28 11:52:16	1.1
+++ kdeui/kcombobox.cpp	2007/07/13 09:25:21
@@ -29,6 +29,7 @@
 #include <kcursor.h>
 #include <kiconloader.h>
 #include <kicontheme.h>
+#include <klistviewsearchline.h>
 #include <klineedit.h>
 #include <klocale.h>
 #include <knotifyclient.h>
@@ -343,10 +344,22 @@
 // *********************************************************************
 // *********************************************************************
 
+class KHistoryCombo::KHistoryComboPrivate
+{
+public:
+    KHistoryComboPrivate() : bHistoryEditorEnabled(false)
+    {
+    }
+    ~KHistoryComboPrivate()
+    {
+    }
+
+    bool bHistoryEditorEnabled;
+};
 
 // we are always read-write
 KHistoryCombo::KHistoryCombo( QWidget *parent, const char *name )
-    : KComboBox( true, parent, name ), d(0)
+    : KComboBox( true, parent, name ), d(new KHistoryComboPrivate)
 {
     init( true ); // using completion
 }
@@ -354,7 +367,7 @@
 // we are always read-write
 KHistoryCombo::KHistoryCombo( bool useCompletion,
                               QWidget *parent, const char *name )
-    : KComboBox( true, parent, name ), d(0)
+    : KComboBox( true, parent, name ), d(new KHistoryComboPrivate)
 {
     init( useCompletion );
 }
@@ -441,6 +454,10 @@
     if ( menu )
     {
         menu->insertSeparator();
+        if (d->bHistoryEditorEnabled) {
+           int idedit = menu->insertItem( SmallIconSet("edit"), i18n("&Edit History..."), this, SLOT( slotEdit()) );
+           menu->setItemEnabled(idedit, count());
+        }
         int id = menu->insertItem( SmallIconSet("history_clear"), i18n("Clear &History"), this, SLOT( slotClear()));
         if (!count())
            menu->setItemEnabled(id, false);
@@ -677,10 +694,104 @@
     emit cleared();
 }
 
+void KHistoryCombo::slotEdit()
+{
+    KHistoryComboEditor dlg( historyItems(), this );
+    connect( &dlg, SIGNAL( removeFromHistory(const QString&) ), SLOT( slotRemoveFromHistory(const QString&)) );
+    dlg.exec();
+}
+
+void KHistoryCombo::slotRemoveFromHistory(const QString &entry)
+{
+    removeFromHistory(entry);
+    emit removed(entry);
+}
+
+void KHistoryCombo::setHistoryEditorEnabled( bool enable )
+{
+    d->bHistoryEditorEnabled = enable;
+}
+
+bool KHistoryCombo::isHistoryEditorEnabled() const
+{
+    return d->bHistoryEditorEnabled;
+}
+
 void KComboBox::virtual_hook( int id, void* data )
 { KCompletionBase::virtual_hook( id, data ); }
 
 void KHistoryCombo::virtual_hook( int id, void* data )
 { KComboBox::virtual_hook( id, data ); }
 
+void KHistoryComboEditor::virtual_hook( int id, void* data )
+{ KDialogBase::virtual_hook( id, data ); }
+
+KHistoryComboEditor::KHistoryComboEditor( const QStringList& entries, QWidget *parent )
+: KDialogBase( parent, "khistorycomboeditor", true, i18n( "History Editor" ),
+    KDialogBase::Close | KDialogBase::User1, KDialogBase::User1, true,
+    KGuiItem( i18n( "&Delete Entry" ), "editdelete") ), d(0)
+{
+    QVBox* box = new QVBox( this );
+    box->setSpacing( KDialog::spacingHint() );
+    setMainWidget( box );
+
+    new QLabel( i18n( "This dialog allows you to delete unwanted history items." ), box );
+
+    // Add searchline
+    QHBox* searchbox = new QHBox( box );
+    searchbox->setSpacing( KDialog::spacingHint() );
+
+    QToolButton *clearSearch = new QToolButton(searchbox);
+    clearSearch->setTextLabel(i18n("Clear Search"), true);
+    clearSearch->setIconSet(SmallIconSet(QApplication::reverseLayout() ? "clear_left" : "locationbar_erase"));
+    QLabel* slbl = new QLabel(i18n("&Search:"), searchbox);
+    KListViewSearchLine* listViewSearch = new KListViewSearchLine(searchbox);
+    slbl->setBuddy(listViewSearch);
+    connect(clearSearch, SIGNAL(pressed()), listViewSearch, SLOT(clear()));
+
+    // Add ListView
+    m_pListView = new KListView( box );
+    listViewSearch->setListView(m_pListView);
+    m_pListView->setAllColumnsShowFocus(true);
+    m_pListView->header()->hide();
+    m_pListView->addColumn("");
+    m_pListView->setRenameable( 0 );
+
+    box->setStretchFactor( m_pListView, 1 );
+
+    QStringList newlist = entries;
+    for ( QStringList::Iterator it = newlist.begin(); it != newlist.end(); ++it ) {
+        new QListViewItem( m_pListView, *it );
+    }
+
+    m_pListView->setMinimumSize( m_pListView->sizeHint() );
+
+    connect( m_pListView, SIGNAL( selectionChanged( QListViewItem * ) ),
+             this, SLOT( slotSelectionChanged( QListViewItem * ) ) );
+
+    enableButton( KDialogBase::User1, false );
+
+    resize( sizeHint() );
+}
+
+KHistoryComboEditor::~KHistoryComboEditor()
+{
+}
+
+void KHistoryComboEditor::slotUser1() // Delete button
+{
+    QListViewItem *item = m_pListView->selectedItem();
+
+    if ( item ) {
+       emit removeFromHistory( item->text(0) );
+       m_pListView->takeItem( item );
+       enableButton( KDialogBase::User1, false );
+    }
+}
+
+void KHistoryComboEditor::slotSelectionChanged( QListViewItem * item )
+{
+    enableButton( KDialogBase::User1, item );
+}
+
 #include "kcombobox.moc"
