mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-04 00:30:59 -05:00
Merge pull request #32336 from elpaso/bugfix-gh32257-pg-source-select-multiline-comments
PG source select dlg: show multiline comments in tooltips
This commit is contained in:
commit
4d72fc4181
Binary file not shown.
@ -40,6 +40,7 @@ email : sherman at mrcc.com
|
||||
#include <QStringList>
|
||||
#include <QStyledItemDelegate>
|
||||
|
||||
|
||||
//! Used to create an editor for when the user tries to change the contents of a cell
|
||||
QWidget *QgsPgSourceSelectDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const
|
||||
{
|
||||
@ -159,7 +160,7 @@ void QgsPgSourceSelectDelegate::setModelData( QWidget *editor, QAbstractItemMode
|
||||
{
|
||||
if ( index.column() == QgsPgTableModel::DbtmType )
|
||||
{
|
||||
QgsWkbTypes::Type type = ( QgsWkbTypes::Type ) cb->currentData().toInt();
|
||||
QgsWkbTypes::Type type = static_cast< QgsWkbTypes::Type >( cb->currentData().toInt() );
|
||||
|
||||
model->setData( index, QgsPgTableModel::iconForWkbType( type ), Qt::DecorationRole );
|
||||
model->setData( index, type != QgsWkbTypes::Unknown ? QgsPostgresConn::displayStringForWkbType( type ) : tr( "Select…" ) );
|
||||
@ -264,6 +265,7 @@ QgsPgSourceSelect::QgsPgSourceSelect( QWidget *parent, Qt::WindowFlags fl, QgsPr
|
||||
|
||||
mTablesTreeView->setModel( &mProxyModel );
|
||||
mTablesTreeView->setSortingEnabled( true );
|
||||
mTablesTreeView->setUniformRowHeights( true );
|
||||
mTablesTreeView->setEditTriggers( QAbstractItemView::CurrentChanged );
|
||||
mTablesTreeView->setItemDelegate( new QgsPgSourceSelectDelegate( this ) );
|
||||
|
||||
|
@ -99,6 +99,15 @@ void QgsPgTableModel::addTableEntry( const QgsPostgresLayerProperty &layerProper
|
||||
|
||||
QStandardItem *tableItem = new QStandardItem( layerProperty.tableName );
|
||||
QStandardItem *commentItem = new QStandardItem( layerProperty.tableComment );
|
||||
if ( ! layerProperty.tableComment.isEmpty() )
|
||||
{
|
||||
// word wrap
|
||||
QString commentText { layerProperty.tableComment };
|
||||
commentText.replace( QRegularExpression( QStringLiteral( "^\n*" ) ), QString() );
|
||||
commentItem->setText( commentText );
|
||||
commentItem->setToolTip( QStringLiteral( "<span>%1</span>" ).arg( commentText.replace( '\n', QStringLiteral( "<br/>" ) ) ) );
|
||||
commentItem->setTextAlignment( Qt::AlignTop );
|
||||
}
|
||||
QStandardItem *geomItem = new QStandardItem( layerProperty.geometryColName );
|
||||
QStandardItem *sridItem = new QStandardItem( wkbType != QgsWkbTypes::NoGeometry ? QString::number( srid ) : QString() );
|
||||
sridItem->setEditable( wkbType != QgsWkbTypes::NoGeometry && srid == std::numeric_limits<int>::min() );
|
||||
@ -190,7 +199,7 @@ void QgsPgTableModel::addTableEntry( const QgsPostgresLayerProperty &layerProper
|
||||
else
|
||||
item->setFlags( item->flags() & ~Qt::ItemIsSelectable );
|
||||
|
||||
if ( tip.isEmpty() && item != checkPkUnicityItem && item != selItem )
|
||||
if ( item->toolTip().isEmpty() && tip.isEmpty() && item != checkPkUnicityItem && item != selItem )
|
||||
{
|
||||
item->setToolTip( QString() );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user