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


C++ KFileItem::mostLocalURL方法代码示例

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


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

示例1: autostart

bool MediaNotifier::autostart(const KFileItem &medium)
{
    QString mimetype = medium.mimetype();

    bool is_cdrom = mimetype.startsWith("cd") || mimetype.startsWith("dvd");
    bool is_mounted = mimetype.endsWith("_mounted");

    // We autorun only on CD/DVD or removable disks (USB, Firewire)
    if(!(is_cdrom || is_mounted) && mimetype != "media/removable_mounted")
    {
        return false;
    }


    // Here starts the 'Autostart Of Applications After Mount' implementation

    // The desktop environment MAY ignore Autostart files altogether
    // based on policy set by the user, system administrator or vendor.
    MediaManagerSettings::self()->readConfig();
    if(!MediaManagerSettings::self()->autostartEnabled())
    {
        return false;
    }

    // From now we're sure the medium is already mounted.
    // We can use the local path for stating, no need to use KIO here.
    bool local;
    QString path = medium.mostLocalURL(local).path(); // local is always true here...

    // When a new medium is mounted the root directory of the medium should
    // be checked for the following Autostart files in order of precedence:
    // .autorun, autorun, autorun.sh
    QStringList autorun_list;
    autorun_list << ".autorun"
                 << "autorun"
                 << "autorun.sh";

    QStringList::iterator it = autorun_list.begin();
    QStringList::iterator end = autorun_list.end();

    for(; it != end; ++it)
    {
        if(QFile::exists(path + "/" + *it))
        {
            return execAutorun(medium, path, *it);
        }
    }

    // When a new medium is mounted the root directory of the medium should
    // be checked for the following Autoopen files in order of precedence:
    // .autoopen, autoopen
    QStringList autoopen_list;
    autoopen_list << ".autoopen"
                  << "autoopen";

    it = autoopen_list.begin();
    end = autoopen_list.end();

    for(; it != end; ++it)
    {
        if(QFile::exists(path + "/" + *it))
        {
            return execAutoopen(medium, path, *it);
        }
    }

    return false;
}
开发者ID:serghei,项目名称:kde3-kdebase,代码行数:68,代码来源:medianotifier.cpp


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