Example #1
0
//-----------------------------------------------------------------------------
void ctkConsolePrivate::updateCompleter()
{
  if (this->Completer)
    {
    // Get the text between the current cursor position
    // and the start of the line
    QTextCursor text_cursor = this->textCursor();
    text_cursor.setPosition(this->InteractivePosition, QTextCursor::KeepAnchor);
    QString commandText = text_cursor.selectedText();

    // Call the completer to update the completion model
    this->Completer->updateCompletionModel(commandText);

    // Place and show the completer if there are available completions
    if (this->Completer->completionCount())
      {
      // Get a QRect for the cursor at the start of the
      // current word and then translate it down 8 pixels.
      text_cursor = this->textCursor();
      text_cursor.movePosition(QTextCursor::StartOfWord);
      QRect cr = this->cursorRect(text_cursor);
      cr.translate(0,8);
      cr.setWidth(this->Completer->popup()->sizeHintForColumn(0)
        + this->Completer->popup()->verticalScrollBar()->sizeHint().width());
      this->Completer->complete(cr);
      }
    else
      {
      this->Completer->popup()->hide();
      }
    }
}
Example #2
0
void UIListBtnType::calculateScreenArea()
{
    QRect r = m_rect;
    r.translate(m_parent->GetAreaRect().left(),
                m_parent->GetAreaRect().top());
    screen_area = r;
}
Example #3
0
void ChannelItemDelegate::drawItem(QPainter *painter,
                                    const QRect &line,
                                    const QPixmap &thumbnail,
                                    const QString &name) const {
    painter->drawPixmap((line.width() - THUMB_WIDTH) / 2, 8, thumbnail);

    QRect nameBox = line;
    nameBox.adjust(0, 0, 0, -THUMB_HEIGHT - 16);
    nameBox.translate(0, line.height() - nameBox.height());
    bool tooBig = false;

    QRect textBox = painter->boundingRect(nameBox,
                                          Qt::AlignTop | Qt::AlignHCenter | Qt::TextWordWrap,
                                          name);
    if (textBox.height() > nameBox.height() || textBox.width() > nameBox.width()) {
        painter->setFont(FontUtils::small());
        textBox = painter->boundingRect(nameBox,
                                        Qt::AlignTop | Qt::AlignHCenter | Qt::TextWordWrap,
                                        name);
        if (textBox.height() > nameBox.height()) {
            painter->setClipRect(nameBox);
            tooBig = true;
        }
    }
    if (tooBig)
        painter->drawText(nameBox, Qt::AlignHCenter | Qt::AlignTop | Qt::TextWordWrap, name);
    else
        painter->drawText(textBox, Qt::AlignCenter | Qt::TextWordWrap, name);
}
Example #4
0
QRect WindowsModernStyle::subElementRect( SubElement element, const QStyleOption* option, const QWidget* widget ) const
{
    QRect rect;
    if ( useVista() )
        rect = QWindowsVistaStyle::subElementRect( element, option, widget );
    else
        rect = QWindowsXPStyle::subElementRect( element, option, widget );

    switch ( element ) {
    case SE_DockWidgetCloseButton:
    case SE_DockWidgetFloatButton:
        rect.translate( -2, 0 );
        break;

    case SE_TabWidgetTabContents:
        if ( isStyledTabWidget( widget ) )
            rect = QWindowsStyle::subElementRect( SE_TabWidgetTabPane, option, widget );
        break;

    case SE_TabWidgetTabBar:
        if ( isStyledTabWidget( widget ) )
            rect = QWindowsStyle::subElementRect( SE_TabWidgetTabBar, option, widget );
        break;

    default:
        break;
    }

    return rect;
}
Example #5
0
// Maps window coordinates to screen coordinates
QRect SceneXrender::Window::mapToScreen(int mask, const WindowPaintData &data, const QRect &rect) const
{
    QRect r = rect;

    if (mask & PAINT_WINDOW_TRANSFORMED) {
        // Apply the window transformation
        r.moveTo(r.x() * data.xScale() + data.xTranslation(),
                 r.y() * data.yScale() + data.yTranslation());
        r.setWidth(r.width() * data.xScale());
        r.setHeight(r.height() * data.yScale());
    }

    // Move the rectangle to the screen position
    r.translate(x(), y());

    if (mask & PAINT_SCREEN_TRANSFORMED) {
        // Apply the screen transformation
        r.moveTo(r.x() * screen_paint.xScale() + screen_paint.xTranslation(),
                 r.y() * screen_paint.yScale() + screen_paint.yTranslation());
        r.setWidth(r.width() * screen_paint.xScale());
        r.setHeight(r.height() * screen_paint.yScale());
    }

    return r;
}
Example #6
0
QRect BalloonTip::relativeTextRect() {
  QRect rect = my_textRect;
  if ( my_arrowPos == TopLeft || TopRight ) {
    rect.translate( 0, 30 );
  }
  return rect;
}
Example #7
0
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;
}
Example #8
0
void QDockWidgetTitleButton::paintEvent(QPaintEvent *)
{
    QPainter p(this);

    QRect r = rect();
    QStyleOption opt;
    opt.init(this);
    opt.state |= QStyle::State_AutoRaise;

#ifdef Q_WS_MAC
    if (!qobject_cast<QMacStyle *>(style()))
#endif
    {
        if (isEnabled() && underMouse() && !isChecked() && !isDown())
            opt.state |= QStyle::State_Raised;
        if (isChecked())
            opt.state |= QStyle::State_On;
        if (isDown())
            opt.state |= QStyle::State_Sunken;
        style()->drawPrimitive(QStyle::PE_PanelButtonTool, &opt, &p, this);
    }

    int shiftHorizontal = opt.state & QStyle::State_Sunken ? style()->pixelMetric(QStyle::PM_ButtonShiftHorizontal, &opt, this) : 0;
    int shiftVertical = opt.state & QStyle::State_Sunken ? style()->pixelMetric(QStyle::PM_ButtonShiftVertical, &opt, this) : 0;

    r.adjust(2, 2, -2, -2);
    r.translate(shiftHorizontal, shiftVertical);

    QPixmap pm = icon().pixmap(style()->pixelMetric(QStyle::PM_SmallIconSize), isEnabled() ?
                                underMouse() ? QIcon::Active : QIcon::Normal
                                    : QIcon::Disabled,
                                isDown() ? QIcon::On : QIcon::Off);
    style()->drawItemPixmap(&p, r, Qt::AlignCenter, pm);
}
Example #9
0
	void paintGroup(QPainter* p, const QStyleOptionViewItem& o, GCUserViewGroupItem* gi) const
	{
		if(!showGroups_)
			return;

		QRect rect = o.rect;
		QFont f = o.font;
		p->setFont(f);
		if (!slimGroups_ || (o.state & QStyle::State_Selected) ) {
			p->fillRect(rect, colorBackground_);
		}

		p->setPen(QPen(colorForeground_));
		rect.translate(2, (rect.height() - o.fontMetrics.height())/2);
		p->drawText(rect, gi->text(0));
		if (slimGroups_	&& !(o.state & QStyle::State_Selected))
		{
			QFontMetrics fm(f);
			int x = fm.width(gi->text(0)) + 8;
			int width = rect.width();
			if(x < width - 8) {
				int h = rect.y() + (rect.height() / 2) - 1;
				p->setPen(QPen(colorBackground_));
				p->drawLine(x, h, width - 8, h);
				h++;
				p->setPen(QPen(colorForeground_));
				p->drawLine(x, h, width - 8, h);
			}
		}
	}
