kdelirc
iractions.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include <kconfig.h>
00014 #include <kdebug.h>
00015
00016 #include "iractions.h"
00017 #include "iraction.h"
00018
00019 void IRActions::loadFromConfig(KConfig &theConfig)
00020 {
00021 clear();
00022 int numBindings = theConfig.readNumEntry("Bindings");
00023 for(int i = 0; i < numBindings; i++)
00024 addAction(IRAction().loadFromConfig(theConfig, i));
00025 }
00026
00027 void IRActions::purgeAllBindings(KConfig &theConfig)
00028 {
00029 int numBindings = theConfig.readNumEntry("Bindings");
00030 for(int i = 0; i < numBindings; i++)
00031 { QString Binding = "Binding" + QString().setNum(i);
00032 int numArguments = theConfig.readNumEntry(Binding + "Arguments");
00033 for(int j = 0; j < numArguments; j++)
00034 { theConfig.deleteEntry(Binding + "Argument" + QString().setNum(j));
00035 theConfig.deleteEntry(Binding + "ArgumentType" + QString().setNum(j));
00036 }
00037 theConfig.deleteEntry(Binding + "Arguments"); theConfig.deleteEntry(Binding + "Program");
00038 theConfig.deleteEntry(Binding + "Object"); theConfig.deleteEntry(Binding + "Method");
00039 theConfig.deleteEntry(Binding + "Remote"); theConfig.deleteEntry(Binding + "Button");
00040 theConfig.deleteEntry(Binding + "Repeat"); theConfig.deleteEntry(Binding + "Mode");
00041 }
00042 }
00043
00044 void IRActions::saveToConfig(KConfig &theConfig)
00045 {
00046 int index = 0;
00047 purgeAllBindings(theConfig);
00048 for(iterator i = begin(); i != end(); ++i,index++)
00049 (*i).saveToConfig(theConfig, index);
00050 theConfig.writeEntry("Bindings", index);
00051 }
00052
00053 IRAIt IRActions::addAction(const IRAction &theAction)
00054 {
00055 return append(theAction);
00056 }
00057
00058 IRAItList IRActions::findByButton(const QString &remote, const QString &button)
00059 {
00060 IRAItList ret;
00061 for(iterator i = begin(); i != end(); ++i)
00062 if((*i).remote() == remote && (*i).button() == button)
00063 ret += i;
00064 return ret;
00065 }
00066
00067 void IRActions::renameMode(const Mode &mode, const QString &to)
00068 {
00069 for(iterator i = begin(); i != end(); ++i)
00070 { if((*i).remote() == mode.remote() && (*i).mode() == mode.name()) (*i).setMode(to);
00071 if((*i).isModeChange() && (*i).modeChange() == mode.name()) (*i).setModeChange(to);
00072 }
00073 }
00074
00075 IRAItList IRActions::findByMode(const Mode &mode)
00076 {
00077 IRAItList ret;
00078 for(iterator i = begin(); i != end(); ++i)
00079 if((*i).remote() == mode.remote() && (*i).mode() == mode.name()) ret += i;
00080 return ret;
00081 }
00082
00083 IRAItList IRActions::findByModeButton(const Mode &mode, const QString &button)
00084 {
00085 IRAItList ret;
00086 for(iterator i = begin(); i != end(); ++i)
00087 if((*i).remote() == mode.remote() && (*i).mode() == mode.name() && (*i).button() == button)
00088 ret += i;
00089 return ret;
00090 }