本文整理汇总了C++中QTreeWidgetItem::childCount方法的典型用法代码示例。如果您正苦于以下问题:C++ QTreeWidgetItem::childCount方法的具体用法?C++ QTreeWidgetItem::childCount怎么用?C++ QTreeWidgetItem::childCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTreeWidgetItem
的用法示例。
在下文中一共展示了QTreeWidgetItem::childCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: okButtonClicked
void CatalogueDialog::okButtonClicked()
{
bool close = false;
QPushButton *button = qobject_cast<QPushButton *>( sender() );
if( !button )
close = false;
else
{
if( button->objectName() == "showCloseButton" )
close = true;
}
QTreeWidgetItem *item = treeWidget->currentItem();
if( !item )
return;
int count = item->childCount();
if( count == 0 )
{
QString str = item->text(0);
emit pageRequested(str);
if( close )
accept();
}
}
示例2: showTheoryNodes
void TestHelpSelectingDialog::showTheoryNodes()
{
QTreeWidgetItem *root = new QTreeWidgetItem();
for (int i = 0; i < theoryNodes.length(); i++)
{
KeyStorageNode currentNode = theoryNodes.at(i);
QList<Key> keys = currentNode.getInnerKeys();
for (int j = 0; j < keys.length(); j++)
{
Key currentKey = keys.at(j);
addKey(root, currentKey, currentNode.getPluginName(), i, Qt::UserRole);
}
}
ui->treeWidgetChangeTheme->clear();
while (root->childCount() != 0)
{
ui->treeWidgetChangeTheme->addTopLevelItem(root->takeChild(0));
}
delete root;
ui->treeWidgetChangeTheme->sortByColumn(0, Qt::AscendingOrder);
}
示例3: isNodeErasable
// Test if a node can be erased in the graph : the condition is that none of its children has a menu modify opened
bool GraphModeler::isNodeErasable ( BaseNode* node)
{
QTreeWidgetItem* item = graphListener->items[node];
if(item == NULL)
{
return false;
}
// check if there is already a dialog opened for that item in the graph
std::map< void*, QTreeWidgetItem*>::iterator it;
for (it = map_modifyDialogOpened.begin(); it != map_modifyDialogOpened.end(); ++it)
{
if (it->second == item) return false;
}
//check the item childs
for(int i=0 ; i<item->childCount() ; i++)
{
QTreeWidgetItem *child = item->child(i);
for( it = map_modifyDialogOpened.begin(); it != map_modifyDialogOpened.end(); ++it)
{
if( it->second == child) return false;
}
}
return true;
}
示例4: load_parking_node
//==============================================================
// Load Stands + Parking
//==============================================================
int AirportsWidget::load_parking_node(QString airport_code){
//* Create the Parkings Node
QTreeWidgetItem *parkingParent = new QTreeWidgetItem();
parkingParent->setText(0, "Parking" );
parkingParent->setIcon(0, QIcon(":/icon/folder"));
treeWidgetAirportInfo->addTopLevelItem(parkingParent);
treeWidgetAirportInfo->setItemExpanded(parkingParent, true);
//* DB query
QSqlQuery query(mainObject->db);
query.prepare("SELECT stand, heading, lat, lng FROM stands WHERE airport_code = ? ORDER BY stand ASC;");
query.bindValue(0, airport_code);
query.exec();
//* No results so create a "none node"
if(query.size() == 0){
QTreeWidgetItem *item = new QTreeWidgetItem(parkingParent);
item->setText(0, tr("-- None --"));
return 0;
}
//* Loop and add the Stands
while(query.next()){
QTreeWidgetItem *item = new QTreeWidgetItem(parkingParent);
item->setText(CI_NODE, query.value(0).toString());
item->setText(CI_SETTING_KEY, QString("stand_").append(query.value(0).toString()));
}
//* return the count
return parkingParent->childCount();
}
示例5: trier
void Tree::trier(int forme)
{
// fichiers SF2 par ordre alphabétique
int max = this->topLevelItemCount();
QTreeWidgetItem *child;
this->sortItems(0, Qt::AscendingOrder); // colonne 5 ne fonctionne pas ?!
for (int i = 0; i < max; i ++)
this->topLevelItem(i)->sortChildren(5, Qt::AscendingOrder);
if (forme)
{
// Mise en forme (expanded / collapsed)
for (int i = 0; i < max; i++)
{
child = this->topLevelItem(i);
child->setExpanded(1);
for (int j = 0; j < child->childCount(); j++)
{
child->child(j)->setExpanded(0);
for (int k = 0; k < child->child(j)->childCount(); k++)
{
child->child(j)->child(k)->setExpanded(0);
}
}
}
}
}
示例6: saveComplexAction
void ComplexActionDialog::saveComplexAction()
{
QList<QTreeWidgetItem *> items = ui->ruleTreeWidget->findItems(QString("*"), Qt::MatchWrap | Qt::MatchWildcard);
if (items.isEmpty()) {
return;
}
QList<RuleElement *> ruleElements;
int column = 0;
for (int i = 0; i < ui->ruleTreeWidget->topLevelItemCount(); ++i) {
QTreeWidgetItem *item = ui->ruleTreeWidget->topLevelItem(i);
if (item->childCount() > 0) {
ruleElements.append(parseRuleTreeItem(item));
}
else {
ruleElements.append(new RuleElement(item->text(column), QList<RuleElement *>()
, mWidgetItemCustomPropertyList.repeatCountByItem(item)
, mWidgetItemCustomPropertyList.isKeyActionByItem(item)
, mWidgetItemCustomPropertyList.durationByItem(item)));
}
}
//printRuleElements(ruleElements);
if (mComplexActionNameDialog->isScenario()) {
mComplexUserActionGenerator->generateScenario(mComplexActionNameDialog->complexActionName(), ruleElements, mComplexActionNameDialog->actionStatus());
}
else {
mComplexUserActionGenerator->generateComplexAction(mComplexActionNameDialog->complexActionName()
, ruleElements);
}
}
示例7: on_downButton_clicked
void InstrumentWizard::on_downButton_clicked()
{
QList<QTreeWidgetItem*> wi = partiturList->selectedItems();
if (wi.isEmpty())
return;
QTreeWidgetItem* item = wi.front();
if (item->type() == PART_LIST_ITEM) {
bool isExpanded = partiturList->isItemExpanded(item);
int idx = partiturList->indexOfTopLevelItem(item);
int n = partiturList->topLevelItemCount();
if (idx < (n-1)) {
partiturList->selectionModel()->clear();
QTreeWidgetItem* item = partiturList->takeTopLevelItem(idx);
partiturList->insertTopLevelItem(idx+1, item);
partiturList->setItemExpanded(item, isExpanded);
partiturList->setItemSelected(item, true);
}
}
else {
QTreeWidgetItem* parent = item->parent();
int idx = parent->indexOfChild(item);
int n = parent->childCount();
if (idx < (n-1)) {
partiturList->selectionModel()->clear();
QTreeWidgetItem* item = parent->takeChild(idx);
parent->insertChild(idx+1, item);
partiturList->setItemSelected(item, true);
}
}
}
示例8: attributeAdded
/**
* Slot for adding an attribute to the tree.
* @param listItem the new attribute to add
*/
void RefactoringAssistant::attributeAdded(UMLClassifierListItem *listItem)
{
UMLAttribute *att = static_cast<UMLAttribute*>(listItem);
DEBUG(DBG_SRC) << "attribute = " << att->name(); //:TODO:
UMLClassifier *parent = dynamic_cast<UMLClassifier*>(att->parent());
if (!parent) {
uWarning() << att->name() << " - Parent of attribute is not a classifier!";
return;
}
QTreeWidgetItem *item = findListViewItem(parent);
if (!item) {
uWarning() << "Parent is not in tree!";
return;
}
for (int i = 0; i < item->childCount(); ++i) {
QTreeWidgetItem *folder = item->child(i);
if (folder->text(1) == QLatin1String("attributes")) {
item = new QTreeWidgetItem(folder, QStringList(att->name()));
m_umlObjectMap[item] = att;
connect(att, SIGNAL(modified()), this, SLOT(objectModified()));
setVisibilityIcon(item, att);
DEBUG(DBG_SRC) << "attribute = " << att->name() << " added!"; //:TODO:
break;
}
}
}
示例9: removeBookmark
void BookmarksSideBar::removeBookmark(const BookmarksModel::Bookmark &bookmark)
{
if (bookmark.folder == QLatin1String("unsorted")) {
QList<QTreeWidgetItem*> list = ui->bookmarksTree->findItems(bookmark.title, Qt::MatchExactly);
if (list.count() == 0) {
return;
}
QTreeWidgetItem* item = list.at(0);
if (item && item->data(0, Qt::UserRole + 10).toInt() == bookmark.id) {
ui->bookmarksTree->deleteItem(item);
}
}
else {
QList<QTreeWidgetItem*> list = ui->bookmarksTree->findItems(BookmarksModel::toTranslatedFolder(bookmark.folder), Qt::MatchExactly);
if (list.count() == 0) {
return;
}
QTreeWidgetItem* parentItem = list.at(0);
if (!parentItem) {
return;
}
for (int i = 0; i < parentItem->childCount(); i++) {
QTreeWidgetItem* item = parentItem->child(i);
if (!item) {
continue;
}
if (item->text(0) == bookmark.title && item->data(0, Qt::UserRole + 10).toInt() == bookmark.id) {
ui->bookmarksTree->deleteItem(item);
return;
}
}
}
}
示例10: updateMoneyTree
/* Update Money for Money Tree */
void MainWindow::updateMoneyTree(QTreeWidgetItem *item){
if (item){
if (item->parent()){
item = item->parent();
}
int count = item->childCount();
int total = 0;
for (int i = 0; i < count; i++){
total += item->child(i)->text(1).toInt();
}
item->setText(1,QString::number(total));
}
else {
int TopCount = ui->moneytree->topLevelItemCount();
QTreeWidgetItem * topItem ;
int childCount ;
int total;
for (int i = 0; i < TopCount; i++){
topItem = ui->moneytree->topLevelItem(i);
childCount = topItem->childCount();
total = 0;
for (int j = 0; j < childCount; j++){
total += topItem->child(j)->text(1).toInt();
}
topItem->setText(1,QString::number(total));
}
}
}
示例11: operationAdded
/**
* Slot for adding an operation to the tree.
* @param listItem the new operation to add
*/
void RefactoringAssistant::operationAdded(UMLClassifierListItem *listItem)
{
UMLOperation *op = static_cast<UMLOperation*>(listItem);
DEBUG(DBG_SRC) << "operation = " << op->name(); //:TODO:
UMLClassifier *parent = dynamic_cast<UMLClassifier*>(op->parent());
if (!parent) {
uWarning() << op->name() << " - Parent of operation is not a classifier!";
return;
}
QTreeWidgetItem *item = findListViewItem(parent);
if (!item) {
return;
}
for (int i = 0; i < item->childCount(); ++i) {
QTreeWidgetItem *folder = item->child(i);
if (folder->text(1) == QLatin1String("operations")) {
item = new QTreeWidgetItem(folder, QStringList(op->name()));
m_umlObjectMap[item] = op;
connect(op, SIGNAL(modified()), this, SLOT(objectModified()));
setVisibilityIcon(item, op);
DEBUG(DBG_SRC) << "operation = " << op->name() << " added!"; //:TODO:
break;
}
}
}
示例12: itemsSelected
void US_NoiseLoader::itemsSelected( void )
{
QList< QTreeWidgetItem* > selitems = tw_noises->selectedItems();
int nsels = selitems.size();
lw_selects->clear();
if ( nsels == 0 )
return;
for ( int ii = 0; ii < nsels; ii++ )
{
QTreeWidgetItem* item = selitems[ ii ];
QString itemtext = item->text( 0 );
if ( itemtext.contains( "_noise" ) )
{ // Select an individual noise
lw_selects->addItem( itemtext );
}
else if ( itemtext.contains( "Model" ) )
{ // Select all the noises associated with a model
for ( int jj = 0; jj < item->childCount(); jj++ )
{
lw_selects->addItem( item->child( jj )->text( 0 ) );
}
}
}
}
示例13: find
PacketTreeItem* PacketTreeView::find(regina::NPacket* packet) {
if (! packet)
return 0;
// Start at the root of the tree and work down.
// Note that the root packet itself will not be found by this routine.
// Also, note that the invisible root item might not be a PacketTreeItem,
// and we should not try to cast it as such.
QTreeWidgetItem* root = invisibleRootItem();
int itemCount = 0;
PacketTreeItem* item;
regina::NPacket* current;
while (itemCount < root->childCount()) {
item = dynamic_cast<PacketTreeItem*>(root->child(itemCount++));
current = item->getPacket();
if (current == packet)
return item;
if (current && current->isGrandparentOf(packet)) {
root = item;
itemCount = 0;
}
}
return 0;
}
示例14: favoritesItemChanged
void ColorDialog::favoritesItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
{
Q_UNUSED(previous);
QTreeWidgetItem *root = ui_->listFavorites->invisibleRootItem();
if (!current) {
ui_->buttonRemove->setEnabled(false);
ui_->buttonMoveUp->setEnabled(false);
ui_->buttonMoveDown->setEnabled(false);
return;
} else {
ui_->buttonRemove->setEnabled(true);
if (root->indexOfChild(current) != 0)
ui_->buttonMoveUp->setEnabled(true);
else
ui_->buttonMoveUp->setEnabled(false);
if (root->indexOfChild(current) != root->childCount() - 1)
ui_->buttonMoveDown->setEnabled(true);
else
ui_->buttonMoveDown->setEnabled(false);
}
int cid = current->data(0, Qt::UserRole).toInt();
ui_->listColors->setCurrentItem(ui_->listColors->invisibleRootItem()->child(colorMap_[cid]));
}
示例15: addToTree
void Configuration::addToTree(ConfigItem* item) {
// Find the parent of this item by following the tree through all but the
// last item in the path
QTreeWidgetItem* parent = _tree->invisibleRootItem();
const QStringList& path = item->path();
QStringList::const_iterator last = path.end();
--last;
for (QStringList::const_iterator i = path.begin(); i != last; ++i) {
QTreeWidgetItem* next = nullptr;
for (int j = 0; j < parent->childCount(); ++j) {
QTreeWidgetItem* child = parent->child(j);
if (child->text(0) == *i) {
next = child;
break;
}
}
if (!next) {
// Create this item
next = new QTreeWidgetItem(parent);
next->setText(0, *i);
}
parent = next;
}
// Create a tree item
item->_treeItem = new QTreeWidgetItem(parent);
item->_treeItem->setFlags(item->_treeItem->flags() | Qt::ItemIsEditable);
item->_treeItem->setData(0, ConfigItemRole, QVariant::fromValue(item));
item->_treeItem->setText(0, path.back());
item->setupItem();
}