[vlmc-devel] [PATCH] GeneralPage: Refactor

Hugo Beauzée-Luyssen hugo at beauzee.fr
Mon Apr 4 10:20:18 CEST 2016


On 04/02/2016 01:16 PM, Yikai Lu wrote:
> Use C++11-style for-loop
> Declare invalid_char as a static const char[]
> ---
>   src/Gui/wizard/GeneralPage.cpp | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/src/Gui/wizard/GeneralPage.cpp b/src/Gui/wizard/GeneralPage.cpp
> index 4828049..a664c36 100644
> --- a/src/Gui/wizard/GeneralPage.cpp
> +++ b/src/Gui/wizard/GeneralPage.cpp
> @@ -29,6 +29,8 @@
>   #include "Settings/Settings.h"
>   #include "Project/Project.h"
>
> +static const char invalidChars[] = "/?:*\\|";
> +
>   GeneralPage::GeneralPage( QWidget *parent ) :
>       QWizardPage( parent )
>   {
> @@ -87,7 +89,6 @@ GeneralPage::validatePage()
>       if ( m_valid == false )
>           return false;
>       const QString       &defaultProjectName = Project::unNamedProject;
> -    QString invalid_char = "/?:*\\|";
>       if ( ui.lineEditName->text().isEmpty() ||
>            ui.lineEditName->text() == defaultProjectName )
>       {
> @@ -96,8 +97,8 @@ GeneralPage::validatePage()
>           ui.lineEditName->setFocus();
>           return false;
>       }
> -    for ( int i = 0; i < invalid_char.length() ; ++i )
> -        if ( ui.lineEditName->text().contains( invalid_char[i] ) )
> +    for ( const auto& c: invalidChars )
> +        if ( ui.lineEditName->text().contains( c ) )
>           {
>               QMessageBox::information( this, tr( "Invalid project name" ),
>                                         tr( "Special characters are not allowed" ) );
>
Applied, thanks!


More information about the Vlmc-devel mailing list