1 Star 0 Fork 9

fuyb/linux_feiq

forked from uenigma/linux_feiq 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
searchfellowdlg.cpp 1.51 KB
一键复制 编辑 原始数据 按行查看 历史
lpx 提交于 2021-12-16 21:35 +08:00 . 格式化代码
#include "searchfellowdlg.h"
#include "ui_searchfellowdlg.h"
SearchFellowDlg::SearchFellowDlg(QWidget *parent) : QDialog(parent),
ui(new Ui::SearchFellowDlg)
{
ui->setupUi(this);
connect(ui->searchEdit, SIGNAL(textChanged(QString)), this, SLOT(search(QString)));
connect(ui->cancelBtn, SIGNAL(pressed()), this, SLOT(hide()));
connect(ui->okBtn, SIGNAL(pressed()), this, SLOT(searchDone()));
connect(ui->resultListWidget, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(searchDone()));
}
SearchFellowDlg::~SearchFellowDlg()
{
delete ui;
}
void SearchFellowDlg::setSearchDriver(function<vector<const Fellow *>(const QString &)> driver)
{
mSearchDriver = driver;
}
void SearchFellowDlg::search(const QString &text)
{
if (mSearchDriver)
{
mCurResult = mSearchDriver(text);
ui->resultListWidget->clear();
for (const Fellow *fellow : mCurResult)
ui->resultListWidget->addItem(QString(fellow->toString().c_str()));
if (mCurResult.size() > 0)
ui->resultListWidget->setCurrentRow(0);
ui->okBtn->setEnabled(mCurResult.size() > 0);
}
}
void SearchFellowDlg::searchDone()
{
auto row = ui->resultListWidget->currentRow();
if (row >= 0)
{
emit onFellowSelected(mCurResult[row]);
hide();
}
}
void SearchFellowDlg::showEvent(QShowEvent *)
{
loadAllFellows();
}
void SearchFellowDlg::loadAllFellows()
{
search(""); //search 空字符串将获得所有好友
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/HALOBING/linux_feiq.git
git@gitee.com:HALOBING/linux_feiq.git
HALOBING
linux_feiq
linux_feiq
master

搜索帮助