コード例 #1
0
ファイル: popup.cpp プロジェクト: Atalanttore/lxqt-panel
// Paulo: I'm not sure what this is for
static bool hasRemovableParent(Solid::Device device)
{
    // qDebug() << "acess:" << device.udi();
    for ( ; !device.udi().isEmpty(); device = device.parent())
    {
        Solid::StorageDrive* drive = device.as<Solid::StorageDrive>();
        if (drive && drive->isRemovable())
        {
            // qDebug() << "removable parent drive:" << device.udi();
            return true;
        }
    }
    return false;
}
コード例 #2
0
ファイル: placesitemmodel.cpp プロジェクト: KDE/dolphin
QAction* PlacesItemModel::teardownAction(int index) const
{
    const PlacesItem* item = placesItem(index);
    if (!item) {
        return 0;
    }

    Solid::Device device = item->device();
    const bool providesTearDown = device.is<Solid::StorageAccess>() &&
                                  device.as<Solid::StorageAccess>()->isAccessible();
    if (!providesTearDown) {
        return 0;
    }

    Solid::StorageDrive* drive = device.as<Solid::StorageDrive>();
    if (!drive) {
        drive = device.parent().as<Solid::StorageDrive>();
    }

    bool hotPluggable = false;
    bool removable = false;
    if (drive) {
        hotPluggable = drive->isHotpluggable();
        removable = drive->isRemovable();
    }

    QString iconName;
    QString text;
    const QString label = item->text();
    if (device.is<Solid::OpticalDisc>()) {
        text = i18nc("@item", "Release '%1'", label);
    } else if (removable || hotPluggable) {
        text = i18nc("@item", "Safely Remove '%1'", label);
        iconName = QStringLiteral("media-eject");
    } else {
        text = i18nc("@item", "Unmount '%1'", label);
        iconName = QStringLiteral("media-eject");
    }

    if (iconName.isEmpty()) {
        return new QAction(text, 0);
    }

    return new QAction(QIcon::fromTheme(iconName), text, 0);
}
コード例 #3
0
ファイル: vfileplacesitem.cpp プロジェクト: curvedspace/vibe
    QVariant FilePlacesItem::deviceData(int role) const
    {
        Solid::Device d = device();

        if (!d.isValid())
            return QVariant();

        switch (role) {
            case Qt::DecorationRole:
                return QIcon::fromTheme(d.icon());
            case Qt::DisplayRole:
                return d.description();
            case VFilePlacesModel::UrlRole:
                if (m_access)
                    return QUrl::fromLocalFile(m_access->filePath());
                else if (m_disc && (m_disc->availableContent() && Solid::OpticalDisc::Audio) != 0) {
                    QString device = d.as<Solid::Block>()->device();
                    return QUrl(QString("audiocd:///?device=%1").arg(device));
                }
            case VFilePlacesModel::FixedDeviceRole: {
                Solid::StorageDrive *drive = 0;
                Solid::Device parentDevice = d;

                while (parentDevice.isValid() && !drive) {
                    drive = parentDevice.as<Solid::StorageDrive>();
                    parentDevice = parentDevice.parent();
                }

                if (drive)
                    return !drive->isHotpluggable() && !drive->isRemovable();
                return true;
            }
            break;
            default:
                break;
        }

        return QVariant();
    }