2 * telepathyeditparameterwidget.cpp - UI to edit Telepathy connection parameter
4 * Copyright (c) 2006 by Michaƫl Larouche <larouche@kde.org>
6 * Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
8 *************************************************************************
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
15 *************************************************************************
17 #include "telepathyeditparameterwidget.h"
20 #include <QtGui/QHBoxLayout>
21 #include <QtGui/QVBoxLayout>
22 #include <QtGui/QGridLayout>
23 #include <QtGui/QLabel>
24 #include <QtGui/QLineEdit>
30 #include "telepathyprotocol.h"
32 using namespace QtTapioca
;
35 * @brief Small label and line edit for a single ConnectionManager::Parameter
37 class ParameterLineEdit
: public QWidget
41 ParameterLineEdit(const ConnectionManager::Parameter
¶meter
, QWidget
*parent
)
42 : QWidget(parent
), m_lineValue(0)
44 m_parameter
= parameter
;
48 ConnectionManager::Parameter
parameter() const
55 QVBoxLayout
*mainLayout
= new QVBoxLayout(this);
58 mainLayout
->addWidget( new QLabel(parameter().name(), this) );
60 // Create editable value field
61 m_lineValue
= new QLineEdit(this);
63 m_lineValue
->setText( parameter().value().toString() );
64 mainLayout
->addWidget(m_lineValue
);
67 mainLayout
->addSpacing(10);
72 return m_parameter
.name();
77 QString temp
= m_lineValue
->text();
82 ConnectionManager::Parameter m_parameter
;
83 QLineEdit
*m_lineValue
;
86 class TelepathyEditParameterWidget::Private
93 void init(QWidget
*parent
);
94 void createWidgets(QWidget
*parent
);
97 QGridLayout
*mainLayout
;
98 QList
<ConnectionManager::Parameter
> paramList
;
99 QList
<ParameterLineEdit
*> lineEditList
;
102 TelepathyEditParameterWidget::TelepathyEditParameterWidget(const QList
<ConnectionManager::Parameter
> ¶mList
, QWidget
*parent
)
103 : QWidget(parent
), d(new Private
)
105 d
->paramList
= paramList
;
109 TelepathyEditParameterWidget::~TelepathyEditParameterWidget()
111 kDebug(TELEPATHY_DEBUG_AREA
) ;
115 QList
<QtTapioca::ConnectionManager::Parameter
> TelepathyEditParameterWidget::parameterList()
117 QList
<ConnectionManager::Parameter
> parameterList
;
119 foreach(ParameterLineEdit
*lineEdit
, d
->lineEditList
)
123 kDebug(TELEPATHY_DEBUG_AREA
) << "WARNING: A ParameterLineEdit is null !";
125 ConnectionManager::Parameter
updatedParameter(lineEdit
->name(), lineEdit
->value());
126 parameterList
.append(updatedParameter
);
129 return parameterList
;
132 void TelepathyEditParameterWidget::setParameterList(const QList
<QtTapioca::ConnectionManager::Parameter
> ¶meterList
)
135 d
->paramList
= parameterList
;
136 d
->createWidgets(this);
139 void TelepathyEditParameterWidget::Private::init(QWidget
*parent
)
141 mainLayout
= new QGridLayout(parent
);
143 createWidgets(parent
);
145 // mainLayout->addStretch(2);
148 void TelepathyEditParameterWidget::Private::createWidgets(QWidget
*parent
)
151 foreach(ConnectionManager::Parameter parameter
, paramList
)
153 ParameterLineEdit
*lineEdit
= new ParameterLineEdit(parameter
, parent
);
154 mainLayout
->addWidget(lineEdit
, row
, column
);
155 lineEditList
.append(lineEdit
);
165 void TelepathyEditParameterWidget::Private::clear()
167 qDeleteAll(lineEditList
);
170 #include "telepathyeditparameterwidget.moc"