@ -271,6 +271,12 @@ public:
bool loadImage ( TileConstants : : TTileChannel channel , const QString & fn )
bool loadImage ( TileConstants : : TTileChannel channel , const QString & fn )
{
{
if ( fn . isEmpty ( ) )
{
pixmaps [ channel ] = TileItemNodePvt : : emptyPm ( ) ;
return true ;
}
QPixmap temp ;
QPixmap temp ;
bool b = temp . load ( fn ) ;
bool b = temp . load ( fn ) ;
@ -284,6 +290,17 @@ public:
return true ;
return true ;
}
}
static bool loadEmptyImage ( )
{
bool b = empty . load ( " :/placeHolder/images/empty_image.png " ) ;
if ( ! b )
{
empty = QPixmap ( ) ;
}
return b ;
}
void clearImage ( TileConstants : : TTileChannel channel )
void clearImage ( TileConstants : : TTileChannel channel )
{
{
pixmaps [ channel ] = QPixmap ( ) ;
pixmaps [ channel ] = QPixmap ( ) ;
@ -293,10 +310,15 @@ public:
return pixmaps [ channel ] ;
return pixmaps [ channel ] ;
}
}
static QPixmap & emptyPm ( ) { return empty ; }
private :
private :
QPixmap pixmaps [ TileConstants : : TileChannelCount ] ;
QPixmap pixmaps [ TileConstants : : TileChannelCount ] ;
static QPixmap empty ;
} ;
} ;
QPixmap TileItemNodePvt : : empty = QPixmap ( ) ;
TileConstants : : TTileChannel TileItemNode : : s_displayChannel = TileConstants : : TileDiffuse ;
TileConstants : : TTileChannel TileItemNode : : s_displayChannel = TileConstants : : TileDiffuse ;
TileItemNode : : TileItemNode ( TileConstants : : TNodeTileType type , int tileId , Node * parent )
TileItemNode : : TileItemNode ( TileConstants : : TNodeTileType type , int tileId , Node * parent )
@ -321,14 +343,7 @@ TileItemNode::~TileItemNode()
bool TileItemNode : : setTileFilename ( TileConstants : : TTileChannel channel , QString filename )
bool TileItemNode : : setTileFilename ( TileConstants : : TTileChannel channel , QString filename )
{
{
QString fn = filename ;
bool b = pvt - > loadImage ( channel , filename ) ;
if ( filename . isEmpty ( ) | | ( filename = = " empty " ) )
{
fn = " :/placeHolder/images/empty_image.png " ;
}
bool b = pvt - > loadImage ( channel , fn ) ;
if ( ! b )
if ( ! b )
return false ;
return false ;
@ -346,6 +361,11 @@ QString TileItemNode::getTileFilename(TileConstants::TTileChannel channel)
return itr . value ( ) ;
return itr . value ( ) ;
}
}
bool TileItemNode : : loadEmptyPixmap ( )
{
return TileItemNodePvt : : loadEmptyImage ( ) ;
}
QVariant TileItemNode : : data ( int column , int role ) const
QVariant TileItemNode : : data ( int column , int role ) const
{
{
QString tileFilename = m_tileFilename [ TileItemNode : : s_displayChannel ] ;
QString tileFilename = m_tileFilename [ TileItemNode : : s_displayChannel ] ;