代码拉取完成,页面将自动刷新
同步操作将从 wufangzhao/startalk_pc_v2 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
//
// Created by cc on 2019-06-20.
//
#include "SearchView.h"
#include "../UICom/qimage/qimage.h"
#include "../UICom/StyleDefine.h"
#include "../Platform/AppSetting.h"
#include <QPainter>
#include <QEvent>
#include <QDebug>
SearchItemDelegate::SearchItemDelegate(QWidget *parent)
: QStyledItemDelegate(parent)
{
}
SearchItemDelegate::~SearchItemDelegate()
= default;
void SearchItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QStyledItemDelegate::paint(painter, option, index);
painter->save();
painter->setRenderHint(QPainter::TextAntialiasing);
painter->fillRect(option.rect, QTalk::StyleDefine::instance().getGroupManagerNormalColor());
//
int radius = 16;
QRect rect = option.rect;
QString strText = index.data(EM_SEARCH_DATATYPE_TEXT).toString();
QString iconPath = index.data(EM_SEARCH_DATATYPE_ICONPATH).toString();
QString staff = index.data(EM_SEARCH_DATATYPE_STAFF).toString();
QPixmap icon = QTalk::qimage::loadCirclePixmap(iconPath, radius * QTalk::qimage::dpi());
painter->setRenderHints(QPainter::Antialiasing, true);
painter->setRenderHints(QPainter::SmoothPixmapTransform, true);
painter->drawPixmap(QRect(rect.x(), rect.y() + (rect.height() - radius * 2) / 2, radius * 2, radius * 2), icon);
QTalk::setPainterFont(painter, AppSetting::instance().getFontLevel());
painter->setPen(QTalk::StyleDefine::instance().getNavNameFontColor());
painter->drawText(QRect(rect.x() + radius * 2 + 8, rect.y(),
rect.width() - radius * 2 - 2 - 30, rect.height() / 2), Qt::AlignBottom, strText);
painter->setPen(QTalk::StyleDefine::instance().getNavContentFontColor());
painter->drawText(QRect(rect.x() + radius * 2 + 8, rect.y() + rect.height() / 2 + 5,
rect.width() - radius * 2 - 8 - 50, rect.height() / 2), Qt::AlignTop, staff);
QRect pixRect = QRect(rect.right() - 40, rect.y() + (rect.height() - 20) / 2, 20, 20);;
bool isChecked = index.data(EM_SEARCH_DATATYPE_CHECKSTATE).toBool();
QString picPath = isChecked ? ":/GroupManager/image1/checkbox_checked.png"
: ":/GroupManager/image1/checkbox_unchecked.png";
QPixmap checkIcon = QTalk::qimage::loadCirclePixmap(picPath,
10 * QTalk::qimage::dpi());
painter->drawPixmap(pixRect, checkIcon);
painter->restore();
}
QSize SearchItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
const QSize& size = QStyledItemDelegate::sizeHint(option, index);
return {size.width(), 56};
}
bool SearchItemDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option,
const QModelIndex &index)
{
if(event->type() == QEvent::MouseButtonPress)
{
bool isChecked = model->data(index, EM_SEARCH_DATATYPE_CHECKSTATE).toBool();
model->setData(index, !isChecked, EM_SEARCH_DATATYPE_CHECKSTATE);
emit itemChanged(index);
}
else if(event->type() == QEvent::MouseButtonDblClick)
{
emit sgItemDbClicked(index);
}
return QStyledItemDelegate::editorEvent(event, model, option, index);
}
/*************/
SearchItemSortModel::SearchItemSortModel(QObject* parent)
: QSortFilterProxyModel(parent)
{
}
bool SearchItemSortModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const {
QModelIndex index = sourceModel()->index(source_row, 0, source_parent);
auto exp = filterRegExp();
bool ret = false;
ret |= index.data(EM_SEARCH_DATATYPE_TEXT).toString().toLower().contains(exp);
ret |= index.data(EM_SEARCH_DATATYPE_USERID).toString().toLower().contains(exp);
ret |= index.data(EM_SEARCH_DATATYPE_INDEX).toString().toLower().contains(exp);
// if(ret)
// {
// sourceModel()->setData(index, false, EM_SEARCH_DATATYPE_CHECKSTATE);
// }
return ret;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。