Allow to clear completion history

Review Request #125484 - Created Oct. 2, 2015 and updated

Information
Laurent Montel
kcompletion
master
Reviewers
kdeframeworks
dfaure

In a application we can't remove history until we close it. It can be problematic when we add a critical word as password etc.

Tested in kdepim from long time ago.
Tested in klineedittest apps.

David Faure

Looks ok to me, except that KHistoryComboBox also adds such a menu item to the KLineEdit popup. Can you check if it has it twice now? I would expect so. In that case you could remove the action+slot from KHistoryComboBox then? (compare the slots to be sure it's the same logic).

  1. it's not totally the same logic

    it will clear the combobox + textline too.

    I will add a test application for khistorycombobox soon to test it.

    void KHistoryComboBox::clearHistory()
    {
    const QString temp = currentText();
    KComboBox::clear();
    if (useCompletion()) {
    completionObject()->clear();
    }
    setEditText(temp);
    }

    void KHistoryComboBoxPrivate::_k_addContextMenuItems(QMenu menu)
    {
    Q_Q(KHistoryComboBox);
    if (menu) {
    menu->addSeparator();
    QAction
    clearHistory = menu->addAction(QIcon::fromTheme("edit-clear-history"),
    KHistoryComboBox::tr("Clear &History"),
    q, SLOT(_k_clear()));
    if (!q->count()) {
    clearHistory->setEnabled(false);
    }
    }
    }

  2. There is a test in source "kcompletionuitest"
    so not necessary to create a new test.

  3. indeed it create 2 "clear history"
    I will investigate how to replace it.

  4. This doesn't clear the text line (QLineEdit), on the contrary, it saves and restores its contents.
    But indeed, when we have a combo, there are the combo items to clear as well, not just the completion.

    So I think KLineEdit needs to emit a signal when its action is triggered, so that KHistoryComboBox can add "clearing the combo".
    (I guess not KComboBox, which could have application-provided items, unrelated to completion/history)

Loading...