void PanelKMenu::paintEvent(QPaintEvent * e) { if (sidePixmap.isNull()) { PanelServiceMenu::paintEvent(e); return; } QPainter p(this); p.setClipRegion(e->region()); QStyleOptionFrame frOpt; frOpt.init(this); frOpt.lineWidth = frameWidth(); frOpt.midLineWidth = 0; style()->drawPrimitive( QStyle::PE_FrameMenu, &frOpt, &p, this); QRect r = sideImageRect(); r.setBottom( r.bottom() - sidePixmap.height() ); if ( r.intersects( e->rect() ) ) { p.drawTiledPixmap( r, sideTilePixmap ); } r = sideImageRect(); r.setTop( r.bottom() - sidePixmap.height() ); if ( r.intersects( e->rect() ) ) { QRect drawRect = r.intersect( e->rect() ); QRect pixRect = drawRect; pixRect.translate( -r.left(), -r.top() ); p.drawPixmap( drawRect.topLeft(), sidePixmap, pixRect ); } PanelServiceMenu::paintEvent( e ); }
void ImagesCollectionView::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { for (int i = 0; i < 9; i++) { QRect rect = images[i].frameGeometry(); QRect p = QRect(event->pos().x(),event->pos().y(),1,1); if (rect.intersects(p)) { images[i].setBeingSelected(true); selectedIndexofImage = count - 9 + i; cout << "press the left mouse button: select the button, index:" << selectedIndexofImage << endl; } else images[i].setBeingSelected(false); } } else if (event->button() == Qt::RightButton) { for (int i = 0; i < 9; i++) { QRect rect = images[i].frameGeometry(); QRect p = QRect(event->pos().x(),event->pos().y(),1,1); if (rect.intersects(p) && images[i].getBeingSelected()) { images[i].setBeingSelected(false); selectedIndexofImage = -1; cout << "press the right mouse button: cancel the selected, index:" << selectedIndexofImage << endl; } } } }
void PanelKMenu::paintEvent(QPaintEvent * e) { if (sidePixmap.isNull()) { PanelServiceMenu::paintEvent(e); return; } QPainter p(this); p.setClipRegion(e->region()); style().drawPrimitive( QStyle::PE_PanelPopup, &p, QRect( 0, 0, width(), height() ), colorGroup(), QStyle::Style_Default, QStyleOption( frameWidth(), 0 ) ); QRect r = sideImageRect(); r.setBottom( r.bottom() - sidePixmap.height() ); if ( r.intersects( e->rect() ) ) { p.drawTiledPixmap( r, sideTilePixmap ); } r = sideImageRect(); r.setTop( r.bottom() - sidePixmap.height() ); if ( r.intersects( e->rect() ) ) { QRect drawRect = r.intersect( e->rect() ); QRect pixRect = drawRect; pixRect.moveBy( -r.left(), -r.top() ); p.drawPixmap( drawRect.topLeft(), sidePixmap, pixRect ); } drawContents( &p ); }
void CannonField::moveShot() { QRegion region = shotRect(); ++timerCount; QRect shotR = shotRect(); if (shotR.intersects(targetRect())) { autoShootTimer->stop(); emit hit(); emit canShoot(true); } else if (shotR.x() > width() || shotR.y() > height() || shotR.intersects(barrierRect())) { autoShootTimer->stop(); emit missed(); emit canShoot(true); } else { region = region.unite(shotR); } update(region); }
void CannonField::paintEvent( QPaintEvent *e ) { QRect updateR = e->rect(); QPainter p; p.begin( this ); if ( updateR.intersects( cannonRect() ) ) paintCannon( &p ); if ( shooting && updateR.intersects( shotRect() ) ) paintShot( &p ); p.end(); }
void CannonField::paintEvent( QPaintEvent *e ) { QRect updateR = e->rect(); QPainter p( this ); if ( updateR.intersects( cannonRect() ) ) paintCannon( &p ); if ( autoShootTimer->isActive() && updateR.intersects( shotRect() ) ) paintShot( &p ); if ( updateR.intersects( targetRect() ) ) paintTarget( &p ); }
void PrettyPopupMenu::paintEvent( QPaintEvent* e ) { generateSidePixmap(); QPainter p( this ); QRect r = sideImageRect(); r.setTop( r.bottom() - s_sidePixmap.height() ); if ( r.intersects( e->rect() ) ) { QRect drawRect = r.intersect( e->rect() ).intersect( sideImageRect() ); QRect pixRect = drawRect; pixRect.moveBy( -r.left(), -r.top() ); p.drawImage( drawRect.topLeft(), s_sidePixmap, pixRect ); } p.setClipRegion( e->region() ); //NOTE The order is important here. drawContents() must be called before drawPrimitive(), // otherwise we get rendering glitches. drawContents( &p ); style().drawPrimitive( QStyle::PE_PanelPopup, &p, QRect( 0, 0, width(), height() ), colorGroup(), QStyle::Style_Default, QStyleOption( frameWidth(), 0 ) ); }
void HTMLClue::select( KHTMLWidget *_htmlw, HTMLChain *_chain, QRect & _rect, int _tx, int _ty ) { HTMLObject *obj; QRect r( x + _tx, y - ascent + _ty, width, ascent + descent ); _tx += x; _ty += y - ascent; _chain->push( this ); if ( _rect.contains( r ) ) { for ( obj = head; obj != 0; obj = obj->next() ) obj->select( _htmlw, _chain, TRUE, _tx, _ty ); } else if ( !_rect.intersects( r ) ) { for ( obj = head; obj != 0; obj = obj->next() ) obj->select( _htmlw, _chain, FALSE, _tx, _ty ); } else { for ( obj = head; obj != 0; obj = obj->next() ) obj->select( _htmlw, _chain, _rect, _tx, _ty ); } _chain->pop(); }
void HTMLCell::select( KHTMLWidget *_htmlw, HTMLChain *_chain, QRect & _rect, int _tx, int _ty ) { HTMLObject *obj; QRect r( x + _tx, y - ascent + _ty, width, ascent + descent ); _tx += x; _ty += y - ascent; bool sel = false; if ( _rect.contains( r ) ) { sel = true; } else if ( !_rect.intersects( r ) ) { sel = false; } else { QRect isect = _rect.intersect( r ); if ( isect.width() > r.width()/2 && isect.height() > r.height()/2 ) sel = true; } _chain->push( this ); for ( obj = head; obj != 0; obj = obj->next() ) obj->select( _htmlw, _chain, sel, _tx, _ty ); _chain->pop(); }
bool KisPixelSelection::isProbablyTotallyUnselected(const QRect & r) const { if (*(m_datamanager->defaultPixel()) != MIN_SELECTED) return false; QRect sr = selectedRect(); return ! r.intersects(sr); }
void SizeTip::positionTip( const QRect &rect ) { QRect tipRect = geometry(); tipRect.moveTopLeft( QPoint( 0, 0 ) ); if ( rect.intersects( tipRect ) ) { QRect deskR = KGlobalSettings::desktopGeometry( QPoint( 0, 0 ) ); tipRect.moveCenter( QPoint( deskR.width()/2, deskR.height()/2 ) ); if ( !rect.contains( tipRect, true ) && rect.intersects( tipRect ) ) tipRect.moveBottomRight( geometry().bottomRight() ); } move( tipRect.topLeft() ); }
QAccessible::State QAccessibleTableCell::state() const { QAccessible::State st; QRect globalRect = view->rect(); globalRect.translate(view->mapToGlobal(QPoint(0,0))); if (!globalRect.intersects(rect())) st.invisible = true; if (view->selectionModel()->isSelected(m_index)) st.selected = true; if (view->selectionModel()->currentIndex() == m_index) st.focused = true; if (m_index.model()->data(m_index, Qt::CheckStateRole).toInt() == Qt::Checked) st.checked = true; Qt::ItemFlags flags = m_index.flags(); if (flags & Qt::ItemIsSelectable) { st.selectable = true; st.focusable = true; if (view->selectionMode() == QAbstractItemView::MultiSelection) st.multiSelectable = true; if (view->selectionMode() == QAbstractItemView::ExtendedSelection) st.extSelectable = true; } if (m_role == QAccessible::TreeItem) { const QTreeView *treeView = qobject_cast<const QTreeView*>(view); if (treeView->model()->hasChildren(m_index)) st.expandable = true; if (treeView->isExpanded(m_index)) st.expanded = true; } return st; }
bool KisPixelSelection::isTotallyUnselected(const QRect & r) const { if (*defaultPixel() != MIN_SELECTED) return false; QRect sr = selectedExactRect(); return ! r.intersects(sr); }
QAccessible::State QAccessibleTable2Cell::state(int child) const { Q_ASSERT(child == 0); State st = Normal; QRect globalRect = view->rect(); globalRect.translate(view->mapToGlobal(QPoint(0,0))); if (!globalRect.intersects(rect(0))) st |= Invisible; if (view->selectionModel()->isSelected(m_index)) st |= Selected; if (view->selectionModel()->currentIndex() == m_index) st |= Focused; if (m_index.model()->data(m_index, Qt::CheckStateRole).toInt() == Qt::Checked) st |= Checked; Qt::ItemFlags flags = m_index.flags(); if (flags & Qt::ItemIsSelectable) { st |= Selectable; st |= Focusable; if (view->selectionMode() == QAbstractItemView::MultiSelection) st |= MultiSelectable; if (view->selectionMode() == QAbstractItemView::ExtendedSelection) st |= ExtSelectable; } if (m_role == QAccessible::TreeItem) { const QTreeView *treeView = qobject_cast<const QTreeView*>(view); if (treeView->isExpanded(m_index)) st |= Expanded; } return st; }
/** * @todo パフォーマンス悪いので改善する。 * 例えば、以下の改善策がある。 * (1) 矩形内にアイテムが一つもなかった場合は、特に何もしない */ void PianorollTrackView::updateSelectedItem() { const VSQ_NS::Sequence *sequence = controllerAdapter->getSequence(); if (!sequence) { return; } // 選択状態を最初の状態に戻す ItemSelectionManager *manager = controllerAdapter->getItemSelectionManager(); manager->revertSelectionStatusTo(mouseStatus.itemSelectionStatusAtFirst); // 矩形に入っているアイテムを、選択状態とする。 // ただし、矩形選択直前に選択状態となっているものは選択状態を解除する QRect rect = mouseStatus.rect(); const VSQ_NS::Event::List *list = sequence->track(trackIndex)->events(); int count = list->size(); std::set<const VSQ_NS::Event *> add; std::set<const VSQ_NS::Event *> remove; for (int i = 0; i < count; i++) { const VSQ_NS::Event *item = list->get(i); if (item->type != VSQ_NS::EventType::NOTE) continue; QRect itemRect = getNoteItemRect(item); if (itemRect.right() < rect.left()) continue; if (rect.right() < itemRect.left()) break; if (rect.intersects(itemRect)) { if (mouseStatus.itemSelectionStatusAtFirst.isContains(item)) { remove.insert(item); } else { add.insert(item); } } } manager->add(add); manager->remove(remove); }
void TextDocument::drawBackground(QPainter* painter, const QRect& bounds) { if (d.highlights.isEmpty() && d.lowlight == -1) return; const int margin = qCeil(documentMargin()); const QAbstractTextDocumentLayout* layout = documentLayout(); static QPointer<TextLowlight> lowlightFrame = 0; if (!lowlightFrame) lowlightFrame = new TextLowlight(static_cast<QWidget*>(painter->device())); static QPointer<TextHighlight> highlightFrame = 0; if (!highlightFrame) highlightFrame = new TextHighlight(static_cast<QWidget*>(painter->device())); if (d.lowlight != -1) { const QAbstractTextDocumentLayout* layout = documentLayout(); const int margin = qCeil(documentMargin()); const QTextBlock to = findBlockByNumber(d.lowlight); if (to.isValid()) { QRect br = layout->blockBoundingRect(to).toAlignedRect(); br.setTop(0); if (bounds.intersects(br)) { br.adjust(-margin - 1, 0, margin + 1, 2); painter->translate(br.topLeft()); lowlightFrame->setGeometry(br); lowlightFrame->render(painter); painter->translate(-br.topLeft()); } } } foreach (int highlight, d.highlights) { QTextBlock block = findBlockByNumber(highlight); if (block.isValid()) { QRect br = layout->blockBoundingRect(block).toAlignedRect(); if (bounds.intersects(br)) { br.adjust(-margin - 1, 0, margin + 1, 2); painter->translate(br.topLeft()); highlightFrame->setGeometry(br); highlightFrame->render(painter); painter->translate(-br.topLeft()); } } } }
void CannonField::paintEvent( QPaintEvent *e ) { QRect updateR = e->rect(); QPainter p( this ); if ( gameEnded ) { p.setPen( black ); p.setFont( QFont( "Courier", 48, QFont::Bold ) ); p.drawText( rect(), AlignCenter, "Game Over" ); } if ( updateR.intersects( cannonRect() ) ) paintCannon( &p ); if ( isShooting() && updateR.intersects( shotRect() ) ) paintShot( &p ); if ( !gameEnded && updateR.intersects( targetRect() ) ) paintTarget( &p ); }
bool DockableWidgetLayout::overlaysWithFirstNWidgets(const QRect& r, int n) const { for (int i = 0; i < n; ++i) { if (r.intersects(dockedWidgets[i]->bounds())) { return true; } } return false; }
void ZoomableAssemblyOverview::drawCoordLabels(QPainter & p) { const static int xoffset = 4; const static int yoffset = 3; U2OpStatusImpl status; //Prepare text QString visibleStartText = QString::number(visibleRange.startPos); QString visibleEndText = QString::number(visibleRange.endPos()); QString visibleDiffText = QString::number(visibleRange.length); insertSpaceSeparators(visibleStartText); insertSpaceSeparators(visibleEndText); insertSpaceSeparators(visibleDiffText); //Prepare font QFont font = p.font(); #if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) font.setStyleHint(QFont::SansSerif, (QFont::StyleStrategy)(QFont::PreferAntialias | QFont::ForceIntegerMetrics)); #else font.setStyleHint(QFont::SansSerif, QFont::PreferAntialias); #endif p.setFont(font); QFontMetrics fontMetrics(font, this); p.setPen(labelForegroundColor); //draw Visible Region QString visibleRegionText = tr("%1 to %2 (%3 bp)").arg(visibleStartText).arg(visibleEndText).arg(visibleDiffText); QRect grtRect = QRect(0, 0, fontMetrics.width(visibleRegionText), fontMetrics.height()); grtRect.translate(xoffset, rect().height() - yoffset - grtRect.height()); if(rect().contains(grtRect)) { p.fillRect(grtRect, labelBackgroundColor); p.drawText(grtRect, visibleRegionText); } //draw Selected Region qint64 from = browser->getXOffsetInAssembly(); qint64 to = qMin(browser->getXOffsetInAssembly() + browser->basesCanBeVisible(), model->getModelLength(status)); //prepare text QString fromText = QString::number(from + 1); // because of 1-based coords QString toText = QString::number(to); QString diff = QString::number(to - from); insertSpaceSeparators(fromText); insertSpaceSeparators(toText); insertSpaceSeparators(diff); //draw text QString selectedRegionText = tr("%1 to %2 (%3 bp)").arg(fromText, toText, diff); QRect srtRect = QRect(0, 0, fontMetrics.width(selectedRegionText), fontMetrics.height()); srtRect.translate(rect().width() - srtRect.width() - xoffset, rect().height() - yoffset - grtRect.height()); if(rect().contains(srtRect) && !srtRect.intersects(grtRect)) { p.fillRect(srtRect, labelBackgroundColor); p.drawText(srtRect, selectedRegionText); } }
//---------------------------------------------------- bool CPhoto::IsPosOnView( const QPoint& pos) { QRect cViewRect ; QRect cPosRect ; cPosRect.setBottomLeft( pos) ; cPosRect.setTopRight( pos) ; cViewRect = ui->ImgView->rect() ; return cViewRect.intersects( cPosRect) ; }
/*! Wrapper for QPainter::drawRect() */ void QwtPainter::drawRect(QPainter *painter, const QRect &rect) { QRect r = d_metricsMap.layoutToDevice(rect, painter); QRect clipRect; const bool deviceClipping = needDeviceClipping(painter, d_deviceClipping); if ( deviceClipping ) clipRect = deviceClipRect(); if ( clipRect.isValid() ) { if ( !clipRect.intersects(r) ) return; if ( !clipRect.contains(r) ) { fillRect(painter, r & clipRect, painter->brush()); int pw = painter->pen().width(); pw = pw % 2 + pw / 2; QwtPolygon pa(5); pa.setPoint(0, r.left(), r.top()); pa.setPoint(1, r.right() - pw, r.top()); pa.setPoint(2, r.right() - pw, r.bottom() - pw); pa.setPoint(3, r.left(), r.bottom() - pw); pa.setPoint(4, r.left(), r.top()); painter->save(); painter->setBrush(Qt::NoBrush); drawPolyline(painter, pa); painter->restore(); return; } } #if QT_VERSION >= 0x040000 if ( painter->pen().style() != Qt::NoPen && painter->pen().color().isValid() ) { // Qt4 adds the pen to the rect, Qt3 not. int pw = painter->pen().width(); if ( pw == 0 ) pw = 1; r.setWidth(r.width() - pw); r.setHeight(r.height() - pw); } #endif painter->drawRect(r); }
car::car(map m){ int x0, y0; bool placed = false; QRect c; while (!placed) { x0 = rand()%(m.getBorder().width() - this->width); y0 = rand()%(m.getBorder().height() - this->height); c = QRect(x0,y0, this->width, this->height); placed = !(c.intersects(m.getGoal())); for (int i = 0; i < m.getObstacles().size(); ++i) { placed = placed & (!c.intersects(m.getObstacles().at(i))); } } this->x = x0 + this->width/2; this->y = y0 + this->height/2; this->angle = 0; this->rad = 0; }
/**************************************************************************** Hacks to glue AGL to an HIView ***************************************************************************/ QRegion qt_mac_get_widget_rgn(const QWidget *widget) { if(!widget->isVisible() || widget->isMinimized()) return QRegion(); const QRect wrect = QRect(qt_mac_posInWindow(widget), widget->size()); if(!wrect.isValid()) return QRegion(); RgnHandle macr = qt_mac_get_rgn(); GetControlRegion((HIViewRef)widget->winId(), kControlStructureMetaPart, macr); OffsetRgn(macr, wrect.x(), wrect.y()); QRegion ret = qt_mac_convert_mac_region(macr); QPoint clip_pos = wrect.topLeft(); for(const QWidget *last_clip = 0, *clip = widget; clip; last_clip = clip, clip = clip->parentWidget()) { if(clip != widget) { GetControlRegion((HIViewRef)clip->winId(), kControlStructureMetaPart, macr); OffsetRgn(macr, clip_pos.x(), clip_pos.y()); ret &= qt_mac_convert_mac_region(macr); } const QObjectList &children = clip->children(); for(int i = children.size()-1; i >= 0; --i) { if(QWidget *child = qobject_cast<QWidget*>(children.at(i))) { if(child == last_clip) break; // This check may seem weird, but when we are using a unified toolbar // The widget is actually being owned by that toolbar and not by Qt. // This means that the geometry it reports will be wrong // and will accidentally cause problems when calculating the region // So, it is better to skip these widgets since they aren't the hierarchy // anyway. if (HIViewGetSuperview(HIViewRef(child->winId())) != HIViewRef(clip->winId())) continue; if(child->isVisible() && !child->isMinimized() && !child->isTopLevel()) { const QRect childRect = QRect(clip_pos+child->pos(), child->size()); if(childRect.isValid() && wrect.intersects(childRect)) { GetControlRegion((HIViewRef)child->winId(), kControlStructureMetaPart, macr); OffsetRgn(macr, childRect.x(), childRect.y()); ret -= qt_mac_convert_mac_region(macr); } } } } if(clip->isWindow()) break; clip_pos -= clip->pos(); } qt_mac_dispose_rgn(macr); return ret; }
bool KDialog::avoidArea( QWidget *w, const QRect& area, int screen ) { if ( !w ) return false; QRect fg = w->frameGeometry(); if ( !fg.intersects( area ) ) return true; // nothing to do. QRect scr = screenRect( w, screen ); QRect avoid( area ); // let's add some margin avoid.moveBy( -5, -5 ); avoid.rRight() += 10; avoid.rBottom() += 10; if ( QMAX( fg.top(), avoid.top() ) <= QMIN( fg.bottom(), avoid.bottom() ) ) { // We need to move the widget up or down int spaceAbove = QMAX(0, avoid.top() - scr.top()); int spaceBelow = QMAX(0, scr.bottom() - avoid.bottom()); if ( spaceAbove > spaceBelow ) // where's the biggest side? if ( fg.height() <= spaceAbove ) // big enough? fg.setY( avoid.top() - fg.height() ); else return false; else if ( fg.height() <= spaceBelow ) // big enough? fg.setY( avoid.bottom() ); else return false; } if ( QMAX( fg.left(), avoid.left() ) <= QMIN( fg.right(), avoid.right() ) ) { // We need to move the widget left or right int spaceLeft = QMAX(0, avoid.left() - scr.left()); int spaceRight = QMAX(0, scr.right() - avoid.right()); if ( spaceLeft > spaceRight ) // where's the biggest side? if ( fg.width() <= spaceLeft ) // big enough? fg.setX( avoid.left() - fg.width() ); else return false; else if ( fg.width() <= spaceRight ) // big enough? fg.setX( avoid.right() ); else return false; } //kdDebug() << "Moving window to " << fg.x() << "," << fg.y() << endl; w->move(fg.x(), fg.y()); return true; }
void SlippyMap::render(QPainter *p, const QRect &rect) { for (int x = 0; x <= m_tilesRect.width(); ++x) for (int y = 0; y <= m_tilesRect.height(); ++y) { QPoint tp(x + m_tilesRect.left(), y + m_tilesRect.top()); QRect box = tileRect(tp); if (rect.intersects(box)) { if (m_tilePixmaps.contains(tp)) p->drawPixmap(box, m_tilePixmaps.value(tp)); else p->drawPixmap(box, m_emptyTile); } } }
void CWndManager::PaintRoot() { const QPoint oldOrigin = m_render2D->Origin(); const QRect oldViewport = m_render2D->Viewport(); CWndControl* ctrl = null; QRect rect, viewport; int remove; for (int i = 0; i < m_controls.GetSize(); i++) { ctrl = m_controls[i]; remove = m_removeControls.Find(ctrl); if (remove != -1) { Delete(ctrl); m_removeControls.RemoveAt(remove); m_controls.RemoveAt(i); i--; continue; } rect = ctrl->GetWindowRect(true); if (oldViewport.intersects(rect)) { viewport = rect; if (viewport.left() < oldViewport.left()) viewport.setLeft(oldViewport.left()); if (viewport.top() < oldViewport.top()) viewport.setTop(oldViewport.top()); if (viewport.right() > oldViewport.right()) viewport.setRight(oldViewport.right()); if (viewport.bottom() > oldViewport.bottom()) viewport.setBottom(oldViewport.bottom()); m_render2D->SetOrigin(rect.topLeft()); m_render2D->SetViewport(viewport); ctrl->Paint(rect, oldViewport); } } if (s_selection.GetSize() > 0) { for (int i = 0; i < m_controls.GetSize(); i++) { ctrl = m_controls[i]; rect = ctrl->GetWindowRect(true); ctrl->RenderSelection(rect, oldViewport); } } m_render2D->SetOrigin(oldOrigin); m_render2D->SetViewport(oldViewport); }
void MoeGraphicsContainer::renderChildren(RenderRecorder * p, QRect region){ updateChildCache(); foreach(MoeGraphicsObject* graphicsObject, visibleChildren) { if(!region.intersects(graphicsObject->realGeometry())) continue; p->pushOpacity(graphicsObject->opacity()); p->pushClipRect(graphicsObject->realGeometry()); p->pushTransform(graphicsObject->localTransform); graphicsObject->render(p, graphicsObject->mapFromParent(graphicsObject->realGeometry() & region)); p->popTransform(); p->popClipRect(); p->popOpacity(); } }
void TextLabel::paint(QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(option); Q_UNUSED(widget); if (!m_hidden) { int i = 0; // lineHeight; int row = 1; int width = Meter::getWidth(); int height = Meter::getHeight(); QRect meterRect(0, 0, width, height); QRect textRect; QPoint next; p->setFont(font); if (scrollType != ScrollNone) { p->setClipRect(0, 0, width, height); if (!calculateScrollCoords(meterRect, textRect, next, 0, 0)) { p->setClipping(false); return; } width = textSize.width(); height = textSize.height(); } QStringList::Iterator it = value.begin(); while (it != value.end() && (row <= height || height == -1)) { drawText(p, 0, 0 + i, width, height, *it); // Draw more instances of text if scroll type is normal scroll if (scrollType == ScrollNormal) { textRect.adjust(next.x(), next.y(), next.x(), next.y()); while (textRect.intersects(meterRect)) { drawText(p, textRect.x(), textRect.y() + i, width, height, *it); textRect.adjust(next.x(), next.y(), next.x(), next.y()); } } i += lineHeight; it++; row++; } if (scrollType != ScrollNone) p->setClipping(false); } }
bool _isShowing( const QWidget * widget__ ,const QRect & rRect_ ) { const auto * widget_ = qobject_cast<const AbstractItemWidget *>(widget__); if (0 == widget_) { return false; } /* 增加边界 为"setPos"之类的动画服务 此类动画幅度不要超过5 否则可能出现逻辑错误 */ const auto && gValue_ = widget_->mapToGlobal(QPoint(-5, -5)); const auto && size_ = widget_->size() + QSize(10, 10); return rRect_.intersects( QRect(gValue_,size_) ); }
void PsiContactListViewDelegate::updateAlerts() { Q_ASSERT(!alertingIndexes_.isEmpty()); if (!contactList()->isVisible()) return; // needed? QRect contactListRect = contactList()->rect(); QHashIterator<QModelIndex, bool> it(alertingIndexes_); while (it.hasNext()) { it.next(); QRect r = contactList()->visualRect(it.key()); if (contactListRect.intersects(r)) { contactList()->dataChanged(it.key(), it.key()); } } }