Skip to content

Commit 471e67f

Browse files
committedFeb 21, 2018
mNofColumns in value relation widget
mNofColumns defining the number of columns when "allowMulti" is checked. The widged is now a tableWidget instead of listWidget. ListWidged stuff is removed - including in valuerelationsearchwidget because unused. Tests are changed from list to table as well.
1 parent a7ca742 commit 471e67f

File tree

7 files changed

+187
-148
lines changed

7 files changed

+187
-148
lines changed
 

‎src/gui/editorwidgets/qgsvaluerelationconfigdlg.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ QgsValueRelationConfigDlg::QgsValueRelationConfigDlg( QgsVectorLayer *vl, int fi
2727
connect( mLayerName, &QgsMapLayerComboBox::layerChanged, mValueColumn, &QgsFieldComboBox::setLayer );
2828
connect( mEditExpression, &QAbstractButton::clicked, this, &QgsValueRelationConfigDlg::editExpression );
2929

30+
mNofColumns->setMinimum( 1 );
31+
mNofColumns->setMaximum( 10 );
32+
mNofColumns->setValue( 1 );
33+
3034
connect( mLayerName, &QgsMapLayerComboBox::layerChanged, this, &QgsEditorConfigWidget::changed );
3135
connect( mKeyColumn, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsEditorConfigWidget::changed );
3236
connect( mValueColumn, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsEditorConfigWidget::changed );
@@ -35,6 +39,14 @@ QgsValueRelationConfigDlg::QgsValueRelationConfigDlg( QgsVectorLayer *vl, int fi
3539
connect( mOrderByValue, &QAbstractButton::toggled, this, &QgsEditorConfigWidget::changed );
3640
connect( mFilterExpression, &QTextEdit::textChanged, this, &QgsEditorConfigWidget::changed );
3741
connect( mUseCompleter, &QAbstractButton::toggled, this, &QgsEditorConfigWidget::changed );
42+
connect( mAllowMulti, &QAbstractButton::toggled, this, [ = ]( bool checked )
43+
{
44+
label_nofColumns->setEnabled( checked );
45+
mNofColumns->setEnabled( checked );
46+
}
47+
);
48+
49+
connect( mNofColumns, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), this, &QgsEditorConfigWidget::changed );
3850
}
3951

4052
QVariantMap QgsValueRelationConfigDlg::config()
@@ -45,6 +57,7 @@ QVariantMap QgsValueRelationConfigDlg::config()
4557
cfg.insert( QStringLiteral( "Key" ), mKeyColumn->currentField() );
4658
cfg.insert( QStringLiteral( "Value" ), mValueColumn->currentField() );
4759
cfg.insert( QStringLiteral( "AllowMulti" ), mAllowMulti->isChecked() );
60+
cfg.insert( QStringLiteral( "NofColumns" ), mNofColumns->value() );
4861
cfg.insert( QStringLiteral( "AllowNull" ), mAllowNull->isChecked() );
4962
cfg.insert( QStringLiteral( "OrderByValue" ), mOrderByValue->isChecked() );
5063
cfg.insert( QStringLiteral( "FilterExpression" ), mFilterExpression->toPlainText() );
@@ -60,6 +73,12 @@ void QgsValueRelationConfigDlg::setConfig( const QVariantMap &config )
6073
mKeyColumn->setField( config.value( QStringLiteral( "Key" ) ).toString() );
6174
mValueColumn->setField( config.value( QStringLiteral( "Value" ) ).toString() );
6275
mAllowMulti->setChecked( config.value( QStringLiteral( "AllowMulti" ) ).toBool() );
76+
mNofColumns->setValue( config.value( QStringLiteral( "NofColumns" ), 1 ).toInt() );
77+
if ( !mAllowMulti->isChecked() )
78+
{
79+
label_nofColumns->setEnabled( false );
80+
mNofColumns->setEnabled( false );
81+
}
6382
mAllowNull->setChecked( config.value( QStringLiteral( "AllowNull" ) ).toBool() );
6483
mOrderByValue->setChecked( config.value( QStringLiteral( "OrderByValue" ) ).toBool() );
6584
mFilterExpression->setPlainText( config.value( QStringLiteral( "FilterExpression" ) ).toString() );

