File indexing completed on 2024-12-01 04:36:37

0001 /*
0002    SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "completionlineedit.h"
0008 #include "completionlistview.h"
0009 #include <KLineEditEventHandler>
0010 
0011 CompletionLineEdit::CompletionLineEdit(QWidget *parent)
0012     : QLineEdit(parent)
0013     , mCompletionListView(new CompletionListView)
0014 {
0015     setClearButtonEnabled(true);
0016     KLineEditEventHandler::catchReturnKey(this);
0017 
0018     mCompletionListView->setTextWidget(this);
0019 
0020     connect(mCompletionListView, &CompletionListView::complete, this, &CompletionLineEdit::complete);
0021 }
0022 
0023 CompletionLineEdit::~CompletionLineEdit()
0024 {
0025     delete mCompletionListView;
0026 }
0027 
0028 void CompletionLineEdit::setCompletionModel(QAbstractItemModel *model)
0029 {
0030     mCompletionListView->setModel(model);
0031 }
0032 
0033 #include "moc_completionlineedit.cpp"