本文整理汇总了C++中QStandardItem::setDragEnabled方法的典型用法代码示例。如果您正苦于以下问题:C++ QStandardItem::setDragEnabled方法的具体用法?C++ QStandardItem::setDragEnabled怎么用?C++ QStandardItem::setDragEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStandardItem
的用法示例。
在下文中一共展示了QStandardItem::setDragEnabled方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddGroup
bool ProgramsModel::AddGroup(QModelIndex &index, int row)
{
int groupId = myHost->programsModel->GetNextGroupId();
QString name("New grp");
//create the group
QStandardItem *groupItem = new QStandardItem( name );
groupItem->setData(GroupNode,NodeType);
groupItem->setData(groupId,ProgramId);
#ifndef QT_NO_DEBUG
groupItem->setData(groupId,Qt::ToolTipRole);
#endif
groupItem->setDragEnabled(true);
groupItem->setDropEnabled(false);
groupItem->setEditable(true);
if(row==-1)
row=rowCount();
insertRow( row, groupItem );
index = groupItem->index();
return true;
}
示例2: AddProgram
bool ProgramsModel::AddProgram(int groupNum, QModelIndex &index, int row)
{
QStandardItem *groupItem = item(groupNum);
//if the group was disabled re-enable it
if(groupItem->rowCount()==0) {
groupItem->setBackground(Qt::transparent);
groupItem->setToolTip("");
}
int progId = myHost->programsModel->GetNextProgId();
QString name("New prog");
//create the program item
QStandardItem *prgItem = new QStandardItem( name );
prgItem->setData(ProgramNode,NodeType);
prgItem->setData(progId,ProgramId);
#ifndef QT_NO_DEBUG
prgItem->setData(progId,Qt::ToolTipRole);
#endif
prgItem->setDragEnabled(true);
prgItem->setDropEnabled(false);
prgItem->setEditable(true);
if(row==-1)
row=groupItem->rowCount();
groupItem->insertRow(row, prgItem);
index = prgItem->index();
// ValidateProgChange(index);
return true;
}
示例3: addItem
QStandardItem* QgsMilXLibrary::addItem( QStandardItem* parent, const QString& value, const QImage& image, bool isLeaf, const QString& symbolXml, const QString& symbolMilitaryName, int symbolPointCount , bool symbolHasVariablePoints )
{
QIcon icon;
QSize iconSize = isLeaf ? mTreeView->iconSize() : !image.isNull() ? QSize( 32, 32 ) : QSize( 1, 32 );
QImage iconImage( iconSize, QImage::Format_ARGB32 );
iconImage.fill( Qt::transparent );
if ( !image.isNull() )
{
double scale = qMin( 1., image.width() > image.height() ? iconImage.width() / double( image.width() ) : iconImage.height() / double( image.height() ) );
QPainter painter( &iconImage );
painter.setRenderHint( QPainter::SmoothPixmapTransform );
painter.drawImage(
QRectF( 0.5 * ( iconSize.width() - scale * image.width() ), 0.5 * ( iconSize.height() - scale * image.height() ), scale * image.width(), scale * image.height() ),
image );
}
icon = QIcon( QPixmap::fromImage( iconImage ) );
if ( !parent )
{
parent = mGalleryModel->invisibleRootItem();
}
// Create category group item if necessary
if ( !isLeaf )
{
// Don't create subgroups with same text as parent
if ( parent->text() == value )
{
return parent;
}
QStandardItem* groupItem = 0;
for ( int i = 0, n = parent->rowCount(); i < n; ++i )
{
if ( parent->child( i )->text() == value )
{
groupItem = parent->child( i );
break;
}
}
if ( !groupItem )
{
groupItem = new QStandardItem( value );
groupItem->setDragEnabled( false );
parent->setChild( parent->rowCount(), groupItem );
groupItem->setIcon( icon );
}
return groupItem;
}
else
{
QStandardItem* item = new QStandardItem( QString( "%1" ).arg( symbolMilitaryName ) );
parent->setChild( parent->rowCount(), item );
item->setData( symbolXml, SymbolXmlRole );
item->setData( symbolMilitaryName, SymbolMilitaryNameRole );
item->setData( symbolPointCount, SymbolPointCountRole );
item->setData( symbolHasVariablePoints, SymbolVariablePointsRole );
item->setToolTip( item->text() );
item->setIcon( icon );
return item;
}
}
示例4: createItemRow
NavigatorTreeModel::ItemRow NavigatorTreeModel::createItemRow(const ModelNode &node)
{
Q_ASSERT(node.isValid());
uint hash = node.internalId();
const bool dropEnabled = node.metaInfo().isValid();
QStandardItem *idItem = new QStandardItem;
idItem->setDragEnabled(true);
idItem->setDropEnabled(dropEnabled);
idItem->setEditable(true);
idItem->setData(hash, NavigatorRole);
if (node.metaInfo().isValid())
idItem->setToolTip(node.type());
else
idItem->setToolTip(msgUnknownItem(node.type()));
# ifdef _LOCK_ITEMS_
QStandardItem *lockItem = new QStandardItem;
lockItem->setDragEnabled(true);
lockItem->setDropEnabled(dropEnabled);
lockItem->setEditable(false);
lockItem->setCheckable(true);
lockItem->setData(hash, NavigatorRole);
# endif
QStandardItem *visibilityItem = new QStandardItem;
visibilityItem->setDropEnabled(dropEnabled);
visibilityItem->setCheckable(true);
visibilityItem->setEditable(false);
visibilityItem->setData(hash, NavigatorRole);
if (node.isRootNode())
visibilityItem->setCheckable(false);
QMap<QString, QStandardItem *> propertyItems;
foreach (const QString &propertyName, visibleProperties(node)) {
QStandardItem *propertyItem = new QStandardItem;
propertyItem->setSelectable(false);
propertyItem->setDragEnabled(false);
propertyItem->setDropEnabled(dropEnabled);
propertyItem->setEditable(false);
propertyItem->setData(propertyName, Qt::DisplayRole);
propertyItems.insert(propertyName, propertyItem);
idItem->appendRow(propertyItem);
}
示例5: createItemRow
NavigatorTreeModel::ItemRow NavigatorTreeModel::createItemRow(const ModelNode &node)
{
Q_ASSERT(node.isValid());
uint hash = qHash(node);
const bool dropEnabled = node.metaInfo().isValid();
QStandardItem *idItem = new QStandardItem;
idItem->setDragEnabled(true);
idItem->setDropEnabled(dropEnabled);
idItem->setEditable(true);
idItem->setData(hash, Qt::UserRole);
#ifdef _LOCK_ITEMS_
QStandardItem *lockItem = new QStandardItem;
lockItem->setDragEnabled(true);
lockItem->setDropEnabled(dropEnabled);
lockItem->setEditable(false);
lockItem->setCheckable(true);
lockItem->setData(hash, Qt::UserRole);
#endif
QStandardItem *visibilityItem = new QStandardItem;
visibilityItem->setDropEnabled(dropEnabled);
visibilityItem->setCheckable(true);
visibilityItem->setEditable(false);
visibilityItem->setData(hash, Qt::UserRole);
if (node.isRootNode()) {
visibilityItem->setCheckable(false);
}
#ifdef _LOCK_ITEMS_
return ItemRow(idItem, lockItem, visibilityItem);
#else
return ItemRow(idItem, visibilityItem);
#endif
}
示例6: browseSavedPlaylist
void SinglePlaylistView::browseSavedPlaylist(MafwPlaylist *mafwplaylist)
{
currentObjectId = QString();
playlistLoaded = true;
objectModel->clear();
QStandardItem *item = new QStandardItem();
item->setData(true, UserRoleHeader);
item->setDragEnabled(false);
item->setDropEnabled(false);
objectModel->appendRow(item);
connect(ui->objectList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onItemDoubleClicked()));
MafwPlaylistAdapter *mpa = new MafwPlaylistAdapter(mafwplaylist);
int size = mpa->size();
gchar** items = mpa->items(0, size-1);
for (int i = 0; items[i] != NULL; i++) {
QStandardItem *item = new QStandardItem();
item->setData(QString::fromUtf8(items[i]), UserRoleObjectID);
item->setData(Duration::Blank, UserRoleSongDuration);
item->setDropEnabled(false);
objectModel->appendRow(item);
}
g_strfreev(items);
PlaylistQueryManager *playlistQM = new PlaylistQueryManager(this, mpa);
mpa->setParent(playlistQM);
connect(playlistQM, SIGNAL(gotItem(QString,GHashTable*,uint)), this, SLOT(onItemReceived(QString,GHashTable*,uint)));
connect(ui->objectList->verticalScrollBar(), SIGNAL(valueChanged(int)), playlistQM, SLOT(setPriority(int)));
playlistQM->getItems(0, size-1);
remainingCount = size;
updateSongCount();
}
示例7: 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);
}