Commit bccc1bc4 authored by Ludovic Fauvet's avatar Ludovic Fauvet
Browse files

Wizard: show recently loaded projects

parent 417c731b
......@@ -24,6 +24,7 @@
#include <QPushButton>
#include <QVBoxLayout>
#include <QMessageBox>
#include <QFileInfo>
#include "WelcomePage.h"
WelcomePage::WelcomePage( QWidget* parent )
......@@ -33,6 +34,10 @@ WelcomePage::WelcomePage( QWidget* parent )
setTitle( tr( "Project wizard" ) );
setSubTitle( tr( "Open or create a project" ) );
connect( m_ui.openPushButton, SIGNAL( clicked() ),
this, SLOT( loadProject() ) );
loadRecentsProjects();
}
void WelcomePage::changeEvent( QEvent *e )
......@@ -67,3 +72,50 @@ bool WelcomePage::validatePage()
}
return true;
}
void WelcomePage::cleanupPage()
{
loadRecentsProjects();
}
void WelcomePage::loadRecentsProjects()
{
m_ui.projectsListWidget->clear();
ProjectManager* pm = ProjectManager::getInstance();
QStringList recents = pm->recentsProjects();
for ( int i = 0; i < recents.count(); ++i )
{
QFileInfo fi( recents.at( i ) );
QListWidgetItem* item = new QListWidgetItem( fi.fileName() );
item->setData( FilePath, fi.absoluteFilePath() );
m_ui.projectsListWidget->addItem( item );
}
}
void WelcomePage::loadProject()
{
ProjectManager* pm = ProjectManager::getInstance();
QString projectPath = pm->loadProjectFile();
QListWidgetItem* item = NULL;
for ( int i = 0; i < m_ui.projectsListWidget->count(); ++i )
{
item = m_ui.projectsListWidget->item( i );
if ( item->data( FilePath ).toString().contains( projectPath ) )
break;
item = NULL;
}
if ( !item )
{
QFileInfo fi( projectPath );
QListWidgetItem* item = new QListWidgetItem( fi.fileName() );
item->setData( FilePath, fi.absoluteFilePath() );
m_ui.projectsListWidget->addItem( item );
}
item->setSelected( true );
}
......@@ -25,6 +25,7 @@
#include <QWizardPage>
#include "ProjectWizard.h"
#include "ProjectManager.h"
#include "ui_WelcomePage.h"
class QWizard;
......@@ -33,6 +34,8 @@ class WelcomePage : public QWizardPage
{
Q_OBJECT
public:
enum { FilePath = Qt::UserRole + 1 };
WelcomePage( QWidget* parent = 0 );
~WelcomePage() { }
......@@ -41,6 +44,11 @@ class WelcomePage : public QWizardPage
protected:
virtual void changeEvent( QEvent *e );
virtual bool validatePage();
virtual void cleanupPage();
private slots:
void loadProject();
void loadRecentsProjects();
private:
Ui::WelcomePage m_ui;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment