[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:58:01 UTC 2016


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

The following commit has been merged in the master branch:
commit e6232d74b106e6aaf29e0b3061339071b678a3da
Author: Matteo Nardi <91.matteo at gmail.com>
Date:   Thu Aug 6 19:00:50 2009 +0000

    -Enable the next button only when a protocol is selected on the first page of the add account assistant.
    -Go to next page when a protocol is double clicked.
    
    svn path=/trunk/playground/network/telepathy-accounts-kcm/; revision=1008048
---
 src/add-account-assistant.cpp  | 200 +++++++++++++++++++++--------------------
 src/add-account-assistant.h    |   1 +
 src/protocol-select-widget.cpp |  11 ++-
 src/protocol-select-widget.h   |   6 +-
 4 files changed, 117 insertions(+), 101 deletions(-)

diff --git a/src/add-account-assistant.cpp b/src/add-account-assistant.cpp
index 1085f84..484178d 100644
--- a/src/add-account-assistant.cpp
+++ b/src/add-account-assistant.cpp
@@ -75,6 +75,14 @@ AddAccountAssistant::AddAccountAssistant(Tp::AccountManagerPtr accountManager, Q
     d->protocolSelectWidget = new ProtocolSelectWidget(this);
     d->pageOne = new KPageWidgetItem(d->protocolSelectWidget);
     d->pageOne->setHeader(i18n("Step 1: Select an Instant Messaging Network."));
+    setValid(d->pageOne, false);
+    connect(d->protocolSelectWidget,
+            SIGNAL(protocolGotSelected(bool)),
+            SLOT(onProtocolSelected(bool)));
+    connect(d->protocolSelectWidget,
+            SIGNAL(protocolDoubleClicked()),
+            SLOT(next()));
+
     d->tabWidget = new KTabWidget(this);
     d->pageTwo = new KPageWidgetItem(d->tabWidget);
     d->pageTwo->setHeader(i18n("Step 2: Fill in the required Parameters."));
@@ -102,124 +110,120 @@ void AddAccountAssistant::next()
     // Check which page we are on.
     if (currentPage() == d->pageOne) {
         kDebug() << "Current page: Page 1.";
-        // Page 1
 
-        // 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.";
+        Q_ASSERT(d->protocolSelectWidget->selectedProtocol());
 
-            // Set up the next page.
-            ProtocolItem *item = d->protocolSelectWidget->selectedProtocol();
+        // Set up the next page.
+        ProtocolItem *item = d->protocolSelectWidget->selectedProtocol();
 
-            ConnectionManagerItem *cmItem = qobject_cast<ConnectionManagerItem*>(item->parent());
-            if (!cmItem) {
-                kWarning() << "cmItem is invalid.";
-            }
+        ConnectionManagerItem *cmItem = qobject_cast<ConnectionManagerItem*>(item->parent());
+        if (!cmItem) {
+            kWarning() << "cmItem is invalid.";
+        }
 
-            QString connectionManager = cmItem->connectionManager()->name();
-            QString protocol = item->protocol();
+        QString connectionManager = cmItem->connectionManager()->name();
+        QString protocol = item->protocol();
 
-            // Get the AccountsUi for the plugin, and get the optional parameter widgets for it.
-            AbstractAccountUi *ui = PluginManager::instance()->accountUiForProtocol(connectionManager,
-                                                                                    protocol);
+        // Get the AccountsUi for the plugin, and get the optional parameter widgets for it.
+        AbstractAccountUi *ui = PluginManager::instance()->accountUiForProtocol(connectionManager,
+                                                                                protocol);
 
-            // Delete the widgets for the next page if they already exist
-            if (d->mandatoryParametersWidget) {
-                d->mandatoryParametersWidget->deleteLater();
-                d->mandatoryParametersWidget = 0;
-            }
+        // Delete the widgets for the next page if they already exist
+        if (d->mandatoryParametersWidget) {
+            d->mandatoryParametersWidget->deleteLater();
+            d->mandatoryParametersWidget = 0;
+        }
 
-            foreach (AbstractAccountParametersWidget *w, d->optionalParametersWidgets) {
-                if (w) {
-                    w->deleteLater();
-                }
+        foreach (AbstractAccountParametersWidget *w, d->optionalParametersWidgets) {
+            if (w) {
+                w->deleteLater();
             }
-            d->optionalParametersWidgets.clear();
-
-            // Set up the Mandatory Parameters page
-            Tp::ProtocolParameterList mandatoryParameters = item->mandatoryParameters();
-            Tp::ProtocolParameterList mandatoryParametersLeft = item->mandatoryParameters();
-
-            // Create the custom UI or generic UI depending on available parameters.
-            if (ui) {
-                // UI does exist, set it up.
-                AbstractAccountParametersWidget *widget = ui->mandatoryParametersWidget(mandatoryParameters);
-                QMap<QString, QVariant::Type> manParams = ui->supportedMandatoryParameters();
-                QMap<QString, QVariant::Type>::const_iterator manIter = manParams.constBegin();
-                while(manIter != manParams.constEnd()) {
-                    foreach (Tp::ProtocolParameter *parameter, mandatoryParameters) {
-                        // If the parameter is not
-                        if ((parameter->name() == manIter.key()) &&
-                            (parameter->type() == manIter.value())) {
-                            mandatoryParametersLeft.removeAll(parameter);
-                        }
+        }
+        d->optionalParametersWidgets.clear();
+
+        // Set up the Mandatory Parameters page
+        Tp::ProtocolParameterList mandatoryParameters = item->mandatoryParameters();
+        Tp::ProtocolParameterList mandatoryParametersLeft = item->mandatoryParameters();
+
+        // Create the custom UI or generic UI depending on available parameters.
+        if (ui) {
+            // UI does exist, set it up.
+            AbstractAccountParametersWidget *widget = ui->mandatoryParametersWidget(mandatoryParameters);
+            QMap<QString, QVariant::Type> manParams = ui->supportedMandatoryParameters();
+            QMap<QString, QVariant::Type>::const_iterator manIter = manParams.constBegin();
+            while(manIter != manParams.constEnd()) {
+                foreach (Tp::ProtocolParameter *parameter, mandatoryParameters) {
+                    // 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;
-                }
+                ++manIter;
             }
 
-            if (!d->mandatoryParametersWidget) {
-                d->mandatoryParametersWidget = new MandatoryParameterEditWidget(
-                        item->mandatoryParameters(), QVariantMap(), d->tabWidget);
+            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;
             }
+        }
 
-            d->tabWidget->addTab(d->mandatoryParametersWidget, i18n("Mandatory Parameters"));
-
-            // Get the list of parameters
-            Tp::ProtocolParameterList optionalParameters = item->optionalParameters();
-            Tp::ProtocolParameterList optionalParametersLeft = item->optionalParameters();
-
-            // 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(optionalParameters);
-
-                // 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, optionalParameters) {
-                        // If the parameter is not
-                        if ((parameter->name() == opIter.key()) &&
-                            (parameter->type() == opIter.value())) {
-                            optionalParametersLeft.removeAll(parameter);
-                        }
-                    }
+        if (!d->mandatoryParametersWidget) {
+            d->mandatoryParametersWidget = new MandatoryParameterEditWidget(
+                    item->mandatoryParameters(), QVariantMap(), d->tabWidget);
+        }
 
-                    ++opIter;
+        d->tabWidget->addTab(d->mandatoryParametersWidget, i18n("Mandatory Parameters"));
+
+        // Get the list of parameters
+        Tp::ProtocolParameterList optionalParameters = item->optionalParameters();
+        Tp::ProtocolParameterList optionalParametersLeft = item->optionalParameters();
+
+        // 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(optionalParameters);
+
+            // 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, optionalParameters) {
+                    // If the parameter is not
+                    if ((parameter->name() == opIter.key()) &&
+                        (parameter->type() == opIter.value())) {
+                        optionalParametersLeft.removeAll(parameter);
+                    }
                 }
 
-                foreach (AbstractAccountParametersWidget *widget, widgets) {
-                    d->optionalParametersWidgets.append(widget);
-                    d->tabWidget->addTab(widget, i18n("Optional Parameters"));
-                }
+                ++opIter;
             }
 
-            // Show the generic UI if optionalParameters is not empty.
-            if (optionalParametersLeft.size() > 0) {
-                OptionalParameterEditWidget *opew =
-                        new OptionalParameterEditWidget(optionalParametersLeft,
-                                                        QVariantMap(),
-                                                        d->tabWidget);
-                d->optionalParametersWidgets.append(opew);
-                d->tabWidget->addTab(opew, i18n("Optional Parameters"));
+            foreach (AbstractAccountParametersWidget *widget, widgets) {
+                d->optionalParametersWidgets.append(widget);
+                d->tabWidget->addTab(widget, i18n("Optional Parameters"));
             }
+        }
 
-            KAssistantDialog::next();
+        // Show the generic UI if optionalParameters is not empty.
+        if (optionalParametersLeft.size() > 0) {
+            OptionalParameterEditWidget *opew =
+                    new OptionalParameterEditWidget(optionalParametersLeft,
+                                                    QVariantMap(),
+                                                    d->tabWidget);
+            d->optionalParametersWidgets.append(opew);
+            d->tabWidget->addTab(opew, i18n("Optional Parameters"));
         }
+
+        KAssistantDialog::next();
     }
 }
 
@@ -331,6 +335,12 @@ void AddAccountAssistant::onAccountCreated(Tp::PendingOperation *op)
     KAssistantDialog::accept();
 }
 
+void AddAccountAssistant::onProtocolSelected(bool value)
+{
+    //if a protocol is selected, enable the next button on the first page
+    setValid(d->pageOne, value);
+}
+
 
 #include "add-account-assistant.moc"
 
diff --git a/src/add-account-assistant.h b/src/add-account-assistant.h
index ed7c3b8..665f06c 100644
--- a/src/add-account-assistant.h
+++ b/src/add-account-assistant.h
@@ -47,6 +47,7 @@ Q_SIGNALS:
 
 private Q_SLOTS:
     void onAccountCreated(Tp::PendingOperation *op);
+    void onProtocolSelected(bool value);
 
 private:
     class Private;
diff --git a/src/protocol-select-widget.cpp b/src/protocol-select-widget.cpp
index 017c410..fa4b3c6 100644
--- a/src/protocol-select-widget.cpp
+++ b/src/protocol-select-widget.cpp
@@ -59,8 +59,11 @@ ProtocolSelectWidget::ProtocolSelectWidget(QWidget *parent)
     d->ui->protocolListView->setModel(d->model);
 
     connect(d->ui->protocolListView->selectionModel(),
-            SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
-            SLOT(onCurrentChanged(const QModelIndex &)));
+            SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
+            SLOT(onSelectionChanged(const QItemSelection &)));
+    connect(d->ui->protocolListView,
+            SIGNAL(doubleClicked(QModelIndex)),
+            SIGNAL(protocolDoubleClicked()));
 
     // Load the list of all installed Telepathy Connection Managers Asynchronously
     QTimer::singleShot(0, this, SLOT(getConnectionManagerList()));
