/** * Moves to the previous item in the history, selecting it for display. * Note that this function move to the item which chronologically precedes * the current one, which, in list view terms, is the next item. */ void HistoryView::selectPrev() { QTreeWidgetItem* pItem; // Get the current item pItem = currentItem(); // Select the next item in the list if (pItem != NULL && itemAbove(pItem) != NULL) { // TODO maybe itemBelow() pItem = itemAbove(pItem); select(pItem); } }
QModelIndex CWizCategoryBaseView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) { QModelIndex index = QTreeWidget::moveCursor(cursorAction, modifiers); if (!index.isValid()) return index; CWizCategoryViewItemBase* pItem = categoryItemFromIndex(index); if (CWizCategoryViewSeparatorItem* pSeparatorItem = dynamic_cast<CWizCategoryViewSeparatorItem*>(pItem)) { switch (cursorAction) { case MoveUp: case MoveLeft: { QTreeWidgetItem* pAbove = itemAbove(pSeparatorItem); Q_ASSERT(pAbove); return indexFromItem(pAbove); } case MoveDown: case MoveRight: { QTreeWidgetItem* pBelow = itemBelow(pSeparatorItem); Q_ASSERT(pBelow); return indexFromItem(pBelow); } default: Q_ASSERT(false); break; } } return index; }
void qm_plistview::keyPressEvent(QKeyEvent *event) { switch (event->key()) { case Qt::Key_Return: { on_item_dclicked(currentItem()); break; } case Qt::Key_Delete: { delete_it(); break; } case Qt::Key_Space: { if (current_songPos != -1 && current_songPos < topLevelItemCount() ) scrollToItem(topLevelItem(current_songPos)); break; } case Qt::Key_Home: { if (topLevelItemCount() > 0) scrollToItem(topLevelItem(0)); break; } case Qt::Key_End: { if (topLevelItemCount() > 0) scrollToItem(topLevelItem(topLevelItemCount() - 1)); break; } case Qt::Key_Down: { if (currentItem()->get_pos < topLevelItemCount()) setCurrentItem(itemBelow ( currentItem() )); break; } case Qt::Key_Up: { if (currentItem()->get_pos > 1) setCurrentItem(itemAbove ( currentItem() )); break; } default: QTreeWidget::keyPressEvent(event); } }
toProjectTemplateItem *toProjectTemplateItem::previousSibling() { toTreeWidgetItem *item = itemAbove(); if (!item) return NULL; if (item == parent()) return NULL; while (item && item->parent() != parent()) item = item->parent(); return dynamic_cast<toProjectTemplateItem *>(item); }
void dragTarget::scrollUp() { disconnect(scrollUpTimer, SIGNAL(timeout()), this, SLOT(scrollUp())); puts("scrollUp chiamato"); this -> scrollToItem(tempScroll); tempScroll = itemAbove(tempScroll); connect(scrollUpTimer, SIGNAL(timeout()), this, SLOT(scrollUp())); if(tempScroll == NULL) { disconnect(scrollUpTimer, SIGNAL(timeout()), this, SLOT(scrollUp())); scrollUpTimer -> stop(); } }
bool HierarchyTreeControl::GetMoveItemID(QDropEvent *event, HierarchyTreeNode::HIERARCHYTREENODEID &insertInTo, HierarchyTreeNode::HIERARCHYTREENODEID &insertAfter) { DropIndicatorPosition position = dropIndicatorPosition(); QTreeWidgetItem* item = itemAt(event->pos()); if (!item) return false; if (item == currentItem()) return false; insertInTo = HierarchyTreeNode::HIERARCHYTREENODEID_EMPTY; switch (position) { case OnViewport: { return false; }break; case OnItem: { QVariant data = item->data(ITEM_ID); insertInTo = data.toInt(); insertAfter = HierarchyTreeNode::HIERARCHYTREENODEID_EMPTY; } break; case AboveItem: { QTreeWidgetItem* parent = item->parent(); if (parent) insertInTo = parent->data(ITEM_ID).toInt(); QTreeWidgetItem* above = itemAbove(item); if (!above) return false; insertAfter = above->data(ITEM_ID).toInt(); } break; case BelowItem: { QTreeWidgetItem* parent = item->parent(); if (parent) insertInTo = parent->data(ITEM_ID).toInt(); insertAfter = item->data(ITEM_ID).toInt(); }break; } if (currentItem() && currentItem()->data(ITEM_ID) == insertAfter) return false; return true; }
void AssignedListView::slotMoveCurrentToolUp() { AssignedListViewItem* const item = dynamic_cast<AssignedListViewItem*>(currentItem()); if (item) { AssignedListViewItem* const iabove = dynamic_cast<AssignedListViewItem*>(itemAbove(item)); if (iabove) { moveTool(item, iabove->toolSet()); setCurrentItem(item); } } }
// move an item one position up void UserMenuTree::itemUp() { QTreeWidgetItem *current = currentItem(); UserMenuItem *aboveitem = dynamic_cast<UserMenuItem *>(itemAbove(current)); if (!aboveitem) { return; } bool expanded = current->isExpanded(); blockSignals(true); QTreeWidgetItem *aboveparent = aboveitem->parent(); int aboveindex = itemIndex(aboveparent,aboveitem); UserMenuItem *parent = dynamic_cast<UserMenuItem *>(current->parent()); int index = itemIndex(parent,current); takeItem(parent,current); if ( parent!=aboveparent && index!=0 ) { aboveindex++; } if ( parent==aboveparent && aboveitem->menutype()==UserMenuData::Submenu ) { insertItem(aboveitem,0,current); } else { insertItem(aboveparent,aboveindex,current); } // update model data of old and new parent, if it has changed UserMenuItem *newparent = dynamic_cast<UserMenuItem *>(current->parent()); if ( parent != newparent ) { if ( parent ) { parent->setModelData(); parent->setText(0, parent->updateMenutitle()); } if ( newparent ) { newparent->setModelData(); newparent->setText(0, newparent->updateMenutitle()); } } current->setExpanded(expanded); setCurrentItem(current); blockSignals(false); }