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


C++ KConfigGroup::group方法代码示例

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


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

示例1: loadFrom

void CustomBuildSystemConfigWidget::loadFrom( KConfig* cfg )
{
    ui->currentConfig->clear();
    QStringList groupNameList;
    KConfigGroup grp = cfg->group( ConfigConstants::customBuildSystemGroup );
    foreach( const QString& grpName, grp.groupList() ) {
        KConfigGroup subgrp = grp.group( grpName );
        CustomBuildSystemConfig config;

        config.title = subgrp.readEntry( ConfigConstants::configTitleKey, QString() );
        config.buildDir = subgrp.readEntry( ConfigConstants::buildDirKey, QUrl() );

        foreach( const QString& subgrpName, subgrp.groupList() ) {
            if( subgrpName.startsWith( ConfigConstants::toolGroupPrefix ) ) {
                KConfigGroup toolgrp = subgrp.group( subgrpName );
                CustomBuildSystemTool tool;
                tool.arguments = toolgrp.readEntry( ConfigConstants::toolArguments, "" );
                tool.executable = toolgrp.readEntry( ConfigConstants::toolExecutable, QUrl() );
                tool.envGrp = toolgrp.readEntry( ConfigConstants::toolEnvironment, QString() );
                tool.enabled = toolgrp.readEntry( ConfigConstants::toolEnabled, false );
                tool.type = CustomBuildSystemTool::ActionType( toolgrp.readEntry( ConfigConstants::toolType, 0 ) );
                config.tools[tool.type] = tool;
            }
        }
        configs << config;
        ui->currentConfig->addItem( config.title );
        groupNameList << grpName;
    }
    int idx = groupNameList.indexOf( grp.readEntry( ConfigConstants::currentConfigKey, "" ) );
    if( !groupNameList.isEmpty() && idx < 0 )
        idx = 0;

    ui->currentConfig->setCurrentIndex( idx );
    changeCurrentConfig( idx );
}
开发者ID:alstef,项目名称:kdevelop,代码行数:35,代码来源:custombuildsystemconfigwidget.cpp

