本文整理汇总了C++中QTreeWidgetItem::indexOfChild方法的典型用法代码示例。如果您正苦于以下问题:C++ QTreeWidgetItem::indexOfChild方法的具体用法?C++ QTreeWidgetItem::indexOfChild怎么用?C++ QTreeWidgetItem::indexOfChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTreeWidgetItem
的用法示例。
在下文中一共展示了QTreeWidgetItem::indexOfChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateButtons
void TabStopDialog::updateButtons(QTreeWidgetItem *item)
{
QTreeWidgetItem *root = m_widgetTree->invisibleRootItem();
m_btnUp->setEnabled(item && (root->indexOfChild(item) > 0 && m_widgetTree->isEnabled()
/*&& (item->itemAbove()->parent() == item->parent()))*/));
m_btnDown->setEnabled(item && root->indexOfChild(item) < (root->childCount() - 1) && m_widgetTree->isEnabled());
}
示例2: 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]));
}
示例3: ensureValidIterator
void QTreeWidgetItemIteratorPrivate::ensureValidIterator(const QTreeWidgetItem *itemToBeRemoved)
{
Q_Q(QTreeWidgetItemIterator);
Q_ASSERT(itemToBeRemoved);
if (!q->current) return;
QTreeWidgetItem *nextItem = q->current;
// Do not walk to the ancestor to find the other item if they have the same parent.
if (nextItem->parent() != itemToBeRemoved->parent()) {
while (nextItem->parent() && nextItem != itemToBeRemoved) {
nextItem = nextItem->parent();
}
}
// If the item to be removed is an ancestor of the current iterator item,
// we need to adjust the iterator.
if (nextItem == itemToBeRemoved) {
QTreeWidgetItem *parent = nextItem;
nextItem = 0;
while (parent && !nextItem) {
nextItem = nextSibling(parent);
parent = parent->parent();
}
if (nextItem) {
// Ooooh... Set the iterator to the next valid item
*q = QTreeWidgetItemIterator(nextItem, q->flags);
if (!(q->matchesFlags(nextItem))) ++(*q);
} else {
// set it to null.
q->current = 0;
m_parentIndex.clear();
return;
}
}
if (nextItem->parent() == itemToBeRemoved->parent()) {
// They have the same parent, i.e. we have to adjust the m_currentIndex member of the iterator
// if the deleted item is to the left of the nextItem.
QTreeWidgetItem *par = itemToBeRemoved->parent(); // We know they both have the same parent.
QTreeWidget *tw = itemToBeRemoved->treeWidget(); // ..and widget
int indexOfItemToBeRemoved = par ? par->indexOfChild(const_cast<QTreeWidgetItem *>(itemToBeRemoved))
: tw->indexOfTopLevelItem(const_cast<QTreeWidgetItem *>(itemToBeRemoved));
int indexOfNextItem = par ? par->indexOfChild(nextItem) : tw->indexOfTopLevelItem(nextItem);
if (indexOfItemToBeRemoved <= indexOfNextItem) {
// A sibling to the left of us was deleted, adjust the m_currentIndex member of the iterator.
// Note that the m_currentIndex will be wrong until the item is actually removed!
m_currentIndex--;
}
}
}
示例4: removeTreeItems
void BoincTree::removeTreeItems(InfoBoinc::Session::IdType id, QList<QTreeWidgetItem *> items)
{
QTreeWidgetItem *sessionItem = m_sessionItems[id];
m_tree->setUpdatesEnabled(false);
foreach (QTreeWidgetItem *item, items) {
sessionItem->takeChild(sessionItem->indexOfChild(item));
}
示例5:
void
TransitionEditorWindow::on_equationsTree_itemClicked(QTreeWidgetItem* item, int /*column*/)
{
qDebug("on_equationsTree_itemClicked");
if (model_ == nullptr) return;
if (transition_ == nullptr) return;
if (item == nullptr) return;
QTreeWidgetItem* parent = item->parent();
if (parent == nullptr) { // root item
ui_->formulaTextEdit->clear();
return;
}
int parentIndex = ui_->equationsTree->indexOfTopLevelItem(parent);
int index = parent->indexOfChild(item);
const auto& equation = model_->equationGroupList()[parentIndex].equationList[index];
// Set timeExpression for the current point.
QTableWidgetItem* currentItem = ui_->pointsTable->currentItem();
if (currentItem == nullptr) return;
int row = currentItem->row();
if (pointList_[row].timeExpression.lock() != equation) {
pointList_[row].timeExpression = equation;
updateTransition();
}
}
示例6: on_moveItemLeftButton_clicked
void TreeWidgetEditor::on_moveItemLeftButton_clicked()
{
QTreeWidgetItem *curItem = ui.treeWidget->currentItem();
if (!curItem)
return;
QTreeWidgetItem *parentItem = curItem->parent();
if (!parentItem)
return;
m_updating = true;
QTreeWidgetItem *takenItem = parentItem->takeChild(parentItem->indexOfChild(curItem));
if (parentItem->parent()) {
int idx = parentItem->parent()->indexOfChild(parentItem);
parentItem->parent()->insertChild(idx, takenItem);
} else {
int idx = ui.treeWidget->indexOfTopLevelItem(parentItem);
ui.treeWidget->insertTopLevelItem(idx, takenItem);
}
ui.treeWidget->setCurrentItem(takenItem, ui.listWidget->currentRow());
m_updating = false;
updateEditor();
}
示例7: indexOfChild
int QTreeWidgetItemProto::indexOfChild(QTreeWidgetItem *child) const
{
QTreeWidgetItem *item = qscriptvalue_cast<QTreeWidgetItem*>(thisObject());
if (item)
return item->indexOfChild(child);
return -1;
}
示例8: onRemoveRequest
/*
The user has triggered the action to remove a file from the project.
Grab the file name and signal ProjectInfo to make the change.
*/
void FileBrowser::onRemoveRequest()
{
QString filepath = currentItem()->text(FILENAME_COLUMN);
QTreeWidgetItem *top = topLevelItem(0);
delete top->takeChild(top->indexOfChild(currentItem()));
emit removeFileRequest(filepath);
}
示例9: moveSelection
void Parametertuner::moveSelection(int dir)
{
QTreeWidgetItem* thisItem = getSelectedItem();
if (!thisItem)
{
m_ui.parameter_root_widget->topLevelItem(0)->setSelected(true);
return;
}
QTreeWidgetItem* parent = thisItem->parent();
QTreeWidgetItem* nextItem;
if (!parent)
{
parent = m_ui.parameter_root_widget->invisibleRootItem();
}
int thisItemIndex = parent->indexOfChild(thisItem);
if (thisItem->isExpanded() && dir == DOWN)
{
nextItem = thisItem->child(0);
updateSelection(thisItem, nextItem);
return;
}
else if (!parent->child(thisItemIndex + dir))
{
updateSelection(thisItem, parent);
return;
}
else
{
nextItem = parent->child(thisItemIndex + dir);
updateSelection(thisItem, nextItem);
return;
}
}
示例10: 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);
}
}
}
示例11: on_removeButton_clicked
void InstrumentWizard::on_removeButton_clicked()
{
QList<QTreeWidgetItem*> wi = partiturList->selectedItems();
if (wi.isEmpty())
return;
QTreeWidgetItem* item = wi.front();
QTreeWidgetItem* parent = item->parent();
if (parent) {
if (((StaffListItem*)item)->op == ITEM_ADD) {
if (parent->childCount() == 1) {
partiturList->takeTopLevelItem(partiturList->indexOfTopLevelItem(parent));
delete parent;
}
else {
parent->takeChild(parent->indexOfChild(item));
delete item;
}
}
else {
((StaffListItem*)item)->op = ITEM_DELETE;
partiturList->setItemHidden(item, true);
}
}
else {
if (((PartListItem*)item)->op == ITEM_ADD)
delete item;
else {
((PartListItem*)item)->op = ITEM_DELETE;
partiturList->setItemHidden(item, true);
}
}
partiturList->clearSelection();
emit completeChanged(partiturList->topLevelItemCount() > 0);
}
示例12: addTestCases
void SummaryTree::addTestCases()
{
QTreeWidgetItem *curItem = currentItem();
if (indexOfTopLevelItem(curItem) == -1)
curItem = curItem->parent();
int index = indexOfTopLevelItem(curItem);
Task *curTask = curContest->getTask(index);
AddTestCasesWizard *wizard = new AddTestCasesWizard(this);
wizard->setSettings(settings, curTask->getTaskType() == Task::Traditional);
if (wizard->exec() == QDialog::Accepted) {
QList<QStringList> inputFiles = wizard->getMatchedInputFiles();
QList<QStringList> outputFiles = wizard->getMatchedOutputFiles();
for (int i = 0; i < inputFiles.size(); i ++) {
addTestCase();
QTreeWidgetItem *curItem = currentItem();
QTreeWidgetItem *parentItem = curItem->parent();
int taskIndex = indexOfTopLevelItem(parentItem);
int testCaseIndex = parentItem->indexOfChild(curItem);
Task *curTask = curContest->getTask(taskIndex);
TestCase *curTestCase = curTask->getTestCase(testCaseIndex);
curTestCase->setFullScore(wizard->getFullScore());
curTestCase->setTimeLimit(wizard->getTimeLimit());
curTestCase->setMemoryLimit(wizard->getMemoryLimit());
for (int j = 0; j < inputFiles[i].size(); j ++)
curTestCase->addSingleCase(inputFiles[i][j], outputFiles[i][j]);
setCurrentItem(parentItem);
setCurrentItem(curItem);
}
}
delete wizard;
}
示例13: on_moveActionLeftButton_clicked
/** Removes an action */
void DlgCustomToolbars::on_moveActionLeftButton_clicked()
{
QTreeWidgetItem* item = toolbarTreeWidget->currentItem();
if (item && item->parent() && toolbarTreeWidget->isItemSelected(item)) {
QTreeWidgetItem* parent = item->parent();
int index = parent->indexOfChild(item);
parent->takeChild(index);
// In case a separator should be moved we have to count the separators
// which come before this one.
// This is needed so that we can distinguish in removeCustomCommand
// which separator it is.
QByteArray data = item->data(0, Qt::UserRole).toByteArray();
if (data == "Separator") {
int countSep = 1;
for (int i=0; i<index-1; i++) {
QByteArray d = parent->child(i)->data(0, Qt::UserRole).toByteArray();
if (d == "Separator") {
countSep++;
}
}
data += QByteArray::number(countSep);
}
removeCustomCommand(parent->text(0), data);
delete item;
}
QVariant data = workbenchBox->itemData(workbenchBox->currentIndex(), Qt::UserRole);
QString workbench = data.toString();
exportCustomToolbars(workbench.toLatin1());
}
示例14: swapItems
void TreeWidget::swapItems(QTreeWidgetItem* source, QTreeWidgetItem* target)
{
QTreeWidgetItem* parent = source->parent();
if (!parent)
parent = invisibleRootItem();
const bool se = source->isExpanded();
const bool ss = source->isFirstColumnSpanned();
const bool te = target->isExpanded();
const bool ts = target->isFirstColumnSpanned();
const int idx = parent->indexOfChild(target);
parent->takeChild(parent->indexOfChild(source));
parent->insertChild(idx, source);
source->setExpanded(se);
source->setFirstColumnSpanned(ss);
target->setExpanded(te);
target->setFirstColumnSpanned(ts);
}
示例15: indexOfItem
int QcTreeWidget::indexOfItem( const QcTreeWidget::ItemPtr & item )
{
if( !item ) return -1;
QTreeWidgetItem *parent = item->parent();
if( parent )
return parent->indexOfChild( item );
else
return indexOfTopLevelItem( item );
}