File indexing completed on 2024-04-28 03:56:49
0001 /* 0002 SPDX-FileCopyrightText: 2023 Alexander Lohnau <alexander.lohnau@gmx.de> 0003 SPDX-License-Identifier: LGPL-2.0-or-later 0004 */ 0005 0006 #include <QApplication> 0007 #include <QLineEdit> 0008 #include <QListView> 0009 #include <QVBoxLayout> 0010 #include <QWidget> 0011 0012 #include <KRunner/ResultsModel> 0013 0014 using namespace KRunner; 0015 0016 class TestObject : public QWidget 0017 { 0018 Q_OBJECT 0019 public: 0020 explicit TestObject() 0021 : QWidget() 0022 { 0023 ResultsModel *model = new ResultsModel(this); 0024 // Comment this line out to load all the system runners 0025 model->runnerManager()->loadRunner(KPluginMetaData::findPluginById(QStringLiteral("krunnertest"), QStringLiteral("fakerunnerplugin"))); 0026 0027 QListView *view = new QListView(this); 0028 view->setModel(model); 0029 view->setAlternatingRowColors(true); 0030 0031 QLineEdit *edit = new QLineEdit(this); 0032 connect(edit, &QLineEdit::textChanged, model, &ResultsModel::setQueryString); 0033 edit->setText("foo"); 0034 0035 QVBoxLayout *l = new QVBoxLayout(this); 0036 l->addWidget(edit); 0037 l->addWidget(view); 0038 } 0039 }; 0040 0041 int main(int argc, char **argv) 0042 { 0043 QApplication app(argc, argv); 0044 0045 TestObject obj; 0046 obj.show(); 0047 0048 return app.exec(); 0049 } 0050 0051 #include "modelwidgettest.moc"