Merge pull request #141 from mammonsama666/0219-dev

Fix bugs
This commit is contained in:
iaom 2021-02-19 23:54:56 -06:00 committed by GitHub
commit d83a4be1b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 29 additions and 7 deletions

View File

@ -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;

View File

@ -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) {

View File

@ -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);
}

View File

@ -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);

View File

@ -33,6 +33,7 @@ public:
explicit ShowMoreLabel(QWidget *parent = nullptr);
~ShowMoreLabel();
void resetLabel();
bool getExpanded();
protected:
bool eventFilter(QObject *, QEvent *);

View File

@ -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;

View File

@ -53,7 +53,7 @@ public:
void setItem(SearchItem *);
void appendItem(QString);
void appendList(QStringList);
void setList(QStringList);
void removeItem(QString);
void clear();