Skip to content
Permalink
Browse files

Add refresh schemas button to combobox

Since we don't auto update the schema list by listening to database
changes, we need a way for users to manually refresh the list
  • Loading branch information
nyalldawson committed Mar 8, 2020
1 parent e8e13ec commit bd5dcd29a1e57c31a22d227856483d23a5c772aa
Showing with 10 additions and 0 deletions.
  1. +10 −0 src/gui/qgsdatabaseschemacombobox.cpp
@@ -15,7 +15,9 @@

#include "qgsdatabaseschemacombobox.h"
#include "qgsdatabaseschemamodel.h"
#include "qgsapplication.h"
#include <QHBoxLayout>
#include <QToolButton>

QgsDatabaseSchemaComboBox::QgsDatabaseSchemaComboBox( const QString &provider, const QString &connection, QWidget *parent )
: QWidget( parent )
@@ -49,8 +51,16 @@ void QgsDatabaseSchemaComboBox::init()
QHBoxLayout *l = new QHBoxLayout();
l->setContentsMargins( 0, 0, 0, 0 );
l->addWidget( mComboBox );

QToolButton *refreshButton = new QToolButton();
refreshButton->setAutoRaise( true );
refreshButton->setToolTip( tr( "Refresh schemas" ) );
refreshButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mActionRefresh.svg" ) ) );
l->addWidget( refreshButton );
setLayout( l );

connect( refreshButton, &QToolButton::clicked, this, &QgsDatabaseSchemaComboBox::refreshSchemas );

connect( mComboBox, static_cast < void ( QComboBox::* )( int ) > ( &QComboBox::activated ), this, &QgsDatabaseSchemaComboBox::indexChanged );
connect( mSortModel, &QAbstractItemModel::rowsInserted, this, &QgsDatabaseSchemaComboBox::rowsChanged );
connect( mSortModel, &QAbstractItemModel::rowsRemoved, this, &QgsDatabaseSchemaComboBox::rowsChanged );

0 comments on commit bd5dcd2

Please sign in to comment.
You can’t perform that action at this time.