File indexing completed on 2024-04-28 09:43:52

0001 /*
0002     SPDX-FileCopyrightText: 2016 ROSA
0003     SPDX-License-Identifier: GPL-3.0-or-later
0004 */
0005 
0006 #ifndef USBDEVICE_H
0007 #define USBDEVICE_H
0008 
0009 ////////////////////////////////////////////////////////////////////////////////
0010 // Class for storing information about USB flash disk
0011 
0012 #include "common.h"
0013 
0014 #include <QStringList>
0015 
0016 #include <KLocalizedString>
0017 #include <KFormat>
0018 
0019 class UsbDevice
0020 {
0021 public:
0022     UsbDevice() :
0023         m_VisibleName(i18n("Unknown Device")),
0024         m_Volumes(),
0025         m_Size(0),
0026         m_SectorSize(512),
0027         m_PhysicalDevice("") {}
0028 
0029     // Formats the device description for GUI
0030     // The format is: "<volume(s)> - <user-friendly name> (<size in megabytes>)"
0031     QString formatDisplayName() const {
0032         return ((m_Volumes.isEmpty()) ? i18n("<unmounted>")
0033                 : m_Volumes.join(", ")) + " - " + m_VisibleName + " (" + KFormat().formatByteSize(m_Size) + QLatin1Char(')');
0034     }
0035 
0036     // User-friendly name of the device
0037     QString     m_VisibleName;
0038     // List of mounted volumes from this device
0039     QStringList m_Volumes;
0040     // Size of the device
0041     quint64     m_Size;
0042     // Sector size
0043     quint32     m_SectorSize;
0044     // System name of the physical disk
0045     QString     m_PhysicalDevice;
0046 };
0047 
0048 Q_DECLARE_METATYPE(UsbDevice*)
0049 
0050 
0051 #endif // USBDEVICE_H