本文整理汇总了C++中QStandardItem::flags方法的典型用法代码示例。如果您正苦于以下问题:C++ QStandardItem::flags方法的具体用法?C++ QStandardItem::flags怎么用?C++ QStandardItem::flags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStandardItem
的用法示例。
在下文中一共展示了QStandardItem::flags方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getTagAttributes
void MainWindow::getTagAttributes(QList<QStandardItem*> *list, QDomNode doc)
{
//add the tag's name in the list
QStandardItem *newItem = new QStandardItem(doc.toElement().tagName());
newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
list->append(newItem);
//if the node doesn't have any children, it means there is a value inside the node, we add this value in the list here
if((!doc.childNodes().item(0).isElement() && doc.hasChildNodes()) && !doc.childNodes().item(0).isComment())
{
newItem = new QStandardItem(doc.toElement().text());
newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
list->append(newItem);
}
//if the node have at least one child, there is no value inside the node so we just had an empty string to the list
else
{
newItem = new QStandardItem("");
newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
list->append(newItem);
}
//add all the attributes to the list
for(int i = 0; i < doc.attributes().length(); i++)
{
newItem = new QStandardItem(doc.attributes().item(i).toAttr().name() + " : " + doc.attributes().item(i).toAttr().value());
newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
list->append(newItem);
}
}
示例2: itemFromIndex
bool QgsDb2TableModel::setData( const QModelIndex &idx, const QVariant &value, int role )
{
if ( !QStandardItemModel::setData( idx, value, role ) )
return false;
if ( idx.column() == DbtmType || idx.column() == DbtmSrid || idx.column() == DbtmPkCol )
{
const QgsWkbTypes::Type wkbType = static_cast< QgsWkbTypes::Type >( idx.sibling( idx.row(), DbtmType ).data( Qt::UserRole + 2 ).toInt() );
bool ok = wkbType != QgsWkbTypes::Unknown;
if ( ok && wkbType != QgsWkbTypes::NoGeometry )
idx.sibling( idx.row(), DbtmSrid ).data().toInt( &ok );
QStringList pkCols = idx.sibling( idx.row(), DbtmPkCol ).data( Qt::UserRole + 1 ).toStringList();
if ( ok && pkCols.size() > 0 )
ok = pkCols.contains( idx.sibling( idx.row(), DbtmPkCol ).data().toString() );
for ( int i = 0; i < DbtmColumns; i++ )
{
QStandardItem *item = itemFromIndex( idx.sibling( idx.row(), i ) );
if ( ok )
item->setFlags( item->flags() | Qt::ItemIsSelectable );
else
item->setFlags( item->flags() & ~Qt::ItemIsSelectable );
}
}
return true;
}
示例3: QStandardItem
QList<QStandardItem *> MainWindow::createrowinputtable(QFileInfo fileinfo)
{
QList<QStandardItem *>listitems;
qint64 fs;
QString strfs;
for(int col=0 ; col < inputmodel->columnCount() ; col++)
{
QStandardItem *item = new QStandardItem();
switch(col)
{
case 0:item->setText(fileinfo.fileName());
// add logs,constellations,signals,prns
item->setFlags(item->flags() ^ Qt::ItemIsEditable);
addChildrentofile(item);
break;
case 1: fs = fileinfo.size();
strfs = convertintokbmbgb(fs);
item->setText(strfs);
item->setFlags(item->flags() ^ Qt::ItemIsEditable);
break;
case 2: item->setFlags(item->flags() ^ Qt::ItemIsEditable); //initialize nof ascii logs
break;
case 3: item->setFlags(item->flags() ^ Qt::ItemIsEditable);// initialize no of binary logs
break;
case 4: item->setFlags(item->flags() ^ Qt::ItemIsEditable);//initialize no of unkonwn logs
break;
}
listitems.append(item);
}
return listitems;
}
示例4: setData
bool QgsPgTableModel::setData( const QModelIndex &idx, const QVariant &value, int role )
{
if ( !QStandardItemModel::setData( idx, value, role ) )
return false;
if ( idx.column() == dbtmType || idx.column() == dbtmSrid || idx.column() == dbtmPkCol )
{
QGis::WkbType geomType = ( QGis::WkbType ) idx.sibling( idx.row(), dbtmType ).data( Qt::UserRole + 2 ).toInt();
bool ok = geomType != QGis::WKBUnknown;
if ( ok && geomType != QGis::WKBNoGeometry )
{
int srid = idx.sibling( idx.row(), dbtmSrid ).data().toInt( &ok );
ok &= srid != INT_MIN;
}
QStringList pkCols = idx.sibling( idx.row(), dbtmPkCol ).data( Qt::UserRole + 1 ).toStringList();
if ( ok && pkCols.size() > 0 )
ok = pkCols.contains( idx.sibling( idx.row(), dbtmPkCol ).data().toString() );
for ( int i = 0; i < dbtmColumns; i++ )
{
QStandardItem *item = itemFromIndex( idx.sibling( idx.row(), i ) );
if ( ok )
item->setFlags( item->flags() | Qt::ItemIsSelectable );
else
item->setFlags( item->flags() & ~Qt::ItemIsSelectable );
}
}
return true;
}
示例5: clone
void tst_QStandardItem::clone()
{
QStandardItem item;
item.setText(QLatin1String("text"));
item.setToolTip(QLatin1String("toolTip"));
item.setStatusTip(QLatin1String("statusTip"));
item.setWhatsThis(QLatin1String("whatsThis"));
item.setSizeHint(QSize(64, 48));
item.setFont(QFont());
item.setTextAlignment(Qt::AlignLeft|Qt::AlignVCenter);
item.setBackground(QColor(Qt::blue));
item.setForeground(QColor(Qt::green));
item.setCheckState(Qt::PartiallyChecked);
item.setAccessibleText(QLatin1String("accessibleText"));
item.setAccessibleDescription(QLatin1String("accessibleDescription"));
item.setFlags(Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
QStandardItem *clone = item.clone();
QCOMPARE(clone->text(), item.text());
QCOMPARE(clone->toolTip(), item.toolTip());
QCOMPARE(clone->statusTip(), item.statusTip());
QCOMPARE(clone->whatsThis(), item.whatsThis());
QCOMPARE(clone->sizeHint(), item.sizeHint());
QCOMPARE(clone->font(), item.font());
QCOMPARE(clone->textAlignment(), item.textAlignment());
QCOMPARE(clone->background(), item.background());
QCOMPARE(clone->foreground(), item.foreground());
QCOMPARE(clone->checkState(), item.checkState());
QCOMPARE(clone->accessibleText(), item.accessibleText());
QCOMPARE(clone->accessibleDescription(), item.accessibleDescription());
QCOMPARE(clone->flags(), item.flags());
QVERIFY(!(*clone < item));
delete clone;
}
示例6: addTransfer
void TransfersContentsWidget::addTransfer(Transfer *transfer)
{
QList<QStandardItem*> items;
QStandardItem *item = new QStandardItem();
item->setData(qVariantFromValue(static_cast<void*>(transfer)), Qt::UserRole);
item->setFlags(item->flags() | Qt::ItemNeverHasChildren);
items.append(item);
item = new QStandardItem(QFileInfo(transfer->getTarget()).fileName());
item->setFlags(item->flags() | Qt::ItemNeverHasChildren);
items.append(item);
for (int i = 2; i < m_model->columnCount(); ++i)
{
item = new QStandardItem();
item->setFlags(item->flags() | Qt::ItemNeverHasChildren);
items.append(item);
}
m_model->appendRow(items);
if (transfer->getState() == Transfer::RunningState)
{
m_speeds[transfer] = QQueue<qint64>();
}
updateTransfer(transfer);
}
示例7: setElement
void InspectorBarLine::setElement()
{
InspectorElementBase::setElement();
BarLine* bl = toBarLine(inspector->element());
// enable / disable individual type combo items according to score and selected bar line status
bool bMultiStaff = bl->score()->nstaves() > 1;
BarLineType blt = bl->barLineType();
bool isRepeat = blt & (BarLineType::START_REPEAT | BarLineType::END_REPEAT | BarLineType::END_START_REPEAT);
const QStandardItemModel* model = qobject_cast<const QStandardItemModel*>(b.type->model());
int i = 0;
for (auto& k : BarLine::barLineTable) {
QStandardItem* item = model->item(i);
// if combo item is repeat type, should be disabled for multi-staff scores
if (k.type & (BarLineType::START_REPEAT | BarLineType::END_REPEAT | BarLineType::END_START_REPEAT)) {
// disable / enable
item->setFlags(bMultiStaff ?
item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled) :
item->flags() | (Qt::ItemFlags)(Qt::ItemIsSelectable|Qt::ItemIsEnabled) );
}
// if combo item is NOT repeat type, should be disabled if selected bar line is a repeat
else {
item->setFlags(isRepeat ?
item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled) :
item->flags() | (Qt::ItemFlags)(Qt::ItemIsSelectable|Qt::ItemIsEnabled) );
}
++i;
}
#if 0
blockSpanDataSignals(true);
manageSpanData();
blockSpanDataSignals(false);
#endif
}
示例8: onRenameFriendActionTriggered
void FriendsWidget::onRenameFriendActionTriggered()
{
// friendContextMenuRequested already made sure that there is only one index selected
QModelIndex selectedIndex = friendView->selectionModel()->selectedIndexes().at(0);
QStandardItem* selectedItem = friendModel->itemFromIndex(friendProxyModel->mapToSource(selectedIndex));
selectedItem->setFlags(selectedItem->flags() | Qt::ItemIsEditable);
friendView->edit(selectedIndex);
selectedItem->setFlags(selectedItem->flags() & ~Qt::ItemIsEditable);
}
示例9: QDialog
QgsStyleV2GroupSelectionDialog::QgsStyleV2GroupSelectionDialog( QgsStyleV2 *style, QWidget *parent ) :
QDialog( parent )
, mStyle( style )
{
setupUi( this );
QStandardItemModel* model = new QStandardItemModel( groupTree );
groupTree->setModel( model );
QStandardItem *allSymbols = new QStandardItem( tr( "All Symbols" ) );
allSymbols->setData( "all", Qt::UserRole + 2 );
allSymbols->setEditable( false );
setBold( allSymbols );
model->appendRow( allSymbols );
QStandardItem *group = new QStandardItem( "" ); //require empty name to get first order groups
group->setData( "groupsheader", Qt::UserRole + 2 );
group->setEditable( false );
group->setFlags( group->flags() & ~Qt::ItemIsSelectable );
buildGroupTree( group );
group->setText( tr( "Groups" ) );//set title later
QStandardItem *ungrouped = new QStandardItem( tr( "Ungrouped" ) );
ungrouped->setData( 0 );
ungrouped->setData( "group", Qt::UserRole + 2 );
setBold( ungrouped );
setBold( group );
group->appendRow( ungrouped );
model->appendRow( group );
QStandardItem *tag = new QStandardItem( tr( "Smart Groups" ) );
tag->setData( "smartgroupsheader" , Qt::UserRole + 2 );
tag->setEditable( false );
tag->setFlags( group->flags() & ~Qt::ItemIsSelectable );
setBold( tag );
QgsSymbolGroupMap sgMap = mStyle->smartgroupsListMap();
QgsSymbolGroupMap::const_iterator i = sgMap.constBegin();
while ( i != sgMap.constEnd() )
{
QStandardItem *item = new QStandardItem( i.value() );
item->setEditable( false );
item->setData( i.key() );
item->setData( "smartgroup" , Qt::UserRole + 2 );
tag->appendRow( item );
++i;
}
model->appendRow( tag );
// expand things in the group tree
int rows = model->rowCount( model->indexFromItem( model->invisibleRootItem() ) );
for ( int i = 0; i < rows; i++ )
{
groupTree->setExpanded( model->indexFromItem( model->item( i ) ), true );
}
connect( groupTree->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), this, SLOT( groupTreeSelectionChanged( const QItemSelection&, const QItemSelection& ) ) );
}
示例10: doubleClicked
void CaxaRun::doubleClicked(const QModelIndex &index)
{
if (index.isValid())
{
QStandardItem *item = m_model->item(index.row(), index.column());
if (index.column() == 1)
item->setFlags(item->flags() | Qt::ItemIsEditable);
else
item->setFlags(item->flags() & ~(Qt::ItemIsEditable));
}
}
示例11: disableAxis
// ensure different axes for consecutive operations
static void disableAxis(QComboBox *w, unsigned int axis) {
const QStandardItemModel* model = qobject_cast<const QStandardItemModel*>(w->model());
for (unsigned int i=0; i < 3; ++i) {
QStandardItem* item = model->item(i);
if (i == axis) {
item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
if (w->currentIndex() == axis) w->setCurrentIndex((axis+1) % 3);
} else {
item->setFlags(item->flags() | Qt::ItemIsEnabled);
}
}
}
示例12: setData
bool QgsPgTableModel::setData( const QModelIndex &idx, const QVariant &value, int role )
{
if ( !QStandardItemModel::setData( idx, value, role ) )
return false;
if ( idx.column() == dbtmType || idx.column() == dbtmSrid || idx.column() == dbtmPkCol )
{
QGis::WkbType wkbType = ( QGis::WkbType ) idx.sibling( idx.row(), dbtmType ).data( Qt::UserRole + 2 ).toInt();
QString tip;
if ( wkbType == QGis::WKBUnknown )
{
tip = tr( "Specify a geometry type" );
}
else if ( wkbType != QGis::WKBNoGeometry )
{
bool ok;
int srid = idx.sibling( idx.row(), dbtmSrid ).data().toInt( &ok );
if ( !ok || srid == INT_MIN )
tip = tr( "Enter a SRID" );
}
QStringList pkCols = idx.sibling( idx.row(), dbtmPkCol ).data( Qt::UserRole + 1 ).toStringList();
if ( tip.isEmpty() && pkCols.size() > 0 )
{
if ( !pkCols.contains( idx.sibling( idx.row(), dbtmPkCol ).data().toString() ) )
tip = tr( "Select a primary key" );
}
for ( int i = 0; i < dbtmColumns; i++ )
{
QStandardItem *item = itemFromIndex( idx.sibling( idx.row(), i ) );
if ( tip.isEmpty() )
{
item->setFlags( item->flags() | Qt::ItemIsSelectable | Qt::ItemIsEnabled );
item->setToolTip( "" );
}
else
{
item->setFlags( item->flags() & ~Qt::ItemIsSelectable );
if ( i == dbtmSchema || i == dbtmTable || i == dbtmGeomCol )
{
item->setFlags( item->flags() & ~Qt::ItemIsEnabled );
item->setToolTip( tip );
}
}
}
}
return true;
}
示例13: setData
bool QgsOracleTableModel::setData( const QModelIndex &idx, const QVariant &value, int role )
{
if ( !QStandardItemModel::setData( idx, value, role ) )
return false;
if ( idx.column() == DbtmType || idx.column() == DbtmSrid || idx.column() == DbtmPkCol )
{
QgsWkbTypes::Type wkbType = ( QgsWkbTypes::Type ) idx.sibling( idx.row(), DbtmType ).data( Qt::UserRole + 2 ).toInt();
QString tip;
if ( wkbType == QgsWkbTypes::Unknown )
{
tip = tr( "Specify a geometry type" );
}
else if ( wkbType != QgsWkbTypes::NoGeometry )
{
bool ok;
int srid = idx.sibling( idx.row(), DbtmSrid ).data().toInt( &ok );
if ( !ok || srid == 0 )
tip = tr( "Enter a SRID" );
}
if ( tip.isEmpty() && idx.sibling( idx.row(), DbtmPkCol ).data( Qt::UserRole + 1 ).toBool() )
{
if ( !idx.sibling( idx.row(), DbtmPkCol ).data( Qt::UserRole + 2 ).toBool() )
tip = tr( "Select a primary key" );
}
for ( int i = 0; i < DbtmColumns; i++ )
{
QStandardItem *item = itemFromIndex( idx.sibling( idx.row(), i ) );
if ( tip.isEmpty() )
{
item->setFlags( item->flags() | Qt::ItemIsSelectable | Qt::ItemIsEnabled );
item->setToolTip( "" );
}
else
{
item->setFlags( item->flags() & ~Qt::ItemIsSelectable );
if ( i == DbtmOwner || i == DbtmTable || i == DbtmGeomCol )
{
item->setFlags( item->flags() & ~Qt::ItemIsEnabled );
item->setToolTip( tip );
}
}
}
}
return true;
}
示例14: QStandardItem
static QStandardItem *createDisabledItem(const QString &text)
{
QStandardItem *rc = new QStandardItem(text);
Qt::ItemFlags flags = rc->flags();
rc->setFlags(flags & ~(Qt::ItemIsEnabled|Qt::ItemIsEditable|Qt::ItemIsSelectable));
return rc;
}
示例15: QComboBox
ActionComboBoxWidget::ActionComboBoxWidget(QWidget *parent) : QComboBox(parent),
m_view(new ItemViewWidget(this)),
m_filterLineEdit(NULL),
m_wasPopupVisible(false)
{
setEditable(true);
setView(m_view);
setItemDelegate(new ItemDelegate(this));
m_view->setHeaderHidden(true);
lineEdit()->hide();
view()->viewport()->parentWidget()->installEventFilter(this);
QStandardItemModel *model = new QStandardItemModel(this);
const QVector<ActionDefinition> definitions = ActionsManager::getActionDefinitions();
for (int i = 0; i < definitions.count(); ++i)
{
QStandardItem *item = new QStandardItem(definitions.at(i).icon, QCoreApplication::translate("actions", (definitions.at(i).description.isEmpty() ? definitions.at(i).text : definitions.at(i).description).toUtf8().constData()));
item->setData(definitions.at(i).identifier, Qt::UserRole);
item->setToolTip(ActionsManager::getActionName(definitions.at(i).identifier));
item->setFlags(item->flags() | Qt::ItemNeverHasChildren);
model->appendRow(item);
}
setModel(model);
setCurrentIndex(-1);
}