21 #include <QStringListModel> 22 #include <QStandardItemModel> 35 connect( mBtnAdd, SIGNAL( clicked(
bool ) ),
this, SLOT( onAddClicked() ) );
36 connect( mBtnRemove, SIGNAL( clicked(
bool ) ),
this, SLOT( onRemoveClicked() ) );
46 item->
setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
47 item->
setData( provider->
id(), Qt::UserRole + 1 );
50 mListAvailable->setModel( modelAvailable );
54 for (
int i = 0; i < widgetsCount; ++i )
60 item->
setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
61 item->
setData( provider->id(), Qt::UserRole + 1 );
65 mListUsed->setModel( modelUsed );
68 void QgsLayerTreeEmbeddedConfigWidget::onAddClicked()
70 if ( !mListAvailable->currentIndex().isValid() )
73 QString providerId = mListAvailable->model()->
data( mListAvailable->currentIndex(), Qt::UserRole + 1 ).toString();
78 if (
QStandardItemModel* model = qobject_cast<QStandardItemModel*>( mListUsed->model() ) )
81 item->
setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
82 item->
setData( provider->
id(), Qt::UserRole + 1 );
83 model->appendRow( item );
87 void QgsLayerTreeEmbeddedConfigWidget::onRemoveClicked()
89 if ( !mListUsed->currentIndex().isValid() )
92 int row = mListUsed->currentIndex().row();
93 mListUsed->model()->removeRow( row );
103 for (
int i = 0; i < widgetsCount; ++i )
109 int newCount = mListUsed->model()->rowCount();
111 for (
int i = 0; i < newCount; ++i )
113 QString providerId = mListUsed->model()->
data( mListUsed->model()->index( i, 0 ), Qt::UserRole + 1 ).toString();
Base class for all map layer types.
void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer.
virtual void setData(const QVariant &value, int role)
int toInt(bool *ok) const
void setFlags(QFlags< Qt::ItemFlag > flags)
void removeCustomProperty(const QString &key)
Remove a custom property from layer.
QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void appendRow(const QList< QStandardItem * > &items)