本文整理汇总了C++中QTreeWidgetItem::flags方法的典型用法代码示例。如果您正苦于以下问题:C++ QTreeWidgetItem::flags方法的具体用法?C++ QTreeWidgetItem::flags怎么用?C++ QTreeWidgetItem::flags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTreeWidgetItem
的用法示例。
在下文中一共展示了QTreeWidgetItem::flags方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseFolderElement
void XbelTree::parseFolderElement(const QDomElement &element,
QTreeWidgetItem *parentItem)
{
QTreeWidgetItem *item = createItem(element, parentItem);
QString title = element.attribute("title");
QString value_ergo = element.attribute("value_ergo");
QString value_ves = element.attribute("value_ves");
QString value_number = element.attribute("value_number");
QString foldedString = element.attribute("folded");
item->setFlags(item->flags() | Qt::ItemIsEditable);
item->setIcon(0, folderIcon);
item->setText(0, title);
item->setText(1, value_ergo);
item->setText(2, value_ves);
item->setText(3, value_number);
item->setText(4, foldedString);
bool folded = (element.attribute("folded") != "no");
setItemExpanded(item, !folded);
QDomElement child = element.firstChildElement();
while (!child.isNull()) {
if (child.tagName() == "folder") {
parseFolderElement(child, item);
} else if (child.tagName() == "separator") {
QTreeWidgetItem *childItem = createItem(child, item);
childItem->setFlags(item->flags() & ~(Qt::ItemIsSelectable | Qt::ItemIsEditable));
childItem->setText(0, QString(30, 0xB7));
}
child = child.nextSiblingElement();
}
}
示例2: addItem
void DataSelectionScreen::addItem(QString name)
{
if (name.contains(":"))
{
QString sysid = name.mid(0,name.indexOf(":"));
name = name.mid(name.indexOf(":")+1);
m_nameToSysId[name] = sysid;
}
if (name.contains("."))
{
//It's a split name, "GCS Status.Roll" for instance.
QString shortname = name.split(".")[1];
QString groupname = name.split(".")[0];
QList<QTreeWidgetItem*> findlist = ui.treeWidget->findItems(groupname,Qt::MatchContains);
if (findlist.size() > 0)
{
QTreeWidgetItem *child = new QTreeWidgetItem(QStringList() << shortname);
child->setFlags(child->flags() | Qt::ItemIsUserCheckable);
child->setCheckState(0,Qt::Unchecked);
findlist[0]->addChild(child);
}
else
{
QTreeWidgetItem *item = new QTreeWidgetItem(QStringList() << groupname);
ui.treeWidget->addTopLevelItem(item);
QTreeWidgetItem *child = new QTreeWidgetItem(QStringList() << shortname);
child->setFlags(child->flags() | Qt::ItemIsUserCheckable);
child->setCheckState(0,Qt::Unchecked);
item->addChild(child);
}
}
ui.treeWidget->sortByColumn(0,Qt::AscendingOrder);
}
示例3: createFolder
void TupItemManager::createFolder(const QString &name)
{
if (name.isNull())
folderName = tr("New folder %1").arg(foldersTotal);
else
folderName = name;
QTreeWidgetItem *newFolder = new QTreeWidgetItem(this);
newFolder->setFlags(newFolder->flags() | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
newFolder->setIcon(0, QIcon(THEME_DIR + "icons/open.png"));
newFolder->setText(1, folderName);
newFolder->setText(2, "");
newFolder->setFlags(newFolder->flags() | Qt::ItemIsEditable);
foldersTotal++;
m_currentFolder = newFolder;
setCurrentItem(m_currentFolder);
if (name.isNull()) {
editItem(m_currentFolder, 1);
emit itemCreated(newFolder);
}
}
示例4: dragEnterEvent
void AccountTreeWidget::dragEnterEvent( QDragEnterEvent *event )
{
if ( event->source() == this && (event->proposedAction() == Qt::MoveAction || dragDropMode() == QAbstractItemView::InternalMove) )
{
QList<QTreeWidgetItem*> items = selectedItems();
if( items.size() != 1 )
return;
bool dragingIdentity = !dynamic_cast<KopeteAccountLVI*>(items.first());
// Set drop flag based on item we drag
if ( dragingIdentity )
invisibleRootItem()->setFlags(invisibleRootItem()->flags() | Qt::ItemIsDropEnabled);
else
invisibleRootItem()->setFlags(invisibleRootItem()->flags() & ~Qt::ItemIsDropEnabled);
for ( int i = 0; i < this->topLevelItemCount(); i++ )
{
QTreeWidgetItem* identityItem = this->topLevelItem( i );
if ( dragingIdentity )
identityItem->setFlags( identityItem->flags() & ~Qt::ItemIsDropEnabled );
else
identityItem->setFlags( identityItem->flags() | Qt::ItemIsDropEnabled );
}
QTreeWidget::dragEnterEvent(event);
}
}
示例5: readProjectSettings
void QgsGlobePluginDialog::readProjectSettings()
{
// Imagery settings
mImageryTreeView->clear();
for ( const LayerDataSource &ds : getImageryDataSources() )
{
QTreeWidgetItem *item = new QTreeWidgetItem( QStringList() << ds.type << ds.uri );
item->setFlags( item->flags() & ~Qt::ItemIsDropEnabled );
mImageryTreeView->addTopLevelItem( item );
}
mImageryTreeView->resizeColumnToContents( 0 );
// Elevation settings
mElevationTreeView->clear();
for ( const LayerDataSource &ds : getElevationDataSources() )
{
QTreeWidgetItem *item = new QTreeWidgetItem( QStringList() << ds.type << ds.uri );
item->setFlags( item->flags() & ~Qt::ItemIsDropEnabled );
mElevationTreeView->addTopLevelItem( item );
}
mElevationTreeView->resizeColumnToContents( 0 );
#if OSGEARTH_VERSION_GREATER_OR_EQUAL( 2, 5, 0 )
mSpinBoxVerticalScale->setValue( QgsProject::instance()->readDoubleEntry( "Globe-Plugin", "/verticalScale", 1 ) );
#endif
// Map settings
groupBoxSky->setChecked( QgsProject::instance()->readBoolEntry( "Globe-Plugin", "/skyEnabled", true ) );
checkBoxDateTime->setChecked( QgsProject::instance()->readBoolEntry( "Globe-Plugin", "/overrideDateTime", false ) );
dateTimeEditSky->setDateTime( QDateTime::fromString( QgsProject::instance()->readEntry( "Globe-Plugin", "/skyDateTime", QDateTime::currentDateTime().toString() ) ) );
checkBoxSkyAutoAmbient->setChecked( QgsProject::instance()->readBoolEntry( "Globe-Plugin", "/skyAutoAmbient", false ) );
horizontalSliderMinAmbient->setValue( QgsProject::instance()->readDoubleEntry( "Globe-Plugin", "/skyMinAmbient", 30. ) );
}
示例6: keyReleaseEvent
void QCustomTreeWidget::keyReleaseEvent(QKeyEvent *e)
{
QTreeWidgetItem *qItem = currentItem();
if (qItem != NULL)
{
switch (e->key())
{
case Qt::Key_F2: qItem->setFlags(qItem->flags() | Qt::ItemIsEditable);
editItem(qItem);
bEditing = true;
qItem->setFlags(qItem->flags() & ~Qt::ItemIsEditable);
break;
case Qt::Key_Delete: if (!bEditing)
{
deleteItem(qItem);
}
break;
case Qt::Key_Plus: if (!bEditing)
{
addItem(dynamic_cast<QCustomTreeWidgetItem*>(qItem));
}
break;
case Qt::Key_Space: if (!bEditing)
{
launchItem(qItem);
}
break;
case Qt::Key_Return:
case Qt::Key_Enter:
case Qt::Key_Escape: bEditing = false;
break;
default: QTreeWidget::keyReleaseEvent(e); break;
}
}
}
示例7: UnwrapTreeItem
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
QTreeWidgetItem* FilterLibraryTreeWidget::UnwrapTreeItem(QJsonObject object)
{
FilterLibraryTreeWidget::ItemType type = FilterLibraryTreeWidget::ItemType(object["Type"].toInt());
QTreeWidgetItem* item = new QTreeWidgetItem(type);
QString name = object["Name"].toString();
item->setText(0, name);
item->setData(0, Qt::UserRole, name);
if (type == FilterLibraryTreeWidget::Node_Item_Type)
{
item->setIcon(0, QIcon(":/folder_blue.png"));
item->setFlags(item->flags() | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
item->setData(2, Qt::UserRole, object["Expanded"].toBool());
for (QJsonObject::iterator iter = object.begin(); iter != object.end(); ++iter)
{
if (iter.value().isObject())
{
QJsonObject childObj = iter.value().toObject();
QTreeWidgetItem* child = FilterLibraryTreeWidget::UnwrapTreeItem(childObj);
item->insertChild(0, child);
}
}
}
else
{
item->setIcon(0, QIcon(":/text.png"));
item->setFlags(item->flags() | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled);
item->setText(1, object["Path"].toString());
item->setData(1, Qt::UserRole, object["Path"].toString());
}
return item;
}
示例8: read_subsection_element
void XMLParameterReader::read_subsection_element(QTreeWidgetItem *parent)
{
// The structure of the parameter file is assumed to be of the form
//
// <subsection>
// <subsection>
// ...
// <parameter>
// <value> ... </value>
// ...
// <pattern_description> ... </pattern_description>
// </parameter>
// <parameter>
// ...
// </parameter>
// ...
// </subsection>
// <subsection>
// ...
// </subsection>
// ...
// </subsection>
//
// Any subsection has a user-specified name also any parameter, but we do not know
// the userspecified names and we can not assume anything. So, when parsing the file,
// we do not know, if the actual <start_element> is a <subsection> or a <parameter>
// in a subsection. To decide, if the element is a subsection- or a parameter-name,
// we assume, that if the next <start_element> is <value>, we have a <parameter>
// and a parameter has the entries <value>, <default_value>, <documentation>,
// <pattern> and <pattern_description>
Q_ASSERT(xml.isStartElement()); // the actual element is <subsection>
QTreeWidgetItem * subsection = create_child_item(parent); // create a new subsection in the tree
subsection->setIcon(0, subsection_icon); // set the icon,
subsection->setText(0, demangle(xml.name().toString())); // the name
tree_widget->setItemExpanded(subsection, 0); // and the folder is not expanded
while (xml.readNext() != QXmlStreamReader::Invalid) // read the next element
{
if (xml.isEndElement()) // if the next element is </subsection>, break the loop
break;
if (xml.isStartElement()) // if it is a start element
{
if (xml.name() == "value") // it can be <value>, then we have found a parameter,
{
subsection->setFlags(subsection->flags() | Qt::ItemIsEditable); // values can be edited,
read_parameter_element (subsection);
}
else // or it can be a new <subsection>
{
subsection->setFlags(subsection->flags() | Qt::NoItemFlags); // subsections can not be edited,
read_subsection_element (subsection);
};
};
};
}
示例9: addFolder
void BookmarksSideBar::addFolder(const QString &name)
{
QTreeWidgetItem* item = new QTreeWidgetItem(ui->bookmarksTree);
item->setText(0, name);
item->setIcon(0, style()->standardIcon(QStyle::SP_DirIcon));
if (name != _bookmarksToolbar && name != _bookmarksMenu) {
item->setFlags(item->flags() | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
}
else {
item->setFlags((item->flags() & ~Qt::ItemIsDragEnabled) | Qt::ItemIsDropEnabled);
}
}
示例10: QDialog
ReportFilter::ReportFilter(QVector<QString> objects)
{
mDialog = new QDialog();
mVbox = new QVBoxLayout();
mDialog->setWindowTitle(tr("Report Filter"));
mLabel = new QLabel("Please select the objects and categories to be presented in report");
mTreeWidget = new QTreeWidget();
QStringList ColumnNames;
ColumnNames << "Object";
mTreeWidget->setHeaderLabels(ColumnNames);
mObject = objects;
for (int i = 0; i < objects.size(); i++)
{
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(0, QString(objects[i]));
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
item->setCheckState(0, Qt::Unchecked);
for (int j = 0; j < 11; j++)
{
QTreeWidgetItem *child = new QTreeWidgetItem();
child->setText(0, QString(num2category(j).c_str()));
child->setFlags(child->flags() | Qt::ItemIsUserCheckable);
child->setCheckState(0, Qt::Unchecked);
item->addChild(child);
}
mItems.push_back(item);
}
mTreeWidget->insertTopLevelItems(0, mItems);
connect(mTreeWidget, SIGNAL(itemChanged(QTreeWidgetItem* , int)), this, SLOT(itemChanged(QTreeWidgetItem* , int)));
mButtonGridBox = new QGridLayout();
mGenerateButton = new QPushButton("Generate");
connect(mGenerateButton, SIGNAL(clicked()), this, SLOT(generate()));
mCancelButton = new QPushButton("Cancel");
connect(mCancelButton, SIGNAL(clicked()), this, SLOT(cancel()));
mSelectAllButton = new QPushButton("Select All");
connect(mSelectAllButton, SIGNAL(clicked()), this, SLOT(selectAll()));
mButtonGridBox->addWidget(mSelectAllButton, 0, 4, 1, 1, Qt::AlignVCenter | Qt::AlignLeft);
mButtonGridBox->addWidget(mGenerateButton, 0, 4, 1, 3, Qt::AlignVCenter | Qt::AlignRight);
mButtonGridBox->addWidget(mCancelButton, 0, 4, 1, 4, Qt::AlignVCenter | Qt::AlignRight);
mVbox->addWidget(mLabel);
mVbox->addWidget(mTreeWidget);
mVbox->addLayout(mButtonGridBox);
mDialog->setMinimumWidth(250);
mDialog->setLayout(mVbox);
isGenerate = false;
}
示例11: setCurrentItemByKey
void MetadataListView::setCurrentItemByKey(const QString& itemKey)
{
if (itemKey.isNull())
{
return;
}
int i = 0;
QTreeWidgetItem* item = 0;
do
{
item = topLevelItem(i);
if (item && (item->flags() & Qt::ItemIsSelectable))
{
MetadataListViewItem* lvItem = dynamic_cast<MetadataListViewItem*>(item);
if (lvItem)
{
if (lvItem->getKey() == itemKey)
{
setCurrentItem(item);
scrollToItem(item);
m_selectedItemKey = itemKey;
return;
}
}
}
++i;
}
while (item);
}
示例12: viewName
void
PlanSimSubpanel::onSimulationFinished()
{
bool oldBlockTree = right->ui->treeSimViews->blockSignals(true);
right->ui->treeSimViews->clear();
onTimeout();
timer.stop();
if (sim_process and not sim_process->error_simu.isEmpty()) {
mLog->logExt(sim_process->error_simu, true);
} else if (sim_process and sim_process->output_map) {
const vle::value::Map& simu = *sim_process->output_map;
QList<QTreeWidgetItem*> views_items;
vle::value::Map::const_iterator itb = simu.begin();
vle::value::Map::const_iterator ite = simu.end();
for (; itb != ite; itb++) {
QString viewName(itb->first.c_str());
QStringList viewType = mvpz->getViewTypeFromDoc(viewName);
if (viewType.contains("finish")) {
QTreeWidgetItem* vItem = new QTreeWidgetItem();
vItem->setText(
0, QString("%1 (%2)").arg(viewName).arg("finish"));
vItem->setData(0, Qt::UserRole + 0, "view");
vItem->setData(0, Qt::UserRole + 1, viewName);
const vle::value::Matrix& res = itb->second->toMatrix();
for (unsigned int i = 0; i < res.columns(); i++) {
if (res.get(i, 0) and res.get(i, 0)->isString()) {
QString portName = res.getString(i, 0).c_str();
if (portName.contains("AchievedPlan")) {
QTreeWidgetItem* pItem = new QTreeWidgetItem();
pItem->setText(0, portName);
pItem->setFlags(vItem->flags() |
Qt::ItemIsUserCheckable);
pItem->setCheckState(0, Qt::Unchecked);
pItem->setData(0, Qt::UserRole + 0, "port");
pItem->setData(0, Qt::UserRole + 1, viewName);
pItem->setData(0, Qt::UserRole + 2, portName);
vItem->addChild(pItem);
}
}
}
views_items.append(vItem);
}
}
right->ui->treeSimViews->addTopLevelItems(views_items);
}
updateCustomPlot();
right->ui->treeSimViews->blockSignals(oldBlockTree);
thread->quit();
thread->wait();
delete thread;
thread = 0;
left->ui->runButton->setEnabled(true);
}
示例13: AddToTree
void autobots_toutiao::AddToTree(const QString& text)
{
QTreeWidgetItem* item = new QTreeWidgetItem(ui.treeWidget_comment_id);
item->setText(0,text);
item->setFlags(item->flags() | Qt::ItemIsEditable);
ui.treeWidget_comment_id->addTopLevelItem(item);
}
示例14: QDialog
DialogPreferences::DialogPreferences(boost::shared_ptr<SettingsManagerBase> settings_, QWidget* parent)
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
, settings(settings_)
{
this->setupUi(this);
delete checkAutoClear;
delete timeEdit;
delete horizontalLayout_5;
delete checkBox_6;
scanWidgets(this);
listAdvancedOptions->setItemDelegate(new ItemDelegateEditCollumn(listAdvancedOptions, CN_CURVALUE));
std::vector<std::string> keys = settings->getAllKeys();
BOOST_FOREACH(const std::string& s, keys) {
if (widgets.count(s) == 0) {
QTreeWidgetItem* twi = new QTreeWidgetItem(listAdvancedOptions);
twi->setText(CN_KEY, S2Q(s));
twi->setText(CN_DEFAULT, S2Q(settings->getInfo(s)->getDefault()));
twi->setFlags(twi->flags() | Qt::ItemIsEditable);
}
}
listCategories->setCurrentRow(0);
SettingsVariableBase* sv = settings->getVariable("gui.qt.showadvancedsettings");
bool showadvanced = sv->getValue<bool>();
if (!showadvanced)
delete listCategories->item(listCategories->count()-1);
initSettings();
}
示例15: levelUpdateChannelNode
void VCSliderProperties::levelUpdateChannelNode(QTreeWidgetItem* parent,
Fixture* fxi, t_channel ch)
{
QTreeWidgetItem* item;
const QLCChannel* channel;
QString str;
Q_ASSERT(parent != NULL);
channel = fxi->channel(ch);
Q_ASSERT(channel != NULL);
item = levelChannelNode(parent, ch);
if (item == NULL)
{
item = new QTreeWidgetItem(parent);
item->setText(KColumnID, str.setNum(ch));
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
item->setCheckState(KColumnName, Qt::Unchecked);
}
item->setText(KColumnName, channel->name());
item->setText(KColumnType, channel->group());
levelUpdateCapabilities(item, channel);
}