本文整理汇总了C++中QTreeWidgetItem::parent方法的典型用法代码示例。如果您正苦于以下问题:C++ QTreeWidgetItem::parent方法的具体用法?C++ QTreeWidgetItem::parent怎么用?C++ QTreeWidgetItem::parent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTreeWidgetItem
的用法示例。
在下文中一共展示了QTreeWidgetItem::parent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: unmark
void CFontFileListView::unmark()
{
QList<QTreeWidgetItem *> items(selectedItems());
QTreeWidgetItem *item;
foreach(item, items)
if(item->parent())
unmarkItem(item);
checkFiles();
}
示例2: linkComponent
void GraphModeler::linkComponent()
{
// get the selected component
helper::vector< QTreeWidgetItem* > selection;
getSelectedItems(selection);
// a component must be selected
if(selection.empty())
return;
QTreeWidgetItem *fromItem = *selection.begin();
BaseObject *fromObject = getObject(fromItem);
// the object must exist
if(!fromObject)
return;
// the object must not be a loader
if(dynamic_cast<sofa::core::loader::BaseLoader*>(fromObject))
return;
// store the partial component hierarchy i.e we store the parent Nodes only
std::vector<QTreeWidgetItem*> items;
for(QTreeWidgetItem *item = fromItem->parent(); item != NULL; item = item->parent())
items.push_back(item);
// create and show the LinkComponent dialog box
sofa::gui::qt::LinkComponent *window=new sofa::gui::qt::LinkComponent(this, items, fromItem);
if(window->loaderNumber() == 0)
{
window->close();
QMessageBox* messageBox = new QMessageBox(QMessageBox::Warning, "No loaders", "This tree branch does not contain any loader to link with.");
messageBox->show();
return;
}
connect(window, SIGNAL(displayMessage(const std::string&)), this, SIGNAL(displayMessage(const std::string&)));
window->show();
}
示例3: deleteFolder
void CastTreeViewer::deleteFolder() {
QTreeWidgetItem *item = currentItem();
if (!item || !item->parent()) return;
QString itemName = item->data(0, Qt::DisplayRole).toString();
if (itemName == AudioFolderName) return;
int ret = DVGui::MsgBox(tr("Delete folder ") + item->text(0) + "?", tr("Yes"),
tr("No"), 1);
if (ret == 2 || ret == 0) return;
QTreeWidgetItem *parentItem = item->parent();
TFilePath childPath(item->data(1, Qt::DisplayRole).toString().toStdWString());
TLevelSet *levelSet =
TApp::instance()->getCurrentScene()->getScene()->getLevelSet();
levelSet->removeFolder(childPath);
TApp::instance()->getCurrentScene()->setDirtyFlag(true);
parentItem->removeChild(item);
setCurrentItem(parentItem);
}
示例4: isShown
bool BasketListViewItem::isShown()
{
QTreeWidgetItem *item = parent();
while (item) {
if (!item->isExpanded())
return false;
item = item->parent();
}
return true;
}
示例5: addDateMoneyTree
/* Add Money tree - Return this Item */
QTreeWidgetItem * MainWindow::addItemMoneyTree(const QString &item, int money, const QDate & date, const QString & id){
QTreeWidgetItem * moneyitem = new QTreeWidgetItem;
moneyitem->setText(0,item);
moneyitem->setText(1,QString::number(money));
moneyitem->setText(2,id);
addDateMoneyTree(date)->addChild(moneyitem);
ui->moneytree->setCurrentItem(moneyitem);
updateMoneyTree(moneyitem->parent());
return moneyitem;
}
示例6: updateTreeChecks
void GUIImport::updateTreeChecks(QObject* obj)
{
QTreeWidgetItem* sender = (QTreeWidgetItem*)obj;
QCheckBox* check = (QCheckBox*)ui->viewTree->itemWidget(sender, COL_CHECKBOX);
if (!sender->parent())
{
Qt::CheckState state = check->checkState();
if (check->checkState() == Qt::PartiallyChecked)
state = Qt::Unchecked;
// just disable or enable childs
for (int i = 0; i < sender->childCount(); i++)
{
QTreeWidgetItem* attrItem = sender->child(i);
QCheckBox* attr_check = (QCheckBox*)ui->viewTree->itemWidget(attrItem, COL_CHECKBOX);
attr_check->setCheckState(state);
}
}
else
{
// clicking on child, check state of siblings
int numChecked = 0;
int numChilds = sender->parent()->childCount();
if (numChilds > 0)
{
for (int i = 0; i < numChilds; i++)
{
QCheckBox* attr_check = (QCheckBox*)ui->viewTree->itemWidget(sender->parent()->child(i), COL_CHECKBOX);
if (attr_check->checkState() == Qt::Checked)
numChecked++;
}
QCheckBox* view_check = (QCheckBox*)ui->viewTree->itemWidget(sender->parent(), COL_CHECKBOX);
if (numChecked == numChilds)
view_check->setCheckState(Qt::Checked);
else
view_check->setCheckState(Qt::PartiallyChecked);
}
}
}
示例7: saveDetails
void FileComparatorWindow::saveDetails()
{
QString filename;
QFileDialog dialog(this);
QStringList filters;
filters.append(QString(tr("Text File (*.txt)")));
dialog.setFileMode(QFileDialog::AnyFile);
dialog.setNameFilters(filters);
dialog.setViewMode(QFileDialog::Detail);
dialog.setAcceptMode(QFileDialog::AcceptSave);
if (dialog.exec() == QDialog::Accepted)
{
filename = dialog.selectedFiles()[0];
if (!filename.contains('.')) filename += ".txt";
QFile *outFile = new QFile(filename);
if (!outFile->open(QIODevice::WriteOnly | QIODevice::Text))
return;
QTreeWidget *tree = ui->treeDetails;
QTreeWidgetItemIterator it(tree);
while (*it) {
QTreeWidgetItem *item = *it;
QString itemText = item->text(0);
while (item->parent())
{
outFile->write(" ");
item = item->parent();
}
outFile->write(itemText.toUtf8() + "\n");
++it;
}
outFile->close();
}
}
示例8: testerExited
void TestRegressionWindow::testerExited(int /* exitCode */, QProcess::ExitStatus exitStatus)
{
assert(m_activeProcess != 0);
assert(m_activeTreeItem != 0);
if(exitStatus == QProcess::CrashExit) // Special case: crash!
{
QTreeWidgetItem *useItem = m_activeTreeItem;
if(m_testCounter >= 0 || m_runCounter > 0) // Single-tests mode invoked on a directory OR All-test-mode
{
QTreeWidgetItem *parent = useItem->parent();
assert(parent != 0);
useItem = parent->child(parent->indexOfChild(useItem) + 1);
assert(useItem != 0);
}
// Reflect crashed test...
updateItemStatus(Crash, useItem, QString());
}
if(m_testCounter >= 0) // All-tests mode
m_ui.progressBar->setValue(m_ui.progressBar->maximum());
// Eventually save log output...
if(!m_saveLogUrl.isEmpty())
{
// We should close our written log with </body></html>.
m_processingQueue.enqueue(QString::fromLatin1("\n</body>\n</html>"));
if(!m_justProcessingQueue)
{
m_justProcessingQueue = true;
QTimer::singleShot(50, this, SLOT(processQueue()));
}
}
// Cleanup gui...
m_ui.saveLogButton->setEnabled(true);
m_ui.actionRun_tests->setEnabled(true);
m_ui.pauseContinueButton->setEnabled(false);
// Check if there is already an output/index.html present...
loadOutputHTML();
// Cleanup data..
delete m_activeProcess;
m_activeProcess = 0;
m_runCounter = 0;
m_testCounter = 0;
m_activeTreeItem = 0;
}
示例9: mouseDoubleClickEvent
//----------------------------------------------------------------------------------------
void ScriptTreeWidget::mouseDoubleClickEvent(QMouseEvent *event)
{
QList<QTreeWidgetItem*> list = selectedItems();
if(list.size() == 0)
return;
QTreeWidgetItem *item = list[0];
if(item->parent() == 0)
return;
while(item->parent() != 0 && item->parent()->parent() != 0)
item = item->parent();
Ogre::String scriptname = item->text(0).toStdString();
Ogre::String scriptfilename = item->whatsThis(0).toStdString();
GenericTextEditor::getSingletonPtr()->displayTextFromFile(scriptfilename.c_str());
}
示例10: REFRESH_TREE_WIDGET
void TREE_ARAMA_KERNEL::REFRESH_TREE_WIDGET()
{
QTreeWidgetItem * item = m_tree_widget->currentItem();
if ( item EQ NULL ) {
return;
}
m_tree_widget->collapseItem(item->parent());
m_tree_widget->expandItem (item->parent());
}
示例11: on_newItemButton_clicked
void TreeWidgetEditor::on_newItemButton_clicked()
{
m_updating = true;
QTreeWidgetItem *curItem = ui.treeWidget->currentItem();
QTreeWidgetItem *newItem = 0;
if (curItem) {
if (curItem->parent())
newItem = new QTreeWidgetItem(curItem->parent(), curItem);
else
newItem = new QTreeWidgetItem(ui.treeWidget, curItem);
} else
newItem = new QTreeWidgetItem(ui.treeWidget);
newItem->setText(0, tr("New Item"));
newItem->setFlags(newItem->flags() | Qt::ItemIsEditable);
ui.treeWidget->setCurrentItem(newItem, ui.listWidget->currentRow());
m_updating = false;
updateEditor();
ui.treeWidget->editItem(newItem, ui.listWidget->currentRow());
}
示例12: on_addButton_clicked
void EditContactEntryDialog::on_addButton_clicked()
{
QTreeWidgetItem* item = ui->propertiesTreeWidget->selectedItems().at(0);
QTreeWidgetItem* topLevelItem = item->parent() ? item->parent() : item;
data::ContactProperty::EType type = ui->propertiesTreeWidget->indexOfTopLevelItem(topLevelItem) == 0
? data::ContactProperty::E_TYPE_EMAIL
: data::ContactProperty::E_TYPE_PHONE_NUMBER;
data::ptr<data::ContactProperty> contactProperty(new data::ContactProperty(m_contactEntry, QString(), "<new>", type));
QTreeWidgetItem* newItem = new QTreeWidgetItem();
initPropertiesTreeWidgetItem(newItem, contactProperty);
if (item == topLevelItem)
{
topLevelItem->addChild(newItem);
}
else
{
topLevelItem->insertChild(topLevelItem->indexOfChild(item) + 1, newItem);
}
}
示例13: calculateExpand
void GxsForumsFillThread::calculateExpand(const RsGxsForumMsg &msg, QTreeWidgetItem *item)
{
if (mFillComplete && mExpandNewMessages && IS_MSG_UNREAD(msg.mMeta.mMsgStatus)) {
QTreeWidgetItem *parentItem = item;
while ((parentItem = parentItem->parent()) != NULL) {
if (std::find(mItemToExpand.begin(), mItemToExpand.end(), parentItem) == mItemToExpand.end()) {
mItemToExpand.push_back(parentItem);
}
}
}
}
示例14: deleteCantact
void CantactTreeWidget::deleteCantact()
{
int ret = QMessageBox::warning(NULL, "warning", "确定要删除该联系人吗?", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if(ret == QMessageBox::Yes)
{
QTreeWidgetItem *item = currentWidgetItem;
QTreeWidgetItem *parent = item->parent();
parent->removeChild(currentWidgetItem);
currentWidgetItem = NULL;
}
}
示例15: remove
void LibraryTreeWidget::remove()
{
QList<QTreeWidgetItem*> selectedItems = this->selectedItems();
for (int i = 0; i < selectedItems.size(); ++i)
{
QTreeWidgetItem* item = selectedItems[i];
if (item->parent())
item->parent()->removeChild(item);
}
std::stack<QTreeWidgetItem*> stack;
for (int i = 0; i < selectedItems.size(); ++i)
stack.push(selectedItems[i]);
while (!stack.empty())
{
QTreeWidgetItem* item = stack.top();
stack.pop();
QString fileName = item->data(0, Qt::UserRole).toMap()["filename"].toString();
QFileInfo fileInfo(fileName);
if (fileInfo.suffix().toLower() == "lua")
dependencyGraph_.removeCode(fileName);
for (int i = 0; i < item->childCount(); ++i)
stack.push(item->child(i));
}
for (int i = 0; i < selectedItems.size(); ++i)
{
QTreeWidgetItem* item = selectedItems[i];
delete item;
}
checkModification();
}