示例2: saveToConfiguration

    void saveToConfiguration(KConfigGroup config)
    {
        kDebug() << m_paths.count();

        KConfigGroup cfg = config.group(PathMappings::pathMappingsEntry);
        cfg.writeEntry("Count", m_paths.count());
        int i=0;
        foreach (const Path &p, m_paths) {
            i++;
            KConfigGroup pCfg = cfg.group(QString::number(i));
            pCfg.writeEntry(PathMappings::pathMappingRemoteEntry, p.remote);
            pCfg.writeEntry(PathMappings::pathMappingLocalEntry, p.local);
        }
开发者ID:caidongyun,项目名称:kdevplatform,代码行数:13,代码来源:pathmappings.cpp

示例3: saveSettings

void ConfirmAddressConfigureTabWidget::saveSettings(KConfigGroup &grp)
{
    KConfigGroup identityGroup = grp.group(QStringLiteral("Confirm Address %1").arg(mIdentity));
    identityGroup.writeEntry("Domains", mDomainNameListEditor->stringList());
    identityGroup.writeEntry("Emails", mWhiteListEditor->stringList());
    identityGroup.writeEntry("RejectDomain", mRejectedDomain->isChecked());
}
开发者ID:KDE,项目名称:kdepim-addons,代码行数:7,代码来源:confirmaddressconfiguretabwidget.cpp

示例4: saveConfig

void CustomBuildSystemConfigWidget::saveConfig( KConfigGroup& grp, CustomBuildSystemConfig& c, int index )
{
    // Generate group name, access and clear it
    KConfigGroup subgrp = grp.group( ConfigConstants::buildConfigPrefix + QString::number(index) );
    subgrp.deleteGroup();

    // Write current configuration key, if our group is current
    if( ui->currentConfig->currentIndex() == index )
        grp.writeEntry( ConfigConstants::currentConfigKey, subgrp.name() );

    subgrp.writeEntry( ConfigConstants::configTitleKey, c.title );
    subgrp.writeEntry<QUrl>( ConfigConstants::buildDirKey, c.buildDir );
    foreach( const CustomBuildSystemTool& tool, c.tools ) {
        KConfigGroup toolgrp = subgrp.group( generateToolGroupName( tool.type ) );
        toolgrp.writeEntry( ConfigConstants::toolType, int(tool.type) );
        toolgrp.writeEntry( ConfigConstants::toolEnvironment , tool.envGrp );
        toolgrp.writeEntry( ConfigConstants::toolEnabled, tool.enabled );
        toolgrp.writeEntry<QUrl>( ConfigConstants::toolExecutable, tool.executable );
        toolgrp.writeEntry( ConfigConstants::toolArguments, tool.arguments );
    }
}
开发者ID:alstef,项目名称:kdevelop,代码行数:21,代码来源:custombuildsystemconfigwidget.cpp

示例5: loadSettings

void ConfirmAddressConfigureTabWidget::loadSettings(const KConfigGroup &grp)
{
    KConfigGroup identityGroup = grp.group(QStringLiteral("Confirm Address %1").arg(mIdentity));
    mDomainNameListEditor->setStringList(identityGroup.readEntry("Domains", QStringList()));
    mWhiteListEditor->setStringList(identityGroup.readEntry("Emails", QStringList()));
    const bool rejectedDomain = identityGroup.readEntry("RejectDomain", false);
    if (rejectedDomain) {
        mRejectedDomain->setChecked(true);
    } else {
        mAcceptedDomain->setChecked(true);
    }
}
开发者ID:KDE,项目名称:kdepim-addons,代码行数:12,代码来源:confirmaddressconfiguretabwidget.cpp

示例6: process

void process(Mode mode, KConfigGroup &grp, QString key, QString value)
{
    switch (mode) {
    case Read:
        if (IS_A_TTY(1))
            std::cout << CHAR(key) << ": " << CHAR(grp.readEntry(key, "does not exist")) << " (" << CHAR(path(grp)) << ")" << std::endl;
        else
            std::cout << CHAR(grp.readEntry(key, ""));
        break;
    case Write: {
        if (grp.isImmutable()) {
            std::cout << "The component/group " << CHAR(path(grp)) << " cannot be modified" << std::endl;
            exit(1);
        }
        bool added = !grp.hasKey(key);
        QString oldv;
        if (!added) oldv = grp.readEntry(key);
        grp.writeEntry(key, QString(value));
        grp.sync();
        if (added)
            std::cout << "New " << CHAR(key) << ": " << CHAR(grp.readEntry(key)) << std::endl;
        else
            std::cout << CHAR(key) << ": " << CHAR(oldv) << " -> " << CHAR(grp.readEntry(key)) << std::endl;
        break;
    }
    case Delete: {
        if (grp.isImmutable()) {
            std::cout << "The component/group " << CHAR(path(grp)) << " cannot be modified" << std::endl;
            exit(1);
        }
        if (grp.hasKey(key)) {
            std::cout << "Removed " << CHAR(key) << ": " << CHAR(grp.readEntry(key)) << std::endl;
            grp.deleteEntry(key);
            grp.sync();
        } else if (grp.hasGroup(key)) {
            std::cout << "There's a group, but no key: " << CHAR(key) << "\nPlease explicitly use deletegroup" << std::endl;
            exit(1);
        } else {
            std::cout << "There's no key " << CHAR(key) << " in " << CHAR(path(grp)) << std::endl;
            exit(1);
        }
        break;
    }
    case DeleteGroup: {
        if (grp.hasGroup(key)) {
            grp = grp.group(key);
            if (grp.isImmutable()) {
                std::cout << "The component/group " << CHAR(path(grp)) << " cannot be modified" << std::endl;
                exit(1);
            }
            QMap<QString, QString> map = grp.entryMap();
            std::cout << "Removed " << CHAR(key) << gs_separator << std::endl;
            for (QMap<QString, QString>::const_iterator it = map.constBegin(), end = map.constEnd(); it != end; ++it) {
                std::cout << CHAR(it.key()) << ": " << CHAR(it.value()) << std::endl;
            }
            grp.deleteGroup();
            grp.sync();
        } else {
            std::cout << "There's no group " << CHAR(key) << " in " << CHAR(path(grp)) << std::endl;
            exit(1);
        }
        break;
    }
    case List:
    case ListKeys: {
        if (!grp.exists()) { // could be parent group
            if (mode == ListKeys)
                exit(1);
            QStringList groups = grp.parent().exists() ? grp.parent().groupList() : grp.config()->groupList();
            if (groups.isEmpty()) {
                std::cout << "The component/group " << CHAR(path(grp)) << " does not exist" << std::endl;
                exit(1);
            }
            std::cout << "Groups in " << CHAR(path(grp)) << gs_separator << std::endl;
            foreach (const QString &s, groups)
                if (key.isEmpty() || s.contains(key, Qt::CaseInsensitive))
                    std::cout << CHAR(s) << std::endl;
            exit(0);
        }

        QMap<QString, QString> map = grp.entryMap();
        if (map.isEmpty()) {
            std::cout << "The group " << CHAR(path(grp)) << " is empty" << std::endl;
            break;
        }

        if (mode == List) {
            bool matchFound = false;
            for (QMap<QString, QString>::const_iterator it = map.constBegin(), end = map.constEnd(); it != end; ++it) {
                if (key.isEmpty() || it.key().contains(key, Qt::CaseInsensitive)) {
                    if (!matchFound)
                        std::cout << std::endl << CHAR(path(grp)) << gs_separator << std::endl;
                    matchFound = true;
                    std::cout << CHAR(it.key()) << ": " << CHAR(it.value()) << std::endl;
                }
            }

            if (!matchFound)
                std::cout << "No present key matches \"" << CHAR(key) << "\" in " << CHAR(path(grp));
            std::cout << std::endl;
//.........这里部分代码省略.........
开发者ID:luebking,项目名称:KLItools,代码行数:101,代码来源:kconfig.cpp

示例7: readSettings


//.........这里部分代码省略.........
        stopSettings.set( TimeOfFirstDepartureSetting,
                          QTime::fromString(cgGlobal.readEntry("timeOfFirstDepartureCustom" + suffix,
                                                               "12:00"), "hh:mm") );
        stopSettings.set( FirstDepartureConfigModeSetting,
                          cgGlobal.readEntry("firstDepartureConfigMode" + suffix,
                                             static_cast<int>(RelativeToCurrentTime)) );
        stopSettings.set( AlarmTimeSetting, cgGlobal.readEntry("alarmTime" + suffix, 5) );

        // Read favorite/recent journey search items for the current stop settings
        QByteArray journeySearchesData =
                cgGlobal.readEntry( "journeySearches" + suffix, QByteArray() );
        stopSettings.set( Settings::JourneySearchSetting, QVariant::fromValue(
                SettingsIO::decodeJourneySearchItems(&journeySearchesData)) );
        stopSettingsList << stopSettings;

        ++i;
        test = "location_" + QString::number( i );
        if ( i > stopSettingCount ) {
            break;
        }
    }

    settings.setCurrentStop( cg.readEntry("currentStopIndex", 0) );

    // Add initial stop settings when no settings are available
    if ( stopSettingsList.isEmpty() ) {
        kDebug() << "Stop settings list in settings is empty";
        if ( publictransportEngine ) {
            QString countryCode = KGlobal::locale()->country();
            Plasma::DataEngine::Data locationData = publictransportEngine->query( "Locations" );
            QString defaultServiceProviderId =
                    locationData[countryCode].toHash()["defaultProvider"].toString();

            StopSettings stopSettings;
            if ( defaultServiceProviderId.isEmpty() ) {
                stopSettings.set( LocationSetting, "showAll" );
            } else {
                stopSettings.set( LocationSetting, countryCode );
                stopSettings.set( ServiceProviderSetting, defaultServiceProviderId );
            }
            stopSettings.setStop( QString() );
            // TODO: Get initial stop names using StopFinder

            stopSettingsList << stopSettings;
        } else {
            stopSettingsList << StopSettings();
        }

    }
    settings.setStops( stopSettingsList );

    if ( settings.currentStopIndex() < 0 ) {
        settings.setCurrentStop( 0 ); // For compatibility with versions < 0.7
    } else if ( settings.currentStopIndex() >= settings.stops().count() ) {
        kDebug() << "Current stop index in settings invalid";
        settings.setCurrentStop( settings.stops().count() - 1 );
    }

    settings.setMaximalNumberOfDepartures( cg.readEntry("maximalNumberOfDepartures", 50) );
    settings.setLinesPerRow( cg.readEntry("linesPerRow", 2) );
    settings.setSizeFactor( Settings::sizeFactorFromSize(cg.readEntry("size", 2)) );
    settings.setDepartureArrivalListType( static_cast<DepartureArrivalListType>(
            cg.readEntry("departureArrivalListType", static_cast<int>(DepartureList))) );

    settings.setDrawShadows( cg.readEntry("drawShadows", true) );
    settings.setHideTargetColumn( cg.readEntry("hideColumnTarget", false) );
    settings.setColorize( cg.readEntry("colorize", true) );

    QString fontFamily = cg.readEntry( "fontFamily", QString() );
    settings.setUseThemeFont( fontFamily.isEmpty() );
    if ( !settings.useThemeFont() ) {
        settings.setFont( QFont(fontFamily) );
    } else {
        settings.setFont( Plasma::Theme::defaultTheme()->font(Plasma::Theme::DefaultFont) );
    }

    // ***************** DEPRECATED BEGIN *****************************************************
    // *** Used for migration of filter settings from versions prior to version 0.10 RC1 ******
    FilterSettingsList filtersList;
    if ( cgGlobal.hasKey("filterConfigurationList") ) {
        kDebug() << "DEPRECATED Filter settings will be restructured for new version";
        QStringList filterConfigurationList =
                cgGlobal.readEntry( "filterConfigurationList", QStringList() );
        for ( int i = filterConfigurationList.count() - 1; i >= 0; --i ) {
            const QString &filterConfiguration = filterConfigurationList[ i ];
            if ( filterConfiguration.isEmpty() ) {
                filterConfigurationList.removeAt( i );
            }
        }

        kDebug() << "Config group list" << cgGlobal.groupList();
        kDebug() << "Filter config list:" << filterConfigurationList;

        // Read old filter settings
        foreach( const QString &filterConfiguration, filterConfigurationList ) {
            FilterSettings filters =
                    readFilterConfig( cgGlobal.group("filterConfig_" + filterConfiguration) );
            filters.name = filterConfiguration;
            filtersList << filters;
        }
开发者ID:janLo,项目名称:PlansmaPublicTransport,代码行数:101,代码来源:settingsio.cpp

示例8: save

void Configuration::save()
{
    KConfigGroup configuration = m_applet->config();
    QStringList arrangement;

    closeActionEditors();

    for (int i = 0; i < m_arrangementUi.currentEntriesListWidget->count(); ++i)
    {
        QListWidgetItem *item = m_arrangementUi.currentEntriesListWidget->item(i);

        if (!item->toolTip().isEmpty())
        {
            if (arrangement.contains(item->toolTip()))
            {
                continue;
            }

            arrangement.append(item->toolTip());

            const KUrl url(item->toolTip());
            Launcher *launcher = new Launcher(url, m_applet);

            if (m_rules.contains(item->toolTip()) && !launcher->isMenu())
            {
                launcher->setRules(m_rules[item->toolTip()].first);
                launcher->setExcluded(m_rules[item->toolTip()].second);
            }

            m_applet->changeLauncher(launcher, url, true);

            launcher->deleteLater();
        }
        else if (item->text() == i18n("--- tasks area ---"))
        {
            arrangement.append("tasks");
        }
        else if (item->text() == i18n("--- jobs area ---"))
        {
            arrangement.append("jobs");
        }
        else
        {
            arrangement.append("separator");
        }
    }

    configuration.deleteGroup("Actions");

    KConfigGroup actionsConfiguration = configuration.group("Actions");

    for (int i = 0; i < m_actionsUi.actionsTableWidget->rowCount(); ++i)
    {
        QTableWidgetItem *actionItem = m_actionsUi.actionsTableWidget->item(i, 0);
        QTableWidgetItem *triggerItem = m_actionsUi.actionsTableWidget->item(i, 1);

        if (triggerItem->data(Qt::EditRole).toString().isEmpty() || actionItem->data(Qt::EditRole).toInt() == 0)
        {
            continue;
        }

        actionsConfiguration.writeEntry(triggerItem->data(Qt::EditRole).toString(), actionItem->data(Qt::EditRole).toInt());
    }

    configuration.writeEntry("moveAnimation", m_appearanceUi.moveAnimation->itemData(m_appearanceUi.moveAnimation->currentIndex()).toInt());
    configuration.writeEntry("parabolicMoveAnimation", m_appearanceUi.parabolicMoveAnimation->isChecked());
    configuration.writeEntry("demandsAttentionAnimation", m_appearanceUi.demandsAttentionAnimation->itemData(m_appearanceUi.demandsAttentionAnimation->currentIndex()).toInt());
    configuration.writeEntry("startupAnimation", m_appearanceUi.startupAnimation->itemData(m_appearanceUi.startupAnimation->currentIndex()).toInt());
    configuration.writeEntry("activeIconIndication", m_appearanceUi.activeIconIndication->itemData(m_appearanceUi.activeIconIndication->currentIndex()).toInt());
    configuration.writeEntry("titleLabelMode", m_appearanceUi.titleLabelMode->itemData(m_appearanceUi.titleLabelMode->currentIndex()).toInt());
    configuration.writeEntry("customBackgroundImage", (m_appearanceUi.customBackgroundImage->url().isValid()?m_appearanceUi.customBackgroundImage->url().path():QString()));
    configuration.writeEntry("showOnlyCurrentDesktop", m_generalUi.showOnlyCurrentDesktop->isChecked());
    configuration.writeEntry("showOnlyCurrentActivity", m_generalUi.showOnlyCurrentActivity->isChecked());
    configuration.writeEntry("showOnlyCurrentScreen", m_generalUi.showOnlyCurrentScreen->isChecked());
    configuration.writeEntry("showOnlyMinimized", m_generalUi.showOnlyMinimized->isChecked());
    configuration.writeEntry("showOnlyTasksWithLaunchers", m_generalUi.showOnlyTasksWithLaunchers->isChecked());
    configuration.writeEntry("connectJobsWithTasks", m_generalUi.connectJobsWithTasks->isChecked());
    configuration.writeEntry("groupJobs", m_generalUi.groupJobs->isChecked());
    configuration.writeEntry("groupingStrategy", m_generalUi.groupingStrategy->itemData(m_generalUi.groupingStrategy->currentIndex()).toInt());
    configuration.writeEntry("sortingStrategy", m_generalUi.sortingStrategy->itemData(m_generalUi.sortingStrategy->currentIndex()).toInt());
    configuration.writeEntry("jobCloseMode", m_generalUi.jobCloseMode->itemData(m_generalUi.jobCloseMode->currentIndex()).toInt());
    configuration.writeEntry("arrangement", arrangement);

    static_cast<KConfigDialog*>(parent())->enableButtonApply(false);

    emit accepted();
}
开发者ID:B-Rich,项目名称:plasmoid-fancy-tasks,代码行数:87,代码来源:Configuration.cpp


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