mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-01 00:46:20 -05:00
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.
This commit is contained in:
parent
a9b25ed9f0
commit
6ea79e34d5
@ -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
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user