Skip to content
Permalink
Browse files

fix style selection when loading from database (fixes #12863)

  • Loading branch information
jef-n committed Jun 3, 2015
1 parent d71b5c6 commit d53d30d29023be261ca6cd9bce9cfaac60d6ef78
Showing with 19 additions and 19 deletions.
  1. +17 −18 src/app/qgsloadstylefromdbdialog.cpp
  2. +0 −1 src/app/qgsloadstylefromdbdialog.h
  3. +2 −0 src/core/qgspallabeling.cpp
@@ -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 );
@@ -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() ) );

@@ -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, "" ) ) );
}
}
@@ -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();
}
@@ -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:
@@ -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;

0 comments on commit d53d30d

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