[vlmc-devel] HACKINGS applied.

Rohit Yadav git at videolan.org
Fri Feb 11 01:35:00 CET 2011


vlmc | branch: master | Rohit Yadav <rohityadav89 at gmail.com> | Fri Feb 11 06:21:34 2011 +0530| [e721b2ba636b0d11a3760ffbb68cf747fb9d6da1] | committer: Rohit Yadav

HACKINGS applied.

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

 src/Gui/project/GuiProjectManager.cpp |    9 +++++
 src/Gui/project/GuiProjectManager.h   |    2 +
 src/Gui/wizard/WelcomePage.cpp        |   54 +++++++++++++++++++++++++-------
 src/Gui/wizard/WelcomePage.h          |    1 +
 src/Gui/wizard/ui/WelcomePage.ui      |   20 +++++++++---
 src/Project/ProjectManager.cpp        |   29 ++++++++++++++---
 src/Project/ProjectManager.h          |    1 +
 7 files changed, 94 insertions(+), 22 deletions(-)

diff --git a/src/Gui/project/GuiProjectManager.cpp b/src/Gui/project/GuiProjectManager.cpp
index 71da4c8..7137566 100644
--- a/src/Gui/project/GuiProjectManager.cpp
+++ b/src/Gui/project/GuiProjectManager.cpp
@@ -307,3 +307,12 @@ GUIProjectManager::loadProject()
         return ;
     loadProject( fileName );
 }
+
+void
+GUIProjectManager::removeProject( const QString &fileName )
+{
+    QFile   projectFile( fileName );
+    if ( !projectFile.exists() )
+        return;
+    ProjectManager::removeProject( fileName );
+}
diff --git a/src/Gui/project/GuiProjectManager.h b/src/Gui/project/GuiProjectManager.h
index 70cf46b..cf45322 100644
--- a/src/Gui/project/GuiProjectManager.h
+++ b/src/Gui/project/GuiProjectManager.h
@@ -64,6 +64,8 @@ public:
      *  This is handled here as there's no use for this in non-GUI mode.
      */
     void            loadProject( const QString& fileName );
+    
+    void            removeProject( const QString& fileName );
 
 protected:
     virtual void    failedToLoad( const QString &reason ) const;
diff --git a/src/Gui/wizard/WelcomePage.cpp b/src/Gui/wizard/WelcomePage.cpp
index e5eeb73..193ad55 100644
--- a/src/Gui/wizard/WelcomePage.cpp
+++ b/src/Gui/wizard/WelcomePage.cpp
@@ -46,6 +46,8 @@ WelcomePage::WelcomePage( QWidget* parent )
 
     connect( m_ui.openPushButton, SIGNAL( clicked() ),
              this, SLOT( loadProject() ) );
+    connect( m_ui.removeProjectButton, SIGNAL( clicked() ),
+             this, SLOT( removeProject() ) );
     connect( m_ui.projectsListWidget, SIGNAL( itemPressed(QListWidgetItem*) ),
              this, SLOT( selectOpenRadio() ) );
     connect( m_ui.projectsListWidget, SIGNAL( itemDoubleClicked(QListWidgetItem*) ),
@@ -62,7 +64,8 @@ WelcomePage::~WelcomePage()
     delete m_projectPath;
 }
 
-void WelcomePage::changeEvent( QEvent *e )
+void
+WelcomePage::changeEvent( QEvent *e )
 {
     switch ( e->type() )
     {
@@ -74,7 +77,8 @@ void WelcomePage::changeEvent( QEvent *e )
     }
 }
 
-int WelcomePage::nextId() const
+int
+WelcomePage::nextId() const
 {
     if ( m_ui.createRadioButton->isChecked() )
         return ProjectWizard::Page_General;
@@ -82,7 +86,8 @@ int WelcomePage::nextId() const
         return ProjectWizard::Page_Open;
 }
 
-void WelcomePage::initializePage()
+void
+WelcomePage::initializePage()
 {
     QSettings s;
 
@@ -91,7 +96,8 @@ void WelcomePage::initializePage()
     loadRecentsProjects();
 }
 
