Merge branch 'main' into zjp-qtimer
This commit is contained in:
commit
c999f1517f
|
@ -4,8 +4,10 @@ HEADERS += \
|
||||||
$$PWD/search-list-view.h \
|
$$PWD/search-list-view.h \
|
||||||
$$PWD/search-detail-view.h \
|
$$PWD/search-detail-view.h \
|
||||||
$$PWD/option-view.h \
|
$$PWD/option-view.h \
|
||||||
|
$$PWD/home-page-item.h \
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/search-list-view.cpp \
|
$$PWD/search-list-view.cpp \
|
||||||
$$PWD/search-detail-view.cpp \
|
$$PWD/search-detail-view.cpp \
|
||||||
$$PWD/option-view.cpp \
|
$$PWD/option-view.cpp \
|
||||||
|
$$PWD/home-page-item.cpp \
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
#include "home-page-item.h"
|
||||||
|
|
||||||
|
HomePageItem::HomePageItem(QWidget *parent, const int& type, const QString& path) : QWidget(parent)
|
||||||
|
{
|
||||||
|
setupUi(type, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
HomePageItem::~HomePageItem()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief HomePageItem::setupUi 根据不同的分栏创建item
|
||||||
|
* @param type 所属分栏
|
||||||
|
* @param path 路径
|
||||||
|
*/
|
||||||
|
void HomePageItem::setupUi(const int& type, const QString& path) {
|
||||||
|
m_widget = new QWidget(this);
|
||||||
|
m_widget->setObjectName("MainWidget");
|
||||||
|
m_widget->setStyleSheet("QWidget#MainWidget{background: rgba(0, 0, 0, 0.1); border-radius: 4px;}");
|
||||||
|
m_iconlabel = new QLabel(m_widget);
|
||||||
|
m_namelabel = new QLabel(m_widget);
|
||||||
|
if (type == ItemType::Recent) {
|
||||||
|
m_widget->setFixedSize(265, 48);
|
||||||
|
QIcon icon;
|
||||||
|
switch (SearchListView::getResType(path)) { //可能出现文件应用等,需要根据路径判断类型
|
||||||
|
case SearchListView::ResType::App : {
|
||||||
|
icon = FileUtils::getAppIcon(path);
|
||||||
|
m_namelabel->setText(FileUtils::getAppName(path));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SearchListView::ResType::File : {
|
||||||
|
icon = FileUtils::getFileIcon(QString("file://%1").arg(path));
|
||||||
|
m_namelabel->setText(FileUtils::getFileName(path));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SearchListView::ResType::Setting : {
|
||||||
|
icon = FileUtils::getSettingIcon(path, true);
|
||||||
|
m_namelabel->setText(FileUtils::getSettingName(path));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SearchListView::ResType::Dir : {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default :
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
m_iconlabel->setPixmap(icon.pixmap(icon.actualSize(QSize(24, 24))));
|
||||||
|
m_hlayout = new QHBoxLayout(m_widget);
|
||||||
|
m_iconlabel->setAlignment(Qt::AlignCenter);
|
||||||
|
m_namelabel->setAlignment(Qt::AlignCenter);
|
||||||
|
m_hlayout->addWidget(m_iconlabel);
|
||||||
|
m_hlayout->addWidget(m_namelabel);
|
||||||
|
m_hlayout->addStretch();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_widget->setFixedSize(120, 120);
|
||||||
|
m_vlayout = new QVBoxLayout(m_widget);
|
||||||
|
m_vlayout->setContentsMargins(0,16,0,12);
|
||||||
|
m_iconlabel->setAlignment(Qt::AlignCenter);
|
||||||
|
m_namelabel->setAlignment(Qt::AlignCenter);
|
||||||
|
m_vlayout->addWidget(m_iconlabel);
|
||||||
|
m_vlayout->addWidget(m_namelabel);
|
||||||
|
QIcon icon = FileUtils::getAppIcon(path);
|
||||||
|
m_iconlabel->setPixmap(icon.pixmap(icon.actualSize(QSize(48, 48))));
|
||||||
|
m_namelabel->setText(FileUtils::getAppName(path));
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
#ifndef HOMEPAGEITEM_H
|
||||||
|
#define HOMEPAGEITEM_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include "file-utils.h"
|
||||||
|
#include "search-list-view.h"
|
||||||
|
|
||||||
|
class HomePageItem : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit HomePageItem(QWidget *, const int&, const QString&);
|
||||||
|
~HomePageItem();
|
||||||
|
|
||||||
|
enum ItemType { //homepage中item的类型,包括常用应用、最近打开、快捷打开
|
||||||
|
Common,
|
||||||
|
Recent,
|
||||||
|
Quick
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setupUi(const int&, const QString&);
|
||||||
|
|
||||||
|
QWidget * m_widget = nullptr;
|
||||||
|
QHBoxLayout * m_hlayout = nullptr;
|
||||||
|
QVBoxLayout * m_vlayout = nullptr;
|
||||||
|
QLabel * m_iconlabel = nullptr;
|
||||||
|
QLabel * m_namelabel = nullptr;
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // HOMEPAGEITEM_H
|
|
@ -98,14 +98,14 @@ void SearchDetailView::setupWidget(const int& type, const QString& path) {
|
||||||
}
|
}
|
||||||
case SearchListView::ResType::File : {
|
case SearchListView::ResType::File : {
|
||||||
QIcon icon = FileUtils::getFileIcon(QString("file://%1").arg(path));
|
QIcon icon = FileUtils::getFileIcon(QString("file://%1").arg(path));
|
||||||
iconLabel->setPixmap(icon.pixmap(icon.actualSize(QSize(100, 100))));
|
iconLabel->setPixmap(icon.pixmap(icon.actualSize(QSize(96, 96))));
|
||||||
nameLabel->setText(FileUtils::getFileName(path));
|
nameLabel->setText(FileUtils::getFileName(path));
|
||||||
typeLabel->setText(tr("Document"));
|
typeLabel->setText(tr("Document"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SearchListView::ResType::Setting : {
|
case SearchListView::ResType::Setting : {
|
||||||
QIcon icon = FileUtils::getSettingIcon(path, true);
|
QIcon icon = FileUtils::getSettingIcon(path, true);
|
||||||
iconLabel->setPixmap(icon.pixmap(icon.actualSize(QSize(100, 100))));
|
iconLabel->setPixmap(icon.pixmap(icon.actualSize(QSize(96, 96))));
|
||||||
QString settingType = path.mid(path.indexOf("/") + 1, path.lastIndexOf("/") - path.indexOf("/") - 1); //配置项所属控制面板插件名
|
QString settingType = path.mid(path.indexOf("/") + 1, path.lastIndexOf("/") - path.indexOf("/") - 1); //配置项所属控制面板插件名
|
||||||
nameLabel->setText(settingType);
|
nameLabel->setText(settingType);
|
||||||
typeLabel->setText(FileUtils::getSettingName(path));
|
typeLabel->setText(FileUtils::getSettingName(path));
|
||||||
|
|
|
@ -14,7 +14,8 @@ SearchListView::SearchListView(QWidget * parent, const QStringList& list, const
|
||||||
this->setHeaderHidden(true);
|
this->setHeaderHidden(true);
|
||||||
this->setColumnWidth(0, 20);
|
this->setColumnWidth(0, 20);
|
||||||
this->setColumnWidth(1, 80);
|
this->setColumnWidth(1, 80);
|
||||||
this->setFixedHeight(list.count() * 47 + 2);
|
int rowHeight = this->rowHeight(this->model()->index(0,1, QModelIndex())) + 1;
|
||||||
|
this->setFixedHeight(list.count() * rowHeight + 2);
|
||||||
this->setAttribute(Qt::WA_TranslucentBackground, true);
|
this->setAttribute(Qt::WA_TranslucentBackground, true);
|
||||||
this->setAutoFillBackground(false);
|
this->setAutoFillBackground(false);
|
||||||
this->setStyleSheet("QWidget{background:transparent;}");
|
this->setStyleSheet("QWidget{background:transparent;}");
|
||||||
|
|
|
@ -21,7 +21,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
int getCurrentType();
|
int getCurrentType();
|
||||||
int getResType(const QString&);
|
static int getResType(const QString&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SearchItemModel * m_model = nullptr;
|
SearchItemModel * m_model = nullptr;
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
#include "file-searcher.h"
|
#include "file-searcher.h"
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
FileSearcher::FileSearcher(QObject *parent) : QObject(parent)
|
FileSearcher::FileSearcher(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileSearcher::onKeywordSearch(QString keyword)
|
void FileSearcher::onKeywordSearch(QString keyword, int begin, int num)
|
||||||
{
|
{
|
||||||
QStringList searchResult;
|
QVector<QStringList> searchResult;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
qDebug()<<"--search start--";
|
qDebug()<<"--search start--";
|
||||||
|
@ -19,14 +21,14 @@ void FileSearcher::onKeywordSearch(QString keyword)
|
||||||
qp.set_database(db);
|
qp.set_database(db);
|
||||||
auto userInput = keyword;
|
auto userInput = keyword;
|
||||||
|
|
||||||
std::string queryStr = indexText.replace(""," ").toStdString();
|
std::string queryStr = keyword.replace(""," ").toStdString();
|
||||||
// std::string s =db.get_spelling_suggestion(queryStr,10);
|
// std::string s =db.get_spelling_suggestion(queryStr,10);
|
||||||
// qDebug()<<"spelling_suggestion!"<<QString::fromStdString(s);
|
// qDebug()<<"spelling_suggestion!"<<QString::fromStdString(s);
|
||||||
|
|
||||||
qDebug()<<"queryStr!"<<QString::fromStdString(queryStr);
|
qDebug()<<"queryStr!"<<QString::fromStdString(queryStr);
|
||||||
//Creat a query
|
//Creat a query
|
||||||
Xapian::Query queryPhrase = qp.parse_query(queryStr,Xapian::QueryParser::FLAG_PHRASE);
|
Xapian::Query queryPhrase = qp.parse_query(queryStr,Xapian::QueryParser::FLAG_PHRASE);
|
||||||
vector<Xapian::Query> v;
|
std::vector<Xapian::Query> v;
|
||||||
for(int i=0;i<userInput.size();i++)
|
for(int i=0;i<userInput.size();i++)
|
||||||
{
|
{
|
||||||
v.push_back(Xapian::Query(QString(userInput.at(i)).toStdString()));
|
v.push_back(Xapian::Query(QString(userInput.at(i)).toStdString()));
|
||||||
|
@ -36,17 +38,53 @@ void FileSearcher::onKeywordSearch(QString keyword)
|
||||||
Xapian::Query queryNear =Xapian::Query(Xapian::Query::OP_NEAR, v.begin(), v.end());
|
Xapian::Query queryNear =Xapian::Query(Xapian::Query::OP_NEAR, v.begin(), v.end());
|
||||||
Xapian::Query query = Xapian::Query(Xapian::Query::OP_AND,queryNear,queryPhrase);
|
Xapian::Query query = Xapian::Query(Xapian::Query::OP_AND,queryNear,queryPhrase);
|
||||||
|
|
||||||
|
//1- dir 2-file
|
||||||
|
unsigned slot = 1;
|
||||||
|
std::string value = "1";
|
||||||
|
Xapian::Query queryValue1 = Xapian::Query(Xapian::Query::OP_VALUE_GE,slot,value);
|
||||||
|
value = "0";
|
||||||
|
Xapian::Query queryValue0 = Xapian::Query(Xapian::Query::OP_VALUE_LE,1,value);
|
||||||
|
Xapian::Query queryDir = Xapian::Query(Xapian::Query::OP_AND,query,queryValue1);
|
||||||
|
Xapian::Query queryFile = Xapian::Query(Xapian::Query::OP_AND,query,queryValue0);
|
||||||
|
|
||||||
qDebug()<<QString::fromStdString(query.get_description());
|
qDebug()<<QString::fromStdString(query.get_description());
|
||||||
enquire.set_query(query);
|
|
||||||
|
|
||||||
Xapian::MSet result = enquire.get_mset(0, 9999);
|
enquire.set_query(queryDir);
|
||||||
qDebug()<< "find results count=" <<static_cast<int>(result.get_matches_estimated());
|
//dir result
|
||||||
|
Xapian::MSet result = enquire.get_mset(begin, begin+num);
|
||||||
|
qDebug()<< "find dir results count=" <<static_cast<int>(result.get_matches_estimated());
|
||||||
|
searchResult.append(getResult(result));
|
||||||
|
|
||||||
// QStringList *pathTobeDelete = new QStringList;
|
enquire.set_query(queryFile);
|
||||||
|
//file result
|
||||||
|
result = enquire.get_mset(begin, begin+num);
|
||||||
|
qDebug()<< "find file results count=" <<static_cast<int>(result.get_matches_estimated());
|
||||||
|
searchResult.append(getResult(result));
|
||||||
|
|
||||||
//get search result
|
qDebug()<< "--search finish--";
|
||||||
for (auto it = result.begin(); it != result.end(); ++it) {
|
}
|
||||||
|
catch(const Xapian::Error &e)
|
||||||
|
{
|
||||||
|
qDebug() <<QString::fromStdString(e.get_description());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Q_EMIT this->result(searchResult);
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList FileSearcher::getResult(Xapian::MSet &result)
|
||||||
|
{
|
||||||
|
//QStringList *pathTobeDelete = new QStringList;
|
||||||
|
//Delete those path doc which is not already exist.
|
||||||
|
|
||||||
|
QStringList searchResult = QStringList();
|
||||||
|
if(result.size() == 0)
|
||||||
|
return searchResult;
|
||||||
|
for (auto it = result.begin(); it != result.end(); ++it)
|
||||||
|
{
|
||||||
Xapian::Document doc = it.get_document();
|
Xapian::Document doc = it.get_document();
|
||||||
|
qDebug()<<"value!!!!"<<QString::fromStdString(doc.get_value(1));
|
||||||
std::string data = doc.get_data();
|
std::string data = doc.get_data();
|
||||||
Xapian::weight docScoreWeight = it.get_weight();
|
Xapian::weight docScoreWeight = it.get_weight();
|
||||||
Xapian::percent docScorePercent = it.get_percent();
|
Xapian::percent docScorePercent = it.get_percent();
|
||||||
|
@ -64,18 +102,7 @@ void FileSearcher::onKeywordSearch(QString keyword)
|
||||||
|
|
||||||
qDebug()<< "doc="<< QString::fromStdString(data) << ",weight=" <<docScoreWeight << ",percent=" << docScorePercent;
|
qDebug()<< "doc="<< QString::fromStdString(data) << ",weight=" <<docScoreWeight << ",percent=" << docScorePercent;
|
||||||
}
|
}
|
||||||
// //Delete those path doc which is not already exist.
|
// if(!pathTobeDelete->isEmpty())
|
||||||
// if(!pathTobeDelete->isEmpty())
|
// deleteAllIndex(pathTobeDelete)
|
||||||
// deleteAllIndex(pathTobeDelete);
|
return searchResult;
|
||||||
|
|
||||||
qDebug()<< "--search finish--";
|
|
||||||
}
|
|
||||||
catch(const Xapian::Error &e)
|
|
||||||
{
|
|
||||||
qDebug() <<QString::fromStdString(e.get_description());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Q_EMIT this->result(searchResult);
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <xapian.h>
|
#include <xapian.h>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
#include <QVector>
|
||||||
#define INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/index_data").toStdString()
|
#define INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/index_data").toStdString()
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,12 +15,12 @@ public:
|
||||||
explicit FileSearcher(QObject *parent = nullptr);
|
explicit FileSearcher(QObject *parent = nullptr);
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void onKeywordSearch(QString keyword);
|
void onKeywordSearch(QString keyword, int begin, int num);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void result(QStringList resultList);
|
void result(QVector<QStringList> resultV);
|
||||||
|
private:
|
||||||
|
QStringList getResult(Xapian::MSet &result);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FILESEARCHER_H
|
#endif // FILESEARCHER_H
|
||||||
|
|
|
@ -134,8 +134,10 @@ Document IndexGenerator::GenerateDocument(const QVector<QString> &list)
|
||||||
doc.setData(sourcePath);
|
doc.setData(sourcePath);
|
||||||
doc.setUniqueTerm(uniqueterm);
|
doc.setUniqueTerm(uniqueterm);
|
||||||
doc.addValue(list.at(2));
|
doc.addValue(list.at(2));
|
||||||
|
if(list.at(2) == QString("1"))
|
||||||
|
qDebug()<<"value!!!"<<list.at(2);
|
||||||
doc.setIndexText(QStringList()<<index_text<<pinyin_text);
|
doc.setIndexText(QStringList()<<index_text<<pinyin_text);
|
||||||
doc.setIndexText(QStringList()<<index_text);
|
// doc.setIndexText(QStringList()<<index_text);
|
||||||
return doc;
|
return doc;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -169,7 +171,7 @@ QStringList IndexGenerator::IndexSearch(QString indexText)
|
||||||
qDebug()<<"queryStr!"<<QString::fromStdString(queryStr);
|
qDebug()<<"queryStr!"<<QString::fromStdString(queryStr);
|
||||||
//Creat a query
|
//Creat a query
|
||||||
Xapian::Query queryPhrase = qp.parse_query(queryStr,Xapian::QueryParser::FLAG_PHRASE);
|
Xapian::Query queryPhrase = qp.parse_query(queryStr,Xapian::QueryParser::FLAG_PHRASE);
|
||||||
vector<Xapian::Query> v;
|
std::vector<Xapian::Query> v;
|
||||||
for(int i=0;i<userInput.size();i++)
|
for(int i=0;i<userInput.size();i++)
|
||||||
{
|
{
|
||||||
v.push_back(Xapian::Query(QString(userInput.at(i)).toStdString()));
|
v.push_back(Xapian::Query(QString(userInput.at(i)).toStdString()));
|
||||||
|
|
|
@ -40,7 +40,9 @@ InotifyManagerRefact::~InotifyManagerRefact(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void InotifyManagerRefact::DoSomething(const QFileInfo& fileInfo){
|
void InotifyManagerRefact::DoSomething(const QFileInfo& fileInfo){
|
||||||
this->mlm->AddMessage(QVector<QString>() << fileInfo.fileName() << fileInfo.absoluteFilePath() << QString(bool((fileInfo.isDir()))));
|
this->mlm->AddMessage(QVector<QString>() << fileInfo.fileName() << fileInfo.absoluteFilePath() << QString(fileInfo.isDir()?"1":"0"));
|
||||||
|
// if(QString(bool((fileInfo.isDir()))) == QString("1"))
|
||||||
|
// qDebug()<<"bool((fileInfo.isDir())"<<QString(fileInfo.isDir());
|
||||||
// this->mlm->AddMessage(QVector<QString>() << "PLog" << "/home/zpf/baidunetdisk/PLog" << "1");
|
// this->mlm->AddMessage(QVector<QString>() << "PLog" << "/home/zpf/baidunetdisk/PLog" << "1");
|
||||||
if(fileInfo.isDir()){
|
if(fileInfo.isDir()){
|
||||||
this->AddWatch(fileInfo.absoluteFilePath());
|
this->AddWatch(fileInfo.absoluteFilePath());
|
||||||
|
|
|
@ -25,6 +25,7 @@ ContentWidget::~ContentWidget()
|
||||||
void ContentWidget::initUI() {
|
void ContentWidget::initUI() {
|
||||||
m_homePage = new QWidget;
|
m_homePage = new QWidget;
|
||||||
m_homePageLyt = new QVBoxLayout(m_homePage);
|
m_homePageLyt = new QVBoxLayout(m_homePage);
|
||||||
|
m_homePageLyt->setSpacing(0);
|
||||||
m_homePage->setLayout(m_homePageLyt);
|
m_homePage->setLayout(m_homePageLyt);
|
||||||
|
|
||||||
m_resultPage = new QWidget;
|
m_resultPage = new QWidget;
|
||||||
|
@ -56,20 +57,59 @@ void ContentWidget::initUI() {
|
||||||
m_detailView = new SearchDetailView(m_resultDetailArea);
|
m_detailView = new SearchDetailView(m_resultDetailArea);
|
||||||
m_resultDetailArea->setWidget(m_detailView);
|
m_resultDetailArea->setWidget(m_detailView);
|
||||||
m_resultDetailArea->setWidgetResizable(true);
|
m_resultDetailArea->setWidgetResizable(true);
|
||||||
m_homePage->setStyleSheet("QWidget{background:pink;}");
|
|
||||||
m_resultListArea->setStyleSheet("QScrollArea{background:transparent;}");
|
m_resultListArea->setStyleSheet("QScrollArea{background:transparent;}");
|
||||||
m_resultDetailArea->setStyleSheet("QScrollArea{background: rgba(0,0,0,0.05); border-radius: 4px;}");
|
m_resultDetailArea->setStyleSheet("QScrollArea{background: rgba(0,0,0,0.05); border-radius: 4px;}");
|
||||||
this->addWidget(m_homePage);
|
this->addWidget(m_homePage);
|
||||||
this->addWidget(m_resultPage);
|
this->addWidget(m_resultPage);
|
||||||
|
|
||||||
setPageType(SearchItem::SearchType::All);//初始化按“全部”加载
|
setPage(SearchItem::SearchType::All);//初始化按“全部”加载
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ContentWidget::initHomePage 向homepage填充内容
|
||||||
|
* @param lists 三个列表:常用,最近,快捷
|
||||||
|
*/
|
||||||
|
void ContentWidget::initHomePage(const QVector<QStringList>& lists) {
|
||||||
|
for (int i = 0; i < lists.count(); i++) {
|
||||||
|
QWidget * listWidget = new QWidget(m_homePage);
|
||||||
|
QVBoxLayout * itemWidgetLyt = new QVBoxLayout(listWidget);
|
||||||
|
QLabel * titleLabel = new QLabel(listWidget);
|
||||||
|
QWidget * itemWidget = new QWidget(listWidget);
|
||||||
|
if (i == 1) {
|
||||||
|
titleLabel->setText(tr("Recently Opened"));
|
||||||
|
QGridLayout * layout = new QGridLayout(itemWidget);
|
||||||
|
layout->setSpacing(8);
|
||||||
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
itemWidget->setLayout(layout);
|
||||||
|
for (int j = 0; j < lists.at(i).count(); j++) {
|
||||||
|
HomePageItem * item = new HomePageItem(itemWidget, i, lists.at(i).at(j));
|
||||||
|
layout->addWidget(item, j / 2, j % 2);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (i) titleLabel->setText(tr("Commonly Used"));
|
||||||
|
else titleLabel->setText(tr("Open Quickly"));
|
||||||
|
QHBoxLayout * layout = new QHBoxLayout(itemWidget);
|
||||||
|
layout->setSpacing(8);
|
||||||
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
itemWidget->setLayout(layout);
|
||||||
|
Q_FOREACH(QString path, lists.at(i)){
|
||||||
|
HomePageItem * item = new HomePageItem(itemWidget, i, path);
|
||||||
|
layout->addWidget(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
itemWidgetLyt->setSpacing(6);
|
||||||
|
titleLabel->setFixedHeight(24);
|
||||||
|
itemWidgetLyt->addWidget(titleLabel);
|
||||||
|
itemWidgetLyt->addWidget(itemWidget);
|
||||||
|
m_homePageLyt->addWidget(listWidget);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief setPageType 预留的接口,为指定类别搜索调整界面内容
|
* @brief setPageType 预留的接口,为指定类别搜索调整界面内容
|
||||||
* @param type
|
* @param type
|
||||||
*/
|
*/
|
||||||
void ContentWidget::setPageType(const int& type){
|
void ContentWidget::setPage(const int& type){
|
||||||
m_currentType = type;
|
m_currentType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +117,7 @@ void ContentWidget::setPageType(const int& type){
|
||||||
* @brief ContentWidget::currentType 返回当前内容页(home或searchresult)
|
* @brief ContentWidget::currentType 返回当前内容页(home或searchresult)
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int ContentWidget::currentType() {
|
int ContentWidget::currentPage() {
|
||||||
return m_currentType;
|
return m_currentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,6 +131,9 @@ void ContentWidget::refreshSearchList(const QVector<int>& types, const QVector<Q
|
||||||
clearSearchList();
|
clearSearchList();
|
||||||
}
|
}
|
||||||
for (int i = 0; i < types.count(); i ++) {
|
for (int i = 0; i < types.count(); i ++) {
|
||||||
|
if (lists.at(i).isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
SearchListView * searchList = new SearchListView(m_resultList, lists.at(i), types.at(i)); //Treeview
|
SearchListView * searchList = new SearchListView(m_resultList, lists.at(i), types.at(i)); //Treeview
|
||||||
QLabel * titleLabel = new QLabel(m_resultList); //表头
|
QLabel * titleLabel = new QLabel(m_resultList); //表头
|
||||||
titleLabel->setContentsMargins(8, 0, 0, 0);
|
titleLabel->setContentsMargins(8, 0, 0, 0);
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QStackedWidget>
|
#include <QStackedWidget>
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
|
#include <QGridLayout>
|
||||||
#include "control/search-detail-view.h"
|
#include "control/search-detail-view.h"
|
||||||
|
#include "home-page-item.h"
|
||||||
|
|
||||||
class ContentWidget : public QStackedWidget
|
class ContentWidget : public QStackedWidget
|
||||||
{
|
{
|
||||||
|
@ -13,9 +15,10 @@ public:
|
||||||
ContentWidget(QWidget *);
|
ContentWidget(QWidget *);
|
||||||
~ContentWidget();
|
~ContentWidget();
|
||||||
|
|
||||||
void setPageType(const int&);
|
void setPage(const int&);
|
||||||
int currentType();
|
int currentPage();
|
||||||
void refreshSearchList(const QVector<int>&, const QVector<QStringList>&);
|
void refreshSearchList(const QVector<int>&, const QVector<QStringList>&);
|
||||||
|
void initHomePage(const QVector<QStringList>&);
|
||||||
private:
|
private:
|
||||||
void initUI();
|
void initUI();
|
||||||
QWidget * m_homePage = nullptr;
|
QWidget * m_homePage = nullptr;
|
||||||
|
|
|
@ -47,6 +47,14 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
//load chinese character and pinyin file to a Map
|
//load chinese character and pinyin file to a Map
|
||||||
FileUtils::loadHanziTable("://index/pinyinWithoutTone.txt");
|
FileUtils::loadHanziTable("://index/pinyinWithoutTone.txt");
|
||||||
|
/*-------------InotyifyRefact Test Start---------------*/
|
||||||
|
QTime t1 = QTime::currentTime();
|
||||||
|
InotifyManagerRefact* imr = new InotifyManagerRefact("/home");
|
||||||
|
imr->start();
|
||||||
|
QTime t2 = QTime::currentTime();
|
||||||
|
qDebug() << t1;
|
||||||
|
qDebug() << t2;
|
||||||
|
/*-------------InotyifyRefact Test End-----------------*/
|
||||||
|
|
||||||
qRegisterMetaType<QVector<QStringList>>("QVector<QStringList>");
|
qRegisterMetaType<QVector<QStringList>>("QVector<QStringList>");
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "index-generator.h"
|
#include "index-generator.h"
|
||||||
//#include "inotify-manager.h"
|
//#include "inotify-manager.h"
|
||||||
#include "inotify.h"
|
#include "inotify.h"
|
||||||
|
#include "file-searcher.h"
|
||||||
|
|
||||||
extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
|
extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
|
||||||
/**
|
/**
|
||||||
|
@ -48,17 +49,6 @@ extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int tran
|
||||||
MainWindow::MainWindow(QWidget *parent) :
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent)
|
QMainWindow(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/*-------------InotyifyRefact Test Start---------------*/
|
|
||||||
QTime t1 = QTime::currentTime();
|
|
||||||
InotifyManagerRefact* imr = new InotifyManagerRefact("/home");
|
|
||||||
imr->start();
|
|
||||||
QTime t2 = QTime::currentTime();
|
|
||||||
qDebug() << t1;
|
|
||||||
qDebug() << t2;
|
|
||||||
/*-------------InotyifyRefact Test End-----------------*/
|
|
||||||
|
|
||||||
this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint);
|
this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint);
|
||||||
this->setAttribute(Qt::WA_TranslucentBackground, true);
|
this->setAttribute(Qt::WA_TranslucentBackground, true);
|
||||||
this->setAutoFillBackground(false);
|
this->setAutoFillBackground(false);
|
||||||
|
@ -148,6 +138,22 @@ void MainWindow::initUi()
|
||||||
searchContent(text);
|
searchContent(text);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//初始化homepage
|
||||||
|
QVector<QStringList> lists;
|
||||||
|
|
||||||
|
//测试用数据
|
||||||
|
QStringList list;
|
||||||
|
list<<"/usr/share/applications/peony.desktop"<<"/usr/share/applications/ukui-control-center.desktop"<<"/usr/share/applications/ukui-clock.desktop"<<"/usr/share/applications/wps-office-pdf.desktop";
|
||||||
|
QStringList list2;
|
||||||
|
list2<<"/home/zjp/下载/搜索结果.png"<<"/home/zjp/下载/显示不全.mp4"<<"/home/zjp/下载/dmesg.log"<<"/home/zjp/下载/WiFi_AP选择.docx";
|
||||||
|
|
||||||
|
lists.append(list);
|
||||||
|
lists.append(list2);
|
||||||
|
lists.append(list);
|
||||||
|
|
||||||
|
//将搜索结果加入列表
|
||||||
|
m_contentFrame->initHomePage(lists);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -214,36 +220,50 @@ void MainWindow::primaryScreenChangedSlot(QScreen *screen)
|
||||||
* @param searchcontent
|
* @param searchcontent
|
||||||
*/
|
*/
|
||||||
void MainWindow::searchContent(QString searchcontent){
|
void MainWindow::searchContent(QString searchcontent){
|
||||||
QVector<int> types;
|
// QVector<int> types;
|
||||||
QVector<QStringList> lists;
|
// QVector<QStringList> lists;
|
||||||
|
|
||||||
AppMatch * appMatchor = new AppMatch(this);
|
AppMatch * appMatchor = new AppMatch(this);
|
||||||
SettingsMatch * settingMatchor = new SettingsMatch(this);
|
SettingsMatch * settingMatchor = new SettingsMatch(this);
|
||||||
|
|
||||||
//测试用数据
|
//测试用数据
|
||||||
QStringList list;
|
// QStringList list;
|
||||||
list = appMatchor->startMatchApp(searchcontent);
|
|
||||||
// list<<"/usr/share/applications/peony.desktop"<<"/usr/share/applications/ukui-control-center.desktop"<<"/usr/share/applications/wps-office-pdf.desktop";
|
// list<<"/usr/share/applications/peony.desktop"<<"/usr/share/applications/ukui-control-center.desktop"<<"/usr/share/applications/wps-office-pdf.desktop";
|
||||||
QStringList list2;
|
// QStringList list2;
|
||||||
list2<<"/home/zjp/下载/搜索结果.png"<<"/home/zjp/下载/显示不全.mp4"<<"/home/zjp/下载/dmesg.log"<<"/home/zjp/下载/WiFi_AP选择.docx";
|
// list2<<"/home/zjp/下载/搜索结果.png"<<"/home/zjp/下载/显示不全.mp4"<<"/home/zjp/下载/dmesg.log"<<"/home/zjp/下载/WiFi_AP选择.docx";
|
||||||
QStringList list3;
|
// QStringList list3;
|
||||||
list3 = settingMatchor->matchstart(searchcontent);
|
|
||||||
// list3<<"About/关于/计算机属性"<<"Area/语言和地区/货币单位"<<"Datetime/时间和日期/手动更改时间"<<"Theme/主题/图标主题";
|
// list3<<"About/关于/计算机属性"<<"Area/语言和地区/货币单位"<<"Datetime/时间和日期/手动更改时间"<<"Theme/主题/图标主题";
|
||||||
types.append(SearchItem::SearchType::Apps);
|
// types.append(SearchItem::SearchType::Apps);
|
||||||
types.append(SearchItem::SearchType::Settings);
|
// types.append(SearchItem::SearchType::Settings);
|
||||||
types.append(SearchItem::SearchType::Files);
|
// types.append(SearchItem::SearchType::Files);
|
||||||
|
|
||||||
lists.append(list);
|
// lists.append(list);
|
||||||
lists.append(list3);
|
// lists.append(list3);
|
||||||
lists.append(list2);
|
// lists.append(list2);
|
||||||
|
|
||||||
//文件搜索
|
//文件搜索
|
||||||
|
|
||||||
|
FileSearcher *searcher = new FileSearcher();
|
||||||
|
|
||||||
|
connect(searcher,&FileSearcher::result,[=](QVector<QStringList> resultV){
|
||||||
|
|
||||||
|
QStringList list1 = resultV.at(0);
|
||||||
|
// QStringList list2 = resultV.at(1);
|
||||||
|
|
||||||
|
QVector<QStringList> lists;
|
||||||
|
lists.append(list1);
|
||||||
|
QVector<int> types;
|
||||||
|
types.append(SearchItem::SearchType::Files);
|
||||||
|
// types.append(SearchItem::SearchType::Files);
|
||||||
|
m_contentFrame->refreshSearchList(types, lists);
|
||||||
|
});
|
||||||
|
searcher->onKeywordSearch(searchcontent,0,10);
|
||||||
// QStringList res = IndexGenerator::IndexSearch(searchcontent);
|
// QStringList res = IndexGenerator::IndexSearch(searchcontent);
|
||||||
// types.append(SearchItem::SearchType::Files);
|
// types.append(SearchItem::SearchType::Files);
|
||||||
// lists.append(res);
|
// lists.append(res);
|
||||||
|
|
||||||
//将搜索结果加入列表
|
//将搜索结果加入列表
|
||||||
m_contentFrame->refreshSearchList(types, lists);
|
// m_contentFrame->refreshSearchList(types, lists);
|
||||||
}
|
}
|
||||||
|
|
||||||
//使用GSetting获取当前窗口应该使用的透明度
|
//使用GSetting获取当前窗口应该使用的透明度
|
||||||
|
|
Loading…
Reference in New Issue