int QgsAttributeTableDialog::columnBoxColumnId() { QgsFieldMap fieldMap = mLayer->pendingFields(); QgsFieldMap::Iterator it = fieldMap.begin(); for ( ; it != fieldMap.end(); ++it ) if ( it.value().name() == mColumnBox->currentText() ) return it.key(); return 0; }
void QgsAttributeTableDialog::columnBoxInit() { QgsFieldMap fieldMap = mLayer->pendingFields(); QgsFieldMap::Iterator it = fieldMap.begin(); for ( ; it != fieldMap.end(); ++it ) if ( mLayer->editType( it.key() ) != QgsVectorLayer::Hidden ) mColumnBox->addItem( it.value().name() ); mColumnBox->setCurrentIndex( mColumnBox->findText( mLayer->displayField() ) ); }
int OptVectorLayer::addFeatureWithDefaultValue( OptFeature& f ) { //{zhangliye2715:api} if ( !isEditable() ) { startEditing(); } // add the fields to the QgsFeature QgsVectorDataProvider* provider = dataProvider(); const QgsFieldMap fields = provider->fields(); for ( QgsFieldMap::const_iterator it = fields.begin(); it != fields.end(); ++it ) { f.addAttribute( it.key(), provider->defaultValue( it.key() ) ); } int id = -1; id = OptVectorLayer::addFeature( f ); if ( id != -1 ) { //add points to other features to keep topology up-to-date int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 ); if( topologicalEditing ) { addTopologicalPoints( f.geometry() ); } } else { return -1; } //vlayer->setModified(true); //commit or rollBack the change if ( isModified() ) { commitChanges(); } else { rollBack(); return -1; } //make the layer still editable for the next adding operation startEditing(); return id; }
void QgsClipboard::replaceWithCopyOf( const QgsFieldMap& fields, QgsFeatureList& features ) { // Replace the QGis clipboard. mFeatureClipboard = features; QgsDebugMsg( "replaced QGis clipboard." ); // Replace the system clipboard. QStringList textLines; QStringList textFields; // first do the field names textFields += "wkt_geom"; for ( QgsFieldMap::const_iterator fit = fields.begin(); fit != fields.end(); ++fit ) { textFields += fit->name(); } textLines += textFields.join( "\t" ); textFields.clear(); // then the field contents for ( QgsFeatureList::iterator it = features.begin(); it != features.end(); ++it ) { QgsAttributeMap attributes = it->attributeMap(); // TODO: Set up Paste Transformations to specify the order in which fields are added. if ( it->geometry() ) textFields += it->geometry()->exportToWkt(); else { QSettings settings; textFields += settings.value( "qgis/nullValue", "NULL" ).toString(); } // QgsDebugMsg("about to traverse fields."); // for ( QgsAttributeMap::iterator it2 = attributes.begin(); it2 != attributes.end(); ++it2 ) { // QgsDebugMsg(QString("inspecting field '%1'.").arg(it2->toString())); textFields += it2->toString(); } textLines += textFields.join( "\t" ); textFields.clear(); } QString textCopy = textLines.join( "\n" ); QClipboard *cb = QApplication::clipboard(); // Copy text into the clipboard // With qgis running under Linux, but with a Windows based X // server (Xwin32), ::Selection was necessary to get the data into // the Windows clipboard (which seems contrary to the Qt // docs). With a Linux X server, ::Clipboard was required. // The simple solution was to put the text into both clipboards. // The ::Selection setText() below one may need placing inside so // #ifdef so that it doesn't get compiled under Windows. cb->setText( textCopy, QClipboard::Selection ); cb->setText( textCopy, QClipboard::Clipboard ); QgsDebugMsg( QString( "replaced system clipboard with: %1." ).arg( textCopy ) ); }