2021-05-22 21:29:43 +08:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020, KylinSoft Co., Ltd.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Authors: zhangjiaping <zhangjiaping@kylinos.cn>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#ifndef SEARCHRESULTMODEL_H
|
|
|
|
#define SEARCHRESULTMODEL_H
|
|
|
|
#include <QAbstractItemModel>
|
|
|
|
#include "search-result-manager.h"
|
|
|
|
|
2021-05-27 10:25:15 +08:00
|
|
|
#define NUM_LIMIT_SHOWN_DEFAULT 5
|
|
|
|
|
2021-05-22 21:29:43 +08:00
|
|
|
namespace Zeeker {
|
|
|
|
|
|
|
|
class SearchResultItem : public QObject {
|
|
|
|
friend class SearchResultModel;
|
2021-08-02 13:46:59 +08:00
|
|
|
friend class BestListModel;
|
2021-09-08 11:03:43 +08:00
|
|
|
friend class WebSearchModel;
|
2021-05-22 21:29:43 +08:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit SearchResultItem(QObject *parent = nullptr);
|
|
|
|
~SearchResultItem() = default;
|
|
|
|
private:
|
|
|
|
//此插件所有搜索结果<具体信息>
|
|
|
|
QVector<SearchPluginIface::ResultInfo> m_result_info_list;
|
|
|
|
};
|
|
|
|
class SearchResultModel : public QAbstractItemModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
SearchResultModel(const QString &plugin_id);
|
|
|
|
~SearchResultModel() = default;
|
2021-08-18 14:23:14 +08:00
|
|
|
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
2021-05-22 21:29:43 +08:00
|
|
|
QModelIndex parent(const QModelIndex &child) const override;
|
|
|
|
int rowCount(const QModelIndex &parent) const override;
|
|
|
|
int columnCount(const QModelIndex &parent) const override;
|
|
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
|
|
|
// bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex())override;
|
|
|
|
const SearchPluginIface::ResultInfo & getInfo(const QModelIndex&);
|
2021-05-27 10:25:15 +08:00
|
|
|
void setExpanded(const bool&);
|
|
|
|
const bool &isExpanded();
|
|
|
|
QStringList getActions(const QModelIndex &);
|
|
|
|
QString getKey(const QModelIndex &);
|
2021-05-22 21:29:43 +08:00
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
void appendInfo(const SearchPluginIface::ResultInfo &);
|
2021-05-25 19:42:40 +08:00
|
|
|
void startSearch(const QString &);
|
2021-05-22 21:29:43 +08:00
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void stopSearch();
|
2021-05-27 10:25:15 +08:00
|
|
|
void itemListChanged(const int&);
|
2021-08-02 13:46:59 +08:00
|
|
|
void sendBestListData(const QString &, const SearchPluginIface::ResultInfo&);
|
2021-05-22 21:29:43 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
void initConnections();
|
|
|
|
SearchResultItem * m_item = nullptr;
|
|
|
|
QString m_plugin_id;
|
|
|
|
SearchResultManager * m_search_manager = nullptr;
|
2021-05-27 10:25:15 +08:00
|
|
|
bool m_isExpanded = false;
|
2021-05-22 21:29:43 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // SEARCHRESULTMODEL_H
|