File indexing completed on 2024-05-05 03:56:58

0001 /*
0002     SPDX-FileCopyrightText: 2021 Wolthera van Hövell tot Westerflier <griffinvalley@gmail.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #ifndef SEARCHPRESETMODEL_H
0008 #define SEARCHPRESETMODEL_H
0009 
0010 #include "provider.h"
0011 #include "quickengine.h"
0012 #include <QAbstractListModel>
0013 
0014 /**
0015  * @brief The SearchPresetModel class
0016  *
0017  * this class handles search presets.
0018  * @since 5.83
0019  */
0020 class SearchPresetModel : public QAbstractListModel
0021 {
0022     Q_OBJECT
0023 public:
0024     explicit SearchPresetModel(KNSCore::EngineBase *parent);
0025     ~SearchPresetModel() override;
0026 
0027     enum Roles {
0028         DisplayNameRole = Qt::UserRole + 1,
0029         IconRole,
0030     };
0031     Q_ENUM(Roles)
0032 
0033     QHash<int, QByteArray> roleNames() const override;
0034 
0035     QVariant data(const QModelIndex &index, int role = DisplayNameRole) const override;
0036     int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0037 
0038     Q_INVOKABLE void loadSearch(const QModelIndex &index);
0039 
0040 private:
0041     KNSCore::EngineBase *const m_engine;
0042 };
0043 
0044 #endif // SEARCHPRESETMODEL_H