void Tweener::release(const TupInputDeviceInformation *input, TupBrushManager *brushManager, TupGraphicsScene *scene) { #ifdef K_DEBUG #ifdef Q_OS_WIN qDebug() << "[Tweener::release()]"; #else T_FUNCINFO; #endif #endif Q_UNUSED(input); Q_UNUSED(brushManager); if (scene->currentFrameIndex() == k->initFrame) { if (k->editMode == TupToolPlugin::Selection) { if (scene->selectedItems().size() > 0) { k->objects = scene->selectedItems(); k->configurator->notifySelection(true); QGraphicsItem *item = k->objects.at(0); QRectF rect = item->sceneBoundingRect(); k->origin = rect.center(); } } } }
void MainRSTView::mouseReleaseEvent(QMouseEvent *event) { isLeft_ = 0; if (event->button() == Qt::LeftButton) { if (!canMove_) return; trySetPort(-(event->localPos() - startMovePos_) + oldCenter_); canMove_ = 0; } else if (event->button() == Qt::RightButton) { if (!currentMainSize_.contains(mapToScene(event->localPos().toPoint()))) return; canDrag_ = 0; if (event->localPos() == rightClickPos_) // single click event { QGraphicsItem *it = clickOnPoint(event->localPos()); if (it) { QRectF bd = it->sceneBoundingRect(); father_->rst_->deletePoint(bd.center().x(), bd.center().y()); } else { QPointF realPos = mapToScene(rightClickPos_.toPoint()); father_->rst_->addPoint(realPos.x(), realPos.y()); } } } }
QGraphicsItem* MainRSTView::clickOnPoint(QPointF p) { QPointF realPos = mapToScene(p.toPoint()); QGraphicsItem *it; if ((it = itemAt(p.toPoint())) == bkgItem_) return 0; QRectF bd = it->sceneBoundingRect(); double e = bd.width() / bd.height(); if (std::abs(e - 1) > 0.1) return 0; return it; }
bool StarView::event (QEvent* e) { if (e->type() != QEvent::ToolTip) return QWidget::event(e); QPoint p (static_cast<QHelpEvent*>(e)->pos()); HostItem *item = 0; QGraphicsItem* graphicsItem = m_canvasView->itemAt(p); if (graphicsItem) item = dynamic_cast<HostItem*>(graphicsItem->parentItem()); if (item) { HostInfo *hostInfo = item->hostInfo(); const QPoint gp(static_cast<QHelpEvent*>(e)->globalPos()); const QRect itemRect = m_canvasView->mapFromScene(graphicsItem->sceneBoundingRect()).boundingRect(); if (hostInfo) { QToolTip::showText(gp+QPoint(10,10), "<p><table><tr><td>" "<img align=\"right\" source=\":/computer.png\"><br><b>" + item->hostName() + "</b><br>" + "<table>" + "<tr><td>" + tr("IP:") + "</td><td>" + hostInfo->ip() + "</td></tr>" + "<tr><td>" + tr("Platform:") + "</td><td>" + hostInfo->platform() + "</td></tr>" + "<tr><td>" + tr("Id:") + "</td><td>" + QString::number(hostInfo->id()) + "</td></tr>" + "<tr><td>" + tr("Speed:") + "</td><td>" + QString::number(hostInfo->serverSpeed()) + "</td></tr>" + "</table>" "</td></tr></table></p>", this, itemRect); } else { QToolTip::showText(gp+QPoint(10,10), "<p><table><tr><td>" "<img align=\"right\" source=\":/computer.png\"><br><b>" + tr("Scheduler") + "</b><br/>" "<table>" + "<tr><td>" + tr("Host: %1").arg(hostInfoManager()->schedulerName()) + "</td></tr>" + "<tr><td>" + tr("Network name: %1").arg(hostInfoManager()->networkName()) + "</td></tr>" + "</table>" "</td></tr></table></p>", this, itemRect); } } else { QToolTip::hideText(); } return QWidget::event(e); }
void MainRSTView::mousePressEvent(QMouseEvent *event) { //qDebug("press %lf %lf", event->localPos().x(), event->localPos().y()); if (event->button() == Qt::LeftButton) { startMovePos_ = event->localPos(); oldCenter_ = QPointF(father_->fx_, father_->fy_); canMove_ = 1; isLeft_ = 1; } else if (event->button() == Qt::RightButton) { if (!currentMainSize_.contains(mapToScene(event->localPos().toPoint()))) return; isLeft_ = -1; rightClickPos_ = event->localPos(); QGraphicsItem *it = clickOnPoint(rightClickPos_); if (it) { canDrag_ = 1; QRectF bd = it->sceneBoundingRect(); targetPoint_ = bd.center(); } } }
//确定按钮的事件 void QMultiCopy::on_OK_clicked() { // QPLC_Struct *PLC_P=NULL; QList<QGraphicsItem *> selList=pwnd->pSceneSheet[pwnd->nActiveSheetIndex]->selectedItems(); if(selList.size()!=1)//选择多个或者没有 { accept(); return; } else{ DrawItemToScene CopyFun; int nItemWidth=0; int nItemHeight=0; if(ui->Overlap->isChecked()) { nItemWidth=0; nItemHeight=0; } else { nItemWidth=selList.at(0)->boundingRect().width(); nItemHeight=selList.at(0)->boundingRect().height(); } qreal bottom;//基准控件的底边界值 qreal right;//基准控件的右边界值 int nColumn=ui->Column->value();//行数 int nColumn_Interval=ui->Column_Interval->value();//行间隔 int nRow=ui->Row->value();//列数 int nRow_Interval=ui->Row_Interval->value();//列间隔 qreal scence_h=pwnd->pSceneSheet[pwnd->nActiveSheetIndex]->sceneRect().height(); qreal scence_w=pwnd->pSceneSheet[pwnd->nActiveSheetIndex]->sceneRect().width(); QGraphicsItem * pCopyTem = NULL; QGraphicsItem * pTem = NULL; QList<QGraphicsItem *> addItemsList; CopyFun.CopyItem(&pCopyTem,selList.at(0)); if(R_Alignment_Group->checkedId() == 1)//默认情况下,选中的是向右递增 { for(int j=0;j<nRow;j++) { for(int i=0;i<nColumn-1;i++) { if((pCopyTem->type()==SAM_DRAW_OBJECT_ROUNDEDRECT_NEW)||(pCopyTem->type() ==SAM_DRAW_OBJECT_ARC_NEW))//判断是否为圆角矩形或者扇形 { right=pCopyTem->sceneBoundingRect().right(); } else { right=pCopyTem->boundingRect().right(); } qreal item_x=right+(i+1)*(nColumn_Interval+nItemWidth);//计算边界值是否越界 if(item_x>scence_w)//若复制的大小越界的话 {//退出循环 break; } CopyFun.CopyItem(&pTem,pCopyTem); pwnd->pSceneSheet[pwnd->nActiveSheetIndex]->addItem(pTem); addItemsList.push_back(pTem); if((pCopyTem->type()==SAM_DRAW_OBJECT_ROUNDEDRECT_NEW)||(pCopyTem->type() ==SAM_DRAW_OBJECT_ARC_NEW))//判断是否为圆角矩形或者扇形 { pTem->setPos(pTem->sceneBoundingRect().topLeft().x()+(nItemWidth+nColumn_Interval)*(i+1), pTem->sceneBoundingRect().topLeft().y()); } else { pTem->setPos((nItemWidth+nColumn_Interval)*(i+1),0); } pTem->setFlag(QGraphicsItemGroup::ItemIsMovable, true); pTem->setFlag(QGraphicsItemGroup::ItemIsSelectable, true); pTem=NULL; } if(j<nRow-1) { qreal item_y; // int hight=pCopyTem->sceneBoundingRect().height(); if((pCopyTem->type()==SAM_DRAW_OBJECT_ROUNDEDRECT_NEW)||(pCopyTem->type() ==SAM_DRAW_OBJECT_ARC_NEW))//判断是否为圆角矩形或者扇形 { bottom=pCopyTem->sceneBoundingRect().bottom(); item_y=bottom+(nRow_Interval+nItemHeight);//计算边界值是否越界 } else { bottom=pCopyTem->boundingRect().bottom(); item_y=bottom+(nRow_Interval+nItemHeight)*(j+1);//计算边界值是否越界 } if(item_y>scence_h)//若复制的大小越界的话 {//退出循环 break; } CopyFun.CopyItem(&pCopyTem,selList.at(0)); //MuCopyList(*pCopyTem,CopyCount,NormKeyboardstr); //pwnd->pSceneSheet[pwnd->nActiveSheetIndex]->setNewItem_ID(pCopyTem,NouseItem ); pwnd->pSceneSheet[pwnd->nActiveSheetIndex]->addItem(pCopyTem); addItemsList.push_back(pCopyTem); if((pCopyTem->type()==SAM_DRAW_OBJECT_ROUNDEDRECT_NEW)||(pCopyTem->type() ==SAM_DRAW_OBJECT_ARC_NEW))//判断是否为圆角矩形或者扇形 { pCopyTem->setPos(pCopyTem->sceneBoundingRect().topLeft().x(),(nItemHeight+nRow_Interval)*(j+1)+ pCopyTem->sceneBoundingRect().topLeft().y()); } else { pCopyTem->setPos(0,(nItemHeight+nRow_Interval)*(j+1)); } pCopyTem->setFlag(QGraphicsItemGroup::ItemIsMovable, true); pCopyTem->setFlag(QGraphicsItemGroup::ItemIsSelectable, true); //pwnd->AndTreeSubItem(pCopyTem); //pwnd->upDatetreeScreenItem();//更新画面的子项 } } } else if(R_Alignment_Group->checkedId() == 2)//选中的是向下递增 { for(int i=0;i<nColumn;i++) { for(int j=0;j<nRow-1;j++) { if((pCopyTem->type()==SAM_DRAW_OBJECT_ROUNDEDRECT_NEW)||(pCopyTem->type() ==SAM_DRAW_OBJECT_ARC_NEW))//判断是否为圆角矩形或者扇形 { bottom=pCopyTem->sceneBoundingRect().bottom(); } else { bottom=pCopyTem->boundingRect().bottom(); } qreal item_y=bottom+(j+1)*(nRow_Interval+nItemHeight);//计算边界值是否越界 // 若复制的大小越界的话 if(item_y>scence_h) break; CopyFun.CopyItem(&pTem,pCopyTem); pwnd->pSceneSheet[pwnd->nActiveSheetIndex]->addItem(pTem); addItemsList.push_back(pTem); if((pCopyTem->type()==SAM_DRAW_OBJECT_ROUNDEDRECT_NEW)||(pCopyTem->type() ==SAM_DRAW_OBJECT_ARC_NEW))//判断是否为圆角矩形或者扇形 { pTem->setPos(pTem->sceneBoundingRect().topLeft().x(),(nItemHeight+nRow_Interval)*(j+1)+ pTem->sceneBoundingRect().topLeft().y()); } else { pTem->setPos(0,(nItemHeight+nRow_Interval)*(j+1)); } pTem->setFlag(QGraphicsItemGroup::ItemIsMovable, true); pTem->setFlag(QGraphicsItemGroup::ItemIsSelectable, true); pTem=NULL; } if(i<nColumn-1) { qreal item_x; if((pCopyTem->type()==SAM_DRAW_OBJECT_ROUNDEDRECT_NEW)||(pCopyTem->type() ==SAM_DRAW_OBJECT_ARC_NEW))//判断是否为圆角矩形或者扇形 { right=pCopyTem->sceneBoundingRect().right(); item_x=right+(nColumn_Interval+nItemWidth);//计算边界值是否越界 } else { right=pCopyTem->boundingRect().right(); item_x=right+(i+1)*(nColumn_Interval+nItemWidth);//计算边界值是否越界 } //若复制的大小越界的话 if(item_x>scence_w) break; CopyFun.CopyItem(&pCopyTem,selList.at(0)); pwnd->pSceneSheet[pwnd->nActiveSheetIndex]->addItem(pCopyTem); addItemsList.push_back(pCopyTem); if((pCopyTem->type()==SAM_DRAW_OBJECT_ROUNDEDRECT_NEW)||(pCopyTem->type() ==SAM_DRAW_OBJECT_ARC_NEW))//判断是否为圆角矩形或者扇形 { pCopyTem->setPos(pCopyTem->sceneBoundingRect().topLeft().x()+(nItemWidth+nColumn_Interval)*(i+1), pCopyTem->sceneBoundingRect().topLeft().y()); } else { pCopyTem->setPos((nItemWidth+nColumn_Interval)*(i+1),0); } pCopyTem->setFlag(QGraphicsItemGroup::ItemIsMovable, true); pCopyTem->setFlag(QGraphicsItemGroup::ItemIsSelectable, true); } } } if(ui->if_Increse_Address->isChecked()) { //设置地址增加 QList<QGraphicsItem *> itemList = addItemsList; qDebug() << "multiCopy size ----"<< itemList.size(); setMulitAddrs(itemList,selList.at(0)); } pwnd->undoStack->push(new multiCopyCommand(pwnd->pSceneSheet[pwnd->nActiveSheetIndex],addItemsList,selList[0],true)); } pwnd->PreviewWindow(); accept(); }
/*! Retuns false so that normal traverse is not changed. */ void TasDuiTraverse::traverseObject(TasObject* objectInfo, QObject* object, TasCommand* command) { Q_UNUSED(command); // TasLogger::logger()->debug("TasDuiTraverse::traverseObject in: " + object->objectName() + " class: " + // "TasDuiTraverse::traverseObject class: " + // QString(object->metaObject()->className())); //this class only traverses menu items if (object->inherits("DuiAppletHandle") || object->inherits("MExtensionHandle")) { TasLogger::logger()->debug("TasDuiTraverse::traverseObject traversing DuiAppletHandle"); QGraphicsItem* graphicsItem = qobject_cast<QGraphicsItem*>(object); TasLogger::logger()->debug("TasDuiTraverse::traverseObject Checking for rect"); if (graphicsItem) { QRectF sceneRect = graphicsItem->sceneBoundingRect(); TasLogger::logger()->debug("TasDuiTraverse::traverseObject rect is " + QString::number(sceneRect.x()) + ":" + QString::number(sceneRect.y())); } TasObject& obj = objectInfo->addObject(); obj.setId(0); obj.setType("TDriverRef"); obj.setName("TDriverRef"); TasLogger::logger()->debug("TasDuiTraverse::traverseObject adding applet handle to " + object->property("pid").toString()); obj.addAttribute("uri", object->property("pid").toString()); } else if (object->inherits("QApplication")){ TasLogger::logger()->debug("TasDuiTraverse::traverseObject traversing QApplication " + TestabilityUtils::getApplicationName()); QApplication* application = qobject_cast<QApplication*>(object); if (application){ if (TestabilityUtils::getApplicationName() == "webwidgetrunner") { // TDriverRef to the actual program (wrtdaemon) TasObject& obj = objectInfo->addObject(); obj.setId(0); obj.setType("TDriverRef"); obj.setName("TDriverRef"); TasLogger::logger()->debug("_Reading property pid: " + application->property("pid").toString()); obj.addAttribute("uri", application->property("pid").toString()); obj.addAttribute("runtimeId", application->property("runtimePid").toString()); } } } else if (QString(object->metaObject()->className()) == "WRT::Maemo::WebWidgetView") { // We don't actually have the webwidget view headers, so going blind TasLogger::logger()->debug(">>TasDuiTraverse::traverseObject traversing WRT::Maemo::WebWidgetView "); quint64 pid = 0; quint64 runtimeid = 0; QMetaObject::invokeMethod(object, "daemonPid", Qt::DirectConnection, Q_RETURN_ARG(quint64, pid)); QMetaObject::invokeMethod(object, "runtimeId", Qt::DirectConnection, Q_RETURN_ARG(quint64, runtimeid)); TasObject& obj = objectInfo->addObject(); obj.setId(0); obj.setType("TDriverRef"); obj.setName("TDriverRef"); TasLogger::logger()->debug("TasDuiTraverse::traverseObject got pid: " + QString::number(pid)); TasLogger::logger()->debug("TasDuiTraverse::traverseObject got runtimeid: " + QString::number(runtimeid)); obj.addAttribute("uri", QString::number(pid)); obj.addAttribute("runtimeId", QString::number(runtimeid)); } // TasLogger::logger()->debug("TasDuiTraverse::traverseObject out"); }
void Tweener::release(const TupInputDeviceInformation *input, TupBrushManager *brushManager, TupGraphicsScene *scene) { #ifdef K_DEBUG #ifdef Q_OS_WIN qDebug() << "[Tweener::release()]"; #else T_FUNCINFO; #endif #endif Q_UNUSED(input); Q_UNUSED(brushManager); if (scene->currentFrameIndex() == k->initFrame) { if (k->editMode == TupToolPlugin::Properties) { if (k->nodesGroup) { k->nodesGroup->createNodes(k->path); k->nodesGroup->show(); k->nodesGroup->expandAllNodes(); k->configurator->updateSteps(k->path); QPainterPath::Element e = k->path->path().elementAt(0); QPointF begin = QPointF(e.x, e.y); if (begin != k->firstNode) { QPointF oldPos = k->firstNode; QPointF newPos = begin; int distanceX = newPos.x() - oldPos.x(); int distanceY = newPos.y() - oldPos.y(); if (k->objects.size() > 0) { foreach (QGraphicsItem *item, k->objects) item->moveBy(distanceX, distanceY); QGraphicsItem *item = k->objects.at(0); QRectF rect = item->sceneBoundingRect(); k->itemObjectReference = rect.center(); } k->firstNode = newPos; } updateTweenPoints(); } } else { if (scene->selectedItems().size() > 0) { k->objects = scene->selectedItems(); k->configurator->notifySelection(true); QGraphicsItem *item = k->objects.at(0); QRectF rect = item->sceneBoundingRect(); QPointF newPos = rect.center(); QPointF oldPos = k->itemObjectReference; k->itemObjectReference = newPos; if (!k->path) { k->path = new QGraphicsPathItem; k->path->setZValue(k->baseZValue); QColor color(55, 155, 55, 200); QPen pen(QBrush(color), 2, Qt::DashDotLine, Qt::RoundCap, Qt::RoundJoin); k->path->setPen(pen); QPainterPath path; path.moveTo(newPos); k->firstNode = newPos; k->path->setPath(path); scene->addItem(k->path); k->isPathInScene = true; k->pathOffset = QPointF(0, 0); } else { int distanceX = newPos.x() - oldPos.x(); int distanceY = newPos.y() - oldPos.y(); k->path->moveBy(distanceX, distanceY); k->pathOffset = QPointF(distanceX, distanceY); // k->firstNode = newPos; } } } } }