Skip to content

Commit

Permalink
QMessageBox replaced by QgsMessageBar
Browse files Browse the repository at this point in the history
"Saved styles manager" renamed to "Database styles manager"
  • Loading branch information
jgrocha committed Jan 28, 2017
1 parent 72c5cf0 commit d60ddcc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
22 changes: 12 additions & 10 deletions src/app/qgsloadstylefromdbdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "qgsloadstylefromdbdialog.h"
#include "qgslogger.h"
#include "qgisapp.h"

#include <QSettings>
#include <QMessageBox>
Expand All @@ -25,7 +26,7 @@ QgsLoadStyleFromDBDialog::QgsLoadStyleFromDBDialog( QWidget *parent )
, mSectionLimit( 0 )
{
setupUi( this );
setWindowTitle( QStringLiteral( "Saved styles manager" ) );
setWindowTitle( QStringLiteral( "Database styles manager" ) );
mSelectedStyleId = QLatin1String( "" );
mSelectedStyleName = QLatin1String( "" );

Expand Down Expand Up @@ -135,14 +136,13 @@ void QgsLoadStyleFromDBDialog::otherTableSelectionChanged()
//deselect any other row on the other table widget
QTableWidgetSelectionRange range( 0, 0, mRelatedTable->rowCount() - 1, mRelatedTable->columnCount() - 1 );
mRelatedTable->setRangeSelected( range, false );

}

void QgsLoadStyleFromDBDialog::selectionChanged( QTableWidget *styleTable )
{
QTableWidgetItem *item;
QList<QTableWidgetItem *> selected = styleTable->selectedItems();
//QgsDebugMsg( QString( "itemSelectionChanged(): count() = %1" ).arg( selected.count() ) );

if ( selected.count() > 0 )
{
item = selected.at( 0 );
Expand All @@ -163,8 +163,7 @@ void QgsLoadStyleFromDBDialog::selectionChanged( QTableWidget *styleTable )
void QgsLoadStyleFromDBDialog::deleteStyleFromDB()
{
QString uri, msgError;
QString infoWindowTitle = QObject::tr( "Delete style %1 from %2" ).arg( mSelectedStyleName, mLayer->providerType() );
//QgsDebugMsg( QString( "Delete style: %1 " ).arg( mSelectedStyleName ) );
QString opInfo = QObject::tr( "Delete style %1 from %2" ).arg( mSelectedStyleName, mLayer->providerType() );

if ( QMessageBox::question( nullptr, QObject::tr( "Delete style" ),
QObject::tr( "Are you sure you want to delete the style %1?" ).arg( mSelectedStyleName ),
Expand All @@ -176,11 +175,12 @@ void QgsLoadStyleFromDBDialog::deleteStyleFromDB()

if ( !msgError.isNull() )
{
QMessageBox::warning( this, infoWindowTitle, msgError );
QgsDebugMsg( opInfo + " failed." );
QgisApp::instance()->messageBar()->pushMessage( opInfo , tr( "%1: fail. %2" ).arg( opInfo, msgError ), QgsMessageBar::WARNING, QgisApp::instance()->messageTimeout() );
}
else
{
QMessageBox::information( this, infoWindowTitle, tr( "Style deleted" ) );
QgisApp::instance()->messageBar()->pushMessage( opInfo , tr( "%1: success" ).arg( opInfo ), QgsMessageBar::INFO, QgisApp::instance()->messageTimeout() );

//Delete all rows from the UI table widgets
mRelatedTable->setRowCount( 0 );
Expand All @@ -193,9 +193,11 @@ void QgsLoadStyleFromDBDialog::deleteStyleFromDB()
int sectionLimit = mLayer->listStylesInDatabase( ids, names, descriptions, errorMsg );
if ( !errorMsg.isNull() )
{
QMessageBox::warning( this, tr( "Error occurred retrieving styles from database" ), errorMsg );
return;
QgisApp::instance()->messageBar()->pushMessage( tr( "Error occurred retrieving styles from database" ), errorMsg, QgsMessageBar::WARNING, QgisApp::instance()->messageTimeout() );
}
else
{
initializeLists( ids, names, descriptions, sectionLimit );
}
initializeLists( ids, names, descriptions, sectionLimit );
}
}
6 changes: 3 additions & 3 deletions src/app/qgsvectorlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
//for loading
mLoadStyleMenu = new QMenu( this );
mLoadStyleMenu->addAction( tr( "Load from file..." ) );
mLoadStyleMenu->addAction( tr( "Saved styles manager" ) );
mLoadStyleMenu->addAction( tr( "Database styles manager" ) );
//mActionLoadStyle->setContextMenuPolicy( Qt::PreventContextMenu );
mActionLoadStyle->setMenu( mLoadStyleMenu );

Expand Down Expand Up @@ -883,11 +883,11 @@ void QgsVectorLayerProperties::saveStyleAs( StyleType styleType )

if ( !msgError.isNull() )
{
QMessageBox::warning( this, infoWindowTitle, msgError );
QgisApp::instance()->messageBar()->pushMessage( infoWindowTitle , msgError, QgsMessageBar::WARNING, QgisApp::instance()->messageTimeout() );
}
else
{
QMessageBox::information( this, infoWindowTitle, tr( "Style saved" ) );
QgisApp::instance()->messageBar()->pushMessage( infoWindowTitle , tr( "Style saved" ), QgsMessageBar::INFO, QgisApp::instance()->messageTimeout() );
}

}
Expand Down
3 changes: 3 additions & 0 deletions src/core/qgsvectordataprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,9 @@ bool QgsVectorDataProvider::isDeleteStyleFromDBSupported() const

void QgsVectorDataProvider::deleteStyleById( const QString& uri, QString styleId, QString& errCause )
{
Q_UNUSED( uri );
Q_UNUSED( styleId );
Q_UNUSED( errCause );
return;
}

Expand Down

0 comments on commit d60ddcc

Please sign in to comment.