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; }
void CListBoxCtrl::NewStrings(const SC_StringArray& newStrings) { ClearEntries(); AddBasicEntry(newStrings); ResetStrings(); ResetSelection(); }
void CustomVirtListCtrl<T,L>::Clear() { m_data.clear(); SetItemCount( 0 ); ResetSelection(); RefreshVisibleItems(); }
void HierarchyTreeWidget::on_treeWidget_itemSelectionChanged() { QTreeWidgetItem* selectedItem = ui->treeWidget->currentItem(); if (!selectedItem) { return; } if (internalSelectionChanged) { return; } QVariant data = selectedItem->data(ITEM_ID); HierarchyTreeNode::HIERARCHYTREENODEID id = data.toInt(); HierarchyTreeNode* baseNode = HierarchyTreeController::Instance()->GetTree().GetNode(id); HierarchyTreePlatformNode* selectedPlatform = dynamic_cast<HierarchyTreePlatformNode* >(baseNode); HierarchyTreeScreenNode* selectedScreen = dynamic_cast<HierarchyTreeScreenNode* >(baseNode); HierarchyTreeControlNode* selectedControl = dynamic_cast<HierarchyTreeControlNode* >(baseNode); if (!selectedPlatform && !selectedScreen && !selectedControl) return; internalSelectionChanged = true; //only platform or screen node can be seleted if (selectedPlatform || selectedScreen) { ResetSelection(); HierarchyTreeController::Instance()->ResetSelectedControl(); selectedItem->setSelected(true); } if (selectedControl) { selectedScreen = selectedControl->GetScreenNode(); selectedPlatform = selectedScreen->GetPlatform(); } else if (selectedScreen) { selectedPlatform = selectedScreen->GetPlatform(); } HierarchyTreeController::Instance()->UpdateSelection(selectedPlatform, selectedScreen); HierarchyTreeController::Instance()->UpdateSelection(baseNode); internalSelectionChanged = false; if (selectedControl) { if (ui->treeWidget->selectedItems().size() == 1) HierarchyTreeController::Instance()->ResetSelectedControl(); HierarchyTreeController::Instance()->SelectControl(selectedControl); } }
void DisassemblyView::mousePressEvent(QMouseEvent * evt) { setCursorPosition(evt); // FIXME if (evt->buttons() & Qt::LeftButton) { ResetSelection(); _needRepaint = true; // TODO: selectionChanged } }
void CListBoxCtrl::Set(CWnd* pParent, int nIDCombo, SC_IntArray& intValArray) { VERIFY(SubclassDlgItem(nIDCombo, pParent)); m_intValArray = intValArray; multiSelection = true; ResetStrings(); EnableWindow(!listStrings.IsEmpty()); ResetSelection(); }
void CListBoxCtrl::Set(CWnd* pParent, int nIDCombo, int* pintVal) { VERIFY(SubclassDlgItem(nIDCombo, pParent)); m_pintVal = pintVal; multiSelection = false; ResetStrings(); EnableWindow(!listStrings.IsEmpty()); ResetSelection(); }
void CustomVirtListCtrl<T,L>::SaveSelection() { ResetSelection(); long item = -1; while ( true ) { item = GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); if ( item == -1 ) break; m_selected_data.push_back( m_data[item] ); } }
/*---------------------------------------------------------------------- TtaSelectElement Selects a single element. This element is highlighted in all views where it can be displayed. If it cannot be displayed in any existing view, a new view is eventually open for displaying it. Parameters: document: the document containing the element to be selected. selectedElement: the element to be selected. NULL for cancelling the selection in the document. ----------------------------------------------------------------------*/ void TtaSelectElement (Document document, Element selectedElement) { DisplayMode dispMode; UserErrorCode = 0; if (selectedElement && ((PtrElement) selectedElement)->ElParent == NULL) TtaError (ERR_invalid_parameter); /* Checks the parameter document */ else if (document < 1 || document > MAX_DOCUMENTS) TtaError (ERR_invalid_document_parameter); else if (LoadedDocument[document - 1] == NULL) TtaError (ERR_invalid_document_parameter); else { dispMode = TtaGetDisplayMode (document); if (dispMode == DisplayImmediately) { if (selectedElement == NULL) /* Abort the selection */ ResetSelection (LoadedDocument[document - 1]); else { SelectElement (LoadedDocument[document - 1], (PtrElement) selectedElement, TRUE, FALSE, TRUE); #ifdef _WX // update the status bar TtaSetStatusSelectedElement (document, 1, selectedElement); #endif /* _WX */ } } else { CancelSelection (); NewSelection (document, selectedElement, NULL, 0, 0); } } }
void CListBoxCtrl::DoCtrlReset() { ResetSelection(); }
/************************************************ * Markers selection process with mouse & ctrl keys. ************************************************/ void CHandsImage::ViewInput(int pMouseX,int pMouseY,FBInputType pAction,int pButtonKey,int pModifier) { switch( pAction ) { case kFBButtonPress: { bool ShiftPressed = (pModifier == kFBKeyShift); bool CtrlPressed = (pModifier == kFBKeyCtrl); if (!ShiftPressed && !CtrlPressed) { //-- first of all - clear current selection ResetSelection(); } /* if (pModifier == kFBKeyShift) { //-- left hand for (int i=0; i<FINGERS_COUNT; i++) { if (mHandLeft[i].selected) { mHandLeft[i].x = (float) pMouseX; mHandLeft[i].y = (float) (Region.Height - pMouseY); } } //-- right hand for (int i=0; i<FINGERS_COUNT; i++) { if (mHandRight[i].selected) { mHandRight[i].x = (float) pMouseX; mHandRight[i].y = (float) (Region.Height - pMouseY); } } break; } */ int InvY = Region.Height - pMouseY; float x1, x2; float y1, y2; //---------------------------------- LEFT HAND x1 = mHandLeft[0].x; y1 = mHandLeft[0].y; x2 = x1 + HAND_SIZE; y2 = y1 + HAND_SIZE; if ((pMouseX > x1) && (pMouseX < x2) && (InvY > y1) && (InvY < y2)) { if (!ShiftPressed) { if (!CtrlPressed) mHandLeft[0].SetSel( true ); else mHandLeft[0].SetSel( !mHandLeft[0].selected ); } else if (mHandLeft[0].selected) { for (int i=0; i<FINGERS_COUNT; i++) mHandLeft[i].SetSel( false ); } else { for (int i=0; i<FINGERS_COUNT; i++) mHandLeft[i].SetSel( true ); } } else if (!CtrlPressed && !ShiftPressed) mHandLeft[0].SetSel( false ); for (int i=1; i<FINGERS_COUNT; i++) { x1 = mHandLeft[i].x; y1 = mHandLeft[i].y; x2 = x1 + FINGER_SIZE; y2 = y1 + FINGER_SIZE; if ((pMouseX > x1) && (pMouseX < x2) && (InvY > y1) && (InvY < y2)) { if (!ShiftPressed) { if (!CtrlPressed) mHandLeft[i].SetSel( true ); else mHandLeft[i].SetSel( !mHandLeft[i].selected ); } else { if ( IsLeftBodyPartSelected( i ) ) SelectLeftBodyPart( i, false ); else SelectLeftBodyPart( i, true ); } } else if (!CtrlPressed && !ShiftPressed) mHandLeft[i].SetSel( false ); } //---------------------------------- RIGHT HAND x1 = mHandRight[0].x; y1 = mHandRight[0].y; x2 = x1 + HAND_SIZE; y2 = y1 + HAND_SIZE; if ((pMouseX > x1) && (pMouseX < x2) && (InvY > y1) && (InvY < y2)) { if (!ShiftPressed) { if (!CtrlPressed) mHandRight[0].SetSel( true ); else mHandRight[0].SetSel( !mHandRight[0].selected ); } else if (mHandRight[0].selected) { for (int i=0; i<FINGERS_COUNT; i++) mHandRight[i].SetSel( false ); } else { for (int i=0; i<FINGERS_COUNT; i++) mHandRight[i].SetSel( true ); } } else if (!CtrlPressed && !ShiftPressed) mHandRight[0].SetSel( false ); for (int i=1; i<FINGERS_COUNT; i++) { x1 = mHandRight[i].x; y1 = mHandRight[i].y; x2 = x1 + FINGER_SIZE; y2 = y1 + FINGER_SIZE; if ((pMouseX > x1) && (pMouseX < x2) && (InvY > y1) && (InvY < y2)) { if (!ShiftPressed) { if (!CtrlPressed) mHandRight[i].SetSel( true ); else mHandRight[i].SetSel( !mHandRight[i].selected ); } else { if ( IsRightBodyPartSelected( i ) ) SelectRightBodyPart( i, false ); else SelectRightBodyPart( i, true ); } } else if (!CtrlPressed && !ShiftPressed) mHandRight[i].SetSel( false ); } if (mHandRight[0].mModel) { if (!mHandRight[0].selected) { mReDraw = false; mHandRight[0].mModel->Selected = true; mHandRight[0].mModel->Selected = false; mReDraw = true; } } } } //-- redraw view FBView::Refresh( true ); }
void DisassemblyView::keyPressEvent(QKeyEvent * evt) { bool InvView = false; // Move cursor if (evt->matches(QKeySequence::MoveToNextChar)) { MoveCursor(+1, 0, InvView); ResetSelection(); } if (evt->matches(QKeySequence::MoveToPreviousChar)) { MoveCursor(-1, 0, InvView); ResetSelection(); } if (evt->matches(QKeySequence::MoveToStartOfLine)) { SetCursor(_addrLen, -1); ResetSelection(); } if (evt->matches(QKeySequence::MoveToEndOfLine)) { medusa::LineData Line; if (m_PrintData.GetLine(m_Cursor.m_Address, m_Cursor.m_yAddressOffset, Line)) { auto TextLen = static_cast<medusa::u32>(Line.GetText().length()); if (TextLen != 0) --TextLen; SetCursor(TextLen, -1); } } if (evt->matches(QKeySequence::MoveToNextLine)) { moveCursorPosition(0, +1); ResetSelection(); } if (evt->matches(QKeySequence::MoveToPreviousLine)) { moveCursorPosition(0, -1); ResetSelection(); } if (evt->matches(QKeySequence::MoveToNextPage)) { MoveCursor(0, +m_Height, InvView); ResetSelection(); } if (evt->matches(QKeySequence::MoveToPreviousPage)) { MoveCursor(0, -static_cast<medusa::s32>(m_Height), InvView); ResetSelection(); } if (evt->matches(QKeySequence::MoveToStartOfDocument)) { medusa::Address FirstAddr = m_rDoc.GetFirstAddress(); m_Cursor.m_Address = FirstAddr; m_Cursor.m_yAddressOffset = 0; m_Top = m_Cursor; m_Format(FirstAddr, m_FormatFlags, m_Height); ResetSelection(); } if (evt->matches(QKeySequence::MoveToEndOfDocument)) { medusa::Address LastAddr = m_rDoc.GetLastAddress(); m_Cursor.m_Address = LastAddr; m_Cursor.m_yAddressOffset = 0; m_Top = m_Cursor; m_Format(LastAddr, m_FormatFlags, m_Height); ResetSelection(); } if (evt->matches(QKeySequence::MoveToNextWord)) { medusa::LineData Line; if (m_PrintData.GetLine(m_Cursor.m_Address, m_Cursor.m_yAddressOffset, Line)) { auto const& rText = Line.GetText(); auto Pos = rText.find_first_not_of(" \n", m_Cursor.m_xAddressOffset); Pos = rText.find_first_of(" \n", Pos); if (Pos != std::string::npos) SetCursor(static_cast<medusa::u32>(Pos), -1); else SetCursor(static_cast<medusa::u32>(rText.length()), -1); } } if (evt->matches(QKeySequence::MoveToPreviousWord)) { medusa::LineData Line; if (m_PrintData.GetLine(m_Cursor.m_Address, m_Cursor.m_yAddressOffset, Line)) { auto const& rText = Line.GetText(); auto Pos = rText.find_last_not_of(" \n", m_Cursor.m_xAddressOffset ? m_Cursor.m_xAddressOffset - 1 : 0); Pos = rText.find_last_of(" \n", Pos); if (Pos != std::string::npos) SetCursor(static_cast<medusa::u32>(Pos) + 1, -1); else SetCursor(0, -1); } } // Move selection if (evt->matches(QKeySequence::SelectNextChar)) MoveSelection(+1, 0, InvView); if (evt->matches(QKeySequence::SelectPreviousChar)) MoveSelection(-1, 0, InvView); if (evt->matches(QKeySequence::SelectStartOfLine)) SetSelection(_addrLen, -1); if (evt->matches(QKeySequence::SelectEndOfLine)) { medusa::LineData Line; if (m_PrintData.GetLine(m_Cursor.m_Address, m_Cursor.m_yAddressOffset, Line)) { auto TextLen = static_cast<medusa::u32>(Line.GetText().length()); if (TextLen != 0) --TextLen; SetSelection(TextLen, -1); } } if (evt->matches(QKeySequence::SelectNextLine)) MoveSelection(0, +1, InvView); if (evt->matches(QKeySequence::SelectPreviousLine)) MoveSelection(0, -1, InvView); if (evt->matches(QKeySequence::SelectNextPage)) MoveSelection(0, +m_Height, InvView); if (evt->matches(QKeySequence::SelectPreviousPage)) MoveSelection(0, -static_cast<medusa::s32>(m_Height), InvView); if (evt->matches(QKeySequence::SelectStartOfDocument)) { m_Cursor.m_Address = m_rDoc.GetFirstAddress(); m_Cursor.m_xAddressOffset = 0; m_Cursor.m_yAddressOffset = 0; m_Format(m_Cursor.m_Address, m_FormatFlags, m_Height); m_SelectionEnd = m_Top = m_Cursor; } if (evt->matches(QKeySequence::SelectEndOfDocument)) { m_Cursor.m_Address = m_rDoc.GetLastAddress(); m_Cursor.m_xAddressOffset = 0; m_Cursor.m_yAddressOffset = 0; m_Format(m_Cursor.m_Address, m_FormatFlags, m_Height); m_SelectionEnd = m_Top = m_Cursor; } if (evt->matches(QKeySequence::SelectNextWord)) { medusa::LineData Line; if (m_PrintData.GetLine(m_Cursor.m_Address, m_Cursor.m_yAddressOffset, Line)) { auto const& rText = Line.GetText(); auto Pos = rText.find_first_not_of(" \n", m_Cursor.m_xAddressOffset); Pos = rText.find_first_of(" \n", Pos); if (Pos != std::string::npos) SetSelection(static_cast<medusa::u32>(Pos), -1); else SetSelection(static_cast<medusa::u32>(rText.length()), -1); } } if (evt->matches(QKeySequence::SelectPreviousWord)) { medusa::LineData Line; if (m_PrintData.GetLine(m_Cursor.m_Address, m_Cursor.m_yAddressOffset, Line)) { auto const& rText = Line.GetText(); auto Pos = rText.find_last_not_of(" \n", m_Cursor.m_xAddressOffset ? m_Cursor.m_xAddressOffset - 1 : 0); Pos = rText.find_last_of(" \n", Pos); if (Pos != std::string::npos) SetSelection(static_cast<medusa::u32>(Pos) + 1, -1); else SetSelection(0, -1); } } if (evt->matches(QKeySequence::SelectAll)) { medusa::Address FirstAddr = m_rDoc.GetFirstAddress(); medusa::Address LastAddr = m_rDoc.GetLastAddress(); m_SelectionBegin.m_Address = FirstAddr; m_SelectionBegin.m_xAddressOffset = 0; m_SelectionBegin.m_yAddressOffset = 0; m_SelectionEnd.m_Address = LastAddr; m_SelectionEnd.m_xAddressOffset = 1; // TODO m_SelectionEnd.m_yAddressOffset = 1; // TODO } // Copy if (evt->matches(QKeySequence::Copy)) { auto Start = m_SelectionBegin; auto Last = m_SelectionEnd; if (Start.m_Address > Last.m_Address) std::swap(Start, Last); medusa::PrintData Print; medusa::FormatDisassembly FmtDisasm(m_rCore, Print); FmtDisasm(std::make_pair(Start.m_Address, Last.m_Address), m_FormatFlags); // TODO trim it! //auto& rLines = Print.GetTextLines(); //rLines.erase(); //rLines.erase(); QApplication::clipboard()->setText(QString::fromStdString(Print.GetTexts())); } emit viewUpdated(); QAbstractScrollArea::keyPressEvent(evt); }