Skip to content

Commit

Permalink
[welcome page] add project projection information
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn authored and m-kuhn committed Sep 11, 2015
1 parent 116089e commit 107d911
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -1191,6 +1191,7 @@ void QgisApp::readSettings()
data.title = settings.value( "title" ).toString();
data.path = settings.value( "path" ).toString();
data.previewImagePath = settings.value( "previewImage" ).toString();
data.crs = settings.value( "crs" ).toString();
settings.endGroup();
mRecentProjects.append( data );
}
Expand Down Expand Up @@ -2786,6 +2787,8 @@ void QgisApp::saveRecentProjectPath( QString projectPath, bool savePreviewImage
if ( projectData.title.isEmpty() )
projectData.title = projectData.path;

projectData.crs = mMapCanvas->mapSettings().destinationCrs().authid();

if ( savePreviewImage )
{
// Generate a unique file name
Expand Down Expand Up @@ -2820,7 +2823,7 @@ void QgisApp::saveRecentProjectPath( QString projectPath, bool savePreviewImage
// Prepend this file to the list
mRecentProjects.prepend( projectData );

// Keep the list to 8 items by trimming excess off the bottom
// Keep the list to 10 items by trimming excess off the bottom
// And remove the associated image
while ( mRecentProjects.count() > 10 )
{
Expand All @@ -2838,6 +2841,7 @@ void QgisApp::saveRecentProjectPath( QString projectPath, bool savePreviewImage
settings.setValue( "title", recentProject.title );
settings.setValue( "path", recentProject.path );
settings.setValue( "previewImage", recentProject.previewImagePath );
settings.setValue( "crs", recentProject.crs );
settings.endGroup();
}

Expand Down
18 changes: 14 additions & 4 deletions src/app/qgswelcomepageitemsmodel.cpp
Expand Up @@ -14,6 +14,7 @@
***************************************************************************/

#include "qgswelcomepageitemsmodel.h"
#include "qgscoordinatereferencesystem.h"
#include "qgsmessagelog.h"

#include <QApplication>
Expand Down Expand Up @@ -59,7 +60,7 @@ void QgsWelcomePageItemDelegate::paint( QPainter* painter, const QStyleOptionVie
painter->setBrush( QBrush( color ) );
painter->drawRoundedRect( option.rect.left() + 5, option.rect.top() + 5, option.rect.width() - 10, option.rect.height() - 10, 8, 8 );

doc.setHtml( QString( "<span style='font-size:18px;font-weight:bold;'>%1</span><br>%2" ).arg( index.data( QgsWelcomePageItemsModel::TitleRole ).toString() ).arg( index.data( QgsWelcomePageItemsModel::PathRole ).toString() ) );
doc.setHtml( QString( "<span style='font-size:18px;font-weight:bold;'>%1</span><br>%2<br>%3" ).arg( index.data( QgsWelcomePageItemsModel::TitleRole ).toString() ).arg( index.data( QgsWelcomePageItemsModel::PathRole ).toString() ).arg( index.data( QgsWelcomePageItemsModel::CrsRole ).toString() ) );
doc.setTextWidth( 800 );

QPixmap icon = qvariant_cast<QPixmap>( index.data( Qt::DecorationRole ) );
Expand All @@ -79,7 +80,7 @@ QSize QgsWelcomePageItemDelegate::sizeHint( const QStyleOptionViewItem & option,
{
QTextDocument doc;

doc.setHtml( QString( "<span style='font-size:18px;font-weight:bold;'>%1</span><br>%2" ).arg( index.data( QgsWelcomePageItemsModel::TitleRole ).toString() ).arg( index.data( QgsWelcomePageItemsModel::PathRole ).toString() ) );
doc.setHtml( QString( "<span style='font-size:18px;font-weight:bold;'>%1</span><br>%2<br>%3" ).arg( index.data( QgsWelcomePageItemsModel::TitleRole ).toString() ).arg( index.data( QgsWelcomePageItemsModel::PathRole ).toString() ).arg( index.data( QgsWelcomePageItemsModel::CrsRole ).toString() ) );
doc.setTextWidth( 800 );

QPixmap icon = qvariant_cast<QPixmap>( index.data( Qt::DecorationRole ) );
Expand Down Expand Up @@ -114,10 +115,19 @@ QVariant QgsWelcomePageItemsModel::data( const QModelIndex& index, int role ) co
case Qt::DisplayRole:
case TitleRole:
return mRecentProjects.at( index.row() ).title != mRecentProjects.at( index.row() ).path ? mRecentProjects.at( index.row() ).title : QFileInfo( mRecentProjects.at( index.row() ).path ).baseName();
break;
case PathRole:
return mRecentProjects.at( index.row() ).path;
break;
case CrsRole:
if ( mRecentProjects.at( index.row() ).crs != "" )
{
QgsCoordinateReferenceSystem crs;
crs.createFromOgcWmsCrs( mRecentProjects.at( index.row() ).crs );
return QString( "%1 (%2)" ).arg( mRecentProjects.at( index.row() ).crs ).arg( crs.description() );
}
else
{
return QString();
}
case Qt::DecorationRole:
{
QImage thumbnail( mRecentProjects.at( index.row() ).previewImagePath );
Expand Down
4 changes: 3 additions & 1 deletion src/app/qgswelcomepageitemsmodel.h
Expand Up @@ -38,7 +38,8 @@ class QgsWelcomePageItemsModel : public QAbstractListModel
enum Role
{
TitleRole = Qt::UserRole + 1,
PathRole = Qt::UserRole + 2
PathRole = Qt::UserRole + 2,
CrsRole = Qt::UserRole + 3
};

struct RecentProjectData
Expand All @@ -47,6 +48,7 @@ class QgsWelcomePageItemsModel : public QAbstractListModel
QString path;
QString title;
QString previewImagePath;
QString crs;
};

QgsWelcomePageItemsModel( QObject* parent = 0 );
Expand Down

0 comments on commit 107d911

Please sign in to comment.