From bb5759e84a986f358e415ef495c0173f571eb312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= <thorbjorn.lindeijer@nokia.com> Date: Fri, 20 Mar 2009 11:06:09 +0100 Subject: [PATCH] Fix error message when erasing the class name Now it kindly asks the user to enter a class name. As requested by Kavindra. :) --- .../utils/classnamevalidatinglineedit.cpp | 7 +++++-- src/libs/utils/newclasswidget.h | 21 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/libs/utils/classnamevalidatinglineedit.cpp b/src/libs/utils/classnamevalidatinglineedit.cpp index 86f86a124d0..64d2031a57c 100644 --- a/src/libs/utils/classnamevalidatinglineedit.cpp +++ b/src/libs/utils/classnamevalidatinglineedit.cpp @@ -84,8 +84,11 @@ bool ClassNameValidatingLineEdit::validate(const QString &value, QString *errorM if (errorMessage) *errorMessage = tr("The class name must not contain namespace delimiters."); return false; - } - if (!m_d->m_nameRegexp.exactMatch(value)) { + } else if (value.isEmpty()) { + if (errorMessage) + *errorMessage = tr("Please enter a class name."); + return false; + } else if (!m_d->m_nameRegexp.exactMatch(value)) { if (errorMessage) *errorMessage = tr("The class name contains invalid characters."); return false; diff --git a/src/libs/utils/newclasswidget.h b/src/libs/utils/newclasswidget.h index 15b21fcb0e6..674adf6c84b 100644 --- a/src/libs/utils/newclasswidget.h +++ b/src/libs/utils/newclasswidget.h @@ -43,11 +43,12 @@ namespace Utils { struct NewClassWidgetPrivate; -/* NewClassWidget: Utility widget for 'New Class' wizards. Prompts the user +/** + * NewClassWidget: Utility widget for 'New Class' wizards. Prompts the user * to enter a class name (optionally derived from some base class) and file * names for header, source and form files. Has some smart logic to derive - * the file names from the class name. */ - + * the file names from the class name. + */ class QWORKBENCH_UTILS_EXPORT NewClassWidget : public QWidget { Q_DISABLE_COPY(NewClassWidget) @@ -115,8 +116,10 @@ public slots: void setFormInputCheckable(bool v); void setFormInputChecked(bool v); - /* The name passed into the new class widget will be reformatted to be a - * valid class name. */ + /** + * The name passed into the new class widget will be reformatted to be a + * valid class name. + */ void setClassName(const QString &suggestedName); void setBaseClassName(const QString &); void setPath(const QString &path); @@ -127,13 +130,15 @@ public slots: void setAllowDirectories(bool v); void setLowerCaseFiles(bool v); - /* Suggest a class name from the base class by stripping the leading 'Q' + /** + * Suggest a class name from the base class by stripping the leading 'Q' * character. This will happen automagically if the base class combo - * changes until the class line edited is manually edited. */ + * changes until the class line edited is manually edited. + */ void suggestClassNameFromBase(); public slots: - // Trigger an update (after changing settings) + /** Trigger an update (after changing settings) */ void triggerUpdateFileNames(); private slots: -- GitLab