Skip to content
Permalink
Browse files

[welcome page] add project projection information

  • Loading branch information
nirvn authored and m-kuhn committed Sep 11, 2015
1 parent 116089e commit 107d911afed8be3e2dc46bd2e4923f35f681d8d1
Showing with 22 additions and 6 deletions.
  1. +5 −1 src/app/qgisapp.cpp
  2. +14 −4 src/app/qgswelcomepageitemsmodel.cpp
  3. +3 −1 src/app/qgswelcomepageitemsmodel.h
@@ -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 );
}
@@ -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
@@ -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 )
{
@@ -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();
}

@@ -14,6 +14,7 @@
***************************************************************************/

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

#include <QApplication>
@@ -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 ) );
@@ -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 ) );
@@ -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 );
@@ -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
@@ -47,6 +48,7 @@ class QgsWelcomePageItemsModel : public QAbstractListModel
QString path;
QString title;
QString previewImagePath;
QString crs;
};

QgsWelcomePageItemsModel( QObject* parent = 0 );

0 comments on commit 107d911

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