Skip to content
Permalink
Browse files

Ignore model font style and color in embed layers dialog

And always show layers in standard font and colors. Otherwise
they inherit the styling of the standard layer tree model,
which means unchecked layers show in a "disabled" looking
style, which is misleading (and meaningless) for the embedded
layer choice.
  • Loading branch information
nyalldawson committed Jun 11, 2018
1 parent a9b25ed commit 6ea79e34d5c4a1a78447033e0386ea271c87e341
Showing with 38 additions and 1 deletion.
  1. +19 −1 src/app/qgsprojectlayergroupdialog.cpp
  2. +19 −0 src/app/qgsprojectlayergroupdialog.h
@@ -26,6 +26,24 @@
#include <QFileInfo>
#include <QMessageBox>




QgsEmbeddedLayerTreeModel::QgsEmbeddedLayerTreeModel( QgsLayerTree *rootNode, QObject *parent )
: QgsLayerTreeModel( rootNode, parent )
{
}

QVariant QgsEmbeddedLayerTreeModel::data( const QModelIndex &index, int role ) const
{
if ( role == Qt::ForegroundRole || role == Qt::FontRole )
return QVariant();

return QgsLayerTreeModel::data( index, role );
}



QgsProjectLayerGroupDialog::QgsProjectLayerGroupDialog( QWidget *parent, const QString &projectFile, Qt::WindowFlags f )
: QDialog( parent, f )
, mRootGroup( new QgsLayerTree )
@@ -180,7 +198,7 @@ void QgsProjectLayerGroupDialog::changeProjectFile()
if ( !mShowEmbeddedContent )
removeEmbeddedNodes( mRootGroup );

QgsLayerTreeModel *model = new QgsLayerTreeModel( mRootGroup, this );
QgsEmbeddedLayerTreeModel *model = new QgsEmbeddedLayerTreeModel( mRootGroup, this );
mTreeView->setModel( model );

connect( mTreeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &QgsProjectLayerGroupDialog::onTreeViewSelectionChanged );
@@ -18,12 +18,31 @@
#include "QDialog"
#include "ui_qgsprojectlayergroupdialogbase.h"
#include "qgshelp.h"
#include "qgslayertreemodel.h"
#include "qgis_app.h"

class QDomElement;

class QgsLayerTree;

/**
* Subclass of QgsLayerTreeModel which overrides font styling
* from base model.
*/
class QgsEmbeddedLayerTreeModel : public QgsLayerTreeModel
{
Q_OBJECT
public:

/**
* Construct a new tree model with given layer tree (root node must not be null pointer).
* The root node is not transferred by the model.
*/
explicit QgsEmbeddedLayerTreeModel( QgsLayerTree *rootNode, QObject *parent = nullptr );

QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
};

//! A dialog to select layers and groups from a qgs project
class APP_EXPORT QgsProjectLayerGroupDialog: public QDialog, private Ui::QgsProjectLayerGroupDialogBase
{

0 comments on commit 6ea79e3

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