2021-08-02 13:46:59 +08:00
|
|
|
#ifndef BESTLISTMODEL_H
|
|
|
|
#define BESTLISTMODEL_H
|
|
|
|
|
|
|
|
#include <QAbstractItemModel>
|
|
|
|
#include "search-result-model.h"
|
|
|
|
|
|
|
|
#define NUM_LIMIT_SHOWN_DEFAULT 5
|
|
|
|
|
2021-12-14 14:43:35 +08:00
|
|
|
namespace UkuiSearch {
|
2021-08-02 13:46:59 +08:00
|
|
|
class BestListModel : public QAbstractItemModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit BestListModel(QObject *parent = nullptr);
|
|
|
|
|
2021-08-18 14:23:14 +08:00
|
|
|
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
2021-08-02 13:46:59 +08:00
|
|
|
QModelIndex parent(const QModelIndex &index) const override;
|
|
|
|
|
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
|
|
|
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
|
|
|
|
|
|
|
const SearchPluginIface::ResultInfo & getInfo(const QModelIndex&);
|
|
|
|
const QString & getPluginInfo(const QModelIndex&);
|
|
|
|
|
|
|
|
void setExpanded(const bool&);
|
|
|
|
const bool &isExpanded();
|
|
|
|
|
|
|
|
QStringList getActions(const QModelIndex &);
|
|
|
|
QString getKey(const QModelIndex &);
|
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
void appendInfo(const QString &, const SearchPluginIface::ResultInfo &);
|
2022-11-22 10:17:36 +08:00
|
|
|
void removeInfo(const QString &);
|
|
|
|
void moveInfo(const QString &pluginName, const int pos);
|
2021-08-02 13:46:59 +08:00
|
|
|
void startSearch(const QString &);
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void stopSearch();
|
|
|
|
void itemListChanged(const int&);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void initConnections();
|
|
|
|
SearchResultItem * m_item = nullptr;
|
|
|
|
QVector<QString> m_plugin_id_list;
|
2021-10-27 11:37:55 +08:00
|
|
|
QVector<QString> m_plugin_action_key_list;
|
2021-08-02 13:46:59 +08:00
|
|
|
bool m_isExpanded = false;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif // BESTLISTMODEL_H
|