forked from openkylin/ukui-search
解决一些编译警告,删除一些无用代码,更新README
This commit is contained in:
parent
c5304dfe94
commit
e5e62cd3f7
|
@ -8,15 +8,18 @@
|
|||
广义的ukui-search除了包括全局搜索应用,还包括在ukui桌面环境中的本地搜索服务以及其开发接口。基于文建索引服务,应用搜索数据服务等基础数据源服务,可以提供基于C++接口的搜索功能,应用开发者可以通过引用动态库的形式直接使用其搜索功能。除此之外,ukui桌面环境搜索服务还提供了一组基于Qt插件框架的插件接口,用户可以通过继承接口以实现搜索功能的扩展。
|
||||
以下提到的ukui-search如无说明均指后者。
|
||||
|
||||
ukui-search 目前被打包成6个包(openkylin):
|
||||
ukui-search 目前被打包成9个包(openkylin):
|
||||
+ ukui-search_xxxxxx.deb
|
||||
+ ukui-search-service_xxxx.deb
|
||||
+ libukui-search-dev_xxxxx.deb
|
||||
+ libukui-search2_xxxxx.deb
|
||||
+ libukui-search-common_xxxxx.deb
|
||||
+ libchinese-segmentation1_xxxx.deb
|
||||
+ libchinese-segmentation-dev_xxxx.deb
|
||||
+ libchinese-segmentation-common_xxxx.deb
|
||||
+ ukui-search-systemdbus_xxxxx.deb
|
||||
|
||||
xxx代表版本号。其中,ukui-search 为全局搜索应用本体,libukui-search包提供了搜索服务基本功能以及扩展接口,libukui-search-dev为其开发包。libchinese-segmentation包为搜索服务提供了NLP能力,如中文分词等。ukui-search-systemdbus包提供了一些systemdbus提权操作。
|
||||
xxx代表版本号。其中,ukui-search 为全局搜索应用本体,ukui-search-service为搜索数据服务相关进程,libukui-search包提供了搜索服务基本功能以及扩展接口,libukui-search-dev为其开发包。libchinese-segmentation包为搜索服务提供了NLP能力,如中文分词等。ukui-search-systemdbus包提供了一些systemdbus提权操作。
|
||||
|
||||
## 运行
|
||||
搜索服务相关的进程共有5个,包括ukui-search(全局搜索GUI界面),ukui-search-service(文件搜索服务),ukui-search-service-dir-manager(文件搜索目录管理模块), ukui-search-app-data-service(应用数据服务),ukuisearch-systemdbus(systembus)。
|
||||
|
|
|
@ -99,6 +99,7 @@ void SearchLineEdit::paintEvent(QPaintEvent *e)
|
|||
|
||||
void SearchLineEdit::focusOutEvent(QFocusEvent *e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
this->setFocus();
|
||||
}
|
||||
|
||||
|
|
|
@ -630,49 +630,6 @@ QString escapeHtml(const QString & str) {
|
|||
return temp;
|
||||
}
|
||||
|
||||
void DetailWidget::setWidgetInfo(const QString &plugin_name, const SearchPluginIface::ResultInfo &info)
|
||||
{
|
||||
// clearLayout(m_descFrameLyt);
|
||||
// clearLayout(m_previewFrameLyt);
|
||||
// if(SearchPluginManager::getInstance()->getPlugin(plugin_name)->isPreviewEnable(info.actionKey,info.type)) {
|
||||
// m_iconLabel->hide();
|
||||
// m_previewFrameLyt->addWidget(SearchPluginManager::getInstance()->getPlugin(plugin_name)->previewPage(info.actionKey,info.type, m_previewFrame), 0 , Qt::AlignHCenter);
|
||||
// m_previewFrameLyt->setContentsMargins(0,0,0,0);
|
||||
// m_previewFrame->show();
|
||||
// } else {
|
||||
// m_previewFrame->hide();
|
||||
// m_iconLabel->setPixmap(info.icon.pixmap(info.icon.actualSize(ICON_SIZE)));
|
||||
// m_iconLabel->show();
|
||||
// }
|
||||
// QFontMetrics fontMetrics = m_nameLabel->fontMetrics();
|
||||
// QString name = fontMetrics.elidedText(info.name, Qt::ElideRight, NAME_LABEL_WIDTH - 8);
|
||||
// m_nameLabel->setText(QString("<h3 style=\"font-weight:normal;\">%1</h3>").arg(escapeHtml(name)));
|
||||
// m_nameLabel->setToolTip(info.name);
|
||||
// m_pluginLabel->setText(plugin_name);
|
||||
// m_nameFrame->show();
|
||||
// m_line_1->show();
|
||||
|
||||
// if (info.description.length() > 0) {
|
||||
// //NEW_TODO 样式待优化
|
||||
// clearLayout(m_descFrameLyt);
|
||||
// Q_FOREACH (SearchPluginIface::DescriptionInfo desc, info.description) {
|
||||
// QLabel * descLabel = new QLabel(m_descFrame);
|
||||
// descLabel->setTextFormat(Qt::PlainText);
|
||||
// descLabel->setWordWrap(true);
|
||||
// QString show_desc = desc.key + " " + desc.value;
|
||||
// descLabel->setText(show_desc);
|
||||
// m_descFrameLyt->addWidget(descLabel);
|
||||
// }
|
||||
// m_descFrame->show();
|
||||
// m_line_2->show();
|
||||
// }
|
||||
// clearLayout(m_actionFrameLyt);
|
||||
// Q_FOREACH (SearchPluginIface::Actioninfo actioninfo, SearchPluginManager::getInstance()->getPlugin(plugin_name)->getActioninfo(info.type)) {
|
||||
// ActionLabel * actionLabel = new ActionLabel(actioninfo.displayName, info.actionKey, actioninfo.actionkey, plugin_name, info.type, m_actionFrame);
|
||||
// m_actionFrameLyt->addWidget(actionLabel);
|
||||
// }
|
||||
// m_actionFrame->show();
|
||||
}
|
||||
|
||||
void DetailWidget::updateDetailPage(const QString &plugin_name, const SearchPluginIface::ResultInfo &info)
|
||||
{
|
||||
|
@ -697,71 +654,6 @@ void DetailWidget::updateDetailPage(const QString &plugin_name, const SearchPlug
|
|||
m_currentPluginId = plugin_name;
|
||||
}
|
||||
|
||||
void DetailWidget::clear()
|
||||
{
|
||||
// m_iconLabel->hide();
|
||||
// m_nameFrame->hide();
|
||||
// m_line_1->hide();
|
||||
// m_descFrame->hide();
|
||||
// m_line_2->hide();
|
||||
// m_actionFrame->hide();
|
||||
}
|
||||
|
||||
void DetailWidget::initUi()
|
||||
{
|
||||
// this->setFixedSize(368, 516);
|
||||
// m_mainLyt = new QVBoxLayout(this);
|
||||
// this->setLayout(m_mainLyt);
|
||||
// m_mainLyt->setContentsMargins(DETAIL_WIDGET_MARGINS);
|
||||
// m_mainLyt->setAlignment(Qt::AlignHCenter);
|
||||
|
||||
// m_iconLabel = new QLabel(this);
|
||||
// m_iconLabel->setFixedHeight(DETAIL_ICON_HEIGHT);
|
||||
// m_iconLabel->setAlignment(Qt::AlignCenter);
|
||||
// m_previewFrame = new QFrame(this);
|
||||
// m_previewFrameLyt = new QHBoxLayout(m_previewFrame);
|
||||
|
||||
// m_nameFrame = new QFrame(this);
|
||||
// m_nameFrameLyt = new QHBoxLayout(m_nameFrame);
|
||||
// m_nameFrame->setLayout(m_nameFrameLyt);
|
||||
// m_nameFrameLyt->setContentsMargins(DETAIL_FRAME_MARGINS);
|
||||
// m_nameLabel = new QLabel(m_nameFrame);
|
||||
// m_nameLabel->setMaximumWidth(NAME_LABEL_WIDTH);
|
||||
// m_pluginLabel = new QLabel(m_nameFrame);
|
||||
// m_pluginLabel->setEnabled(false);
|
||||
// m_nameFrameLyt->addWidget(m_nameLabel);
|
||||
// m_nameFrameLyt->addStretch();
|
||||
// m_nameFrameLyt->addWidget(m_pluginLabel);
|
||||
|
||||
// m_line_1 = new QFrame(this);
|
||||
// m_line_1->setFixedHeight(1);
|
||||
// m_line_1->setLineWidth(0);
|
||||
// m_line_1->setStyleSheet(LINE_STYLE);
|
||||
// m_line_2 = new QFrame(this);
|
||||
// m_line_2->setFixedHeight(1);
|
||||
// m_line_2->setLineWidth(0);
|
||||
// m_line_2->setStyleSheet(LINE_STYLE);
|
||||
|
||||
// m_descFrame = new QFrame(this);
|
||||
// m_descFrameLyt = new QVBoxLayout(m_descFrame);
|
||||
// m_descFrame->setLayout(m_descFrameLyt);
|
||||
// m_descFrameLyt->setContentsMargins(DETAIL_FRAME_MARGINS);
|
||||
|
||||
// m_actionFrame = new QFrame(this);
|
||||
// m_actionFrameLyt = new QVBoxLayout(m_actionFrame);
|
||||
// m_actionFrame->setLayout(m_actionFrameLyt);
|
||||
// m_actionFrameLyt->setContentsMargins(DETAIL_FRAME_MARGINS);
|
||||
|
||||
// m_mainLyt->addWidget(m_iconLabel);
|
||||
// m_mainLyt->addWidget(m_previewFrame, 0, Qt::AlignHCenter);
|
||||
// m_mainLyt->addWidget(m_nameFrame);
|
||||
// m_mainLyt->addWidget(m_line_1);
|
||||
// m_mainLyt->addWidget(m_descFrame);
|
||||
// m_mainLyt->addWidget(m_line_2);
|
||||
// m_mainLyt->addWidget(m_actionFrame);
|
||||
// m_mainLyt->addStretch();
|
||||
}
|
||||
|
||||
void DetailWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QStyleOption opt;
|
||||
|
@ -791,53 +683,6 @@ void DetailWidget::clearLayout(QLayout *layout)
|
|||
child = NULL;
|
||||
}
|
||||
|
||||
//ActionLabel::ActionLabel(const QString &action, const QString &key, const int &ActionKey, const QString &pluginId, const int type, QWidget *parent) : QLabel(parent)
|
||||
//{
|
||||
// m_action = action;
|
||||
// m_key = key;
|
||||
// m_actionKey = ActionKey;
|
||||
// m_type = type;
|
||||
// m_pluginId = pluginId;
|
||||
// this->initUi();
|
||||
// this->installEventFilter(this);
|
||||
//}
|
||||
|
||||
//void ActionLabel::initUi()
|
||||
//{
|
||||
// this->setText(m_action);
|
||||
// QPalette pal = palette();
|
||||
// pal.setColor(QPalette::WindowText, ACTION_NORMAL_COLOR);
|
||||
// pal.setColor(QPalette::Light, ACTION_HOVER_COLOR);
|
||||
// pal.setColor(QPalette::Dark, ACTION_PRESS_COLOR);
|
||||
// this->setPalette(pal);
|
||||
// this->setForegroundRole(QPalette::WindowText);
|
||||
// this->setCursor(QCursor(Qt::PointingHandCursor));
|
||||
//}
|
||||
|
||||
//bool ActionLabel::eventFilter(QObject *watched, QEvent *event)
|
||||
//{
|
||||
// if (watched == this) {
|
||||
// if(event->type() == QEvent::MouseButtonPress) {
|
||||
// this->setForegroundRole(QPalette::Dark);
|
||||
// return true;
|
||||
// } else if(event->type() == QEvent::MouseButtonRelease) {
|
||||
// SearchPluginIface *plugin = SearchPluginManager::getInstance()->getPlugin(m_pluginId);
|
||||
// if (plugin)
|
||||
// plugin->openAction(m_actionKey, m_key, m_type);
|
||||
// else
|
||||
// qWarning()<<"Get plugin failed!";
|
||||
// this->setForegroundRole(QPalette::Light);
|
||||
// return true;
|
||||
// } else if(event->type() == QEvent::Enter) {
|
||||
// this->setForegroundRole(QPalette::Light);
|
||||
// return true;
|
||||
// } else if(event->type() == QEvent::Leave) {
|
||||
// this->setForegroundRole(QPalette::WindowText);
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
ResultScrollBar::ResultScrollBar(QWidget *parent) : QScrollBar(parent)
|
||||
{
|
||||
|
||||
|
|
|
@ -115,32 +115,16 @@ class DetailWidget : public QWidget
|
|||
public:
|
||||
DetailWidget(QWidget *parent = nullptr);
|
||||
~DetailWidget() = default;
|
||||
void clear();
|
||||
|
||||
public Q_SLOTS:
|
||||
void setWidgetInfo(const QString &plugin_name, const SearchPluginIface::ResultInfo &info);
|
||||
void updateDetailPage(const QString &plugin_name, const SearchPluginIface::ResultInfo &info);
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
private:
|
||||
void initUi();
|
||||
void clearLayout(QLayout *);
|
||||
QVBoxLayout * m_mainLyt = nullptr;
|
||||
QString m_currentPluginId;
|
||||
QWidget *m_detailPage = nullptr;
|
||||
// QLabel * m_iconLabel = nullptr;
|
||||
// QFrame *m_previewFrame = nullptr;
|
||||
// QHBoxLayout *m_previewFrameLyt = nullptr;
|
||||
// QFrame * m_nameFrame = nullptr;
|
||||
// QHBoxLayout * m_nameFrameLyt = nullptr;
|
||||
// QLabel * m_nameLabel = nullptr;
|
||||
// QLabel * m_pluginLabel = nullptr;
|
||||
// QFrame * m_line_1 = nullptr;
|
||||
// QFrame * m_descFrame = nullptr;
|
||||
// QVBoxLayout * m_descFrameLyt = nullptr;
|
||||
// QFrame * m_line_2 = nullptr;
|
||||
// QFrame * m_actionFrame = nullptr;
|
||||
// QVBoxLayout * m_actionFrameLyt = nullptr;
|
||||
};
|
||||
|
||||
class DetailArea : public QScrollArea
|
||||
|
@ -156,24 +140,6 @@ private:
|
|||
Q_SIGNALS:
|
||||
void setWidgetInfo(const QString&, const SearchPluginIface::ResultInfo&);
|
||||
};
|
||||
|
||||
//class ActionLabel : public QLabel
|
||||
//{
|
||||
// Q_OBJECT
|
||||
//public:
|
||||
// ActionLabel(const QString &action, const QString &key, const int &ActionKey, const QString &pluginId, const int type = 0, QWidget *parent = nullptr);
|
||||
// ~ActionLabel() = default;
|
||||
//private:
|
||||
// void initUi();
|
||||
// QString m_action;
|
||||
// QString m_key;
|
||||
// int m_actionKey;
|
||||
// int m_type = 0;
|
||||
// QString m_pluginId;
|
||||
|
||||
//protected:
|
||||
// bool eventFilter(QObject *, QEvent *);
|
||||
//};
|
||||
}
|
||||
|
||||
#endif // SEARCHPAGESECTION_H
|
||||
|
|
|
@ -35,11 +35,6 @@ SearchResultPage::SearchResultPage(QWidget *parent) : QWidget(parent)
|
|||
setInternalPlugins();
|
||||
}
|
||||
|
||||
void SearchResultPage::setSize(const int&width, const int&height)
|
||||
{
|
||||
// m_splitter->setFixedSize(width, height);
|
||||
}
|
||||
|
||||
void SearchResultPage::setInternalPlugins()
|
||||
{
|
||||
QList<PluginInfo> infoList = SearchPluginManager::getInstance()->getPluginIds();
|
||||
|
@ -129,6 +124,7 @@ void SearchResultPage::setWidth(int width)
|
|||
|
||||
void SearchResultPage::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
QPainter p(this);
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
p.setBrush(palette().base());
|
||||
|
|
|
@ -31,7 +31,6 @@ class SearchResultPage : public QWidget
|
|||
public:
|
||||
explicit SearchResultPage(QWidget *parent = nullptr);
|
||||
~SearchResultPage() = default;
|
||||
void setSize(const int&, const int&);
|
||||
void setInternalPlugins();
|
||||
void appendPlugin(const QString &plugin_id);
|
||||
void movePlugin(const QString &plugin_id, int index);
|
||||
|
|
|
@ -404,8 +404,9 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
|
|||
return QWidget::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void MainWindow::paintEvent(QPaintEvent *event) {
|
||||
|
||||
void MainWindow::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
QPainterPath path;
|
||||
|
||||
path.addRoundedRect(m_searchBarWidget->x()+10, m_searchBarWidget->y()+10, m_searchBarWidget->width()-20, m_searchBarWidget->height()-20, 12, 12);
|
||||
|
|
|
@ -31,6 +31,7 @@ BestListModel::BestListModel(QObject *parent)
|
|||
|
||||
QModelIndex BestListModel::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
if(row < 0 || row > m_item->m_result_info_list.length() - 1)
|
||||
return QModelIndex();
|
||||
return createIndex(row, column, m_item);
|
||||
|
@ -38,6 +39,7 @@ QModelIndex BestListModel::index(int row, int column, const QModelIndex &parent)
|
|||
|
||||
QModelIndex BestListModel::parent(const QModelIndex &index) const
|
||||
{
|
||||
Q_UNUSED(index)
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
|
@ -96,6 +98,7 @@ QStringList BestListModel::getActions(const QModelIndex &index)
|
|||
{
|
||||
// if (m_item->m_result_info_list.length() > index.row() && index.row() >= 0)
|
||||
// return m_item->m_result_info_list.at(index.row()).actionList;
|
||||
Q_UNUSED(index)
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
|
@ -200,6 +203,7 @@ void BestListModel::moveInfo(const QString &pluginName, const int pos)
|
|||
|
||||
void BestListModel::startSearch(const QString &keyword)
|
||||
{
|
||||
Q_UNUSED(keyword)
|
||||
if (!m_item->m_result_info_list.isEmpty()) {
|
||||
this->beginResetModel();
|
||||
m_plugin_id_list.clear();
|
||||
|
|
|
@ -33,6 +33,7 @@ SearchResultModel::SearchResultModel(const QString &plugin_id)
|
|||
|
||||
QModelIndex SearchResultModel::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
if(row < 0 || row > m_item->m_result_info_list.length() - 1)
|
||||
return QModelIndex();
|
||||
// QVector<SearchPluginIface::ResultInfo> * m_info = &m_result_info_list;
|
||||
|
@ -41,6 +42,7 @@ QModelIndex SearchResultModel::index(int row, int column, const QModelIndex &par
|
|||
|
||||
QModelIndex SearchResultModel::parent(const QModelIndex &child) const
|
||||
{
|
||||
Q_UNUSED(child)
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ WebSearchModel::WebSearchModel(QObject *parent)
|
|||
|
||||
QModelIndex WebSearchModel::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
if(row < 0 || row > m_item->m_result_info_list.length() - 1)
|
||||
return QModelIndex();
|
||||
return createIndex(row, column, m_item);
|
||||
|
@ -37,6 +38,7 @@ QModelIndex WebSearchModel::index(int row, int column, const QModelIndex &parent
|
|||
|
||||
QModelIndex WebSearchModel::parent(const QModelIndex &index) const
|
||||
{
|
||||
Q_UNUSED(index)
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
|
|
|
@ -167,21 +167,6 @@ const bool &BestListView::isExpanded()
|
|||
return m_model->isExpanded();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief BestListView::onMenuTriggered 点击右键菜单的槽函数
|
||||
* @param action
|
||||
*/
|
||||
void BestListView::onMenuTriggered(QAction *action)
|
||||
{
|
||||
//NEW_TODO 接口调整后需要修改
|
||||
// SearchPluginIface *plugin = SearchPluginManager::getInstance()->getPlugin(m_plugin_id);
|
||||
// if (plugin) {
|
||||
//// plugin->openAction(action->text(), m_model->getKey(this->currentIndex()));
|
||||
// } else {
|
||||
// qWarning()<<"Get plugin failed!";
|
||||
// }
|
||||
}
|
||||
|
||||
void BestListView::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
m_tmpCurrentIndex = this->currentIndex();
|
||||
|
|
|
@ -53,7 +53,6 @@ public Q_SLOTS:
|
|||
void onItemListChanged(const int &);
|
||||
void setExpanded(const bool &);
|
||||
const bool &isExpanded();
|
||||
void onMenuTriggered(QAction *);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
|
|
|
@ -325,6 +325,7 @@ const bool &ResultView::isExpanded()
|
|||
*/
|
||||
void ResultView::onMenuTriggered(QAction *action)
|
||||
{
|
||||
Q_UNUSED(action)
|
||||
//NEW_TODO 接口调整后需要修改
|
||||
SearchPluginIface *plugin = SearchPluginManager::getInstance()->getPlugin(m_plugin_id);
|
||||
if (plugin) {
|
||||
|
|
|
@ -343,8 +343,7 @@ bool AppSearchPlugin::addDesktopShortcut(const QString& path) {
|
|||
QString newName = QString(dirpath + "/" + desktopfn);
|
||||
bool ret = file.copy(QString(dirpath + "/" + desktopfn));
|
||||
if(ret) {
|
||||
QProcess process;
|
||||
process.startDetached(QString("chmod a+x %1").arg(newName));
|
||||
QProcess::startDetached("chmod", {"a+x", newName});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -385,8 +384,7 @@ bool AppSearchPlugin::installAppAction(const QString & name) {
|
|||
}
|
||||
appLaunchInterface = nullptr;
|
||||
if (!res) {
|
||||
QProcess process;
|
||||
res = process.startDetached(QString("kylin-software-center -find %1").arg(name));
|
||||
res = QProcess::startDetached("kylin-software-center", {"-find", name});
|
||||
}
|
||||
}
|
||||
if(interface) {
|
||||
|
|
|
@ -217,6 +217,7 @@ std::string FileUtils::makeDocUterm(QString path) {
|
|||
* @return
|
||||
*/
|
||||
QIcon FileUtils::getFileIcon(const QString &uri, bool checkValid) {
|
||||
Q_UNUSED(checkValid)
|
||||
QMutexLocker locker(&iconMutex);
|
||||
auto file = wrapGFile(g_file_new_for_uri(uri.toUtf8().constData()));
|
||||
auto info = wrapGFileInfo(g_file_query_info(file.get()->get(),
|
||||
|
@ -790,7 +791,7 @@ QString FileUtils::chineseSubString(const std::string &myStr, uint start, uint l
|
|||
|
||||
if (length >= myStr.length()) {
|
||||
afterSub = myStr.substr(start,length); //截取;
|
||||
if (fm.width(QString::fromStdString(afterSub)) >= 2*LABEL_MAX_WIDTH) {
|
||||
if (fm.horizontalAdvance(QString::fromStdString(afterSub)) >= 2*LABEL_MAX_WIDTH) {
|
||||
sub = fm.elidedText(sub, Qt::ElideRight, 2*LABEL_MAX_WIDTH); //超过两行则省略
|
||||
} else {
|
||||
sub = fm.elidedText(sub, Qt::ElideLeft, 2*LABEL_MAX_WIDTH); //超过两行则省略
|
||||
|
@ -812,7 +813,7 @@ QString FileUtils::chineseSubString(const std::string &myStr, uint start, uint l
|
|||
|
||||
afterSub = myStr.substr(newStart, length);
|
||||
sub=QString::fromStdString(afterSub);
|
||||
if (fm.width(QString::fromStdString(myStr.substr(newStart, start))) >= 2*LABEL_MAX_WIDTH) {
|
||||
if (fm.horizontalAdvance(QString::fromStdString(myStr.substr(newStart, start))) >= 2*LABEL_MAX_WIDTH) {
|
||||
sub = fm.elidedText(sub, Qt::ElideLeft, 2*LABEL_MAX_WIDTH);
|
||||
} else {
|
||||
if (newStart + 3 < start) {
|
||||
|
@ -959,7 +960,7 @@ QString FileUtils::wrapData(QLabel *p_label, const QString &text)
|
|||
QString wrapText = text;
|
||||
|
||||
QFontMetrics fontMetrics = p_label->fontMetrics();
|
||||
int textSize = fontMetrics.width(wrapText);
|
||||
int textSize = fontMetrics.horizontalAdvance(wrapText);
|
||||
|
||||
if(textSize > LABEL_MAX_WIDTH){
|
||||
int lastIndex = 0;
|
||||
|
@ -967,11 +968,11 @@ QString FileUtils::wrapData(QLabel *p_label, const QString &text)
|
|||
|
||||
for(int i = lastIndex; i < wrapText.length(); i++) {
|
||||
|
||||
if(fontMetrics.width(wrapText.mid(lastIndex, i - lastIndex)) == LABEL_MAX_WIDTH) {
|
||||
if(fontMetrics.horizontalAdvance(wrapText.mid(lastIndex, i - lastIndex)) == LABEL_MAX_WIDTH) {
|
||||
lastIndex = i;
|
||||
wrapText.insert(i, '\n');
|
||||
count++;
|
||||
} else if(fontMetrics.width(wrapText.mid(lastIndex, i - lastIndex)) > LABEL_MAX_WIDTH) {
|
||||
} else if(fontMetrics.horizontalAdvance(wrapText.mid(lastIndex, i - lastIndex)) > LABEL_MAX_WIDTH) {
|
||||
lastIndex = i;
|
||||
wrapText.insert(i - 1, '\n');
|
||||
count++;
|
||||
|
|
|
@ -19,10 +19,11 @@
|
|||
*/
|
||||
#include "batch-indexer.h"
|
||||
#include <QFileInfo>
|
||||
#include <QTime>
|
||||
#include <QElapsedTimer>
|
||||
#include <QDebug>
|
||||
#include <malloc.h>
|
||||
#include <QQueue>
|
||||
#include <QDateTime>
|
||||
|
||||
#include "file-utils.h"
|
||||
#include "basic-indexer.h"
|
||||
|
@ -42,7 +43,8 @@ BatchIndexer::BatchIndexer(const QStringList &folders, const QStringList &blackL
|
|||
|
||||
void BatchIndexer::run()
|
||||
{
|
||||
QTime t = QTime::currentTime();
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
if(m_target == Target::None || m_stop->LOAD) {
|
||||
Q_EMIT done(m_mode);
|
||||
return;
|
||||
|
@ -57,7 +59,7 @@ void BatchIndexer::run()
|
|||
}
|
||||
m_cache.clear();
|
||||
malloc_trim(0);
|
||||
qDebug() << "FirstRunIndexer: time :" << t.elapsed();
|
||||
qDebug() << "FirstRunIndexer: time :" << timer.elapsed() << "milliseconds";
|
||||
Q_EMIT done(m_mode);
|
||||
}
|
||||
|
||||
|
@ -196,7 +198,7 @@ void BatchIndexer::contentIndex()
|
|||
// bool ocrEnable = FileIndexerConfig::getInstance()->isOCREnable();
|
||||
if(FileIndexerConfig::getInstance()->isOCREnable()) {
|
||||
qDebug() << "OCR enabled.";
|
||||
suffixMap.unite(targetPhotographTypeMap);
|
||||
suffixMap.insert(targetPhotographTypeMap);
|
||||
}
|
||||
if(m_mode == WorkMode::Rebuild) {
|
||||
contentDb.rebuild();
|
||||
|
|
|
@ -80,13 +80,14 @@ void FileSearchPlugin::stopSearch()
|
|||
|
||||
QList<SearchPluginIface::Actioninfo> FileSearchPlugin::getActioninfo(int type)
|
||||
{
|
||||
Q_UNUSED(type)
|
||||
return m_actionInfo;
|
||||
}
|
||||
|
||||
void FileSearchPlugin::openAction(int actionkey, QString key, int type)
|
||||
{
|
||||
Q_UNUSED(type)
|
||||
//TODO add some return message here.
|
||||
qDebug() << "openAction!!!!!!!!";
|
||||
switch (actionkey) {
|
||||
case 0:
|
||||
if(FileUtils::openFile(key) == -1) {
|
||||
|
@ -288,11 +289,13 @@ void DirSearchPlugin::stopSearch()
|
|||
|
||||
QList<SearchPluginIface::Actioninfo> DirSearchPlugin::getActioninfo(int type)
|
||||
{
|
||||
Q_UNUSED(type)
|
||||
return m_actionInfo;
|
||||
}
|
||||
|
||||
void DirSearchPlugin::openAction(int actionkey, QString key, int type)
|
||||
{
|
||||
Q_UNUSED(type)
|
||||
//TODO add some return message here.
|
||||
switch (actionkey) {
|
||||
case 0:
|
||||
|
@ -469,11 +472,13 @@ void FileContengSearchPlugin::stopSearch()
|
|||
|
||||
QList<SearchPluginIface::Actioninfo> FileContengSearchPlugin::getActioninfo(int type)
|
||||
{
|
||||
Q_UNUSED(type)
|
||||
return m_actionInfo;
|
||||
}
|
||||
|
||||
void FileContengSearchPlugin::openAction(int actionkey, QString key, int type)
|
||||
{
|
||||
Q_UNUSED(type)
|
||||
//TODO add some return message here.
|
||||
switch (actionkey) {
|
||||
case 0:
|
||||
|
@ -556,18 +561,18 @@ QString FileContengSearchPlugin::wrapData(QLabel *p_label, const QString &text)
|
|||
QString wrapText = text;
|
||||
|
||||
QFontMetrics fontMetrics = p_label->fontMetrics();
|
||||
int textSize = fontMetrics.width(wrapText);
|
||||
int textSize = fontMetrics.horizontalAdvance(wrapText);
|
||||
if(textSize > LABEL_MAX_WIDTH){
|
||||
int lastIndex = 0;
|
||||
int count = 0;
|
||||
|
||||
for(int i = lastIndex; i < wrapText.length(); i++) {
|
||||
|
||||
if(fontMetrics.width(wrapText.mid(lastIndex, i - lastIndex)) == LABEL_MAX_WIDTH) {
|
||||
if(fontMetrics.horizontalAdvance(wrapText.mid(lastIndex, i - lastIndex)) == LABEL_MAX_WIDTH) {
|
||||
lastIndex = i;
|
||||
wrapText.insert(i, '\n');
|
||||
count++;
|
||||
} else if(fontMetrics.width(wrapText.mid(lastIndex, i - lastIndex)) > LABEL_MAX_WIDTH) {
|
||||
} else if(fontMetrics.horizontalAdvance(wrapText.mid(lastIndex, i - lastIndex)) > LABEL_MAX_WIDTH) {
|
||||
lastIndex = i;
|
||||
wrapText.insert(i - 1, '\n');
|
||||
count++;
|
||||
|
|
|
@ -62,7 +62,7 @@ void IndexUpdater::UpdateIndex()
|
|||
qDebug() << "===finish update basic index===";
|
||||
}
|
||||
if(FileIndexerConfig::getInstance()->isContentIndexEnable()) {
|
||||
if(m_stop->load()) {
|
||||
if(m_stop->loadRelaxed()) {
|
||||
qDebug() << "Index stopped, abort update content index.";
|
||||
return;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ void IndexUpdater::UpdateIndex()
|
|||
QMap<QString, bool> suffixMap = targetFileTypeMap;
|
||||
//ocr
|
||||
if(FileIndexerConfig::getInstance()->isOCREnable()) {
|
||||
suffixMap.unite(targetPhotographTypeMap);
|
||||
suffixMap.insert(targetPhotographTypeMap);
|
||||
}
|
||||
qDebug() << "===update content index===";
|
||||
int size = 0;
|
||||
|
@ -110,7 +110,7 @@ void IndexUpdater::UpdateIndex()
|
|||
qDebug() << "30 finished.";
|
||||
size = 0;
|
||||
}
|
||||
if(m_stop->load()) {
|
||||
if(m_stop->loadRelaxed()) {
|
||||
qDebug() << "Index stopped, content index update interrupted";
|
||||
m_cache.clear();
|
||||
m_cache.shrink_to_fit();
|
||||
|
|
|
@ -128,7 +128,7 @@ int FileSearch::keywordSearchfile() {
|
|||
try {
|
||||
qDebug() << "--keywordSearchfile start--";
|
||||
Xapian::Database db(INDEX_PATH);
|
||||
Xapian::Query query = creatQueryForFileSearch(db);
|
||||
Xapian::Query query = creatQueryForFileSearch();
|
||||
Xapian::Enquire enquire(db);
|
||||
|
||||
Xapian::Query queryFile;
|
||||
|
@ -162,7 +162,7 @@ int FileSearch::keywordSearchfile() {
|
|||
}
|
||||
}
|
||||
|
||||
Xapian::Query FileSearch::creatQueryForFileSearch(Xapian::Database &db) {
|
||||
Xapian::Query FileSearch::creatQueryForFileSearch() {
|
||||
auto userInput = m_keyword.toLower();
|
||||
std::vector<Xapian::Query> v;
|
||||
for(int i = 0; i < userInput.size(); i++) {
|
||||
|
|
|
@ -105,7 +105,7 @@ protected:
|
|||
void run();
|
||||
private:
|
||||
int keywordSearchfile();
|
||||
Xapian::Query creatQueryForFileSearch(Xapian::Database &db);
|
||||
Xapian::Query creatQueryForFileSearch();
|
||||
int getResult(Xapian::MSet &result);
|
||||
|
||||
DataQueue<SearchPluginIface::ResultInfo> *m_search_result = nullptr;
|
||||
|
|
|
@ -39,7 +39,7 @@ include(settingsearch/settingsearch.pri)
|
|||
include(websearch/websearch.pri)
|
||||
include(searchinterface/search-interface.pri)
|
||||
include(dirwatcher/dirwatcher.pri)
|
||||
include(mailsearch/mailsearch.pri)
|
||||
#include(mailsearch/mailsearch.pri)
|
||||
include(search-app-widget-plugin/search-app-widget-plugin.pri)
|
||||
|
||||
LIBS += -L$$OUT_PWD/../libchinese-segmentation/ -lchinese-segmentation
|
||||
|
|
|
@ -28,6 +28,7 @@ using namespace UkuiSearch;
|
|||
|
||||
NoteSearchPlugin::NoteSearchPlugin(QObject *parent)
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
g_uniqueSymbol = 0;
|
||||
SearchPluginIface::Actioninfo open { 0, tr("Open")};
|
||||
m_actionInfo << open;
|
||||
|
@ -70,11 +71,13 @@ void NoteSearchPlugin::stopSearch()
|
|||
|
||||
QList<SearchPluginIface::Actioninfo> NoteSearchPlugin::getActioninfo(int type)
|
||||
{
|
||||
Q_UNUSED(type)
|
||||
return m_actionInfo;
|
||||
}
|
||||
|
||||
void NoteSearchPlugin::openAction(int actionkey, QString key, int type)
|
||||
{
|
||||
Q_UNUSED(type)
|
||||
switch (actionkey) {
|
||||
case 0:
|
||||
{
|
||||
|
@ -103,7 +106,7 @@ void NoteSearchPlugin::openAction(int actionkey, QString key, int type)
|
|||
if (res)
|
||||
break;
|
||||
QProcess process;
|
||||
process.startDetached(QString("ukui-notebook --show %1").arg(key.toInt()));
|
||||
process.startDetached("ukui-notebook", {"--show", key});
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "settings-search-plugin.h"
|
||||
#include "note-search-plugin.h"
|
||||
#include "web-search-plugin.h"
|
||||
#include "mail-search-plugin.h"
|
||||
|
||||
#define PLUGIN_ORDER_SETTINGS QDir::homePath() + "/.config/org.ukui/ukui-search/ukui-search-plugin-order.conf"
|
||||
#define PLUGINS_INFO_GROUP "PluginsInfo"
|
||||
|
@ -41,6 +40,7 @@ using namespace UkuiSearch;
|
|||
static SearchPluginManager *global_instance = nullptr;
|
||||
SearchPluginManager::SearchPluginManager(QObject *parent)
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
initOrderSettings();
|
||||
registerPlugin(new AppSearchPlugin);
|
||||
registerPlugin(new NoteSearchPlugin);
|
||||
|
|
|
@ -9,7 +9,7 @@ class SearchResultPropertyInfo: public QObject
|
|||
Q_OBJECT
|
||||
public:
|
||||
SearchResultPropertyInfo();
|
||||
SearchResultPropertyInfo(SearchProperty::SearchResultProperty property);
|
||||
explicit SearchResultPropertyInfo(SearchProperty::SearchResultProperty property);
|
||||
SearchResultPropertyInfo(const SearchResultPropertyInfo &other);
|
||||
SearchResultPropertyInfo& operator=(const SearchResultPropertyInfo& rhs);
|
||||
bool operator==(const SearchResultPropertyInfo& rhs) const;
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
const QString name();
|
||||
const QString description();
|
||||
const QIcon icon() {return QIcon::fromTheme("appsearch");}
|
||||
void setEnable(bool enable) {}
|
||||
void setEnable(bool enable) {Q_UNUSED(enable)}
|
||||
bool isEnable() { return true;}
|
||||
|
||||
SearchProperty::SearchType getSearchType() {return SearchProperty::SearchType::Application;}
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
const QString name();
|
||||
const QString description();
|
||||
const QIcon icon() {return QIcon::fromTheme("folder");}
|
||||
void setEnable(bool enable) {}
|
||||
void setEnable(bool enable) {Q_UNUSED(enable)}
|
||||
bool isEnable() { return true;}
|
||||
|
||||
SearchProperty::SearchType getSearchType() {return SearchProperty::SearchType::File;}
|
||||
|
|
|
@ -57,11 +57,13 @@ void SettingsSearchPlugin::stopSearch()
|
|||
|
||||
QList<SearchPluginIface::Actioninfo> SettingsSearchPlugin::getActioninfo(int type)
|
||||
{
|
||||
Q_UNUSED(type)
|
||||
return m_actionInfo;
|
||||
}
|
||||
|
||||
void SettingsSearchPlugin::openAction(int actionkey, QString key, int type)
|
||||
{
|
||||
Q_UNUSED(type)
|
||||
//TODO add some return message here.
|
||||
switch (actionkey) {
|
||||
case 0:
|
||||
|
@ -91,8 +93,7 @@ void SettingsSearchPlugin::openAction(int actionkey, QString key, int type)
|
|||
if (res)
|
||||
break;
|
||||
//打开控制面板对应页面
|
||||
QProcess process;
|
||||
process.startDetached(QString("ukui-control-center -m %1").arg(key.toLower()));
|
||||
QProcess::startDetached("ukui-control-center", {"-m", key.toLower()});
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -61,11 +61,15 @@ void WebSearchPlugin::stopSearch()
|
|||
|
||||
QList<UkuiSearch::SearchPluginIface::Actioninfo> UkuiSearch::WebSearchPlugin::getActioninfo(int type)
|
||||
{
|
||||
Q_UNUSED(type)
|
||||
return m_actionInfo;
|
||||
}
|
||||
|
||||
void UkuiSearch::WebSearchPlugin::openAction(int actionkey, QString key, int type)
|
||||
{
|
||||
Q_UNUSED(actionkey)
|
||||
Q_UNUSED(key)
|
||||
Q_UNUSED(type)
|
||||
QString address;
|
||||
QString engine = GlobalSettings::getInstance()->getValue("webEngine").toString();
|
||||
if(!engine.isEmpty()) {
|
||||
|
@ -108,6 +112,7 @@ void UkuiSearch::WebSearchPlugin::openAction(int actionkey, QString key, int typ
|
|||
|
||||
QWidget *UkuiSearch::WebSearchPlugin::detailPage(const UkuiSearch::SearchPluginIface::ResultInfo &ri)
|
||||
{
|
||||
Q_UNUSED(ri)
|
||||
return m_detailPage;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue