[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:30 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-accounts-kcm.git;a=commitdiff;h=60620bd
The following commit has been merged in the master branch:
commit 60620bd9f7767930c7705e8a62fa9d12cd4e0b00
Author: David Edmundson <kde at davidedmundson.co.uk>
Date: Sun Jan 2 20:54:16 2011 +0000
Compile against Telepathy-Qt4 0.5
Changed account abstract-account-parameters-widget.h to return
QVariantMap of parameterValues() instead of trying to
QMap<ParameterItem,QString> which didn't compile.
There didn't appear to be a reason for doing this as it was just copied
to a QVariantMap directly after anyway.
Note that the code now doesn't remove any parameters which have the same
value as the default. This didn't seem to be a step required by
Telepathy.
Also updated parameter-edit-model to always return the value in the type
requested by the ProtocolParameter.
---
.../abstract-account-parameters-widget.h | 2 +-
src/KCMTelepathyAccounts/account-edit-widget.cpp | 31 +++++++--------
src/KCMTelepathyAccounts/account-edit-widget.h | 2 +-
src/KCMTelepathyAccounts/parameter-edit-model.cpp | 10 +++--
src/KCMTelepathyAccounts/parameter-edit-model.h | 4 +-
src/KCMTelepathyAccounts/parameter-edit-widget.cpp | 6 +--
src/KCMTelepathyAccounts/parameter-edit-widget.h | 2 +-
src/KCMTelepathyAccounts/parameter-item.cpp | 20 +++++-----
src/KCMTelepathyAccounts/parameter-item.h | 6 +--
src/KCMTelepathyAccounts/protocol-item.cpp | 6 +--
src/account-item.cpp | 5 ++-
src/add-account-assistant.cpp | 34 ++++++-----------
src/edit-account-dialog.cpp | 44 +++++++---------------
13 files changed, 72 insertions(+), 100 deletions(-)
diff --git a/src/KCMTelepathyAccounts/abstract-account-parameters-widget.h b/src/KCMTelepathyAccounts/abstract-account-parameters-widget.h
index 6357b4e..a7e7c2d 100644
--- a/src/KCMTelepathyAccounts/abstract-account-parameters-widget.h
+++ b/src/KCMTelepathyAccounts/abstract-account-parameters-widget.h
@@ -39,7 +39,7 @@ public:
QWidget *parent = 0);
virtual ~AbstractAccountParametersWidget();
- virtual QMap<Tp::ProtocolParameter*, QVariant> parameterValues() const = 0;
+ virtual QVariantMap parameterValues() const = 0;
virtual Tp::ProtocolParameterList parameters() const;
virtual bool validateParameterValues();
diff --git a/src/KCMTelepathyAccounts/account-edit-widget.cpp b/src/KCMTelepathyAccounts/account-edit-widget.cpp
index b554db7..9bbac46 100644
--- a/src/KCMTelepathyAccounts/account-edit-widget.cpp
+++ b/src/KCMTelepathyAccounts/account-edit-widget.cpp
@@ -48,7 +48,7 @@ public:
AbstractAccountUi *accountUi;
Ui::AccountEditWidget ui;
AbstractAccountParametersWidget *mainOptionsWidget;
- QMap<Tp::ProtocolParameter*, QVariant> advancedParameterValues;
+ QVariantMap advancedParameterValues;
};
AccountEditWidget::AccountEditWidget(const QString &connectionManager,
@@ -91,19 +91,13 @@ bool AccountEditWidget::validateParameterValues() const
return d->mainOptionsWidget->validateParameterValues();
}
-QMap<Tp::ProtocolParameter*, QVariant> AccountEditWidget::parameterValues() const
+QVariantMap AccountEditWidget::parameterValues() const
{
- QMap<Tp::ProtocolParameter*, QVariant> values;
+ QVariantMap values;
values = d->mainOptionsWidget->parameterValues();
// append the advanced options, if any
- QMap<Tp::ProtocolParameter*, QVariant>::const_iterator paramIter;
- paramIter = d->advancedParameterValues.constBegin();
- while (paramIter != d->advancedParameterValues.constEnd()) {
- values.insert(paramIter.key(), paramIter.value());
- paramIter++;
- }
-
+ values.unite(d->advancedParameterValues);
return values;
}
@@ -111,8 +105,8 @@ void AccountEditWidget::loadWidgets()
{
Tp::ProtocolParameterList mandatoryParameters;
- foreach (Tp::ProtocolParameter *parameter, d->parameters) {
- if (parameter->isRequired())
+ foreach (Tp::ProtocolParameter parameter, d->parameters) {
+ if (parameter.isRequired())
mandatoryParameters.append(parameter);
}
@@ -135,9 +129,9 @@ void AccountEditWidget::loadWidgets()
bool paramFound = false;
while(paramIter != params.constEnd()) {
paramFound = false;
- foreach (Tp::ProtocolParameter *parameter, d->parameters) {
- if ((parameter->name() == paramIter.key()) &&
- (parameter->type() == paramIter.value())) {
+ foreach (Tp::ProtocolParameter parameter, d->parameters) {
+ if ((parameter.name() == paramIter.key()) &&
+ (parameter.type() == paramIter.value())) {
mandatoryParameters.removeAll(parameter);
paramFound = true;
}
@@ -180,6 +174,7 @@ void AccountEditWidget::onAdvancedClicked()
dialog.setMainWidget(advancedWidget);
// loop until the entered values are ok or the user cancels the dialog
+
while(true) {
if (dialog.exec() == KDialog::Accepted) {
// validate the parameter values
@@ -189,11 +184,13 @@ void AccountEditWidget::onAdvancedClicked()
// at this point the values are fine
d->advancedParameterValues = advancedWidget->parameterValues();
// update the parameter values in case the dialog is opened again
- QMap<Tp::ProtocolParameter*,QVariant>::const_iterator paramIter;
+ //FIXME this concept of parameters and advanced parameter values get merged here. This seems broken.
+
+ QVariantMap::const_iterator paramIter;
paramIter = d->advancedParameterValues.constBegin();
while (paramIter != d->advancedParameterValues.constEnd())
{
- d->parameterValues[paramIter.key()->name()] = paramIter.value();
+ d->parameterValues[paramIter.key()] = paramIter.value();
paramIter++;
}
diff --git a/src/KCMTelepathyAccounts/account-edit-widget.h b/src/KCMTelepathyAccounts/account-edit-widget.h
index 4c78338..d17b43f 100644
--- a/src/KCMTelepathyAccounts/account-edit-widget.h
+++ b/src/KCMTelepathyAccounts/account-edit-widget.h
@@ -40,7 +40,7 @@ public:
virtual ~AccountEditWidget();
virtual bool validateParameterValues() const;
- virtual QMap<Tp::ProtocolParameter*, QVariant> parameterValues() const;
+ virtual QVariantMap parameterValues() const;
private Q_SLOTS:
void onAdvancedClicked();
diff --git a/src/KCMTelepathyAccounts/parameter-edit-model.cpp b/src/KCMTelepathyAccounts/parameter-edit-model.cpp
index 0fe52a1..39e7f97 100644
--- a/src/KCMTelepathyAccounts/parameter-edit-model.cpp
+++ b/src/KCMTelepathyAccounts/parameter-edit-model.cpp
@@ -133,7 +133,7 @@ bool ParameterEditModel::setData(const QModelIndex &index, const QVariant &value
}
}
-void ParameterEditModel::addItem(Tp::ProtocolParameter *parameter, const QVariant &originalValue)
+void ParameterEditModel::addItem(Tp::ProtocolParameter parameter, const QVariant &originalValue)
{
kDebug();
// FIXME: Check we are not creating duplicate items.
@@ -144,12 +144,14 @@ void ParameterEditModel::addItem(Tp::ProtocolParameter *parameter, const QVarian
endInsertRows();
}
-QMap<Tp::ProtocolParameter*, QVariant> ParameterEditModel::parameterValues() const
+QVariantMap ParameterEditModel::parameterValues() const
{
- QMap<Tp::ProtocolParameter*, QVariant> values;
+ QVariantMap values;
foreach (ParameterItem *item, m_items) {
- values.insert(item->parameter(), item->value());
+ QVariant value = item->value();
+ value.convert(item->type());
+ values.insert(item->parameter().name(), value);
}
return values;
diff --git a/src/KCMTelepathyAccounts/parameter-edit-model.h b/src/KCMTelepathyAccounts/parameter-edit-model.h
index 0c762ea..6511fc8 100644
--- a/src/KCMTelepathyAccounts/parameter-edit-model.h
+++ b/src/KCMTelepathyAccounts/parameter-edit-model.h
@@ -54,8 +54,8 @@ public:
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
virtual bool setData(const QModelIndex &index, const QVariant &value, int role);
- void addItem(Tp::ProtocolParameter *parameter, const QVariant &originalValue);
- QMap<Tp::ProtocolParameter*, QVariant> parameterValues() const;
+ void addItem(Tp::ProtocolParameter parameter, const QVariant &originalValue);
+ QVariantMap parameterValues() const;
bool validateParameterValues();
diff --git a/src/KCMTelepathyAccounts/parameter-edit-widget.cpp b/src/KCMTelepathyAccounts/parameter-edit-widget.cpp
index 187c39f..f818e3c 100644
--- a/src/KCMTelepathyAccounts/parameter-edit-widget.cpp
+++ b/src/KCMTelepathyAccounts/parameter-edit-widget.cpp
@@ -63,8 +63,8 @@ ParameterEditWidget::ParameterEditWidget(Tp::ProtocolParameterList parameters,
SLOT(onDelegateDataChanged(QModelIndex, QVariant, int)));
// Add the parameters to the model.
- foreach (Tp::ProtocolParameter *parameter, parameters) {
- d->model->addItem(parameter, values.value(parameter->name(), parameter->defaultValue()));
+ foreach (Tp::ProtocolParameter parameter, parameters) {
+ d->model->addItem(parameter, values.value(parameter.name(), parameter.defaultValue()));
}
}
@@ -75,7 +75,7 @@ ParameterEditWidget::~ParameterEditWidget()
delete d;
}
-QMap<Tp::ProtocolParameter*, QVariant> ParameterEditWidget::parameterValues() const
+QVariantMap ParameterEditWidget::parameterValues() const
{
return d->model->parameterValues();
}
diff --git a/src/KCMTelepathyAccounts/parameter-edit-widget.h b/src/KCMTelepathyAccounts/parameter-edit-widget.h
index 4d3b5a6..1c63b5f 100644
--- a/src/KCMTelepathyAccounts/parameter-edit-widget.h
+++ b/src/KCMTelepathyAccounts/parameter-edit-widget.h
@@ -37,7 +37,7 @@ public:
QWidget *parent = 0);
~ParameterEditWidget();
- virtual QMap<Tp::ProtocolParameter*, QVariant> parameterValues() const;
+ virtual QVariantMap parameterValues() const;
virtual bool validateParameterValues();
diff --git a/src/KCMTelepathyAccounts/parameter-item.cpp b/src/KCMTelepathyAccounts/parameter-item.cpp
index 318f175..781dcc4 100644
--- a/src/KCMTelepathyAccounts/parameter-item.cpp
+++ b/src/KCMTelepathyAccounts/parameter-item.cpp
@@ -24,23 +24,23 @@
#include <KDebug>
-ParameterItem::ParameterItem(Tp::ProtocolParameter *parameter,
+ParameterItem::ParameterItem(Tp::ProtocolParameter parameter,
const QVariant &originalValue,
QObject *parent)
: QObject(parent),
m_parameter(parameter),
m_originalValue(originalValue)
{
- kDebug() << "New parameter:" << parameter->name() << "of type:" << parameter->type() << "with value:" << m_originalValue;
+ kDebug() << "New parameter:" << parameter.name() << "of type:" << parameter.type() << "with value:" << m_originalValue;
// To begin with, the current value is the original value.
m_currentValue = m_originalValue;
// Set the localized name with the value from the dictionary if possible.
- m_localizedName = Dictionary::instance()->string(parameter->name());
+ m_localizedName = Dictionary::instance()->string(parameter.name());
if (m_localizedName.isEmpty()) {
- m_localizedName = parameter->name();
+ m_localizedName = parameter.name();
}
// Assume the default/un-altered value is valid.
@@ -54,7 +54,7 @@ ParameterItem::~ParameterItem()
QString ParameterItem::name() const
{
- return m_parameter->name();
+ return m_parameter.name();
}
QString ParameterItem::localizedName() const
@@ -64,7 +64,7 @@ QString ParameterItem::localizedName() const
QVariant::Type ParameterItem::type() const
{
- return m_parameter->type();
+ return m_parameter.type();
}
QVariant ParameterItem::value() const
@@ -74,20 +74,20 @@ QVariant ParameterItem::value() const
bool ParameterItem::isSecret() const
{
- return m_parameter->isSecret();
+ return m_parameter.isSecret();
}
bool ParameterItem::isRequired() const
{
- return m_parameter->isRequired();
+ return m_parameter.isRequired();
}
bool ParameterItem::isRequiredForRegistration() const
{
- return m_parameter->isRequiredForRegistration();
+ return m_parameter.isRequiredForRegistration();
}
-Tp::ProtocolParameter *ParameterItem::parameter()
+Tp::ProtocolParameter ParameterItem::parameter()
{
return m_parameter;
}
diff --git a/src/KCMTelepathyAccounts/parameter-item.h b/src/KCMTelepathyAccounts/parameter-item.h
index 14b1116..9f9aa33 100644
--- a/src/KCMTelepathyAccounts/parameter-item.h
+++ b/src/KCMTelepathyAccounts/parameter-item.h
@@ -33,7 +33,7 @@ class ParameterItem : public QObject
Q_DISABLE_COPY(ParameterItem);
public:
- ParameterItem(Tp::ProtocolParameter *parameter,
+ ParameterItem(Tp::ProtocolParameter parameter,
const QVariant &originalValue,
QObject *parent = 0);
virtual ~ParameterItem();
@@ -45,14 +45,14 @@ public:
bool isSecret() const;
bool isRequired() const;
bool isRequiredForRegistration() const;
- Tp::ProtocolParameter *parameter();
+ Tp::ProtocolParameter parameter();
QValidator::State validity() const;
void setValue(const QVariant &value);
void setValidity(QValidator::State validity);
private:
- Tp::ProtocolParameter *m_parameter;
+ Tp::ProtocolParameter m_parameter;
const QVariant m_originalValue;
QVariant m_currentValue;
QString m_localizedName;
diff --git a/src/KCMTelepathyAccounts/protocol-item.cpp b/src/KCMTelepathyAccounts/protocol-item.cpp
index 03ac0bc..c4acdce 100644
--- a/src/KCMTelepathyAccounts/protocol-item.cpp
+++ b/src/KCMTelepathyAccounts/protocol-item.cpp
@@ -63,9 +63,9 @@ Tp::ProtocolParameterList ProtocolItem::parameters() const
Tp::ConnectionManagerPtr cm = item->connectionManager();
- foreach (Tp::ProtocolInfo *info, cm->protocols()) {
- if (info->name() == m_protocol)
- return info->parameters();
+ foreach (Tp::ProtocolInfo info, cm->protocols()) {
+ if (info.name() == m_protocol)
+ return info.parameters();
}
return Tp::ProtocolParameterList();
}
diff --git a/src/account-item.cpp b/src/account-item.cpp
index 50afaa5..6072a63 100644
--- a/src/account-item.cpp
+++ b/src/account-item.cpp
@@ -100,10 +100,11 @@ void AccountItem::generateIcon()
{
kDebug();
- QString iconPath = account()->icon();
+ QString iconPath = account()->iconName();
//if the icon has not been setted, we use the protocol icon
+
if(iconPath.isEmpty()) {
- iconPath = QString("im-%1").arg(account()->protocol());
+ iconPath = QString("im-%1").arg(account()->protocolName());
}
delete m_icon;
diff --git a/src/add-account-assistant.cpp b/src/add-account-assistant.cpp
index 3933763..19e4f1c 100644
--- a/src/add-account-assistant.cpp
+++ b/src/add-account-assistant.cpp
@@ -160,7 +160,7 @@ void AddAccountAssistant::accept()
}
// Get the parameter values.
- QMap<Tp::ProtocolParameter*, QVariant> parameterValues;
+ QVariantMap parameterValues;
parameterValues = d->accountEditWidget->parameterValues();
// Get the ProtocolItem that was selected and the corresponding ConnectionManagerItem.
@@ -172,33 +172,23 @@ void AddAccountAssistant::accept()
return;
}
- // Merge the parameters into a QVariantMap for submitting to the Telepathy AM.
- QVariantMap parameters;
-
- foreach (Tp::ProtocolParameter *pp, parameterValues.keys()) {
- QVariant value = parameterValues.value(pp);
-
- // Don't try and add empty parameters or ones where the default value is still set.
- if ((!value.isNull()) && (value != pp->defaultValue())) {
-
- // Check for params where they are empty and the default is null.
- if (pp->type() == QVariant::String) {
- if ((pp->defaultValue() == QVariant()) && (value.toString().isEmpty())) {
- continue;
- }
- }
+ // kDebug() << "Parameters to add with:" << parameters;
- parameters.insert(pp->name(), value);
+ //remove any empty parameter values
+ QVariantMap::iterator i;
+ for (i = parameterValues.begin(); i != parameterValues.end(); ++i)
+ {
+ if (i.value().isNull())
+ {
+ parameterValues.remove(i.key());
}
}
- // kDebug() << "Parameters to add with:" << parameters;
-
// FIXME: Ask the user to submit a Display Name
Tp::PendingAccount *pa = d->accountManager->createAccount(connectionManagerItem->connectionManager()->name(),
protocolItem->protocol(),
- parameters.value("account").toString(),
- parameters);
+ parameterValues["account"].toString(),
+ parameterValues);
connect(pa,
SIGNAL(finished(Tp::PendingOperation*)),
@@ -240,7 +230,7 @@ void AddAccountAssistant::onAccountCreated(Tp::PendingOperation *op)
// Set the account icon
QString icon = QString("im-%1").arg(d->account->protocolName());
kDebug() << "Set account icon to: " << icon;
- d->account->setIcon(icon);
+ d->account->setIconName(icon);
kDebug() << "Calling set enabled.";
diff --git a/src/edit-account-dialog.cpp b/src/edit-account-dialog.cpp
index 73462f2..efe4227 100644
--- a/src/edit-account-dialog.cpp
+++ b/src/edit-account-dialog.cpp
@@ -57,13 +57,13 @@ EditAccountDialog::EditAccountDialog(AccountItem *item, QWidget *parent)
d->item = item;
// Get the protocol's parameters and values.
- Tp::ProtocolInfo *protocolInfo = d->item->account()->protocolInfo();
- Tp::ProtocolParameterList protocolParameters = protocolInfo->parameters();
+ 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()->protocol(),
+ d->item->account()->protocolName(),
protocolParameters,
parameterValues,
this);
@@ -87,38 +87,20 @@ void EditAccountDialog::accept()
}
// Get the mandatory parameters.
- QMap<Tp::ProtocolParameter*, QVariant> parameterValues;
- parameterValues = d->widget->parameterValues();
-
- // Merge the parameters into a QVariantMap for submitting to the Telepathy AM.
QVariantMap parameters;
- QStringList unsetParameters;
-
- foreach (Tp::ProtocolParameter *pp, parameterValues.keys()) {
- QVariant value = parameterValues.value(pp);
-
- // Unset null parameters.
- if (value.isNull()) {
- unsetParameters.append(pp->name());
- continue;
- }
+ parameters = d->widget->parameterValues();
- // Unset any parameters where the default value is equal to the current value.
- if (pp->defaultValue() == value) {
- unsetParameters.append(pp->name());
- continue;
- }
+ QStringList unsetParameters;
- // Unset any strings where the default is empty, and the value is an empty string
- if (pp->type() == QVariant::String) {
- if ((pp->defaultValue().isNull()) && value.toString().isEmpty()) {
- unsetParameters.append(pp->name());
- continue;
- }
+ //if the value is null for any parameter, don't set it, and add it to a list of parameters to remove.
+ QVariantMap::iterator i;
+ for (i = parameters.begin(); i != parameters.end(); ++i)
+ {
+ if (i.value().isNull())
+ {
+ unsetParameters.append(i.key());
+ parameters.remove(i.key());
}
-
- // Parameter has a valid value, so set it.
- parameters.insert(pp->name(), value);
}
// kDebug() << "Set parameters:" << parameters;
--
ktp-accounts-kcm packaging
More information about the pkg-kde-commits
mailing list