[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [KDE-Telepathy] 56219ac: Refactor AccountEditWidget to pass
From:       David Edmundson <kde () davidedmundson ! co ! uk>
Date:       2011-01-09 16:44:47
Message-ID: 20110109164447.3E820A6090 () git ! kde ! org
[Download RAW message or body]

commit 56219ac460403bf62a4a62509f5ad8bee26e3c44
branch master
Author: David Edmundson <kde@davidedmundson.co.uk>
Date:   Sat Jan 8 21:41:05 2011 +0000

    Refactor AccountEditWidget to pass ProtocolInfo rather than several QStrings \
seperately.  This simplifies bits of code and reduces the chance of sending garbage \
data to the account edit widget.  Also gives the account edit access to the protocol \
icon.

diff --git a/src/KCMTelepathyAccounts/account-edit-widget.cpp \
b/src/KCMTelepathyAccounts/account-edit-widget.cpp index b2afd2f..1bd635b 100644
--- a/src/KCMTelepathyAccounts/account-edit-widget.cpp
+++ b/src/KCMTelepathyAccounts/account-edit-widget.cpp
@@ -51,9 +51,7 @@ public:
     QList<ProtocolParameterValue> advancedParameterValues;
 };
 
-AccountEditWidget::AccountEditWidget(const QString &connectionManager,
-                                     const QString &protocol,
-                                     const Tp::ProtocolParameterList &parameters,
+AccountEditWidget::AccountEditWidget(const Tp::ProtocolInfo &info,
                                      const QVariantMap &parameterValues,
                                      QWidget *parent)
         : QWidget(parent),
@@ -69,9 +67,9 @@ AccountEditWidget::AccountEditWidget(const QString \
&connectionManager,  QHBoxLayout* layout = new QHBoxLayout(d->ui.centralWidget);
     layout->setContentsMargins(0,0,0,0);
 
-    d->connectionManager = connectionManager;
-    d->protocol = protocol;
-    d->parameters = parameters;
+    d->connectionManager = info.cmName();
+    d->protocol = info.name();
+    d->parameters = info.parameters();
     d->parameterValues = parameterValues;
 
     connect(d->ui.advancedButton, SIGNAL(clicked()),
diff --git a/src/KCMTelepathyAccounts/account-edit-widget.h \
b/src/KCMTelepathyAccounts/account-edit-widget.h index 8724820..9e8ac68 100644
--- a/src/KCMTelepathyAccounts/account-edit-widget.h
+++ b/src/KCMTelepathyAccounts/account-edit-widget.h
@@ -35,9 +35,7 @@ class KDE_EXPORT AccountEditWidget : public QWidget
     Q_OBJECT
 
 public:
-    explicit AccountEditWidget(const QString &connectionManager,
-                               const QString &protocol,
-                               const Tp::ProtocolParameterList &parameters,
+    explicit AccountEditWidget(const Tp::ProtocolInfo &info,
                                const QVariantMap &parameterValues = QVariantMap(),
                                QWidget *parent = 0);
     virtual ~AccountEditWidget();
diff --git a/src/KCMTelepathyAccounts/protocol-item.cpp \
b/src/KCMTelepathyAccounts/protocol-item.cpp index 49f588d..2a68443 100644
--- a/src/KCMTelepathyAccounts/protocol-item.cpp
+++ b/src/KCMTelepathyAccounts/protocol-item.cpp
@@ -54,7 +54,7 @@ QString ProtocolItem::localizedName() const
     return m_localizedName;
 }
 
-Tp::ProtocolParameterList ProtocolItem::parameters() const
+Tp::ProtocolInfo ProtocolItem::protocolInfo() const
 {
     kDebug();
 
@@ -65,9 +65,9 @@ Tp::ProtocolParameterList ProtocolItem::parameters() const
 
     foreach (const Tp::ProtocolInfo &info, cm->protocols()) {
         if (info.name() == m_protocol)
-            return info.parameters();
+            return info;
     }
-    return Tp::ProtocolParameterList();
+    return Tp::ProtocolInfo();
 }
 
 #include "protocol-item.moc"
diff --git a/src/KCMTelepathyAccounts/protocol-item.h \
b/src/KCMTelepathyAccounts/protocol-item.h index 90b96ee..759956e 100644
--- a/src/KCMTelepathyAccounts/protocol-item.h
+++ b/src/KCMTelepathyAccounts/protocol-item.h
@@ -41,8 +41,7 @@ public:
 
     QString protocol() const;
     QString localizedName() const;
-
-    Tp::ProtocolParameterList parameters() const;
+    Tp::ProtocolInfo protocolInfo() const;
 
 private:
     QString m_protocol;
diff --git a/src/add-account-assistant.cpp b/src/add-account-assistant.cpp
index 6b7647f..184cf93 100644
--- a/src/add-account-assistant.cpp
+++ b/src/add-account-assistant.cpp
@@ -121,10 +121,6 @@ void AddAccountAssistant::next()
             kWarning() << "cmItem is invalid.";
         }
 
-        QString connectionManager = cmItem->connectionManager()->name();
-        QString protocol = item->protocol();
-        Tp::ProtocolParameterList parameters = item->parameters();
-
         // Delete the widgets for the next page if they already exist
         if (d->accountEditWidget) {
             d->accountEditWidget->deleteLater();
@@ -132,9 +128,7 @@ void AddAccountAssistant::next()
         }
 
         // Set up the account edit widget
-        d->accountEditWidget = new AccountEditWidget(connectionManager,
-                                                     protocol,
-                                                     parameters,
+        d->accountEditWidget = new AccountEditWidget(item->protocolInfo(),
                                                      QVariantMap(),
                                                      d->pageTwoWidget);
         d->pageTwoWidget->layout()->addWidget(d->accountEditWidget);
diff --git a/src/edit-account-dialog.cpp b/src/edit-account-dialog.cpp
index 27b0e73..b787dac 100644
--- a/src/edit-account-dialog.cpp
+++ b/src/edit-account-dialog.cpp
@@ -58,17 +58,14 @@ EditAccountDialog::EditAccountDialog(AccountItem *item, QWidget \
*parent)  
     // Get the protocol's parameters and values.
     Tp::ProtocolInfo protocolInfo = d->item->account()->protocolInfo();
-    Tp::ProtocolParameterList protocolParameters = protocolInfo.parameters();
     QVariantMap parameterValues = d->item->account()->parameters();
 
     // Set up the interface
-    d->widget = new AccountEditWidget(d->item->account()->cmName(),
-                                      d->item->account()->protocolName(),
-                                      protocolParameters,
+    d->widget = new AccountEditWidget(protocolInfo,
                                       parameterValues,
                                       this);
     setMainWidget(d->widget);
-    resize(400, 480);
+//    resize(400, 480);
 }
 
 EditAccountDialog::~EditAccountDialog()


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic