mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
UniversalEntry: put notebooks and folders before notes in the result
This commit is contained in:
parent
e844bf5e40
commit
31dbdbfe4d
@ -13,6 +13,14 @@ VListWidgetDoubleRows::VListWidgetDoubleRows(QWidget *p_parent)
|
|||||||
QListWidgetItem *VListWidgetDoubleRows::addItem(const QIcon &p_icon,
|
QListWidgetItem *VListWidgetDoubleRows::addItem(const QIcon &p_icon,
|
||||||
const QString &p_firstRow,
|
const QString &p_firstRow,
|
||||||
const QString &p_secondRow)
|
const QString &p_secondRow)
|
||||||
|
{
|
||||||
|
return VListWidgetDoubleRows::insertItem(count(), p_icon, p_firstRow, p_secondRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
QListWidgetItem *VListWidgetDoubleRows::insertItem(int p_row,
|
||||||
|
const QIcon &p_icon,
|
||||||
|
const QString &p_firstRow,
|
||||||
|
const QString &p_secondRow)
|
||||||
{
|
{
|
||||||
VDoubleRowItemWidget *itemWidget = new VDoubleRowItemWidget(this);
|
VDoubleRowItemWidget *itemWidget = new VDoubleRowItemWidget(this);
|
||||||
itemWidget->setText(p_firstRow, p_secondRow);
|
itemWidget->setText(p_firstRow, p_secondRow);
|
||||||
@ -34,7 +42,7 @@ QListWidgetItem *VListWidgetDoubleRows::addItem(const QIcon &p_icon,
|
|||||||
|
|
||||||
item->setSizeHint(sz);
|
item->setSizeHint(sz);
|
||||||
|
|
||||||
VListWidget::addItem(item);
|
VListWidget::insertItem(p_row, item);
|
||||||
VListWidget::setItemWidget(item, itemWidget);
|
VListWidget::setItemWidget(item, itemWidget);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,11 @@ public:
|
|||||||
const QString &p_firstRow,
|
const QString &p_firstRow,
|
||||||
const QString &p_secondRow);
|
const QString &p_secondRow);
|
||||||
|
|
||||||
|
QListWidgetItem *insertItem(int p_row,
|
||||||
|
const QIcon &p_icon,
|
||||||
|
const QString &p_firstRow,
|
||||||
|
const QString &p_secondRow);
|
||||||
|
|
||||||
void clearAll() Q_DECL_OVERRIDE;
|
void clearAll() Q_DECL_OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -622,8 +622,11 @@ void VSearchUE::appendItemToList(const QSharedPointer<VSearchResultItem> &p_item
|
|||||||
}
|
}
|
||||||
|
|
||||||
QIcon *icon = NULL;
|
QIcon *icon = NULL;
|
||||||
|
// We put notebook and folder before note.
|
||||||
|
int row = 0;
|
||||||
switch (p_item->m_type) {
|
switch (p_item->m_type) {
|
||||||
case VSearchResultItem::Note:
|
case VSearchResultItem::Note:
|
||||||
|
row = m_listWidget->count();
|
||||||
icon = &m_noteIcon;
|
icon = &m_noteIcon;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -639,11 +642,11 @@ void VSearchUE::appendItemToList(const QSharedPointer<VSearchResultItem> &p_item
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
QListWidgetItem *item = m_listWidget->addItem(*icon, first, second);
|
QListWidgetItem *item = m_listWidget->insertItem(row, *icon, first, second);
|
||||||
item->setData(Qt::UserRole, m_data.size() - 1);
|
item->setData(Qt::UserRole, m_data.size() - 1);
|
||||||
item->setToolTip(p_item->m_path);
|
item->setToolTip(p_item->m_path);
|
||||||
|
|
||||||
if (m_listWidget->currentRow() == -1) {
|
if (row == 0) {
|
||||||
m_listWidget->setCurrentRow(0);
|
m_listWidget->setCurrentRow(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user