ukui-search/frontend/view/best-list-view.h

115 lines
3.0 KiB
C
Raw Normal View History

2021-08-02 13:46:59 +08:00
#ifndef BESTLISTVIEW_H
#define BESTLISTVIEW_H
#include <QTreeView>
#include <QVBoxLayout>
#include <QLabel>
#include <QMenu>
#include <QApplication>
#include "best-list-model.h"
#include "show-more-label.h"
#include "title-label.h"
#include "result-view-delegate.h"
2021-12-14 14:43:35 +08:00
namespace UkuiSearch {
2021-08-02 13:46:59 +08:00
class BestListView : public QTreeView
{
Q_OBJECT
public:
BestListView(QWidget *parent = nullptr);
~BestListView() = default;
2021-08-18 14:23:14 +08:00
2021-08-02 13:46:59 +08:00
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);
const QString getPluginInfo(const QModelIndex&index);
int getResultHeight();
2021-08-02 13:46:59 +08:00
public Q_SLOTS:
void clearSelectedRow();
void onRowDoubleClickedSlot(const QModelIndex &);
2021-08-18 14:23:14 +08:00
void onRowSelectedSlot(const QModelIndex &index);
2021-08-02 13:46:59 +08:00
void onItemListChanged(const int &);
void setExpanded(const bool &);
const bool &isExpanded();
void onMenuTriggered(QAction *);
protected:
2021-09-08 16:34:32 +08:00
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent * event);
2021-09-09 11:23:59 +08:00
void mouseMoveEvent(QMouseEvent *event);
bool viewportEvent(QEvent *event);
2021-08-02 13:46:59 +08:00
private:
void initConnections();
2021-08-18 14:23:14 +08:00
2021-08-02 13:46:59 +08:00
BestListModel * m_model = nullptr;
bool m_is_selected = false;
2022-06-15 15:54:50 +08:00
ResultViewDelegate * m_styleDelegate = nullptr;
2021-08-02 13:46:59 +08:00
int m_count = 0;
2021-09-08 16:34:32 +08:00
QModelIndex m_tmpCurrentIndex;
QModelIndex m_tmpMousePressIndex;
QTimer *m_touchTimer;
2021-08-02 13:46:59 +08:00
Q_SIGNALS:
void startSearch(const QString &);
void currentRowChanged(const QString &, const SearchPluginIface::ResultInfo&);
void sendBestListData(const QString &, const SearchPluginIface::ResultInfo&);
void listLengthChanged(const int &);
void rowClicked();
};
class BestListWidget : public QWidget
{
Q_OBJECT
public:
BestListWidget(QWidget *parent = nullptr);
~BestListWidget() = default;
2021-08-18 14:23:14 +08:00
QString getWidgetName();
void setEnabled(const bool&);
void clearResult();
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);
const QString getPluginInfo(const QModelIndex&index);
int getResultHeight();
2021-08-02 13:46:59 +08:00
private:
void initUi();
void initConnections();
2021-08-18 14:23:14 +08:00
bool m_enabled = true;
2021-08-02 13:46:59 +08:00
QVBoxLayout * m_mainLyt = nullptr;
TitleLabel * m_titleLabel = nullptr;
BestListView * m_bestListView = nullptr;
2021-08-18 14:23:14 +08:00
public Q_SLOTS:
void expandListSlot();
void reduceListSlot();
void onListLengthChanged(const int &);
2021-08-02 13:46:59 +08:00
Q_SIGNALS:
void startSearch(const QString &);
void stopSearch();
void currentRowChanged(const QString &, const SearchPluginIface::ResultInfo&);
void sendBestListData(const QString &, const SearchPluginIface::ResultInfo&);
void clearSelectedRow();
void sizeChanged();
void rowClicked();
2021-08-18 14:23:14 +08:00
2021-08-02 13:46:59 +08:00
};
}
#endif // BESTLISTVIEW_H