17#include "moc_qgstablewidgetbase.cpp" 
   23  connect( addButton, &QToolButton::clicked, 
this, &QgsTableWidgetBase::addButton_clicked );
 
   24  connect( removeButton, &QToolButton::clicked, 
this, &QgsTableWidgetBase::removeButton_clicked );
 
 
   29  tableView->setModel( model );
 
   30  connect( tableView->selectionModel(), &QItemSelectionModel::selectionChanged, 
this, &QgsTableWidgetBase::onSelectionChanged );
 
 
   36void QgsTableWidgetBase::addButton_clicked()
 
   41  const QItemSelectionModel *select = tableView->selectionModel();
 
   42  const int pos = select->hasSelection() ? select->selectedRows()[0].row() : 0;
 
   43  QAbstractItemModel *model = tableView->model();
 
   44  model->insertRows( pos, 1 );
 
   45  const QModelIndex index = model->index( pos, 0 );
 
   46  tableView->scrollTo( index );
 
   47  tableView->edit( index );
 
   48  tableView->selectRow( pos );
 
   51void QgsTableWidgetBase::removeButton_clicked()
 
   56  const QItemSelectionModel *select = tableView->selectionModel();
 
   58  if ( select->hasSelection() )
 
   60    tableView->model()->removeRows( select->selectedRows()[0].row(), 1 );
 
   64void QgsTableWidgetBase::onSelectionChanged()
 
   66  removeButton->setEnabled( tableView->selectionModel()->hasSelection() );
 
   73  addButton->setEnabled( !mReadOnly );
 
   74  removeButton->setEnabled( !mReadOnly && tableView->selectionModel()->hasSelection() );
 
   78    mWidgetActions->hide();
 
   79    layout()->setSpacing( 0 );
 
   83    mWidgetActions->show();
 
   84    layout()->setSpacing( 6 );