Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

configtab.cpp

Go to the documentation of this file.
00001 /*
00002 Opie-Remote.  emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie.
00003 Copyright (C) 2002 Thomas Stephens
00004 
00005 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
00006 License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
00007 version.
00008 
00009 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
00010 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
00011 Public License for more details.
00012 
00013 You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
00014 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00015 */
00016 
00017 #include "configtab.h"
00018 
00019 ConfigTab::ConfigTab(QWidget *parent, const char *name):QWidget(parent,name)
00020 {
00021 
00022         QVBoxLayout *layout  =  new QVBoxLayout(this);
00023 
00024         topGroupConf = new TopGroupConf(this, "topGroupConf");
00025         layout->addWidget(topGroupConf, 1);
00026         layout->addSpacing(1);
00027 
00028         dvdGroupConf = new DVDGroupConf(this, "dvdGroupConf");
00029         layout->addWidget(dvdGroupConf, 1);
00030         layout->addSpacing(1);
00031 
00032         vcrGroupConf = new VCRGroupConf(this, "vcrGroupConf");
00033         layout->addWidget(vcrGroupConf, 1);
00034         layout->addSpacing(1);
00035 
00036         channelGroupConf = new ChannelGroupConf(this, "channelGroupConf");
00037         layout->addWidget(channelGroupConf, 1);
00038         
00039 
00040 }
00041 
00042 void ConfigTab::setConfig(Config *newCfg)
00043 {
00044         cfg = newCfg;
00045         cfg->setGroup("Remotes");
00046         topGroupConf->updateRemotes(cfg->readListEntry("remoteList", ',') );
00047         cfg->setGroup("Default");
00048         const QObject *obj;
00049 
00050         const QObjectList *objList = topGroupConf->children();
00051         for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next())
00052         {
00053                 if(obj->inherits("QPushButton"))
00054                 {
00055                         if(!cfg->hasKey((QString)obj->name()+"Label"))
00056                         {
00057                                 cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text());
00058                         }
00059                 }
00060         }
00061 
00062         objList = dvdGroupConf->children();
00063         for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next())
00064         {
00065                 if(obj->inherits("QPushButton"))
00066                 {
00067                         if(!cfg->hasKey((QString)obj->name()+"Label"))
00068                         {
00069                                 cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text());
00070                         }
00071                 }
00072         }
00073 
00074         objList = vcrGroupConf->children();
00075         for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next())
00076         {
00077                 if(obj->inherits("QPushButton"))
00078                 {
00079                         if(!cfg->hasKey((QString)obj->name()+"Label"))
00080                         {
00081                                 cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text());
00082                         }
00083                 }
00084         }
00085 
00086         objList = channelGroupConf->children();
00087         for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next())
00088         {
00089                 if(obj->inherits("QPushButton"))
00090                 {
00091                         if(!cfg->hasKey((QString)obj->name()+"Label"))
00092                         {
00093                                 cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text());
00094                         }
00095                 }
00096         }
00097         cfg->write();
00098 
00099         cfg->setGroup("Remotes");
00100 }
00101 /*
00102 void ConfigTab::savePressed()
00103 {
00104         cfg->setGroup(remotes->currentText());
00105         ButtonDialog *bd = new ButtonDialog(this, "BD", true, 0);
00106         if( bd->exec() == 1)
00107         {
00108                 printf("%s\n", bd->getList().join(" ").latin1());
00109         }
00110 }
00111 */
00112 
00113 void ConfigTab::newPressed()
00114 {
00115         QStringList list;
00116         cfg->setGroup("Remotes");
00117         list=cfg->readListEntry("remoteList", ',');
00118         list+=topGroupConf->getRemotesText();
00119         cfg->writeEntry("remoteList", list, ',');
00120         cfg->setGroup(topGroupConf->getRemotesText());
00121         topGroupConf->updateRemotes(QStringList(topGroupConf->getRemotesText()) );
00122         cfg->write();
00123         emit remotesChanged();
00124         remoteSelected(topGroupConf->getRemotesText());
00125 }
00126 
00127 void ConfigTab::remoteSelected(const QString &string)
00128 {
00129         cfg->setGroup(string);
00130         const QObject *obj;
00131 
00132         const QObjectList *objList = topGroupConf->children();
00133         for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next())
00134         {
00135                 if(obj->inherits("QPushButton"))
00136                 {
00137                         if(cfg->hasKey((QString)obj->name()+"Label"))
00138                         {
00139                                 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
00140                         }
00141                         else
00142                         {
00143                                 cfg->setGroup("Default");
00144                                 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
00145                                 cfg->setGroup(string);
00146                         }
00147                 }
00148         }
00149 
00150         objList = dvdGroupConf->children();
00151         for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next())
00152         {
00153                 if(obj->inherits("QPushButton"))
00154                 {
00155                         if(cfg->hasKey((QString)obj->name()+"Label"))
00156                         {
00157                                 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
00158                         }
00159                         else
00160                         {
00161                                 cfg->setGroup("Default");
00162                                 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
00163                                 cfg->setGroup(string);
00164                         }
00165                 }
00166         }
00167 
00168         objList = vcrGroupConf->children();
00169         for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next())
00170         {
00171                 if(obj->inherits("QPushButton"))
00172                 {
00173                         if(cfg->hasKey((QString)obj->name()+"Label"))
00174                         {
00175                                 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
00176                         }
00177                         else
00178                         {
00179                                 cfg->setGroup("Default");
00180                                 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
00181                                 cfg->setGroup(string);
00182                         }
00183                 }
00184         }
00185 
00186         objList = channelGroupConf->children();
00187         for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next())
00188         {
00189                 if(obj->inherits("QPushButton"))
00190                 {
00191                         if(cfg->hasKey((QString)obj->name()+"Label"))
00192                         {
00193                                 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
00194                         }
00195                         else
00196                         {
00197                                 cfg->setGroup("Default");
00198                                 ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") );
00199                                 cfg->setGroup(string);
00200                         }
00201                 }
00202         }
00203 }
00204 
00205 void ConfigTab::buttonPressed()
00206 {
00207         const QObject *button = sender();
00208         QString string = button->name();
00209 
00210         ButtonDialog *bd = new ButtonDialog(((QPushButton *)button)->text(), this, "BD", true, 0);
00211         if( bd->exec() == 1)
00212         {
00213                 cfg->writeEntry(string, bd->getList().join(" ").latin1());
00214                 cfg->writeEntry(string+"Label", bd->getLabel().latin1());
00215         }
00216         cfg->write();
00217         ((QPushButton *)button)->setText(bd->getLabel());
00218 }

Generated on Sat Nov 5 16:18:02 2005 for OPIE by  doxygen 1.4.2