diff --git a/libpeony-qt/model/side-bar-proxy-filter-sort-model.cpp b/libpeony-qt/model/side-bar-proxy-filter-sort-model.cpp index 2786e393..5b276597 100644 --- a/libpeony-qt/model/side-bar-proxy-filter-sort-model.cpp +++ b/libpeony-qt/model/side-bar-proxy-filter-sort-model.cpp @@ -99,6 +99,7 @@ bool SideBarProxyFilterSortModel::filterAcceptsRow(int sourceRow, const QModelIn if (!m_show_hidden) { return !item->displayName().startsWith("."); } + } return true; @@ -119,7 +120,51 @@ bool SideBarProxyFilterSortModel::lessThan(const QModelIndex &left, const QModel if (leftItem->type() != SideBarAbstractItem::FileSystemItem || rightItem->type() != SideBarAbstractItem::FileSystemItem) { return false; } - //qDebug()<displayName()<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; }