Skip to content
Permalink
Browse files

add ramp count to selection info label

  • Loading branch information
etiennesky committed Apr 25, 2013
1 parent 8218baf commit 43c2805ecf742e629bc438f5597f8cadf9249e3c
@@ -555,6 +555,22 @@ int QgsCptCityDataItem::rowCount()
// populate();
return mChildren.size();
}

int QgsCptCityDataItem::leafCount() const
{
if ( !mPopulated )
return 0;

int count = 0;
foreach ( QgsCptCityDataItem *child, mChildren )
{
if ( child )
count += child->leafCount();
}
return count;
}


bool QgsCptCityDataItem::hasChildren()
{
return ( mPopulated ? mChildren.count() > 0 : true );
@@ -833,6 +849,7 @@ QgsCptCityCollectionItem::~QgsCptCityCollectionItem()
QVector< QgsCptCityDataItem* > QgsCptCityCollectionItem::childrenRamps( bool recursive )
{
QVector< QgsCptCityDataItem* > rampItems;
QVector< QgsCptCityDataItem* > deleteItems;

populate();

@@ -853,13 +870,24 @@ QVector< QgsCptCityDataItem* > QgsCptCityCollectionItem::childrenRamps( bool rec
rampItem->init();
if ( rampItem->isValid() )
rampItems << rampItem;
// should also delete item from parent, but we are in a loop now
else
deleteItems << rampItem;
}
else
{
QgsDebugMsg( "invalid item " + childItem->path() );
}
}

// delete items - this is not efficient, but only happens once
foreach ( QgsCptCityDataItem* deleteItem, deleteItems )
{
int i = mChildren.indexOf( deleteItem );
if ( i != -1 )
mChildren.remove( i );
delete deleteItem;
}

return rampItems;
}

@@ -1178,7 +1206,12 @@ QVector<QgsCptCityDataItem*> QgsCptCitySelectionItem::createChildren()
QgsCptCityDataItem* childItem =
QgsCptCityDirectoryItem::dataItem( this, childPath, childPath );
if ( childItem )
children << childItem;
{
if ( childItem->isValid() )
children << childItem;
else
delete childItem;
}
}
else
{
@@ -101,6 +101,8 @@ class CORE_EXPORT QgsCptCityDataItem : public QObject
bool hasChildren();

int rowCount();
// retrieve total count of "leaf" items (all children which are end nodes)
virtual int leafCount() const;

//

@@ -205,6 +207,7 @@ class CORE_EXPORT QgsCptCityColorRampItem : public QgsCptCityDataItem
// --- reimplemented from QgsCptCityDataItem ---

virtual bool equal( const QgsCptCityDataItem *other );
virtual int leafCount() const { return 1; }

// --- New virtual methods for layer item derived classes ---
const QgsCptCityColorRampV2& ramp() const { return mRamp; }
@@ -29,6 +29,11 @@

/////////

// TODO
// - remove dialog or add help as help button
// - fix Diverging children when first show Selections
// - fix crash on Diverging?

class TreeFilterProxyModel : public QSortFilterProxyModel
{
// Q_OBJECT
@@ -285,26 +290,24 @@ void QgsCptCityColorRampV2Dialog::updateTreeView( QgsCptCityDataItem *item, bool
lblSchemeName->setText( "" );
populateVariants();
}
updateListWidget( item );
lblSchemePath->setText( item->path() );
lblCollectionInfo->setText( item->info() );
lblCollectionInfo->setText( QString( "%1 (%2)" ).arg( item->info() ).arg( item->leafCount() ) );
updateCopyingInfo( mArchive->copyingInfo( mArchive->copyingFileName( item->path() ) ) );
updateListWidget( item );
}
else if ( item->type() == QgsCptCityDataItem::Selection )
{
lblSchemePath->setText( "" );
// lblCollectionName->setText( item->path() );
lblCollectionInfo->setText( item->info() );
clearCopyingInfo( );
updateListWidget( item );
lblCollectionInfo->setText( QString( "%1 (%2)" ).arg( item->info() ).arg( item->leafCount() ) );
}
else if ( item->type() == QgsCptCityDataItem::AllRamps )
{
lblSchemePath->setText( "" );
// lblCollectionName->setText( item->path() );
clearCopyingInfo( );
updateListWidget( item );
lblCollectionInfo->setText( tr( "All Ramps (%1)" ).arg( item->rowCount() ) );
lblCollectionInfo->setText( tr( "All Ramps (%1)" ).arg( item->leafCount() ) );
}
else
{

0 comments on commit 43c2805

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