void Containment::restore(KConfigGroup &group)
{
    /*
    #ifndef NDEBUG
    // qDebug() << "!!!!!!!!!!!!initConstraints" << group.name() << d->type;
    // qDebug() << "    location:" << group.readEntry("location", (int)d->location);
    // qDebug() << "    geom:" << group.readEntry("geometry", geometry());
    // qDebug() << "    formfactor:" << group.readEntry("formfactor", (int)d->formFactor);
    // qDebug() << "    screen:" << group.readEntry("screen", d->screen);
    #endif
    */
    setLocation((Plasma::Types::Location)group.readEntry("location", (int)d->location));
    setFormFactor((Plasma::Types::FormFactor)group.readEntry("formfactor", (int)d->formFactor));
    d->lastScreen = group.readEntry("lastScreen", d->lastScreen);

    setWallpaper(group.readEntry("wallpaperplugin", ContainmentPrivate::defaultWallpaper));

    d->activityId = group.readEntry("activityId", QString());

    flushPendingConstraintsEvents();
    restoreContents(group);
    setImmutability((Types::ImmutabilityType)group.readEntry("immutability", (int)Types::Mutable));

    if (isContainment()) {
        KConfigGroup cfg = KConfigGroup(corona()->config(), "ActionPlugins");
        cfg = KConfigGroup(&cfg, QString::number(containmentType()));

        //qDebug() << cfg.keyList();
        if (cfg.exists()) {
            foreach (const QString &key, cfg.keyList()) {
                //qDebug() << "loading" << key;
                setContainmentActions(key, cfg.readEntry(key, QString()));
            }
        } else { //shell defaults
Example #2
0
ControlModules::ControlModules()
{
    const KConfigGroup config = KGlobal::config()->group("mangonel_controlmodules");
    
    foreach(const QString &key, config.keyList()) {
        QList<QVariant> values = config.readEntry<QList<QVariant> >(key, QList<QVariant>());
        popularity pop;
        pop.count = values[0].toInt();
        pop.lastUse = values[1].toInt();
        m_popularities.insert(key, pop);
    }
}
Example #3
0
void KonfUpdate::copyOrMoveGroup(const QStringList &srcGroupPath, const QStringList &dstGroupPath)
{
    KConfigGroup cg = KConfigUtils::openGroup(m_oldConfig1, srcGroupPath);

    // Keys
    Q_FOREACH(const QString &key, cg.keyList()) {
        copyOrMoveKey(srcGroupPath, key, dstGroupPath, key);
    }

    // Subgroups
    Q_FOREACH(const QString &group, cg.groupList()) {
        QStringList groupPath = QStringList() << group;
        copyOrMoveGroup(srcGroupPath + groupPath, dstGroupPath + groupPath);
    }
}
Example #4
0
QMap<QString, QVariant> Service::parametersFromDescription(const KConfigGroup &description)
{
    QMap<QString, QVariant> params;

    if (!d->config || !description.isValid()) {
        return params;
    }

    const QString op = description.name();
    foreach (const QString &key, description.keyList()) {
        KConfigSkeletonItem *item = d->config->findItem(op, key);
        if (item) {
            params.insert(key, description.readEntry(key, item->property()));
        }
    }

    return params;
}
Example #5
0
void UserAgentDlg::save()
{
    Q_ASSERT (m_config);

    // Put all the groups except the default into the delete list.
    QStringList deleteList = m_config->groupList();

    //Remove all the groups that DO NOT contain a "UserAgent" entry...
    QStringList::ConstIterator endIt = deleteList.constEnd();
    for (QStringList::ConstIterator it = deleteList.constBegin(); it != endIt; ++it) {
        if ( (*it) == QLatin1String ("<default>"))
            continue;

        KConfigGroup cg (m_config, *it);
        if (!cg.hasKey ("UserAgent"))
            deleteList.removeAll (*it);
    }

    QString domain;
    QTreeWidgetItem* item;
    int itemCount = ui.sitePolicyTreeWidget->topLevelItemCount();

    // Save and remove from the delete list all the groups that were
    // not deleted by the end user.
    for (int i = 0; i < itemCount; i++) {
        item = ui.sitePolicyTreeWidget->topLevelItem (i);
        domain = item->text (0);
        KConfigGroup cg (m_config, domain);
        cg.writeEntry ("UserAgent", item->text (2));
        deleteList.removeAll (domain);
        qDebug ("UserAgentDlg::save: Removed [%s] from delete list", domain.toLatin1().constData());
    }

    // Write the global configuration information...
    KConfigGroup cg (m_config, QString());
    cg.writeEntry ("SendUserAgent", ui.sendUACheckBox->isChecked());
    cg.writeEntry ("UserAgentKeys", m_ua_keys);

    // Sync up all the changes so far...
    m_config->sync();

    // If delete list is not empty, delete the specified domains.
    if (!deleteList.isEmpty()) {
        // Remove entries from local file.
        endIt = deleteList.constEnd();
        KConfig cfg (QStringLiteral("kio_httprc"), KConfig::SimpleConfig);

        for (QStringList::ConstIterator it = deleteList.constBegin(); it != endIt; ++it) {
            KConfigGroup cg (&cfg, *it);
            cg.deleteEntry ("UserAgent");
            qDebug ("UserAgentDlg::save: Deleting UserAgent of group [%s]", (*it).toLatin1().constData());
            if (cg.keyList().count() < 1)
                cg.deleteGroup();
        }

        // Sync up the configuration...
        cfg.sync();

        // Check everything is gone, reset to blank otherwise.
        m_config->reparseConfiguration();
        endIt = deleteList.constEnd();
        for (QStringList::ConstIterator it = deleteList.constBegin(); it != endIt; ++it) {
            KConfigGroup cg (m_config, *it);
            if (cg.hasKey ("UserAgent"))
                cg.writeEntry ("UserAgent", QString());
        }

        // Sync up the configuration...
        m_config->sync();
    }

    KSaveIOConfig::updateRunningIOSlaves (this);
    configChanged (false);
}
Example #6
0
void SettingsCore::loadSettings()
{
#ifdef ABAKUS_QTONLY
    //TODO
#else
    KConfigGroup config = KGlobal::config()->group("Settings");
    
    QString mode = config.readEntry("Trigonometric mode", "Degrees");
    if(mode == "Degrees") {
        setTrigMode(Abakus::Degrees);
    }
    else {
        setTrigMode(Abakus::Radians);
    }
    
    int precision = config.readEntry("Decimal Precision", -1);
    if(precision < -1 || precision > 75)
    {
        precision = -1;
    }
    
    Abakus::m_prec = precision;
    
    m_historyLimit = config.readEntry("History Limit", 500);
    
    
    config = KGlobal::config()->group("GUI");
    
    m_mathematicalSidebarVisible = config.readEntry("ShowMathematicalSidebar", true);
    m_mathematicalSidebarActiveView = config.readEntry("MathematicalSidebarActiveTab", "numerals");
    m_mathematicalSidebarWidth = config.readEntry("MathematicalSidebarWidth", 200);
    
    m_compactMode = config.readEntry("InCompactMode", false);
    
    m_windowSize = config.readEntry("Size", QSize(600, 220));
    
    
    config = KGlobal::config()->group("Variables");
    QStringList variableKeys = config.keyList();
    QStringList variableValues;
    Abakus::Number number;
    
    for(int i = 0; i < variableKeys.count(); ++i)
    {
        variableValues = config.readEntry(variableKeys[i], QStringList());
        if(variableValues.count() < 3) continue;
        
        number = Abakus::Number(variableValues[1].toLatin1());
        number.setNumeralSystem((Abakus::NumeralSystem) variableValues[2].toInt());
        
        NumeralModel::instance()->setValue(variableValues[0], number);
    }
    
    
    config = KGlobal::config()->group("Functions");
    QStringList functionKeys = config.keyList();
    QString functionValue;
    
    for(int i = 0; i < functionKeys.count(); ++i)
    {
        functionValue = config.readEntry(functionKeys[i], QString());
        if(functionValue.isEmpty()) continue;
                                      
        QByteArray strValue = "set " + functionValue.toLatin1();
        parseString(strValue.data()); // Run the function definitions through the parser
    }
    
    
    config = KGlobal::config()->group("History");
    QStringList historyKeys = config.keyList();
    QStringList historyValues;
    ResultModel* resultModel = ResultModel::instance();
    ResultModelItem* resultModelItem;
    
    for(int i = historyKeys.count() - 1; i >= 0; --i)
    {
        historyValues = config.readEntry(historyKeys[i], QStringList());
        if(historyValues.count() < 1) continue;
        
        if(historyValues[0].toInt() == ResultModelItem::Result)
        {
            if(historyValues.count() < 4) continue;
            number = Abakus::Number(historyValues[2].toLatin1());
            number.setNumeralSystem((Abakus::NumeralSystem) historyValues[3].toInt());
            resultModelItem = new ResultModelItem(historyValues[1], number);
        }
        else
        {
            if(historyValues.count() < 3) continue;
            resultModelItem = new ResultModelItem(historyValues[1], historyValues[2]);
        }
        resultModel->addResultModelItem(resultModelItem);
    }
    
    m_actionCollection->readSettings();
#endif
}
CSVTemplate::CSVTemplate(KConfigBase* config) : m_columns(0)
{
    if (config == 0) return;

    KConfigGroup columnMap = config->group("csv column map");
    const QStringList keyList = columnMap.keyList();

    QStringList::const_iterator it    = keyList.begin();
    QStringList::const_iterator endIt = keyList.end();
    for (; it != endIt; ++it)
    {
        if ((*it).isEmpty()) continue;

        bool ok = false;
        int column = (*it).toInt(&ok);
        if (!ok) continue;

        int field = columnMap.readEntry(*it, -1);
        if (field < 0) continue;

        m_columnToField.insert(column, field);
    }

    KConfigGroup general = config->group("General");

    m_datePattern = general.readEntry("DatePattern");
    if (m_datePattern.isEmpty()) m_datePattern = "Y-M-D";
    createDateFormat();

    m_columns = general.readEntry("Columns", 0);
    if (m_columns < 0) m_columns = 0;

    switch (general.readEntry("DelimiterType", 0))
    {
        case 1:
            m_delimiter = ";";
            break;

        case 2:
            m_delimiter = "\t";
            break;

        case 3:
            m_delimiter = " ";
            break;

        case 4:
            m_delimiter = general.readEntry("DelimiterOther");
            break;

        default:
            m_delimiter = ",";
    }
    if (m_delimiter.isEmpty()) m_delimiter = ",";

    switch (general.readEntry("QuoteType", 0))
    {
        case 1:
            m_quote = "'";
            break;

        case 2:
            break;

        default:
            m_quote = "\"";
            break;
    }
}