Commit 7c0f8516 authored by Isaac True's avatar Isaac True Committed by Christoph Feck
Browse files

Implement sorting of the device tree items

This patch fixes the issue of processor numbers not being sorted in human-readable order.

It overloads the < operator on the SolDevice class to implement sorting by process number and sorting by storage volume names (as they
should go, e.g.: sda, sda1, sda2...).

BUG: 380355

Reviewed by: cfeck, davidedmundson

Differential Revision:
parent ed7850ba
......@@ -49,6 +49,7 @@ DeviceListing::DeviceListing(QWidget *parent, InfoPanel *info, DevInfoPlugin *st
......@@ -153,3 +153,28 @@ bool SolDevice::isDeviceSet()
return deviceSet;
bool SolDevice::operator< ( const QTreeWidgetItem & other ) const
const SolDevice * otherDevice = dynamic_cast<const SolDevice*>(&other);
if (otherDevice) {
if (deviceType() != otherDevice->deviceType()) {
return deviceType() < otherDevice->deviceType();
switch (deviceType()) {
case Solid::DeviceInterface::Processor: {
const Solid::Processor *left =<const Solid::Processor>();
const Solid::Processor *right = otherDevice-><const Solid::Processor>();
// Processors are sorted in ascending order, so this is reversed
return left->number() > right->number();
case Solid::DeviceInterface::StorageVolume: {
// Storage volumes are sorted in ascending order (i.e. sda, sda1, sda2...)
return text(0) > other.text(0);
return text(0) < other.text(0);
......@@ -108,6 +108,7 @@ public:
QString udi() const;
bool isDeviceSet();
bool operator< (const QTreeWidgetItem & other) const;
void setDeviceText(const QString &);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment