[SCM] ktp-accounts-kcm packaging branch, master, updated. debian/15.12.1-1-1157-gc4589c5

Maximiliano Curia maxy at moszumanska.debian.org
Fri May 27 23:57:55 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-accounts-kcm.git;a=commitdiff;h=79b3f69

The following commit has been merged in the master branch:
commit 79b3f691e8c1025e239757d22886061ab20fa0e8
Author: George Goldberg <grundleborg at googlemail.com>
Date:   Mon Aug 3 13:19:58 2009 +0000

    Show the apropriate parameter-edit-widgets in the edit account dialog. Does not yet prepopulate them with existing values.
    
    svn path=/trunk/playground/network/telepathy-accounts-kcm/; revision=1006320
---
 src/edit-account-dialog.cpp | 127 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 126 insertions(+), 1 deletion(-)

diff --git a/src/edit-account-dialog.cpp b/src/edit-account-dialog.cpp
index 873eb9f..6af4793 100644
--- a/src/edit-account-dialog.cpp
+++ b/src/edit-account-dialog.cpp
@@ -20,18 +20,39 @@
 
 #include "edit-account-dialog.h"
 
+#include "mandatory-parameter-edit-widget.h"
+#include "optional-parameter-edit-widget.h"
+#include "plugin-manager.h"
+
+#include "libkcmtelepathyaccounts/abstract-account-parameters-widget.h"
+#include "libkcmtelepathyaccounts/abstract-account-ui.h"
+
 #include <KDebug>
+#include <KLocale>
+#include <KTabWidget>
+
+#include <QtCore/QList>
+
+#include <TelepathyQt4/ConnectionManager>
 
 class EditAccountDialog::Private
 {
 public:
     Private()
-            : item(0)
+            : item(0), tabWidget(0), mandatoryParametersWidget(0)
     {
         kDebug();
     }
 
     AccountItem *item;
+
+    Tp::ProtocolParameterList mandatoryProtocolParameters;
+    Tp::ProtocolParameterList optionalProtocolParameters;
+    QVariantMap parameterValues;
+
+    KTabWidget *tabWidget;
+    AbstractAccountParametersWidget *mandatoryParametersWidget;
+    QList<AbstractAccountParametersWidget*> optionalParametersWidgets;
 };
 
 EditAccountDialog::EditAccountDialog(AccountItem *item, QWidget *parent)
@@ -40,7 +61,111 @@ EditAccountDialog::EditAccountDialog(AccountItem *item, QWidget *parent)
 {
     kDebug();
 
+    // Set up the tab widget.
+    d->tabWidget = new KTabWidget(this);
+    setMainWidget(d->tabWidget);
+    resize(400, 480);
+
     d->item = item;
+
+    // Get the protocol's parameters.
+    Tp::ProtocolInfo *protocolInfo = d->item->account()->protocolInfo();
+    Tp::ProtocolParameterList protocolParameters = protocolInfo->parameters();
+
+    foreach (Tp::ProtocolParameter *parameter, protocolParameters) {
+        if (parameter->isRequired()) {
+            d->mandatoryProtocolParameters.append(parameter);
+        } else {
+            d->optionalProtocolParameters.append(parameter);
+        }
+    }
+
+    // Get the parameter values.
+    d->parameterValues = d->item->account()->parameters();
+
+    // The rest of this method is based on code from add-account-assistant.cpp
+
+    // Get the AccountsUi for the plugin, and get the optional parameter widgets for it.
+    AbstractAccountUi *ui = PluginManager::instance()->accountUiForProtocol(item->account()->cmName(),
+                                                                            item->account()->protocol());
+
+    // Set up the Mandatory Parameters page
+    Tp::ProtocolParameterList mandatoryParametersLeft = d->mandatoryProtocolParameters;
+
+    // Create the custom UI or generic UI depending on available parameters.
+    if (ui) {
+        // UI does exist, set it up.
+        AbstractAccountParametersWidget *widget = ui->mandatoryParametersWidget(d->mandatoryProtocolParameters);
+        QMap<QString, QVariant::Type> manParams = ui->supportedMandatoryParameters();
+        QMap<QString, QVariant::Type>::const_iterator manIter = manParams.constBegin();
+        while(manIter != manParams.constEnd()) {
+            foreach (Tp::ProtocolParameter *parameter, d->mandatoryProtocolParameters) {
+                // If the parameter is not
+                if ((parameter->name() == manIter.key()) &&
+                    (parameter->type() == manIter.value())) {
+                    mandatoryParametersLeft.removeAll(parameter);
+                }
+            }
+
+            ++manIter;
+        }
+
+        if (mandatoryParametersLeft.isEmpty()) {
+            d->mandatoryParametersWidget = widget;
+        } else {
+            // FIXME: At the moment, if the custom widget can't handle all the mandatory
+            // parameters we fall back to the generic one for all of them. It might be nicer
+            // to have the custom UI for as many as possible, and stick a small generic one
+            // underneath for those parameters it doesn't handle.
+            widget->deleteLater();
+            widget = 0;
+        }
+    }
+
+    if (!d->mandatoryParametersWidget) {
+        d->mandatoryParametersWidget = new MandatoryParameterEditWidget(d->mandatoryProtocolParameters, d->tabWidget);
+    }
+
+    d->tabWidget->addTab(d->mandatoryParametersWidget, i18n("Mandatory Parameters"));
+
+    // Get the list of parameters
+    Tp::ProtocolParameterList optionalParametersLeft = d->optionalProtocolParameters;
+
+    // Check if the AbstractAccountUi exists. If not then we use the autogenerated UI for
+    // everything.
+    if (ui) {
+        // UI Does exist, set it up.
+        QList<AbstractAccountParametersWidget*> widgets = ui->optionalParametersWidgets(d->optionalProtocolParameters);
+
+        // Remove all handled parameters from the optionalParameters list.
+        QMap<QString, QVariant::Type> opParams = ui->supportedOptionalParameters();
+        QMap<QString, QVariant::Type>::const_iterator opIter = opParams.constBegin();
+        while(opIter != opParams.constEnd()) {
+            foreach (Tp::ProtocolParameter *parameter, d->optionalProtocolParameters) {
+                // If the parameter is not
+                if ((parameter->name() == opIter.key()) &&
+                    (parameter->type() == opIter.value())) {
+                    optionalParametersLeft.removeAll(parameter);
+                }
+            }
+
+            ++opIter;
+        }
+
+        foreach (AbstractAccountParametersWidget *widget, widgets) {
+            d->optionalParametersWidgets.append(widget);
+            d->tabWidget->addTab(widget, i18n("Optional Parameters"));
+        }
+    }
+
+    // Show the generic UI if optionalParameters is not empty.
+    if (optionalParametersLeft.size() > 0) {
+        OptionalParameterEditWidget *opew =
+                new OptionalParameterEditWidget(optionalParametersLeft, d->tabWidget);
+        d->optionalParametersWidgets.append(opew);
+        d->tabWidget->addTab(opew, i18n("Optional Parameters"));
+    }
+
 }
 
 EditAccountDialog::~EditAccountDialog()

-- 
ktp-accounts-kcm packaging



More information about the pkg-kde-commits mailing list