[FIX]修复U盘没有按照规则排序的问题[LINK]bug#160879

This commit is contained in:
xiangwenjie 2023-06-26 07:32:59 +00:00 committed by Yue-Lan
parent 7bbd04104c
commit 69bdcdac7f
1 changed files with 46 additions and 1 deletions

View File

@ -99,6 +99,7 @@ bool SideBarProxyFilterSortModel::filterAcceptsRow(int sourceRow, const QModelIn
if (!m_show_hidden) { if (!m_show_hidden) {
return !item->displayName().startsWith("."); return !item->displayName().startsWith(".");
} }
} }
return true; return true;
@ -119,7 +120,51 @@ bool SideBarProxyFilterSortModel::lessThan(const QModelIndex &left, const QModel
if (leftItem->type() != SideBarAbstractItem::FileSystemItem || rightItem->type() != SideBarAbstractItem::FileSystemItem) { if (leftItem->type() != SideBarAbstractItem::FileSystemItem || rightItem->type() != SideBarAbstractItem::FileSystemItem) {
return false; return false;
} }
//qDebug()<<leftItem->displayName()<<rightItem->displayName();
if (left.parent().data(Qt::UserRole).toString().compare("computer:///") == 0
&& right.parent().data(Qt::UserRole).toString().compare("computer:///") == 0) {
if (leftItem->uri().compare("file:///") == 0) {
return false;
}
if (rightItem->uri().compare("file:///") == 0) {
return true;
}
if (leftItem->uri().compare("computer:///ukui-data-volume") == 0) {
return false;
}
if (rightItem->uri().compare("computer:///ukui-data-volume") == 0) {
return true;
}
if ((!(leftItem->isEjectable() || leftItem->isStopable()) && !leftItem->getDevice().startsWith("/dev/bus/usb"))
&& (!(rightItem->isEjectable() || rightItem->isStopable()) && !rightItem->getDevice().startsWith("/dev/bus/usb"))) {
return m_comparer.compare(leftItem->getDevice(), rightItem->getDevice()) > 0;
} else if (!(leftItem->isEjectable() || leftItem->isStopable()) && !leftItem->getDevice().startsWith("/dev/bus/usb")) {
return false;
} else if (!(rightItem->isEjectable() || rightItem->isStopable()) && !rightItem->getDevice().startsWith("/dev/bus/usb")) {
return true;
}
if (((leftItem->isEjectable() || leftItem->isStopable()) && !leftItem->getDevice().startsWith("/dev/sr"))
&& ((rightItem->isEjectable() || rightItem->isStopable()) && !rightItem->getDevice().startsWith("/dev/sr"))) {
return m_comparer.compare(leftItem->getDevice(), rightItem->getDevice()) > 0;
} else if ((leftItem->isEjectable() || leftItem->isStopable()) && !leftItem->getDevice().startsWith("/dev/sr")) {
return false;
} else if ((rightItem->isEjectable() || rightItem->isEjectable()) && !rightItem->getDevice().startsWith("/dev/sr")) {
return true;
}
if (leftItem->getDevice().startsWith("/dev/bus/usb") && rightItem->getDevice().startsWith("/dev/bus/usb")) {
return m_comparer.compare(leftItem->getDevice(), rightItem->getDevice()) > 0;
} else if (leftItem->getDevice().startsWith("/dev/bus/usb")) {
return false;
} else if (rightItem->getDevice().startsWith("/dev/bus/usb")) {
return true;
}
return m_comparer.compare(leftItem->getDevice(), rightItem->getDevice()) > 0;
}
return m_comparer.compare(leftItem->displayName(), rightItem->displayName()) > 0; return m_comparer.compare(leftItem->displayName(), rightItem->displayName()) > 0;
} }