21 #include <QFileDialog>    22 #include <QMessageBox>    23 #include <QTextStream>    30   tableWidget->insertRow( 0 );
    32   connect( addNullButton, SIGNAL( clicked() ), 
this, SLOT( addNullButtonPushed() ) );
    33   connect( removeSelectedButton, SIGNAL( clicked() ), 
this, SLOT( removeSelectedButtonPushed() ) );
    34   connect( loadFromLayerButton, SIGNAL( clicked() ), 
this, SLOT( loadFromLayerButtonPushed() ) );
    35   connect( loadFromCSVButton, SIGNAL( clicked() ), 
this, SLOT( loadFromCSVButtonPushed() ) );
    36   connect( tableWidget, SIGNAL( cellChanged( 
int, 
int ) ), 
this, SLOT( vCellChanged( 
int, 
int ) ) );
    45   for ( 
int i = 0; i < tableWidget->rowCount() - 1; i++ )
    54     if (( ks == settings.
value( 
"qgis/nullValue", 
"NULL" ).
toString() ) && !( ki->
flags() & Qt::ItemIsEditable ) )
    63       cfg.insert( vi->
text(), ks );
    72   tableWidget->clearContents();
    73   for ( 
int i = tableWidget->rowCount() - 1; i > 0; i-- )
    75     tableWidget->removeRow( i );
    79   for ( QgsEditorWidgetConfig::ConstIterator mit = config.begin(); mit != config.end(); mit++, row++ )
    81     if ( mit.value().isNull() )
    82       setRow( row, mit.key(), 
QString() );
    84       setRow( row, mit.value().toString(), mit.key() );
    88 void QgsValueMapConfigDlg::vCellChanged( 
int row, 
int column )
    91   if ( row == tableWidget->rowCount() - 1 )
    93     tableWidget->insertRow( row + 1 );
    99 void QgsValueMapConfigDlg::removeSelectedButtonPushed()
   105   for ( i = 0; i < list.
size(); i++ )
   107     if ( list[i]->column() == 0 )
   109       int row = list[i]->row();
   110       if ( !rowsToRemove.
contains( row ) )
   112         rowsToRemove.
insert( row );
   116   for ( i = 0; i < rowsToRemove.
size(); i++ )
   118     tableWidget->removeRow( rowsToRemove.
values().
at( i ) - removed );
   126   tableWidget->clearContents();
   127   for ( 
int i = tableWidget->rowCount() - 1; i > 0; i-- )
   129     tableWidget->removeRow( i );
   141     if ( mit.value().isNull() )
   142       setRow( row, mit.key(), 
QString() );
   144       setRow( row, mit.key(), mit.value().toString() );
   148 void QgsValueMapConfigDlg::setRow( 
int row, 
const QString value, 
const QString description )
   153   tableWidget->insertRow( row );
   159     valueCell->
setFont( cellFont );
   160     valueCell->
setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
   161     descriptionCell->
setFont( cellFont );
   167   tableWidget->setItem( row, 0, valueCell );
   168   tableWidget->setItem( row, 1, descriptionCell );
   171 void QgsValueMapConfigDlg::addNullButtonPushed()
   176 void QgsValueMapConfigDlg::loadFromLayerButtonPushed()
   179   if ( !layerDialog.
exec() )
   185 void QgsValueMapConfigDlg::loadFromCSVButtonPushed()
   195   if ( !f.
open( QIODevice::ReadOnly ) )
   199                               tr( 
"Could not open file %1\nError was:%2" ).arg( fileName, f.
errorString() ),
   200                               QMessageBox::Cancel );
   207   QRegExp re0( 
"^([^;]*);(.*)$" );
   209   QRegExp re1( 
"^([^,]*),(.*)$" );
   245     if ( key == settings.
value( 
"qgis/nullValue", 
"NULL" ).
toString() )
 void updateMap(const QMap< QString, QVariant > &map, bool insertNull)
void setAutoDetectUnicode(bool enabled)
QString cap(int nth) const
QString readLine(qint64 maxlen)
void setMinimal(bool minimal)
QString errorString() const
const T & at(int i) const
QgsValueMapConfigDlg(QgsVectorLayer *vl, int fieldIdx, QWidget *parent)
const_iterator insert(const T &value)
QString tr(const char *sourceText, const char *disambiguation, int n)
QMap< QString, QVariant > & valueMap()
Getter to value map which is currently active. 
int indexIn(const QString &str, int offset, CaretMode caretMode) const
QVariantMap QgsEditorWidgetConfig
Holds a set of configuration parameters for a editor widget wrapper. 
QList< T > values() const
virtual QgsEditorWidgetConfig config() override
Create a configuration from the current GUI state. 
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
bool insertNull()
Returns true if the "Add NULL value" checkbox has been checked. 
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
virtual void setConfig(const QgsEditorWidgetConfig &config) override
Update the configuration widget to represent the given configuration. 
void setItalic(bool enable)
bool contains(const T &value) const
QVariant value(const QString &key, const QVariant &defaultValue) const
QString mid(int position, int n) const
QString getOpenFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFlags< QFileDialog::Option > options)
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. 
#define VALUEMAP_NULL_TEXT