forked from openkylin/ukui-search
add the first letter search
This commit is contained in:
parent
d00118331b
commit
7308c98090
|
@ -185,18 +185,19 @@ QString FileUtils::find(const QString &hanzi)
|
|||
return output;
|
||||
}
|
||||
|
||||
void stitchMultiToneWordsDFS(const QString& hanzi, const QString& result, QStringList& resultList){
|
||||
void stitchMultiToneWordsDFS(const QString& hanzi, const QString& resultAllPinYin, const QString& resultFirst, QStringList& resultList){
|
||||
if (hanzi.size() == 0){
|
||||
resultList.append(result);
|
||||
resultList.append(resultAllPinYin);
|
||||
resultList.append(resultFirst);
|
||||
return;
|
||||
}
|
||||
if (FileUtils::map_chinese2pinyin.contains(hanzi.at(0))){
|
||||
for (auto i : FileUtils::map_chinese2pinyin[hanzi.at(0)]){
|
||||
stitchMultiToneWordsDFS(hanzi.right(hanzi.size() - 1), result + i, resultList);
|
||||
stitchMultiToneWordsDFS(hanzi.right(hanzi.size() - 1), resultAllPinYin + i, resultFirst + i.at(0), resultList);
|
||||
}
|
||||
}
|
||||
else{
|
||||
stitchMultiToneWordsDFS(hanzi.right(hanzi.size() - 1), result + hanzi.at(0), resultList);
|
||||
stitchMultiToneWordsDFS(hanzi.right(hanzi.size() - 1), resultAllPinYin + hanzi.at(0), resultFirst + hanzi.at(0), resultList);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -204,10 +205,10 @@ QStringList FileUtils::findMultiToneWords(const QString& hanzi)
|
|||
{
|
||||
// QStringList* output = new QStringList();
|
||||
QStringList output;
|
||||
QString temp;
|
||||
QString tempAllPinYin, tempFirst;
|
||||
QStringList stringList = hanzi.split("");
|
||||
|
||||
stitchMultiToneWordsDFS(hanzi, temp, output);
|
||||
stitchMultiToneWordsDFS(hanzi, tempAllPinYin, tempFirst, output);
|
||||
// qDebug() << output;
|
||||
return output;
|
||||
}
|
||||
|
|
|
@ -124,8 +124,9 @@ Document IndexGenerator::GenerateDocument(const QVector<QString> &list)
|
|||
// QString pinyin_text = FileUtils::find(QString(list.at(0)).replace(".","")).replace("", " ").simplified();
|
||||
|
||||
//多音字版
|
||||
QStringList pintin_text_list = FileUtils::findMultiToneWords(QString(list.at(0)).replace(".",""));
|
||||
for (QString& i : pintin_text_list){
|
||||
//现加入首字母
|
||||
QStringList pinyin_text_list = FileUtils::findMultiToneWords(QString(list.at(0)).replace(".",""));
|
||||
for (QString& i : pinyin_text_list){
|
||||
i.replace("", " ");
|
||||
}
|
||||
|
||||
|
@ -148,7 +149,7 @@ Document IndexGenerator::GenerateDocument(const QVector<QString> &list)
|
|||
qDebug()<<"value!!!"<<list.at(2);
|
||||
QStringList temp;
|
||||
temp.append(index_text);
|
||||
temp.append(pintin_text_list);
|
||||
temp.append(pinyin_text_list);
|
||||
doc.setIndexText(temp);
|
||||
// doc.setIndexText(QStringList()<<index_text<<pinyin_text);
|
||||
// doc.setIndexText(QStringList()<<index_text);
|
||||
|
|
|
@ -52,13 +52,13 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
{
|
||||
// FileUtils::findMultiToneWords("翟康宁test");
|
||||
/*-------------Inotify Test Start---------------*/
|
||||
QTime t1 = QTime::currentTime();
|
||||
InotifyManagerRefact* im = new InotifyManagerRefact("/home");
|
||||
im->Traverse();
|
||||
QTime t2 = QTime::currentTime();
|
||||
qDebug() << t1;
|
||||
qDebug() << t2;
|
||||
im->start();
|
||||
// QTime t1 = QTime::currentTime();
|
||||
// InotifyManagerRefact* im = new InotifyManagerRefact("/home");
|
||||
// im->Traverse();
|
||||
// QTime t2 = QTime::currentTime();
|
||||
// qDebug() << t1;
|
||||
// qDebug() << t2;
|
||||
// im->start();
|
||||
/*-------------Inotify Test End-----------------*/
|
||||
|
||||
this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint);
|
||||
|
|
Loading…
Reference in New Issue