Merge branch 'main' into '0330-dev'
# Conflicts: # libsearch/index/first-index.h # libsearch/index/inotify-index.h
This commit is contained in:
commit
3c014ff917
|
@ -35,8 +35,8 @@ FirstIndex::FirstIndex(const QString& path) : Traverse_BFS(path)
|
|||
qDebug() << "contentIndexDataBaseStatus: " << contentIndexDataBaseStatus;
|
||||
qDebug() << "inotifyIndexStatus: " << inotifyIndexStatus;
|
||||
|
||||
|
||||
if (indexDataBaseStatus == "" || contentIndexDataBaseStatus == ""){
|
||||
/* || contentIndexDataBaseStatus == ""*/
|
||||
if (indexDataBaseStatus == ""){
|
||||
this->bool_dataBaseExist = false;
|
||||
}
|
||||
else{
|
||||
|
@ -75,7 +75,7 @@ FirstIndex::~FirstIndex()
|
|||
void FirstIndex::DoSomething(const QFileInfo& fileInfo){
|
||||
// qDebug() << "there are some shit here"<<fileInfo.fileName() << fileInfo.absoluteFilePath() << QString(fileInfo.isDir() ? "1" : "0");
|
||||
this->q_index->enqueue(QVector<QString>() << fileInfo.fileName() << fileInfo.absoluteFilePath() << QString((fileInfo.isDir() && (!fileInfo.isSymLink())) ? "1" : "0"));
|
||||
if ((!fileInfo.fileName().split(".").isEmpty()) && (true == targetFileTypeMap[fileInfo.fileName().split(".").last()])){
|
||||
if ((fileInfo.fileName().split(".", QString::SkipEmptyParts).length() > 1) && (true == targetFileTypeMap[fileInfo.fileName().split(".").last()])){
|
||||
this->q_content_index->enqueue(fileInfo.absoluteFilePath());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ void InotifyIndex::DoSomething(const QFileInfo& fileInfo){
|
|||
QQueue<QVector<QString> > tempFile;
|
||||
tempFile.enqueue(QVector<QString>() << fileInfo.fileName() << fileInfo.absoluteFilePath() << QString((fileInfo.isDir() && (!fileInfo.isSymLink())) ? "1" : "0"));
|
||||
IndexGenerator::getInstance()->creatAllIndex(&tempFile);
|
||||
if ((!fileInfo.fileName().split(".").isEmpty()) && (true == targetFileTypeMap[fileInfo.fileName().split(".").last()])){
|
||||
if ((fileInfo.fileName().split(".", QString::SkipEmptyParts).length() > 1) && (true == targetFileTypeMap[fileInfo.fileName().split(".").last()])){
|
||||
QQueue<QString> tmp;
|
||||
tmp.enqueue(fileInfo.absoluteFilePath());
|
||||
IndexGenerator::getInstance()->creatAllIndex(&tmp);
|
||||
|
|
|
@ -30,6 +30,7 @@ void Traverse_BFS::Traverse(){
|
|||
bfs.enqueue(this->path);
|
||||
QFileInfoList list;
|
||||
QDir dir;
|
||||
// QDir::Hidden
|
||||
dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
|
||||
dir.setSorting(QDir::DirsFirst);
|
||||
while (!bfs.empty()) {
|
||||
|
|
|
@ -260,39 +260,6 @@ void ContentWidget::hideListView()
|
|||
* @param listview
|
||||
*/
|
||||
void ContentWidget::setupConnect(SearchListView * listview) {
|
||||
connect(listview, &SearchListView::currentRowChanged, this, [ = ](const int& type, const QString& path) {
|
||||
if(type == SearchItem::SearchType::Contents && !m_contentDetailList.isEmpty()) {
|
||||
m_detailView->isContent = true;
|
||||
m_detailView->setContent(m_contentDetailList.at(listview->currentIndex().row()), m_keyword);
|
||||
} else if (type == SearchItem::SearchType::Best && !m_bestContent.isEmpty() && listview->currentIndex().row() == listview->getLength() - 1) {
|
||||
m_detailView->setContent(m_bestContent, m_keyword);
|
||||
m_detailView->isContent = true;
|
||||
m_detailView->setupWidget(SearchItem::SearchType::Contents, path);
|
||||
listview->is_current_list = true;
|
||||
Q_EMIT this->currentItemChanged();
|
||||
listview->is_current_list = false;
|
||||
return;
|
||||
} else {
|
||||
m_detailView->isContent = false;
|
||||
}
|
||||
if (type == SearchItem::SearchType::Web) {
|
||||
m_detailView->setWebWidget(this->m_keyword);
|
||||
} else if (type == SearchItem::SearchType::Apps) {
|
||||
int index = listview->currentIndex().row();
|
||||
m_detailView->setAppWidget(m_appList.at(index), m_appPathList.at(index), m_appIconList.at(index), m_appDescList.at(index));
|
||||
} else if (type == SearchItem::SearchType::Best) {
|
||||
if (m_bestList.at(listview->currentIndex().row()).first == SearchItem::SearchType::Apps) {
|
||||
m_detailView->setAppWidget(m_appList.at(0), m_appPathList.at(0), m_appIconList.at(0), m_appDescList.at(0));
|
||||
} else {
|
||||
m_detailView->setupWidget(m_bestList.at(listview->currentIndex().row()).first, m_bestList.at(listview->currentIndex().row()).second);
|
||||
}
|
||||
} else {
|
||||
m_detailView->setupWidget(type, path);
|
||||
}
|
||||
listview->is_current_list = true;
|
||||
Q_EMIT this->currentItemChanged();
|
||||
listview->is_current_list = false;
|
||||
});
|
||||
connect(this, &ContentWidget::currentItemChanged, listview, [ = ]() {
|
||||
|
||||
if (! listview->is_current_list) {
|
||||
|
@ -305,6 +272,8 @@ void ContentWidget::setupConnect(SearchListView * listview) {
|
|||
m_resultListArea->ensureVisible(pos.x(),pos.y());
|
||||
});
|
||||
connect(listview,&SearchListView::mousePressed,this,&ContentWidget::mousePressed);
|
||||
connect(listview, SIGNAL(currentRowChanged(SearchListView *,const int&, const QString&)), this, SLOT(onListViewRowChanged(SearchListView *, const int&, const QString&)));
|
||||
connect(listview, SIGNAL(onRowDoubleClicked(SearchListView *,const int&, const QString&)), this, SLOT(onListViewRowDoubleClicked(SearchListView *, const int&, const QString&)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -731,6 +700,74 @@ void ContentWidget::clearLayout(QLayout * layout) {
|
|||
child = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ContentWidget::onListViewRowChanged 点击某列表某一行的槽函数
|
||||
* @param type
|
||||
* @param path
|
||||
*/
|
||||
void ContentWidget::onListViewRowChanged(SearchListView * listview, const int &type, const QString &path)
|
||||
{
|
||||
if(type == SearchItem::SearchType::Contents && !m_contentDetailList.isEmpty()) {
|
||||
m_detailView->isContent = true;
|
||||
m_detailView->setContent(m_contentDetailList.at(listview->currentIndex().row()), m_keyword);
|
||||
} else if (type == SearchItem::SearchType::Best && !m_bestContent.isEmpty() && listview->currentIndex().row() == listview->getLength() - 1) {
|
||||
m_detailView->setContent(m_bestContent, m_keyword);
|
||||
m_detailView->isContent = true;
|
||||
m_detailView->setupWidget(SearchItem::SearchType::Contents, path);
|
||||
listview->is_current_list = true;
|
||||
Q_EMIT this->currentItemChanged();
|
||||
listview->is_current_list = false;
|
||||
return;
|
||||
} else {
|
||||
m_detailView->isContent = false;
|
||||
}
|
||||
if (type == SearchItem::SearchType::Web) {
|
||||
m_detailView->setWebWidget(this->m_keyword);
|
||||
} else if (type == SearchItem::SearchType::Apps) {
|
||||
int index = listview->currentIndex().row();
|
||||
m_detailView->setAppWidget(m_appList.at(index), m_appPathList.at(index), m_appIconList.at(index), m_appDescList.at(index));
|
||||
} else if (type == SearchItem::SearchType::Best) {
|
||||
if (m_bestList.at(listview->currentIndex().row()).first == SearchItem::SearchType::Apps) {
|
||||
m_detailView->setAppWidget(m_appList.at(0), m_appPathList.at(0), m_appIconList.at(0), m_appDescList.at(0));
|
||||
} else {
|
||||
m_detailView->setupWidget(m_bestList.at(listview->currentIndex().row()).first, m_bestList.at(listview->currentIndex().row()).second);
|
||||
}
|
||||
} else {
|
||||
m_detailView->setupWidget(type, path);
|
||||
}
|
||||
listview->is_current_list = true;
|
||||
Q_EMIT this->currentItemChanged();
|
||||
listview->is_current_list = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ContentWidget::onListViewRowDoubleClicked 双击某列表某一行的槽函数
|
||||
* @param type
|
||||
* @param path
|
||||
*/
|
||||
void ContentWidget::onListViewRowDoubleClicked(SearchListView * listview, 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief ContentWidget::setContentList 文本内容搜索结果列表(包含所有文本段)
|
||||
|
|
|
@ -113,6 +113,8 @@ Q_SIGNALS:
|
|||
|
||||
private Q_SLOTS:
|
||||
void clearLayout(QLayout *);
|
||||
void onListViewRowChanged(SearchListView * listview, const int& type, const QString& path);
|
||||
void onListViewRowDoubleClicked(SearchListView * listview, const int& type, const QString& path);
|
||||
};
|
||||
|
||||
#endif // CONTENTWIDGET_H
|
||||
|
|
|
@ -50,35 +50,11 @@ HomePageItem::~HomePageItem()
|
|||
* @param path 路径
|
||||
*/
|
||||
void HomePageItem::setupUi(const int& type, const QString& path) {
|
||||
m_path = path;
|
||||
m_widget = new QWidget(this);
|
||||
m_widget->setObjectName("MainWidget");
|
||||
// m_widget->setStyleSheet("QWidget#MainWidget{background: rgba(0, 0, 0, 0.05); border-radius: 4px;}");
|
||||
m_widget->installEventFilter(this);
|
||||
connect(this, &HomePageItem::onItemClicked, this, [ = ]() {
|
||||
switch (SearchListView::getResType(path)) {
|
||||
case SearchListView::ResType::App: {
|
||||
GDesktopAppInfo * desktopAppInfo = g_desktop_app_info_new_from_filename(path.toLocal8Bit().data());
|
||||
g_app_info_launch(G_APP_INFO(desktopAppInfo),nullptr, nullptr, nullptr);
|
||||
g_object_unref(desktopAppInfo);
|
||||
break;
|
||||
}
|
||||
case SearchListView::ResType::Best:
|
||||
case SearchListView::ResType::Content:
|
||||
case SearchListView::ResType::Dir:
|
||||
case SearchListView::ResType::File: {
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
|
||||
break;
|
||||
}
|
||||
case SearchListView::ResType::Setting: {
|
||||
//打开控制面板对应页面
|
||||
QProcess process;
|
||||
process.startDetached(QString("ukui-control-center --%1").arg(path.left(path.indexOf("/")).toLower()));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
m_iconlabel = new QLabel(m_widget);
|
||||
m_namelabel = new QLabel(m_widget);
|
||||
if (type == ItemType::Recent) {
|
||||
|
@ -150,6 +126,33 @@ void HomePageItem::setupUi(const int& type, const QString& path) {
|
|||
m_vlayout->addWidget(m_namelabel);
|
||||
}
|
||||
|
||||
void HomePageItem::onItemClicked()
|
||||
{
|
||||
switch (SearchListView::getResType(m_path)) {
|
||||
case SearchListView::ResType::App: {
|
||||
GDesktopAppInfo * desktopAppInfo = g_desktop_app_info_new_from_filename(m_path.toLocal8Bit().data());
|
||||
g_app_info_launch(G_APP_INFO(desktopAppInfo),nullptr, nullptr, nullptr);
|
||||
g_object_unref(desktopAppInfo);
|
||||
break;
|
||||
}
|
||||
case SearchListView::ResType::Best:
|
||||
case SearchListView::ResType::Content:
|
||||
case SearchListView::ResType::Dir:
|
||||
case SearchListView::ResType::File: {
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(m_path));
|
||||
break;
|
||||
}
|
||||
case SearchListView::ResType::Setting: {
|
||||
//打开控制面板对应页面
|
||||
QProcess process;
|
||||
process.startDetached(QString("ukui-control-center --%1").arg(m_path.left(m_path.indexOf("/")).toLower()));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool HomePageItem::eventFilter(QObject *watched, QEvent *event){
|
||||
if (watched == m_widget){
|
||||
if (event->type() == QEvent::MouseButtonPress) {
|
||||
|
@ -157,7 +160,7 @@ bool HomePageItem::eventFilter(QObject *watched, QEvent *event){
|
|||
this->update();
|
||||
return true;
|
||||
} else if (event->type() == QEvent::MouseButtonRelease) {
|
||||
Q_EMIT this->onItemClicked();
|
||||
this->onItemClicked();
|
||||
m_transparency = 0.06;
|
||||
this->update();
|
||||
return true;
|
||||
|
|
|
@ -47,6 +47,7 @@ protected:
|
|||
|
||||
private:
|
||||
void setupUi(const int&, const QString&);
|
||||
void onItemClicked();
|
||||
|
||||
QWidget * m_widget = nullptr;
|
||||
QHBoxLayout * m_hlayout = nullptr;
|
||||
|
@ -54,9 +55,7 @@ private:
|
|||
QLabel * m_iconlabel = nullptr;
|
||||
QLabel * m_namelabel = nullptr;
|
||||
double m_transparency = 0;
|
||||
|
||||
Q_SIGNALS:
|
||||
void onItemClicked();
|
||||
QString m_path;
|
||||
};
|
||||
|
||||
#endif // HOMEPAGEITEM_H
|
||||
|
|
|
@ -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 && !path.contains(".desktop")) {
|
||||
return installAppAction(path.mid(path.indexOf("/") + 1));
|
||||
} else {
|
||||
if (openAction(type, path)) {
|
||||
writeConfigFile(path);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
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 *);
|
||||
|
|
|
@ -46,7 +46,7 @@ SearchListView::SearchListView(QWidget * parent, const QStringList& list, const
|
|||
|
||||
m_type = type;
|
||||
connect(this->selectionModel(), &QItemSelectionModel::selectionChanged, this, [ = ](const QItemSelection &selected, const QItemSelection &deselected) {
|
||||
Q_EMIT this->currentRowChanged(getCurrentType(), m_item->m_pathlist.at(this->currentIndex().row()));
|
||||
Q_EMIT this->currentRowChanged(this, getCurrentType(), m_item->m_pathlist.at(this->currentIndex().row()));
|
||||
m_isSelected = true;
|
||||
if(!selected.isEmpty())
|
||||
{
|
||||
|
@ -56,8 +56,8 @@ SearchListView::SearchListView(QWidget * parent, const QStringList& list, const
|
|||
}
|
||||
});
|
||||
|
||||
connect(this, &SearchListView::doubleClicked, this, [ = ](const QModelIndex& index) {
|
||||
|
||||
connect(this, &SearchListView::activated, this, [ = ](const QModelIndex& index) {
|
||||
Q_EMIT this->onRowDoubleClicked(this, getCurrentType(), m_item->m_pathlist.at(index.row()));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,8 @@ private:
|
|||
int m_type;
|
||||
|
||||
Q_SIGNALS:
|
||||
void currentRowChanged(const int&, const QString&);
|
||||
void currentRowChanged(SearchListView *,const int&, const QString&);
|
||||
void onRowDoubleClicked(SearchListView *, const int&, const QString&);
|
||||
void currentSelectPos(QPoint pos);
|
||||
void mousePressed();
|
||||
|
||||
|
|
Loading…
Reference in New Issue