QRect EventTimelineDatePainter::dateStringToRect(const QDate &date, const QString &dateString) const
{
    QRect result;

    result.setTop(0);
    result.setLeft(qMax(0, qRound(m_pixelsPerSecondRatio * m_visibleTimeStart.secsTo(QDateTime(date, QTime(), Qt::UTC)))));
    result.setWidth(m_painter.fontMetrics().width(dateString) + 15);
    result.setHeight(m_fontHeight);

    return result;
}
QRect expandRect(const Point2D &p, QRect rect)
{
    auto expandMax = [](float outPoint, float expandedSide){return outPoint > expandedSide ? outPoint : expandedSide;};
    auto expandMin = [](float outPoint, float expandedSide){return outPoint < expandedSide ? outPoint : expandedSide;};
    rect.setRight(expandMax(p.X(), rect.right()));
    rect.setLeft(expandMin(p.X(), rect.left()));

    rect.setBottom(expandMax(p.Y(), rect.bottom()));
    rect.setTop(expandMin(p.Y(), rect.top()));
    return rect;
}
Example #3
0
void VideoDisplay::mousePressEvent(QMouseEvent *event)
{

    if (!m_worker->m_pFrame)
        return;

    if (!m_IsMouseOn)
    {
        m_IsMouseOn = true;
    }

        //return;

    if(event->buttons() & Qt::LeftButton)
    {
        QRect videoRect(0, 0, m_Config._config.frmWidth, m_Config._config.frmHeight);

        if(videoRect.contains(event->x(),event->y()))
        {
            m_worker->m_IsTracking = false;            
            _isSelecting = true;
            trackingRect.left = event->x() - videoRect.left();
            trackingRect.top = event->y() - videoRect.top();

            _toBeTracked.setLeft(event->x());
            _toBeTracked.setTop(event->y());
            _toBeTracked.setRight(event->x()) ;
            _toBeTracked.setBottom( event->y());
        }
    }
    else if (event->buttons() & Qt::RightButton)
    {
        trackingRect.left		= event->x()-m_rectWidthInit / 2;
        trackingRect.top		= event->y()-m_rectHeightInit / 2;
        trackingRect.right		= event->x()+m_rectWidthInit / 2;
        trackingRect.bottom	= event->y()+m_rectHeightInit / 2;

        if(trackingRect.left < 0)
            trackingRect.left = 0;
        if(trackingRect.right > m_Config._config.frmWidth - 1)
            trackingRect.right = m_Config._config.frmWidth - 1;
        if(trackingRect.top < 0)
            trackingRect.top = 0;
        if(trackingRect.bottom > m_Config._config.frmHeight - 1)
            trackingRect.bottom = m_Config._config.frmHeight - 1;

        ResetRectCurrent();
        m_worker->StartTracking(trackingRect);
    }



    QMainWindow::mousePressEvent(event);
}
Example #4
0
void IconDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
						 const QModelIndex &index) const
{
	painter->save();
	if (option.state & QStyle::State_Selected)
	{
		painter->fillRect(option.rect, option.palette.highlight());
		painter->setPen(option.palette.color(QPalette::HighlightedText));
	}

	QRect iconRect = option.rect;
	iconRect.setWidth(32);
	iconRect.setHeight(32);

	int fontHeight = painter->fontMetrics().height();
	QRect shortRect = option.rect;
	shortRect.setLeft(shortRect.left() + 38);
	shortRect.setBottom(shortRect.top() + fontHeight);

	QRect longRect = option.rect;
	longRect.setLeft(longRect.left() + 50);
	longRect.setTop(longRect.top() + fontHeight);

    QString text = Catalog::decorateText(index.data(ROLE_SHORT).toString(), g_searchText);
	painter->drawText(shortRect, Qt::AlignTop | Qt::TextShowMnemonic, text);

	if (option.state & QStyle::State_Selected)
		painter->setPen(alternativesPath->palette().color(QPalette::HighlightedText));
	else
		painter->setPen(alternativesPath->palette().color(QPalette::WindowText));

	painter->setFont(alternativesPath->font());

	QString full = index.data(ROLE_FULL).toString();
	full = painter->fontMetrics().elidedText(full, option.textElideMode, longRect.width());
	painter->drawText(longRect, Qt::AlignTop, full);

	QIcon p = index.data(ROLE_ICON).value<QIcon>();
	p.paint(painter, iconRect);
	painter->restore();
}
Example #5
0
void AlbumDelegate::paint(
        QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    QPen oldPen = painter->pen();

    QStyle *style = QApplication::style();

    int margin = style->pixelMetric(QStyle::PM_ButtonMargin);

    QRect rect = option.rect;

    if (option.state & QStyle::State_HasFocus) {
        painter->fillRect(rect, option.palette.highlight());

        painter->setPen(option.palette.color(QPalette::HighlightedText));
    }

    rect.adjust(margin, margin, -margin, -margin);

    QRect decorationRect = rect;
    decorationRect.setRight(decorationRect.left() + option.decorationSize.width());

    QPixmap decoration = qvariant_cast<QPixmap>(index.data(Qt::DecorationRole));
    if (!decoration.isNull())
        style->drawItemPixmap(painter, decorationRect, Qt::AlignCenter, decoration);
    else
        painter->drawRect(decorationRect);

    rect.setLeft(decorationRect.right() + margin);

    QString text = index.data(Qt::DisplayRole).toString();

    QRect textRect;
    painter->drawText(rect, Qt::TextWordWrap, text, &textRect);
    rect.setTop(textRect.bottom() + margin);

    text = index.data(Artist).toString();

    painter->drawText(rect, Qt::TextWordWrap, text, &textRect);
    rect.setTop(textRect.bottom() + margin);

    QVariant trackCount = index.data(TrackCount);

    if (trackCount.isValid()) {
        text = trackCount.toInt() != 1
                ? tr("%1 Songs").arg(trackCount.toInt())
                : tr("1 Song");

        painter->drawText(rect, Qt::TextWordWrap, text, &textRect);
    }

    painter->setPen(oldPen);
}
Example #6
0
void CBilateralFilterSet::resizeEvent(QResizeEvent *e)
{
	QDialog::resizeEvent(e);
	QRect rect = ui.frame->geometry();
	int nW = rect.width();
	int nH = rect.height();
	rect.setLeft(0);
	rect.setTop(0);
	rect.setWidth(nW);
	rect.setHeight(nH);
	m_pShowImgWnd->setGeometry(rect);
}
Example #7
0
bool JsonUtils::tryParse(const QVariant &arg, QRect &result)
{
    JsonArray args = arg.value<JsonArray>();
    if (args.size() != 4) return false;

    result.setLeft(args[0].toInt());
    result.setTop(args[1].toInt());
    result.setWidth(args[2].toInt());
    result.setHeight(args[3].toInt());

    return true;
}
Example #8
0
QRect Utils::ReadRect(ProgramOptions::Ptr po, const std::string& name, const QRect& defaultVal)
{
    ProgramOptions::Ptr node = po->StartNode(name);
    QRect rect;
    
    rect.setLeft(node->GetInt("Left", defaultVal.left()));
    rect.setTop(node->GetInt("Top", defaultVal.top()));
    rect.setWidth(node->GetInt("Width", defaultVal.width()));
    rect.setHeight(node->GetInt("Height", defaultVal.height()));
    
    return rect;
}
void ManagerWindow::mouseMoveEvent(QMouseEvent* e)
{
    if (this->dragOrigin != QPoint(-1, -1)) {
        int dx = e->globalX() - this->dragOrigin.x();
        int dy = e->globalY() - this->dragOrigin.y();

        QRect g = this->geometry();

        if (this->resizeLeft)
            g.setLeft(g.left() + dx);
        if (this->resizeRight)
            g.setRight(g.right() + dx);
        if (this->resizeUp)
            g.setTop(g.top() + dy);
        if (this->resizeDown)
            g.setBottom(g.bottom() + dy);

        this->setGeometry(g);

        this->dragOrigin = e->globalPos();
    } else {
        if (!this->isFullScreen() && !this->isMaximized()) {
            int x = e->x();
            int y = e->y();

            QRect r = this->rect();
            this->resizeLeft = qAbs(x - r.left()) <= borderWidth;
            this->resizeRight = qAbs(x - r.right()) <= borderWidth;
            this->resizeUp = qAbs(y - r.top()) <= borderWidth;
            this->resizeDown = qAbs(y - r.bottom()) <= borderWidth;

            if ((this->resizeLeft & this->resizeUp) || (this->resizeRight & this->resizeDown))
                this->setCursor(QCursor(Qt::SizeFDiagCursor));
            else if ((this->resizeLeft & this->resizeDown) || (this->resizeRight & this->resizeUp))
                this->setCursor(QCursor(Qt::SizeBDiagCursor));
            else if (this->resizeLeft || this->resizeRight)
                this->setCursor(QCursor(Qt::SizeHorCursor));
            else if (this->resizeUp || this->resizeDown)
                this->setCursor(QCursor(Qt::SizeVerCursor));
            else
                //By default, child widgets inherit the cursor form the parent, which means
                //that if the mouse pointer moves from border directly to child widget,
                //the cursor will keep whatever shape it had.
				//Therefore, the cursor for all DIRECT children of this window
				//(QWidgets in this case) must explicitly be set to Qt::ArrowCursor
				// in designer or constructor.
				//In designer, it appears that the cursor is already set to Qt::ArrowCursor,
				//but actually, the cursor is unset.
				//It must be set to some other value, then back to ArrowCursor.
                this->setCursor(QCursor(Qt::ArrowCursor));
        }
    }
}
Example #10
0
void ScPainterEx_GDI::getClipPathDimensions( QRect& r )
{
	RECT rect = { 0, 0, 0, 0 };
	int result = GetClipBox( m_dc, &rect );
	if( result != NULLREGION && result != ERROR )
	{
		r.setLeft( rect.left );
		r.setRight( rect.right );
		r.setBottom( rect.bottom );
		r.setTop( rect.top );	
	}
}
Example #11
0
void
Style::drawHeaderSection(const QStyleOption *option, QPainter *painter, const QWidget*) const
{
    OPT_SUNKEN OPT_HOVER
    const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option);
    const bool sorting = header && (header->sortIndicator != QStyleOptionHeader::None);

    Qt::Orientation o = Qt::Vertical; int s = RECT.height();
    if (header && header->orientation == Qt::Vertical)
    {
        o = Qt::Horizontal;
        s = RECT.width();
    }

    QColor c =  sorting ? COLOR(config.view.sortingHeader_role[Bg]) : COLOR(config.view.header_role[Bg]);

    if (Colors::value(c) < 50)
        { int h,s,v,a; c.getHsv(&h, &s, &v, &a); c.setHsv(h, s, 50, a); }

    if (appType == GTK)
        sunken = option->state & State_HasFocus;
    if (sunken)
    {
        const QPixmap &sunk = Gradients::pix(c, s, o, Gradients::Sunken);
        painter->drawTiledPixmap(RECT, sunk);
        return;
    }

    const Gradients::Type gt = sorting ? config.view.sortingHeaderGradient : config.view.headerGradient;

    if (hover)
        c = Colors::mid(c, sorting ? CCOLOR(view.sortingHeader, Fg) : CCOLOR(view.header, Fg),8,1);

    if (gt == Gradients::None)
        painter->fillRect(RECT, c);
    else
        painter->drawTiledPixmap(RECT, Gradients::pix(c, s, o, gt));

    if (o == Qt::Vertical)
    {
        if (!header || header->section < QStyleOptionHeader::End)
        {
            QRect r = RECT; r.setLeft(r.right() - F(1));
            painter->drawTiledPixmap(r, Gradients::pix(CCOLOR(view.header, Bg), s, o, Gradients::Sunken));
        }
        if (Colors::value(CCOLOR(view.header, Bg)) > 90) // not on dark elements - looks just stupid...
        {
            SAVE_PEN
            painter->setPen(Colors::mid(FCOLOR(Base), Qt::black, 6, 1));
            painter->drawLine(RECT.bottomLeft(), RECT.bottomRight());
            RESTORE_PEN
        }
    }
std::vector<QRect> Ui::AvatarContainerWidget::calculateAvatarPositions(const QRect& _rcParent, QSize& _avatarsSize)
{
    std::vector<QRect> positions;
    avatarRects_.clear();

    if (!avatars_.empty())
    {
        if (_avatarsSize.width() <= 0 || _avatarsSize.height() <= 0)
        {
            _avatarsSize = calculateAvatarSize();
        }

        QRect remains = _rcParent;
        remains.setLeft  (remains.left()   + xOffset_);
        remains.setRight (remains.right()  - xOffset_);
        remains.setTop   (remains.top()    + yOffset_);
        remains.setBottom(remains.bottom() - yOffset_);

        remains.setLeft(std::max((remains.right() + remains.left() - _avatarsSize.width()) / 2, remains.left()));
        remains.setRight(std::min(remains.right(), remains.left() + _avatarsSize.width()));
        remains.setTop(std::max((remains.bottom() + remains.top() - _avatarsSize.height()) / 2, remains.top()));
        remains.setBottom(std::min(remains.bottom(), remains.top() + _avatarsSize.height()));

        for (std::map<std::string, Logic::QPixmapSCptr>::iterator it = avatars_.begin(); it != avatars_.end(); it++)
        {
            if (remains.width() < avatarSize_ || remains.height() < avatarSize_)
            {
                break;
            }

            QRect rc_draw = remains;
            rc_draw.setRight(rc_draw.left() + avatarSize_);
            positions.push_back(rc_draw);

            remains.setLeft(remains.left() + avatarSize_ * (1.0f - overlapPer01_));
        }
    }

    return positions;
}
Example #13
0
/*!
  \return Bounding rectangle of the pipe ( without borders )
          in widget coordinates
*/
QRect QwtThermo::pipeRect() const
{
    int mbd = 0;
    if ( d_data->scalePosition != QwtThermo::NoScale )
    {
        int d1, d2;
        scaleDraw()->getBorderDistHint( font(), d1, d2 );
        mbd = qMax( d1, d2 );
    }
    const int bw = d_data->borderWidth;
    const int scaleOff = bw + mbd;

    const QRect cr = contentsRect();

    QRect pipeRect = cr;
    if ( d_data->orientation == Qt::Horizontal )
    {
        pipeRect.adjust( scaleOff, 0, -scaleOff, 0 );

        if ( d_data->scalePosition == QwtThermo::TrailingScale )
            pipeRect.setTop( cr.top() + cr.height() - bw - d_data->pipeWidth );
        else
            pipeRect.setTop( bw );

        pipeRect.setHeight( d_data->pipeWidth );
    }
    else // Qt::Vertical
    {
        pipeRect.adjust( 0, scaleOff, 0, -scaleOff );

        if ( d_data->scalePosition == QwtThermo::LeadingScale )
            pipeRect.setLeft( bw );
        else 
            pipeRect.setLeft( cr.left() + cr.width() - bw - d_data->pipeWidth );

        pipeRect.setWidth( d_data->pipeWidth );
    }

    return pipeRect;
}
Example #14
0
void ListviewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
                           const QModelIndex &index) const
{
    QStyledItemDelegate::paint(painter,option,index);

    painter->save();

    QFontMetrics fm(font);

    QIcon icon = qvariant_cast<QIcon>(index.data(IconRole));
    QString headerText = qvariant_cast<QString>(index.data(headerTextRole));
    QString subText = qvariant_cast<QString>(index.data(subHeaderTextrole));

    QSize iconsize = icon.actualSize(option.decorationSize);

    QRect headerRect = option.rect;
    QRect subheaderRect = option.rect;
    QRect iconRect = subheaderRect;

    iconRect.setRight(iconsize.width()+30);
    iconRect.setTop(iconRect.top());
    headerRect.setLeft(30);
    subheaderRect.setLeft(30);
    headerRect.setTop(headerRect.top()+1);
    headerRect.setBottom(headerRect.top()+fm.height());

    subheaderRect.setTop(headerRect.bottom()-5);

    painter->drawPixmap(QPoint(iconRect.left()+iconsize.width()/2,iconRect.top()+iconsize.height()/2),icon.pixmap(iconsize.width(),iconsize.height()));

    painter->setFont(font);
    painter->drawText(headerRect,headerText);


    painter->setFont(SubFont);
    painter->drawText(subheaderRect.left(),subheaderRect.top()+17,subText);

    painter->restore();

}
Example #15
0
void LevelMeterVU::resized()
{
    if (m_backgroundPixmap)
    {
        delete m_backgroundPixmap;
    }

    m_backgroundPixmap = new QPixmap(rect().width(), rect().height());
    m_backgroundPixmap->fill(QColor(42, 42, 42, 255));

    QPainter painter(m_backgroundPixmap);
    QRect barTop = m_backgroundPixmap->rect();
    barTop.setBottom(0.5 * rect().height() - 2);
    barTop.setTop(2);
    barTop.setLeft(0.75* rect().width());
    painter.fillRect(barTop, Qt::red);

    QRect bar = m_backgroundPixmap->rect();

    // 100% full height white line
    painter.setPen(Qt::white);
//    painter.drawLine(0.75*bar.width(), 0, 0.75*bar.width(), bar.height());

    m_scaleEngine.setSize(0.75*bar.width());
    const ScaleEngine::TickList& scaleTickList = m_scaleEngine.getTickList();


    for (int i = 0; i < scaleTickList.count(); i++)
    {
//        qDebug() << "LevelMeterVU::resized: tick #" << i
//                << " major: " << scaleTickList[i].major
//                << " pos: " << scaleTickList[i].pos
//                << " text: " << scaleTickList[i].text
//                << " textPos: " << scaleTickList[i].textPos
//                << " textSize: " << scaleTickList[i].textSize;
        const ScaleEngine::Tick tick = scaleTickList[i];

        if(tick.major)
        {
            if ((tick.textSize > 0) && (tick.textPos > 0))
            {
                painter.drawText(QPointF(tick.textPos - (tick.textSize/2) - 2, bar.height()/2), tick.text);
            }

            painter.drawLine(tick.pos, 0, scaleTickList[i].pos, bar.height());
        }
        else
        {
            painter.drawLine(tick.pos, bar.height()/4, scaleTickList[i].pos, bar.height()/2);
        }
    }
}
Example #16
0
void MapCanvas::paintEvent(QPaintEvent *e)
{
	if(mapHandle() <= 0 )
	{
		QWidget::paintEvent(e);
		return;
	}

//	QElapsedTimer ti;
//	ti.start();

	QRect drawRect;
	drawRect.setTop( mapTopLeft().y() );
	drawRect.setLeft( mapTopLeft().x() );
	drawRect.setHeight( height() );
	drawRect.setWidth( width() );

	int bytesPerLine = (int)(drawRect.width() * mMapBitDepth / 8);
	int size = bytesPerLine * drawRect.height();

	char *dataBytes = AllocateTheMemory(size);
	memset(dataBytes, 0x0, size);

	XIMAGEDESC ximage;
	ximage.Point = dataBytes;
	ximage.Width = (long)(drawRect.width());
	ximage.Height = (long)(drawRect.height());
	ximage.Depth = mMapBitDepth;
	ximage.CellSize = mMapBitDepth / 8;
	ximage.RowSize = (long)(bytesPerLine);

	RECT rect;
	rect.top = drawRect.top();
	rect.left = drawRect.left();
	rect.bottom = (long)(drawRect.bottom());
	rect.right = (long)(drawRect.right());

	mapPaintToXImage(mMapHandle, &ximage, 0, 0, &rect);

	QImage img((uchar *) dataBytes, drawRect.width(), drawRect.height(), QImage::Format_RGB32);

	QPainter p(this);
	p.drawImage(0, 0, img);
	p.setPen( mZoomRectPen);
	p.drawRect(mZoomRect);

	FreeTheMemory(dataBytes);

	mRepaint = false;

//	qDebug()<<"Repaint in"<<ti.elapsed()<<"ms";
}
Example #17
0
/*!\reimp
*/
void QRadioButton::drawButtonLabel( QPainter *p )
{
    int x, y, w, h;
    GUIStyle gs = style();
    QSize sz = style().exclusiveIndicatorSize();
    if ( gs == WindowsStyle )
	sz.setWidth(sz.width()+1);
    y = 0;
    x = sz.width() + gutter;
    w = width() - x;
    h = height();

    style().drawItem( p, x, y, w, h,
		      AlignLeft|AlignVCenter|ShowPrefix,
		      colorGroup(), isEnabled(),
		      pixmap(), text() );

    if ( hasFocus() ) {
	QRect br = style().itemRect( p, x, y, w, h,
				     AlignLeft|AlignVCenter|ShowPrefix,
				     isEnabled(),
				     pixmap(), text() );
	br.setLeft( br.left()-3 );
	br.setRight( br.right()+2 );
	br.setTop( br.top()-2 );
	br.setBottom( br.bottom()+2);
	br = br.intersect( QRect(0,0,width(),height()) );

	if ( !text().isEmpty() )
	    style().drawFocusRect( p, br, colorGroup() );
	else {
	    br.setRight( br.left()-1 );
	    br.setLeft( br.left()-16 );
	    br.setTop( br.top() );
	    br.setBottom( br.bottom() );
	    style().drawFocusRect( p, br, colorGroup() );
	}
    }
}
Example #18
0
void SpecButton::paintEvent( QPaintEvent *event )
{
    QPushButton::paintEvent( event );

    QRect rect = event->rect();
        rect.setLeft(   7 );
        rect.setTop(    7 );
        rect.setWidth(  rect.width()  - 8 );
        rect.setHeight( rect.height() - 8 );

    QPainter painter( this );
        painter.fillRect( rect , color );
}
void ExpandingDelegate::adjustRect(QRect &rect) const
{
    if (!model()->indexIsItem(m_currentIndex) /*&& m_currentIndex.column() == 0*/) {

        rect.setLeft(model()->treeView()->columnViewportPosition(0));
        int columnCount = model()->columnCount(m_currentIndex.parent());

        if (!columnCount) {
            return;
        }
        rect.setRight(model()->treeView()->columnViewportPosition(columnCount - 1) + model()->treeView()->columnWidth(columnCount - 1));
    }
}
//------------------------------------------------------------------------------
//
void QEAnalogIndicator::drawBar (QPainter & painter, QRect &area,
                                 const double fraction)
{
   int temp;
   QPen pen;
   QBrush brush;

   QRect barRect (area);

   switch (this->mOrientation) {

      case Left_To_Right:
         // Convert fractions back to pixels.
         //
         temp = int (fraction * (area.right () - area.left ()));
         barRect.setRight (area.left () + temp);
         break;

      case Top_To_Bottom:
         temp = int (fraction * (area.bottom () - area.top ()));
         barRect.setBottom (area.top () + temp);
         break;

      case Right_To_Left:
         temp = int (fraction * (area.right () - area.left ()));
         barRect.setLeft (area.right () - temp);
         break;

      case Bottom_To_Top:
         temp = int (fraction * (area.bottom () - area.top ()));
         barRect.setTop (area.bottom () - temp);
         break;

      default:
         // report an error??
         //
         return;
   }

   // barRect and paint it.
   //
   pen.setColor (this->getForegroundPaintColour ());
   pen.setWidth (1);
   painter.setPen (pen);

   brush.setStyle (Qt::SolidPattern);
   brush.setColor (this->getForegroundPaintColour() );
   painter.setBrush (brush);

   painter.drawRect (barRect);
}
Example #21
0
/*!
  Render the legend into a given rectangle.

  \param painter Painter
  \param rect Bounding rectangle
  \param fillBackground When true, fill rect with the widget background 

  \sa renderLegend() is used by QwtPlotRenderer - not by QwtLegend itself
*/
void QwtLegend::renderLegend( QPainter *painter, 
    const QRectF &rect, bool fillBackground ) const
{
    if ( d_data->itemMap.isEmpty() )
        return;

    if ( fillBackground )
    {
        if ( autoFillBackground() ||
            testAttribute( Qt::WA_StyledBackground ) )
        {
            QwtPainter::drawBackgound( painter, rect, this );
        }
    }

    const QwtDynGridLayout *legendLayout = 
        qobject_cast<QwtDynGridLayout *>( contentsWidget()->layout() );
    if ( legendLayout == NULL )
        return;

    int left, right, top, bottom;
    getContentsMargins( &left, &top, &right, &bottom );

    QRect layoutRect; 
    layoutRect.setLeft( qCeil( rect.left() ) + left );
    layoutRect.setTop( qCeil( rect.top() ) + top );
    layoutRect.setRight( qFloor( rect.right() ) - right );
    layoutRect.setBottom( qFloor( rect.bottom() ) - bottom );

    uint numCols = legendLayout->columnsForWidth( layoutRect.width() );
    QList<QRect> itemRects =
        legendLayout->layoutItems( layoutRect, numCols );

    int index = 0;

    for ( int i = 0; i < legendLayout->count(); i++ )
    {
        QLayoutItem *item = legendLayout->itemAt( i );
        QWidget *w = item->widget();
        if ( w )
        {
            painter->save();

            painter->setClipRect( itemRects[index], Qt::IntersectClip );
            renderItem( painter, w, itemRects[index], fillBackground );

            index++;
            painter->restore();
        }
    }
}
Example #22
0
void FileManager::rename_item()
{
  //RenameLineEdit *le;

  if (dir_content_->hasFocus())
  {
    cur_list_view_=dir_content_;
    cur_le_=le_on_dir_content_;
  }
  if (dirtree_view_->hasFocus())
  {
    cur_list_view_=dirtree_view_;
    cur_le_=le_on_dirtree_;
  }



  rename_item_=(FOListViewItem*)cur_list_view_->currentItem();

  qDebug("dirname: %s", rename_item_->dirname().c_str());
  qDebug("basename: %s", rename_item_->basename().c_str());
  //return ;

  if (rename_item_==0) return;

  cur_list_view_->ensureItemVisible( rename_item_ );

/*
  cur_list_view->horizontalScrollBar()->setValue( 0 );
  cur_list_view->horizontalScrollBar()->setEnabled( FALSE );
  cur_list_view->verticalScrollBar()->setEnabled( FALSE );
  */

  //QRect header_r = dir_content_->header()->sectionRect(0);
  int header_height = cur_list_view_->header()->height();
  QRect r = cur_list_view_->itemRect(rename_item_);
  r.setTop( r.top() + cur_list_view_->frameWidth() + 1 + header_height);
  r.setBottom( r.bottom() + cur_list_view_->frameWidth() + header_height);
  //cur_list_view_->treeStepSize();
  r.setLeft( r.left() + cal_step_size(cur_list_view_, rename_item_));
  qDebug("TreeStepSize: %d", cur_list_view_->treeStepSize());
  //r.setWidth( cur_list_view_->columnWidth( 0 ) - cur_list_view_->treeStepSize());


  cur_le_->setGeometry( r );
  cur_le_->setText( rename_item_->text( 0 ) );
  cur_le_->selectAll();
  cur_le_->show();
  cur_le_->setFocus();

}
/*!
  Render the legend into a given rectangle.

  \param plot Plot widget
  \param painter Painter
  \param rect Bounding rectangle
*/
void QwtPlotRenderer::renderLegend( const QwtPlot *plot,
    QPainter *painter, const QRectF &rect ) const
{
    if ( !plot->legend() || plot->legend()->isEmpty() )
        return;

    if ( !( d_data->discardFlags & DiscardBackground ) )
    {
        if ( plot->legend()->autoFillBackground() ||
            plot->legend()->testAttribute( Qt::WA_StyledBackground ) )
        {
            qwtRenderBackground( painter, rect, plot->legend() );
        }
    }

    const QwtDynGridLayout *legendLayout = qobject_cast<QwtDynGridLayout *>( 
        plot->legend()->contentsWidget()->layout() );
    if ( legendLayout == NULL )
        return;

    int left, right, top, bottom;
    plot->legend()->getContentsMargins( &left, &top, &right, &bottom );

    QRect layoutRect;
    layoutRect.setLeft( qCeil( rect.left() ) + left );
    layoutRect.setTop( qCeil( rect.top() ) + top );
    layoutRect.setRight( qFloor( rect.right() ) - right );
    layoutRect.setBottom( qFloor( rect.bottom() ) - bottom );

    uint numCols = legendLayout->columnsForWidth( layoutRect.width() );
    QList<QRect> itemRects =
        legendLayout->layoutItems( layoutRect, numCols );

    int index = 0;

    for ( int i = 0; i < legendLayout->count(); i++ )
    {
        QLayoutItem *item = legendLayout->itemAt( i );
        QWidget *w = item->widget();
        if ( w )
        {
            painter->save();

            painter->setClipRect( itemRects[index] );
            renderLegendItem( plot, painter, w, itemRects[index] );

            index++;
            painter->restore();
        }
    }
}
Example #24
0
QRect GLTileSet::Tile(int index)
{
    QRect result;
    if(!Tiles.isNull() && index <= (Tiles.height() * Tiles.width() / tileSize) )
    {
        int row = index / tilesWide;
        int col = index % tilesWide;
        result.setLeft(col * tileSize);
        result.setTop(row * tileSize);
        result.setWidth(tileSize);
        result.setHeight(tileSize);
    }
    return result;
}
bool ControllerMouseColumnsResizer::processMouseMove(QMouseEvent* event)
{
    if (m_rubberBand)
    {
        QRect rect = activationState().context.widget->rect();
        rect.setLeft(event->x());
        rect.setRight(event->x());
        m_rubberBand->setGeometry(rect);

        return true;
    }

    return ControllerMouseCaptured::processMouseMove(event);
}
Example #26
0
// repaint columns from col0 to col1. If col1 is -1, repaint all
// the way to the right edge of the table.
// called by
//          1.void Qps::update_table(int col)
void HeadedTable::repaintColumns(int col0, int col1)
{
    QRect bvr = body->viewRect();
    QRect hvr = head->viewRect();
    int x0 = colOffset(col0) - body->xOffset();
    if (x0 > hvr.width())
        return;
    if (x0 < 0)
        x0 = 0;
    bvr.setLeft(x0);
    hvr.setLeft(x0);
    if (col1 >= 0)
    {
        int x1 = colOffset(col1) + max_widths[col1] - body->xOffset();
        if (x1 < hvr.width())
        {
            hvr.setRight(x1);
            bvr.setRight(x1);
        }
    }
    head->repaint(hvr);
    body->repaint(bvr);
}
Example #27
0
void QtSegmentControlPrivate::layoutSegments()
{
    if (!layoutDirty)
        return;
    const int segmentCount = segments.count();
    QRect rect;
    for (int i = 0; i < segmentCount; ++i) {
        QSize ssh = q->segmentSizeHint(i);
        rect.setSize(ssh);
        segments[i].rect = rect;
        rect.setLeft(rect.left() + ssh.width());
    }
    layoutDirty = false;
}
Example #28
0
void SceneTreeDelegate::customDraw(QPainter *painter, QStyleOptionViewItem *option, const QModelIndex &index) const
{
	DAVA::Entity *entity = index.data(SceneTreeItem::TreeItemEntityRole).value<DAVA::Entity*>();

	if(NULL != entity && entity->GetLocked())
	{
		QRect owRect = option->rect;
		owRect.setLeft(owRect.right() - 16);

		lockedIcon.paint(painter, owRect);

		option->rect.setRight(owRect.left());
	}
}
	void SpeechTranscriptionWidget::transcriberModel_cursorChanged(std::pair<long, long> oldCursor)
	{
		UpdateCursorUI();

		QRect updateRect = ui->widgetSamples->rect();

		auto nullCur = SpeechTranscriptionViewModel::nullCursor();
		auto newCursor = transcriberModel_->cursor();
		if (false && oldCursor != nullCur && newCursor != nullCur)
		{
			// update only invalidated rect

			std::array<long, 4> cursorBounds;
			int cursorBoundsCount = 0;
			if (oldCursor.first != PticaGovorun::NullSampleInd)
				cursorBounds[cursorBoundsCount++] = oldCursor.first;
			if (oldCursor.second != PticaGovorun::NullSampleInd)
				cursorBounds[cursorBoundsCount++] = oldCursor.second;
			if (newCursor.first != PticaGovorun::NullSampleInd)
				cursorBounds[cursorBoundsCount++] = newCursor.first;
			if (newCursor.second != PticaGovorun::NullSampleInd)
				cursorBounds[cursorBoundsCount++] = newCursor.second;

			assert(cursorBoundsCount > 0 && "Must be some cursor boundaries on cursor change");

			auto minIt = std::min_element(cursorBounds.begin(), cursorBounds.begin() + cursorBoundsCount);
			auto maxIt = std::max_element(cursorBounds.begin(), cursorBounds.begin() + cursorBoundsCount);

			auto minSampleInd = *minIt;
			auto maxSampleInd = *maxIt;

			auto minX = transcriberModel_->sampleIndToDocPosX(minSampleInd);
			minX -= transcriberModel_->docOffsetX();

			auto maxX = transcriberModel_->sampleIndToDocPosX(maxSampleInd);
			maxX -= transcriberModel_->docOffsetX();

			const static int VerticalMarkerWidth = 3;
			updateRect.setLeft(minX - VerticalMarkerWidth);
			updateRect.setRight(maxX + VerticalMarkerWidth);
		}

		// QWidget::repaint is more responsive and the moving cursor may not flicker
		// but if drawing is slow, the UI may stop responding at all
		// QWidget::update may not be in time to interactively update the UI (the cursor may flicker)
		// but the UI will be responsive under intensive drawing
		ui->widgetSamples->update(updateRect);
		//ui->widgetSamples->repaint(updateRect); // NOTE: may hang in paint routines on audio playing
	}
