summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/remote/configtab.cpp17
1 files changed, 4 insertions, 13 deletions
diff --git a/noncore/tools/remote/configtab.cpp b/noncore/tools/remote/configtab.cpp
index ebfba2e..af2b5ff 100644
--- a/noncore/tools/remote/configtab.cpp
+++ b/noncore/tools/remote/configtab.cpp
@@ -9,210 +9,201 @@ version.
9This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 9This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
10implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 10implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11Public License for more details. 11Public License for more details.
12 12
13You should have received a copy of the GNU General Public License along with this program; if not, write to the Free 13You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
14Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 14Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15*/ 15*/
16 16
17#include "configtab.h" 17#include "configtab.h"
18 18
19ConfigTab::ConfigTab(QWidget *parent, const char *name):QWidget(parent,name) 19ConfigTab::ConfigTab(QWidget *parent, const char *name):QWidget(parent,name)
20{ 20{
21 21
22 QVBoxLayout *layout = new QVBoxLayout(this); 22 QVBoxLayout *layout = new QVBoxLayout(this);
23 23
24 topGroupConf = new TopGroupConf(this, "topGroupConf"); 24 topGroupConf = new TopGroupConf(this, "topGroupConf");
25 layout->addWidget(topGroupConf, 1); 25 layout->addWidget(topGroupConf, 1);
26 layout->addSpacing(1); 26 layout->addSpacing(1);
27 27
28 dvdGroupConf = new DVDGroupConf(this, "dvdGroupConf"); 28 dvdGroupConf = new DVDGroupConf(this, "dvdGroupConf");
29 layout->addWidget(dvdGroupConf, 1); 29 layout->addWidget(dvdGroupConf, 1);
30 layout->addSpacing(1); 30 layout->addSpacing(1);
31 31
32 vcrGroupConf = new VCRGroupConf(this, "vcrGroupConf"); 32 vcrGroupConf = new VCRGroupConf(this, "vcrGroupConf");
33 layout->addWidget(vcrGroupConf, 1); 33 layout->addWidget(vcrGroupConf, 1);
34 layout->addSpacing(1); 34 layout->addSpacing(1);
35 35
36 channelGroupConf = new ChannelGroupConf(this, "channelGroupConf"); 36 channelGroupConf = new ChannelGroupConf(this, "channelGroupConf");
37 layout->addWidget(channelGroupConf, 1); 37 layout->addWidget(channelGroupConf, 1);
38 38
39 39
40} 40}
41 41
42void ConfigTab::setConfig(Config *newCfg) 42void ConfigTab::setConfig(Config *newCfg)
43{ 43{
44 cfg = newCfg; 44 cfg = newCfg;
45 cfg->setGroup("Remotes"); 45 cfg->setGroup("Remotes");
46 topGroupConf->updateRemotes(cfg->readListEntry("remoteList", ',') ); 46 topGroupConf->updateRemotes(cfg->readListEntry("remoteList", ',') );
47 cfg->setGroup("Default"); 47 cfg->setGroup("Default");
48 const QObject *obj; 48 const QObject *obj;
49 49
50 const QObjectList *objList = topGroupConf->children(); 50 const QObjectList *objList = topGroupConf->children();
51 for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) 51 for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next())
52 { 52 {
53 if(obj->inherits("QPushButton")) 53 if(obj->inherits("QPushButton"))
54 { 54 {
55 if(!cfg->hasKey((QString)obj->name()+"Label")) 55 if(!cfg->hasKey((QString)obj->name()+"Label"))
56 { 56 {
57 cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text()); 57 cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text());
58 } 58 }
59 } 59 }
60 } 60 }
61 61
62 objList = dvdGroupConf->children(); 62 objList = dvdGroupConf->children();
63 for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) 63 for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next())
64 { 64 {
65 if(obj->inherits("QPushButton")) 65 if(obj->inherits("QPushButton"))
66 { 66 {
67 if(!cfg->hasKey((QString)obj->name()+"Label")) 67 if(!cfg->hasKey((QString)obj->name()+"Label"))
68 { 68 {
69 cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text()); 69 cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text());
70 } 70 }
71 } 71 }
72 } 72 }
73 73
74 objList = vcrGroupConf->children(); 74 objList = vcrGroupConf->children();
75 for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) 75 for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next())
76 { 76 {
77 if(obj->inherits("QPushButton")) 77 if(obj->inherits("QPushButton"))
78 { 78 {
79 if(!cfg->hasKey((QString)obj->name()+"Label")) 79 if(!cfg->hasKey((QString)obj->name()+"Label"))
80 { 80 {
81 cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text()); 81 cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text());
82 } 82 }
83 } 83 }
84 } 84 }
85 85
86 objList = channelGroupConf->children(); 86 objList = channelGroupConf->children();
87 for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) 87 for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next())
88 { 88 {
89 if(obj->inherits("QPushButton")) 89 if(obj->inherits("QPushButton"))
90 { 90 {
91 if(!cfg->hasKey((QString)obj->name()+"Label")) 91 if(!cfg->hasKey((QString)obj->name()+"Label"))
92 { 92 {
93 cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text()); 93 cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text());
94 } 94 }
95 } 95 }
96 } 96 }
97 cfg->write(); 97 cfg->write();
98 98
99 cfg->setGroup("Remotes"); 99 cfg->setGroup("Remotes");
100 100
101 QString curr_remote = topGroupConf->getRemotesText(); 101 QString curr_remote = topGroupConf->getRemotesText();
102 if(curr_remote != "") 102 if(curr_remote != "")
103 remoteSelected(curr_remote); 103 remoteSelected(curr_remote);
104} 104}
105/*
106void ConfigTab::savePressed()
107{
108 cfg->setGroup(remotes->currentText());
109 ButtonDialog *bd = new ButtonDialog(this, "BD", true, 0);
110 if( bd->exec() == 1)
111 {
112 printf("%s\n", bd->getList().join(" ").latin1());
113 }
114}
115*/
116 105
117void ConfigTab::newPressed() 106void ConfigTab::newPressed()
118{ 107{
119 QStringList list; 108 QStringList list;
120 QString newname = topGroupConf->getRemotesText(); 109 QString newname = topGroupConf->getRemotesText();
121 if(newname=="Remotes") 110 if(newname.stripWhiteSpace()=="")
122 QMessageBox::warning(this, tr("Error"), tr("The name 'Remotes' is not allowed"), QMessageBox::Ok, QMessageBox::NoButton); 111 QMessageBox::warning(this, tr("Error"), tr("Please enter a name\nfirst"), QMessageBox::Ok, QMessageBox::NoButton);
112 else if(newname=="Remotes")
113 QMessageBox::warning(this, tr("Error"), tr("The name 'Remotes' is\nnot allowed"), QMessageBox::Ok, QMessageBox::NoButton);
123 else { 114 else {
124 cfg->setGroup("Remotes"); 115 cfg->setGroup("Remotes");
125 list=cfg->readListEntry("remoteList", ','); 116 list=cfg->readListEntry("remoteList", ',');
126 if(list.findIndex(newname) == -1) { 117 if(list.findIndex(newname) == -1) {
127 list+=newname; 118 list+=newname;
128 cfg->writeEntry("remoteList", list, ','); 119 cfg->writeEntry("remoteList", list, ',');
129 cfg->setGroup(newname); 120 cfg->setGroup(newname);
130 topGroupConf->updateRemotes(QStringList(newname) ); 121 topGroupConf->updateRemotes(QStringList(newname) );
131 cfg->write(); 122 cfg->write();
132 emit remotesChanged(); 123 emit remotesChanged();
133 remoteSelected(newname); 124 remoteSelected(newname);
134 } 125 }
135 else { 126 else {
136 QMessageBox::warning(this, tr("Already exists"), tr("A layout named %1\nalready exists").arg(newname), QMessageBox::Ok, QMessageBox::NoButton); 127 QMessageBox::warning(this, tr("Already exists"), tr("A layout named %1\nalready exists").arg(newname), QMessageBox::Ok, QMessageBox::NoButton);
137 // Re-select existing layout 128 // Re-select existing layout
138 remoteSelected(newname); 129 remoteSelected(newname);
139 } 130 }
140 } 131 }
141} 132}
142 133
143void ConfigTab::remoteSelected(const QString &string) 134void ConfigTab::remoteSelected(const QString &string)
144{ 135{
145 cfg->setGroup(string); 136 cfg->setGroup(string);
146 const QObject *obj; 137 const QObject *obj;
147 138
148 const QObjectList *objList = topGroupConf->children(); 139 const QObjectList *objList = topGroupConf->children();
149 for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) 140 for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next())
150 { 141 {
151 if(obj->inherits("QPushButton")) 142 if(obj->inherits("QPushButton"))
152 { 143 {
153 if(cfg->hasKey((QString)obj->name()+"Label")) 144 if(cfg->hasKey((QString)obj->name()+"Label"))
154 { 145 {
155 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); 146 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
156 } 147 }
157 else 148 else
158 { 149 {
159 cfg->setGroup("Default"); 150 cfg->setGroup("Default");
160 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); 151 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
161 cfg->setGroup(string); 152 cfg->setGroup(string);
162 } 153 }
163 } 154 }
164 } 155 }
165 156
166 objList = dvdGroupConf->children(); 157 objList = dvdGroupConf->children();
167 for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) 158 for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next())
168 { 159 {
169 if(obj->inherits("QPushButton")) 160 if(obj->inherits("QPushButton"))
170 { 161 {
171 if(cfg->hasKey((QString)obj->name()+"Label")) 162 if(cfg->hasKey((QString)obj->name()+"Label"))
172 { 163 {
173 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); 164 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
174 } 165 }
175 else 166 else
176 { 167 {
177 cfg->setGroup("Default"); 168 cfg->setGroup("Default");
178 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); 169 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
179 cfg->setGroup(string); 170 cfg->setGroup(string);
180 } 171 }
181 } 172 }
182 } 173 }
183 174
184 objList = vcrGroupConf->children(); 175 objList = vcrGroupConf->children();
185 for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) 176 for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next())
186 { 177 {
187 if(obj->inherits("QPushButton")) 178 if(obj->inherits("QPushButton"))
188 { 179 {
189 if(cfg->hasKey((QString)obj->name()+"Label")) 180 if(cfg->hasKey((QString)obj->name()+"Label"))
190 { 181 {
191 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); 182 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
192 } 183 }
193 else 184 else
194 { 185 {
195 cfg->setGroup("Default"); 186 cfg->setGroup("Default");
196 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); 187 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
197 cfg->setGroup(string); 188 cfg->setGroup(string);
198 } 189 }
199 } 190 }
200 } 191 }
201 192
202 objList = channelGroupConf->children(); 193 objList = channelGroupConf->children();
203 for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) 194 for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next())
204 { 195 {
205 if(obj->inherits("QPushButton")) 196 if(obj->inherits("QPushButton"))
206 { 197 {
207 if(cfg->hasKey((QString)obj->name()+"Label")) 198 if(cfg->hasKey((QString)obj->name()+"Label"))
208 { 199 {
209 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); 200 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
210 } 201 }
211 else 202 else
212 { 203 {
213 cfg->setGroup("Default"); 204 cfg->setGroup("Default");
214 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); 205 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
215 cfg->setGroup(string); 206 cfg->setGroup(string);
216 } 207 }
217 } 208 }
218 } 209 }