forked from openkylin/ukui-search
Merge from dev-unity.
This commit is contained in:
commit
1e0f66c8ff
|
@ -1,72 +1,53 @@
|
|||
# This file is used to ignore files which are generated
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
*~
|
||||
*.autosave
|
||||
*.a
|
||||
*.core
|
||||
*.moc
|
||||
# C++ objects and libs
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
*.orig
|
||||
*.rej
|
||||
*.a
|
||||
*.la
|
||||
*.lai
|
||||
*.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
|
||||
*.dll
|
||||
*.dylib
|
||||
|
||||
# Qt-es
|
||||
object_script.*.Release
|
||||
object_script.*.Debug
|
||||
*_plugin_import.cpp
|
||||
/.qmake.cache
|
||||
/.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
|
||||
*.pro.user*
|
||||
# Qt unit tests
|
||||
target_wrapper.*
|
||||
|
||||
# xemacs temporary files
|
||||
*.flc
|
||||
# QtCreator
|
||||
*.autosave
|
||||
|
||||
# Vim temporary files
|
||||
.*.swp
|
||||
# QtCreator Qml
|
||||
*.qmlproject.user
|
||||
*.qmlproject.user.*
|
||||
|
||||
# Visual Studio generated files
|
||||
*.ib_pdb_index
|
||||
*.idb
|
||||
*.ilk
|
||||
*.pdb
|
||||
*.sln
|
||||
*.suo
|
||||
*.vcproj
|
||||
*vcproj.*.*.user
|
||||
*.ncb
|
||||
*.sdf
|
||||
*.opensdf
|
||||
*.vcxproj
|
||||
*vcxproj.*
|
||||
# QtCreator CMake
|
||||
CMakeLists.txt.user*
|
||||
|
||||
# MinGW generated files
|
||||
*.Debug
|
||||
*.Release
|
||||
|
||||
# Python byte code
|
||||
*.pyc
|
||||
|
||||
# Binaries
|
||||
# --------
|
||||
*.dll
|
||||
*.exe
|
||||
# QtCreator 4.8< compilation database
|
||||
compile_commands.json
|
||||
|
||||
# QtCreator local machine specific files for imported projects
|
||||
*creator.user*
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
[Desktop Entry]
|
||||
Name=Search
|
||||
Name[zh_CN]=搜索
|
||||
Name[bo_CN]=བཤེར་འཚོལ།
|
||||
GenericName=UKUI Global Search
|
||||
GenericName[zh_CN]=全局搜索
|
||||
GenericName[bo_CN]=བཤེར་འཚོལ།
|
||||
Comment=ukui-search
|
||||
Comment[zh_CN]=全局搜索
|
||||
Comment[bo_CN]=ཁྱོན་ཡོངས་བཤེར་འཚོལ།
|
||||
Exec=/usr/bin/ukui-search -s
|
||||
Type=Application
|
||||
Icon=kylin-search
|
||||
|
|
|
@ -95,9 +95,7 @@ void FirstIndex::DoSomething(const QFileInfo& fileInfo) {
|
|||
|
||||
void FirstIndex::run() {
|
||||
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.
|
||||
|
||||
QString indexDataBaseStatus = IndexStatusRecorder::getInstance()->getStatus(INDEX_DATABASE_STATE).toString();
|
||||
QString contentIndexDataBaseStatus = IndexStatusRecorder::getInstance()->getStatus(CONTENT_INDEX_DATABASE_STATE).toString();
|
||||
QString inotifyIndexStatus = IndexStatusRecorder::getInstance()->getStatus(INOTIFY_NORMAL_EXIT).toString();
|
||||
|
@ -106,7 +104,6 @@ void FirstIndex::run() {
|
|||
qDebug() << "contentIndexDataBaseStatus: " << contentIndexDataBaseStatus;
|
||||
qDebug() << "inotifyIndexStatus: " << inotifyIndexStatus;
|
||||
|
||||
/* || contentIndexDataBaseStatus == ""*/
|
||||
if(indexDataBaseStatus == "") {
|
||||
this->bool_dataBaseExist = false;
|
||||
} else {
|
||||
|
@ -119,9 +116,6 @@ void FirstIndex::run() {
|
|||
}
|
||||
|
||||
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>>();
|
||||
|
||||
int fifo_fd;
|
||||
|
@ -135,11 +129,6 @@ void FirstIndex::run() {
|
|||
assert(false);
|
||||
}
|
||||
|
||||
// this->q_content_index->enqueue(QString("/home/zhangzihao/Desktop/qwerty/四库全书.txt"));
|
||||
|
||||
// this->p_indexGenerator->creatAllIndex(this->q_content_index);
|
||||
|
||||
|
||||
++FileUtils::_index_status;
|
||||
pid_t pid;
|
||||
pid = fork();
|
||||
|
@ -157,7 +146,6 @@ void FirstIndex::run() {
|
|||
} else {
|
||||
// p_indexGenerator = IndexGenerator::getInstance(false,this);
|
||||
p_indexGenerator = IndexGenerator::getInstance(true, this);
|
||||
|
||||
}
|
||||
//TODO Fix these weird code.
|
||||
QSemaphore sem(5);
|
||||
|
@ -166,7 +154,6 @@ void FirstIndex::run() {
|
|||
mutex2.lock();
|
||||
mutex3.lock();
|
||||
sem.acquire(4);
|
||||
// QtConcurrent::run([&](){
|
||||
sem.acquire(1);
|
||||
mutex1.unlock();
|
||||
this->setPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
|
||||
|
@ -174,7 +161,6 @@ void FirstIndex::run() {
|
|||
FileUtils::_max_index_count = this->q_index->length();
|
||||
qDebug() << "max_index_count:" << FileUtils::_max_index_count;
|
||||
sem.release(5);
|
||||
// });
|
||||
QtConcurrent::run(&m_pool, [&]() {
|
||||
sem.acquire(2);
|
||||
mutex2.unlock();
|
||||
|
@ -197,7 +183,6 @@ void FirstIndex::run() {
|
|||
QQueue<QString>* tmp2 = new QQueue<QString>();
|
||||
qDebug() << "q_content_index:" << q_content_index->size();
|
||||
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;
|
||||
//修改一次处理的数据量,从30个文件改为文件总大小为50M以下,50M为暂定值--jxx20210519
|
||||
for(size_t i = 0;/* (i < 30) && (fileSize < 52428800) && */(!this->q_content_index->empty()); ++i) {
|
||||
|
@ -230,6 +215,8 @@ void FirstIndex::run() {
|
|||
mutex2.unlock();
|
||||
mutex3.unlock();
|
||||
|
||||
|
||||
|
||||
if(this->q_index)
|
||||
delete this->q_index;
|
||||
this->q_index = nullptr;
|
||||
|
|
|
@ -35,11 +35,9 @@
|
|||
#include <sys/wait.h>
|
||||
#include <sys/prctl.h>
|
||||
#include <syslog.h>
|
||||
//#include <QtConcurrent>
|
||||
#include "traverse_bfs.h"
|
||||
#include "index-status-recorder.h"
|
||||
#include "index-generator.h"
|
||||
#include "inotify-index.h"
|
||||
#include "file-utils.h"
|
||||
#include "common.h"
|
||||
namespace Zeeker {
|
||||
|
@ -58,31 +56,11 @@ private:
|
|||
IndexGenerator* p_indexGenerator = nullptr;
|
||||
QThreadPool m_pool;
|
||||
|
||||
//here should be refact
|
||||
// MessageListManager* mlm;
|
||||
|
||||
//test
|
||||
QQueue<QVector<QString>>* q_index;
|
||||
// QQueue<QString>* q_content_index;
|
||||
//修改QQueue存储数据为QPair<QString,qint64>,增加存储文件大小数据便于处理时统计--jxx20210519
|
||||
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!!!
|
||||
const size_t u_send_length = 8192;
|
||||
};
|
||||
|
|
|
@ -7280,7 +7280,7 @@ jiao 叫
|
|||
shao,zhao 召
|
||||
ba,pa 叭
|
||||
ding 叮
|
||||
ke,ge 可
|
||||
ke 可
|
||||
tai,yi,si 台
|
||||
chi,hua,e 叱
|
||||
shi 史
|
||||
|
@ -8647,7 +8647,7 @@ di,ti 奃
|
|||
yan 奄
|
||||
pao 奅
|
||||
juan 奆
|
||||
ji,ai,yi,qi 奇
|
||||
ji,qi 奇
|
||||
nai 奈
|
||||
feng 奉
|
||||
pi,xi,lie,xie 奊
|
||||
|
|
|
@ -345,7 +345,7 @@ int FileContentSearch::getResult(Xapian::MSet &result, std::string &keyWord) {
|
|||
// qWarning()<<QString::fromStdString(s);
|
||||
auto term = doc.termlist_begin();
|
||||
std::string wordTobeFound = QString::fromStdString(keyWord).section(" ", 0, 0).toStdString();
|
||||
int size = wordTobeFound.length();
|
||||
// int size = wordTobeFound.length();
|
||||
term.skip_to(wordTobeFound);
|
||||
// int count = 0;
|
||||
// for(auto pos = term.positionlist_begin(); pos != term.positionlist_end() && count < 6; ++pos) {
|
||||
|
|
|
@ -235,9 +235,9 @@ SearchLineEdit::SearchLineEdit(QWidget *parent) : QLineEdit(parent) {
|
|||
// this->addAction(searchAction,QLineEdit::LeadingPosition);
|
||||
|
||||
/*发送输入框文字改变的dbus*/
|
||||
QDBusConnection::sessionBus().unregisterService("org.ukui.search.service");
|
||||
QDBusConnection::sessionBus().registerService("org.ukui.search.service");
|
||||
QDBusConnection::sessionBus().registerObject("/lineEdit/textChanged", this, QDBusConnection :: ExportAllSlots | QDBusConnection :: ExportAllSignals);
|
||||
// QDBusConnection::sessionBus().unregisterService("org.ukui.search.service");
|
||||
// QDBusConnection::sessionBus().registerService("org.ukui.search.service");
|
||||
// QDBusConnection::sessionBus().registerObject("/lineEdit/textChanged", this, QDBusConnection :: ExportAllSlots | QDBusConnection :: ExportAllSignals);
|
||||
|
||||
connect(this, &QLineEdit::textChanged, this, &SearchLineEdit::lineEditTextChanged);
|
||||
connect(this, &QLineEdit::textChanged, this, [ = ]() {
|
||||
|
|
|
@ -94,11 +94,11 @@ private:
|
|||
class SearchLineEdit : public QLineEdit {
|
||||
Q_OBJECT
|
||||
|
||||
/*
|
||||
* 负责与ukui桌面环境应用通信的dbus
|
||||
* 搜索框文本改变的时候发送信号
|
||||
*/
|
||||
Q_CLASSINFO("D-Bus Interface", "org.ukui.search.inputbox")
|
||||
// /*
|
||||
// * 负责与ukui桌面环境应用通信的dbus
|
||||
// * 搜索框文本改变的时候发送信号
|
||||
// */
|
||||
// Q_CLASSINFO("D-Bus Interface", "org.ukui.search.inputbox")
|
||||
public:
|
||||
SearchLineEdit(QWidget *parent = nullptr);
|
||||
void record();
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
//#include "inotify-manager.h"
|
||||
#include "libsearch.h"
|
||||
#include "global-settings.h"
|
||||
#include "ukui-search-dbus-service.h"
|
||||
|
||||
using namespace Zeeker;
|
||||
//void handler(int){
|
||||
|
@ -279,6 +280,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
//set main window to the center of screen
|
||||
MainWindow *w = new MainWindow;
|
||||
UkuiSearchDbusServices dbusService(w);
|
||||
qApp->setWindowIcon(QIcon::fromTheme("kylin-search"));
|
||||
// centerToScreen(w);
|
||||
// w->moveToPanel();
|
||||
|
|
|
@ -472,16 +472,16 @@ void MainWindow::centerToScreen(QWidget* widget) {
|
|||
int desk_y = desk_rect.height();
|
||||
int x = widget->width();
|
||||
int y = widget->height();
|
||||
QDBusInterface primaryScreenInterface("org.ukui.SettingsDaemon",
|
||||
"/org/ukui/SettingsDaemon/wayland",
|
||||
"org.ukui.SettingsDaemon.wayland",
|
||||
QDBusConnection::sessionBus());
|
||||
if(QDBusReply<int>(primaryScreenInterface.call("x")).isValid()) {
|
||||
QDBusReply<int> width = primaryScreenInterface.call("width");
|
||||
QDBusReply<int> height = primaryScreenInterface.call("height");
|
||||
desk_x = width;
|
||||
desk_y = height;
|
||||
}
|
||||
// QDBusInterface primaryScreenInterface("org.ukui.SettingsDaemon",
|
||||
// "/org/ukui/SettingsDaemon/wayland",
|
||||
// "org.ukui.SettingsDaemon.wayland",
|
||||
// QDBusConnection::sessionBus());
|
||||
// if(QDBusReply<int>(primaryScreenInterface.call("x")).isValid()) {
|
||||
// QDBusReply<int> width = primaryScreenInterface.call("width");
|
||||
// QDBusReply<int> height = primaryScreenInterface.call("height");
|
||||
// desk_x = width;
|
||||
// desk_y = height;
|
||||
// }
|
||||
widget->move(desk_x / 2 - x / 2 + desk_rect.left(), desk_y / 2 - y / 2 + desk_rect.top());
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ SOURCES += \
|
|||
search-app-thread.cpp \
|
||||
search-result.cpp \
|
||||
settings-widget.cpp \
|
||||
ukui-search-dbus-service.cpp \
|
||||
xatom-helper.cpp
|
||||
|
||||
|
||||
|
@ -46,6 +47,7 @@ HEADERS += \
|
|||
search-app-thread.h \
|
||||
search-result.h \
|
||||
settings-widget.h \
|
||||
ukui-search-dbus-service.h \
|
||||
xatom-helper.h
|
||||
|
||||
# Default rules for deployment.
|
||||
|
|
|
@ -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(){
|
||||
}
|
|
@ -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
|
|
@ -22,7 +22,7 @@ target.path = /usr/bin
|
|||
INSTALLS += \
|
||||
target \
|
||||
inst1 \
|
||||
inst2 \
|
||||
inst2
|
||||
|
||||
HEADERS += \
|
||||
sysdbusregister.h
|
||||
|
|
Loading…
Reference in New Issue