Feature(frontend):Add double click event to search list view.
新增搜索结果列表双击打开功能.
This commit is contained in:
parent
0f1229f945
commit
dbb3c6661d
|
@ -305,6 +305,27 @@ void ContentWidget::setupConnect(SearchListView * listview) {
|
|||
m_resultListArea->ensureVisible(pos.x(),pos.y());
|
||||
});
|
||||
connect(listview,&SearchListView::mousePressed,this,&ContentWidget::mousePressed);
|
||||
connect(listview, &SearchListView::onRowDoubleClicked, [ = ](const int& type, const QString& path) {
|
||||
qDebug()<<"A row has been double clicked.Type = "<<type<<"; Name = "<<path;
|
||||
if (type == SearchItem::SearchType::Best && m_bestList.at(listview->currentIndex().row()).first != SearchItem::SearchType::Apps) {
|
||||
m_detailView->doubleClickAction(m_bestList.at(listview->currentIndex().row()).first, path);
|
||||
} else if (type == SearchItem::SearchType::Best && m_bestList.at(listview->currentIndex().row()).first == SearchItem::SearchType::Apps) {
|
||||
if (m_appPathList.at(0) == "" || m_appPathList.at(0).isEmpty()){
|
||||
m_detailView->doubleClickAction(SearchListView::ResType::App, m_appList.at(0));
|
||||
} else {
|
||||
m_detailView->doubleClickAction(SearchListView::ResType::App, m_appPathList.at(0));
|
||||
}
|
||||
} else if (type == SearchItem::SearchType::Apps) {
|
||||
int index = listview->currentIndex().row();
|
||||
if (m_appPathList.at(index) == "" || m_appPathList.at(index).isEmpty()){
|
||||
m_detailView->doubleClickAction(SearchListView::ResType::App, m_appList.at(index));
|
||||
} else {
|
||||
m_detailView->doubleClickAction(SearchListView::ResType::App, m_appPathList.at(index));
|
||||
}
|
||||
} else {
|
||||
m_detailView->doubleClickAction(type, path);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -243,6 +243,25 @@ void SearchDetailView::closeWebWidget()
|
|||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SearchDetailView::doubleClickAction 处理搜索结果列表选项双击事件
|
||||
* @param type
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
bool SearchDetailView::doubleClickAction(const int &type, const QString &path)
|
||||
{
|
||||
if (type == SearchListView::ResType::App) {
|
||||
if (path.contains(".desktop")) {
|
||||
return openAction(type, path);
|
||||
} else {
|
||||
return installAppAction(path.mid(path.indexOf("/") + 1));
|
||||
}
|
||||
} else {
|
||||
return openAction(type, path);
|
||||
}
|
||||
}
|
||||
|
||||
QString SearchDetailView::getHtmlText(const QString & text, const QString & keyword) {
|
||||
QString htmlString;
|
||||
bool boldOpenned = false;
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
void setWebWidget(const QString&);
|
||||
void setAppWidget(const QString &name, const QString &path, const QString &icon, const QString &description);
|
||||
void closeWebWidget();
|
||||
bool doubleClickAction(const int&, const QString&);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *);
|
||||
|
|
|
@ -161,6 +161,12 @@ void SearchListView::mousePressEvent(QMouseEvent *event)
|
|||
QTreeView::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void SearchListView::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
Q_EMIT this->onRowDoubleClicked(getCurrentType(), m_item->m_pathlist.at(this->currentIndex().row()));
|
||||
QTreeView::mouseDoubleClickEvent(event);
|
||||
}
|
||||
|
||||
//获取当前选项所属搜索类型
|
||||
int SearchListView::getCurrentType() {
|
||||
switch (m_type) {
|
||||
|
|
|
@ -63,6 +63,7 @@ public:
|
|||
bool isHidden = false;
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||
private:
|
||||
SearchItemModel * m_model = nullptr;
|
||||
SearchItem * m_item = nullptr;
|
||||
|
@ -74,6 +75,7 @@ private:
|
|||
|
||||
Q_SIGNALS:
|
||||
void currentRowChanged(const int&, const QString&);
|
||||
void onRowDoubleClicked(const int&, const QString&);
|
||||
void currentSelectPos(QPoint pos);
|
||||
void mousePressed();
|
||||
|
||||
|
|
Loading…
Reference in New Issue