KDevelop API Documentation

lib/widgets/propeditor/pstringlistedit.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE project 00002 Copyright (C) 2003 Alexander Dymo <cloudtemple@mksat.net> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00017 Boston, MA 02111-1307, USA. 00018 */ 00019 #include <klocale.h> 00020 00021 #include <qlineedit.h> 00022 #include <kpushbutton.h> 00023 #include <qlayout.h> 00024 #include <qdialog.h> 00025 00026 #include <keditlistbox.h> 00027 #include <kstdguiitem.h> 00028 00029 #include "pstringlistedit.h" 00030 #include "propertyeditor.h" 00031 00032 PStringListEdit::PStringListEdit( const PropertyEditor * editor, const QString pname, const QVariant value, QWidget * parent, const char * name ) 00033 : QWidget(parent, name) 00034 { 00035 l = new QHBoxLayout(this); 00036 00037 edit = new QLineEdit(this); 00038 edit->setReadOnly(true); 00039 l->addWidget(edit); 00040 pbSelect = new QPushButton("...", this); 00041 l->addWidget(pbSelect); 00042 00043 connect(pbSelect, SIGNAL(clicked()), this, SLOT(showEditor())); 00044 setValue(value, false); 00045 setPName(pname); 00046 connect(this, SIGNAL(propertyChanged(QString, QVariant)), editor, SLOT(emitPropertyChange(QString, QVariant))); 00047 } 00048 00049 QVariant PStringListEdit::value() const 00050 { 00051 return QVariant(m_list); 00052 } 00053 00054 void PStringListEdit::setValue(const QVariant value, bool emitChange) 00055 { 00056 m_list = value.toStringList(); 00057 if (emitChange) 00058 emit propertyChanged(pname(), value); 00059 } 00060 00061 void PStringListEdit::showEditor( ) 00062 { 00063 QDialog* dia = new QDialog(this, "stringlist_dialog", true); 00064 QVBoxLayout *dv = new QVBoxLayout(dia, 2); 00065 00066 KEditListBox *select = new KEditListBox(dia, "select_char"); 00067 dv->addWidget(select); 00068 00069 QHBoxLayout *dh = new QHBoxLayout(dv, 6); 00070 KPushButton *pbOk = new KPushButton(KStdGuiItem::ok(), dia); 00071 KPushButton *pbCancel = new KPushButton(KStdGuiItem::cancel(), dia); 00072 QSpacerItem *si = new QSpacerItem(30, 0, QSizePolicy::Expanding, QSizePolicy::Expanding); 00073 00074 connect(pbOk, SIGNAL(clicked()), dia, SLOT(accept())); 00075 connect(pbCancel, SIGNAL(clicked()), dia, SLOT(reject())); 00076 00077 dh->addItem(si); 00078 dh->addWidget(pbOk); 00079 dh->addWidget(pbCancel); 00080 00081 select->insertStringList(m_list); 00082 00083 if (dia->exec() == QDialog::Accepted) 00084 { 00085 m_list = select->items(); 00086 } 00087 delete dia; 00088 00089 emit propertyChanged(pname(), m_list); 00090 } 00091 00092 #include "pstringlistedit.moc"
KDE Logo
This file is part of the documentation for KDevelop Version 3.0.4.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Oct 6 17:39:09 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003