/** * Handles what happens when a left-button double click occurs. * * If there are no stencils selected, this function returns. Otherwise * it launches the text tool on the selected stencils and switches back * to this tool when it's done. */ void SelectTool::leftDoubleClick(const QPoint& pos) { if( view()->activePage()->selectedStencils()->count() <= 0 ) return; KoPoint pagePoint = view()->canvasWidget()->mapFromScreen(pos); // Figure out how big 4 pixels is in terms of points double threshold = view()->zoomHandler()->unzoomItY(4); int colType; KivioPage *page = view()->activePage(); KivioStencil* stencil = page->checkForStencil( &pagePoint, &colType, threshold, false); if(stencil) { // Locate the text tool. If not found, bail with an error Kivio::Plugin *p = view()->pluginManager()->findPlugin("Text Mouse Tool"); if( !p ) { kdDebug(43000) << "SelectTool::leftDoubleClick() - unable to locate Text Tool" << endl; return; } static_cast<Kivio::MouseTool*>(p)->applyToolAction(stencil, pagePoint); } }
bool SelectTool::startCustomDragging(const QPoint &pos, bool selectedOnly ) { KivioCanvas* canvas = view()->canvasWidget(); KivioPage *pPage = canvas->activePage(); KivioStencil *pStencil; int colType; KoPoint pagePoint = canvas->mapFromScreen( pos ); // Figure out how big 4 pixels is in terms of points double threshold = view()->zoomHandler()->unzoomItY(4); pStencil = pPage->checkForStencil( &pagePoint, &colType, threshold, selectedOnly ); if( !pStencil || colType < kctCustom ) { return false; } if(pStencil->isSelected()) { // If we are clicking an already selected stencil, and the control // key down, then unselect this stencil if(m_controlKey) { pPage->unselectStencil(pStencil); } } else { // Clicking a new stencil, and the control key is not down if(!m_controlKey) { pPage->unselectAllStencils(); } pPage->selectStencil( pStencil ); } m_pCustomDraggingStencil = pStencil; // Set the mode m_mode = stmCustomDragging; m_customDragID = colType; m_customDragOrigPoint = pStencil->customIDPoint(m_customDragID); view()->canvasWidget()->setShowConnectorTargets(true); view()->canvasWidget()->repaint(); // Create a new painter object canvas->beginUnclippedSpawnerPainter(); m_firstTime = true; return true; }
/** * Tests if we can start dragging a stencil. */ bool SelectTool::startDragging(const QPoint &pos, bool onlySelected) { KivioCanvas* canvas = view()->canvasWidget(); KivioPage *pPage = canvas->activePage(); KivioStencil *pStencil; int colType; // Figure out how big 4 pixels is in terms of points double threshold = view()->zoomHandler()->unzoomItY(4); KoPoint pagePoint = canvas->mapFromScreen( pos ); pStencil = pPage->checkForStencil( &pagePoint, &colType, threshold, onlySelected ); if( !pStencil ) return false; canvas->setEnabled(false); if( pStencil->isSelected() ) { // If we are clicking an already selected stencil, and the control // key down, then unselect this stencil if( m_controlKey==true ) { pPage->unselectStencil( pStencil ); } // Otherwise, it means we are just moving } else { // Clicking a new stencil, and the control key is not down if( !m_controlKey ) pPage->unselectAllStencils(); pPage->selectStencil( pStencil ); // Update the auto guidelines view()->canvasWidget()->updateAutoGuideLines(); } // Create a new painter object canvas->beginUnclippedSpawnerPainter(); // Build the list of old geometry KivioSelectDragData *pData; m_lstOldGeometry.clear(); pStencil = canvas->activePage()->selectedStencils()->first(); while( pStencil ) { pData = new KivioSelectDragData; pData->rect = pStencil->rect(); m_lstOldGeometry.append(pData); pStencil = canvas->activePage()->selectedStencils()->next(); } m_selectedRect = view()->activePage()->getRectForAllSelectedStencils(); changeMouseCursor(pos); // Set the mode m_mode = stmDragging; m_firstTime = true; canvas->setEnabled(true); return true; }