Skip to content

Commit

Permalink
Add refresh schemas button to combobox
Browse files Browse the repository at this point in the history
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 9, 2020
1 parent e8e13ec commit bd5dcd2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/gui/qgsdatabaseschemacombobox.cpp
Expand Up @@ -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 )
Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit bd5dcd2

Please sign in to comment.