[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: [PATCH] Re: kconf_update
From: Waldo Bastian <bastian () kde ! org>
Date: 2002-03-10 6:11:47
[Download RAW message or body]
On Saturday 09 March 2002 06:00 am, Frerich Raabe wrote:
> On Saturday 09 March 2002 01:45, you wrote:
> > On Friday 08 March 2002 02:47 pm, Frerich Raabe wrote:
> > > is there any elegant possibility to just rename a configuration file
> > > when employing .upd files? The recent changes to Kicker applets
> > > (especially how their configuration files are called, fooappletrc
> > > changed into foo_appletrc) make it necessary for me to adjust
> > > KNewsTicker's .upd file accordingly, but right now I see no nice way to
> > > do that (other than to use a dummy script which just outputs the data
> > > it got piped).
> >
> > You basically would like a "AllGroups" command just like there is
> > "AllKeys" currently? I can add that.
>
> That'd work just as well, yes. I'd really appreciate it if you could add
> support for that command. :-)
Here you go. Please review. I also added code that checks whether the old file
is empty afterwards and deletes the file if that is the case.
Cheers,
Waldo
--
Advanced technology only happens when people take a basic idea and add to it.
-- Bob Bemer
["kconf_update.diff" (text/x-diff)]
Index: README.kconf_update
===================================================================
RCS file: /home/kde/kdelibs/kconf_update/README.kconf_update,v
retrieving revision 1.6
diff -u -p -r1.6 README.kconf_update
--- README.kconf_update 2001/07/16 02:14:18 1.6
+++ README.kconf_update 2002/03/10 06:09:25
@@ -123,6 +123,11 @@ AllKeys
Specifies that all configuration information in the selected group should
be moved (All keys).
+AllGroups
+
+Specifies that all configuration information from all keys in ALL
+groups should be moved.
+
RemoveKey=<oldkey>
Index: kconf_update.cpp
===================================================================
RCS file: /home/kde/kdelibs/kconf_update/kconf_update.cpp,v
retrieving revision 1.8
diff -u -p -r1.8 kconf_update.cpp
--- kconf_update.cpp 2001/10/10 17:40:37 1.8
+++ kconf_update.cpp 2002/03/10 06:09:25
@@ -58,6 +58,7 @@ public:
void gotKey(const QString &_key);
void gotRemoveKey(const QString &_key);
void gotAllKeys();
+ void gotAllGroups();
void gotOptions(const QString &_options);
void gotScript(const QString &_script);
void resetOptions();
@@ -115,7 +116,6 @@ KonfUpdate::KonfUpdate()
++it)
{
QString file = *it;
-qWarning("File = %s", file.latin1());
updateFile(file);
}
}
@@ -153,6 +153,7 @@ QStringList KonfUpdate::findDirtyUpdateF
* # Comment
* Id=id
* File=oldfile[,newfile]
+ * AllGroups
* Group=oldgroup[,newgroup]
* RemoveGroup=oldgroup
* Options=[copy,][overwrite,]
@@ -221,6 +222,11 @@ bool KonfUpdate::updateFile(const QStrin
gotAllKeys();
resetOptions();
}
+ else if (line == "AllGroups")
+ {
+ gotAllGroups();
+ resetOptions();
+ }
else
qWarning("%s:%d parse error '%s'", filename.latin1(), lineCount, line.latin1());
}
@@ -257,7 +263,6 @@ void KonfUpdate::gotId(const QString &_i
if (ids.contains(_id))
{
skip = true;
-qWarning("Skipping '%s'", _id.latin1());
return;
}
skip = false;
@@ -278,6 +283,17 @@ void KonfUpdate::gotFile(const QString &
oldConfig2->sync();
delete oldConfig2;
oldConfig2 = 0;
+
+ QString file = locateLocal("config", oldFile);
+ struct stat s_buf;
+ if (stat(QFile::encodeName(file), &s_buf) == 0)
+ {
+ if (s_buf.st_size == 0)
+ {
+ // Delete empty file.
+ unlink(QFile::encodeName(file));
+ }
+ }
oldFile = QString::null;
}
@@ -449,6 +465,24 @@ void KonfUpdate::gotAllKeys()
it != list.end(); ++it)
{
gotKey(it.key());
+ }
+}
+
+void KonfUpdate::gotAllGroups()
+{
+ if (!oldConfig1)
+ {
+ qWarning("AllGroups without file specification.");
+ return;
+ }
+
+ QStringList allGroups = oldConfig1->groupList();
+ for(QStringList::ConstIterator it = allGroups.begin();
+ it != allGroups.end(); ++it)
+ {
+ oldGroup = *it;
+ newGroup = oldGroup;
+ gotAllKeys();
}
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic