优化应用搜索功能;修复偶现搜索结果重复问题
This commit is contained in:
parent
a6a5b7846a
commit
f82f1cb4cd
|
@ -331,6 +331,10 @@ void ResultArea::sendKeyPressSignal(QString &pluginID)
|
|||
for (ResultWidget *plugin : m_widget_list) {
|
||||
if (pluginID == plugin->pluginId()) {
|
||||
QModelIndex index = plugin->getCurrentSelection();
|
||||
//todo 这里偶尔会导致崩溃@jxx,暂时规避。
|
||||
if(!index.isValid()) {
|
||||
break;
|
||||
}
|
||||
height += index.row() == 0 ? 0 : index.row() * resultHeight + TITLE_HEIGHT;
|
||||
int moreHeight = index.row() == 0 ? (TITLE_HEIGHT + resultHeight * 2) : (resultHeight * 2);
|
||||
this->ensureVisible(0, height + moreHeight, 0, 0);
|
||||
|
|
|
@ -127,7 +127,7 @@ void AppSearchPlugin::openAction(int actionkey, QString key, int type)
|
|||
QWidget *AppSearchPlugin::detailPage(const ResultInfo &ri)
|
||||
{
|
||||
m_currentActionKey = ri.actionKey;
|
||||
m_iconLabel->setPixmap(ri.icon.isNull() ? QIcon(":/res/icons/desktop.png").pixmap(120, 120) : ri.icon.pixmap(120, 120));
|
||||
m_iconLabel->setPixmap(ri.icon.isNull() ? QIcon(":/res/icons/unknown.svg").pixmap(120, 120) : ri.icon.pixmap(120, 120));
|
||||
QFontMetrics fontMetrics = m_nameLabel->fontMetrics();
|
||||
QString showname = fontMetrics.elidedText(ri.name, Qt::ElideRight, 215); //当字体长度超过215时显示为省略号
|
||||
m_nameLabel->setText(FileUtils::setAllTextBold(showname));
|
||||
|
@ -172,7 +172,13 @@ void AppSearchPlugin::run()
|
|||
SearchPluginIface::ResultInfo ri;
|
||||
ri.actionKey = oneResult.getExtral().at(0).toString();
|
||||
ri.name = oneResult.getExtral().at(1).toString();
|
||||
ri.icon = oneResult.getExtral().at(2).value<QIcon>();
|
||||
QIcon icon = oneResult.getExtral().at(2).value<QIcon>();
|
||||
|
||||
if(icon.isNull()) {
|
||||
ri.icon = QIcon(":/res/icons/unknown.svg");
|
||||
} else {
|
||||
ri.icon = icon;
|
||||
}
|
||||
SearchPluginIface::DescriptionInfo description;
|
||||
description.key = QString(tr("Application Description:"));
|
||||
description.value = oneResult.getExtral().at(3).toString();
|
||||
|
|
|
@ -13,6 +13,7 @@ AppSearchTask::AppSearchTask(QObject *parent)
|
|||
this->setParent(parent);
|
||||
qRegisterMetaType<size_t>("size_t");
|
||||
m_pool = new QThreadPool(this);
|
||||
m_appInfoTable = new AppInfoTable(this);
|
||||
m_pool->setMaxThreadCount(1);
|
||||
}
|
||||
|
||||
|
@ -49,7 +50,8 @@ void AppSearchTask::sendFinishSignal(size_t searchId)
|
|||
}
|
||||
|
||||
|
||||
AppSearchWorker::AppSearchWorker(AppSearchTask *AppSarchTask, std::shared_ptr<SearchController> searchController) : m_AppSearchTask(AppSarchTask), m_searchController(searchController)
|
||||
AppSearchWorker::AppSearchWorker(AppSearchTask *AppSarchTask, std::shared_ptr<SearchController> searchController) :
|
||||
m_AppSearchTask(AppSarchTask), m_searchController(searchController)
|
||||
{
|
||||
qDBusRegisterMetaType<QMap<QString, QString>>();
|
||||
qDBusRegisterMetaType<QList<QMap<QString, QString>>>();
|
||||
|
@ -60,15 +62,15 @@ AppSearchWorker::AppSearchWorker(AppSearchTask *AppSarchTask, std::shared_ptr<Se
|
|||
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
|
||||
}
|
||||
m_interFace->setTimeout(1500);
|
||||
m_currentSearchId = m_searchController->getCurrentSearchId();
|
||||
}
|
||||
|
||||
void AppSearchWorker::run()
|
||||
{
|
||||
m_currentSearchId = m_searchController->getCurrentSearchId();
|
||||
QStringList results;
|
||||
QStringList keyWords = m_searchController->getKeyword();
|
||||
ResultDataTypes dataType = m_searchController->getResultDataType(SearchType::Application);
|
||||
m_appInfoTable.searchInstallApp(keyWords, results);
|
||||
m_AppSearchTask->m_appInfoTable->searchInstallApp(keyWords, results);
|
||||
for (int i = 0; i < results.size() / 3; i++) {
|
||||
if (m_searchController->beginSearchIdCheck(m_currentSearchId)) {
|
||||
QVariantList info;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
namespace UkuiSearch {
|
||||
class AppSearchTask : public SearchTaskPluginIface
|
||||
{
|
||||
friend class AppSearchWorker;
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AppSearchTask(QObject *parent);
|
||||
|
@ -31,6 +32,7 @@ public:
|
|||
Q_INVOKABLE void sendFinishSignal(size_t searchId);
|
||||
|
||||
private:
|
||||
AppInfoTable *m_appInfoTable = nullptr;
|
||||
QThreadPool *m_pool = nullptr;
|
||||
};
|
||||
|
||||
|
@ -47,7 +49,6 @@ private:
|
|||
void sendErrorMsg(const QString &msg);
|
||||
|
||||
private:
|
||||
AppInfoTable m_appInfoTable;
|
||||
AppSearchTask *m_AppSearchTask = nullptr;
|
||||
std::shared_ptr<SearchController> m_searchController;
|
||||
QDBusInterface *m_interFace = nullptr;
|
||||
|
|
|
@ -54,11 +54,11 @@ void FileSearchTask::sendFinishSignal(size_t searchId)
|
|||
|
||||
FileSearchWorker::FileSearchWorker(FileSearchTask *fileSarchTask, std::shared_ptr<SearchController> searchController) : m_FileSearchTask(fileSarchTask), m_searchController(searchController)
|
||||
{
|
||||
m_currentSearchId = m_searchController->getCurrentSearchId();
|
||||
}
|
||||
|
||||
void FileSearchWorker::run()
|
||||
{
|
||||
m_currentSearchId = m_searchController->getCurrentSearchId();
|
||||
//1.检查是否为不可搜索目录
|
||||
QStringList searchDirs = m_searchController->getSearchDir();
|
||||
searchDirs.removeDuplicates();
|
||||
|
|
Loading…
Reference in New Issue