ukui-search/frontend/control/stack-pages/search-page-section.h

145 lines
3.8 KiB
C
Raw Permalink Normal View History

/*
*
* 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 SEARCHPAGESECTION_H
#define SEARCHPAGESECTION_H
#include <QScrollArea>
#include <QScrollBar>
#include <QPaintEvent>
#include <QPainter>
#include <QStyleOption>
#include "result-view.h"
2021-07-05 14:27:14 +08:00
#include "search-plugin-iface.h"
2021-08-02 13:46:59 +08:00
#include "best-list-view.h"
2021-12-14 14:43:35 +08:00
namespace UkuiSearch {
class ResultScrollBar : public QScrollBar
{
Q_OBJECT
public:
ResultScrollBar(QWidget *parent = nullptr);
~ResultScrollBar() = default;
protected:
void showEvent(QShowEvent *event);
void hideEvent(QHideEvent *event);
Q_SIGNALS:
void scrollBarAppeared();
void scrollBarIsHideen();
};
class ResultArea : public QScrollArea
{
Q_OBJECT
public:
ResultArea(QWidget *parent = nullptr);
~ResultArea() = default;
void appendWidet(ResultWidget *);
void insertWidget(ResultWidget *widget, int index);
bool removeWidget(const QString& pluginName);
bool moveWidget(const QString& pluginName, int index);
void setVisibleList(const QStringList &);
2021-08-18 14:23:14 +08:00
void pressEnter();
void pressDown();
void pressUp();
int getVScrollBarWidth();
2021-08-18 14:23:14 +08:00
void setResultSelection();
bool getSelectedState();
void sendKeyPressSignal(QString &pluginID);
public Q_SLOTS:
void onWidgetSizeChanged();
2021-08-18 14:23:14 +08:00
void setSelectionInfo(QString &pluginID);
2021-11-02 16:59:25 +08:00
2021-09-27 17:25:06 +08:00
protected:
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
bool viewportEvent(QEvent *event);
private:
void initUi();
2021-08-02 13:46:59 +08:00
void initConnections();
void setupConnectionsForWidget(ResultWidget *);
2021-08-18 14:23:14 +08:00
QWidget * m_widget = nullptr;
QVBoxLayout * m_mainLyt = nullptr;
BestListWidget * m_bestListWidget = nullptr;
QList<ResultWidget *> m_widget_list;
TitleLabel * m_titleLabel = nullptr;
ResultScrollBar *m_scrollBar = nullptr;
2021-08-18 14:23:14 +08:00
bool m_detail_open_state = false;
bool m_is_selected = false;
QString m_selectedPluginID;
2021-09-27 17:25:06 +08:00
QPoint m_pressPoint;
2021-08-18 14:23:14 +08:00
Q_SIGNALS:
void startSearch(const QString &);
void stopSearch();
2021-08-02 13:46:59 +08:00
void currentRowChanged(const QString &, const SearchPluginIface::ResultInfo&);
2021-08-18 14:23:14 +08:00
void keyPressChanged(const QString &, const SearchPluginIface::ResultInfo&);
2021-08-02 13:46:59 +08:00
void clearSelectedRow();
void resizeHeight(int height);
void resizeWidth(const int &);
void rowClicked();
void scrollBarAppeared();
void scrollBarIsHideen();
};
class DetailWidget : public QWidget
{
Q_OBJECT
public:
DetailWidget(QWidget *parent = nullptr);
~DetailWidget() = default;
public Q_SLOTS:
void updateDetailPage(const QString &plugin_name, const SearchPluginIface::ResultInfo &info);
protected:
void paintEvent(QPaintEvent *event);
private:
void clearLayout(QLayout *);
QVBoxLayout * m_mainLyt = nullptr;
QString m_currentPluginId;
QWidget *m_detailPage = nullptr;
};
class DetailArea : public QScrollArea
{
Q_OBJECT
public:
DetailArea(QWidget *parent = nullptr);
~DetailArea() = default;
private:
void initUi();
DetailWidget * m_detailWidget = nullptr;
Q_SIGNALS:
void setWidgetInfo(const QString&, const SearchPluginIface::ResultInfo&);
};
}
#endif // SEARCHPAGESECTION_H