[vlmc-devel] GeneralPage: Refactor

Yikai Lu git at videolan.org
Mon Apr 4 10:25:52 CEST 2016


vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Sat Apr  2 20:16:07 2016 +0900| [439950b69085dc9df475aea0783e36c2b892c2ff] | committer: Hugo Beauzée-Luyssen

GeneralPage: Refactor

Use C++11-style for-loop
Declare invalid_char as a static const char[]

Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

> https://code.videolan.org/videolan/vlmc/commit/439950b69085dc9df475aea0783e36c2b892c2ff
---

 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" ) );



More information about the Vlmc-devel mailing list