Skip to content
Permalink
Browse files

fix cpt-city loading of invalid (non-existent) ramps in Seleections

  • Loading branch information
etiennesky committed Apr 25, 2013
1 parent 4f41de8 commit 89f34b20b4757f45ff025dfa7b4fdc2b97becc1f
@@ -35,7 +35,7 @@
<gradient file="Grand_Boucle" dir="jjg/ccolo/vredeling"/>
<gradient file="Optimus_Prime" dir="jjg/ccolo/vredeling"/>
<gradient file="British_Cheer" dir="jjg/ccolo/vredeling"/>
<gradient file="Tubular_Bells" dir="/jjg/ccolo/vredeling"/>
<gradient file="Tubular_Bells" dir="jjg/ccolo/vredeling"/>
<gradient file="xmas_22" dir="ma/xmas"/>
<gradient file="ha_14" dir="ma/postcard"/>
<gradient file="departure" dir="mjf"/>
@@ -708,23 +708,25 @@ bool QgsCptCityDataItem::equal( const QgsCptCityDataItem *other )
// ---------------------------------------------------------------------

QgsCptCityColorRampItem::QgsCptCityColorRampItem( QgsCptCityDataItem* parent,
QString name, QString path, QString variantName )
QString name, QString path, QString variantName, bool initialize )
: QgsCptCityDataItem( ColorRamp, parent, name, path ),
mInitialised( false ), mRamp( path, variantName, false )
{
// QgsDebugMsg( "name= " + name + " path= " + path );
mPopulated = true;
//init();
if ( initialize )
init();
}

QgsCptCityColorRampItem::QgsCptCityColorRampItem( QgsCptCityDataItem* parent,
QString name, QString path, QStringList variantList )
QString name, QString path, QStringList variantList, bool initialize )
: QgsCptCityDataItem( ColorRamp, parent, name, path ),
mInitialised( false ), mRamp( path, variantList, QString(), false )
{
// QgsDebugMsg( "name= " + name + " path= " + path );
mPopulated = true;
//init();
if ( initialize )
init();
}

// TODO only load file when icon is requested...
@@ -878,10 +880,11 @@ QVector< QgsCptCityDataItem* > QgsCptCityCollectionItem::childrenRamps( bool rec
QgsDebugMsg( "invalid item " + childItem->path() );
}
}
// delete items - this is not efficient, but only happens once

// delete invalid items - this is not efficient, but should only happens once
foreach ( QgsCptCityDataItem* deleteItem, deleteItems )
{
QgsDebugMsg( QString( "item %1 is invalid, will be deleted" ).arg( deleteItem->path() ) );
int i = mChildren.indexOf( deleteItem );
if ( i != -1 )
mChildren.remove( i );
@@ -1215,7 +1218,8 @@ QVector<QgsCptCityDataItem*> QgsCptCitySelectionItem::createChildren()
}
else
{
item = new QgsCptCityColorRampItem( this, childPath, childPath );
// init item to test if is valid after loading file
item = new QgsCptCityColorRampItem( this, childPath, childPath, QString(), true );
if ( item->isValid() )
children << item;
else
@@ -198,10 +198,12 @@ class CORE_EXPORT QgsCptCityColorRampItem : public QgsCptCityDataItem
public:
QgsCptCityColorRampItem( QgsCptCityDataItem* parent,
QString name, QString path,
QString variantName = QString() );
QString variantName = QString(),
bool initialize = false );
QgsCptCityColorRampItem( QgsCptCityDataItem* parent,
QString name, QString path,
QStringList variantList );
QStringList variantList,
bool initialize = false );
~QgsCptCityColorRampItem() {}

// --- reimplemented from QgsCptCityDataItem ---
@@ -167,10 +167,6 @@ QgsCptCityColorRampV2Dialog::QgsCptCityColorRampV2Dialog( QgsCptCityColorRampV2*

connect( this, SIGNAL( finished( int ) ), this, SLOT( onFinished() ) );

// TODO - remove this when basic archive is complete
if ( mArchive->archiveName() == DEFAULT_CPTCITY_ARCHIVE )
tabBar->setCurrentIndex( 1 );

}

QgsCptCityColorRampV2Dialog::~QgsCptCityColorRampV2Dialog()
@@ -495,7 +491,7 @@ void QgsCptCityColorRampV2Dialog::on_buttonBox_helpRequested()
QString helpText = tr( "You can download a more complete set of cpt-city gradients "
"by installing the \"Color Ramp Manager\" plugin "
"(you must enable Experimental plugins in the plugin manager).\n\n"
);
);
QMessageBox* msg = new QMessageBox( this );
msg->setText( helpText );
msg->exec();
@@ -510,12 +506,12 @@ bool QgsCptCityColorRampV2Dialog::saveAsGradientRamp() const

void QgsCptCityColorRampV2Dialog::updateListWidget( QgsCptCityDataItem *item )
{
mListWidget->clear();
mListRamps.clear();
QgsCptCityCollectionItem* colItem = dynamic_cast<QgsCptCityCollectionItem*>( item );
if ( colItem )
{
QgsDebugMsg( "path= " + item->path() );
mListWidget->clear();
mListRamps.clear();
// recursively get children ramps
QVector<QgsCptCityDataItem*> childrenRamps = colItem->childrenRamps( true );
for ( int i = 0; i < childrenRamps.count(); i++ )
@@ -538,7 +534,6 @@ void QgsCptCityColorRampV2Dialog::updateListWidget( QgsCptCityDataItem *item )
else
{
QgsDebugMsg( "invalid item" );
mListWidget->clear();
}
}

0 comments on commit 89f34b2

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