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


C++ KConfig::entryMap方法代码示例

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


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

示例1: slotLoadProfile

void MainWindow::slotLoadProfile( const QString& id )
{
  const QString path = Kontact::ProfileManager::self()->profileById( id ).saveLocation();
  if ( path.isNull() )
    return;

  KConfig* const cfg = Prefs::self()->config();
  Prefs::self()->writeConfig();
  saveMainWindowSettings( cfg );
  saveSettings();

  const KConfig profile( path+"/kontactrc", /*read-only=*/false, /*useglobals=*/false );
  const QStringList groups = profile.groupList();
  for ( QStringList::ConstIterator it = groups.begin(), end = groups.end(); it != end; ++it )
  {
    cfg->setGroup( *it );
    typedef QMap<QString, QString> StringMap;
    const StringMap entries = profile.entryMap( *it );
    for ( StringMap::ConstIterator it2 = entries.begin(), end = entries.end(); it2 != end; ++it2 )
    {
      if ( it2.data() == "KONTACT_PROFILE_DELETE_KEY" )
        cfg->deleteEntry( it2.key() );
      else
        cfg->writeEntry( it2.key(), it2.data() );
    }
  }

  cfg->sync();
  Prefs::self()->readConfig();
  applyMainWindowSettings( cfg );
  KIconTheme::reconfigure();
  const WId wid = winId();
  KIPC::sendMessage( KIPC::PaletteChanged, wid );
  KIPC::sendMessage( KIPC::FontChanged, wid );
  KIPC::sendMessage( KIPC::StyleChanged, wid );
  KIPC::sendMessage( KIPC::SettingsChanged, wid );
  for ( int i = 0; i < KIcon::LastGroup; ++i )
      KIPC::sendMessage( KIPC::IconChanged, wid, i );

  loadSettings();

  for ( PluginList::Iterator it = mPlugins.begin(); it != mPlugins.end(); ++it ) {
    if ( !(*it)->isRunningStandalone() ) {
        kdDebug() << "Ensure loaded: " << (*it)->identifier() << endl;
        (*it)->part();
    }
    (*it)->loadProfile( path );
  }
}
开发者ID:,项目名称:,代码行数:49,代码来源:

示例2: convertOldPrefs

