[vlmc-devel] commit: Wizzard: Applying HACKING to GeneralPage ( =?UTF-8?Q?Hugo=20Beauz=C3=A9e=2DLuyssen?==?UTF-8?Q?=20?=)

git at videolan.org git at videolan.org
Sat Nov 27 15:34:05 CET 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Sat Nov 27 14:20:36 2010 +0100| [d27ce67e42bfea702ff0e1b3f72f3819f750a830] | committer: Hugo Beauzée-Luyssen 

Wizzard: Applying HACKING to GeneralPage

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=d27ce67e42bfea702ff0e1b3f72f3819f750a830
---

 src/Gui/wizard/GeneralPage.cpp |   65 ++++++++++++++++++++++------------------
 src/Gui/wizard/GeneralPage.h   |   24 +++++++-------
 2 files changed, 48 insertions(+), 41 deletions(-)

diff --git a/src/Gui/wizard/GeneralPage.cpp b/src/Gui/wizard/GeneralPage.cpp
index b30c7a5..bd030cf 100644
--- a/src/Gui/wizard/GeneralPage.cpp
+++ b/src/Gui/wizard/GeneralPage.cpp
@@ -51,7 +51,8 @@ GeneralPage::GeneralPage( QWidget *parent ) :
     registerField( "projectName*", ui.lineEditName );
 }
 
-void GeneralPage::changeEvent( QEvent *e )
+void
+GeneralPage::changeEvent( QEvent *e )
 {
     QWizardPage::changeEvent( e );
     switch ( e->type() )
@@ -64,19 +65,21 @@ void GeneralPage::changeEvent( QEvent *e )
     }
 }
 
-int GeneralPage::nextId() const
+int
+GeneralPage::nextId() const
 {
     return ProjectWizard::Page_Video;
 }
 
-void GeneralPage::initializePage()
+void
+GeneralPage::initializePage()
 {
     //Since this is a new project, it will be unnamed
-    QString projectName = ProjectManager::unNamedProject;
+    QString     projectName = ProjectManager::unNamedProject;
     ui.lineEditName->setText( projectName );
 
     //fetching the global workspace path
-    QString workspacePath = VLMC_GET_STRING( "general/DefaultProjectLocation" );
+    QString     workspacePath = VLMC_GET_STRING( "general/DefaultProjectLocation" );
     ui.lineEditWorkspace->setText( workspacePath );
 
     updateProjectLocation();
@@ -84,15 +87,16 @@ void GeneralPage::initializePage()
 
 void GeneralPage::cleanupPage()
 {
-
 }
 
-bool GeneralPage::validatePage()
+bool
+GeneralPage::validatePage()
 {
-    SettingsManager* sManager = SettingsManager::getInstance();
+    SettingsManager     *sManager = SettingsManager::getInstance();
 
-    QString defaultProjectName = ProjectManager::unNamedProject;
-    if ( ui.lineEditName->text().isEmpty() || ui.lineEditName->text() == defaultProjectName )
+    const QString       &defaultProjectName = ProjectManager::unNamedProject;
+    if ( ui.lineEditName->text().isEmpty() ||
+         ui.lineEditName->text() == defaultProjectName )
     {
         QMessageBox::information( this, tr( "Form is incomplete" ),
                                   tr( "The project name must be filled." ) );
@@ -107,7 +111,7 @@ bool GeneralPage::validatePage()
         return false;
     }
 
-    QVariant projectName( ui.lineEditName->text() );
+    QVariant    projectName( ui.lineEditName->text() );
     sManager->setValue( "general/ProjectName", projectName, SettingsManager::Project );
 
     //Create the project directory in the workspace dir.
@@ -120,18 +124,21 @@ bool GeneralPage::validatePage()
     return true;
 }
 
-void GeneralPage::openWorkspaceDirectory()
+void
+GeneralPage::openWorkspaceDirectory()
 {
-    QString workspace = QFileDialog::getExistingDirectory( this,
+    QString     workspace = QFileDialog::getExistingDirectory( this,
                                                            "Choose a workspace directory",
                                                            QDir::homePath() );
-    if ( workspace.isEmpty() ) return;
+    if ( workspace.isEmpty() )
+        return;
     ui.lineEditWorkspace->setText( workspace );
 }
 
-void GeneralPage::updateProjectLocation()
+void
+GeneralPage::updateProjectLocation()
 {
-    QString workspacePath = ui.lineEditWorkspace->text();
+    QString     workspacePath = ui.lineEditWorkspace->text();
     if ( workspacePath.isEmpty() )
     {
         ui.lineEditProjectLocation->setText( tr( "Missing workspace location" ) );
@@ -139,9 +146,9 @@ void GeneralPage::updateProjectLocation()
     }
     else
     {
-        QString pName = ui.lineEditName->text().replace( ' ', '_' );
-        QDir workspaceDir( workspacePath );
-        QDir projectDir( QString( "%1/%2" ).arg( workspacePath, pName ) );
+        QString     pName = ui.lineEditName->text().replace( ' ', '_' );
+        QDir        workspaceDir( workspacePath );
+        QDir        projectDir( QString( "%1/%2" ).arg( workspacePath, pName ) );
 
         ui.lineEditProjectLocation->setText( projectDir.absolutePath() );
 
@@ -153,18 +160,18 @@ void GeneralPage::updateProjectLocation()
         }
 
         if ( !workspaceDir.exists() )
-            ui.lineEditProjectLocation->setPalette( pInvalid );
-        else
-        {
-            if ( projectDir.exists() )
-                ui.lineEditProjectLocation->setPalette( pInvalid );
-            else
-                ui.lineEditProjectLocation->setPalette( pValid );
-        }
+            setValidity( false );
+        else //Invalidate the path if the project directory already exists
+            setValidity( !projectDir.exists() );
     }
 }
 
-void GeneralPage::setWorkspaceStatus( bool /*valid*/ )
+void
+GeneralPage::setValidity( bool status )
 {
-
+    if ( status == true )
+        ui.lineEditProjectLocation->setPalette( pValid );
+    else
+        ui.lineEditProjectLocation->setPalette( pInvalid );
+    m_valid = status;
 }
diff --git a/src/Gui/wizard/GeneralPage.h b/src/Gui/wizard/GeneralPage.h
index 27f0f7a..6e02d7d 100644
--- a/src/Gui/wizard/GeneralPage.h
+++ b/src/Gui/wizard/GeneralPage.h
@@ -32,24 +32,24 @@ public:
     GeneralPage( QWidget *parent = 0 );
 
 protected:
-    virtual void changeEvent( QEvent *e );
-    virtual int nextId() const;
-    virtual void initializePage();
-    virtual bool validatePage();
-    virtual void cleanupPage();
+    virtual void        changeEvent( QEvent *e );
+    virtual int         nextId() const;
+    virtual void        initializePage();
+    virtual bool        validatePage();
+    virtual void        cleanupPage();
 
 private:
-
+    void                setValidity( bool status );
 
 private slots:
-    void openWorkspaceDirectory();
-    void updateProjectLocation();
-    void setWorkspaceStatus( bool valid );
+    void                openWorkspaceDirectory();
+    void                updateProjectLocation();
 
 private:
-    Ui::GeneralPage ui;
-    QPalette pValid;
-    QPalette pInvalid;
+    Ui::GeneralPage     ui;
+    QPalette            pValid;
+    QPalette            pInvalid;
+    bool                m_valid;
 };
 
 #endif // GENERALPAGE_H



More information about the Vlmc-devel mailing list