‎src/gui/editorwidgets/qgsvaluerelationsearchwidgetwrapper.cpp

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,6 @@ QVariant QgsValueRelationSearchWidgetWrapper::value() const
5454
}
5555
}
5656

57-
if ( mListWidget )
58-
{
59-
QStringList selection;
60-
for ( int i = 0; i < mListWidget->count(); ++i )
61-
{
62-
QListWidgetItem *item = mListWidget->item( i );
63-
if ( item->checkState() == Qt::Checked )
64-
selection << item->data( Qt::UserRole ).toString();
65-
}
66-
67-
v = selection.join( QStringLiteral( "," ) ).prepend( '{' ).append( '}' );
68-
}
69-
7057
if ( mLineEdit )
7158
{
7259
Q_FOREACH ( const QgsValueRelationFieldFormatter::ValueRelationItem &i, mCache )
@@ -141,10 +128,6 @@ void QgsValueRelationSearchWidgetWrapper::clearWidget()
141128
{
142129
mComboBox->setCurrentIndex( 0 );
143130
}
144-
if ( mListWidget )
145-
{
146-
mListWidget->clearSelection();
147-
}
148131
if ( mLineEdit )
149132
{
150133
mLineEdit->setText( QString() );
@@ -157,10 +140,6 @@ void QgsValueRelationSearchWidgetWrapper::setEnabled( bool enabled )
157140
{
158141
mComboBox->setEnabled( enabled );
159142
}
160-
if ( mListWidget )
161-
{
162-
mListWidget->setEnabled( enabled );
163-
}
164143
if ( mLineEdit )
165144
{
166145
mLineEdit->setEnabled( enabled );
@@ -231,7 +210,6 @@ void QgsValueRelationSearchWidgetWrapper::initWidget( QWidget *editor )
231210
mCache = QgsValueRelationFieldFormatter::createCache( config() );
232211

233212
mComboBox = qobject_cast<QComboBox *>( editor );
234-
mListWidget = qobject_cast<QListWidget *>( editor );
235213
mLineEdit = qobject_cast<QLineEdit *>( editor );
236214

237215
if ( mComboBox )
@@ -249,18 +227,6 @@ void QgsValueRelationSearchWidgetWrapper::initWidget( QWidget *editor )
249227

250228
connect( mComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsValueRelationSearchWidgetWrapper::onValueChanged );
251229
}
252-
else if ( mListWidget )
253-
{
254-
Q_FOREACH ( const QgsValueRelationFieldFormatter::ValueRelationItem &element, mCache )
255-
{
256-
QListWidgetItem *item = nullptr;
257-
item = new QListWidgetItem( element.value );
258-
item->setData( Qt::UserRole, element.key );
259-
260-
mListWidget->addItem( item );
261-
}
262-
connect( mListWidget, &QListWidget::itemChanged, this, &QgsValueRelationSearchWidgetWrapper::onValueChanged );
263-
}
264230
else if ( mLineEdit )
265231
{
266232
QStringList values;

‎src/gui/editorwidgets/qgsvaluerelationsearchwidgetwrapper.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "qgsvaluerelationfieldformatter.h"
2222

2323
#include <QComboBox>
24-
#include <QListWidget>
2524
#include <QLineEdit>
2625
#include "qgis_gui.h"
2726

@@ -65,7 +64,6 @@ class GUI_EXPORT QgsValueRelationSearchWidgetWrapper : public QgsSearchWidgetWra
6564

6665
private:
6766
QComboBox *mComboBox = nullptr;
68-
QListWidget *mListWidget = nullptr;
6967
QLineEdit *mLineEdit = nullptr;
7068

7169
QgsValueRelationFieldFormatter::ValueRelationCache mCache;

‎src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.cpp

Lines changed: 75 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "qgsfilterlineedit.h"
2424
#include "qgsfeatureiterator.h"
2525
#include "qgsvaluerelationfieldformatter.h"
26+
#include "qgslogger.h"
2627

2728
#include <QStringListModel>
2829
#include <QCompleter>
@@ -46,16 +47,21 @@ QVariant QgsValueRelationWidgetWrapper::value() const
4647
}
4748
}
4849

49-
if ( mListWidget )
50+
if ( mTableWidget )
5051
{
5152
QStringList selection;
52-
for ( int i = 0; i < mListWidget->count(); ++i )
53+
for ( int j = 0; j < mTableWidget->rowCount(); j++ )
5354
{
54-
QListWidgetItem *item = mListWidget->item( i );
55-
if ( item->checkState() == Qt::Checked )
56-
selection << item->data( Qt::UserRole ).toString();
55+
for ( int i = 0; i < config( QStringLiteral( "NofColumns" ) ).toInt(); ++i )
56+
{
57+
QTableWidgetItem *item = mTableWidget->item( j, i );
58+
if ( item )
59+
{
60+
if ( item->checkState() == Qt::Checked )
61+
selection << item->data( Qt::UserRole ).toString();
62+
}
63+
}
5764
}
58-
5965
v = selection.join( QStringLiteral( "," ) ).prepend( '{' ).append( '}' );
6066
}
6167

@@ -78,7 +84,7 @@ QWidget *QgsValueRelationWidgetWrapper::createWidget( QWidget *parent )
7884
{
7985
if ( config( QStringLiteral( "AllowMulti" ) ).toBool() )
8086
{
81-
return new QListWidget( parent );
87+
return new QTableWidget( parent );
8288
}
8389
else if ( config( QStringLiteral( "UseCompleter" ) ).toBool() )
8490
{
@@ -94,7 +100,7 @@ void QgsValueRelationWidgetWrapper::initWidget( QWidget *editor )
94100
mCache = QgsValueRelationFieldFormatter::createCache( config() );
95101

96102
mComboBox = qobject_cast<QComboBox *>( editor );
97-
mListWidget = qobject_cast<QListWidget *>( editor );
103+
mTableWidget = qobject_cast<QTableWidget *>( editor );
Code has comments. Press enter to view.
98104
mLineEdit = qobject_cast<QLineEdit *>( editor );
99105

100106
if ( mComboBox )
@@ -112,17 +118,39 @@ void QgsValueRelationWidgetWrapper::initWidget( QWidget *editor )
112118
connect( mComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ),
113119
this, static_cast<void ( QgsEditorWidgetWrapper::* )()>( &QgsEditorWidgetWrapper::emitValueChanged ) );
114120
}
115-
else if ( mListWidget )
121+
else if ( mTableWidget )
116122
{
117-
Q_FOREACH ( const QgsValueRelationFieldFormatter::ValueRelationItem &element, mCache )
123+
mTableWidget->horizontalHeader()->setResizeMode( QHeaderView::Stretch );
124+
mTableWidget->horizontalHeader()->setVisible( false );
125+
mTableWidget->verticalHeader()->setResizeMode( QHeaderView::Stretch );
126+
mTableWidget->verticalHeader()->setVisible( false );
127+
mTableWidget->setShowGrid( false );
128+
mTableWidget->setEditTriggers( QAbstractItemView::NoEditTriggers );
129+
mTableWidget->setSelectionMode( QAbstractItemView::NoSelection );
130+
if ( mCache.size() > 0 )
131+
mTableWidget->setRowCount( ( mCache.size() + config( QStringLiteral( "NofColumns" ) ).toInt() - 1 ) / config( QStringLiteral( "NofColumns" ) ).toInt() );
132+
else
133+
mTableWidget->setRowCount( 1 );
134+
if ( config( QStringLiteral( "NofColumns" ) ).toInt() > 0 )
135+
mTableWidget->setColumnCount( config( QStringLiteral( "NofColumns" ) ).toInt() );
136+
else
137+
mTableWidget->setColumnCount( 1 );
138+
139+
int row = 0, column = 0;
140+
for ( const QgsValueRelationFieldFormatter::ValueRelationItem &element : qgis::as_const( mCache ) )
118141
{
119-
QListWidgetItem *item = nullptr;
120-
item = new QListWidgetItem( element.value );
142+
if ( column == config( QStringLiteral( "NofColumns" ) ).toInt() )
143+
{
144+
row++;
145+
column = 0;
146+
}
147+
QTableWidgetItem *item = nullptr;
148+
item = new QTableWidgetItem( element.value );
121149
item->setData( Qt::UserRole, element.key );
122-
123-
mListWidget->addItem( item );
150+
mTableWidget->setItem( row, column, item );
151+
column++;
124152
}
125-
connect( mListWidget, &QListWidget::itemChanged, this, static_cast<void ( QgsEditorWidgetWrapper::* )()>( &QgsEditorWidgetWrapper::emitValueChanged ) );
153+
connect( mTableWidget, &QTableWidget::itemChanged, this, static_cast<void ( QgsEditorWidgetWrapper::* )()>( &QgsEditorWidgetWrapper::emitValueChanged ) );
126154
}
127155
else if ( mLineEdit )
128156
{
@@ -144,23 +172,29 @@ void QgsValueRelationWidgetWrapper::initWidget( QWidget *editor )
144172

145173
bool QgsValueRelationWidgetWrapper::valid() const
146174
{
147-
return mListWidget || mLineEdit || mComboBox;
175+
return mTableWidget || mLineEdit || mComboBox;
148176
}
149177

150178
void QgsValueRelationWidgetWrapper::setValue( const QVariant &value )
151179
{
152-
if ( mListWidget )
180+
if ( mTableWidget )
153181
{
154182
QStringList checkList;
155183
if ( value.type() == QVariant::StringList )
156184
checkList = value.toStringList();
157185
else if ( value.type() == QVariant::String )
158186
checkList = value.toString().remove( QChar( '{' ) ).remove( QChar( '}' ) ).split( ',' );
159187

160-
for ( int i = 0; i < mListWidget->count(); ++i )
188+
for ( int j = 0; j < mTableWidget->rowCount(); j++ )
161189
{
162-
QListWidgetItem *item = mListWidget->item( i );
163-
item->setCheckState( checkList.contains( item->data( Qt::UserRole ).toString() ) ? Qt::Checked : Qt::Unchecked );
190+
for ( int i = 0; i < config( QStringLiteral( "NofColumns" ) ).toInt() ; ++i )
191+
{
192+
QTableWidgetItem *item = mTableWidget->item( j, i );
193+
if ( item )
194+
{
195+
item->setCheckState( checkList.contains( item->data( Qt::UserRole ).toString() ) ? Qt::Checked : Qt::Unchecked );
196+
}
197+
}
164198
}
165199
}
166200
else if ( mComboBox )
@@ -182,14 +216,17 @@ void QgsValueRelationWidgetWrapper::setValue( const QVariant &value )
182216

183217
void QgsValueRelationWidgetWrapper::showIndeterminateState()
184218
{
185-
if ( mListWidget )
219+
if ( mTableWidget )
186220
{
187-
mListWidget->blockSignals( true );
188-
for ( int i = 0; i < mListWidget->count(); ++i )
221+
mTableWidget->blockSignals( true );
222+
for ( int j = 0; j < mTableWidget->rowCount(); j++ )
189223
{
190-
mListWidget->item( i )->setCheckState( Qt::PartiallyChecked );
224+
for ( int i = 0; i < config( QStringLiteral( "NofColumns" ) ).toInt(); ++i )
225+
{
226+
mTableWidget->item( j, i )->setCheckState( Qt::PartiallyChecked );
227+
}
191228
}
192-
mListWidget->blockSignals( false );
229+
mTableWidget->blockSignals( false );
193230
}
194231
else if ( mComboBox )
195232
{
@@ -208,16 +245,21 @@ void QgsValueRelationWidgetWrapper::setEnabled( bool enabled )
208245

209246
mEnabled = enabled;
210247

211-
if ( mListWidget )
248+
if ( mTableWidget )
212249
{
213-
for ( int i = 0; i < mListWidget->count(); ++i )
250+
for ( int j = 0; j < mTableWidget->rowCount(); j++ )
214251
{
215-
QListWidgetItem *item = mListWidget->item( i );
216-
217-
if ( enabled )
218-
item->setFlags( item->flags() | Qt::ItemIsEnabled );
219-
else
220-
item->setFlags( item->flags() & ~Qt::ItemIsEnabled );
252+
for ( int i = 0; i < mTableWidget->columnCount(); ++i )
253+
{
254+
QTableWidgetItem *item = mTableWidget->item( j, i );
255+
if ( item )
256+
{
257+
if ( enabled )
258+
item->setFlags( item->flags() | Qt::ItemIsEnabled );
259+
else
260+
item->setFlags( item->flags() & ~Qt::ItemIsEnabled );
261+
}
262+
}
221263
}
222264
}
223265
else

‎src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
#include "qgsvaluerelationfieldformatter.h"
2121

2222
#include <QComboBox>
23-
#include <QListWidget>
23+
#include <QTableWidget>
24+
#include <QHeaderView>
2425
#include <QLineEdit>
2526
#include "qgis_gui.h"
2627

@@ -72,7 +73,7 @@ class GUI_EXPORT QgsValueRelationWidgetWrapper : public QgsEditorWidgetWrapper
7273

7374
private:
7475
QComboBox *mComboBox = nullptr;
75-
QListWidget *mListWidget = nullptr;
76+
QTableWidget *mTableWidget = nullptr;
7677
QLineEdit *mLineEdit = nullptr;
7778

7879
QgsValueRelationFieldFormatter::ValueRelationCache mCache;

‎src/ui/editorwidgets/qgsvaluerelationconfigdlgbase.ui

Lines changed: 83 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,44 @@
1313
<property name="windowTitle">
1414
<string>Form</string>
1515
</property>
16-
<layout class="QGridLayout" name="gridLayout" columnstretch="0,1">
17-
<item row="0" column="0" colspan="2">
18-
<widget class="QLabel" name="label_8">
19-
<property name="text">
20-
<string>Select layer, key column and value column</string>
21-
</property>
22-
</widget>
16+
<layout class="QGridLayout" name="gridLayout" columnstretch="0,0,0">
17+
<item row="12" column="0" colspan="2">
18+
<layout class="QHBoxLayout" name="horizontalLayout">
19+
<item>
20+
<widget class="QLabel" name="label_19">
21+
<property name="text">
22+
<string>Filter expression</string>
23+
</property>
24+
<property name="buddy">
25+
<cstring>mValueColumn</cstring>
26+
</property>
27+
</widget>
28+
</item>
29+
<item>
30+
<widget class="QToolButton" name="mEditExpression">
31+
<property name="layoutDirection">
32+
<enum>Qt::RightToLeft</enum>
33+
</property>
34+
<property name="icon">
35+
<iconset resource="../../../images/images.qrc">
36+
<normaloff>:/images/themes/default/mIconExpression.svg</normaloff>:/images/themes/default/mIconExpression.svg</iconset>
37+
</property>
38+
</widget>
39+
</item>
40+
<item>
41+
<spacer name="horizontalSpacer">
42+
<property name="orientation">
43+
<enum>Qt::Horizontal</enum>
44+
</property>
45+
<property name="sizeHint" stdset="0">
46+
<size>
47+
<width>40</width>
48+
<height>20</height>
49+
</size>
50+
</property>
51+
</spacer>
52+
</item>
53+
</layout>
2354
</item>
2455
<item row="1" column="0">
2556
<widget class="QLabel" name="label_5">
@@ -31,29 +62,43 @@
3162
</property>
3263
</widget>
3364
</item>
34-
<item row="1" column="1">
35-
<widget class="QgsMapLayerComboBox" name="mLayerName"/>
36-
</item>
37-
<item row="2" column="0">
38-
<widget class="QLabel" name="label_6">
65+
<item row="0" column="0" colspan="2">
66+
<widget class="QLabel" name="label_8">
3967
<property name="text">
40-
<string>Key column</string>
41-
</property>
42-
<property name="buddy">
43-
<cstring>mKeyColumn</cstring>
68+
<string>Select layer, key column and value column</string>
4469
</property>
4570
</widget>
4671
</item>
47-
<item row="5" column="0" colspan="2">
48-
<widget class="QCheckBox" name="mOrderByValue">
72+
<item row="4" column="0" colspan="2">
73+
<widget class="QCheckBox" name="mAllowNull">
4974
<property name="text">
50-
<string>Order by value</string>
75+
<string>Allow NULL value</string>
5176
</property>
5277
</widget>
5378
</item>
5479
<item row="2" column="1">
5580
<widget class="QgsFieldComboBox" name="mKeyColumn"/>
5681
</item>
82+
<item row="3" column="1">
83+
<widget class="QgsFieldComboBox" name="mValueColumn"/>
84+
</item>
85+
<item row="10" column="0" colspan="2">
86+
<widget class="QCheckBox" name="mUseCompleter">
87+
<property name="text">
88+
<string>Use completer</string>
89+
</property>
90+
</widget>
91+
</item>
92+
<item row="2" column="0">
93+
<widget class="QLabel" name="label_6">
94+
<property name="text">
95+
<string>Key column</string>
96+
</property>
97+
<property name="buddy">
98+
<cstring>mKeyColumn</cstring>
99+
</property>
100+
</widget>
101+
</item>
57102
<item row="3" column="0">
58103
<widget class="QLabel" name="label_7">
59104
<property name="text">
@@ -64,70 +109,35 @@
64109
</property>
65110
</widget>
66111
</item>
67-
<item row="3" column="1">
68-
<widget class="QgsFieldComboBox" name="mValueColumn"/>
69-
</item>
70-
<item row="4" column="0" colspan="2">
71-
<widget class="QCheckBox" name="mAllowNull">
112+
<item row="6" column="0" colspan="2">
113+
<widget class="QCheckBox" name="mOrderByValue">
72114
<property name="text">
73-
<string>Allow NULL value</string>
115+
<string>Order by value</string>
74116
</property>
75117
</widget>
76118
</item>
77-
<item row="6" column="0" colspan="2">
78-
<widget class="QCheckBox" name="mAllowMulti">
119+
<item row="1" column="1">
120+
<widget class="QgsMapLayerComboBox" name="mLayerName"/>
121+
</item>
122+
<item row="8" column="0">
123+
<widget class="QLabel" name="label_nofColumns">
79124
<property name="text">
80-
<string>Allow multiple selections</string>
125+
<string>Number of columns</string>
81126
</property>
82127
</widget>
83128
</item>
129+
<item row="13" column="0" colspan="2">
130+
<widget class="QTextEdit" name="mFilterExpression"/>
131+
</item>
84132
<item row="7" column="0" colspan="2">
85-
<widget class="QCheckBox" name="mUseCompleter">
133+
<widget class="QCheckBox" name="mAllowMulti">
86134
<property name="text">
87-
<string>Use completer</string>
135+
<string>Allow multiple selections</string>
88136
</property>
89137
</widget>
90138
</item>
91-
<item row="10" column="0" colspan="2">
92-
<widget class="QTextEdit" name="mFilterExpression"/>
93-
</item>
94-
<item row="9" column="0" colspan="2">
95-
<layout class="QHBoxLayout" name="horizontalLayout">
96-
<item>
97-
<widget class="QLabel" name="label_19">
98-
<property name="text">
99-
<string>Filter expression</string>
100-
</property>
101-
<property name="buddy">
102-
<cstring>mValueColumn</cstring>
103-
</property>
104-
</widget>
105-
</item>
106-
<item>
107-
<widget class="QToolButton" name="mEditExpression">
108-
<property name="layoutDirection">
109-
<enum>Qt::RightToLeft</enum>
110-
</property>
111-
<property name="icon">
112-
<iconset resource="../../images/images.qrc">
113-
<normaloff>:/images/themes/default/mIconExpression.svg</normaloff>:/images/themes/default/mIconExpression.svg</iconset>
114-
</property>
115-
</widget>
116-
</item>
117-
<item>
118-
<spacer name="horizontalSpacer">
119-
<property name="orientation">
120-
<enum>Qt::Horizontal</enum>
121-
</property>
122-
<property name="sizeHint" stdset="0">
123-
<size>
124-
<width>40</width>
125-
<height>20</height>
126-
</size>
127-
</property>
128-
</spacer>
129-
</item>
130-
</layout>
139+
<item row="8" column="1">
140+
<widget class="QSpinBox" name="mNofColumns"/>
131141
</item>
132142
</layout>
133143
</widget>
@@ -154,6 +164,8 @@
154164
<tabstop>mEditExpression</tabstop>
155165
<tabstop>mFilterExpression</tabstop>
156166
</tabstops>
157-
<resources/>
167+
<resources>
168+
<include location="../../../images/images.qrc"/>
169+
</resources>
158170
<connections/>
159171
</ui>

‎tests/src/gui/testqgsvaluerelationwidgetwrapper.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,26 +76,27 @@ void TestQgsValueRelationWidgetWrapper::testScrollBarUnlocked()
7676
w.setEnabled( true );
7777

7878
// add an item virtually
79-
QListWidgetItem item;
79+
QTableWidgetItem item;
8080
item.setText( QStringLiteral( "MyText" ) );
81-
w.mListWidget->addItem( &item );
82-
QCOMPARE( w.mListWidget->item( 0 )->text(), QString( "MyText" ) );
81+
w.mTableWidget->setItem( 0, 0, &item );
82+
83+
QCOMPARE( w.mTableWidget->item( 0, 0 )->text(), QString( "MyText" ) );
8384

8485
// when the widget wrapper is enabled, the container should be enabled
8586
// as well as items
8687
w.setEnabled( true );
8788

8889
QCOMPARE( w.widget()->isEnabled(), true );
8990

90-
bool itemEnabled = w.mListWidget->item( 0 )->flags() & Qt::ItemIsEnabled;
91+
bool itemEnabled = w.mTableWidget->item( 0, 0 )->flags() & Qt::ItemIsEnabled;
9192
QCOMPARE( itemEnabled, true );
9293

9394
// when the widget wrapper is disabled, the container should still be enabled
9495
// to keep the scrollbar available but items should be disabled to avoid
9596
// edition
9697
w.setEnabled( false );
9798

98-
itemEnabled = w.mListWidget->item( 0 )->flags() & Qt::ItemIsEnabled;
99+
itemEnabled = w.mTableWidget->item( 0, 0 )->flags() & Qt::ItemIsEnabled;
99100
QCOMPARE( itemEnabled, false );
100101

101102
QCOMPARE( w.widget()->isEnabled(), true );
@@ -104,7 +105,7 @@ void TestQgsValueRelationWidgetWrapper::testScrollBarUnlocked()
104105
w.setEnabled( true );
105106

106107
QCOMPARE( w.widget()->isEnabled(), true );
107-
itemEnabled = w.mListWidget->item( 0 )->flags() & Qt::ItemIsEnabled;
108+
itemEnabled = w.mTableWidget->item( 0, 0 )->flags() & Qt::ItemIsEnabled;
108109
QCOMPARE( itemEnabled, true );
109110
}
110111

0 commit comments

Comments
 (0)
Please sign in to comment.