void Menu::handleKeyPress(int key) { if (key == Qt::Key_Enter || key == Qt::Key_Return) { itemPressed(TriggeredSource::Keyboard); return; } if (key == (rtl() ? Qt::Key_Left : Qt::Key_Right)) { if (_selected >= 0 && _actionsData[_selected].hasSubmenu) { itemPressed(TriggeredSource::Keyboard); return; } else if (_selected < 0 && !_actions.isEmpty()) { _mouseSelection = false; setSelected(0); } } if ((key != Qt::Key_Up && key != Qt::Key_Down) || _actions.size() < 1) return; auto delta = (key == Qt::Key_Down ? 1 : -1), start = _selected; if (start < 0 || start >= _actions.size()) { start = (delta > 0) ? (_actions.size() - 1) : 0; } auto newSelected = start; do { newSelected += delta; if (newSelected < 0) { newSelected += _actions.size(); } else if (newSelected >= _actions.size()) { newSelected -= _actions.size(); } } while (newSelected != start && (!_actions[newSelected]->isEnabled() || _actions[newSelected]->isSeparator())); if (_actions[newSelected]->isEnabled() && !_actions[newSelected]->isSeparator()) { _mouseSelection = false; setSelected(newSelected); } }
void Smb4KSharesView::mousePressEvent(QMouseEvent *e) { // Hide the current tool tip so that it is not in the way. if (m_tooltipItem) { emit aboutToHideToolTip(m_tooltipItem); m_tooltipItem->tooltip()->hide(); m_tooltipItem = 0; } else { // Do nothing } // Get the item that is under the mouse. If there is no // item, unselect the current item. QListWidgetItem *item = itemAt(e->pos()); if (!item && !selectedItems().isEmpty()) { clearSelection(); setCurrentItem(0); emit itemPressed(currentItem()); } else { // Do nothing } QListWidget::mousePressEvent(e); }
void PopupMenu::keyPressEvent(QKeyEvent *e) { if (_childMenuIndex >= 0) { return _menus.at(_childMenuIndex)->keyPressEvent(e); } if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) { itemPressed(PressSourceKeyboard); return; } else if (e->key() == Qt::Key_Escape) { hideMenu(_parent ? true : false); return; } if (e->key() == (rtl() ? Qt::Key_Left : Qt::Key_Right)) { if (_selected >= 0 && _menus.at(_selected)) { itemPressed(PressSourceKeyboard); return; } else if (_selected < 0 && _parent && !_actions.isEmpty()) { _mouseSelection = false; setSelected(0); } } else if (e->key() == (rtl() ? Qt::Key_Right : Qt::Key_Left)) { if (_parent) { hideMenu(true); } } if ((e->key() != Qt::Key_Up && e->key() != Qt::Key_Down) || _actions.size() < 1) return; int32 delta = (e->key() == Qt::Key_Down ? 1 : -1), start = _selected; if (start < 0 || start >= _actions.size()) { start = (delta > 0) ? (_actions.size() - 1) : 0; } int32 newSelected = start; do { newSelected += delta; if (newSelected < 0) { newSelected += _actions.size(); } else if (newSelected >= _actions.size()) { newSelected -= _actions.size(); } } while (newSelected != start && (!_actions.at(newSelected)->isEnabled() || _actions.at(newSelected)->isSeparator())); if (_actions.at(newSelected)->isEnabled() && !_actions.at(newSelected)->isSeparator()) { _mouseSelection = false; setSelected(newSelected); } }
void Menu::handleMousePress(QPoint globalPosition) { handleMouseMove(globalPosition); if (rect().contains(mapFromGlobal(globalPosition))) { itemPressed(TriggeredSource::Mouse); } else if (_mousePressDelegate) { _mousePressDelegate(globalPosition); } }
void PrimitiveTreeView::initialize() { d->delegate = new PrimitiveItemDelegate(this, this); setItemDelegate(d->delegate); setRootIsDecorated(false); header()->hide(); setUniformRowHeights(true); connect(this, SIGNAL(pressed(QModelIndex)), this, SLOT(itemPressed(QModelIndex))); }
void PopupMenu::mousePressEvent(QMouseEvent *e) { mouseMoveEvent(e); if (_inner.contains(mapFromGlobal(e->globalPos()))) { itemPressed(PressSourceMouse); return; } if (_parent) { _parent->mousePressEvent(e); } else { hideMenu(); } }
void LauncherView::init() { mainLayout = new QVBoxLayout(this); mainLayout->setMargin(0); mainLayout->setSpacing(2); icons = new LauncherViewListView(this); icons->setItemDelegate(new LauncherViewDelegate(icons)); mainLayout->addWidget(icons); setFocusProxy(icons); #ifdef ENABLE_SMOOTHLIST icons->setVisible(false); smoothicons = new QSmoothList(this); smoothicons->setItemDelegate(new LauncherViewDelegate(smoothicons)); mainLayout->addWidget(smoothicons); setFocusProxy(smoothicons); QSoftMenuBar::setLabel(smoothicons, Qt::Key_Select, QSoftMenuBar::Select); #endif QtopiaApplication::setStylusOperation( icons->viewport(), QtopiaApplication::RightOnHold ); icons->setFrameStyle( QFrame::NoFrame ); icons->setResizeMode( QListView::Fixed ); icons->setSelectionMode( QAbstractItemView::SingleSelection ); icons->setSelectionBehavior( QAbstractItemView::SelectItems ); icons->setUniformItemSizes( true ); // icons->setWordWrap( true ); contentSet = new QContentSet( QContentSet::Asynchronous, this); contentSet->setSortOrder(QStringList() << "name"); model = new QContentSetModel(contentSet, this); // setViewMode(QListView::IconMode); setViewMode(QListView::ListMode); connect( icons, SIGNAL(clicked(QModelIndex)), SLOT(itemClicked(QModelIndex))); connect( icons, SIGNAL(activated(QModelIndex)), SLOT(returnPressed(QModelIndex)) ); connect( icons, SIGNAL(pressed(QModelIndex)), SLOT(itemPressed(QModelIndex))); icons->setModel(model); #ifdef ENABLE_SMOOTHLIST connect( smoothicons, SIGNAL(activated(QModelIndex)), SLOT(returnPressed(QModelIndex)) ); smoothicons->setModel(model); #endif }
void TextTool::press(const KTInputDeviceInformation *input, KTBrushManager *brushManager, KTGraphicsScene *scene) { Q_UNUSED(brushManager); QList<QGraphicsItem *> items = scene->items(input->pos()); if (items.count() > 0) { QGraphicsItem *itemPress = items[0]; if (itemPressed(itemPress)) return; } m_item = new KTTextItem; m_item->setPos(input->pos()); }
void EraserTool::press(const TupInputDeviceInformation *input, TupBrushManager *brushManager, TupGraphicsScene *scene) { if (input->buttons() == Qt::LeftButton) { QPointF pos = input->pos(); if (name() == tr("Eraser")) { QList<QGraphicsItem *> items = scene->items(input->pos()); if (items.count() > 0) { QGraphicsItem *itemPress = items[0]; itemPressed(itemPress, brushManager, pos); } } } }
void EventCanvas::selectAtTick(unsigned int tick)/*{{{*/ { CItemList list = _items; if(multiPartSelectionAction && !multiPartSelectionAction->isChecked()) list = getItemlistForCurrentPart(); //CItemList list = getItemlistForCurrentPart(); //Select note nearest tick, if none selected and there are any if (!list.empty() && selectionSize() == 0) { iCItem i = list.begin(); CItem* nearest = i->second; while (i != list.end()) { CItem* cur = i->second; unsigned int curtk = abs(cur->x() + cur->part()->tick() - tick); unsigned int neartk = abs(nearest->x() + nearest->part()->tick() - tick); if (curtk < neartk) { nearest = cur; } i++; } if (!nearest->isSelected()) { selectItem(nearest, true); if(editor->isGlobalEdit()) populateMultiSelect(nearest); songChanged(SC_SELECTION); } itemPressed(nearest); m_tempPlayItems.append(nearest); QTimer::singleShot(NOTE_PLAY_TIME, this, SLOT(playReleaseForItem())); } }/*}}}*/
HistoryView::HistoryView(QWidget* parent) : QTreeView(parent) , m_history(mApp->history()) , m_filterModel(new HistoryFilterModel(m_history->model())) { setModel(m_filterModel); setAllColumnsShowFocus(true); setUniformRowHeights(true); setSelectionMode(QAbstractItemView::ExtendedSelection); m_header = new HeaderView(this); setHeader(m_header); m_header->setDefaultSectionSizes(QList<double>() << 0.4 << 0.35 << 0.10 << 0.08); m_header->setSectionHidden(4, true); connect(this, SIGNAL(activated(QModelIndex)), this, SLOT(itemActivated(QModelIndex))); connect(this, SIGNAL(pressed(QModelIndex)), this, SLOT(itemPressed(QModelIndex))); connect(m_filterModel, SIGNAL(expandAllItems()), this, SLOT(expandAll())); connect(m_filterModel, SIGNAL(collapseAllItems()), this, SLOT(collapseAll())); }
int QTreeWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QTreeView::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: itemPressed((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 1: itemClicked((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 2: itemDoubleClicked((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 3: itemActivated((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 4: itemEntered((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 5: itemChanged((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 6: itemExpanded((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1]))); break; case 7: itemCollapsed((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1]))); break; case 8: currentItemChanged((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< QTreeWidgetItem*(*)>(_a[2]))); break; case 9: itemSelectionChanged(); break; case 10: scrollToItem((*reinterpret_cast< const QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< QAbstractItemView::ScrollHint(*)>(_a[2]))); break; case 11: scrollToItem((*reinterpret_cast< const QTreeWidgetItem*(*)>(_a[1]))); break; case 12: expandItem((*reinterpret_cast< const QTreeWidgetItem*(*)>(_a[1]))); break; case 13: collapseItem((*reinterpret_cast< const QTreeWidgetItem*(*)>(_a[1]))); break; case 14: clear(); break; case 15: d_func()->_q_emitItemPressed((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 16: d_func()->_q_emitItemClicked((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 17: d_func()->_q_emitItemDoubleClicked((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 18: d_func()->_q_emitItemActivated((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 19: d_func()->_q_emitItemEntered((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 20: d_func()->_q_emitItemChanged((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 21: d_func()->_q_emitItemExpanded((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 22: d_func()->_q_emitItemCollapsed((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 23: d_func()->_q_emitCurrentItemChanged((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< const QModelIndex(*)>(_a[2]))); break; case 24: d_func()->_q_sort(); break; case 25: d_func()->_q_dataChanged((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< const QModelIndex(*)>(_a[2]))); break; case 26: d_func()->_q_itemsSorted(); break; case 27: d_func()->_q_selectionChanged((*reinterpret_cast< const QItemSelection(*)>(_a[1])),(*reinterpret_cast< const QItemSelection(*)>(_a[2]))); break; } _id -= 28; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< int*>(_v) = columnCount(); break; case 1: *reinterpret_cast< int*>(_v) = topLevelItemCount(); break; } _id -= 2; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setColumnCount(*reinterpret_cast< int*>(_v)); break; } _id -= 2; } else if (_c == QMetaObject::ResetProperty) { _id -= 2; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 2; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 2; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 2; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 2; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 2; } #endif // QT_NO_PROPERTIES return _id; }
int QListWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QListView::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: itemPressed((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break; case 1: itemClicked((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break; case 2: itemDoubleClicked((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break; case 3: itemActivated((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break; case 4: itemEntered((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break; case 5: itemChanged((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break; case 6: currentItemChanged((*reinterpret_cast< QListWidgetItem*(*)>(_a[1])),(*reinterpret_cast< QListWidgetItem*(*)>(_a[2]))); break; case 7: currentTextChanged((*reinterpret_cast< const QString(*)>(_a[1]))); break; case 8: currentRowChanged((*reinterpret_cast< int(*)>(_a[1]))); break; case 9: itemSelectionChanged(); break; case 10: scrollToItem((*reinterpret_cast< const QListWidgetItem*(*)>(_a[1])),(*reinterpret_cast< QAbstractItemView::ScrollHint(*)>(_a[2]))); break; case 11: scrollToItem((*reinterpret_cast< const QListWidgetItem*(*)>(_a[1]))); break; case 12: clear(); break; case 13: d_func()->_q_emitItemPressed((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 14: d_func()->_q_emitItemClicked((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 15: d_func()->_q_emitItemDoubleClicked((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 16: d_func()->_q_emitItemActivated((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 17: d_func()->_q_emitItemEntered((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 18: d_func()->_q_emitItemChanged((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 19: d_func()->_q_emitCurrentItemChanged((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< const QModelIndex(*)>(_a[2]))); break; case 20: d_func()->_q_sort(); break; case 21: d_func()->_q_dataChanged((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< const QModelIndex(*)>(_a[2]))); break; default: ; } _id -= 22; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< int*>(_v) = count(); break; case 1: *reinterpret_cast< int*>(_v) = currentRow(); break; case 2: *reinterpret_cast< bool*>(_v) = isSortingEnabled(); break; } _id -= 3; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 1: setCurrentRow(*reinterpret_cast< int*>(_v)); break; case 2: setSortingEnabled(*reinterpret_cast< bool*>(_v)); break; } _id -= 3; } else if (_c == QMetaObject::ResetProperty) { _id -= 3; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 3; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 3; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 3; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 3; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 3; } #endif // QT_NO_PROPERTIES return _id; }
void MailListView::itemMenuRequested() { EmailListItem *item = static_cast<EmailListItem *>( currentItem() ); if ( item ) emit itemPressed( item ); }
/*! \internal */ void QThemedView::itemMousePressed(QThemeItem *item) { emit itemClicked(item); emit itemPressed(item); }
void EventCanvas::actionCommand(int action)/*{{{*/ { switch(action) { case LOCATORS_TO_SELECTION: { int tick_max = 0; int tick_min = INT_MAX; bool found = false; for (iCItem i = _items.begin(); i != _items.end(); i++) { if (!i->second->isSelected()) continue; int tick = i->second->x(); int len = i->second->event().lenTick(); found = true; if (tick + len > tick_max) tick_max = tick + len; if (tick < tick_min) tick_min = tick; } if (found) { Pos p1(tick_min, true); Pos p2(tick_max, true); song->setPos(1, p1); song->setPos(2, p2); } } break; case SEL_RIGHT ... SEL_RIGHT_ADD: { if (action == SEL_RIGHT && allItemsAreSelected()) { deselectAll(); selectAtTick(song->cpos()); return; } iCItem i, iRightmost; CItem* rightmost = NULL; // get a list of items that belong to the current part // since multiple parts have populated the _items list // we need to filter on the actual current Part! CItemList list = _items; if(multiPartSelectionAction && !multiPartSelectionAction->isChecked()) list = getItemlistForCurrentPart(); //Get the rightmost selected note (if any) i = list.begin(); while (i != list.end()) { if (i->second->isSelected()) { iRightmost = i; rightmost = i->second; } ++i; } if (rightmost) { iCItem temp = iRightmost; temp++; //If so, deselect current note and select the one to the right if (temp != list.end()) { if (action != SEL_RIGHT_ADD) deselectAll(); iRightmost++; iRightmost->second->setSelected(true); itemPressed(iRightmost->second); m_tempPlayItems.append(iRightmost->second); QTimer::singleShot(NOTE_PLAY_TIME, this, SLOT(playReleaseForItem())); if(editor->isGlobalEdit()) populateMultiSelect(iRightmost->second); updateSelection(); } } else // there was no item selected at all? Then select nearest to tick if there is any { selectAtTick(song->cpos()); updateSelection(); } } break; case SEL_LEFT ... SEL_LEFT_ADD: { if (action == SEL_LEFT && allItemsAreSelected()) { deselectAll(); selectAtTick(song->cpos()); return; } iCItem i, iLeftmost; CItem* leftmost = NULL; // get a list of items that belong to the current part // since multiple parts have populated the _items list // we need to filter on the actual current Part! CItemList list = _items; if(multiPartSelectionAction && !multiPartSelectionAction->isChecked()) list = getItemlistForCurrentPart(); if (list.size() > 0) { i = list.end(); while (i != list.begin()) { --i; if (i->second->isSelected()) { iLeftmost = i; leftmost = i->second; } } if (leftmost) { if (iLeftmost != list.begin()) { //Add item if (action != SEL_LEFT_ADD) deselectAll(); iLeftmost--; iLeftmost->second->setSelected(true); itemPressed(iLeftmost->second); m_tempPlayItems.append(iLeftmost->second); QTimer::singleShot(NOTE_PLAY_TIME, this, SLOT(playReleaseForItem())); if(editor->isGlobalEdit()) populateMultiSelect(iLeftmost->second); updateSelection(); } else { leftmost->setSelected(true); itemPressed(leftmost); m_tempPlayItems.append(leftmost); QTimer::singleShot(NOTE_PLAY_TIME, this, SLOT(playReleaseForItem())); if(editor->isGlobalEdit()) populateMultiSelect(leftmost); updateSelection(); } } else // there was no item selected at all? Then select nearest to tick if there is any { selectAtTick(song->cpos()); updateSelection(); } } } break; case INC_PITCH_OCTAVE: { modifySelected(NoteInfo::VAL_PITCH, 12); } break; case DEC_PITCH_OCTAVE: { modifySelected(NoteInfo::VAL_PITCH, -12); } break; case INC_PITCH: { modifySelected(NoteInfo::VAL_PITCH, 1); } break; case DEC_PITCH: { modifySelected(NoteInfo::VAL_PITCH, -1); } break; case INC_POS: { // TODO: Check boundaries modifySelected(NoteInfo::VAL_TIME, editor->raster()); } break; case DEC_POS: { // TODO: Check boundaries modifySelected(NoteInfo::VAL_TIME, 0 - editor->raster()); } break; case INCREASE_LEN: { // TODO: Check boundaries modifySelected(NoteInfo::VAL_LEN, editor->raster()); } break; case DECREASE_LEN: { // TODO: Check boundaries modifySelected(NoteInfo::VAL_LEN, 0 - editor->raster()); } break; case GOTO_SEL_NOTE: { CItem* leftmost = getLeftMostSelected(); if (leftmost) { unsigned newtick = leftmost->event().tick() + leftmost->part()->tick(); Pos p1(newtick, true); song->setPos(0, p1, true, true, false); } } break; case MIDI_PANIC: { song->panic(); } break; } }/*}}}*/
void EventCanvas::viewMousePressEvent(QMouseEvent* event)/*{{{*/ { ///keyState = event->state(); _keyState = ((QInputEvent*) event)->modifiers(); _button = event->button(); //printf("viewMousePressEvent buttons:%x mods:%x button:%x\n", (int)event->buttons(), (int)keyState, event->button()); // special events if right button is clicked while operations // like moving or drawing lasso is performed. if (event->buttons() & Qt::RightButton & ~(event->button())) { //printf("viewMousePressEvent special buttons:%x mods:%x button:%x\n", (int)event->buttons(), (int)keyState, event->button()); switch (_drag) { case DRAG_LASSO: _drag = DRAG_OFF; redraw(); return; case DRAG_MOVE: _drag = DRAG_OFF; endMoveItems(_start, MOVE_MOVE, 0); return; default: break; } } // ignore event if (another) button is already active: if (event->buttons() & (Qt::LeftButton | Qt::RightButton | Qt::MidButton) & ~(event->button())) { //printf("viewMousePressEvent ignoring buttons:%x mods:%x button:%x\n", (int)event->buttons(), (int)keyState, event->button()); return; } bool shift = _keyState & Qt::ShiftModifier; bool alt = _keyState & Qt::AltModifier; bool ctrl = _keyState & Qt::ControlModifier; _start = event->pos(); //--------------------------------------------------- // set curItem to item mouse is pointing // (if any) //--------------------------------------------------- CItemList list = _items; if(multiPartSelectionAction && !multiPartSelectionAction->isChecked()) list = getItemlistForCurrentPart(); if (virt()) { _curItem = list.find(_start);//_items.find(_start); } else { _curItem = 0; //selectAtTick(_start.x()); iCItem ius; bool usfound = false; for (iCItem i = list.begin(); i != list.end(); ++i) { MidiTrack* mtrack = (MidiTrack*)i->second->part()->track(); int sy = _start.y(); int p = y2pitch(sy); if(editor->isGlobalEdit()) p += mtrack->getTransposition(); int p2 = pitch2y(p); QPoint lpos(_start.x(), p2); QRect box = i->second->bbox(); int x = rmapxDev(box.x()); int y = rmapyDev(box.y()); int w = rmapxDev(box.width()); int h = rmapyDev(box.height()); QRect r(x, y, w, h); r.translate(i->second->pos().x(), i->second->pos().y()); if(r.contains(lpos)) { if (i->second->isSelected()) { _curItem = i->second; break; } else if (!usfound) { ius = i; usfound = true; } } } if (!_curItem && usfound) _curItem = ius->second; } if(editor->isGlobalEdit() && _curItem) { populateMultiSelect(_curItem); } if (_curItem && (event->button() == Qt::MidButton)) { if (!_curItem->isSelected()) { selectItem(_curItem, true); updateSelection(); redraw(); } startDrag(_curItem, shift); } else if (event->button() == Qt::RightButton) { if (_curItem) { if (shift) { _drag = DRAG_RESIZE; setCursor(); int dx = _start.x() - _curItem->x(); _curItem->setWidth(dx); _start.setX(_curItem->x()); deselectAll(); selectItem(_curItem, true); updateSelection(); redraw(); } else { _itemPopupMenu = genItemPopup(_curItem); if (_itemPopupMenu) { QAction *act = _itemPopupMenu->exec(QCursor::pos()); if (act) itemPopup(_curItem, act->data().toInt(), _start); delete _itemPopupMenu; } } } else { _canvasPopupMenu = genCanvasPopup(true); if (_canvasPopupMenu) { QAction *act = _canvasPopupMenu->exec(QCursor::pos(), 0); if (act) { int actnum = act->data().toInt(); canvasPopup(actnum); if(actnum >= 20) //Nome of the tools have a higher number than 9 { editor->updateCanvas(); los->arranger->updateCanvas(); } } delete _canvasPopupMenu; } } } else if (event->button() == Qt::LeftButton) { switch (_tool) { case PointerTool: if (_curItem) { /*if (_curItem->part() != _curPart) { _curPart = _curItem->part(); _curPartId = _curPart->sn(); curPartChanged(); }*/ itemPressed(_curItem); if (shift) _drag = DRAG_COPY_START; else if (alt) { _drag = DRAG_CLONE_START; } else if (ctrl) { //Select all on the same pitch (e.g. same y-value) deselectAll(); //printf("Yes, ctrl and press\n"); for (iCItem i = _items.begin(); i != _items.end(); ++i) { if (i->second->y() == _curItem->y()) selectItem(i->second, true); } updateSelection(); redraw(); } else _drag = DRAG_MOVE_START; } else _drag = DRAG_LASSO_START; setCursor(); break; case RubberTool: deleteItem(_start); _drag = DRAG_DELETE; setCursor(); break; case PencilTool: if (_curItem) { _drag = DRAG_RESIZE; setCursor(); int dx = _start.x() - _curItem->x(); _curItem->setWidth(dx); _start.setX(_curItem->x()); } else { _drag = DRAG_NEW; setCursor(); _curItem = newItem(_start, event->modifiers()); if (_curItem) _items.add(_curItem); else { _drag = DRAG_OFF; setCursor(); } } deselectAll(); if (_curItem) { selectItem(_curItem, true); // Play the note itemPressed(_curItem); } updateSelection(); redraw(); break; default: break; } } mousePress(event); }/*}}}*/