MCPcopy Create free account
hub / github.com/KangLin/RabbitRemoteControl / mousePressEvent

Method mousePressEvent

App/Client/Favorite/FavoriteView.cpp:626–668  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

624}
625
626void CFavoriteView::mousePressEvent(QMouseEvent *event)
627{
628 qDebug(log) << "mousePressEvent";
629 if (m_pTreeView && m_pTreeView->selectionModel()
630 && event->button() == Qt::LeftButton) {
631
632 // 获取选中的索引
633 QModelIndexList indexes = m_pTreeView->selectionModel()->selectedIndexes();
634 if (!indexes.isEmpty()) {
635
636#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
637 auto curIndex = m_pTreeView->indexAt(event->position().toPoint());
638#else
639 auto curIndex = m_pTreeView->indexAt(event->pos());
640#endif
641 if(indexes.contains(curIndex)) {
642 QDrag *drag = new QDrag(this);
643 do {
644 if(!drag) break;
645 m_DragStartPosition = event->pos();
646 CFavoriteMimeData *pData = new CFavoriteMimeData();
647 pData->m_Items = indexes;
648 drag->setMimeData(pData);
649 Qt::DropAction dropAction = Qt::MoveAction;
650 /*
651 if(event->modifiers() & Qt::ControlModifier) {
652 dropAction = Qt::CopyAction;
653 // 设置拖拽时的光标
654 // QIcon icon = QIcon::fromTheme("edit-copy");
655 // QSize size(16, 16);
656 // if(!icon.availableSizes().isEmpty())
657 // size = icon.availableSizes().at(0);
658 // drag->setDragCursor(icon.pixmap(size), Qt::MoveAction);
659 }//*/
660 drag->exec(dropAction);
661 } while(0);
662 if(drag)
663 delete drag;
664 }
665 }
666 }
667 QWidget::mousePressEvent(event);
668}
669
670void CFavoriteView::mouseMoveEvent(QMouseEvent *event)
671{

Callers

nothing calls this directly

Calls 2

isEmptyMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected