Commit 398b1f69 authored by Guillaume Pasero's avatar Guillaume Pasero

BUG: Mantis-1420: handle the layer name as an alias

parent 60207112
......@@ -139,6 +139,12 @@ public:
*/
void ToWgs84( const PointType &, PointType & wgs84, double & alt ) const;
/** Setter for the m_Name attribute ( should be initialized by subclasses )*/
void SetName(const QString & name);
/** Getter for the m_Name attribute */
const QString & GetName() const;
/*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/
//
......@@ -198,6 +204,7 @@ private:
// Private attributes.
private:
QString m_Name;
/*-[ PRIVATE SLOTS SECTION ]-----------------------------------------------*/
//
......
......@@ -114,7 +114,8 @@ GetSpatialReferenceType( const std::string & wkt, bool hasKwl )
AbstractLayerModel
::AbstractLayerModel( QObject* p ) :
AbstractModel( p ),
VisibleInterface()
VisibleInterface(),
m_Name(QString())
{
}
......@@ -180,6 +181,25 @@ AbstractLayerModel
virtual_ToWgs84( p, wgs84, alt );
}
/*****************************************************************************/
void
AbstractLayerModel
::SetName(const QString & name)
{
if (name != m_Name)
{
m_Name = name;
}
}
/*****************************************************************************/
const QString &
AbstractLayerModel
::GetName() const
{
return m_Name;
}
/*******************************************************************************/
bool
AbstractLayerModel
......
......@@ -94,6 +94,7 @@ VectorImageModel
::SetFilename( const QString& filename , int w, int h)
{
setObjectName( filename );
SetName( QFileInfo( filename ).fileName() );
// 1. store the input filename
FilenameInterface::SetFilename( filename );
......
......@@ -423,6 +423,7 @@ LayerStackItemModel
}
break;
case Qt::EditRole:
case Qt::DisplayRole:
switch( idx.column() )
{
......@@ -447,21 +448,7 @@ LayerStackItemModel
break;
case COLUMN_NAME:
if( layer->inherits(
VectorImageModel::staticMetaObject.className() ) )
{
const VectorImageModel * vectorImageModel =
qobject_cast< const VectorImageModel * >( layer );
assert( vectorImageModel!=NULL );
// qDebug() << "filename:" << vectorImageModel->GetFilename();
return QFileInfo( vectorImageModel->GetFilename() ).fileName();
}
else
{
qDebug() << "Unhandled AbstractLayerModel subclass.";
}
return layer->GetName();
break;
case COLUMN_EFFECT:
......@@ -842,7 +829,7 @@ LayerStackItemModel
// qDebug()
// << this << "::setData(" << idx << "," << value << "," << role << ")";
if( idx.column()==COLUMN_NAME && role==Qt::CheckStateRole )
if( idx.column()==COLUMN_NAME )
{
// qDebug() << idx.row() << "check-state:" << value;
......@@ -856,30 +843,45 @@ LayerStackItemModel
assert( layer!=NULL );
assert( layer==dynamic_cast< VisibleInterface * >( layer ) );
VisibleInterface * interface = dynamic_cast< VisibleInterface * >( layer );
assert( interface!=NULL );
switch( value.toInt() )
switch( role )
{
case Qt::Checked:
interface->SetVisible( true );
case Qt::EditRole:
{
QString strValue = value.toString();
if( !strValue.isEmpty() )
{
layer->SetName( strValue );
emit dataChanged( idx, idx );
return true;
}
}
break;
case Qt::Unchecked:
interface->SetVisible( false );
case Qt::CheckStateRole:
switch( value.toInt() )
{
case Qt::Checked:
interface->SetVisible( true );
break;
case Qt::Unchecked:
interface->SetVisible( false );
break;
default:
assert( false && "Unhandled Qt::CheckedState value." );
break;
}
emit dataChanged( idx, idx );
return true;
break;
default:
assert( false && "Unhandled Qt::CheckedState value." );
break;
}
emit dataChanged( idx, idx );
return true;
}
return false;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment