当前位置: 首页>>代码示例>>C++>>正文


C++ Device::parent方法代码示例

本文整理汇总了C++中solid::Device::parent方法的典型用法代码示例。如果您正苦于以下问题:C++ Device::parent方法的具体用法?C++ Device::parent怎么用?C++ Device::parent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在solid::Device的用法示例。


在下文中一共展示了Device::parent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: start

void SolidDeviceJob::start()
{
    Solid::Device device (m_dest);
    QString operation = operationName();
    
    if (operation == QLatin1String("mount")) {
        if (device.is<Solid::StorageAccess>()) {
            Solid::StorageAccess *access = device.as<Solid::StorageAccess>();
            if (access && !access->isAccessible()) {
                access->setup();
            }
        }
    }
    else if (operation == QLatin1String("unmount")) {
        if (device.is<Solid::OpticalDisc>()) {
            Solid::OpticalDrive *drive = device.as<Solid::OpticalDrive>();
            if (!drive) {
                drive = device.parent().as<Solid::OpticalDrive>();
            }
            if (drive) {
                drive->eject();
            }
        }
        else if (device.is<Solid::StorageAccess>()) {
            Solid::StorageAccess *access = device.as<Solid::StorageAccess>();
            if (access && access->isAccessible()) {
                access->teardown();
            }
        }
    }

    emitResult();
}
开发者ID:KDE,项目名称:plasma-workspace,代码行数:33,代码来源:soliddevicejob.cpp

示例2: opticalParent

Solid::Device MenuDiskItem::opticalParent() const
{
    Solid::Device it = mDevice;
    //search for parent drive
    for ( ; !it.udi().isEmpty(); it = it.parent())
    {
        if (it.is<Solid::OpticalDrive>())
            break;
    }
    return it;
}
开发者ID:krytarowski,项目名称:lxqt-panel,代码行数:11,代码来源:menudiskitem.cpp

示例3: hasRemovableParent

// 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;
}
开发者ID:Atalanttore,项目名称:lxqt-panel,代码行数:15,代码来源:popup.cpp

示例4: lookup

AudioCdDevice::AudioCdDevice(MusicModel *m, Solid::Device &dev)
    : Device(m, dev, false, true)
    #ifdef CDDB_FOUND
    , cddb(0)
    #endif
    #ifdef MUSICBRAINZ5_FOUND
    , mb(0)
    #endif
    , year(0)
    , disc(0)
    , time(0xFFFFFFFF)
    , lookupInProcess(false)
    , autoPlay(false)
{
    icn=Icon("media-optical");
    drive=dev.parent().as<Solid::OpticalDrive>();
    Solid::Block *block=dev.as<Solid::Block>();
    if (block) {
        device=block->device();
    } else { // With UDisks2 we cannot get block from device :-(
        QStringList parts=dev.udi().split("/", QString::SkipEmptyParts);
        if (!parts.isEmpty()) {
            parts=parts.last().split(":");
            if (!parts.isEmpty()) {
                device="/dev/"+parts.first();
            }
        }
    }
    if (!device.isEmpty()) {
        static bool registeredTypes=false;
        if (!registeredTypes) {
            qRegisterMetaType<CdAlbum >("CdAlbum");
            qRegisterMetaType<QList<CdAlbum> >("QList<CdAlbum>");
            registeredTypes=true;
        }
        devPath=Song::constCddaProtocol+device+QChar('/');
        #if defined CDDB_FOUND && defined MUSICBRAINZ5_FOUND
        connectService(Settings::self()->useCddb());
        #else
        connectService(true);
        #endif
        detailsString=i18n("Reading disc");
        setStatusMessage(detailsString);
        lookupInProcess=true;
        connect(Covers::self(), SIGNAL(cover(const Song &, const QImage &, const QString &)),
                this, SLOT(setCover(const Song &, const QImage &, const QString &)));
        emit lookup(Settings::self()->cdAuto());
    }
}
开发者ID:ciotog,项目名称:cantata,代码行数:49,代码来源:audiocddevice.cpp

示例5: teardownAction

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);
}
开发者ID:KDE,项目名称:dolphin,代码行数:45,代码来源:placesitemmodel.cpp

示例6: deviceData

    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();
    }
开发者ID:curvedspace,项目名称:vibe,代码行数:39,代码来源:vfileplacesitem.cpp


注:本文中的solid::Device::parent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。