示例#1
0
void QgsAttributeTableView::setModel( QgsAttributeTableFilterModel* filterModel )
{
  if ( mFilterModel )
  {
    // Cleanup old model stuff if present
    disconnect( mFilterModel, SIGNAL( filterAboutToBeInvalidated() ), this, SLOT( onFilterAboutToBeInvalidated() ) );
    disconnect( mFilterModel, SIGNAL( filterInvalidated() ), this, SLOT( onFilterInvalidated() ) );
  }

  mFilterModel = filterModel;
  QTableView::setModel( filterModel );

  connect( mFilterModel, SIGNAL( destroyed() ), this, SLOT( modelDeleted() ) );

  delete mFeatureSelectionModel;
  mFeatureSelectionModel = 0;

  if ( filterModel )
  {
    if ( !mFeatureSelectionManager )
    {
      mFeatureSelectionManager = new QgsVectorLayerSelectionManager( mFilterModel->layer(), mFilterModel );
    }

    mFeatureSelectionModel = new QgsFeatureSelectionModel( mFilterModel, mFilterModel, mFeatureSelectionManager, mFilterModel );
    setSelectionModel( mFeatureSelectionModel );
    mTableDelegate->setFeatureSelectionModel( mFeatureSelectionModel );
    connect( mFeatureSelectionModel, SIGNAL( requestRepaint( QModelIndexList ) ), this, SLOT( repaintRequested( QModelIndexList ) ) );
    connect( mFeatureSelectionModel, SIGNAL( requestRepaint() ), this, SLOT( repaintRequested() ) );
  }
}
示例#2
0
/**
 * Sets pointer to model's project.
 */
void BaseModel::setProject(Project* prj){
	Q_ASSERT(this->prj == NULL);
	Q_ASSERT(prj != NULL);
	this->prj = prj;

	connect(
		this->prj,
		SIGNAL(modelRenamed(QString, QString, ModelType)),
		this,
		SLOT(selectedModelRenamed(QString, QString, ModelType))
	);

	connect(
		this->prj,
		SIGNAL(modelDeleted(QString, ModelType)),
		this,
		SLOT(selectedModelDeleted(QString, ModelType))
	);
}