summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndi Fischer <[email protected]>2014-12-05 00:38:32 +0100
committerAndi Fischer <[email protected]>2014-12-05 00:38:32 +0100
commit5ad8664a2d8f2f44d8a8bec18a7b76ee98f67c6a (patch)
tree495934e117a8de05059555139d131a66437c993b
parentb55f200d97bd52ce6b1ba8200ede92d3b31319ce (diff)
Fix the usage of the validator.
-rw-r--r--umbrello/widgets/associationwidget.cpp18
-rw-r--r--umbrello/widgets/floatingtextwidget.cpp7
-rw-r--r--umbrello/widgets/objectwidget.cpp8
3 files changed, 19 insertions, 14 deletions
diff --git a/umbrello/widgets/associationwidget.cpp b/umbrello/widgets/associationwidget.cpp
index 488b34b..33f35ec 100644
--- a/umbrello/widgets/associationwidget.cpp
+++ b/umbrello/widgets/associationwidget.cpp
@@ -2982,7 +2982,8 @@ void AssociationWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent * me)
void AssociationWidget::slotMenuSelection(QAction* action)
{
QString oldText, newText;
- QRegExpValidator v(QRegExp(QLatin1String(".*")), 0);
+ QRegExpValidator validator(QRegExp(QLatin1String(".*")), 0);
+ int pos = 0;
Uml::AssociationType::Enum atype = associationType();
Uml::RoleType::Enum r = RoleType::B;
ListPopupMenu::MenuType sel = ListPopupMenu::typeFromAction(action);
@@ -3037,8 +3038,9 @@ void AssociationWidget::slotMenuSelection(QAction* action)
i18n("Multiplicity"),
i18n("Enter multiplicity:"),
QLineEdit::Normal,
- oldText, NULL); //FIXME KF5 ", &v);"
- if (newText != oldText) {
+ oldText, NULL);
+ if ((newText != oldText) &&
+ (validator.validate(newText, pos) == QValidator::Acceptable)) {
if (FloatingTextWidget::isTextValid(newText)) {
setMultiplicity(newText, r);
} else {
@@ -3057,8 +3059,9 @@ void AssociationWidget::slotMenuSelection(QAction* action)
i18n("Association Name"),
i18n("Enter association name:"),
QLineEdit::Normal,
- oldText, NULL); //FIXME KF5 ", &v);"
- if (newText != oldText) {
+ oldText, NULL);
+ if ((newText != oldText) &&
+ (validator.validate(newText, pos) == QValidator::Acceptable)) {
if (FloatingTextWidget::isTextValid(newText)) {
setName(newText);
} else {
@@ -3079,8 +3082,9 @@ void AssociationWidget::slotMenuSelection(QAction* action)
i18n("Role Name"),
i18n("Enter role name:"),
QLineEdit::Normal,
- oldText, NULL); //FIXME KF5 ", &v);"
- if (newText != oldText) {
+ oldText, NULL);
+ if ((newText != oldText) &&
+ (validator.validate(newText, pos) == QValidator::Acceptable)) {
if (FloatingTextWidget::isTextValid(newText)) {
setRoleName(newText, r);
} else {
diff --git a/umbrello/widgets/floatingtextwidget.cpp b/umbrello/widgets/floatingtextwidget.cpp
index aaa0d3b..580d0b9 100644
--- a/umbrello/widgets/floatingtextwidget.cpp
+++ b/umbrello/widgets/floatingtextwidget.cpp
@@ -390,7 +390,8 @@ Uml::TextRole::Enum FloatingTextWidget::textRole() const
*/
void FloatingTextWidget::handleRename()
{
- QRegExpValidator v(QRegExp(QLatin1String(".*")), 0);
+ QRegExpValidator validator(QRegExp(QLatin1String(".*")), 0);
+ int pos = 0;
QString t;
if (m_textRole == Uml::TextRole::RoleAName || m_textRole == Uml::TextRole::RoleBName) {
t = i18n("Enter role name:");
@@ -412,8 +413,8 @@ void FloatingTextWidget::handleRename()
QString newText = QInputDialog::getText(m_scene->activeView(),
i18n("Rename"), t,
QLineEdit::Normal,
- text(), &ok); //FIXME KF5 ", &v);"
- if (!ok || newText == text()) {
+ text(), &ok);
+ if (!ok || newText == text() || validator.validate(newText, pos) == QValidator::Invalid) {
return;
}
diff --git a/umbrello/widgets/objectwidget.cpp b/umbrello/widgets/objectwidget.cpp
index e619a0c..902472c 100644
--- a/umbrello/widgets/objectwidget.cpp
+++ b/umbrello/widgets/objectwidget.cpp
@@ -163,21 +163,21 @@ void ObjectWidget::slotMenuSelection(QAction* action)
case ListPopupMenu::mt_Rename_Object:
{
bool ok;
- QRegExpValidator* validator = new QRegExpValidator(QRegExp(QLatin1String(".*")), 0);
+ QRegExpValidator validator(QRegExp(QLatin1String(".*")), 0);
+ int pos = 0;
QString name = QInputDialog::getText(m_scene->activeView(),
i18n("Rename Object"),
i18n("Enter object name:"),
QLineEdit::Normal,
m_instanceName,
- &ok); //FIXME KF5 ", validator);"
- if (ok) {
+ &ok);
+ if (ok && validator.validate(name, pos) == QValidator::Acceptable) {
m_instanceName = name;
updateGeometry();
moveEvent(0);
update();
UMLApp::app()->document()->setModified(true);
}
- delete validator;
break;
}
case ListPopupMenu::mt_Properties: