本文整理汇总了C++中QStandardItem::isEditable方法的典型用法代码示例。如果您正苦于以下问题:C++ QStandardItem::isEditable方法的具体用法?C++ QStandardItem::isEditable怎么用?C++ QStandardItem::isEditable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStandardItem
的用法示例。
在下文中一共展示了QStandardItem::isEditable方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnItemClicked
void QtPropertyEditor::OnItemClicked(const QModelIndex &index)
{
QStandardItem *item = curModel->itemFromIndex(index);
if(NULL != item && item->isEditable() && item->isEnabled())
{
edit(index, QAbstractItemView::DoubleClicked, NULL);
}
}
示例2: removeGroup
void AbstractCameraManager::removeGroup(QModelIndex index) {
QStandardItem * item = getModel()->itemFromIndex( index );
if( !item->isEditable() ) return;
QStandardItem * parent = item->parent();
if( parent == NULL ) parent = item->model()->invisibleRootItem();
for(int i=item->rowCount(); i>0; i--) {
newCameraList.insertRow(0, item->takeRow(0));
}
parent->removeRow( item->row() );
detectNewCamerasAndExpand();
}
示例3: addTableEntry
void QgsOracleTableModel::addTableEntry( const QgsOracleLayerProperty &layerProperty )
{
QgsDebugMsg( layerProperty.toString() );
if ( layerProperty.isView && layerProperty.pkCols.isEmpty() )
{
QgsDebugMsg( "View without pk skipped." );
return;
}
// is there already a root item with the given scheme Name?
QStandardItem *ownerItem = 0;
for ( int i = 0; i < layerProperty.size(); i++ )
{
QGis::WkbType wkbType = layerProperty.types[ i ];
int srid = layerProperty.srids[ i ];
QString tip;
if ( wkbType == QGis::WKBUnknown )
{
tip = tr( "Specify a geometry type" );
}
else if ( wkbType != QGis::WKBNoGeometry && srid == 0 )
{
tip = tr( "Enter a SRID" );
}
if ( tip.isEmpty() && layerProperty.isView )
{
tip = tr( "Select a primary key" );
}
QStandardItem *ownerNameItem = new QStandardItem( layerProperty.ownerName );
QStandardItem *typeItem = new QStandardItem( iconForWkbType( wkbType ), wkbType == QGis::WKBUnknown ? tr( "Select..." ) : QgsOracleConn::displayStringForWkbType( wkbType ) );
typeItem->setData( wkbType == QGis::WKBUnknown, Qt::UserRole + 1 );
typeItem->setData( wkbType, Qt::UserRole + 2 );
if ( wkbType == QGis::WKBUnknown )
typeItem->setFlags( typeItem->flags() | Qt::ItemIsEditable );
QStandardItem *tableItem = new QStandardItem( layerProperty.tableName );
QStandardItem *geomItem = new QStandardItem( layerProperty.geometryColName );
QStandardItem *sridItem = new QStandardItem( wkbType != QGis::WKBNoGeometry ? QString::number( srid ) : "" );
sridItem->setEditable( wkbType != QGis::WKBNoGeometry && srid == 0 );
if ( sridItem->isEditable() )
{
sridItem->setText( tr( "Enter..." ) );
sridItem->setFlags( sridItem->flags() | Qt::ItemIsEditable );
}
QStandardItem *pkItem = new QStandardItem( "" );
if ( layerProperty.isView )
{
pkItem->setText( tr( "Select..." ) );
pkItem->setFlags( pkItem->flags() | Qt::ItemIsEditable );
}
else
pkItem->setFlags( pkItem->flags() & ~Qt::ItemIsEditable );
pkItem->setData( layerProperty.isView, Qt::UserRole + 1 );
pkItem->setData( false, Qt::UserRole + 2 ); // not selected
QStandardItem *selItem = new QStandardItem( "" );
selItem->setFlags( selItem->flags() | Qt::ItemIsUserCheckable );
selItem->setCheckState( Qt::Checked );
selItem->setToolTip( tr( "Disable 'Fast Access to Features at ID' capability to force keeping the attribute table in memory (e.g. in case of expensive views)." ) );
QStandardItem* sqlItem = new QStandardItem( layerProperty.sql );
QList<QStandardItem*> childItemList;
childItemList << ownerNameItem;
childItemList << tableItem;
childItemList << typeItem;
childItemList << geomItem;
childItemList << sridItem;
childItemList << pkItem;
childItemList << selItem;
childItemList << sqlItem;
foreach ( QStandardItem *item, childItemList )
{
if ( tip.isEmpty() )
{
item->setFlags( item->flags() | Qt::ItemIsSelectable | Qt::ItemIsEnabled );
item->setToolTip( "" );
}
else
{
item->setFlags( item->flags() & ~Qt::ItemIsSelectable );
if ( item == ownerNameItem || item == tableItem || item == geomItem )
{
item->setFlags( item->flags() & ~Qt::ItemIsEnabled );
item->setToolTip( tip );
}
}
}
if ( !ownerItem )
//.........这里部分代码省略.........
示例4: getSetFlags
void tst_QStandardItem::getSetFlags()
{
QStandardItem item;
item.setEnabled(true);
QVERIFY(item.isEnabled());
QVERIFY(item.flags() & Qt::ItemIsEnabled);
item.setEditable(true);
QVERIFY(item.isEditable());
QVERIFY(item.flags() & Qt::ItemIsEditable);
item.setSelectable(true);
QVERIFY(item.isSelectable());
QVERIFY(item.flags() & Qt::ItemIsSelectable);
item.setCheckable(true);
QVERIFY(item.isCheckable());
QCOMPARE(item.checkState(), Qt::Unchecked);
QVERIFY(item.flags() & Qt::ItemIsUserCheckable);
item.setTristate(true);
QVERIFY(item.isTristate());
QVERIFY(item.flags() & Qt::ItemIsTristate);
#ifndef QT_NO_DRAGANDDROP
item.setDragEnabled(true);
QVERIFY(item.isDragEnabled());
QVERIFY(item.flags() & Qt::ItemIsDragEnabled);
item.setDropEnabled(true);
QVERIFY(item.isDropEnabled());
QVERIFY(item.flags() & Qt::ItemIsDropEnabled);
#endif
QVERIFY(item.isEnabled());
item.setEnabled(false);
QVERIFY(!item.isEnabled());
QVERIFY(!(item.flags() & Qt::ItemIsEnabled));
QVERIFY(item.isEditable());
item.setEditable(false);
QVERIFY(!item.isEditable());
QVERIFY(!(item.flags() & Qt::ItemIsEditable));
QVERIFY(item.isSelectable());
item.setSelectable(false);
QVERIFY(!item.isSelectable());
QVERIFY(!(item.flags() & Qt::ItemIsSelectable));
QVERIFY(item.isCheckable());
item.setCheckable(false);
QVERIFY(!item.isCheckable());
QVERIFY(!(item.flags() & Qt::ItemIsUserCheckable));
QVERIFY(item.isTristate());
item.setTristate(false);
QVERIFY(!item.isTristate());
QVERIFY(!(item.flags() & Qt::ItemIsTristate));
#ifndef QT_NO_DRAGANDDROP
QVERIFY(item.isDragEnabled());
item.setDragEnabled(false);
QVERIFY(!item.isDragEnabled());
QVERIFY(!(item.flags() & Qt::ItemIsDragEnabled));
QVERIFY(item.isDropEnabled());
item.setDropEnabled(false);
QVERIFY(!item.isDropEnabled());
QVERIFY(!(item.flags() & Qt::ItemIsDropEnabled));
#endif
item.setCheckable(false);
item.setCheckState(Qt::Checked);
item.setCheckable(true);
QCOMPARE(item.checkState(), Qt::Checked);
}
示例5: addTableEntry
void QgsPgTableModel::addTableEntry( const QgsPostgresLayerProperty &layerProperty )
{
QgsDebugMsg( layerProperty.toString() );
// is there already a root item with the given scheme Name?
QStandardItem *schemaItem = nullptr;
for ( int i = 0; i < layerProperty.size(); i++ )
{
QgsWkbTypes::Type wkbType = layerProperty.types[ i ];
int srid = layerProperty.srids[ i ];
if ( wkbType == QgsWkbTypes::Unknown && layerProperty.geometryColName.isEmpty() )
{
wkbType = QgsWkbTypes::NoGeometry;
}
QString tip;
if ( wkbType == QgsWkbTypes::Unknown )
{
tip = tr( "Specify a geometry type in the '%1' column" ).arg( tr( "Data Type" ) );
}
else if ( wkbType != QgsWkbTypes::NoGeometry && srid == INT_MIN )
{
tip = tr( "Enter a SRID into the '%1' column" ).arg( tr( "SRID" ) );
}
else if ( !layerProperty.pkCols.isEmpty() )
{
tip = tr( "Select columns in the '%1' column that uniquely identify features of this layer" ).arg( tr( "Feature id" ) );
}
QStandardItem *schemaNameItem = new QStandardItem( layerProperty.schemaName );
QStandardItem *typeItem = new QStandardItem( iconForWkbType( wkbType ), wkbType == QgsWkbTypes::Unknown ? tr( "Select..." ) : QgsPostgresConn::displayStringForWkbType( wkbType ) );
typeItem->setData( wkbType == QgsWkbTypes::Unknown, Qt::UserRole + 1 );
typeItem->setData( wkbType, Qt::UserRole + 2 );
if ( wkbType == QgsWkbTypes::Unknown )
typeItem->setFlags( typeItem->flags() | Qt::ItemIsEditable );
QStandardItem *geomTypeItem = new QStandardItem( QgsPostgresConn::displayStringForGeomType( layerProperty.geometryColType ) );
QStandardItem *tableItem = new QStandardItem( layerProperty.tableName );
QStandardItem *commentItem = new QStandardItem( layerProperty.tableComment );
QStandardItem *geomItem = new QStandardItem( layerProperty.geometryColName );
QStandardItem *sridItem = new QStandardItem( wkbType != QgsWkbTypes::NoGeometry ? QString::number( srid ) : QLatin1String( "" ) );
sridItem->setEditable( wkbType != QgsWkbTypes::NoGeometry && srid == INT_MIN );
if ( sridItem->isEditable() )
{
sridItem->setText( tr( "Enter..." ) );
sridItem->setFlags( sridItem->flags() | Qt::ItemIsEditable );
}
QStandardItem *pkItem = new QStandardItem( QLatin1String( "" ) );
if ( !layerProperty.pkCols.isEmpty() )
{
pkItem->setText( tr( "Select..." ) );
pkItem->setFlags( pkItem->flags() | Qt::ItemIsEditable );
}
else
pkItem->setFlags( pkItem->flags() & ~Qt::ItemIsEditable );
pkItem->setData( layerProperty.pkCols, Qt::UserRole + 1 );
pkItem->setData( "", Qt::UserRole + 2 );
QStandardItem *selItem = new QStandardItem( QLatin1String( "" ) );
selItem->setFlags( selItem->flags() | Qt::ItemIsUserCheckable );
selItem->setCheckState( Qt::Checked );
selItem->setToolTip( tr( "Disable 'Fast Access to Features at ID' capability to force keeping the attribute table in memory (e.g. in case of expensive views)." ) );
QStandardItem *sqlItem = new QStandardItem( layerProperty.sql );
QList<QStandardItem *> childItemList;
childItemList << schemaNameItem;
childItemList << tableItem;
childItemList << commentItem;
childItemList << geomItem;
childItemList << geomTypeItem;
childItemList << typeItem;
childItemList << sridItem;
childItemList << pkItem;
childItemList << selItem;
childItemList << sqlItem;
Q_FOREACH ( QStandardItem *item, childItemList )
{
if ( tip.isEmpty() )
{
item->setFlags( item->flags() | Qt::ItemIsSelectable );
item->setToolTip( QLatin1String( "" ) );
}
else
{
item->setFlags( item->flags() & ~Qt::ItemIsSelectable );
if ( item == schemaNameItem )
item->setData( QgsApplication::getThemeIcon( QStringLiteral( "/mIconWarning.svg" ) ), Qt::DecorationRole );
if ( item == schemaNameItem || item == tableItem || item == geomItem )
{
item->setToolTip( tip );
//.........这里部分代码省略.........
示例6: addTableEntry
void QgsPgTableModel::addTableEntry( const QgsPostgresLayerProperty &layerProperty )
{
QgsDebugMsg( layerProperty.toString() );
// is there already a root item with the given scheme Name?
QStandardItem *schemaItem = nullptr;
for ( int i = 0; i < layerProperty.size(); i++ )
{
QgsWkbTypes::Type wkbType = layerProperty.types[ i ];
int srid = layerProperty.srids[ i ];
if ( wkbType == QgsWkbTypes::Unknown && layerProperty.geometryColName.isEmpty() )
{
wkbType = QgsWkbTypes::NoGeometry;
}
QString tip;
bool withTipButSelectable = false;
if ( wkbType == QgsWkbTypes::Unknown )
{
tip = tr( "Specify a geometry type in the '%1' column" ).arg( tr( "Data Type" ) );
}
else if ( wkbType != QgsWkbTypes::NoGeometry && srid == std::numeric_limits<int>::min() )
{
tip = tr( "Enter a SRID into the '%1' column" ).arg( tr( "SRID" ) );
}
else if ( !layerProperty.pkCols.isEmpty() )
{
tip = tr( "Select columns in the '%1' column that uniquely identify features of this layer" ).arg( tr( "Feature id" ) );
withTipButSelectable = true;
}
QStandardItem *schemaNameItem = new QStandardItem( layerProperty.schemaName );
QStandardItem *typeItem = new QStandardItem( iconForWkbType( wkbType ), wkbType == QgsWkbTypes::Unknown ? tr( "Select…" ) : QgsPostgresConn::displayStringForWkbType( wkbType ) );
typeItem->setData( wkbType == QgsWkbTypes::Unknown, Qt::UserRole + 1 );
typeItem->setData( wkbType, Qt::UserRole + 2 );
if ( wkbType == QgsWkbTypes::Unknown )
typeItem->setFlags( typeItem->flags() | Qt::ItemIsEditable );
QStandardItem *geomTypeItem = new QStandardItem( QgsPostgresConn::displayStringForGeomType( layerProperty.geometryColType ) );
QStandardItem *tableItem = new QStandardItem( layerProperty.tableName );
QStandardItem *commentItem = new QStandardItem( layerProperty.tableComment );
QStandardItem *geomItem = new QStandardItem( layerProperty.geometryColName );
QStandardItem *sridItem = new QStandardItem( wkbType != QgsWkbTypes::NoGeometry ? QString::number( srid ) : QString() );
sridItem->setEditable( wkbType != QgsWkbTypes::NoGeometry && srid == std::numeric_limits<int>::min() );
if ( sridItem->isEditable() )
{
sridItem->setText( tr( "Enter…" ) );
sridItem->setFlags( sridItem->flags() | Qt::ItemIsEditable );
}
QStandardItem *pkItem = new QStandardItem( QString() );
if ( !layerProperty.pkCols.isEmpty() )
{
pkItem->setText( tr( "Select…" ) );
pkItem->setFlags( pkItem->flags() | Qt::ItemIsEditable );
}
else
pkItem->setFlags( pkItem->flags() & ~Qt::ItemIsEditable );
pkItem->setData( layerProperty.pkCols, Qt::UserRole + 1 );
QStringList defPk( QgsSettings().value( QStringLiteral( "/PostgreSQL/connections/%1/keys/%2/%3" ).arg( mConnName, layerProperty.schemaName, layerProperty.tableName ), QStringList() ).toStringList() );
if ( !layerProperty.pkCols.isEmpty() && defPk.isEmpty() )
{
// If we have a view with multiple possible columns to be used as the primary key, for convenience
// let's select the first one - this is what the browser dock already does. We risk that a wrong column
// will be used, but most of the time we should be fine.
defPk = QStringList( layerProperty.pkCols[0] );
}
pkItem->setData( defPk, Qt::UserRole + 2 );
if ( !defPk.isEmpty() )
pkItem->setText( defPk.join( ',' ) );
QStandardItem *selItem = new QStandardItem( QString() );
selItem->setFlags( selItem->flags() | Qt::ItemIsUserCheckable );
selItem->setCheckState( Qt::Checked );
selItem->setToolTip( headerData( Columns::DbtmSelectAtId, Qt::Orientation::Horizontal, Qt::ToolTipRole ).toString() );
QStandardItem *checkPkUnicityItem = new QStandardItem( QString() );
checkPkUnicityItem->setFlags( checkPkUnicityItem->flags() | Qt::ItemIsUserCheckable );
// Legacy: default value is determined by project option to trust layer's metadata
// TODO: remove this default from QGIS 4 and leave default value to false?
// checkPkUnicity has only effect on views and materialized views, so we can safely disable it
if ( layerProperty.isView || layerProperty.isMaterializedView )
{
checkPkUnicityItem->setCheckState( QgsProject::instance( )->trustLayerMetadata() ? Qt::CheckState::Unchecked : Qt::CheckState::Checked );
checkPkUnicityItem->setToolTip( headerData( Columns::DbtmCheckPkUnicity, Qt::Orientation::Horizontal, Qt::ToolTipRole ).toString() );
}
else
{
checkPkUnicityItem->setCheckState( Qt::CheckState::Unchecked );
checkPkUnicityItem->setFlags( checkPkUnicityItem->flags() & ~ Qt::ItemIsEnabled );
checkPkUnicityItem->setToolTip( tr( "This option is only available for views and materialized views." ) );
}
//.........这里部分代码省略.........
示例7: addTableEntry
void QgsPgTableModel::addTableEntry( const QgsPostgresLayerProperty& layerProperty )
{
QgsDebugMsg( layerProperty.toString() );
// is there already a root item with the given scheme Name?
QStandardItem *schemaItem = 0;
for ( int i = 0; i < layerProperty.size(); i++ )
{
QGis::WkbType wkbType = layerProperty.types[ i ];
int srid = layerProperty.srids[ i ];
if ( wkbType == QGis::WKBUnknown && layerProperty.geometryColName.isEmpty() )
{
wkbType = QGis::WKBNoGeometry;
}
bool selectable = wkbType == QGis::WKBNoGeometry || ( wkbType != QGis::WKBUnknown && srid != INT_MIN );
QStandardItem *schemaNameItem = new QStandardItem( layerProperty.schemaName );
QStandardItem *typeItem = new QStandardItem( iconForWkbType( wkbType ), wkbType == QGis::WKBUnknown ? tr( "Select..." ) : QgsPostgresConn::displayStringForWkbType( wkbType ) );
typeItem->setData( wkbType == QGis::WKBUnknown, Qt::UserRole + 1 );
typeItem->setData( wkbType, Qt::UserRole + 2 );
if ( wkbType == QGis::WKBUnknown )
typeItem->setFlags( typeItem->flags() | Qt::ItemIsEditable );
QStandardItem *geomTypeItem = new QStandardItem( QgsPostgresConn::displayStringForGeomType( layerProperty.geometryColType ) );
QStandardItem *tableItem = new QStandardItem( layerProperty.tableName );
QStandardItem *geomItem = new QStandardItem( layerProperty.geometryColName );
QStandardItem *sridItem = new QStandardItem( wkbType != QGis::WKBNoGeometry ? QString::number( srid ) : "" );
sridItem->setEditable( wkbType != QGis::WKBNoGeometry && srid == INT_MIN );
if ( sridItem->isEditable() )
{
sridItem->setText( tr( "Enter..." ) );
sridItem->setFlags( sridItem->flags() | Qt::ItemIsEditable );
}
QString pkCol = "";
if ( layerProperty.pkCols.size() > 0 )
{
pkCol = layerProperty.pkCols[0];
}
QStandardItem *pkItem = new QStandardItem( pkCol );
if ( layerProperty.pkCols.size() > 1 )
pkItem->setFlags( pkItem->flags() | Qt::ItemIsEditable );
else
pkItem->setFlags( pkItem->flags() & ~Qt::ItemIsEditable );
pkItem->setData( layerProperty.pkCols, Qt::UserRole + 1 );
pkItem->setData( pkCol, Qt::UserRole + 2 );
QStandardItem *selItem = new QStandardItem( "" );
selItem->setFlags( selItem->flags() | Qt::ItemIsUserCheckable );
selItem->setCheckState( Qt::Checked );
selItem->setToolTip( tr( "Disable 'Fast Access to Features at ID' capability to force keeping the attribute table in memory (e.g. in case of expensive views)." ) );
QStandardItem* sqlItem = new QStandardItem( layerProperty.sql );
QList<QStandardItem*> childItemList;
childItemList << schemaNameItem;
childItemList << tableItem;
childItemList << geomItem;
childItemList << geomTypeItem;
childItemList << typeItem;
childItemList << sridItem;
childItemList << pkItem;
childItemList << selItem;
childItemList << sqlItem;
foreach ( QStandardItem *item, childItemList )
{
if ( selectable )
{
item->setFlags( item->flags() | Qt::ItemIsSelectable );
}
else
{
item->setFlags( item->flags() & ~Qt::ItemIsSelectable );
}
}
if ( !schemaItem )
{
QList<QStandardItem*> schemaItems = findItems( layerProperty.schemaName, Qt::MatchExactly, dbtmSchema );
// there is already an item for this schema
if ( schemaItems.size() > 0 )
{
schemaItem = schemaItems.at( dbtmSchema );
}
else
{
// create a new toplevel item for this schema
schemaItem = new QStandardItem( layerProperty.schemaName );
schemaItem->setFlags( Qt::ItemIsEnabled );
invisibleRootItem()->setChild( invisibleRootItem()->rowCount(), schemaItem );
}
}
//.........这里部分代码省略.........