Skip to content

Commit d53d30d

Browse files
committedJun 3, 2015
fix style selection when loading from database (fixes #12863)
1 parent d71b5c6 commit d53d30d

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed
 

‎src/app/qgsloadstylefromdbdialog.cpp

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ QgsLoadStyleFromDBDialog::QgsLoadStyleFromDBDialog( QWidget *parent )
2020
{
2121
setupUi( this );
2222
setWindowTitle( "Load style from database" );
23-
mSelectedStyleId = tr( "" );
23+
mSelectedStyleId = "";
2424

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

3636
connect( mRelatedTable, SIGNAL( cellClicked( int, int ) ), this, SLOT( cellSelectedRelatedTable( int ) ) );
3737
connect( mOthersTable, SIGNAL( cellClicked( int, int ) ), this, SLOT( cellSelectedOthersTable( int ) ) );
38-
connect( mRelatedTable, SIGNAL( doubleClicked( QModelIndex ) ),
39-
this, SLOT( accept() ) );
40-
connect( mOthersTable, SIGNAL( doubleClicked( QModelIndex ) ),
41-
this, SLOT( accept() ) );
38+
connect( mRelatedTable, SIGNAL( doubleClicked( QModelIndex ) ), this, SLOT( accept() ) );
39+
connect( mOthersTable, SIGNAL( doubleClicked( QModelIndex ) ), this, SLOT( accept() ) );
4240
connect( mCancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
4341
connect( mLoadButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
4442

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

6058
void QgsLoadStyleFromDBDialog::initializeLists( QStringList ids, QStringList names, QStringList descriptions, int sectionLimit )
6159
{
62-
mIds = ids;
63-
mNames = names;
64-
mDescriptions = descriptions;
6560
mSectionLimit = sectionLimit;
66-
int relatedTableNOfCols = ( sectionLimit > 0 ) ? 2 : 1;
67-
int othersTableNOfCols = ( ids.count() - sectionLimit > 0 ) ? 2 : 1;
61+
int relatedTableNOfCols = sectionLimit > 0 ? 2 : 1;
62+
int othersTableNOfCols = ids.count() - sectionLimit > 0 ? 2 : 1;
6863
QString twoColsHeader( "Name;Description" );
6964
QString oneColsHeader( "No styles found in the database" );
70-
QString relatedTableHeader = ( relatedTableNOfCols == 1 ) ? oneColsHeader : twoColsHeader;
71-
QString othersTableHeader = ( othersTableNOfCols == 1 ) ? oneColsHeader : twoColsHeader;
65+
QString relatedTableHeader = relatedTableNOfCols == 1 ? oneColsHeader : twoColsHeader;
66+
QString othersTableHeader = othersTableNOfCols == 1 ? oneColsHeader : twoColsHeader;
7267

7368
mRelatedTable->setColumnCount( relatedTableNOfCols );
7469
mOthersTable->setColumnCount( othersTableNOfCols );
7570
mRelatedTable->setHorizontalHeaderLabels( relatedTableHeader.split( ";" ) );
7671
mOthersTable->setHorizontalHeaderLabels( othersTableHeader.split( ";" ) );
7772
mRelatedTable->setRowCount( sectionLimit );
7873
mOthersTable->setRowCount( ids.count() - sectionLimit );
79-
mRelatedTable->setDisabled(( relatedTableNOfCols == 1 ) );
80-
mOthersTable->setDisabled(( othersTableNOfCols == 1 ) );
74+
mRelatedTable->setDisabled( relatedTableNOfCols == 1 );
75+
mOthersTable->setDisabled( othersTableNOfCols == 1 );
8176

8277
for ( int i = 0; i < sectionLimit; i++ )
8378
{
84-
mRelatedTable->setItem( i, 0, new QTableWidgetItem( names.value( i, "" ) ) );
79+
QTableWidgetItem *item = new QTableWidgetItem( names.value( i, "" ) );
80+
item->setData( Qt::UserRole, ids[i] );
81+
mRelatedTable->setItem( i, 0, item );
8582
mRelatedTable->setItem( i, 1, new QTableWidgetItem( descriptions.value( i, "" ) ) );
8683
}
8784
for ( int i = sectionLimit; i < ids.count(); i++ )
8885
{
8986
int j = i - sectionLimit;
90-
mOthersTable->setItem( j, 0, new QTableWidgetItem( names.value( i, "" ) ) );
87+
QTableWidgetItem *item = new QTableWidgetItem( names.value( i, "" ) );
88+
item->setData( Qt::UserRole, ids[i] );
89+
mOthersTable->setItem( j, 0, item );
9190
mOthersTable->setItem( j, 1, new QTableWidgetItem( descriptions.value( i, "" ) ) );
9291
}
9392
}
@@ -100,11 +99,11 @@ QString QgsLoadStyleFromDBDialog::getSelectedStyleId()
10099
void QgsLoadStyleFromDBDialog::cellSelectedRelatedTable( int r )
101100
{
102101
mLoadButton->setEnabled( true );
103-
mSelectedStyleId = mIds.value( r );
102+
mSelectedStyleId = mRelatedTable->item( r, 0 )->data( Qt::UserRole ).toString();
104103
}
105104

106105
void QgsLoadStyleFromDBDialog::cellSelectedOthersTable( int r )
107106
{
108107
mLoadButton->setEnabled( true );
109-
mSelectedStyleId = mIds.value( r + mSectionLimit );
108+
mSelectedStyleId = mOthersTable->item( r, 0 )->data( Qt::UserRole ).toString();
110109
}

‎src/app/qgsloadstylefromdbdialog.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class APP_EXPORT QgsLoadStyleFromDBDialog : public QDialog, private Ui::QgsLoadS
1818
{
1919
QString mSelectedStyleId;
2020
int mSectionLimit;
21-
QStringList mIds, mNames, mDescriptions;
2221
QString qmlStyle;
2322
Q_OBJECT
2423
public:

‎src/core/qgspallabeling.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3400,6 +3400,8 @@ QStringList QgsPalLabeling::splitToGraphemes( const QString &text )
34003400

34013401
QgsGeometry* QgsPalLabeling::prepareGeometry( const QgsGeometry* geometry, const QgsRenderContext& context, const QgsCoordinateTransform* ct, double minSize, QgsGeometry* clipGeometry )
34023402
{
3403+
Q_UNUSED( minSize );
3404+
34033405
if ( !geometry )
34043406
{
34053407
return 0;

0 commit comments

Comments
 (0)
Please sign in to comment.