Skip to content

Commit 89f34b2

Browse files
committedApr 25, 2013
fix cpt-city loading of invalid (non-existent) ramps in Seleections
1 parent 4f41de8 commit 89f34b2

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed
 

‎resources/cpt-city-qgis-min/selections/div.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<gradient file="Grand_Boucle" dir="jjg/ccolo/vredeling"/>
3636
<gradient file="Optimus_Prime" dir="jjg/ccolo/vredeling"/>
3737
<gradient file="British_Cheer" dir="jjg/ccolo/vredeling"/>
38-
<gradient file="Tubular_Bells" dir="/jjg/ccolo/vredeling"/>
38+
<gradient file="Tubular_Bells" dir="jjg/ccolo/vredeling"/>
3939
<gradient file="xmas_22" dir="ma/xmas"/>
4040
<gradient file="ha_14" dir="ma/postcard"/>
4141
<gradient file="departure" dir="mjf"/>

‎src/core/symbology-ng/qgscptcityarchive.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -708,23 +708,25 @@ bool QgsCptCityDataItem::equal( const QgsCptCityDataItem *other )
708708
// ---------------------------------------------------------------------
709709

710710
QgsCptCityColorRampItem::QgsCptCityColorRampItem( QgsCptCityDataItem* parent,
711-
QString name, QString path, QString variantName )
711+
QString name, QString path, QString variantName, bool initialize )
712712
: QgsCptCityDataItem( ColorRamp, parent, name, path ),
713713
mInitialised( false ), mRamp( path, variantName, false )
714714
{
715715
// QgsDebugMsg( "name= " + name + " path= " + path );
716716
mPopulated = true;
717-
//init();
717+
if ( initialize )
718+
init();
718719
}
719720

720721
QgsCptCityColorRampItem::QgsCptCityColorRampItem( QgsCptCityDataItem* parent,
721-
QString name, QString path, QStringList variantList )
722+
QString name, QString path, QStringList variantList, bool initialize )
722723
: QgsCptCityDataItem( ColorRamp, parent, name, path ),
723724
mInitialised( false ), mRamp( path, variantList, QString(), false )
724725
{
725726
// QgsDebugMsg( "name= " + name + " path= " + path );
726727
mPopulated = true;
727-
//init();
728+
if ( initialize )
729+
init();
728730
}
729731

730732
// TODO only load file when icon is requested...
@@ -878,10 +880,11 @@ QVector< QgsCptCityDataItem* > QgsCptCityCollectionItem::childrenRamps( bool rec
878880
QgsDebugMsg( "invalid item " + childItem->path() );
879881
}
880882
}
881-
882-
// delete items - this is not efficient, but only happens once
883+
884+
// delete invalid items - this is not efficient, but should only happens once
883885
foreach ( QgsCptCityDataItem* deleteItem, deleteItems )
884886
{
887+
QgsDebugMsg( QString( "item %1 is invalid, will be deleted" ).arg( deleteItem->path() ) );
885888
int i = mChildren.indexOf( deleteItem );
886889
if ( i != -1 )
887890
mChildren.remove( i );
@@ -1215,7 +1218,8 @@ QVector<QgsCptCityDataItem*> QgsCptCitySelectionItem::createChildren()
12151218
}
12161219
else
12171220
{
1218-
item = new QgsCptCityColorRampItem( this, childPath, childPath );
1221+
// init item to test if is valid after loading file
1222+
item = new QgsCptCityColorRampItem( this, childPath, childPath, QString(), true );
12191223
if ( item->isValid() )
12201224
children << item;
12211225
else

‎src/core/symbology-ng/qgscptcityarchive.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,12 @@ class CORE_EXPORT QgsCptCityColorRampItem : public QgsCptCityDataItem
198198
public:
199199
QgsCptCityColorRampItem( QgsCptCityDataItem* parent,
200200
QString name, QString path,
201-
QString variantName = QString() );
201+
QString variantName = QString(),
202+
bool initialize = false );
202203
QgsCptCityColorRampItem( QgsCptCityDataItem* parent,
203204
QString name, QString path,
204-
QStringList variantList );
205+
QStringList variantList,
206+
bool initialize = false );
205207
~QgsCptCityColorRampItem() {}
206208

207209
// --- reimplemented from QgsCptCityDataItem ---

‎src/gui/symbology-ng/qgscptcitycolorrampv2dialog.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,6 @@ QgsCptCityColorRampV2Dialog::QgsCptCityColorRampV2Dialog( QgsCptCityColorRampV2*
167167

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

170-
// TODO - remove this when basic archive is complete
171-
if ( mArchive->archiveName() == DEFAULT_CPTCITY_ARCHIVE )
172-
tabBar->setCurrentIndex( 1 );
173-
174170
}
175171

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

511507
void QgsCptCityColorRampV2Dialog::updateListWidget( QgsCptCityDataItem *item )
512508
{
509+
mListWidget->clear();
510+
mListRamps.clear();
513511
QgsCptCityCollectionItem* colItem = dynamic_cast<QgsCptCityCollectionItem*>( item );
514512
if ( colItem )
515513
{
516514
QgsDebugMsg( "path= " + item->path() );
517-
mListWidget->clear();
518-
mListRamps.clear();
519515
// recursively get children ramps
520516
QVector<QgsCptCityDataItem*> childrenRamps = colItem->childrenRamps( true );
521517
for ( int i = 0; i < childrenRamps.count(); i++ )
@@ -538,7 +534,6 @@ void QgsCptCityColorRampV2Dialog::updateListWidget( QgsCptCityDataItem *item )
538534
else
539535
{
540536
QgsDebugMsg( "invalid item" );
541-
mListWidget->clear();
542537
}
543538
}
544539

0 commit comments

Comments
 (0)
Please sign in to comment.