From 94ea037203778b6f41e50da0d5b2a58659266c02 Mon Sep 17 00:00:00 2001 From: iaom Date: Mon, 24 Apr 2023 18:40:47 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=B8=80=E4=BA=9B=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libsearch/index/batch-indexer.cpp | 2 +- libsearch/index/compatible-define.h | 6 ++++++ libsearch/index/index-updater.cpp | 7 ++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/libsearch/index/batch-indexer.cpp b/libsearch/index/batch-indexer.cpp index 60f8d08..d2d9bb9 100644 --- a/libsearch/index/batch-indexer.cpp +++ b/libsearch/index/batch-indexer.cpp @@ -200,7 +200,7 @@ void BatchIndexer::contentIndex() // bool ocrEnable = FileIndexerConfig::getInstance()->isOCREnable(); if(FileIndexerConfig::getInstance()->isOCREnable()) { qDebug() << "OCR enabled."; - suffixMap.insert(targetPhotographTypeMap); + suffixMap.INSERT(targetPhotographTypeMap); } if(m_mode == WorkMode::Rebuild) { contentDb.rebuild(); diff --git a/libsearch/index/compatible-define.h b/libsearch/index/compatible-define.h index 749643d..6b74515 100644 --- a/libsearch/index/compatible-define.h +++ b/libsearch/index/compatible-define.h @@ -19,13 +19,19 @@ */ #ifndef COMPATIBLEDEFINE_H #define COMPATIBLEDEFINE_H +#include #endif // COMPATIBLEDEFINE_H #if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) //T QAtomicInteger::load() const #define LOAD load() + +//QMap &QMap::unite(const QMap &other) +#define INSERT(T) unite(T) #endif #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) //T QAtomicInteger::loadRelaxed() const #define LOAD loadRelaxed() +//void QMap::insert(const QMap &map) +#define INSERT(T) insert(T) #endif diff --git a/libsearch/index/index-updater.cpp b/libsearch/index/index-updater.cpp index 69d8766..e8632ba 100644 --- a/libsearch/index/index-updater.cpp +++ b/libsearch/index/index-updater.cpp @@ -25,6 +25,7 @@ #include "file-content-indexer.h" #include "common.h" #include "file-utils.h" +#include "compatible-define.h" using namespace UkuiSearch; IndexUpdater::IndexUpdater(const QVector& files, QAtomicInt &stop) : m_cache(files), @@ -62,7 +63,7 @@ void IndexUpdater::UpdateIndex() qDebug() << "===finish update basic index==="; } if(FileIndexerConfig::getInstance()->isContentIndexEnable()) { - if(m_stop->loadRelaxed()) { + if(m_stop->LOAD) { qDebug() << "Index stopped, abort update content index."; return; } @@ -75,7 +76,7 @@ void IndexUpdater::UpdateIndex() QMap suffixMap = targetFileTypeMap; //ocr if(FileIndexerConfig::getInstance()->isOCREnable()) { - suffixMap.insert(targetPhotographTypeMap); + suffixMap.INSERT(targetPhotographTypeMap); } qDebug() << "===update content index==="; int size = 0; @@ -110,7 +111,7 @@ void IndexUpdater::UpdateIndex() qDebug() << "30 finished."; size = 0; } - if(m_stop->loadRelaxed()) { + if(m_stop->LOAD) { qDebug() << "Index stopped, content index update interrupted"; m_cache.clear(); m_cache.shrink_to_fit();