本文整理汇总了C++中QTreeWidgetItem::setExpanded方法的典型用法代码示例。如果您正苦于以下问题:C++ QTreeWidgetItem::setExpanded方法的具体用法?C++ QTreeWidgetItem::setExpanded怎么用?C++ QTreeWidgetItem::setExpanded使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTreeWidgetItem
的用法示例。
在下文中一共展示了QTreeWidgetItem::setExpanded方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fillTree
void AddFixture::fillTree(const QString& selectManufacturer,
const QString& selectModel)
{
QTreeWidgetItem* parent;
QTreeWidgetItem* child;
QString manuf;
QString model;
/* Clear the tree of any previous data */
m_tree->clear();
/* Add all known fixture definitions to the tree */
QStringListIterator it(m_fixtureDefCache.manufacturers());
while (it.hasNext() == true)
{
manuf = it.next();
parent = new QTreeWidgetItem(m_tree);
parent->setText(KColumnName, manuf);
QStringListIterator modit(m_fixtureDefCache.models(manuf));
while (modit.hasNext() == true)
{
model = modit.next();
child = new QTreeWidgetItem(parent);
child->setText(KColumnName, model);
if (manuf == selectManufacturer &&
model == selectModel)
{
parent->setExpanded(true);
m_tree->setCurrentItem(child);
}
}
}
/* Create a parent and a child for generic dimmer device */
parent = new QTreeWidgetItem(m_tree);
parent->setText(KColumnName, KXMLFixtureGeneric);
child = new QTreeWidgetItem(parent);
child->setText(KColumnName, KXMLFixtureGeneric);
/* Select generic dimmer by default */
if (selectManufacturer == KXMLFixtureGeneric &&
selectModel == KXMLFixtureGeneric)
{
parent->setExpanded(true);
m_tree->setCurrentItem(child);
}
}
示例2: searchComponents
void AddComponentDialog::searchComponents(const QString& input) {
setSelectedComponent(nullptr);
mUi->treeComponents->clear();
// min. 2 chars to avoid freeze on entering first character due to huge result
if (input.length() > 1) {
SearchResult result = searchComponentsAndDevices(input);
QHashIterator<FilePath, SearchResultComponent> cmpIt(result);
while (cmpIt.hasNext()) {
cmpIt.next();
QTreeWidgetItem* cmpItem = new QTreeWidgetItem(mUi->treeComponents);
cmpItem->setText(0, cmpIt.value().name);
cmpItem->setData(0, Qt::UserRole, cmpIt.key().toStr());
QHashIterator<FilePath, SearchResultDevice> devIt(cmpIt.value().devices);
while (devIt.hasNext()) {
devIt.next();
QTreeWidgetItem* devItem = new QTreeWidgetItem(cmpItem);
devItem->setText(0, devIt.value().name);
devItem->setData(0, Qt::UserRole, devIt.key().toStr());
devItem->setText(1, devIt.value().pkgName);
devItem->setTextAlignment(1, Qt::AlignRight);
}
cmpItem->setText(1, QString("[%1]").arg(cmpIt.value().devices.count()));
cmpItem->setTextAlignment(1, Qt::AlignRight);
cmpItem->setExpanded(!cmpIt.value().match);
}
}
mUi->treeComponents->sortByColumn(0, Qt::AscendingOrder);
}
示例3: addEvaluation
bool BookmarkGui::addEvaluation( QString stars )
{
Bookmark bk ;
QueryResult favorite ;
bk.getFavoriteFullData( favorite , this->current_favorite );
QList<QTreeWidgetItem *> list_evaluations =
ui->treeEvaluations->findItems ( stars , Qt::MatchExactly , 1 ) ;
qDebug() << list_evaluations.isEmpty() << list_evaluations.size() << stars ;
if ( list_evaluations.isEmpty() || list_evaluations.size() > 1 ) return false ;
QTreeWidgetItem *evaluation = list_evaluations.first() ;
if ( evaluation->type() != BookmarkGui::item_evaluation ) return false ;
QTreeWidgetItem* item = new QTreeWidgetItem( (QTreeWidgetItem*)0 , BookmarkGui::item_article ) ;
this->setArticleItemDecorations( item , this->current_favorite , this->current_favorite_id ) ;
evaluation->addChild( item ) ;
evaluation->setExpanded( true ) ;
ui->treeEvaluations->setCurrentItem( item );
return true ;
}
示例4: AddControlItem
void HierarchyTreeWidget::AddControlItem(QTreeWidgetItem* parent, const EXPANDEDITEMS& selectedItems, const EXPANDEDITEMS& expandedItems, const HierarchyTreeNode::HIERARCHYTREENODESLIST& items)
{
for (HierarchyTreeNode::HIERARCHYTREENODESLIST::const_iterator iter = items.begin();
iter != items.end();
++iter)
{
const HierarchyTreeControlNode* controlNode = (const HierarchyTreeControlNode*)(*iter);
QTreeWidgetItem* controlItem = new QTreeWidgetItem();
controlItem->setData(ITEM_ID, controlNode->GetId());
controlItem->setText(0, controlNode->GetName());
Decorate(controlItem, controlNode->GetUIObject());
parent->insertChild(parent->childCount(), controlItem);
AddControlItem(controlItem, selectedItems, expandedItems, controlNode->GetChildNodes());
if (expandedItems.find(controlNode->GetId()) != expandedItems.end())
controlItem->setExpanded(true);
if (selectedItems.find(controlNode->GetId()) != selectedItems.end())
{
controlItem->setSelected(true);
}
}
}
示例5: QTreeWidgetItem
QTreeWidgetItem *FixtureRemap::getUniverseItem(quint32 universe, QTreeWidget *tree)
{
QTreeWidgetItem *topItem = NULL;
for (int i = 0; i < tree->topLevelItemCount(); i++)
{
QTreeWidgetItem* tItem = tree->topLevelItem(i);
quint32 tUni = tItem->text(KColumnUniverse).toUInt();
if (tUni == universe)
{
topItem = tItem;
break;
}
}
// Haven't found this universe node ? Create it.
if (topItem == NULL)
{
topItem = new QTreeWidgetItem(tree);
topItem->setText(KColumnName, tr("Universe %1").arg(universe + 1));
topItem->setText(KColumnUniverse, QString::number(universe));
topItem->setText(KColumnID, QString::number(Function::invalidId()));
topItem->setExpanded(true);
}
return topItem;
}
示例6: askNewFolder
void RSSWidget::askNewFolder()
{
bool ok;
QString newName = AutoExpandableDialog::getText(
this, tr("Please choose a folder name"), tr("Folder name:"), QLineEdit::Normal
, tr("New folder"), &ok);
if (!ok) return;
newName = newName.trimmed();
if (newName.isEmpty()) return;
// Determine destination folder for new item
QTreeWidgetItem *destItem = nullptr;
QList<QTreeWidgetItem *> selectedItems = m_feedListWidget->selectedItems();
if (!selectedItems.empty()) {
destItem = selectedItems.first();
if (!m_feedListWidget->isFolder(destItem))
destItem = destItem->parent();
}
// Consider the case where the user clicked on Unread item
RSS::Folder *rssDestFolder = ((!destItem || (destItem == m_feedListWidget->stickyUnreadItem()))
? RSS::Session::instance()->rootFolder()
: qobject_cast<RSS::Folder *>(m_feedListWidget->getRSSItem(destItem)));
QString error;
const QString newFolderPath = RSS::Item::joinPath(rssDestFolder->path(), newName);
if (!RSS::Session::instance()->addFolder(newFolderPath, &error))
QMessageBox::warning(this, "qBittorrent", error, QMessageBox::Ok);
// Expand destination folder to display new feed
if (destItem && (destItem != m_feedListWidget->stickyUnreadItem()))
destItem->setExpanded(true);
// As new RSS items are added synchronously, we can do the following here.
m_feedListWidget->setCurrentItem(m_feedListWidget->mapRSSItem(RSS::Session::instance()->itemByPath(newFolderPath)));
}
示例7: on_pushButtonRefresh_clicked
/**
* @brief MainWindow::on_pushButtonRefresh_clicked
*/
void MainWindow::on_pushButtonRefresh_clicked()
{
qDebug() debugprefix << "on_pushButtonRefresh_clicked() scanning channels" ;
int c,i;
treeWidgetItems.clear();
ui->treeWidgetInterfaces->clear();
canStatus stat = canGetNumberOfChannels(&c);
if( canOK == stat ){
for (i=0; i < c; i++) {
char tmp[255];
stat = canGetChannelData(i, canCHANNELDATA_DEVDESCR_ASCII, &tmp, sizeof(tmp));
if (stat < 0){
char buf[128];
canGetErrorText(stat,buf,128);
qDebug() debugprefix << "canGetChannelData() " << buf ;
}else{
QTreeWidgetItem *port = new QTreeWidgetItem(ui->treeWidgetInterfaces);
QTreeWidgetItem *name = new QTreeWidgetItem(port);
port->setText(0, QString().setNum(i,10));
name->setText(0, QString(tmp));
qDebug() debugprefix << "canGetChannelData("<< i << ") " << tmp;
port->setExpanded(true);
}
}
}else{
char buf[128];
canGetErrorText(stat,buf,128);
qDebug() debugprefix << "canGetNumberOfChannels() " << buf ;
}
}
示例8: addClassifier
/**
* Add a classifier to the data structure.
* @param classifier the classifier to add
* @param parent the tree item under which the classifier is placed
* @param addSuper add it to the base classifier folder
* @param addSub add it to the derived classifier folder
* @param recurse ...
*/
void RefactoringAssistant::addClassifier(UMLClassifier *classifier, QTreeWidgetItem *parent, bool addSuper, bool addSub, bool recurse)
{
if (!classifier) {
uWarning() << "No classifier given - do nothing!";
return;
}
DEBUG(DBG_SRC) << classifier->name() << " added.";
QTreeWidgetItem *classifierItem, *item;
if (parent) {
classifierItem = parent;
}
else {
classifierItem = new QTreeWidgetItem(this, QStringList(classifier->name()));
m_umlObjectMap[classifierItem] = classifier;
}
m_alreadySeen << classifier;
connect(classifier, SIGNAL(modified()),
this, SLOT(objectModified()));
// add attributes
connect(classifier, SIGNAL(attributeAdded(UMLClassifierListItem*)),
this, SLOT(attributeAdded(UMLClassifierListItem*)));
connect(classifier, SIGNAL(attributeRemoved(UMLClassifierListItem*)),
this, SLOT(attributeRemoved(UMLClassifierListItem*)));
QStringList itemTextAt;
itemTextAt << i18n("Attributes") << QLatin1String("attributes");
QTreeWidgetItem *attsFolder = new QTreeWidgetItem(classifierItem, itemTextAt);
attsFolder->setIcon(0, Icon_Utils::SmallIcon(Icon_Utils::it_Folder_Orange));
attsFolder->setExpanded(true);
UMLAttributeList atts(classifier->getAttributeList());
foreach(UMLAttribute* att, atts) {
attributeAdded(att);
}
示例9: QDialog
QDeleteDataDialog::QDeleteDataDialog(QDataManager* manager,QWidget *parent) :
QDialog(parent),
ui(new Ui::QDeleteDataDialog),
m_listView(new QBaseListView),
m_dataManager(manager)
{
ui->setupUi(this);
ui->verticalLayout->insertWidget(0,m_listView,1);
m_listView->setFrameStyle(QFrame::Box);
m_listView->header()->hide();
QList<QDataGroup*> groups = m_dataManager->getGroups();
foreach(QDataGroup * g,groups)
{
QList<QAbstractDataHost*> datas = g->getDatas();
if(datas.size()>0)
{
QTreeWidgetItem * gitem = new QTreeWidgetItem(m_listView);
gitem->setText(0,g->getGroupName());
gitem->setData(0,DarkRole,true);
gitem->setExpanded(true);
gitem->setIcon(0,m_listView->getExpandIcon());
m_itemToGroup.insert(gitem,g);
foreach(QAbstractDataHost * data,datas)
{
QTreeWidgetItem * ditem = new QTreeWidgetItem(gitem);
ditem->setText(0,data->getPropertyValue("objectName").toString());
ditem->setCheckState(0,Qt::Unchecked);
ditem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
m_itemToData.insert(ditem,data);
}
示例10: SelectItemAndExpandTreeByEventName
void FMODSoundBrowser::SelectItemAndExpandTreeByEventName(const DAVA::String & eventName)
{
DAVA::Vector<DAVA::String> tokens;
DAVA::Split(eventName, "/", tokens);
DAVA::int32 tokensCount = tokens.size();
QTreeWidgetItem * currentItem = ui->treeWidget->invisibleRootItem();
for(DAVA::int32 i = 0; i < tokensCount; i++)
{
QString currentToken = QString(tokens[i].c_str());
DAVA::int32 childrenCount = currentItem->childCount();
QTreeWidgetItem * findedItem = 0;
for(DAVA::int32 k = 0; k < childrenCount; k++)
{
QTreeWidgetItem * currentChild = currentItem->child(k);
if(currentChild->text(0) == currentToken)
{
findedItem = currentChild;
findedItem->setExpanded(true);
break;
}
}
if(!findedItem)
return;
currentItem = findedItem;
}
currentItem->setSelected(true);
}
示例11: expandPath
void QSofaListView::expandPath(const std::string& path)
{
if(path.empty())
return;
if(path.data()[0] != '/')
return;
Node* match = down_cast<Node>( graphListener_->findObject(this->topLevelItem(0))->toBaseNode() );
QStringList tokens = QString::fromStdString(path).split('/') ;
for(int i=1;i<tokens.size();i++)
{
match = match->getChild(tokens[i].toStdString());
if(match == nullptr)
return;
if(graphListener_->items.find(match) != graphListener_->items.end())
{
QTreeWidgetItem* item = graphListener_->items[match] ;
item->setExpanded ( true );
}
}
}
示例12: addSubscriber
void MainWindow::addSubscriber()
{
QTreeWidgetItemIterator it(ui->treeWidget);
while (*it)
{
(*it)->setSelected(false);
(*it)->setExpanded(false);
++it;
}
QTreeWidgetItem *sub = new QTreeWidgetItem(ui->treeWidget);
sub->setText(0, QString("Brak identyfikatora #") + QString::number(ui->treeWidget->model()->rowCount()));
QTreeWidgetItem *id = new QTreeWidgetItem(sub);
id->setText(0, "#:");
id->setText(1, QString::number(ui->treeWidget->model()->rowCount()));
QTreeWidgetItem *mail = new QTreeWidgetItem(sub);
mail->setText(0, "E-mail:");
mail->setText(1, "brak");
QTreeWidgetItem *phone = new QTreeWidgetItem(sub);
phone->setText(0, "Telefon:");
phone->setText(1, "brak");
QTreeWidgetItem *notification = new QTreeWidgetItem(sub);
notification->setText(0, "Typ powiadomienia:");
notification->setText(1, "brak");
sub->setSelected(true);
sub->setExpanded(true);
ui->treeWidget->insertTopLevelItem(0, sub);
ui->treeWidget->scrollToBottom();
selectedSubscriber = NULL;
}
示例13: handleExpansion
void Parametertuner::handleExpansion(int dir)
{
// Error checking
if(dir != COLLAPSE) return;
// Declare variables
QTreeWidgetItem* thisItem;
QTreeWidgetItem* parentItem;
// Get the currently selected item
thisItem = getSelectedItem(); // Careful: This may still be null!
// Handle case where collapse has been requested
if(dir == COLLAPSE)
{
// Can't collapse the whole root
if(!thisItem) return;
if(!itemHasParent(thisItem)) return;
// Collapse the parent item of the currently selected item
parentItem = itemGetParent(thisItem);
updateSelection(thisItem, parentItem);
parentItem->setExpanded(false);
// Done
return;
}
}
示例14: loadFoldersOpenState
void RSSImp::loadFoldersOpenState()
{
QStringList open_folders = Preferences::instance()->getRssOpenFolders();
foreach (const QString& var_path, open_folders) {
QStringList path = var_path.split("\\");
QTreeWidgetItem* parent = 0;
foreach (const QString& name, path) {
int nbChildren = 0;
if (parent)
nbChildren = parent->childCount();
else
nbChildren = m_feedList->topLevelItemCount();
for (int i = 0; i < nbChildren; ++i) {
QTreeWidgetItem* child;
if (parent)
child = parent->child(i);
else
child = m_feedList->topLevelItem(i);
if (m_feedList->getRSSItem(child)->id() == name) {
parent = child;
parent->setExpanded(true);
qDebug("expanding folder %s", qPrintable(name));
break;
}
}
}
示例15: OnSelectedControlNodesChanged
void HierarchyTreeWidget::OnSelectedControlNodesChanged(const HierarchyTreeController::SELECTEDCONTROLNODES &selectedControls)
{
if (internalSelectionChanged)
return;
internalSelectionChanged = true;
ResetSelection();
TREEITEMS items = GetAllItems();
for (HierarchyTreeController::SELECTEDCONTROLNODES::const_iterator iter = selectedControls.begin();
iter != selectedControls.end();
++iter)
{
const HierarchyTreeControlNode* node = (*iter);
TREEITEMS::iterator itemIter = items.find(node->GetId());
if (itemIter != items.end())
{
QTreeWidgetItem* item = itemIter->second;
item->setSelected(true);
// Force show selected item
QTreeWidgetItem* parentItem = item->parent();
while (parentItem)
{
parentItem->setExpanded(true);
parentItem = parentItem->parent();
}
}
}
internalSelectionChanged = false;
}