29  : QMainWindow( parent )
 
   32  setWindowTitle( tr( 
"Table Designer" ) );
 
   34  setAttribute( Qt::WA_DeleteOnClose );
 
   35  setDockOptions( dockOptions() | QMainWindow::GroupedDragging );
 
   39  QGridLayout *viewLayout = 
new QGridLayout();
 
   40  viewLayout->setSpacing( 0 );
 
   41  viewLayout->setContentsMargins( 0, 0, 0, 0 );
 
   42  centralWidget()->layout()->setSpacing( 0 );
 
   43  centralWidget()->layout()->setContentsMargins( 0, 0, 0, 0 );
 
   46  mMessageBar->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
 
   47  static_cast< QGridLayout * 
>( centralWidget()->layout() )->addWidget( mMessageBar, 0, 0, 1, 1, Qt::AlignTop );
 
   50  mTableWidget->setContentsMargins( 0, 0, 0, 0 );
 
   51  viewLayout->addWidget( mTableWidget, 0, 0 );
 
   52  mViewFrame->setLayout( viewLayout );
 
   53  mViewFrame->setContentsMargins( 0, 0, 0, 0 );
 
   55  mTableWidget->setFocus();
 
   64  const int minDockWidth( fontMetrics().boundingRect( QStringLiteral( 
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ) ).width() );
 
   66  mPropertiesDock = 