/******************************************************************************
* If the preferences were written by a previous version of KAlarm, do any
* necessary conversions.
*/
void Preferences::convertOldPrefs()
{
    KConfig *config = KGlobal::config();
    config->setGroup(GENERAL_SECTION);
    int version = KAlarm::getVersionNumber(config->readEntry(VERSION_NUM));
    if(version >= KAlarm::Version(1, 4, 22))
        return;     // config format is up to date

    if(version <= KAlarm::Version(1, 4, 21))
    {
        // Convert KAlarm 1.4.21 preferences
        static const QString OLD_REMIND_UNITS = QString::fromLatin1("DefRemindUnits");
        config->setGroup(DEFAULTS_SECTION);
        int intUnit     = config->readNumEntry(OLD_REMIND_UNITS, 0);
        QString strUnit = (intUnit == 1) ? QString::fromLatin1("Days")
                          : (intUnit == 2) ? QString::fromLatin1("Weeks")
                          :                  QString::fromLatin1("HoursMinutes");
        config->deleteEntry(OLD_REMIND_UNITS);
        config->writeEntry(DEF_REMIND_UNITS, strUnit);
    }

    if(version <= KAlarm::Version(1, 4, 20))
    {
        // Convert KAlarm 1.4.20 preferences
        static const QString VIEW_SECTION = QString::fromLatin1("View");
        static const QString SHOW_ARCHIVED_ALARMS = QString::fromLatin1("ShowArchivedAlarms");
        static const QString SHOW_EXPIRED_ALARMS  = QString::fromLatin1("ShowExpiredAlarms");
        static const QString SHOW_ALARM_TIME      = QString::fromLatin1("ShowAlarmTime");
        static const QString SHOW_TIME_TO_ALARM   = QString::fromLatin1("ShowTimeToAlarm");
        config->setGroup(GENERAL_SECTION);
        bool showExpired = config->readBoolEntry(SHOW_EXPIRED_ALARMS, false);
        bool showTime    = config->readBoolEntry(SHOW_ALARM_TIME, true);
        bool showTimeTo  = config->readBoolEntry(SHOW_TIME_TO_ALARM, false);
        config->deleteEntry(SHOW_EXPIRED_ALARMS);
        config->deleteEntry(SHOW_ALARM_TIME);
        config->deleteEntry(SHOW_TIME_TO_ALARM);
        config->setGroup(VIEW_SECTION);
        config->writeEntry(SHOW_ARCHIVED_ALARMS, showExpired);
        config->writeEntry(SHOW_ALARM_TIME, showTime);
        config->writeEntry(SHOW_TIME_TO_ALARM, showTimeTo);
    }

    if(version <= KAlarm::Version(1, 4, 5))
    {
        // Convert KAlarm 1.4.5 preferences
        static const QString DEF_SOUND = QString::fromLatin1("DefSound");
        config->setGroup(DEFAULTS_SECTION);
        bool sound = config->readBoolEntry(DEF_SOUND, false);
        if(!sound)
            config->writeEntry(DEF_SOUND_TYPE, SoundPicker::NONE);
        config->deleteEntry(DEF_SOUND);
    }

    if(version < KAlarm::Version(1, 3, 0))
    {
        // Convert KAlarm pre-1.3 preferences
        static const QString EMAIL_ADDRESS             = QString::fromLatin1("EmailAddress");
        static const QString EMAIL_USE_CTRL_CENTRE     = QString::fromLatin1("EmailUseControlCenter");
        static const QString EMAIL_BCC_USE_CTRL_CENTRE = QString::fromLatin1("EmailBccUseControlCenter");
        QMap<QString, QString> entries = config->entryMap(GENERAL_SECTION);
        if(entries.find(EMAIL_FROM) == entries.end()
                &&  entries.find(EMAIL_USE_CTRL_CENTRE) != entries.end())
        {
            // Preferences were written by KAlarm pre-1.2.1
            config->setGroup(GENERAL_SECTION);
            bool useCC = false;
            bool bccUseCC = false;
            const bool default_emailUseControlCentre    = true;
            const bool default_emailBccUseControlCentre = true;
            useCC = config->readBoolEntry(EMAIL_USE_CTRL_CENTRE, default_emailUseControlCentre);
            // EmailBccUseControlCenter was missing in preferences written by KAlarm pre-0.9.5
            bccUseCC = config->hasKey(EMAIL_BCC_USE_CTRL_CENTRE)
                       ? config->readBoolEntry(EMAIL_BCC_USE_CTRL_CENTRE, default_emailBccUseControlCentre)
                       : useCC;
            config->writeEntry(EMAIL_FROM, (useCC ? FROM_CONTROL_CENTRE : config->readEntry(EMAIL_ADDRESS)));
            config->writeEntry(EMAIL_BCC_ADDRESS, (bccUseCC ? FROM_CONTROL_CENTRE : config->readEntry(EMAIL_BCC_ADDRESS)));
            config->deleteEntry(EMAIL_ADDRESS);
            config->deleteEntry(EMAIL_BCC_USE_CTRL_CENTRE);
            config->deleteEntry(EMAIL_USE_CTRL_CENTRE);
        }
        // Convert KAlarm 1.2 preferences
        static const QString DEF_CMD_XTERM = QString::fromLatin1("DefCmdXterm");
        config->setGroup(DEFAULTS_SECTION);
        if(config->hasKey(DEF_CMD_XTERM))
        {
            config->writeEntry(DEF_CMD_LOG_TYPE,
                               (config->readBoolEntry(DEF_CMD_XTERM, false) ? EditAlarmDlg::EXEC_IN_TERMINAL : EditAlarmDlg::DISCARD_OUTPUT));
            config->deleteEntry(DEF_CMD_XTERM);
        }
    }
    config->setGroup(GENERAL_SECTION);
    config->writeEntry(VERSION_NUM, KALARM_VERSION);
    config->sync();
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:98,代码来源:preferences.cpp

示例3: doTests

void doTests() {
    // the data file to use.
    // first determine the path used to call this program,
    // and then prepend that to the data file name.
    QString path = myName.section('/', 0, -3);
    QString datafile = path;
    datafile.append("/healpix_example_sm.fits");

    // create a temporary config file to use
    QString cfgfile = "testhealpix.temp";
    KConfig *cfg = new KConfig(cfgfile, false, false);
    cfg->setGroup("Healpix General");
    cfg->setGroup(datafile);
    cfg->writeEntry("Matrix X Dimension", XDIM);
    cfg->writeEntry("Matrix Y Dimension", YDIM);
    cfg->writeEntry("Theta Autoscale", true);
    cfg->writeEntry("Theta Units", 0);
    cfg->writeEntry("Theta Min", 0.0);
    cfg->writeEntry("Theta Max", 1.0);
    cfg->writeEntry("Phi Autoscale", true);
    cfg->writeEntry("Phi Units", 0);
    cfg->writeEntry("Phi Min", 0.0);
    cfg->writeEntry("Phi Max", 1.0);
    cfg->writeEntry("Vector Theta", 1);
    cfg->writeEntry("Vector Phi", 2);
    cfg->writeEntry("Vector Degrade Factor", DEGRADE);
    cfg->writeEntry("Vector Magnitude Autoscale", true);
    cfg->writeEntry("Vector Max Magnitude", 1.0);
    cfg->writeEntry("Vector is QU", true);

    // use the C functions to test for healpix support
    int verstehen = understands_healpix(cfg, datafile);
    if (verstehen) {
        kstdDebug() << "Data file " << datafile << " is supported" << endl;
        QString suggestion;
        bool complete;

        QStringList matrices = matrixList_healpix(cfg, datafile, "HEALPIX", &suggestion, &complete);
        kstdDebug() << "Available matrices are:" << endl;
        for ( QStringList::Iterator it = matrices.begin(); it != matrices.end(); ++it ) {
            kstdDebug() << "  " << *it << endl;
        }
        kstdDebug() << "  suggestion = " << suggestion << endl;
        kstdDebug() << "  complete = " << complete << endl;

        QStringList fields = fieldList_healpix(cfg, datafile, "HEALPIX", &suggestion, &complete);
        kstdDebug() << "Available fields are:" << endl;
        for ( QStringList::Iterator it = fields.begin(); it != fields.end(); ++it ) {
            kstdDebug() << "  " << *it << endl;
        }
        kstdDebug() << "  suggestion = " << suggestion << endl;
        kstdDebug() << "  complete = " << complete << endl;

        // actually create HealpixSource
        HealpixSource *hpx = new HealpixSource(cfg, datafile, "HEALPIX");

        // test that saveConfig produces the same as the
        // original input configuration
        QString cfgfile2 = "testhealpix.temp2";
        KConfig *chk = new KConfig(cfgfile2, false, false);
        hpx->saveConfig(chk);
        StringMap cfgmap = cfg->entryMap(datafile);
        StringMap chkmap = chk->entryMap(datafile);

        /*
        kstdDebug() << cfgmap["Matrix X Dimension"] << " " << chkmap["Matrix X Dimension"] << endl;
        kstdDebug() << cfgmap["Matrix Y Dimension"] << " " << chkmap["Matrix Y Dimension"] << endl;
        kstdDebug() << cfgmap["Theta Autoscale"] << " " << chkmap["Theta Autoscale"] << endl;
        kstdDebug() << cfgmap["Theta Units"] << " " << chkmap["Theta Units"] << endl;
        kstdDebug() << cfgmap["Theta Min"] << " " << chkmap["Theta Min"] << endl;
        kstdDebug() << cfgmap["Theta Max"] << " " << chkmap["Theta Max"] << endl;
        kstdDebug() << cfgmap["Phi Autoscale"] << " " << chkmap["Phi Autoscale"] << endl;
        kstdDebug() << cfgmap["Phi Units"] << " " << chkmap["Phi Units"] << endl;
        kstdDebug() << cfgmap["Phi Min"] << " " << chkmap["Phi Min"] << endl;
        kstdDebug() << cfgmap["Phi Max"] << " " << chkmap["Phi Max"] << endl;
        kstdDebug() << cfgmap["Vector Theta"] << " " << chkmap["Vector Theta"] << endl;
        kstdDebug() << cfgmap["Vector Phi"] << " " << chkmap["Vector Phi"] << endl;
        kstdDebug() << cfgmap["Vector Degrade Factor"] << " " << chkmap["Vector Degrade Factor"] << endl;
        kstdDebug() << cfgmap["Vector Magnitude Autoscale"] << " " << chkmap["Vector Magnitude Autoscale"] << endl;
        kstdDebug() << cfgmap["Vector Max Magnitude"] << " " << chkmap["Vector Max Magnitude"] << endl;
        kstdDebug() << cfgmap["Vector is QU"] << " " << chkmap["Vector is QU"] << endl;
        */

        if (cfgmap["Matrix X Dimension"] != chkmap["Matrix X Dimension"]) {
            QString msg = "Matrix X Dimension integrity";
            testAssert(false, msg);
        }
        if (cfgmap["Matrix Y Dimension"] != chkmap["Matrix Y Dimension"]) {
            QString msg = "Matrix Y Dimension integrity";
            testAssert(false, msg);
        }
        if (cfgmap["Theta Autoscale"] != chkmap["Theta Autoscale"]) {
            QString msg = "Theta Autoscale integrity";
            testAssert(false, msg);
        }
        if (cfgmap["Theta Units"] != chkmap["Theta Units"]) {
            QString msg = "Theta Units integrity";
            testAssert(false, msg);
        }
        if (cfgmap["Theta Min"] != chkmap["Theta Min"]) {
//.........这里部分代码省略.........
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:101,代码来源:testhealpix.cpp


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