Pimcommon
7#include "lineeditwithcompleterng.h"
8#include <KLocalizedString>
10#include <QContextMenuEvent>
12#include <QStringListModel>
15#define MAX_COMPLETION_ITEMS 20
16LineEditWithCompleterNg::LineEditWithCompleterNg(
QWidget *parent)
22 completer->setModel(mCompleterListModel);
23 setCompleter(completer);
26LineEditWithCompleterNg::~LineEditWithCompleterNg() =
default;
28void LineEditWithCompleterNg::addCompletionItem(
const QString &str)
30 mListCompetion.removeAll(str);
31 mListCompetion.prepend(str);
32 while (mListCompetion.size() > MAX_COMPLETION_ITEMS) {
33 mListCompetion.removeLast();
35 mCompleterListModel->setStringList(mListCompetion);
38void LineEditWithCompleterNg::contextMenuEvent(QContextMenuEvent *e)
44 i18n(
"Clear History"),
46 &LineEditWithCompleterNg::slotClearHistory);
52void LineEditWithCompleterNg::slotClearHistory()
54 mListCompetion.clear();
55 mCompleterListModel->setStringList(mListCompetion);
58#include "moc_lineeditwithcompleterng.cpp"
QString i18n(const char *text, const TYPE &arg...)
QIcon fromTheme(const QString &name)
QMenu * createStandardContextMenu()
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:47:24 by
doxygen 1.13.2 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.