QGIS API Documentation  2.12.0-Lyon
qgsvaluemapsearchwidgetwrapper.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsdefaultsearchwidgettwrapper.cpp
3  --------------------------------------
4  Date : 31.5.2015
5  Copyright : (C) 2015 Karolina Alexiou (carolinux)
6  Email : carolinegr at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
17 #include "qgstexteditconfigdlg.h"
18 
19 #include "qgsfield.h"
20 #include "qgsfieldvalidator.h"
21 
22 #include <QSettings>
23 #include <QSizePolicy>
24 
26  : QgsDefaultSearchWidgetWrapper( vl, fieldIdx, parent ),
27  mComboBox( NULL )
28 {
29 }
30 
32 {
33  return new QComboBox( parent );
34 }
35 
36 void QgsValueMapSearchWidgetWrapper::comboBoxIndexChanged( int )
37 {
38  if ( mComboBox )
39  setExpression( mComboBox->itemData( mComboBox->currentIndex() ).toString() );
40 }
41 
43 {
44  return true;
45 }
46 
48 {
49  mComboBox = qobject_cast<QComboBox*>( editor );
50 
51  if ( mComboBox )
52  {
53  const QgsEditorWidgetConfig cfg = config();
55  mComboBox->addItem( tr( "Please select" ), "" );
56 
57  while ( it != cfg.constEnd() )
58  {
59  mComboBox->addItem( it.key(), it.value() );
60  ++it;
61  }
62  connect( mComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( comboBoxIndexChanged( int ) ) );
63  }
64 }
65 
const_iterator constBegin() const
QString tr(const char *sourceText, const char *disambiguation, int n)
void addItem(const QString &text, const QVariant &userData)
QgsValueMapSearchWidgetWrapper(QgsVectorLayer *vl, int fieldIdx, QWidget *parent=0)
const QgsEditorWidgetConfig config()
Returns the whole config.
bool applyDirectly() override
If this is true, then this search widget should take effect directly when its expression changes...
const_iterator constEnd() const
QVariant itemData(int index, int role) const
void initWidget(QWidget *editor) override
This method should initialize the editor widget with runtime data.
typedef ConstIterator
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Represents a vector layer which manages a vector based data sets.
QWidget * createWidget(QWidget *parent) override
This method should create a new widget with the provided parent.