[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/network/telepathy-accounts-kcm/src/KCMTelepathyAccounts
From: George Goldberg <grundleborg () googlemail ! com>
Date: 2009-09-14 8:51:58
Message-ID: 1252918318.171544.29421.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1023213 by gberg:
Use the new validation code to validate all the parameters when we add/edit an account.
M +1 -1 mandatory-parameter-edit-widget.cpp
M +1 -1 optional-parameter-edit-widget.cpp
M +19 -0 parameter-edit-model.cpp
M +2 -0 parameter-edit-model.h
M +5 -0 parameter-edit-widget.cpp
M +2 -0 parameter-edit-widget.h
--- trunk/playground/network/telepathy-accounts-kcm/src/KCMTelepathyAccounts/mandatory-parameter-edit-widget.cpp \
#1023212:1023213 @@ -60,7 +60,7 @@
}
}
- return true;
+ return ParameterEditWidget::validateParameterValues();
}
--- trunk/playground/network/telepathy-accounts-kcm/src/KCMTelepathyAccounts/optional-parameter-edit-widget.cpp \
#1023212:1023213 @@ -52,7 +52,7 @@
kDebug();
// TODO: Implement me!
- return true;
+ return ParameterEditWidget::validateParameterValues();
}
--- trunk/playground/network/telepathy-accounts-kcm/src/KCMTelepathyAccounts/parameter-edit-model.cpp \
#1023212:1023213 @@ -22,7 +22,10 @@
#include "parameter-item.h"
+#include <KApplication>
#include <KDebug>
+#include <KLocale>
+#include <KMessageBox>
#include <QtGui/QValidator>
@@ -152,6 +155,22 @@
return values;
}
+bool ParameterEditModel::validateParameterValues()
+{
+ foreach (ParameterItem *item, m_items) {
+ if (item->validity() != QValidator::Acceptable) {
+ // Display a more helpful error here.
+ KMessageBox::error(QApplication::activeWindow (),
+ i18n("\"<b>%1</b>\" is not an acceptable value for <b>%2</b>")
+ .arg(item->value().toString())
+ .arg(item->localizedName()));
+ return false;
+ }
+ }
+ return true;
+}
+
+
#include "parameter-edit-model.moc"
--- trunk/playground/network/telepathy-accounts-kcm/src/KCMTelepathyAccounts/parameter-edit-model.h \
#1023212:1023213 @@ -57,6 +57,8 @@
void addItem(Tp::ProtocolParameter *parameter, const QVariant &originalValue);
QMap<Tp::ProtocolParameter*, QVariant> parameterValues() const;
+ bool validateParameterValues();
+
private:
QList<ParameterItem*> m_items;
};
--- trunk/playground/network/telepathy-accounts-kcm/src/KCMTelepathyAccounts/parameter-edit-widget.cpp \
#1023212:1023213 @@ -86,6 +86,11 @@
d->model->setData(index, value, role);
}
+bool ParameterEditWidget::validateParameterValues()
+{
+ return d->model->validateParameterValues();
+}
+
#include "parameter-edit-widget.moc"
--- trunk/playground/network/telepathy-accounts-kcm/src/KCMTelepathyAccounts/parameter-edit-widget.h \
#1023212:1023213 @@ -39,6 +39,8 @@
virtual QMap<Tp::ProtocolParameter*, QVariant> parameterValues() const;
+ virtual bool validateParameterValues();
+
private Q_SLOTS:
void onDelegateDataChanged(const QModelIndex &index, const QVariant &value, int role);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic