Merge from dev-unity.

This commit is contained in:
iaom 2021-08-20 16:03:51 +08:00
commit 1e0f66c8ff
14 changed files with 123 additions and 119 deletions

101
.gitignore vendored
View File

@ -1,72 +1,53 @@
# This file is used to ignore files which are generated # C++ objects and libs
# ---------------------------------------------------------------------------- *.slo
*.lo
*~
*.autosave
*.a
*.core
*.moc
*.o *.o
*.obj *.a
*.orig *.la
*.rej *.lai
*.so *.so
*.so.* *.so.*
*_pch.h.cpp
*_resource.rc
.#*
*.*#
core
!core/
tags
.DS_Store
.directory
*.debug
Makefile*
*.prl
*.app
moc_*.cpp
ui_*.h
qrc_*.cpp
Thumbs.db
*.res
*.rc *.rc
*.dll
*.dylib
# Qt-es
object_script.*.Release
object_script.*.Debug
*_plugin_import.cpp
/.qmake.cache /.qmake.cache
/.qmake.stash /.qmake.stash
*.pro.user
*.pro.user.*
*.qbs.user
*.qbs.user.*
*.moc
moc_*.cpp
moc_*.h
qrc_*.cpp
ui_*.h
*.qmlc
*.jsc
Makefile*
*build-*
*.qm
*.prl
# qtcreator generated files # Qt unit tests
*.pro.user* target_wrapper.*
# xemacs temporary files # QtCreator
*.flc *.autosave
# Vim temporary files # QtCreator Qml
.*.swp *.qmlproject.user
*.qmlproject.user.*
# Visual Studio generated files # QtCreator CMake
*.ib_pdb_index CMakeLists.txt.user*
*.idb
*.ilk
*.pdb
*.sln
*.suo
*.vcproj
*vcproj.*.*.user
*.ncb
*.sdf
*.opensdf
*.vcxproj
*vcxproj.*
# MinGW generated files # QtCreator 4.8< compilation database
*.Debug compile_commands.json
*.Release
# Python byte code
*.pyc
# Binaries
# --------
*.dll
*.exe
# QtCreator local machine specific files for imported projects
*creator.user*

View File

@ -1,10 +1,13 @@
[Desktop Entry] [Desktop Entry]
Name=Search Name=Search
Name[zh_CN]=搜索 Name[zh_CN]=搜索
Name[bo_CN]=བཤེར་འཚོལ།
GenericName=UKUI Global Search GenericName=UKUI Global Search
GenericName[zh_CN]=全局搜索 GenericName[zh_CN]=全局搜索
GenericName[bo_CN]=བཤེར་འཚོལ།
Comment=ukui-search Comment=ukui-search
Comment[zh_CN]=全局搜索 Comment[zh_CN]=全局搜索
Comment[bo_CN]=ཁྱོན་ཡོངས་བཤེར་འཚོལ།
Exec=/usr/bin/ukui-search -s Exec=/usr/bin/ukui-search -s
Type=Application Type=Application
Icon=kylin-search Icon=kylin-search

View File