@@ -131,11 +134,11 @@ ProtocolItem *ProtocolSelectWidget::selectedProtocol()
     return d->model->itemForIndex(selectedIndexes.at(0));
 }
 
-void ProtocolSelectWidget::onCurrentChanged(const QModelIndex &current)
+void ProtocolSelectWidget::onSelectionChanged(const QItemSelection &selected)
 {
     kDebug();
 
-    Q_EMIT selectedProtocolChanged(d->model->itemForIndex(current));
+    Q_EMIT protocolGotSelected(!selected.isEmpty());
 }
 
 
diff --git a/src/protocol-select-widget.h b/src/protocol-select-widget.h
index 8e658f5..1904744 100644
--- a/src/protocol-select-widget.h
+++ b/src/protocol-select-widget.h
@@ -24,6 +24,7 @@
 #include <QtGui/QWidget>
 
 class ProtocolItem;
+class QItemSelection;
 
 class QModelIndex;
 
@@ -44,10 +45,11 @@ public:
 private Q_SLOTS:
     void getConnectionManagerList();
     void onConnectionManagerListGot(Tp::PendingOperation *op);
-    void onCurrentChanged(const QModelIndex &current);
+    void onSelectionChanged(const QItemSelection &selected);
 
 Q_SIGNALS:
-    void selectedProtocolChanged(ProtocolItem *item);
+    void protocolGotSelected(bool selected);
+    void protocolDoubleClicked();
 
 private:
     class Private;

-- 
ktp-accounts-kcm packaging



More information about the pkg-kde-commits mailing list