Example #10
0
void StampBrush::endCapture()
{
    if (mBrushBehavior != Capture)
        return;

    mBrushBehavior = Free;

    TileLayer *tileLayer = currentTileLayer();
    Q_ASSERT(tileLayer);

    // Intersect with the layer and translate to layer coordinates
    QRect captured = capturedArea();
    captured.intersect(QRect(tileLayer->x(), tileLayer->y(),
                             tileLayer->width(), tileLayer->height()));

    if (captured.isValid()) {
        captured.translate(-tileLayer->x(), -tileLayer->y());
        TileLayer *capture = tileLayer->copy(captured);
        emit currentTilesChanged(capture);
        // A copy will have been created, so delete this version
        delete capture;
    } else {
        updatePosition();
    }
}
Example #11
0
	void paintGroup(QPainter* p, const QStyleOptionViewItem& o, GCUserViewGroupItem* gi) const
	{
		bool slimGroups = PsiOptions::instance()->getOption("options.ui.look.contactlist.use-slim-group-headings").toBool();
		QRect rect = o.rect;
		QFont f = o.font;
		f.setPointSize(common_smallFontSize);
		p->setFont(f);
		QColor colorForeground = ColorOpt::instance()->color("options.ui.look.colors.contactlist.grouping.header-foreground");
		QColor colorBackground = ColorOpt::instance()->color("options.ui.look.colors.contactlist.grouping.header-background");
		if (!slimGroups || (o.state & QStyle::State_Selected) ) {
			p->fillRect(rect, colorBackground);
		}

		p->setPen(QPen(colorForeground));
		rect.translate(2, (rect.height() - o.fontMetrics.height())/2);
		p->drawText(rect, gi->text(0));
		if (slimGroups	&& !(o.state & QStyle::State_Selected))
		{
			QFontMetrics fm(f);
			int x = fm.width(gi->text(0)) + 8;
			int width = rect.width();
			if(x < width - 8) {
				int h = rect.y() + (rect.height() / 2) - 1;
				p->setPen(QPen(colorBackground));
				p->drawLine(x, h, width - 8, h);
				h++;
				p->setPen(QPen(colorForeground));
				p->drawLine(x, h, width - 8, h);
			}
		}
	}
