💩💩💩add class ukui-search-qdbus and turn PWD to OUT_PWD

This commit is contained in:
zhangzihao 2021-01-06 14:14:38 +08:00
parent 9b77757652
commit 842fe557bb
9 changed files with 73 additions and 6 deletions

View File

@ -41,3 +41,4 @@ void FileTypeFilter::Test(){
ig->creatAllIndex(this->result); ig->creatAllIndex(this->result);
} }

View File

@ -13,7 +13,8 @@ HEADERS += \
$$PWD/messagelisttemplate.h \ $$PWD/messagelisttemplate.h \
$$PWD/traverse_bfs.h \ $$PWD/traverse_bfs.h \
# $$PWD/text-content-indexer.h \ # $$PWD/text-content-indexer.h \
$$PWD/file-searcher.h $$PWD/file-searcher.h \
$$PWD/ukui-search-qdbus.h
SOURCES += \ SOURCES += \
# $$PWD/chinesecharacterstopinyin.cpp \ # $$PWD/chinesecharacterstopinyin.cpp \
@ -29,5 +30,6 @@ SOURCES += \
$$PWD/test-Inotify-Manager.cpp \ $$PWD/test-Inotify-Manager.cpp \
$$PWD/traverse_bfs.cpp \ $$PWD/traverse_bfs.cpp \
# $$PWD/text-content-indexer.cpp \ # $$PWD/text-content-indexer.cpp \
$$PWD/file-searcher.cpp $$PWD/file-searcher.cpp \
$$PWD/ukui-search-qdbus.cpp

View File

@ -1,7 +1,18 @@
#include "inotify.h" #include "inotify.h"
#include "ukui-search-qdbus.h"
InotifyManagerRefact::InotifyManagerRefact(const QString& path) : Traverse_BFS(path) InotifyManagerRefact::InotifyManagerRefact(const QString& path) : Traverse_BFS(path)
{ {
/*-------------ukuisearchdbus Test start-----------------*/
qDebug() << "setInotifyMaxUserWatches start";
UkuiSearchQDBus usQDBus;
usQDBus.setInotifyMaxUserWatches();
qDebug() << "setInotifyMaxUserWatches end";
/*-------------ukuisearchdbus Test End-----------------*/
// dirPath = new QMap<QString, QStringList>(); // dirPath = new QMap<QString, QStringList>();
m_fd = inotify_init(); m_fd = inotify_init();
qDebug() << "m_fd----------->" <<m_fd; qDebug() << "m_fd----------->" <<m_fd;

View File

@ -0,0 +1,29 @@
#include "ukui-search-qdbus.h"
#include <QDebug>
UkuiSearchQDBus::UkuiSearchQDBus()
{
this->tmpSystemQDBusInterface = new QDBusInterface("com.ukui.search.qt.systemdbus",
"/",
"com.ukui.search.interface",
QDBusConnection::systemBus());
if (!tmpSystemQDBusInterface->isValid()){
qCritical() << "Create Client Interface Failed When execute chage: " << QDBusConnection::systemBus().lastError();
return;
}
}
UkuiSearchQDBus::~UkuiSearchQDBus(){
delete this->tmpSystemQDBusInterface;
this->tmpSystemQDBusInterface = nullptr;
}
//一键三连
void UkuiSearchQDBus::setInotifyMaxUserWatches()
{
// /proc/sys/fs/inotify/max_user_watches
this->tmpSystemQDBusInterface->call("setInotifyMaxUseWatchesStep1");
// sysctl
this->tmpSystemQDBusInterface->call("setInotifyMaxUseWatchesStep2");
// /etc/sysctl.conf
this->tmpSystemQDBusInterface->call("setInotifyMaxUseWatchesStep3");
}

View File

@ -0,0 +1,16 @@
#ifndef UKUISEARCHQDBUS_H
#define UKUISEARCHQDBUS_H
#include <QDBusInterface>
class UkuiSearchQDBus
{
public:
UkuiSearchQDBus();
~UkuiSearchQDBus();
void setInotifyMaxUserWatches();
private:
QDBusInterface* tmpSystemQDBusInterface;
};
#endif // UKUISEARCHQDBUS_H

View File

@ -10,6 +10,8 @@
#include "index/filetypefilter.h" #include "index/filetypefilter.h"
#include "index/ukui-search-qdbus.h"
class LIBSEARCH_EXPORT GlobalSearch class LIBSEARCH_EXPORT GlobalSearch
{ {
public: public:

View File

@ -1,4 +1,4 @@
QT += core concurrent xml widgets QT += core concurrent xml widgets dbus
VERSION = 0.0.1 VERSION = 0.0.1
TARGET = ukui-search TARGET = ukui-search

View File

@ -47,6 +47,12 @@ void centerToScreen(QWidget* widget) {
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
/*-------------ukuisearchdbus Test start-----------------*/
// UkuiSearchQDBus usQDBus;
// usQDBus.setInotifyMaxUserWatches();
/*-------------ukuisearchdbus Test End-----------------*/
//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---------------*/ /*-------------InotyifyRefact Test Start---------------*/
@ -58,7 +64,7 @@ int main(int argc, char *argv[])
qDebug() << t2; qDebug() << t2;
/*-------------InotyifyRefact Test End-----------------*/ /*-------------InotyifyRefact Test End-----------------*/
/*-------------InotyifyRefact Test Start---------------*/ /*-------------content index Test Start---------------*/
QTime t3 = QTime::currentTime(); QTime t3 = QTime::currentTime();
FileTypeFilter* ftf = new FileTypeFilter("/home"); FileTypeFilter* ftf = new FileTypeFilter("/home");
ftf->Test(); ftf->Test();
@ -67,7 +73,7 @@ int main(int argc, char *argv[])
ftf = nullptr; ftf = nullptr;
qDebug() << t3; qDebug() << t3;
qDebug() << t4; qDebug() << t4;
/*-------------InotyifyRefact Test End-----------------*/ /*-------------content index Test End-----------------*/
/*-------------文本搜索 Test start-----------------*/ /*-------------文本搜索 Test start-----------------*/
// FileSearcher *search = new FileSearcher(); // FileSearcher *search = new FileSearcher();

View File

@ -57,7 +57,7 @@ qm_files.files = $$OUT_PWD/res/translations/*.qm
INSTALLS += \ INSTALLS += \
qm_files \ qm_files \
LIBS += -L$$PWD/../libsearch -lukui-search -L$$PWD/../libchinese-segmentation/ -lchinese-segmentation LIBS += -L$$OUT_PWD/../libsearch -L$$OUT_PWD/../libchinese-segmentation/ -lchinese-segmentation -lukui-search
INCLUDEPATH += $$PWD/../libsearch INCLUDEPATH += $$PWD/../libsearch
DEPENDPATH += $$PWD/../libsearch DEPENDPATH += $$PWD/../libsearch