kandy Library API Documentation

cmdpropertiesdialog.cpp

00001 /* 00002 This file is part of Kandy. 00003 00004 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00019 00020 As a special exception, permission is given to link this program 00021 with any edition of Qt, and distribute the resulting executable, 00022 without including the source code for Qt in the source distribution. 00023 */ 00024 00025 #include <qlistview.h> 00026 #include <qlineedit.h> 00027 #include <qcheckbox.h> 00028 00029 #include <kinputdialog.h> 00030 #include <klocale.h> 00031 00032 #include "atcommand.h" 00033 00034 #include "cmdpropertiesdialog.h" 00035 #include "cmdpropertiesdialog.moc" 00036 00037 class ParameterItem : public QCheckListItem { 00038 public: 00039 ParameterItem(ATParameter *p,QListView *parent) : 00040 QCheckListItem(parent,p->name(),CheckBox),mParameter(p) 00041 { 00042 setText(1,p->value()); 00043 setOn(p->userInput()); 00044 } 00045 00046 void writeParameter() 00047 { 00048 mParameter->setName(text(0)); 00049 mParameter->setValue(text(1)); 00050 mParameter->setUserInput(isOn()); 00051 } 00052 00053 private: 00054 ATParameter *mParameter; 00055 }; 00056 00057 00058 /* 00059 * Constructs a CmdPropertiesDialog which is a child of 'parent', with the 00060 * name 'name' and widget flags set to 'f' 00061 * 00062 * The dialog will by default be modeless, unless you set 'modal' to 00063 * TRUE to construct a modal dialog. 00064 */ 00065 CmdPropertiesDialog::CmdPropertiesDialog(ATCommand *cmd, QWidget* parent, 00066 const char* name, bool modal, 00067 WFlags fl ) 00068 : CmdPropertiesDialog_base( parent, name, modal, fl ) 00069 { 00070 mCmd = cmd; 00071 00072 readCommand(); 00073 } 00074 00075 CmdPropertiesDialog::~CmdPropertiesDialog() 00076 { 00077 } 00078 00079 void CmdPropertiesDialog::readCommand() 00080 { 00081 mNameEdit->setText(mCmd->cmdName()); 00082 mStringEdit->setText(mCmd->cmdString()); 00083 mHexCheck->setChecked(mCmd->hexOutput()); 00084 00085 QPtrList<ATParameter> parameters = mCmd->parameters(); 00086 for(int i=(int)parameters.count()-1;i>=0;--i) { 00087 ATParameter *p = parameters.at(i); 00088 new ParameterItem(p,mParameterList); 00089 } 00090 } 00091 00092 void CmdPropertiesDialog::writeCommand() 00093 { 00094 mCmd->setCmdName(mNameEdit->text()); 00095 mCmd->setCmdString(mStringEdit->text()); 00096 mCmd->setHexOutput(mHexCheck->isChecked()); 00097 ParameterItem *item = (ParameterItem *)mParameterList->firstChild(); 00098 while (item) { 00099 item->writeParameter(); 00100 item = (ParameterItem *)item->nextSibling(); 00101 } 00102 } 00103 00104 void CmdPropertiesDialog::editParameterName(QListViewItem *item) 00105 { 00106 bool ok = false; 00107 00108 QString newName = KInputDialog::getText(QString::null, 00109 i18n("Enter parameter name:"),item->text(0),&ok,this); 00110 00111 if (ok) { 00112 item->setText(0,newName); 00113 } 00114 } 00115 00116 void CmdPropertiesDialog::slotAccept() 00117 { 00118 writeCommand(); 00119 accept(); 00120 }
KDE Logo
This file is part of the documentation for kandy Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Oct 1 15:19:02 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003