forked from openkylin/ukui-search
Add modify time in result info.
This commit is contained in:
parent
c643518001
commit
1ab8001445
|
@ -95,7 +95,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
//NEW_TODO, register plugins
|
||||
// SearchPluginManager::getInstance()->registerPlugin(\\);
|
||||
// m_stackedWidget->setPlugins(SearchPluginManager::getInstance()->getPluginIds());
|
||||
m_stackedWidget->setPlugins(QStringList()<<"File"<<"Folder");
|
||||
m_stackedWidget->setPlugins(SearchPluginManager::getInstance()->getPluginIds());
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
|
|
|
@ -24,7 +24,7 @@ using namespace Zeeker;
|
|||
SearchResultManager::SearchResultManager(const QString& plugin_id, QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_plugin_id = plugin_id;
|
||||
m_result_queue = new QQueue<SearchPluginIface::ResultInfo>;
|
||||
m_result_queue = new DataQueue<SearchPluginIface::ResultInfo>;
|
||||
m_get_result_thread = new ReceiveResultThread(m_result_queue);
|
||||
initConnections();
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ void SearchResultManager::startSearch(const QString &keyword)
|
|||
}
|
||||
m_result_queue->clear();
|
||||
SearchPluginIface *plugin = SearchPluginManager::getInstance()->getPlugin(m_plugin_id);
|
||||
// plugin->KeywordSearch(keyword, m_result_queue);
|
||||
plugin->KeywordSearch(keyword, m_result_queue);
|
||||
/*********************测试用数据*********************/
|
||||
// SearchPluginIface::ResultInfo test_info;
|
||||
// if (m_plugin_id == "File") {
|
||||
|
@ -112,7 +112,7 @@ void SearchResultManager::initConnections()
|
|||
connect(m_get_result_thread, &ReceiveResultThread::gotResultInfo, this, &SearchResultManager::gotResultInfo);
|
||||
}
|
||||
|
||||
ReceiveResultThread::ReceiveResultThread(QQueue<SearchPluginIface::ResultInfo> * result_queue, QObject *parent)
|
||||
ReceiveResultThread::ReceiveResultThread(DataQueue<SearchPluginIface::ResultInfo> * result_queue, QObject *parent)
|
||||
{
|
||||
m_result_queue = result_queue;
|
||||
}
|
||||
|
|
|
@ -32,14 +32,14 @@ namespace Zeeker {
|
|||
class ReceiveResultThread : public QThread {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ReceiveResultThread(QQueue<SearchPluginIface::ResultInfo> * result_queue, QObject * parent = nullptr);
|
||||
ReceiveResultThread(DataQueue<SearchPluginIface::ResultInfo> * result_queue, QObject * parent = nullptr);
|
||||
~ReceiveResultThread() = default;
|
||||
void stop();
|
||||
protected:
|
||||
void run() override;
|
||||
|
||||
private:
|
||||
QQueue<SearchPluginIface::ResultInfo> * m_result_queue;
|
||||
DataQueue<SearchPluginIface::ResultInfo> * m_result_queue;
|
||||
|
||||
Q_SIGNALS:
|
||||
void gotResultInfo(const SearchPluginIface::ResultInfo&);
|
||||
|
@ -60,7 +60,7 @@ public Q_SLOTS:
|
|||
private:
|
||||
void initConnections();
|
||||
QString m_plugin_id;
|
||||
QQueue<SearchPluginIface::ResultInfo> * m_result_queue;
|
||||
DataQueue<SearchPluginIface::ResultInfo> * m_result_queue;
|
||||
ReceiveResultThread * m_get_result_thread = nullptr;
|
||||
|
||||
Q_SIGNALS:
|
||||
|
|
|
@ -90,17 +90,15 @@ bool SearchManager::isBlocked(QString &path) {
|
|||
|
||||
bool SearchManager::creatResultInfo(SearchPluginIface::ResultInfo &ri, QString path)
|
||||
{
|
||||
QFileInfo info(info);
|
||||
QFileInfo info(path);
|
||||
if(!info.exists()) {
|
||||
return false;
|
||||
}
|
||||
SearchPluginIface::DescriptionInfo di;
|
||||
di.key = tr("Path:");
|
||||
di.value = path;
|
||||
|
||||
ri.icon = FileUtils::getFileIcon(QUrl::fromLocalFile(path).toString());
|
||||
ri.name = info.fileName();
|
||||
ri.description = QVector<SearchPluginIface::DescriptionInfo>() << di;
|
||||
ri.description = QVector<SearchPluginIface::DescriptionInfo>() \
|
||||
<< SearchPluginIface::DescriptionInfo{tr("Path:"), path} \
|
||||
<< SearchPluginIface::DescriptionInfo{tr("Modified time:"), info.lastModified().toString("yyyy/MM/dd hh:mm:ss")};
|
||||
ri.actionKey = path;
|
||||
ri.type = 0;
|
||||
return true;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <QDebug>
|
||||
#include "search-plugin-manager.h"
|
||||
#include "file-search-plugin.h"
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
<location filename="../../libsearch/index/file-search-plugin.cpp" line="17"/>
|
||||
<location filename="../../libsearch/index/file-search-plugin.cpp" line="27"/>
|
||||
<source>File Search</source>
|
||||
<translation></translation>
|
||||
<translation>文件搜索</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../libsearch/index/file-search-plugin.cpp" line="22"/>
|
||||
|
@ -95,9 +95,14 @@
|
|||
<context>
|
||||
<name>Zeeker::SearchManager</name>
|
||||
<message>
|
||||
<location filename="../../libsearch/index/search-manager.cpp" line="98"/>
|
||||
<location filename="../../libsearch/index/search-manager.cpp" line="100"/>
|
||||
<source>Path:</source>
|
||||
<translation>路径:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../libsearch/index/search-manager.cpp" line="101"/>
|
||||
<source>Modified time:</source>
|
||||
<translation>修改时间:</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
Loading…
Reference in New Issue