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


C++ Ptr::setParent方法代码示例

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


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

示例1: loadProfile

Profile::Ptr ProfileManager::loadProfile(const QString& shortPath)
{
    // the fallback profile has a 'special' path name, "FALLBACK/"
    if (shortPath == _fallbackProfile->path())
        return _fallbackProfile;

    QString path = shortPath;

    // add a suggested suffix and relative prefix if missing
    QFileInfo fileInfo(path);

    if (fileInfo.isDir())
        return Profile::Ptr();

    if (fileInfo.suffix() != QLatin1String("profile"))
        path.append(".profile");
    if (fileInfo.path().isEmpty() || fileInfo.path() == QLatin1String("."))
        path.prepend(QLatin1String("konsole") + QDir::separator());

    // if the file is not an absolute path, look it up
    if (!fileInfo.isAbsolute())
        path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, path);

    // if the file is not found, return immediately
    if (path.isEmpty()) {
        return Profile::Ptr();
    }

    // check that we have not already loaded this profile
    foreach(const Profile::Ptr& profile, _profiles) {
        if (profile->path() == path)
            return profile;
    }

    // guard to prevent problems if a profile specifies itself as its parent
    // or if there is recursion in the "inheritance" chain
    // (eg. two profiles, A and B, specifying each other as their parents)
    static QStack<QString> recursionGuard;
    PopStackOnExit<QString> popGuardOnExit(recursionGuard);

    if (recursionGuard.contains(path)) {
        qWarning() << "Ignoring attempt to load profile recursively from" << path;
        return _fallbackProfile;
    } else {
        recursionGuard.push(path);
    }

    // load the profile
    ProfileReader* reader = new KDE4ProfileReader;

    Profile::Ptr newProfile = Profile::Ptr(new Profile(fallbackProfile()));
    newProfile->setProperty(Profile::Path, path);

    QString parentProfilePath;
    bool result = reader->readProfile(path, newProfile, parentProfilePath);

    if (!parentProfilePath.isEmpty()) {
        Profile::Ptr parentProfile = loadProfile(parentProfilePath);
        newProfile->setParent(parentProfile);
    }

    delete reader;

    if (!result) {
        qWarning() << "Could not load profile from " << path;
        return Profile::Ptr();
    } else {
        addProfile(newProfile);
        return newProfile;
    }
}
开发者ID:Tasssadar,项目名称:konsole,代码行数:71,代码来源:ProfileManager.cpp


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