Skip to content
Permalink
Browse files

Disable unavailable projects

  • Loading branch information
m-kuhn committed Aug 19, 2015
1 parent 9bce9ed commit 10dfb5bc9b169bfb67dea2f27628bd6524a9dcda
Showing with 23 additions and 5 deletions.
  1. +22 −5 src/app/qgswelcomepageitemsmodel.cpp
  2. +1 −0 src/app/qgswelcomepageitemsmodel.h
@@ -16,9 +16,10 @@
#include "qgswelcomepageitemsmodel.h"

#include <QPixmap>
#include <QFile>

QgsWelcomePageItemsModel::QgsWelcomePageItemsModel(QObject* parent)
: QAbstractListModel( parent )
QgsWelcomePageItemsModel::QgsWelcomePageItemsModel( QObject* parent )
: QAbstractListModel( parent )
{

}
@@ -31,15 +32,16 @@ void QgsWelcomePageItemsModel::setRecentProjects( const QList<RecentProjectData>
}


int QgsWelcomePageItemsModel::rowCount(const QModelIndex& parent) const
int QgsWelcomePageItemsModel::rowCount( const QModelIndex& parent ) const
{
Q_UNUSED( parent )
return mRecentProjects.size();
}

QVariant QgsWelcomePageItemsModel::data(const QModelIndex& index, int role) const
QVariant QgsWelcomePageItemsModel::data( const QModelIndex& index, int role ) const
{
switch ( role ) {
switch ( role )
{
case Qt::DisplayRole:
return mRecentProjects.at( index.row() ).title;
break;
@@ -54,8 +56,23 @@ QVariant QgsWelcomePageItemsModel::data(const QModelIndex& index, int role) cons

case Qt::ToolTipRole:
return mRecentProjects.at( index.row() ).path;
break;

default:
return QVariant();
}
}


Qt::ItemFlags QgsWelcomePageItemsModel::flags( const QModelIndex& index ) const
{
Qt::ItemFlags flags = QAbstractItemModel::flags( index );

const RecentProjectData& projectData = mRecentProjects.at( index.row() );

if ( !QFile::exists(( projectData.path ) ) )
flags &= ~Qt::ItemIsEnabled;

return flags;

}
@@ -37,6 +37,7 @@ class QgsWelcomePageItemsModel : public QAbstractListModel

int rowCount( const QModelIndex& parent ) const;
QVariant data( const QModelIndex& index, int role ) const;
Qt::ItemFlags flags( const QModelIndex& index ) const;

private:
QList<RecentProjectData> mRecentProjects;

0 comments on commit 10dfb5b

Please sign in to comment.
You can’t perform that action at this time.