Warning, file /plasma/milou/lib/test/widgettest.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  * This file is part of the KDE Baloo Project
0003  * SPDX-FileCopyrightText: 2014 Vishesh Handa <me@vhanda.in>
0004  *
0005  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0006  *
0007  */
0008 
0009 #include <QApplication>
0010 #include <QTimer>
0011 #include <QVBoxLayout>
0012 
0013 #include <QListView>
0014 #include <QWidget>
0015 #include <qlineedit.h>
0016 
0017 #include "../sourcesmodel.h"
0018 
0019 using namespace Milou;
0020 
0021 class TestObject : public QWidget
0022 {
0023     Q_OBJECT
0024 public Q_SLOTS:
0025     void main();
0026 
0027 public:
0028     explicit TestObject(QWidget *parent = nullptr, Qt::WindowFlags f = {})
0029         : QWidget(parent, f)
0030     {
0031         QTimer::singleShot(0, this, SLOT(main()));
0032     }
0033 };
0034 
0035 int main(int argc, char **argv)
0036 {
0037     QApplication app(argc, argv);
0038 
0039     TestObject obj;
0040     obj.show();
0041 
0042     return app.exec();
0043 }
0044 
0045 void TestObject::main()
0046 {
0047     SourcesModel *smodel = new SourcesModel(this);
0048     smodel->setQueryLimit(20);
0049 
0050     QListView *view = new QListView(this);
0051     view->setModel(smodel);
0052     view->setAlternatingRowColors(true);
0053 
0054     QLineEdit *edit = new QLineEdit(this);
0055     connect(edit, SIGNAL(textChanged(QString)), smodel, SLOT(setQueryString(QString)));
0056 
0057     QVBoxLayout *l = new QVBoxLayout(this);
0058     l->addWidget(edit);
0059     l->addWidget(view);
0060 }
0061 
0062 #include "widgettest.moc"