commit
d83a4be1b3
|
@ -555,10 +555,12 @@ void ContentWidget::appendSearchItem(const int& type, const QString& path, QStri
|
|||
m_fileListView->isHidden = false;
|
||||
appendSearchItem(SearchItem::SearchType::Best, path);
|
||||
}
|
||||
if (m_fileListView->getLength() < 5) {
|
||||
if (m_fileListView->getLength() < 5) { //当已搜索结果列表少于5项,直接将搜索结果添加到列表中
|
||||
m_fileListView->appendItem(path);
|
||||
} else if (m_fileListView->getLength() == 5) {
|
||||
} else if (m_fileListView->getLength() == 5) { //当已搜索结果等于5项,新增的被折叠,显示“展开”按钮
|
||||
m_fileShowMoreLabel->show();
|
||||
} else { //当搜索列表显示的大于5项,说明列表被展开,可以继续把新增项添加到列表中
|
||||
m_fileListView->appendItem(path);
|
||||
}
|
||||
m_fileList.append(path);
|
||||
break;;
|
||||
|
@ -574,6 +576,8 @@ void ContentWidget::appendSearchItem(const int& type, const QString& path, QStri
|
|||
m_dirListView->appendItem(path);
|
||||
} else if (m_dirListView->getLength() == 5) {
|
||||
m_dirShowMoreLabel->show();
|
||||
} else {
|
||||
m_dirListView->appendItem(path);
|
||||
}
|
||||
m_dirList.append(path);
|
||||
break;
|
||||
|
@ -595,6 +599,8 @@ void ContentWidget::appendSearchItem(const int& type, const QString& path, QStri
|
|||
m_contentListView->appendItem(path);
|
||||
} else if (m_contentListView->getLength() == 5) {
|
||||
m_contentShowMoreLabel->show();
|
||||
} else {
|
||||
m_contentListView->appendItem(path);
|
||||
}
|
||||
m_contentList.append(path);
|
||||
QString temp;
|
||||
|
|
|
@ -62,7 +62,7 @@ void HighlightItemDelegate::paint(QPainter * painter, const QStyleOptionViewItem
|
|||
doc.documentLayout()->draw(painter, ctx); //绘制文本区域内容
|
||||
painter->restore();
|
||||
|
||||
//以下为drawitemtext方法绘制文字,印加粗字体与原字体不等宽导致像素不对齐,视觉效果较差,已暂时摒弃
|
||||
//以下为drawitemtext方法绘制文字,因加粗字体与原字体不等宽导致像素不对齐,视觉效果较差,已暂时摒弃
|
||||
// QStyleOptionViewItem itemOption = option;
|
||||
// initStyleOption(&itemOption, index);
|
||||
// if (itemOption.state & QStyle::State_HasFocus) {
|
||||
|
|
|
@ -76,7 +76,13 @@ void SearchListView::appendItem(QString path) {
|
|||
*/
|
||||
void SearchListView::setList(QStringList list)
|
||||
{
|
||||
m_model->appendList(list);
|
||||
QModelIndex index = this->currentIndex();
|
||||
m_model->setList(list);
|
||||
if (index.row() >= 0 && index.row() < list.length()) {
|
||||
this->blockSignals(true);
|
||||
this->setCurrentIndex(index);
|
||||
this->blockSignals(false);
|
||||
}
|
||||
rowheight = this->rowHeight(this->model()->index(0, 0, QModelIndex()));
|
||||
this->setFixedHeight(m_item->getCurrentSize() * rowheight + 4);
|
||||
}
|
||||
|
|
|
@ -40,6 +40,15 @@ void ShowMoreLabel::resetLabel()
|
|||
m_textLabel->setText(tr("Show More..."));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ShowMoreLabel::getExpanded 获取当前是否是展开状态
|
||||
* @return true已展开,false已收起
|
||||
*/
|
||||
bool ShowMoreLabel::getExpanded()
|
||||
{
|
||||
return m_isOpen;
|
||||
}
|
||||
|
||||
void ShowMoreLabel::initUi()
|
||||
{
|
||||
m_layout = new QHBoxLayout(this);
|
||||
|
|
|
@ -33,6 +33,7 @@ public:
|
|||
explicit ShowMoreLabel(QWidget *parent = nullptr);
|
||||
~ShowMoreLabel();
|
||||
void resetLabel();
|
||||
bool getExpanded();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *, QEvent *);
|
||||
|
|
|
@ -149,10 +149,10 @@ void SearchItemModel::appendItem(QString path) {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief SearchItemModel::appendList 直接以列表形式添加搜索结果
|
||||
* @brief SearchItemModel::setList 直接以列表形式添加搜索结果
|
||||
* @param list
|
||||
*/
|
||||
void SearchItemModel::appendList(QStringList list)
|
||||
void SearchItemModel::setList(QStringList list)
|
||||
{
|
||||
this->beginResetModel();
|
||||
m_item->m_pathlist = list;
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
void setItem(SearchItem *);
|
||||
|
||||
void appendItem(QString);
|
||||
void appendList(QStringList);
|
||||
void setList(QStringList);
|
||||
void removeItem(QString);
|
||||
void clear();
|
||||
|
||||
|
|
Loading…
Reference in New Issue