new QgsDockWidget( tr( 
"Cell Contents" ), 
this );
 
   67  mPropertiesDock->setObjectName( QStringLiteral( 
"FormattingDock" ) );
 
   69  mPropertiesDock->setWidget( mPropertiesStack );
 
   70  mPropertiesDock->setMinimumWidth( minDockWidth );
 
   76  mPropertiesDock->setFeatures( QDockWidget::NoDockWidgetFeatures );
 
  107    updateActionNamesFromSelection();
 
  111  updateActionNamesFromSelection();
 
  113  addDockWidget( Qt::RightDockWidgetArea, mPropertiesDock );
 
  115  mActionImportFromClipboard->setEnabled( !QApplication::clipboard()->text().isEmpty() );
 
  116  connect( QApplication::clipboard(), &QClipboard::dataChanged, 
this, [ = ]() { mActionImportFromClipboard->setEnabled( !QApplication::clipboard()->text().isEmpty() ); } );
 
  119  connect( mActionClose, &QAction::triggered, 
this, &QMainWindow::close );
 
  128  connect( mActionSelectAll, &QAction::triggered, mTableWidget, &QgsTableEditorWidget::selectAll );
 
  130  connect( mActionIncludeHeader, &QAction::toggled, 
this, [ = ]( 
bool checked )
 
  139  const QByteArray state = settings.
value( QStringLiteral( 
"LayoutDesigner/tableEditorState" ), QByteArray(), 
QgsSettings::App ).toByteArray();
 
  140  if ( !state.isEmpty() && !restoreState( state ) )
 
  142    QgsDebugError( QStringLiteral( 
"restore of table editor dialog UI state failed" ) );
 
  155  if ( QApplication::clipboard()->text().isEmpty() )
 
  158  if ( QMessageBox::question( 
this, tr( 
"Import Content From Clipboard" ),
 
  159                              tr( 
"Importing content from clipboard will overwrite current table content. Are you sure?" ) ) != QMessageBox::Yes )
 
  163  const QStringList lines = QApplication::clipboard()->text().split( 
'\n' );
 
  164  for ( 
const QString &line : lines )
 
  166    if ( !line.isEmpty() )
 
  169      const QStringList cells = line.split( 
'\t' );
 
  170      for ( 
const QString &text : cells )
 
  179  if ( !contents.isEmpty() )
 
  191  mBlockSignals = 
true;
 
  193  mTableWidget->resizeRowsToContents();
 
  194  mTableWidget->resizeColumnsToContents();
 
  195  mBlockSignals = 
false;
 
  225  return mActionIncludeHeader->isChecked();
 
  230  mActionIncludeHeader->setChecked( included );
 
  248void QgsTableEditorDialog::updateActionNamesFromSelection()
 
  253  mActionInsertRowsAbove->setEnabled( rowCount > 0 );
 
  254  mActionInsertRowsBelow->setEnabled( rowCount > 0 );
 
  255  mActionDeleteRows->setEnabled( rowCount > 0 );
 
  256  mActionSelectRow->setEnabled( rowCount > 0 );
 
  259    mActionInsertRowsAbove->setText( tr( 
"Rows Above" ) );
 
  260    mActionInsertRowsBelow->setText( tr( 
"Rows Below" ) );
 
  261    mActionDeleteRows->setText( tr( 
"Delete Rows" ) );
 
  262    mActionSelectRow->setText( tr( 
"Select Rows" ) );
 
  264  else if ( rowCount == 1 )
 
  266    mActionInsertRowsAbove->setText( tr( 
"Row Above" ) );
 
  267    mActionInsertRowsBelow->setText( tr( 
"Row Below" ) );
 
  268    mActionDeleteRows->setText( tr( 
"Delete Row" ) );
 
  269    mActionSelectRow->setText( tr( 
"Select Row" ) );
 
  273    mActionInsertRowsAbove->setText( tr( 
"%n Row(s) Above", 
nullptr, rowCount ) );
 
  274    mActionInsertRowsBelow->setText( tr( 
"%n Row(s) Below", 
nullptr, rowCount ) );
 
  275    mActionDeleteRows->setText( tr( 
"Delete %n Row(s)", 
nullptr, rowCount ) );
 
  276    mActionSelectRow->setText( tr( 
"Select %n Row(s)", 
nullptr, rowCount ) );
 
  279  mActionInsertColumnsBefore->setEnabled( columnCount > 0 );
 
  280  mActionInsertColumnsAfter->setEnabled( columnCount > 0 );
 
  281  mActionDeleteColumns->setEnabled( columnCount > 0 );
 
  282  mActionSelectColumn->setEnabled( columnCount > 0 );
 
  283  if ( columnCount == 0 )
 
  285    mActionInsertColumnsBefore->setText( tr( 
"Columns Before" ) );
 
  286    mActionInsertColumnsAfter->setText( tr( 
"Columns After" ) );
 
  287    mActionDeleteColumns->setText( tr( 
"Delete Columns" ) );
 
  288    mActionSelectColumn->setText( tr( 
"Select Columns" ) );
 
  290  else if ( columnCount == 1 )
 
  292    mActionInsertColumnsBefore->setText( tr( 
"Column Before" ) );
 
  293    mActionInsertColumnsAfter->setText( tr( 
"Column After" ) );
 
  294    mActionDeleteColumns->setText( tr( 
"Delete Column" ) );
 
  295    mActionSelectColumn->setText( tr( 
"Select Column" ) );
 
  299    mActionInsertColumnsBefore->setText( tr( 
"%n Column(s) Before", 
nullptr, columnCount ) );
 
  300    mActionInsertColumnsAfter->setText( tr( 
"%n Column(s) After", 
nullptr, columnCount ) );
 
  301    mActionDeleteColumns->setText( tr( 
"Delete %n Column(s)", 
nullptr, columnCount ) );
 
  302    mActionSelectColumn->setText( tr( 
"Select %n Column(s)", 
nullptr, columnCount ) );
 
Abstract interface for generating an expression context.
 
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
 
A bar for displaying non-blocking messages to the user.
 
This class is a composition of two QSettings instances:
 
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
 
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
 
Encapsulates the contents and formatting of a single table cell.
 
void setIncludeTableHeader(bool included)
Sets whether the table includes a header row.
 
QgsTableContents tableContents() const
Returns the current contents of the editor widget table.
 
void setTableHeaders(const QVariantList &headers)
Sets the table headers.
 
bool includeTableHeader() const
Returns true if the table includes a header row.
 
QgsTableEditorDialog(QWidget *parent=nullptr)
Constructor for QgsTableEditorDialog with the specified parent widget.
 
void includeHeaderChanged(bool included)
Emitted whenever the "include table header" setting is changed.
 
void setTableColumnWidth(int column, double width)
Sets the configured column width for the specified column.
 
void tableChanged()
Emitted whenever the table contents are changed.
 
void setTableRowHeight(int row, double height)
Sets the configured row height for the specified row.
 
void registerExpressionContextGenerator(QgsExpressionContextGenerator *generator)
Register an expression context generator class that will be used to retrieve an expression context fo...
 
bool setTableContentsFromClipboard()
Parses the clipboard text into contents to show in the editor widget.
 
QVariantList tableHeaders() const
Returns the table header values.
 
void closeEvent(QCloseEvent *) override
 
double tableRowHeight(int row)
Returns the configured row height for the specified row, or 0 if an automatic height should be used f...
 
double tableColumnWidth(int column)
Returns the configured column width for the specified column, or 0 if an automatic width should be us...
 
void setTableContents(const QgsTableContents &contents)
Sets the contents to show in the editor widget.
 
#define QgsDebugError(str)
 
QVector< QgsTableRow > QgsTableContents
A set of table rows.
 
QVector< QgsTableCell > QgsTableRow
A row of table cells.