Skip to content

Commit

Permalink
PG source select dlg: show multiline comments in tooltips
Browse files Browse the repository at this point in the history
Fixes #32257
  • Loading branch information
elpaso committed Oct 22, 2019
1 parent 6d38921 commit 520a879
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/providers/postgres/qgspgsourceselect.cpp
Expand Up @@ -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
{
Expand Down Expand Up @@ -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…" ) );
Expand Down Expand Up @@ -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 ) );

Expand Down
3 changes: 2 additions & 1 deletion src/providers/postgres/qgspgtablemodel.cpp
Expand Up @@ -99,6 +99,7 @@ void QgsPgTableModel::addTableEntry( const QgsPostgresLayerProperty &layerProper

QStandardItem *tableItem = new QStandardItem( layerProperty.tableName );
QStandardItem *commentItem = new QStandardItem( layerProperty.tableComment );
commentItem->setToolTip( layerProperty.tableComment );
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() );
Expand Down Expand Up @@ -190,7 +191,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() );
}
Expand Down

0 comments on commit 520a879

Please sign in to comment.