Update debian files and some interface optimization.

This commit is contained in:
zhangpengfei 2021-01-06 17:42:35 +08:00
parent a88b26e099
commit 5b11ba39c6
8 changed files with 92 additions and 41 deletions

9
debian/control vendored
View File

@ -54,4 +54,11 @@ Depends: ${misc:Depends},
${shlibs:Depends},
libukui-search0 (= ${binary:Version}),
libchinese-segmentation0 (= ${binary:Version})
Description: Libraries for ukui-search(development files).
Description: Libraries for ukui-search(development files).
Package: ukui-search-systemdbus
Architecture: any
Depends: ${shlibs:Depends},
${misc:Depends},
Description: ukui-search-systemdbus is a systembus interface to modify max_user_watches nums
permanent.

3
debian/ukui-search-systemdbus.install vendored Normal file
View File

@ -0,0 +1,3 @@
/usr/share/dbus-1/system-services/com.ukui.search.qt.systemdbus.service
/etc/dbus-1/system.d/com.ukui.search.qt.systemdbus.conf
/usr/bin/ukui-search-systemdbus

View File

@ -1 +1 @@
usr/bin/*
usr/bin/ukui-search

View File

@ -66,7 +66,7 @@ void FileSearcher::onKeywordSearch(QString keyword, int begin, int num)
}
catch(const Xapian::Error &e)
{
qDebug() <<QString::fromStdString(e.get_description());
qWarning() <<QString::fromStdString(e.get_description());
return;
}
Q_EMIT this->result(searchResult);
@ -116,7 +116,7 @@ void FileSearcher::onKeywordSearchContent(QString keyword, int begin, int num)
}
catch(const Xapian::Error &e)
{
qDebug() <<QString::fromStdString(e.get_description());
qWarning() <<QString::fromStdString(e.get_description());
qDebug()<< "--content search finish--";
return;
}

View File

@ -18,10 +18,10 @@ using namespace std;
static IndexGenerator *global_instance = nullptr;
IndexGenerator *IndexGenerator::getInstance()
IndexGenerator *IndexGenerator::getInstance(bool rebuild)
{
if (!global_instance) {
global_instance = new IndexGenerator;
global_instance = new IndexGenerator(rebuild);
}
return global_instance;
}
@ -58,12 +58,11 @@ bool IndexGenerator::creatAllIndex(QList<QVector<QString> > *messageList)
}
catch(const Xapian::Error &e)
{
qWarning()<<"creatAllIndex fail!"<<QString::fromStdString(e.get_description());
qWarning()<<__FILE__<<__LINE__<<__FUNCTION__<<"creatAllIndex fail!"<<QString::fromStdString(e.get_description());
//need a record
GlobalSettings::getInstance()->setValue(INDEX_DATABASE_STATE,"0");
return false;
GlobalSettings::getInstance()->setValue(INDEX_DATABASE_STATE,"1");
Q_ASSERT(false);
}
GlobalSettings::getInstance()->setValue(INDEX_DATABASE_STATE,"1");
m_doc_list_path->clear();
Q_EMIT this->transactionFinished();
@ -90,22 +89,30 @@ bool IndexGenerator::creatAllIndex(QList<QString> *messageList)
}
catch(const Xapian::Error &e)
{
qWarning()<<"creat content Index fail!"<<QString::fromStdString(e.get_description());
GlobalSettings::getInstance()->setValue(CONTENT_INDEX_DATABASE_STATE,"0");
return false;
qWarning()<<__FILE__<<__LINE__<<__FUNCTION__<<"creat content Index fail!"<<QString::fromStdString(e.get_description());
GlobalSettings::getInstance()->setValue(CONTENT_INDEX_DATABASE_STATE,"1");
Q_ASSERT(false);
}
GlobalSettings::getInstance()->setValue(CONTENT_INDEX_DATABASE_STATE,"1");
m_doc_list_content->clear();
Q_EMIT this->transactionFinished();
return true;
}
IndexGenerator::IndexGenerator(QObject *parent) : QObject(parent)
IndexGenerator::IndexGenerator(bool rebuild, QObject *parent) : QObject(parent)
{
m_datebase_path = new Xapian::WritableDatabase(INDEX_PATH, Xapian::DB_CREATE_OR_OPEN);
m_database_content = new Xapian::WritableDatabase(CONTENT_INDEX_PATH, Xapian::DB_CREATE_OR_OPEN);
GlobalSettings::getInstance()->setValue(CONTENT_INDEX_DATABASE_STATE,"1");
if(rebuild)
{
m_datebase_path = new Xapian::WritableDatabase(INDEX_PATH, Xapian::DB_CREATE_OR_OVERWRITE);
m_database_content = new Xapian::WritableDatabase(CONTENT_INDEX_PATH, Xapian::DB_CREATE_OR_OVERWRITE);
}
else
{
m_datebase_path = new Xapian::WritableDatabase(INDEX_PATH, Xapian::DB_CREATE_OR_OPEN);
m_database_content = new Xapian::WritableDatabase(CONTENT_INDEX_PATH, Xapian::DB_CREATE_OR_OPEN);
}
GlobalSettings::getInstance()->setValue(INDEX_DATABASE_STATE,"0");
GlobalSettings::getInstance()->setValue(CONTENT_INDEX_DATABASE_STATE,"0");
}
IndexGenerator::~IndexGenerator()
@ -114,7 +121,8 @@ IndexGenerator::~IndexGenerator()
delete m_datebase_path;
if(m_database_content)
delete m_database_content;
GlobalSettings::getInstance()->setValue(INDEX_GENERATOR_NORMAL_EXIT,"1");
GlobalSettings::getInstance()->setValue(INDEX_DATABASE_STATE,"2");
GlobalSettings::getInstance()->setValue(INDEX_GENERATOR_NORMAL_EXIT,"2");
}
void IndexGenerator::insertIntoDatabase(Document doc)
@ -341,7 +349,7 @@ bool IndexGenerator::deleteAllIndex(QStringList *pathlist)
}
catch(const Xapian::Error &e)
{
qWarning() <<QString::fromStdString(e.get_description());
qWarning() <<__FILE__<<__LINE__<<__FUNCTION__<<QString::fromStdString(e.get_description());
return false;
}
}

View File

@ -14,7 +14,7 @@ class IndexGenerator : public QObject
{
Q_OBJECT
public:
static IndexGenerator *getInstance();
static IndexGenerator *getInstance(bool rebuild = false);
bool setIndexdataPath();
bool isIndexdataExist();
static QStringList IndexSearch(QString indexText);
@ -27,7 +27,7 @@ public Q_SLOTS:
bool deleteAllIndex(QStringList *pathlist);
private:
explicit IndexGenerator(QObject *parent = nullptr);
explicit IndexGenerator(bool rebuild = false,QObject *parent = nullptr);
~IndexGenerator();
//For file name index
void HandlePathList(QList<QVector<QString>> *messageList);

View File

@ -25,7 +25,7 @@ include(index/index.pri)
include(appsearch/appsearch.pri)
include(settingsearch/settingsearch.pri))
LIBS += -L../libchinese-segmentation/ -lchinese-segmentation
LIBS += -L$$OUT_PWD/../libchinese-segmentation/ -lchinese-segmentation
LIBS += -lxapian -lquazip5
SOURCES += \

View File

@ -32,6 +32,48 @@
#include "libsearch.h"
#include "global-settings.h"
void messageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
QByteArray localMsg = msg.toLocal8Bit();
QByteArray currentTime = QTime::currentTime().toString().toLocal8Bit();
bool showDebug = true;
QString logFilePath = QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/ukui-search.log";
if (!QFile::exists(logFilePath)) {
showDebug = false;
}
FILE *log_file = nullptr;
if (showDebug) {
log_file = fopen(logFilePath.toLocal8Bit().constData(), "a+");
}
const char *file = context.file ? context.file : "";
const char *function = context.function ? context.function : "";
switch (type) {
case QtDebugMsg:
if (!log_file) {
break;
}
fprintf(log_file, "Debug: %s: %s (%s:%u, %s)\n", currentTime.constData(), localMsg.constData(), file, context.line, function);
break;
case QtInfoMsg:
fprintf(log_file? log_file: stdout, "Info: %s: %s (%s:%u, %s)\n", currentTime.constData(), localMsg.constData(), file, context.line, function);
break;
case QtWarningMsg:
fprintf(log_file? log_file: stderr, "Warning: %s: %s (%s:%u, %s)\n", currentTime.constData(), localMsg.constData(), file, context.line, function);
break;
case QtCriticalMsg:
fprintf(log_file? log_file: stderr, "Critical: %s: %s (%s:%u, %s)\n", currentTime.constData(), localMsg.constData(), file, context.line, function);
break;
case QtFatalMsg:
fprintf(log_file? log_file: stderr, "Fatal: %s: %s (%s:%u, %s)\n", currentTime.constData(), localMsg.constData(), file, context.line, function);
break;
}
if (log_file)
fclose(log_file);
}
void centerToScreen(QWidget* widget) {
if (!widget)
@ -64,37 +106,28 @@ int main(int argc, char *argv[])
// qDebug() << t2;
/*-------------InotyifyRefact Test End-----------------*/
/*-------------content index Test Start---------------*/
QTime t3 = QTime::currentTime();
FileTypeFilter* ftf = new FileTypeFilter("/home");
ftf->Test();
QTime t4 = QTime::currentTime();
delete ftf;
ftf = nullptr;
qDebug() << t3;
qDebug() << t4;
// QTime t3 = QTime::currentTime();
// FileTypeFilter* ftf = new FileTypeFilter("/home");
// ftf->Test();
// QTime t4 = QTime::currentTime();
// delete ftf;
// ftf = nullptr;
// qDebug() << t3;
// qDebug() << t4;
/*-------------content index Test End-----------------*/
/*-------------文本搜索 Test start-----------------*/
// FileSearcher *search = new FileSearcher();
// search->onKeywordSearchContent("重要器官移植⑤白血病");
// search->onKeywordSearchContent("g,e,x");
/*-------------文本搜索 Test End-----------------*/
/*-------------GlobalSettings Test start-----------------*/
// GlobalSettings::getInstance();
/*-------------GlobalSettings Test End-----------------*/
qRegisterMetaType<QVector<QStringList>>("QVector<QStringList>");
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QtSingleApplication app("ukui-search", argc, argv);
app.setQuitOnLastWindowClosed(false);
qInstallMessageHandler(messageOutput);
if(app.isRunning())
{