Skip to content

Commit

Permalink
fix style selection when loading from database (fixes #12863)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jun 3, 2015
1 parent d71b5c6 commit d53d30d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
35 changes: 17 additions & 18 deletions src/app/qgsloadstylefromdbdialog.cpp
Expand Up @@ -20,7 +20,7 @@ QgsLoadStyleFromDBDialog::QgsLoadStyleFromDBDialog( QWidget *parent )
{
setupUi( this );
setWindowTitle( "Load style from database" );
mSelectedStyleId = tr( "" );
mSelectedStyleId = "";

mLoadButton->setDisabled( true );
mRelatedTable->setEditTriggers( QTableWidget::NoEditTriggers );
Expand All @@ -35,10 +35,8 @@ QgsLoadStyleFromDBDialog::QgsLoadStyleFromDBDialog( QWidget *parent )

connect( mRelatedTable, SIGNAL( cellClicked( int, int ) ), this, SLOT( cellSelectedRelatedTable( int ) ) );
connect( mOthersTable, SIGNAL( cellClicked( int, int ) ), this, SLOT( cellSelectedOthersTable( int ) ) );
connect( mRelatedTable, SIGNAL( doubleClicked( QModelIndex ) ),
this, SLOT( accept() ) );
connect( mOthersTable, SIGNAL( doubleClicked( QModelIndex ) ),
this, SLOT( accept() ) );
connect( mRelatedTable, SIGNAL( doubleClicked( QModelIndex ) ), this, SLOT( accept() ) );
connect( mOthersTable, SIGNAL( doubleClicked( QModelIndex ) ), this, SLOT( accept() ) );
connect( mCancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
connect( mLoadButton, SIGNAL( clicked() ), this, SLOT( accept() ) );

Expand All @@ -59,35 +57,36 @@ QgsLoadStyleFromDBDialog::~QgsLoadStyleFromDBDialog()

void QgsLoadStyleFromDBDialog::initializeLists( QStringList ids, QStringList names, QStringList descriptions, int sectionLimit )
{
mIds = ids;
mNames = names;
mDescriptions = descriptions;
mSectionLimit = sectionLimit;
int relatedTableNOfCols = ( sectionLimit > 0 ) ? 2 : 1;
int othersTableNOfCols = ( ids.count() - sectionLimit > 0 ) ? 2 : 1;
int relatedTableNOfCols = sectionLimit > 0 ? 2 : 1;
int othersTableNOfCols = ids.count() - sectionLimit > 0 ? 2 : 1;
QString twoColsHeader( "Name;Description" );
QString oneColsHeader( "No styles found in the database" );
QString relatedTableHeader = ( relatedTableNOfCols == 1 ) ? oneColsHeader : twoColsHeader;
QString othersTableHeader = ( othersTableNOfCols == 1 ) ? oneColsHeader : twoColsHeader;
QString relatedTableHeader = relatedTableNOfCols == 1 ? oneColsHeader : twoColsHeader;
QString othersTableHeader = othersTableNOfCols == 1 ? oneColsHeader : twoColsHeader;

mRelatedTable->setColumnCount( relatedTableNOfCols );
mOthersTable->setColumnCount( othersTableNOfCols );
mRelatedTable->setHorizontalHeaderLabels( relatedTableHeader.split( ";" ) );
mOthersTable->setHorizontalHeaderLabels( othersTableHeader.split( ";" ) );
mRelatedTable->setRowCount( sectionLimit );
mOthersTable->setRowCount( ids.count() - sectionLimit );
mRelatedTable->setDisabled(( relatedTableNOfCols == 1 ) );
mOthersTable->setDisabled(( othersTableNOfCols == 1 ) );
mRelatedTable->setDisabled( relatedTableNOfCols == 1 );
mOthersTable->setDisabled( othersTableNOfCols == 1 );

for ( int i = 0; i < sectionLimit; i++ )
{
mRelatedTable->setItem( i, 0, new QTableWidgetItem( names.value( i, "" ) ) );
QTableWidgetItem *item = new QTableWidgetItem( names.value( i, "" ) );
item->setData( Qt::UserRole, ids[i] );
mRelatedTable->setItem( i, 0, item );
mRelatedTable->setItem( i, 1, new QTableWidgetItem( descriptions.value( i, "" ) ) );
}
for ( int i = sectionLimit; i < ids.count(); i++ )
{
int j = i - sectionLimit;
mOthersTable->setItem( j, 0, new QTableWidgetItem( names.value( i, "" ) ) );
QTableWidgetItem *item = new QTableWidgetItem( names.value( i, "" ) );
item->setData( Qt::UserRole, ids[i] );
mOthersTable->setItem( j, 0, item );
mOthersTable->setItem( j, 1, new QTableWidgetItem( descriptions.value( i, "" ) ) );
}
}
Expand All @@ -100,11 +99,11 @@ QString QgsLoadStyleFromDBDialog::getSelectedStyleId()
void QgsLoadStyleFromDBDialog::cellSelectedRelatedTable( int r )
{
mLoadButton->setEnabled( true );
mSelectedStyleId = mIds.value( r );
mSelectedStyleId = mRelatedTable->item( r, 0 )->data( Qt::UserRole ).toString();
}

void QgsLoadStyleFromDBDialog::cellSelectedOthersTable( int r )
{
mLoadButton->setEnabled( true );
mSelectedStyleId = mIds.value( r + mSectionLimit );
mSelectedStyleId = mOthersTable->item( r, 0 )->data( Qt::UserRole ).toString();
}
1 change: 0 additions & 1 deletion src/app/qgsloadstylefromdbdialog.h
Expand Up @@ -18,7 +18,6 @@ class APP_EXPORT QgsLoadStyleFromDBDialog : public QDialog, private Ui::QgsLoadS
{
QString mSelectedStyleId;
int mSectionLimit;
QStringList mIds, mNames, mDescriptions;
QString qmlStyle;
Q_OBJECT
public:
Expand Down
2 changes: 2 additions & 0 deletions src/core/qgspallabeling.cpp
Expand Up @@ -3400,6 +3400,8 @@ QStringList QgsPalLabeling::splitToGraphemes( const QString &text )

QgsGeometry* QgsPalLabeling::prepareGeometry( const QgsGeometry* geometry, const QgsRenderContext& context, const QgsCoordinateTransform* ct, double minSize, QgsGeometry* clipGeometry )
{
Q_UNUSED( minSize );

if ( !geometry )
{
return 0;
Expand Down

0 comments on commit d53d30d

Please sign in to comment.