Example #30
0
void ResultViewPic::calculatePieces()
{
  selectPicture();
  
  mPieces.clear();

  float aspectRatio = float( mFullPic.width() ) / float( mFullPic.height() );

  kdDebug() << "AR: " << aspectRatio << endl;

  int y = sqrt( float( totalCount() ) / aspectRatio );
  int x = y * aspectRatio;

  kdDebug() << "TOTAL: " << x << " " << y << endl;

  while( x * y < totalCount() ) {
    y += 1;
    x = y * aspectRatio;
  }

  kdDebug() << "TOTAL2: " << x << " " << y << endl;

  int row = 0;
  int col = 0;

  float x_size = float( mFullPic.width() ) / float( x );
  float y_size = float( mFullPic.height() ) / float( y );

  kdDebug() << "X_SIZE: " << x_size << " Y_SIZE: " << y_size << endl;

  for ( int i = 0; i < x * y; ++i ) {
    QRect piece;
    piece.setLeft( row * x_size );
    piece.setTop( col * y_size );
    piece.setWidth( ceil( x_size ) );
    piece.setHeight( ceil( y_size ) );
    mPieces.append( piece );

    row++;
    if ( row >= x ) {
      col++;
      row = 0;
    }
  }

//  showPiece( mPieces.last() );
  
  kdDebug() << "PIECES: " << mPieces.count() << endl;
}