-bool WelcomePage::validatePage()
+bool
+WelcomePage::validatePage()
 {
     if ( m_ui.openRadioButton->isChecked() )
     {
@@ -109,12 +115,14 @@ bool WelcomePage::validatePage()
     return true;
 }
 
-void WelcomePage::cleanupPage()
+void
+WelcomePage::cleanupPage()
 {
 
 }
 
-void WelcomePage::loadRecentsProjects()
+void
+WelcomePage::loadRecentsProjects()
 {
     m_ui.projectsListWidget->clear();
     ProjectManager* pm = GUIProjectManager::getInstance();
@@ -130,7 +138,8 @@ void WelcomePage::loadRecentsProjects()
     }
 }
 
-void WelcomePage::loadProject()
+void
+WelcomePage::loadProject()
 {
     QString projectPath =
             QFileDialog::getOpenFileName( NULL, tr( "Select a project file" ),
@@ -163,30 +172,51 @@ void WelcomePage::loadProject()
     selectOpenRadio();
 }
 
-void WelcomePage::selectOpenRadio()
+void
+WelcomePage::removeProject()
+{
+    QList<QListWidgetItem*> selected = m_ui.projectsListWidget->selectedItems();
+    if ( selected.isEmpty() )
+        return;
+
+    const QString fileName = selected.at( 0 )->data( FilePath ).toString();
+    if ( fileName.isEmpty() )
+        return;
+
+    GUIProjectManager::getInstance()->removeProject( fileName );
+    loadRecentsProjects(); // Reload recent projects
+}
+
+void
+WelcomePage::selectOpenRadio()
 {
     m_ui.openRadioButton->setChecked( true );
+    m_ui.removeProjectButton->setEnabled( true );
 }
 
-void WelcomePage::projectDoubleClicked( QListWidgetItem* item )
+void
+WelcomePage::projectDoubleClicked( QListWidgetItem* item )
 {
     Q_UNUSED( item );
     if ( wizard() )
         wizard()->next();
 }
 
-QString WelcomePage::projectPath()
+QString
+WelcomePage::projectPath()
 {
     return *m_projectPath;
 }
 
-void WelcomePage::setProjectPath( const QString& path )
+void
+WelcomePage::setProjectPath( const QString& path )
 {
     m_projectPath->clear();
     m_projectPath->append( path );
 }
 
-void WelcomePage::hideWizardAtStartup( bool hidden )
+void
+WelcomePage::hideWizardAtStartup( bool hidden )
 {
     QSettings s;
     s.setValue( "ShowWizardStartup", !hidden );
diff --git a/src/Gui/wizard/WelcomePage.h b/src/Gui/wizard/WelcomePage.h
index 1ba4dae..932f7b2 100644
--- a/src/Gui/wizard/WelcomePage.h
+++ b/src/Gui/wizard/WelcomePage.h
@@ -50,6 +50,7 @@ class WelcomePage : public QWizardPage
 
     private slots:
         void loadProject();
+        void removeProject();
         void loadRecentsProjects();
         void projectDoubleClicked( QListWidgetItem* item );
         void selectOpenRadio();
diff --git a/src/Gui/wizard/ui/WelcomePage.ui b/src/Gui/wizard/ui/WelcomePage.ui
index 9d5f808..a8a1035 100644
--- a/src/Gui/wizard/ui/WelcomePage.ui
+++ b/src/Gui/wizard/ui/WelcomePage.ui
@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>521</width>
+    <width>551</width>
     <height>414</height>
    </rect>
   </property>
@@ -54,7 +54,7 @@ p, li { white-space: pre-wrap; }
      </property>
     </widget>
    </item>
-   <item row="6" column="1">
+   <item row="7" column="1">
     <spacer name="verticalSpacer">
      <property name="orientation">
       <enum>Qt::Vertical</enum>
@@ -83,7 +83,7 @@ p, li { white-space: pre-wrap; }
      </property>
     </spacer>
    </item>
-   <item row="4" column="1" rowspan="2">
+   <item row="4" column="1" rowspan="3">
     <widget class="QListWidget" name="projectsListWidget">
      <property name="sizePolicy">
       <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
@@ -100,7 +100,7 @@ p, li { white-space: pre-wrap; }
      </property>
     </widget>
    </item>
-   <item row="5" column="2">
+   <item row="6" column="2">
     <spacer name="verticalSpacer_3">
      <property name="orientation">
       <enum>Qt::Vertical</enum>
@@ -142,7 +142,7 @@ p, li { white-space: pre-wrap; }
      </property>
     </spacer>
    </item>
-   <item row="7" column="0" colspan="4">
+   <item row="8" column="0" colspan="4">
     <widget class="QCheckBox" name="hideStartupCheckBox">
      <property name="text">
       <string>Do not show at startup.</string>
@@ -152,6 +152,16 @@ p, li { white-space: pre-wrap; }
      </property>
     </widget>
    </item>
+   <item row="5" column="2">
+    <widget class="QPushButton" name="removeProjectButton">
+     <property name="enabled">
+      <bool>false</bool>
+     </property>
+     <property name="text">
+      <string>Remove</string>
+     </property>
+    </widget>
+   </item>
   </layout>
  </widget>
  <resources/>
diff --git a/src/Project/ProjectManager.cpp b/src/Project/ProjectManager.cpp
index 0568626..a34aec3 100644
--- a/src/Project/ProjectManager.cpp
+++ b/src/Project/ProjectManager.cpp
@@ -32,6 +32,7 @@
 #include "Workspace.h"
 
 #include <QDir>
+#include <QMessageBox>
 #include <QSettings>
 #include <QtDebug>
 #include <QXmlStreamWriter>
@@ -165,7 +166,21 @@ ProjectManager::loadProject( const QString& fileName )
     Library::getInstance()->loadProject( root );
 }
 
-void    ProjectManager::__saveProject( const QString &fileName )
+void
+ProjectManager::removeProject( const QString& fileName )
+{
+    // Remove all occurence of fileName
+    m_recentsProjects.removeAll( fileName );
+
+    if( !QFile::remove( fileName ) )
+        QMessageBox::warning( NULL, tr( "Can't delete project file" ),
+                          tr( "Can't delete this project file: %1\nPlease delete it manually." ).arg( fileName ) );
+    QSettings s;
+    s.setValue( "RecentsProjects", m_recentsProjects );
+}
+
+void
+ProjectManager::__saveProject( const QString &fileName )
 {
     QByteArray          projectString;
 
@@ -189,7 +204,8 @@ void    ProjectManager::__saveProject( const QString &fileName )
     file.write( projectString );
 }
 
-void    ProjectManager::emergencyBackup()
+void
+ProjectManager::emergencyBackup()
 {
     QString     name;
 
@@ -203,7 +219,8 @@ void    ProjectManager::emergencyBackup()
     s.sync();
 }
 
-bool    ProjectManager::isBackupFile( const QString& projectFile )
+bool
+ProjectManager::isBackupFile( const QString& projectFile )
 {
     return projectFile.endsWith( ProjectManager::backupSuffix );
 }
@@ -215,7 +232,8 @@ ProjectManager::createAutoSaveOutputFileName( const QString& baseName ) const
 }
 
 
-void    ProjectManager::appendToRecentProject( const QString& projectFile )
+void
+ProjectManager::appendToRecentProject( const QString& projectFile )
 {
     // Append the item to the recents list
     m_recentsProjects.removeAll( projectFile );
@@ -227,7 +245,8 @@ void    ProjectManager::appendToRecentProject( const QString& projectFile )
     s.setValue( "RecentsProjects", m_recentsProjects );
 }
 
-QString ProjectManager::projectName() const
+QString
+ProjectManager::projectName() const
 {
     if ( m_projectName.isEmpty() == true )
     {
diff --git a/src/Project/ProjectManager.h b/src/Project/ProjectManager.h
index 66622ad..921e221 100644
--- a/src/Project/ProjectManager.h
+++ b/src/Project/ProjectManager.h
@@ -48,6 +48,7 @@ public:
     static const QString    backupSuffix;
 
     void            loadProject( const QString& fileName );
+    void            removeProject( const QString& fileName );
     QStringList     recentsProjects() const;
     virtual bool    closeProject();
     virtual void    saveProject( const QString &outputFileName );



More information about the Vlmc-devel mailing list