Merge pull request #85 from iaom/0113-dev

支持了更多的文本文件編碼格式;更新changelog。
This commit is contained in:
张佳萍 2021-01-14 21:02:36 +08:00 committed by GitHub
commit 74a8583b90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 3 deletions

13
debian/changelog vendored
View File

@ -1,3 +1,16 @@
ukui-search (0.0.1+0114) v101; urgency=medium
* Bugs fixed.
-- zhangpengfei <zhangpengfei@zhangpengfei> Thu, 14 Jan 2021 20:47:42 +0800
ukui-search (0.0.1+0113) v101; urgency=medium
* Bugs fixed.
* Functions perfected.
-- zhangpengfei <zhangpengfei@kylinos.cn> Wed, 13 Jan 2021 18:55:43 +0800
ukui-search (0.0.1+0104) v101; urgency=medium
* Initial release.

3
debian/control vendored
View File

@ -15,7 +15,8 @@ Build-Depends: debhelper (>=9.0.0),
libglib2.0-dev,
libkf5windowsystem-dev,
libgsettings-qt-dev,
libqt5x11extras5-dev
libqt5x11extras5-dev,
libuchardet-dev
Standards-Version: 4.5.0
Homepage: https://www.ukui.org/
Vcs-Git: https://github.com/ukui/ukui-search.git

View File

@ -10,6 +10,7 @@
#include <QMimeDatabase>
#include <QMimeType>
#include <QQueue>
#include "uchardet/uchardet.h"
size_t FileUtils::_max_index_count = 0;
size_t FileUtils::_current_index_count = 0;
unsigned short FileUtils::_index_status = INITIAL_STATE;
@ -512,6 +513,22 @@ void FileUtils::getTxtContent(QString &path, QString &textcontent)
QFile file(path);
if(!file.open(QIODevice::ReadOnly|QIODevice::Text))
return;
textcontent = QString(file.readAll()).replace("\n","");
QByteArray encodedString = file.readAll();
uchardet_t chardet = uchardet_new();
if(uchardet_handle_data(chardet,encodedString.constData(),encodedString.size()) !=0)
qWarning()<<"Txt file encoding format detect fail!"<<path;
uchardet_data_end(chardet);
const char *codec = uchardet_get_charset(chardet);
if(QTextCodec::codecForName(codec) == 0)
qWarning()<<"Unsupported Text encoding format"<<path;
QTextStream stream(encodedString,QIODevice::ReadOnly);
stream.setCodec(codec);
textcontent = stream.readAll().replace("\n","");
return;
}

View File

@ -26,7 +26,7 @@ include(appsearch/appsearch.pri)
include(settingsearch/settingsearch.pri))
LIBS += -L$$OUT_PWD/../libchinese-segmentation/ -lchinese-segmentation
LIBS += -lxapian -lquazip5
LIBS += -lxapian -lquazip5 -luchardet
SOURCES += \
file-utils.cpp \