[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:59:30 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-accounts-kcm.git;a=commitdiff;h=5a366cb
The following commit has been merged in the master branch:
commit 5a366cbc34414b6bdbf69cbfa22f3d203c1a1204
Author: David Edmundson <kde at davidedmundson.co.uk>
Date: Sat Apr 23 00:34:18 2011 +0100
Updated parameter edit model to keep track of profile parameters
Removed work around that set default value on first creation based on profile parameter.
---
src/KCMTelepathyAccounts/parameter-edit-model.cpp | 19 +++++++++++++++----
src/KCMTelepathyAccounts/parameter-edit-model.h | 4 ++--
src/KCMTelepathyAccounts/parameter-item.cpp | 17 +++++++++++++++++
src/KCMTelepathyAccounts/parameter-item.h | 7 +++++++
src/add-account-assistant.cpp | 6 +-----
src/edit-account-dialog.cpp | 2 +-
6 files changed, 43 insertions(+), 12 deletions(-)
diff --git a/src/KCMTelepathyAccounts/parameter-edit-model.cpp b/src/KCMTelepathyAccounts/parameter-edit-model.cpp
index ccbe0d7..e0040b9 100644
--- a/src/KCMTelepathyAccounts/parameter-edit-model.cpp
+++ b/src/KCMTelepathyAccounts/parameter-edit-model.cpp
@@ -173,7 +173,7 @@ Tp::ProtocolParameter ParameterEditModel::parameter(const QString ¶meterName
}
-void ParameterEditModel::addItem(const Tp::ProtocolParameter ¶meter, const QVariant &originalValue)
+void ParameterEditModel::addItem(const Tp::ProtocolParameter ¶meter, const Tp::Profile::Parameter &profileParameter, const QVariant &originalValue)
{
// Check we are not creating duplicate items.
foreach (const ParameterItem *item, m_items) {
@@ -184,14 +184,25 @@ void ParameterEditModel::addItem(const Tp::ProtocolParameter ¶meter, const Q
// Create a new ParameterItem and add it to the list.
beginInsertRows(QModelIndex(), m_items.size(), m_items.size());
- m_items.append(new ParameterItem(parameter, originalValue, this));
+ m_items.append(new ParameterItem(parameter, profileParameter, originalValue, this));
endInsertRows();
}
-void ParameterEditModel::addItems(const Tp::ProtocolParameterList& parameters, const QVariantMap& parameterValues)
+void ParameterEditModel::addItems(const Tp::ProtocolParameterList ¶meters, const Tp::Profile::ParameterList &profileParameters, const QVariantMap ¶meterValues)
{
foreach (const Tp::ProtocolParameter ¶meter, parameters) {
- addItem(parameter, parameterValues[parameter.name()]);
+
+ Tp::Profile::Parameter relevantProfileParameter;
+
+ //try and find the correct profile parameter, if it can't be found leave it as empty.
+ foreach(Tp::Profile::Parameter profileParameter, profileParameters) {
+ if (profileParameter.name() == parameter.name()) {
+ relevantProfileParameter = profileParameter;
+ break;
+ }
+ }
+
+ addItem(parameter, relevantProfileParameter, parameterValues[parameter.name()]);
}
}
diff --git a/src/KCMTelepathyAccounts/parameter-edit-model.h b/src/KCMTelepathyAccounts/parameter-edit-model.h
index 27e3235..8083fcb 100644
--- a/src/KCMTelepathyAccounts/parameter-edit-model.h
+++ b/src/KCMTelepathyAccounts/parameter-edit-model.h
@@ -68,8 +68,8 @@ public:
QModelIndex indexForParameter(const Tp::Profile::Parameter ¶meter) const;
Tp::ProtocolParameter parameter(const QString ¶meterName) const;
- void addItem(const Tp::ProtocolParameter ¶meter, const QVariant &originalValue);
- void addItems(const Tp::ProtocolParameterList ¶meters, const QVariantMap ¶meterValues = QVariantMap());
+ void addItem(const Tp::ProtocolParameter ¶meter, const Tp::Profile::Parameter &profileParameter, const QVariant &originalValue);
+ void addItems(const Tp::ProtocolParameterList ¶meters, const Tp::Profile::ParameterList &profileParameters, const QVariantMap ¶meterValues = QVariantMap());
Tp::ProtocolParameterList parameters() const;
diff --git a/src/KCMTelepathyAccounts/parameter-item.cpp b/src/KCMTelepathyAccounts/parameter-item.cpp
index c7d827a..3bf88c4 100644
--- a/src/KCMTelepathyAccounts/parameter-item.cpp
+++ b/src/KCMTelepathyAccounts/parameter-item.cpp
@@ -25,15 +25,22 @@
#include <KDebug>
ParameterItem::ParameterItem(const Tp::ProtocolParameter ¶meter,
+ const Tp::Profile::Parameter &profileParameter,
const QVariant &originalValue,
QObject *parent)
: QObject(parent),
m_parameter(parameter),
+ m_profileParameter(profileParameter),
m_originalValue(originalValue)
{
// To begin with, the current value is the original value.
m_currentValue = m_originalValue;
+ //if no default value is set, use the value from the profile (if it exists)
+ if (m_currentValue.isNull()) {
+ m_currentValue = profileParameter.value();
+ }
+
// Set the localized name with the value from the dictionary if possible.
m_localizedName = Dictionary::instance()->string(parameter.name());
@@ -84,11 +91,21 @@ bool ParameterItem::isRequiredForRegistration() const
return m_parameter.isRequiredForRegistration();
}
+bool ParameterItem::isMandatory() const
+{
+ return m_profileParameter.isMandatory();
+}
+
const Tp::ProtocolParameter ParameterItem::parameter() const
{
return m_parameter;
}
+const Tp::Profile::Parameter ParameterItem::profileParameter() const
+{
+ return m_profileParameter;
+}
+
QValidator::State ParameterItem::validity() const
{
return m_validity;
diff --git a/src/KCMTelepathyAccounts/parameter-item.h b/src/KCMTelepathyAccounts/parameter-item.h
index 047aa57..7f9f6b7 100644
--- a/src/KCMTelepathyAccounts/parameter-item.h
+++ b/src/KCMTelepathyAccounts/parameter-item.h
@@ -26,6 +26,8 @@
#include <QtGui/QValidator>
#include <TelepathyQt4/ConnectionManager>
+#include <TelepathyQt4/Profile>
+
class ParameterItem : public QObject
{
@@ -34,6 +36,7 @@ class ParameterItem : public QObject
public:
ParameterItem(const Tp::ProtocolParameter ¶meter,
+ const Tp::Profile::Parameter &profileParameter,
const QVariant &originalValue,
QObject *parent = 0);
virtual ~ParameterItem();
@@ -45,7 +48,10 @@ public:
bool isSecret() const;
bool isRequired() const;
bool isRequiredForRegistration() const;
+ /** Returns true if the item is from a profile and should _not_ be changed*/
+ bool isMandatory() const;
const Tp::ProtocolParameter parameter() const;
+ const Tp::Profile::Parameter profileParameter() const;
QValidator::State validity() const;
void setValue(const QVariant &value);
@@ -53,6 +59,7 @@ public:
private:
Tp::ProtocolParameter m_parameter;
+ Tp::Profile::Parameter m_profileParameter;
const QVariant m_originalValue;
QVariant m_currentValue;
QString m_localizedName;
diff --git a/src/add-account-assistant.cpp b/src/add-account-assistant.cpp
index dcfaa5a..85bc3e8 100644
--- a/src/add-account-assistant.cpp
+++ b/src/add-account-assistant.cpp
@@ -256,11 +256,7 @@ void AddAccountAssistant::pageTwo()
// Add the parameters to the model.
ParameterEditModel *parameterModel = new ParameterEditModel(this);
- parameterModel->addItems(parameters);
-
- foreach(const Tp::Profile::Parameter ¶meter, d->currentProfileItem->profile()->parameters()) {
- parameterModel->setData(parameterModel->indexForParameter(parameter), parameter.value(), Qt::EditRole);
- }
+ parameterModel->addItems(parameters, d->currentProfileItem->profile()->parameters());
// Delete account previous widget if it already existed.
if (d->accountEditWidget) {
diff --git a/src/edit-account-dialog.cpp b/src/edit-account-dialog.cpp
index 5cc5eb8..edf41bf 100644
--- a/src/edit-account-dialog.cpp
+++ b/src/edit-account-dialog.cpp
@@ -67,7 +67,7 @@ EditAccountDialog::EditAccountDialog(AccountItem *item, QWidget *parent)
// Add the parameters to the model.
ParameterEditModel *parameterModel = new ParameterEditModel(this);
- parameterModel->addItems(parameters, parameterValues);
+ parameterModel->addItems(parameters, d->item->account()->profile()->parameters(), parameterValues);
// Set up the interface
d->widget = new AccountEditWidget(d->item->account()->profile(),
--
ktp-accounts-kcm packaging
More information about the pkg-kde-commits
mailing list