Skip to content
Permalink
Browse files

Better headers in guide view

  • Loading branch information
nyalldawson committed Jul 25, 2017
1 parent 048a5b7 commit e718f92bd507bf4dbbe98720342edaddc4bc378a
@@ -164,6 +164,8 @@ class QgsLayoutGuideCollection : QAbstractTableModel

virtual Qt::ItemFlags flags( const QModelIndex &index ) const;

virtual QVariant headerData( int section, Qt::Orientation orientation,
int role = Qt::DisplayRole ) const;

void addGuide( QgsLayoutGuide *guide /Transfer/ );
%Docstring
@@ -152,7 +152,8 @@ QgsLayoutGuideCollection::QgsLayoutGuideCollection( QgsLayout *layout )
: QAbstractTableModel( layout )
, mLayout( layout )
{

QFont f;
mHeaderSize = QFontMetrics( f ).width( "XX" );
}

QgsLayoutGuideCollection::~QgsLayoutGuideCollection()
@@ -276,6 +277,17 @@ Qt::ItemFlags QgsLayoutGuideCollection::flags( const QModelIndex &index ) const
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
}

QVariant QgsLayoutGuideCollection::headerData( int section, Qt::Orientation orientation, int role ) const
{
if ( role == Qt::DisplayRole )
return QVariant();
else if ( role == Qt::SizeHintRole )
{
return QSize( mHeaderSize, mHeaderSize );
}
return QAbstractTableModel::headerData( section, orientation, role );
}

void QgsLayoutGuideCollection::addGuide( QgsLayoutGuide *guide )
{
guide->setLayout( mLayout );
@@ -189,6 +189,8 @@ class CORE_EXPORT QgsLayoutGuideCollection : public QAbstractTableModel
QVariant data( const QModelIndex &index, int role ) const override;
bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
Qt::ItemFlags flags( const QModelIndex &index ) const override;
QVariant headerData( int section, Qt::Orientation orientation,
int role = Qt::DisplayRole ) const override;

/**
* Adds a \a guide to the collection. Ownership of the guide is transferred to the
@@ -213,6 +215,7 @@ class CORE_EXPORT QgsLayoutGuideCollection : public QAbstractTableModel
QgsLayout *mLayout = nullptr;

QList< QgsLayoutGuide * > mGuides;
int mHeaderSize = 0;

};

0 comments on commit e718f92

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