@ -95,9 +95,7 @@ void FirstIndex::DoSomething(const QFileInfo& fileInfo) {
void FirstIndex::run() { void FirstIndex::run() {
QTime t1 = QTime::currentTime(); QTime t1 = QTime::currentTime();
// Create a fifo at ~/.config/org.ukui/ukui-search, the fifo is used to control the order of child processes' running. // Create a fifo at ~/.config/org.ukui/ukui-search, the fifo is used to control the order of child processes' running.
QString indexDataBaseStatus = IndexStatusRecorder::getInstance()->getStatus(INDEX_DATABASE_STATE).toString(); QString indexDataBaseStatus = IndexStatusRecorder::getInstance()->getStatus(INDEX_DATABASE_STATE).toString();
QString contentIndexDataBaseStatus = IndexStatusRecorder::getInstance()->getStatus(CONTENT_INDEX_DATABASE_STATE).toString(); QString contentIndexDataBaseStatus = IndexStatusRecorder::getInstance()->getStatus(CONTENT_INDEX_DATABASE_STATE).toString();
QString inotifyIndexStatus = IndexStatusRecorder::getInstance()->getStatus(INOTIFY_NORMAL_EXIT).toString(); QString inotifyIndexStatus = IndexStatusRecorder::getInstance()->getStatus(INOTIFY_NORMAL_EXIT).toString();
@ -106,7 +104,6 @@ void FirstIndex::run() {
qDebug() << "contentIndexDataBaseStatus: " << contentIndexDataBaseStatus; qDebug() << "contentIndexDataBaseStatus: " << contentIndexDataBaseStatus;
qDebug() << "inotifyIndexStatus: " << inotifyIndexStatus; qDebug() << "inotifyIndexStatus: " << inotifyIndexStatus;
/* || contentIndexDataBaseStatus == ""*/
if(indexDataBaseStatus == "") { if(indexDataBaseStatus == "") {
this->bool_dataBaseExist = false; this->bool_dataBaseExist = false;
} else { } else {
@ -119,9 +116,6 @@ void FirstIndex::run() {
} }
this->q_index = new QQueue<QVector<QString>>(); this->q_index = new QQueue<QVector<QString>>();
//this->q_content_index = new QQueue<QString>();
//NEW_QUEUE(this->q_content_index);
// this->mlm = new MessageListManager();
this->q_content_index = new QQueue<QPair<QString,qint64>>(); this->q_content_index = new QQueue<QPair<QString,qint64>>();
int fifo_fd; int fifo_fd;
@ -135,11 +129,6 @@ void FirstIndex::run() {
assert(false); assert(false);
} }
// this->q_content_index->enqueue(QString("/home/zhangzihao/Desktop/qwerty/四库全书.txt"));
// this->p_indexGenerator->creatAllIndex(this->q_content_index);
++FileUtils::_index_status; ++FileUtils::_index_status;
pid_t pid; pid_t pid;
pid = fork(); pid = fork();
@ -157,7 +146,6 @@ void FirstIndex::run() {
} else { } else {
// p_indexGenerator = IndexGenerator::getInstance(false,this); // p_indexGenerator = IndexGenerator::getInstance(false,this);
p_indexGenerator = IndexGenerator::getInstance(true, this); p_indexGenerator = IndexGenerator::getInstance(true, this);
} }
//TODO Fix these weird code. //TODO Fix these weird code.
QSemaphore sem(5); QSemaphore sem(5);
@ -166,7 +154,6 @@ void FirstIndex::run() {
mutex2.lock(); mutex2.lock();
mutex3.lock(); mutex3.lock();
sem.acquire(4); sem.acquire(4);
// QtConcurrent::run([&](){
sem.acquire(1); sem.acquire(1);
mutex1.unlock(); mutex1.unlock();
this->setPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)); this->setPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
@ -174,7 +161,6 @@ void FirstIndex::run() {
FileUtils::_max_index_count = this->q_index->length(); FileUtils::_max_index_count = this->q_index->length();
qDebug() << "max_index_count:" << FileUtils::_max_index_count; qDebug() << "max_index_count:" << FileUtils::_max_index_count;
sem.release(5); sem.release(5);
// });
QtConcurrent::run(&m_pool, [&]() { QtConcurrent::run(&m_pool, [&]() {
sem.acquire(2); sem.acquire(2);
mutex2.unlock(); mutex2.unlock();
@ -197,7 +183,6 @@ void FirstIndex::run() {
QQueue<QString>* tmp2 = new QQueue<QString>(); QQueue<QString>* tmp2 = new QQueue<QString>();
qDebug() << "q_content_index:" << q_content_index->size(); qDebug() << "q_content_index:" << q_content_index->size();
while(!this->q_content_index->empty()) { while(!this->q_content_index->empty()) {
// for (size_t i = 0; (i < this->u_send_length) && (!this->q_content_index->empty()); ++i){
qint64 fileSize = 0; qint64 fileSize = 0;
//修改一次处理的数据量从30个文件改为文件总大小为50M以下50M为暂定值--jxx20210519 //修改一次处理的数据量从30个文件改为文件总大小为50M以下50M为暂定值--jxx20210519
for(size_t i = 0;/* (i < 30) && (fileSize < 52428800) && */(!this->q_content_index->empty()); ++i) { for(size_t i = 0;/* (i < 30) && (fileSize < 52428800) && */(!this->q_content_index->empty()); ++i) {
@ -230,6 +215,8 @@ void FirstIndex::run() {
mutex2.unlock(); mutex2.unlock();
mutex3.unlock(); mutex3.unlock();
if(this->q_index) if(this->q_index)
delete this->q_index; delete this->q_index;
this->q_index = nullptr; this->q_index = nullptr;

View File

@ -35,11 +35,9 @@
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/prctl.h> #include <sys/prctl.h>
#include <syslog.h> #include <syslog.h>
//#include <QtConcurrent>
#include "traverse_bfs.h" #include "traverse_bfs.h"
#include "index-status-recorder.h" #include "index-status-recorder.h"
#include "index-generator.h" #include "index-generator.h"
#include "inotify-index.h"
#include "file-utils.h" #include "file-utils.h"
#include "common.h" #include "common.h"
namespace Zeeker { namespace Zeeker {
@ -58,31 +56,11 @@ private:
IndexGenerator* p_indexGenerator = nullptr; IndexGenerator* p_indexGenerator = nullptr;
QThreadPool m_pool; QThreadPool m_pool;
//here should be refact
// MessageListManager* mlm;
//test
QQueue<QVector<QString>>* q_index; QQueue<QVector<QString>>* q_index;
// QQueue<QString>* q_content_index; // QQueue<QString>* q_content_index;
//修改QQueue存储数据为QPair<QString,qint64>,增加存储文件大小数据便于处理时统计--jxx20210519 //修改QQueue存储数据为QPair<QString,qint64>,增加存储文件大小数据便于处理时统计--jxx20210519
QQueue<QPair<QString,qint64>>* q_content_index; QQueue<QPair<QString,qint64>>* q_content_index;
const QMap<QString, bool> targetFileTypeMap = {
std::map<QString, bool>::value_type("doc", true),
std::map<QString, bool>::value_type("docx", true),
std::map<QString, bool>::value_type("ppt", true),
std::map<QString, bool>::value_type("pptx", true),
std::map<QString, bool>::value_type("xls", true),
std::map<QString, bool>::value_type("xlsx", true),
std::map<QString, bool>::value_type("txt", true),
std::map<QString, bool>::value_type("dot", true),
std::map<QString, bool>::value_type("wps", true),
std::map<QString, bool>::value_type("pps", true),
std::map<QString, bool>::value_type("dps", true),
std::map<QString, bool>::value_type("et", true),
std::map<QString, bool>::value_type("pdf", true)
};
//xapian will auto commit per 10,000 changes, donnot change it!!! //xapian will auto commit per 10,000 changes, donnot change it!!!
const size_t u_send_length = 8192; const size_t u_send_length = 8192;
}; };

View File

@ -7280,7 +7280,7 @@ jiao 叫
shao,zhao 召 shao,zhao 召
ba,pa 叭 ba,pa 叭
ding 叮 ding 叮
ke,ge ke 可
tai,yi,si 台 tai,yi,si 台
chi,hua,e 叱 chi,hua,e 叱
shi 史 shi 史
@ -8647,7 +8647,7 @@ di,ti 奃
yan 奄 yan 奄
pao 奅 pao 奅
juan 奆 juan 奆
ji,ai,yi,qi 奇 ji,qi 奇
nai 奈 nai 奈
feng 奉 feng 奉
pi,xi,lie,xie 奊 pi,xi,lie,xie 奊

View File

@ -345,7 +345,7 @@ int FileContentSearch::getResult(Xapian::MSet &result, std::string &keyWord) {
// qWarning()<<QString::fromStdString(s); // qWarning()<<QString::fromStdString(s);
auto term = doc.termlist_begin(); auto term = doc.termlist_begin();
std::string wordTobeFound = QString::fromStdString(keyWord).section(" ", 0, 0).toStdString(); std::string wordTobeFound = QString::fromStdString(keyWord).section(" ", 0, 0).toStdString();
int size = wordTobeFound.length(); // int size = wordTobeFound.length();
term.skip_to(wordTobeFound); term.skip_to(wordTobeFound);
// int count = 0; // int count = 0;
// for(auto pos = term.positionlist_begin(); pos != term.positionlist_end() && count < 6; ++pos) { // for(auto pos = term.positionlist_begin(); pos != term.positionlist_end() && count < 6; ++pos) {

View File

@ -235,9 +235,9 @@ SearchLineEdit::SearchLineEdit(QWidget *parent) : QLineEdit(parent) {
// this->addAction(searchAction,QLineEdit::LeadingPosition); // this->addAction(searchAction,QLineEdit::LeadingPosition);
/*发送输入框文字改变的dbus*/ /*发送输入框文字改变的dbus*/
QDBusConnection::sessionBus().unregisterService("org.ukui.search.service"); // QDBusConnection::sessionBus().unregisterService("org.ukui.search.service");
QDBusConnection::sessionBus().registerService("org.ukui.search.service"); // QDBusConnection::sessionBus().registerService("org.ukui.search.service");
QDBusConnection::sessionBus().registerObject("/lineEdit/textChanged", this, QDBusConnection :: ExportAllSlots | QDBusConnection :: ExportAllSignals); // QDBusConnection::sessionBus().registerObject("/lineEdit/textChanged", this, QDBusConnection :: ExportAllSlots | QDBusConnection :: ExportAllSignals);
connect(this, &QLineEdit::textChanged, this, &SearchLineEdit::lineEditTextChanged); connect(this, &QLineEdit::textChanged, this, &SearchLineEdit::lineEditTextChanged);
connect(this, &QLineEdit::textChanged, this, [ = ]() { connect(this, &QLineEdit::textChanged, this, [ = ]() {

View File

@ -94,11 +94,11 @@ private:
class SearchLineEdit : public QLineEdit { class SearchLineEdit : public QLineEdit {
Q_OBJECT Q_OBJECT
/* // /*
* ukui桌面环境应用通信的dbus // * 负责与ukui桌面环境应用通信的dbus
* // * 搜索框文本改变的时候发送信号
   */ //    */
Q_CLASSINFO("D-Bus Interface", "org.ukui.search.inputbox") // Q_CLASSINFO("D-Bus Interface", "org.ukui.search.inputbox")
public: public:
SearchLineEdit(QWidget *parent = nullptr); SearchLineEdit(QWidget *parent = nullptr);
void record(); void record();

View File

@ -39,6 +39,7 @@
//#include "inotify-manager.h" //#include "inotify-manager.h"
#include "libsearch.h" #include "libsearch.h"
#include "global-settings.h" #include "global-settings.h"
#include "ukui-search-dbus-service.h"
using namespace Zeeker; using namespace Zeeker;
//void handler(int){ //void handler(int){
@ -279,6 +280,7 @@ int main(int argc, char *argv[]) {
//set main window to the center of screen //set main window to the center of screen
MainWindow *w = new MainWindow; MainWindow *w = new MainWindow;
UkuiSearchDbusServices dbusService(w);
qApp->setWindowIcon(QIcon::fromTheme("kylin-search")); qApp->setWindowIcon(QIcon::fromTheme("kylin-search"));
// centerToScreen(w); // centerToScreen(w);
// w->moveToPanel(); // w->moveToPanel();

View File

@ -472,16 +472,16 @@ void MainWindow::centerToScreen(QWidget* widget) {
int desk_y = desk_rect.height(); int desk_y = desk_rect.height();
int x = widget->width(); int x = widget->width();
int y = widget->height(); int y = widget->height();
QDBusInterface primaryScreenInterface("org.ukui.SettingsDaemon", // QDBusInterface primaryScreenInterface("org.ukui.SettingsDaemon",
"/org/ukui/SettingsDaemon/wayland", // "/org/ukui/SettingsDaemon/wayland",
"org.ukui.SettingsDaemon.wayland", // "org.ukui.SettingsDaemon.wayland",
QDBusConnection::sessionBus()); // QDBusConnection::sessionBus());
if(QDBusReply<int>(primaryScreenInterface.call("x")).isValid()) { // if(QDBusReply<int>(primaryScreenInterface.call("x")).isValid()) {
QDBusReply<int> width = primaryScreenInterface.call("width"); // QDBusReply<int> width = primaryScreenInterface.call("width");
QDBusReply<int> height = primaryScreenInterface.call("height"); // QDBusReply<int> height = primaryScreenInterface.call("height");
desk_x = width; // desk_x = width;
desk_y = height; // desk_y = height;
} // }
widget->move(desk_x / 2 - x / 2 + desk_rect.left(), desk_y / 2 - y / 2 + desk_rect.top()); widget->move(desk_x / 2 - x / 2 + desk_rect.left(), desk_y / 2 - y / 2 + desk_rect.top());
} }

View File

@ -35,6 +35,7 @@ SOURCES += \
search-app-thread.cpp \ search-app-thread.cpp \
search-result.cpp \ search-result.cpp \
settings-widget.cpp \ settings-widget.cpp \
ukui-search-dbus-service.cpp \
xatom-helper.cpp xatom-helper.cpp
@ -46,6 +47,7 @@ HEADERS += \
search-app-thread.h \ search-app-thread.h \
search-result.h \ search-result.h \
settings-widget.h \ settings-widget.h \
ukui-search-dbus-service.h \
xatom-helper.h xatom-helper.h
# Default rules for deployment. # Default rules for deployment.

View File

@ -0,0 +1,23 @@
#include "ukui-search-dbus-service.h"
using namespace Zeeker;
void UkuiSearchDbusServices::showWindow(){
m_mainWindow->bootOptionsFilter("-s");
}
UkuiSearchDbusServices::UkuiSearchDbusServices(MainWindow *m)
{
m_mainWindow = m;
//注册服务
QDBusConnection sessionBus = QDBusConnection::sessionBus();
QDBusConnection::sessionBus().unregisterService("com.ukui.search.service");
if(!sessionBus.registerService("com.ukui.search.service")){
qWarning() << "ukui-search dbus register service failed reason:" << sessionBus.lastError();
}
if(!sessionBus.registerObject("/", this, QDBusConnection::ExportAllSlots)){
qWarning() << "ukui-search dbus register object failed reason:" << sessionBus.lastError();
}
}
UkuiSearchDbusServices::~UkuiSearchDbusServices(){
}

View File

@ -0,0 +1,28 @@
#ifndef UKUISEARCHDBUSSERVICE_H
#define UKUISEARCHDBUSSERVICE_H
#include <QDBusConnection>
#include <QObject>
#include "mainwindow.h"
namespace Zeeker {
class UkuiSearchDbusServices: public QObject{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface","org.ukui.search.service")
public:
explicit UkuiSearchDbusServices(MainWindow *m);
~UkuiSearchDbusServices();
public Q_SLOTS:
void showWindow();
private:
MainWindow *m_mainWindow;
};
}
#endif // UKUISEARCHDBUSSERVICE_H

View File

@ -22,7 +22,7 @@ target.path = /usr/bin
INSTALLS += \ INSTALLS += \
target \ target \
inst1 \ inst1 \
inst2 \ inst2
HEADERS += \ HEADERS += \
sysdbusregister.h sysdbusregister.h