[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/network/telepathy-accounts-kcm/src
From: George Goldberg <grundleborg () googlemail ! com>
Date: 2009-07-23 11:26:39
Message-ID: 1248348399.247209.16968.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1001469 by gberg:
Add parameter-edit-widgets to the second page of the add account assitant.
M +42 -10 add-account-assistant.cpp
M +22 -0 parameter-edit-delegate.cpp
M +5 -0 parameter-edit-delegate.h
M +9 -1 parameter-edit-widget.cpp
M +44 -0 protocol-item.cpp
M +5 -0 protocol-item.h
--- trunk/playground/network/telepathy-accounts-kcm/src/add-account-assistant.cpp #1001468:1001469
@@ -20,6 +20,8 @@
#include "add-account-assistant.h"
+#include "parameter-edit-widget.h"
+#include "protocol-item.h"
#include "protocol-select-widget.h"
#include <KDebug>
@@ -31,13 +33,20 @@
{
public:
Private()
- : pageOne(0)
+ : protocolSelectWidget(0),
+ tabWidget(0),
+ mandatoryParametersWidget(0),
+ optionalParametersWidget(0),
+ pageOne(0),
+ pageTwo(0)
{
kDebug();
}
- ProtocolSelectWidget *widgetOne;
- KTabWidget *widgetTwo;
+ ProtocolSelectWidget *protocolSelectWidget;
+ KTabWidget *tabWidget;
+ ParameterEditWidget *mandatoryParametersWidget;
+ ParameterEditWidget *optionalParametersWidget;
KPageWidgetItem *pageOne;
KPageWidgetItem *pageTwo;
};
@@ -49,11 +58,11 @@
kDebug();
// Set up the pages of the Assistant.
- d->widgetOne = new ProtocolSelectWidget(this);
- d->pageOne = new KPageWidgetItem(d->widgetOne);
+ d->protocolSelectWidget = new ProtocolSelectWidget(this);
+ d->pageOne = new KPageWidgetItem(d->protocolSelectWidget);
d->pageOne->setHeader(i18n("Step 1: Select an Instant Messaging Network."));
- d->widgetTwo = new KTabWidget(this);
- d->pageTwo = new KPageWidgetItem(d->widgetTwo);
+ d->tabWidget = new KTabWidget(this);
+ d->pageTwo = new KPageWidgetItem(d->tabWidget);
d->pageTwo->setHeader(i18n("Step 2: Fill in the required Parameters."));
addPage(d->pageOne);
@@ -83,9 +92,32 @@
kDebug() << "Current page: Page 1.";
// Page 1
- // Check if the protocol is selected. If it is, continue to the next page.
- if (d->widgetOne->selectedProtocol()) {
- kDebug() << "Protocol is selected. Continue to the next page.";
+ // Check if the protocol is selected. If it is, set up the next page and continue to it.
+ if (d->protocolSelectWidget->selectedProtocol()) {
+ kDebug() << "Protocol is selected. Set up and continue to the next page.";
+
+ // Set up the next page.
+ ProtocolItem *item = d->protocolSelectWidget->selectedProtocol();
+
+ // Delete the widgets for the next page if they already exist
+ if (d->mandatoryParametersWidget) {
+ d->mandatoryParametersWidget->deleteLater();
+ d->mandatoryParametersWidget = 0;
+ }
+
+ if (d->optionalParametersWidget) {
+ d->optionalParametersWidget->deleteLater();
+ d->optionalParametersWidget = 0;
+ }
+
+ d->mandatoryParametersWidget = new ParameterEditWidget(d->tabWidget);
+ d->mandatoryParametersWidget->setParameters(item->mandatoryParameters());
+ d->tabWidget->addTab(d->mandatoryParametersWidget, i18n("Mandatory Parameters"));
+
+ d->optionalParametersWidget = new ParameterEditWidget(d->tabWidget);
+ d->optionalParametersWidget->setParameters(item->optionalParameters());
+ d->tabWidget->addTab(d->optionalParametersWidget, i18n("Optional Parameters"));
+
KAssistantDialog::next();
}
}
--- trunk/playground/network/telepathy-accounts-kcm/src/parameter-edit-delegate.cpp #1001468:1001469
@@ -59,6 +59,28 @@
Q_UNUSED(index);
}
+void ParameterEditDelegate::paint(QPainter *painter,
+ const QStyleOptionViewItem &option,
+ const QModelIndex &index) const
+{
+ // TODO: Implement me!
+ Q_UNUSED(painter);
+ Q_UNUSED(option);
+ Q_UNUSED(index);
+}
+
+QSize ParameterEditDelegate::sizeHint(const QStyleOptionViewItem &option,
+ const QModelIndex &index) const
+{
+ // TODO: Implement me!
+
+ Q_UNUSED(option);
+ Q_UNUSED(index);
+
+ return QSize();
+}
+
+
#include "parameter-edit-delegate.moc"
--- trunk/playground/network/telepathy-accounts-kcm/src/parameter-edit-delegate.h #1001468:1001469
@@ -31,6 +31,11 @@
explicit ParameterEditDelegate(QAbstractItemView *itemView, QObject *parent = 0);
virtual ~ParameterEditDelegate();
+ virtual void paint(QPainter *painter,
+ const QStyleOptionViewItem &option,
+ const QModelIndex &index) const;
+ virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
+
protected:
virtual QList<QWidget*> createItemWidgets() const;
virtual void updateItemWidgets(const QList<QWidget*> widgets,
--- trunk/playground/network/telepathy-accounts-kcm/src/parameter-edit-widget.cpp #1001468:1001469
@@ -20,6 +20,8 @@
#include "parameter-edit-widget.h"
+#include "parameter-edit-delegate.h"
+
#include "ui_parameter-edit-widget.h"
#include <KDebug>
@@ -28,13 +30,14 @@
{
public:
Private()
- : ui(0)
+ : ui(0), delegate(0)
{
kDebug();
}
Ui::ParameterEditWidget *ui;
Tp::ProtocolParameterList parameters;
+ ParameterEditDelegate *delegate;
};
ParameterEditWidget::ParameterEditWidget(QWidget *parent)
@@ -46,6 +49,11 @@
// Set up the UI.
d->ui = new Ui::ParameterEditWidget;
d->ui->setupUi(this);
+
+ // d->delegate = new ParameterEditDelegate(d->ui->parameterListView, this);
+ // d->ui->parameterListView->setItemDelegate(d->delegate);
+
+ // TODO: Model
}
ParameterEditWidget::~ParameterEditWidget()
--- trunk/playground/network/telepathy-accounts-kcm/src/protocol-item.cpp #1001468:1001469
@@ -45,6 +45,50 @@
return m_protocol;
}
+Tp::ProtocolParameterList ProtocolItem::mandatoryParameters() const
+{
+ kDebug();
+ ConnectionManagerItem *item = qobject_cast<ConnectionManagerItem*>(parent());
+
+ Tp::ConnectionManagerPtr cm = item->connectionManager();
+
+ Tp::ProtocolParameterList mandatoryParameters;
+ foreach (Tp::ProtocolInfo *info, cm->protocols()) {
+ if (info->name() == m_protocol) {
+ foreach (Tp::ProtocolParameter *parameter, info->parameters()) {
+ if (parameter->isRequired()) {
+ mandatoryParameters << parameter;
+ }
+ }
+ }
+ }
+
+ return mandatoryParameters;
+}
+
+Tp::ProtocolParameterList ProtocolItem::optionalParameters() const
+{
+ kDebug();
+
+ ConnectionManagerItem *item = qobject_cast<ConnectionManagerItem*>(parent());
+
+ Tp::ConnectionManagerPtr cm = item->connectionManager();
+
+ Tp::ProtocolParameterList optionalParameters;
+ foreach (Tp::ProtocolInfo *info, cm->protocols()) {
+ if (info->name() == m_protocol) {
+ foreach (Tp::ProtocolParameter *parameter, info->parameters()) {
+ if (!parameter->isRequired()) {
+ optionalParameters << parameter;
+ }
+ }
+ }
+ }
+
+ return optionalParameters;
+}
+
+
#include "protocol-item.moc"
--- trunk/playground/network/telepathy-accounts-kcm/src/protocol-item.h #1001468:1001469
@@ -23,6 +23,8 @@
#include <QtCore/QObject>
+#include <TelepathyQt4/ConnectionManager>
+
class ConnectionManagerItem;
class ProtocolItem : public QObject
@@ -37,6 +39,9 @@
QString protocol() const;
+ Tp::ProtocolParameterList mandatoryParameters() const;
+ Tp::ProtocolParameterList optionalParameters() const;
+
private:
QString m_protocol;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic