Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
use an enum for columns
  • Loading branch information
3nids authored and nyalldawson committed Jan 21, 2022
1 parent 08eedd7 commit 8291009
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/gui/providers/ogr/qgsogrdbsourceselect.cpp
Expand Up @@ -293,8 +293,8 @@ void QgsOgrDbSourceSelect::btnConnect_clicked()
{
mTablesTreeView->expand( proxyModel()->mapFromSource( mTableModel->indexFromItem( mTableModel->invisibleRootItem()->child( i ) ) ) );
}
mTablesTreeView->resizeColumnToContents( 0 );
mTablesTreeView->resizeColumnToContents( 1 );
mTablesTreeView->resizeColumnToContents( QgsOgrDbTableModel::DbtmTable );
mTablesTreeView->resizeColumnToContents( QgsOgrDbTableModel::DbtmType );

cbxAllowGeometrylessTables->setEnabled( true );

Expand Down
13 changes: 10 additions & 3 deletions src/gui/providers/ogr/qgsogrdbtablemodel.cpp
Expand Up @@ -27,7 +27,7 @@ QgsOgrDbTableModel::QgsOgrDbTableModel( QObject *parent )
<< tr( "Type" )
<< tr( "Geometry column" )
<< tr( "SQL" );
setHorizontalHeaderLabels( columns() );
setHorizontalHeaderLabels( mColumns );
}

QStringList QgsOgrDbTableModel::columns() const
Expand All @@ -42,8 +42,15 @@ int QgsOgrDbTableModel::defaultSearchColumn() const

bool QgsOgrDbTableModel::searchableColumn( int column ) const
{
Q_UNUSED( column )
return true;
Columns col = static_cast<Columns>( column );
switch ( col )
{
case QgsOgrDbTableModel::DbtmTable:
case QgsOgrDbTableModel::DbtmType:
case QgsOgrDbTableModel::DbtmGeomCol:
case QgsOgrDbTableModel::DbtmSql:
return true;
}
}

void QgsOgrDbTableModel::addTableEntry( const Qgis::BrowserLayerType &layerType, const QString &tableName, const QString &uri, const QString &geometryColName, const QString &geometryType, const QString &sql )
Expand Down
8 changes: 8 additions & 0 deletions src/gui/providers/ogr/qgsogrdbtablemodel.h
Expand Up @@ -54,6 +54,14 @@ class QgsOgrDbTableModel : public QgsAbstractDbTableModel
return mTableCount;
}

enum Columns
{
DbtmTable = 0,
DbtmType,
DbtmGeomCol,
DbtmSql,
};

//! Sets the DB full path
void setPath( const QString &path )
{
Expand Down

0 comments on commit 8291009

Please sign in to comment.