Example #12
0
QPixmap QX11WindowSurface::grabWidget(const QWidget *widget,
                                      const QRect& rect) const
{
    if (!widget || d_ptr->device.isNull())
        return QPixmap();

    QRect srcRect;

    // make sure the rect is inside the widget & clip to widget's rect
    if (!rect.isEmpty())
        srcRect = rect & widget->rect();
    else
        srcRect = widget->rect();

    if (srcRect.isEmpty())
        return QPixmap();

    // If it's a child widget we have to translate the coordinates
    if (widget != window())
        srcRect.translate(widget->mapTo(window(), QPoint(0, 0)));

    QPixmap::x11SetDefaultScreen(widget->x11Info().screen());
    QPixmap px(srcRect.width(), srcRect.height());

    GC tmpGc = XCreateGC(X11->display, d_ptr->device.handle(), 0, 0);

    // Copy srcRect from the backing store to the new pixmap
    XSetGraphicsExposures(X11->display, tmpGc, False);
    XCopyArea(X11->display, d_ptr->device.handle(), px.handle(), tmpGc,
              srcRect.x(), srcRect.y(), srcRect.width(), srcRect.height(), 0, 0);

    XFreeGC(X11->display, tmpGc);

    return px;
}
/*!
  Returns a QPixmap generated from the part of the backing store
  corresponding to \a widget. Returns a null QPixmap if an error
  occurs. The contents of the pixmap are only defined for the regions
  of \a widget that have received paint events since the last resize
  of the backing store.

  If \a rectangle is a null rectangle (the default), the entire widget
  is grabbed. Otherwise, the grabbed area is limited to \a rectangle.

  The default implementation uses QWindowSurface::buffer().

  \sa QPixmap::grabWidget()
*/
QPixmap QWindowSurface::grabWidget(const QWidget *widget, const QRect &rectangle) const
{
    QPixmap result;

    if (widget->window() != window())
        return result;

    const QImage *img = const_cast<QWindowSurface *>(this)->buffer(widget->window());

    if (!img || img->isNull())
        return result;

    QRect rect = rectangle.isEmpty() ? widget->rect() : (widget->rect() & rectangle);

    rect.translate(offset(widget) - offset(widget->window()));
    rect &= QRect(QPoint(), img->size());

    if (rect.isEmpty())
        return result;

    QImage subimg(img->scanLine(rect.y()) + rect.x() * img->depth() / 8,
                  rect.width(), rect.height(),
                  img->bytesPerLine(), img->format());
    subimg.detach(); //### expensive -- maybe we should have a real SubImage that shares reference count

    result = QPixmap::fromImage(subimg);
    return result;
}
Example #14
0
void StampBrush::endCapture()
{
    if (mBrushBehavior != Capture)
        return;

    mBrushBehavior = Free;

    TileLayer *tileLayer = currentTileLayer();
    Q_ASSERT(tileLayer);

    // Intersect with the layer and translate to layer coordinates
    QRect captured = capturedArea();
    captured &= QRect(tileLayer->x(), tileLayer->y(),
                      tileLayer->width(), tileLayer->height());

    if (captured.isValid()) {
        captured.translate(-tileLayer->x(), -tileLayer->y());
        Map *map = tileLayer->map();
        TileLayer *capture = tileLayer->copy(captured);
        Map *stamp = new Map(map->orientation(),
                             capture->width(),
                             capture->height(),
                             map->tileWidth(),
                             map->tileHeight());

        // Add tileset references to map
        foreach (const SharedTileset &tileset, capture->usedTilesets())
            stamp->addTileset(tileset);

        stamp->addLayer(capture);

        emit stampCaptured(TileStamp(stamp));
    } else {
Example #15
0
void Plotter::mouseReleaseEvent(QMouseEvent *event)
{
    if ((event->button() == Qt::LeftButton) && rubberBandIsShown) {
        rubberBandIsShown = false;
        updateRubberBandRegion();
        unsetCursor();

        QRect rect = rubberBandRect.normalized();
        if (rect.width() < 4 || rect.height() < 4)
            return;
        rect.translate(-Margin, -Margin);

        PlotSettings prevSettings = zoomStack[curZoom];
        PlotSettings settings;
        double dx = prevSettings.spanX() / (width() - 2 * Margin);
        double dy = prevSettings.spanY() / (height() - 2 * Margin);
        settings.minX = prevSettings.minX + dx * rect.left();
        settings.maxX = prevSettings.minX + dx * rect.right();
        settings.minY = prevSettings.maxY - dy * rect.bottom();
        settings.maxY = prevSettings.maxY - dy * rect.top();
        settings.adjust();

        zoomStack.resize(curZoom + 1);
        zoomStack.append(settings);
        zoomIn();
    }
}
Example #16
0
void KMagSelWin::titleMoved (const QPoint &offset)
{
  QRect selRect = oldSelRect;
  selRect.translate (offset.x(), offset.y());
  setSelRect (selRect);
  emit resized ();
}
Example #17
0
void UIKeyboardType::calculateScreenArea()
{
    QRect r = m_area;
    r.translate(m_parent->GetAreaRect().left(),
                m_parent->GetAreaRect().top());
    screen_area = r;
}
Example #18
0
/*!
  \return the bounding rect for the label
*/
QRect QwtArrowButton::labelRect() const
{
    const int m = Margin;

    QRect r = rect();
    r.setRect(r.x() + m, r.y() + m,
              r.width() - 2 * m, r.height() - 2 * m);

    if ( isDown() ) {
        int ph, pv;
#if QT_VERSION < 0x040000
        ph = style().pixelMetric(
                 QStyle::PM_ButtonShiftHorizontal, this);
        pv = style().pixelMetric(
                 QStyle::PM_ButtonShiftVertical, this);
        r.moveBy(ph, pv);
#else
        QStyleOptionButton option = styleOpt(this);
        ph = style()->pixelMetric(
                 QStyle::PM_ButtonShiftHorizontal, &option, this);
        pv = style()->pixelMetric(
                 QStyle::PM_ButtonShiftVertical, &option, this);
        r.translate(ph, pv);
#endif
    }

    return r;
}
void LfmDelegate::paint( QPainter* p, const QStyleOptionViewItem& opt, const QModelIndex& index ) const
{
    QIcon icon;

    if( index.data(Qt::DecorationRole).type() == QVariant::Icon )
    {
        icon = index.data(Qt::DecorationRole).value<QIcon>();

        if ( icon.isNull() )
            //icon = QIcon( m_defaultImage );
            icon = QIcon( ":/default_user.png" );

        QRect iconRect = opt.rect.translated( 3, 3 );
        iconRect.setSize( QSize( 34, 34 ));
        icon.paint( p, iconRect );
        QSize iconSize = icon.actualSize( iconRect.size());

        if( iconSize.isEmpty()) iconSize = QSize( 34, 34 );

        iconRect.translate( ( iconRect.width() - iconSize.width()) / 2.0f,
                            ( iconRect.height() - iconSize.height()) /2.0f );
        iconRect.setSize( iconSize );
        p->drawRect( iconRect );
    }

    QFontMetrics fm( p->font() );
    QString elidedText = fm.elidedText( index.data().toString(), Qt::ElideRight, opt.rect.width() - 50 );
    p->drawText( opt.rect.adjusted( 46, 3, -5, -5 ), elidedText );
}
Example #20
0
void QMdStyle::drawBronzeSpinBoxButton(SubControl which,
        const QStyleOptionComplex *option, QPainter *painter) const
{
    PrimitiveElement arrow = PE_IndicatorArrowLeft;
    QRect buttonRect = option->rect;
    if ((which == SC_SpinBoxUp)
            != (option->direction == Qt::RightToLeft)) {
        arrow = PE_IndicatorArrowRight;
        buttonRect.translate(buttonRect.width() / 2, 0);
    }
    buttonRect.setWidth((buttonRect.width() + 1) / 2);

    QStyleOption buttonOpt(*option);
    painter->save();
    painter->setClipRect(buttonRect, Qt::IntersectClip);
    if (!(option->activeSubControls & which))
        buttonOpt.state &= ~(State_MouseOver | State_On | State_Sunken);
    drawBronzeBevel(&buttonOpt, painter);

    QStyleOption arrowOpt(buttonOpt);
    arrowOpt.rect = subControlRect(CC_SpinBox, option, which)
                    .adjusted(+3, +3, -3, -3);
    if(arrowOpt.rect.isValid())
        drawPrimitive(arrow, &arrowOpt, painter);
    painter->restore();
}
Example #21
0
void ItemViewShowfotoDelegate::drawImageFormat(QPainter* p, const QRect& r, const QString& mime) const
{
    Q_D(const ItemViewShowfotoDelegate);

    if (!mime.isEmpty() && !r.isNull())
    {
        QString type = mime;

        p->save();

        QFont fnt(d->fontReg);
        fnt.setWeight(QFont::Black);
        fnt.setItalic(false);
        p->setFont(fnt);
        p->setPen(QPen(Qt::gray));
        p->setOpacity(0.50);

        QRect bRect = p->boundingRect(r, Qt::AlignBottom | Qt::AlignHCenter, type.toUpper());
        bRect.adjust(1, 1, -1, -1);
        bRect.translate(0, 1);

        p->fillRect(bRect, Qt::SolidPattern);
        p->setPen(QPen(Qt::white));
        p->setOpacity(1.0);
        p->drawText(bRect, Qt::AlignBottom | Qt::AlignHCenter, type.toUpper());

        p->restore();
    }
}
Example #22
0
void UserDelegate::paint(QPainter * painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {
	const QAbstractItemModel *m = index.model();
	const QModelIndex idxc1 = index.sibling(index.row(), 1);
	QVariant data = m->data(idxc1);
	QList<QVariant> ql = data.toList();

	painter->save();

	QStyleOptionViewItemV4 o = option;
	initStyleOption(&o, index);

	QStyle *style = o.widget->style();
	QIcon::Mode iconMode = QIcon::Normal;

	QPalette::ColorRole colorRole = ((o.state & QStyle::State_Selected) ? QPalette::HighlightedText : QPalette::Text);
#if defined(Q_OS_WIN)
	// Qt's Vista Style has the wrong highlight color for treeview items
	// We can't check for QStyleSheetStyle so we have to search the children list search for a QWindowsVistaStyle
	QList<QObject *> hierarchy = style->findChildren<QObject *>();
	hierarchy.insert(0, style);
	foreach (QObject *obj, hierarchy) {
		if (QString::fromUtf8(obj->metaObject()->className()) == QString::fromUtf8("QWindowsVistaStyle")) {
			colorRole = QPalette::Text;
			break;
		}
	}
#endif

	// draw background
	style->drawPrimitive(QStyle::PE_PanelItemViewItem, &o, painter, o.widget);

	// resize rect to exclude the flag icons
	o.rect = option.rect.adjusted(0, 0, -FLAG_DIMENSION * ql.count(), 0);

	// draw icon
	QRect decorationRect = style->subElementRect(QStyle::SE_ItemViewItemDecoration, &o, o.widget);
	o.icon.paint(painter, decorationRect, o.decorationAlignment, iconMode, QIcon::On);

	// draw text
	QRect textRect = style->subElementRect(QStyle::SE_ItemViewItemText, &o, o.widget);
	QString itemText = o.fontMetrics.elidedText(o.text, o.textElideMode, textRect.width());
	painter->setFont(o.font);
	style->drawItemText(painter, textRect, o.displayAlignment, o.palette, true, itemText, colorRole);

	// draw flag icons to original rect
	QRect ps = QRect(option.rect.right() - (ql.size() * FLAG_DIMENSION),
					 option.rect.y(), ql.size() * FLAG_DIMENSION,
					 option.rect.height());

	for (int i = 0; i < ql.size(); ++i) {
		QRect r = ps;
		r.setSize(QSize(FLAG_ICON_DIMENSION, FLAG_ICON_DIMENSION));
		r.translate(i * FLAG_DIMENSION + FLAG_ICON_PADDING, FLAG_ICON_PADDING);
		QRect p = QStyle::alignedRect(option.direction, option.decorationAlignment, r.size(), r);
		qvariant_cast<QIcon>(ql[i]).paint(painter, p, option.decorationAlignment, iconMode, QIcon::On);
	}

	painter->restore();
}
Example #23
0
void MainWin::shiftDown(QRect &rect, int offset) const
{
#if QT_VERSION < 0x040000
        rect.moveBy(0, offset);     
#else
        rect.translate(0, offset);     
#endif
}
Example #24
0
QRect KisCloneLayer::exactBounds() const
{
    QRect rect = original()->exactBounds();
    if(m_d->x || m_d->y) {
        rect.translate(m_d->x, m_d->y);
    }
    return rect | projection()->exactBounds();
}
//-----------------------------------------------------------------------------
void PythonQtScriptingConsole::handleTabCompletion()
{
  QTextCursor textCursor   = this->textCursor();
  int pos = textCursor.position();
  textCursor.setPosition(commandPromptPosition());
  textCursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
  int startPos = textCursor.selectionStart();

  int offset = pos-startPos;
  QString text = textCursor.selectedText();

  QString textToComplete;
  int cur = offset;
  while(cur--) {
    QChar c = text.at(cur);
    if (c.isLetterOrNumber() || c == '.' || c == '_') {
      textToComplete.prepend(c);
    } else {
      break;
    }
  }


  QString lookup;
  QString compareText = textToComplete;
  int dot = compareText.lastIndexOf('.');
  if (dot!=-1) {
    lookup = compareText.mid(0, dot);
    compareText = compareText.mid(dot+1, offset);
  }
  if (!lookup.isEmpty() || !compareText.isEmpty()) {
    compareText = compareText.toLower();
    QStringList found;
    QStringList l = PythonQt::self()->introspection(_context, lookup, PythonQt::Anything);
    foreach (QString n, l) {
      if (n.toLower().startsWith(compareText)) {
        found << n;
      }
    }
    
    if (!found.isEmpty()) {
      _completer->setCompletionPrefix(compareText);
      _completer->setCompletionMode(QCompleter::PopupCompletion);
      _completer->setModel(new QStringListModel(found, _completer));
      _completer->setCaseSensitivity(Qt::CaseInsensitive);
      QTextCursor c = this->textCursor();
      c.movePosition(QTextCursor::StartOfWord);
      QRect cr = cursorRect(c);
      cr.setWidth(_completer->popup()->sizeHintForColumn(0)
        + _completer->popup()->verticalScrollBar()->sizeHint().width());
      cr.translate(0,8);
      _completer->complete(cr);
    } else {
      _completer->popup()->hide();
    }
  } else {
void CSliderMultiPos::drawSpanLabel(QStylePainter* painter,QRect rect,int baseElemIndex){

    setupPainter( painter,rect.topLeft(),rect.bottomRight(),
                        this->palette().color( QPalette::Dark ).light( 50 ) );
    rect.setHeight(25);
    if( this->tickPosition()==TicksBelow ){
        rect.translate(0,-20);
    }
    painter->drawText( rect,Qt::AlignCenter,intervalLabelPrefix+QString::number(baseElemIndex+1) );
}
Example #27
0
void KigPainter::drawText( const Rect& p, const QString& s, int textFlags )
{
    QRect t = toScreen(p);
    int tf = textFlags;
    t.translate( 2, 2 );
    t.setWidth( t.width() - 4 );
    t.setHeight( t.height() - 4 );
    mP.drawText( t, tf, s );
    if( mNeedOverlay ) textOverlay( t, s, tf );
}
Example #28
0
void TreeFinder::relocate()
{
    QRect r = rect();
    QRect br = parentWidget()->rect();
    r.moveBottom(br.bottom());
    r.setWidth(br.width() + 2);
    r.translate(-1, -offset());
    setGeometry(r);
    raise();
}
Example #29
0
QModelIndex ColorGridView::indexAt(const QPoint& p) const
{
    QRect area = viewport()->rect();
    area.translate(horizontalScrollBar()->value(), verticalScrollBar()->value());
    QPoint leftTop = area.topLeft();
    leftTop += p;
    int row = leftTop.y() / (gridMargin+gridWidth);
    int column = leftTop.x() / (gridMargin+gridWidth);
    return model()->index(row,column);
}
Example #30
0
void DataWindow::startAnimation()
{
    QRect rect;

    if(widgetState == WIDGET_OPENED)
    {
        widgetState = WIDGET_RETRACTED;

        closeAnimation->stop();

        animation_width = ui->actionsContainerWidget->width();

        widgetCloseAnimation->setStartValue(QVariant(animation_width));
        widgetCloseAnimation->setEndValue(QVariant(0));

        rect = geometry();
        rect.setWidth(rect.width() - animation_width);
        rect.translate(animation_width, 0);

        windowCloseAnimation->setStartValue(QVariant(geometry()));
        windowCloseAnimation->setEndValue(QVariant(rect));

        closeAnimation->start();
    }
    else // WIDGET_RETRACTED
    {
        widgetState = WIDGET_OPENED;

        openAnimation->stop();

        widgetOpenAnimation->setStartValue(QVariant(0));
        widgetOpenAnimation->setEndValue(QVariant(animation_width));

        rect = geometry();
        rect.setWidth(rect.width() + animation_width);
        rect.translate(- animation_width, 0);

        windowOpenAnimation->setStartValue(QVariant(geometry()));
        windowOpenAnimation->setEndValue(QVariant(rect));

        openAnimation->start();
    }
}