Esempio n. 1
0
void LayerListModel::reorderLayers(QList<uint16_t> neworder)
{
	QVector<LayerListItem> newitems;
	for(int j=neworder.size()-1;j>=0;--j) {
		const uint16_t id=neworder[j];
		for(int i=0;i<_items.size();++i) {
			if(_items[i].id == id) {
				newitems << _items[i];
				break;
			}
		}
	}
	_items = newitems;
	emit dataChanged(index(0), index(_items.size()));
	emit layersReordered();
}
Esempio n. 2
0
void LayerList::setClient(net::Client *client)
{
	Q_ASSERT(_client==0);

	_client = client;
	_ui->layerlist->setModel(client->layerlist());

	LayerListDelegate *del = new LayerListDelegate(this);
	del->setClient(client);
	_ui->layerlist->setItemDelegate(del);

	_aclmenu->setUserList(client->userlist());

	connect(_client->layerlist(), SIGNAL(layerCreated(bool)), this, SLOT(onLayerCreate(bool)));
	connect(_client->layerlist(), SIGNAL(layerDeleted(int,int)), this, SLOT(onLayerDelete(int,int)));
	connect(_client->layerlist(), SIGNAL(layersReordered()), this, SLOT(onLayerReorder()));
	connect(_client->layerlist(), SIGNAL(modelReset()), this, SLOT(onLayerReorder()));
	connect(client->layerlist(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(dataChanged(QModelIndex,QModelIndex)));
	connect(_ui->layerlist->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(selectionChanged(QItemSelection)));

	connect(del, SIGNAL(toggleVisibility(int,bool)), this, SLOT(setLayerVisibility(int, bool)));
}