本文整理汇总了C++中KConfig::groupList方法的典型用法代码示例。如果您正苦于以下问题:C++ KConfig::groupList方法的具体用法?C++ KConfig::groupList怎么用?C++ KConfig::groupList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KConfig
的用法示例。
在下文中一共展示了KConfig::groupList方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setUserWhoField
void KMFolder::setUserWhoField( const QString& whoField, bool writeConfig )
{
if ( mUserWhoField == whoField && !whoField.isEmpty() )
return;
if ( whoField.isEmpty() )
{
// default setting
const KPIMIdentities::Identity & identity =
kmkernel->identityManager()->identityForUoidOrDefault( mIdentity );
QString identityfcc, identitydrafts, identitytemplates;
{
/* KPIMIdentities::Identity::fcc(), KPIMIdentities::Identity::drafts() and KPIMIdentities::Identity::templates()
using akonadi, so read values from config file directly */
const KConfig config( "emailidentities" );
const QStringList identities = config.groupList().filter( QRegExp( "^Identity #\\d+$" ) );
for ( QStringList::const_iterator group = identities.constBegin(); group != identities.constEnd(); ++group ) {
const KConfigGroup configGroup( &config, *group );
if ( configGroup.readEntry( "uoid", 0U ) == identity.uoid() ) {
identityfcc = configGroup.readEntry( "Fcc2", QString() );
identitydrafts = configGroup.readEntry( "Drafts2", QString() );
identitytemplates = configGroup.readEntry( "Templates2", QString() );
break;
}
}
}
if ( isSystemFolder() && folderType() != KMFolderTypeImap ) {
// local system folders
if ( this == kmkernel->inboxFolder() ||
this == kmkernel->trashFolder() )
mWhoField = "From";
if ( this == kmkernel->outboxFolder() ||
this == kmkernel->sentFolder() ||
this == kmkernel->templatesFolder() ||
this == kmkernel->draftsFolder() )
mWhoField = "To";
} else if ( identitydrafts == idString() ||
identitytemplates == idString() ||
identityfcc == idString() )
// drafts, templates or sent of the identity
mWhoField = "To";
else
mWhoField = "From";
} else if ( whoField == "From" || whoField == "To" )
// set the whoField according to the user-setting
mWhoField = whoField;
else {
// this should not happen...
kDebug() << "Illegal setting" << whoField << "for userWhoField!";
return; // don't use the value
}
mUserWhoField = whoField;
if ( writeConfig ) {
mStorage->writeConfig();
emit viewConfigChanged();
}
}
示例2: readConfig
/******************************************************************************
* Read the configuration file.
* Create the client list and open all calendar files.
*/
void ADConfigData::readConfig()
{
kdDebug(5900) << "ADConfigData::readConfig()" << endl;
ClientInfo::clear();
KConfig *config = KGlobal::config();
QStringList clients = config->groupList().grep(CLIENT_GROUP_SEARCH);
for(QStringList::Iterator cl = clients.begin(); cl != clients.end(); ++cl)
{
// Read this client's configuration
config->setGroup(*cl);
QString client = *cl;
client.remove(CLIENT_GROUP_SEARCH);
QString title = config->readEntry(TITLE_KEY, client); // read app title (default = app name)
QCString dcopObject = config->readEntry(DCOP_OBJECT_KEY).local8Bit();
bool startClient = config->readBoolEntry(START_CLIENT_KEY, false);
QString calendar = config->readPathEntry(CALENDAR_KEY);
// Verify the configuration
bool ok = false;
if(client.isEmpty() || KStandardDirs::findExe(client).isNull())
kdError(5900) << "ADConfigData::readConfig(): group '" << *cl << "' deleted (client app not found)\n";
else if(calendar.isEmpty())
kdError(5900) << "ADConfigData::readConfig(): no calendar specified for '" << client << "'\n";
else if(dcopObject.isEmpty())
kdError(5900) << "ADConfigData::readConfig(): no DCOP object specified for '" << client << "'\n";
else
{
ADCalendar *cal = ADCalendar::getCalendar(calendar);
if(cal)
kdError(5900) << "ADConfigData::readConfig(): calendar registered by multiple clients: " << calendar << endl;
else
ok = true;
}
if(!ok)
{
config->deleteGroup(*cl, true);
continue;
}
// Create the client and calendar objects
new ClientInfo(client.local8Bit(), title, dcopObject, calendar, startClient);
kdDebug(5900) << "ADConfigData::readConfig(): client " << client << " : calendar " << calendar << endl;
}
// Remove obsolete CheckInterval entry (if it exists)
config->setGroup("General");
config->deleteEntry("CheckInterval");
// Save any updates
config->sync();
}
示例3: 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 );
}
}
示例4: gotAllGroups
void KonfUpdate::gotAllGroups()
{
if (!m_oldConfig1) {
logFileError() << "AllGroups without previous File specification" << endl;
return;
}
const QStringList allGroups = m_oldConfig1->groupList();
for (QStringList::ConstIterator it = allGroups.begin();
it != allGroups.end(); ++it) {
m_oldGroup = QStringList() << *it;
m_newGroup = m_oldGroup;
gotAllKeys();
}
}
示例5: read_settings
bool Settings::read_settings(KConfig &cfg_P, bool include_disabled_P, ImportType import_P)
{
if(actions == NULL)
actions = new Action_data_group(NULL, "should never see", "should never see", NULL, Action_data_group::SYSTEM_ROOT, true);
if(cfg_P.groupList().count() == 0) // empty
return false;
cfg_P.setGroup("Main"); // main group
if(import_P == ImportNone) // reading main cfg file
already_imported = cfg_P.readListEntry("AlreadyImported");
else
{
QString import_id = cfg_P.readEntry("ImportId");
if(!import_id.isEmpty())
{
if(already_imported.contains(import_id))
{
if(import_P == ImportSilent
|| KMessageBox::warningContinueCancel(NULL, i18n("This \"actions\" file has already been imported before. "
"Are you sure you want to import it again?"))
!= KMessageBox::Continue)
return true; // import "successful"
}
else
already_imported.append(import_id);
}
else
{
if(import_P != ImportSilent
&& KMessageBox::warningContinueCancel(NULL, i18n("This \"actions\" file has no ImportId field and therefore it cannot be determined "
"whether or not it has been imported already. Are you sure you want to import it?"))
== KMessageBox::Cancel)
return true;
}
}
int version = cfg_P.readNumEntry("Version", -1234576);
switch(version)
{
case 1:
read_settings_v1(cfg_P);
break;
case 2:
read_settings_v2(cfg_P, include_disabled_P);
break;
default:
kdWarning(1217) << "Unknown cfg. file version\n";
return false;
case -1234576: // no config file
if(import_P) // if importing, this is an error
return false;
break;
}
if(import_P != ImportNone)
return true; // don't read global settings
cfg_P.setGroup("Main"); // main group
daemon_disabled = cfg_P.readBoolEntry("Disabled", false);
cfg_P.setGroup("Gestures");
gestures_disabled_globally = cfg_P.readBoolEntry("Disabled", true);
gesture_mouse_button = cfg_P.readNumEntry("MouseButton", 2);
gesture_mouse_button = KCLAMP(gesture_mouse_button, 2, 9);
gesture_timeout = cfg_P.readNumEntry("Timeout", 300);
cfg_P.setGroup("GesturesExclude");
delete gestures_exclude;
gestures_exclude = new Windowdef_list(cfg_P);
cfg_P.setGroup("Voice");
voice_shortcut = KShortcut(cfg_P.readEntry("Shortcut", ""));
return true;
}
示例6: update
//
// read the types from config file and update the internal list
//
void KateModeManager::update ()
{
KConfig config ("katemoderc", KConfig::NoGlobals);
QStringList g (config.groupList());
qDeleteAll (m_types);
m_types.clear ();
m_name2Type.clear ();
for (int z=0; z < g.count(); z++)
{
KConfigGroup cg(&config, g[z]);
KateFileType *type = new KateFileType ();
type->number = z;
type->name = g[z];
type->section = cg.readEntry ("Section");
type->wildcards = cg.readXdgListEntry ("Wildcards");
type->mimetypes = cg.readXdgListEntry ("Mimetypes");
type->priority = cg.readEntry ("Priority", 0);
type->varLine = cg.readEntry ("Variables");
type->indenter = cg.readEntry ("Indenter");
type->hl = cg.readEntry ("Highlighting");
// only for generated types...
type->hlGenerated = cg.readEntry ("Highlighting Generated", false);
type->version = cg.readEntry ("Highlighting Version");
// insert into the list + hash...
m_types.append(type);
m_name2Type.insert (type->name, type);
}
// try if the hl stuff is up to date...
const KateSyntaxModeList &modes = KateHlManager::self()->syntaxDocument()->modeList();
for (int i = 0; i < modes.size(); ++i)
{
KateFileType *type = 0;
bool newType = false;
if (m_name2Type.contains (modes[i]->name))
type = m_name2Type[modes[i]->name];
else
{
newType = true;
type = new KateFileType ();
type->name = modes[i]->name;
type->priority = 0;
m_types.append (type);
m_name2Type.insert (type->name, type);
}
if (newType || type->version != modes[i]->version)
{
type->name = modes[i]->name;
type->section = modes[i]->section;
type->wildcards = modes[i]->extension.split (';', QString::SkipEmptyParts);
type->mimetypes = modes[i]->mimetype.split (';', QString::SkipEmptyParts);
type->priority = modes[i]->priority.toInt();
type->version = modes[i]->version;
type->indenter = modes[i]->indenter;
type->hl = modes[i]->name;
type->hlGenerated = true;
}
}
// sort the list...
QList<KateFileType *> newList;
for (int i=0; i < m_types.count(); i++)
{
KateFileType *t = m_types[i];
int insert = 0;
for (; insert <= newList.count(); insert++)
{
if (insert == newList.count())
break;
if ( QString(newList.at(insert)->section + newList.at(insert)->name).toLower()
> QString(t->section + t->name).toLower() )
break;
}
newList.insert (insert, t);
}
// replace old list with new sorted list...
m_types = newList;
// add the none type...
KateFileType *t = new KateFileType ();
// DO NOT TRANSLATE THIS, DONE LATER, marked by hlGenerated
t->name = "Normal";
t->hl = "None";
t->hlGenerated = true;
//.........这里部分代码省略.........
示例7: gotScript
void KonfUpdate::gotScript(const QString &_script)
{
QString script, interpreter;
int i = _script.indexOf(',');
if (i == -1) {
script = _script.trimmed();
} else {
script = _script.left(i).trimmed();
interpreter = _script.mid(i + 1).trimmed();
}
if (script.isEmpty()) {
logFileError() << "Script fails to specify filename";
m_skip = true;
return;
}
QString path = KStandardDirs::locate("data", "kconf_update/" + script);
if (path.isEmpty()) {
if (interpreter.isEmpty()) {
path = KStandardDirs::locate("lib", "kconf_update_bin/" + script);
}
if (path.isEmpty()) {
logFileError() << "Script '" << script << "' not found" << endl;
m_skip = true;
return;
}
}
if (!m_arguments.isNull()) {
log() << m_currentFilename << ": Running script '" << script << "' with arguments '" << m_arguments << "'" << endl;
} else {
log() << m_currentFilename << ": Running script '" << script << "'" << endl;
}
QString cmd;
if (interpreter.isEmpty()) {
cmd = path;
} else {
cmd = interpreter + ' ' + path;
}
if (!m_arguments.isNull()) {
cmd += ' ';
cmd += m_arguments;
}
KTemporaryFile scriptIn;
scriptIn.open();
KTemporaryFile scriptOut;
scriptOut.open();
KTemporaryFile scriptErr;
scriptErr.open();
int result;
if (m_oldConfig1) {
if (m_debug) {
scriptIn.setAutoRemove(false);
log() << "Script input stored in " << scriptIn.fileName() << endl;
}
KConfig cfg(scriptIn.fileName(), KConfig::SimpleConfig);
if (m_oldGroup.isEmpty()) {
// Write all entries to tmpFile;
const QStringList grpList = m_oldConfig1->groupList();
for (QStringList::ConstIterator it = grpList.begin();
it != grpList.end();
++it) {
copyGroup(m_oldConfig1, *it, &cfg, *it);
}
} else {
KConfigGroup cg1 = KConfigUtils::openGroup(m_oldConfig1, m_oldGroup);
KConfigGroup cg2(&cfg, QString());
copyGroup(cg1, cg2);
}
cfg.sync();
#ifndef _WIN32_WCE
result = system(QFile::encodeName(QString("%1 < %2 > %3 2> %4").arg(cmd, scriptIn.fileName(), scriptOut.fileName(), scriptErr.fileName())));
#else
QString path_ = QDir::convertSeparators ( QFileInfo ( cmd ).absoluteFilePath() );
QString file_ = QFileInfo ( cmd ).fileName();
SHELLEXECUTEINFO execInfo;
memset ( &execInfo,0,sizeof ( execInfo ) );
execInfo.cbSize = sizeof ( execInfo );
execInfo.fMask = SEE_MASK_FLAG_NO_UI;
execInfo.lpVerb = L"open";
execInfo.lpFile = (LPCWSTR) path_.utf16();
execInfo.lpDirectory = (LPCWSTR) file_.utf16();
execInfo.lpParameters = (LPCWSTR) QString(" < %1 > %2 2> %3").arg( scriptIn.fileName(), scriptOut.fileName(), scriptErr.fileName()).utf16();
result = ShellExecuteEx ( &execInfo );
if (result != 0)
{
result = 0;
}
else
{
//.........这里部分代码省略.........
示例8: gotFile
void KonfUpdate::gotFile(const QString &_file)
{
// Reset group
gotGroup(QString());
if (!m_oldFile.isEmpty()) {
// Close old file.
delete m_oldConfig1;
m_oldConfig1 = 0;
KConfigGroup cg(m_oldConfig2, "$Version");
QStringList ids = cg.readEntry("update_info", QStringList());
QString cfg_id = m_currentFilename + ':' + m_id;
if (!ids.contains(cfg_id) && !m_skip) {
ids.append(cfg_id);
cg.writeEntry("update_info", ids);
}
cg.sync();
delete m_oldConfig2;
m_oldConfig2 = 0;
QString file = KStandardDirs::locateLocal("config", m_oldFile);
KDE_struct_stat s_buf;
if (KDE::stat(file, &s_buf) == 0) {
if (s_buf.st_size == 0) {
// Delete empty file.
QFile::remove(file);
}
}
m_oldFile.clear();
}
if (!m_newFile.isEmpty()) {
// Close new file.
KConfigGroup cg(m_newConfig, "$Version");
QStringList ids = cg.readEntry("update_info", QStringList());
QString cfg_id = m_currentFilename + ':' + m_id;
if (!ids.contains(cfg_id) && !m_skip) {
ids.append(cfg_id);
cg.writeEntry("update_info", ids);
}
m_newConfig->sync();
delete m_newConfig;
m_newConfig = 0;
m_newFile.clear();
}
m_newConfig = 0;
int i = _file.indexOf(',');
if (i == -1) {
m_oldFile = _file.trimmed();
} else {
m_oldFile = _file.left(i).trimmed();
m_newFile = _file.mid(i + 1).trimmed();
if (m_oldFile == m_newFile) {
m_newFile.clear();
}
}
if (!m_oldFile.isEmpty()) {
m_oldConfig2 = new KConfig(m_oldFile, KConfig::NoGlobals);
QString cfg_id = m_currentFilename + ':' + m_id;
KConfigGroup cg(m_oldConfig2, "$Version");
QStringList ids = cg.readEntry("update_info", QStringList());
if (ids.contains(cfg_id)) {
m_skip = true;
m_newFile.clear();
log() << m_currentFilename << ": Skipping update '" << m_id << "'" << endl;
}
if (!m_newFile.isEmpty()) {
m_newConfig = new KConfig(m_newFile, KConfig::NoGlobals);
KConfigGroup cg(m_newConfig, "$Version");
ids = cg.readEntry("update_info", QStringList());
if (ids.contains(cfg_id)) {
m_skip = true;
log() << m_currentFilename << ": Skipping update '" << m_id << "'" << endl;
}
} else {
m_newConfig = m_oldConfig2;
}
m_oldConfig1 = new KConfig(m_oldFile, KConfig::NoGlobals);
} else {
m_newFile.clear();
}
m_newFileName = m_newFile;
if (m_newFileName.isEmpty()) {
m_newFileName = m_oldFile;
}
m_skipFile = false;
if (!m_oldFile.isEmpty()) { // if File= is specified, it doesn't exist, is empty or contains only kconf_update's [$Version] group, skip
if (m_oldConfig1 != NULL
&& (m_oldConfig1->groupList().isEmpty()
|| (m_oldConfig1->groupList().count() == 1 && m_oldConfig1->groupList().first() == "$Version"))) {
log() << m_currentFilename << ": File '" << m_oldFile << "' does not exist or empty, skipping" << endl;
m_skipFile = true;
}
//.........这里部分代码省略.........