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 = nullptr; 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() ) ); } mActionWidget = createActionWidget( 0 ); mActionWidget->setVisible( false ); updateActionImage( mActionWidget ); }
void QgsAttributeTableView::mouseMoveEvent( QMouseEvent *event ) { QModelIndex index = indexAt( event->pos() ); if ( index.data( QgsAttributeTableFilterModel::TypeRole ) == QgsAttributeTableFilterModel::ColumnTypeActionButton ) { Q_ASSERT( index.isValid() ); if ( !indexWidget( index ) ) setIndexWidget( index, createActionWidget( mFilterModel->data( index, QgsAttributeTableModel::FeatureIdRole ).toLongLong() ) ); } setSelectionMode( QAbstractItemView::NoSelection ); QTableView::mouseMoveEvent( event ); setSelectionMode( QAbstractItemView::ExtendedSelection ); }
void ToolBar::addAction(const QString &actionName, Qt::ToolButtonStyle style, QAction *before) { if (windowHasAction(actionName, true)) return; ToolBarAction newAction; newAction.actionName = actionName; newAction.action = 0; newAction.widget = 0; newAction.style = style; int beforeIndex = before ? indexOf(before) : ToolBarActions.size(); createActionWidget(before, newAction); if (!before) ToolBarActions.append(newAction); else ToolBarActions.insert(beforeIndex, newAction); MyChangeNotifier.notify(); }