Skip to content
Permalink
Browse files

store relative cpt-city paths for portability

  • Loading branch information
etiennesky committed Nov 17, 2012
1 parent 4c53c62 commit 145fca47cb3b300e95e0dd62058465bdd8d05b1a
@@ -407,8 +407,10 @@ QgsVectorGradientColorRampV2* QgsCptCityColorRampV2::cloneGradientRamp() const
// add author and copyright information
// TODO also add COPYING.xml file/link?
QgsStringMap info = copyingInfo();
info["source"] = "cpt-city archive - " + mSchemeName + mVariantName + ".svg";
info["license/file"] = copyingFileName();
info["cpt-city-gradient"] = "<cpt-city>/" + mSchemeName + mVariantName + ".svg";
QString copyingFilename = copyingFileName();
copyingFilename.remove( QgsCptCityArchive::defaultBaseDir() );
info["cpt-city-license"] = "<cpt-city>" + copyingFilename;
ramp->setInfo( info );
return ramp;
}
@@ -17,6 +17,7 @@

#include "qgsvectorcolorrampv2.h"
#include "qgsdialog.h"
#include "qgscptcityarchive.h"

#include <QColorDialog>
#include <QInputDialog>
@@ -75,45 +76,79 @@ void QgsVectorGradientColorRampV2Dialog::on_btnInformation_pressed()
return;

QgsDialog *dlg = new QgsDialog( this );
QLabel *label = 0;

// information table
QTableWidget *tableInfo = new QTableWidget( dlg );
tableInfo->verticalHeader()->hide();
tableInfo->horizontalHeader()->hide();
tableInfo->setColumnCount( 2 );
tableInfo->setRowCount( mRamp->info().count() );
tableInfo->setColumnCount( 2 );
int i = 0;
for ( QgsStringMap::const_iterator it = mRamp->info().constBegin();
it != mRamp->info().constEnd(); ++it )
{
QgsDebugMsg( it.key() + "-" + it.value() );
if ( it.key().startsWith( "cpt-city" ) )
continue;
tableInfo->setItem( i, 0, new QTableWidgetItem( it.key() ) );
tableInfo->setItem( i, 1, new QTableWidgetItem( it.value() ) );
tableInfo->resizeRowToContents( i );
i++;
}
tableInfo->resizeColumnToContents( 0 );
tableInfo->horizontalHeader()->setStretchLastSection( true );
tableInfo->setRowCount( i );
tableInfo->setFixedHeight( tableInfo->rowHeight( 0 ) * i + 5 );
dlg->layout()->addWidget( tableInfo );
dlg->resize( 600, 250 );

dlg->layout()->addSpacing( 5 );

// gradient file
QString gradientFile = mRamp->info().value( "cpt-city-gradient" );
if ( ! gradientFile.isNull() )
{
QString fileName = gradientFile;
fileName.replace( "<cpt-city>", QgsCptCityArchive::defaultBaseDir() );
if ( ! QFile::exists( fileName ) )
{
fileName = gradientFile;
fileName.replace( "<cpt-city>", "http://soliton.vm.bytemark.co.uk/pub/cpt-city" );
}
label = new QLabel( tr( "Gradient file : %1" ).arg( fileName ), dlg );
label->setTextInteractionFlags( Qt::TextBrowserInteraction );
dlg->layout()->addSpacing( 5 );
dlg->layout()->addWidget( label );
}

// license file
QString licenseFile = mRamp->info().value( "license/file" );
if ( !licenseFile.isNull() && QFile::exists( licenseFile ) )
QString licenseFile = mRamp->info().value( "cpt-city-license" );
if ( !licenseFile.isNull() )
{
QTextEdit *textEdit = new QTextEdit( dlg );
textEdit->setReadOnly( true );
QFile file( licenseFile );
if ( file.open( QIODevice::ReadOnly | QIODevice::Text ) )
QString fileName = licenseFile;
fileName.replace( "<cpt-city>", QgsCptCityArchive::defaultBaseDir() );
if ( ! QFile::exists( fileName ) )
{
fileName = licenseFile;
fileName.replace( "<cpt-city>", "http://soliton.vm.bytemark.co.uk/pub/cpt-city" );
}
label = new QLabel( tr( "License file : %1" ).arg( fileName ), dlg );
label->setTextInteractionFlags( Qt::TextBrowserInteraction );
dlg->layout()->addSpacing( 5 );
dlg->layout()->addWidget( label );
if ( QFile::exists( fileName ) )
{
textEdit->setText( file.readAll() );
file.close();
dlg->layout()->addSpacing( 10 );
dlg->layout()->addWidget( new QLabel( tr( "License file : %1" ).arg( licenseFile ), dlg ) );
dlg->layout()->addSpacing( 5 );
dlg->layout()->addWidget( textEdit );
dlg->resize( 600, 500 );
QTextEdit *textEdit = new QTextEdit( dlg );
textEdit->setReadOnly( true );
QFile file( fileName );
if ( file.open( QIODevice::ReadOnly | QIODevice::Text ) )
{
textEdit->setText( file.readAll() );
file.close();
dlg->layout()->addSpacing( 5 );
dlg->layout()->addWidget( textEdit );
dlg->resize( 600, 500 );
}
}
}

0 comments on commit 145fca4

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