ukui-search/frontend/view/result-view.h

103 lines
2.8 KiB
C
Raw Normal View History

#ifndef RESULTVIEW_H
#define RESULTVIEW_H
#include <QTreeView>
#include <QVBoxLayout>
#include <QLabel>
#include <QMenu>
#include <QApplication>
#include "search-result-model.h"
#include "show-more-label.h"
#include "title-label.h"
2021-05-25 19:42:40 +08:00
#include "result-view-delegate.h"
namespace Zeeker {
class ResultView : public QTreeView
{
Q_OBJECT
public:
ResultView(const QString &plugin_id, QWidget *parent = nullptr);
~ResultView() = default;
bool isSelected();
int showHeight();
2021-08-18 14:23:14 +08:00
int getResultNum();
QModelIndex getModlIndex(int row, int column);
SearchPluginIface::ResultInfo getIndexResultInfo(QModelIndex &index);
public Q_SLOTS:
void clearSelectedRow();
2021-05-25 19:42:40 +08:00
void onRowDoubleClickedSlot(const QModelIndex &);
2021-08-18 14:23:14 +08:00
void onRowSelectedSlot(const QModelIndex &index);
void onItemListChanged(const int &);
void setExpanded(const bool &);
const bool &isExpanded();
void onMenuTriggered(QAction *);
protected:
void mousePressEvent(QMouseEvent *event) override;
private:
void initConnections();
SearchResultModel * m_model = nullptr;
QString m_plugin_id;
bool m_is_selected = false;
2021-05-25 19:42:40 +08:00
ResultViewDelegate * m_style_delegate = nullptr;
int m_count = 0;
Q_SIGNALS:
void startSearch(const QString &);
void stopSearch();
void currentRowChanged(const QString &, const SearchPluginIface::ResultInfo&);
2021-08-02 13:46:59 +08:00
void sendBestListData(const QString &, const SearchPluginIface::ResultInfo&);
void listLengthChanged(const int &);
void rowClicked();
void lableReset();
};
class ResultWidget : public QWidget
{
Q_OBJECT
public:
ResultWidget(const QString &plugin_id, QWidget *parent = nullptr);
~ResultWidget() = default;
QString pluginId();
void setEnabled(const bool&);
void clearResult();
2021-08-18 14:23:14 +08:00
int getResultNum();
void setResultSelection(const QModelIndex &index);
void clearResultSelection();
QModelIndex getModlIndex(int row, int column);
void activateIndex();
QModelIndex getCurrentSelection();
bool getExpandState();
SearchPluginIface::ResultInfo getIndexResultInfo(QModelIndex &index);
2021-05-25 19:42:40 +08:00
public Q_SLOTS:
void expandListSlot();
void reduceListSlot();
void onListLengthChanged(const int &);
2021-05-25 19:42:40 +08:00
private:
QString m_plugin_id;
bool m_enabled = true;
void initUi();
void initConnections();
QVBoxLayout * m_mainLyt = nullptr;
TitleLabel * m_titleLabel = nullptr;
ResultView * m_resultView = nullptr;
Q_SIGNALS:
void startSearch(const QString &);
void stopSearch();
void currentRowChanged(const QString &, const SearchPluginIface::ResultInfo&);
2021-08-02 13:46:59 +08:00
void sendBestListData(const QString &, const SearchPluginIface::ResultInfo&);
void clearSelectedRow();
void sizeChanged();
void rowClicked();
void resizeWidth(const int &);
};
}
#endif // RESULTVIEW_H