21 #include <QFileDialog> 22 #include <QMessageBox> 23 #include <QTextStream> 30 tableWidget->insertRow( 0 );
32 connect( removeSelectedButton, SIGNAL( clicked() ),
this, SLOT( removeSelectedButtonPushed() ) );
33 connect( loadFromLayerButton, SIGNAL( clicked() ),
this, SLOT( loadFromLayerButtonPushed() ) );
34 connect( loadFromCSVButton, SIGNAL( clicked() ),
this, SLOT( loadFromCSVButtonPushed() ) );
35 connect( tableWidget, SIGNAL( cellChanged(
int,
int ) ),
this, SLOT( vCellChanged(
int,
int ) ) );
43 for (
int i = 0; i < tableWidget->rowCount() - 1; i++ )
66 tableWidget->clearContents();
67 for (
int i = tableWidget->rowCount() - 1; i > 0; i-- )
69 tableWidget->removeRow( i );
75 tableWidget->insertRow( row );
76 if ( mit.value().isNull() )
82 tableWidget->setItem( row, 0,
new QTableWidgetItem( mit.value().toString() ) );
88 void QgsValueMapConfigDlg::vCellChanged(
int row,
int column )
91 if ( row == tableWidget->rowCount() - 1 )
93 tableWidget->insertRow( row + 1 );
97 void QgsValueMapConfigDlg::removeSelectedButtonPushed()
103 for ( i = 0; i < list.
size(); i++ )
105 if ( list[i]->column() == 0 )
107 int row = list[i]->row();
108 if ( !rowsToRemove.
contains( row ) )
110 rowsToRemove.
insert( row );
114 for ( i = 0; i < rowsToRemove.
size(); i++ )
116 tableWidget->removeRow( rowsToRemove.
values().
at( i ) - removed );
123 tableWidget->clearContents();
124 for (
int i = tableWidget->rowCount() - 1; i > 0; i-- )
126 tableWidget->removeRow( i );
140 tableWidget->insertRow( row );
141 if ( mit.value().isNull() )
148 tableWidget->setItem( row, 1,
new QTableWidgetItem( mit.value().toString() ) );
153 void QgsValueMapConfigDlg::loadFromLayerButtonPushed()
156 if ( !layerDialog.
exec() )
162 void QgsValueMapConfigDlg::loadFromCSVButtonPushed()
170 if ( !f.
open( QIODevice::ReadOnly ) )
174 tr(
"Could not open file %1\nError was:%2" ).arg( fileName, f.
errorString() ),
175 QMessageBox::Cancel );
182 QRegExp re0(
"^([^;]*);(.*)$" );
184 QRegExp re1(
"^([^,]*),(.*)$" );
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
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.
bool contains(const T &value) const
QVariant value(const QString &key, const QVariant &defaultValue) const
QString mid(int position, int n) const
iterator insert(const Key &key, const T &value)
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.