예제 #1
0
void CardView::calcLayout()
{
  // Start in the upper left corner and layout all the
  // cars using their height and width
  int maxWidth = 0;
  int maxHeight = 0;
  int xPos = 0;
  int yPos = 0;
  int cardSpacing = d->mItemSpacing;

  // delete the old separators
  d->mSeparatorList.clear();

  Q3PtrListIterator<CardViewItem> iter( d->mItemList );
  CardViewItem *item = 0;
  CardViewSeparator *sep = 0;
  xPos += cardSpacing;

  for ( iter.toFirst(); iter.current(); ++iter ) {
    item = *iter;

    yPos += cardSpacing;

    if ( yPos + item->height() + cardSpacing >= height() - horizontalScrollBar()->height() ) {
      maxHeight = qMax( maxHeight, yPos );

      // Drawing in this column would be greater than the height
      // of the scroll view, so move to next column
      yPos = cardSpacing;
      xPos += cardSpacing + maxWidth;
      if ( d->mDrawSeparators ) {
        // Create a separator since the user asked
        sep = new CardViewSeparator( this );
        sep->mRect.moveTopLeft( QPoint( xPos, yPos + d->mItemMargin ) );
        xPos += d->mSepWidth + cardSpacing;
        d->mSeparatorList.append( sep );
      }

      maxWidth = 0;
    }

    item->d->x = xPos;
    item->d->y = yPos;

    yPos += item->height();
    maxWidth = qMax( maxWidth, d->mItemWidth );
  }

  xPos += maxWidth;
  resizeContents( xPos + cardSpacing, maxHeight );

  // Update the height of all the separators now that we know the
  // max height of a column
  Q3PtrListIterator<CardViewSeparator> sepIter( d->mSeparatorList );
  for ( sepIter.toFirst(); sepIter.current(); ++sepIter )
    (*sepIter)->mRect.setHeight( maxHeight - 2 * cardSpacing - 2 * d->mItemMargin );

  d->mLayoutDirty = false;
}
예제 #2
0
CMyGraphicsView::CMyGraphicsView(QWidget * parent) :
    QGraphicsView(parent)
{
    setViewportUpdateMode(FullViewportUpdate);

    connect(horizontalScrollBar(), SIGNAL(actionTriggered(int)), this, SLOT(scrollActionTriggered(int)));
    connect(verticalScrollBar(), SIGNAL(actionTriggered(int)), this, SLOT(scrollActionTriggered(int)));
}
예제 #3
0
void DisassemblyView::paintBackground(QPainter& p)
{
  // Draw background
  medusa::UserConfiguration UserCfg;
  QColor AddrColor = QColor(QString::fromStdString(UserCfg.GetOption("color.background_address")));
  QColor CodeColor = QColor(QString::fromStdString(UserCfg.GetOption("color.background_listing")));
  QColor CursColor = QColor(Qt::black);

  QRect AddrRect = viewport()->rect();
  QRect CodeRect = viewport()->rect();

  AddrRect.setWidth((_addrLen - horizontalScrollBar()->value()) * _wChar);
  CodeRect.setX((_addrLen - horizontalScrollBar()->value()) * _wChar);

  p.fillRect(AddrRect, AddrColor);
  p.fillRect(CodeRect, CodeColor);
}
예제 #4
0
void MyTest::updateWidgetGeo()
{
    int hvalue = horizontalScrollBar()->value();
    int vvalue = verticalScrollBar()->value();
    QPoint topLeft = viewport()->rect().topLeft();

    frame->move(topLeft.x() - hvalue, topLeft.y() - vvalue);
}
예제 #5
0
파일: textbrowser.cpp 프로젝트: c3c/quazaa
void TextBrowser::paintEvent(QPaintEvent* event)
{
    const QRect bounds = rect().translated(horizontalScrollBar()->value(),
                                           verticalScrollBar()->value());

    if (!d.highlights.isEmpty()) {
        QPainter painter(viewport());
        painter.translate(-horizontalScrollBar()->value(), -verticalScrollBar()->value());

        int margin = qCeil(document()->documentMargin());
        foreach (int highlight, d.highlights) {
            QTextBlock block = document()->findBlockByNumber(highlight);
            QRectF br = document()->documentLayout()->blockBoundingRect(block);
            if (bounds.intersects(br.toAlignedRect()))
                painter.fillRect(br.adjusted(-margin, 0, margin, 0), d.highlightColor);
        }
    }
예제 #6
0
void NodeView::mouseMoveEvent(QMouseEvent* event)
{
    if (event->buttons() == Qt::MiddleButton)
    {
        if (_isPanning)
        {
            horizontalScrollBar()->setValue(horizontalScrollBar()->value() - (event->x() - _panStartPos.x()));
            verticalScrollBar()->setValue(verticalScrollBar()->value() - (event->y() - _panStartPos.y()));
            _panStartPos = event->pos();

            event->accept();
            return;
        }
    }

    QGraphicsView::mouseMoveEvent(event);
}
예제 #7
0
void GraphicsDImgView::continuePanning(const QPoint& pos)
{
    QPoint delta = pos - d->mousePressPos;
    horizontalScrollBar()->setValue(d->panningScrollPos.x() + (isRightToLeft() ? delta.x() : -delta.x()));
    verticalScrollBar()->setValue(d->panningScrollPos.y() - delta.y());
    emit contentsMoved(false);
    viewport()->update();
}
예제 #8
0
//------------------------------------------------------------------------------
void ptImageView::mouseMoveEvent(QMouseEvent* event) {
  // drag image with left mouse button to scroll
  if (FLeftMousePressed) {
    FDragDelta->setP2(event->pos());
    horizontalScrollBar()->setValue(horizontalScrollBar()->value() -
                                    FDragDelta->x2() +
                                    FDragDelta->x1());
    verticalScrollBar()->setValue(verticalScrollBar()->value() -
                                  FDragDelta->y2() +
                                  FDragDelta->y1());
    FDragDelta->setP1(event->pos());
    event->accept();

  } else {
    event->ignore();
  }
}
예제 #9
0
bool PlaylistView::eventFilter(QObject* object, QEvent* event) {
  if (event->type() == QEvent::Enter &&
      (object == horizontalScrollBar() || object == verticalScrollBar())) {
    RatingHoverOut();
    return false;
  }
  return QObject::eventFilter(object, event);
}
예제 #10
0
/**
 * @brief scalingTime call each time when need handle scaling.
 * @param x value from 0.0 to 1.0
 */
void VMainGraphicsView::scalingTime(qreal x)
{
    Q_UNUSED(x);
    const QPointF p0scene = mapToScene(mapFromGlobal(QCursor::pos()));

    qreal factor = 1.0 + static_cast<qreal>(_numScheduledScalings) / 50.0;
    scale(factor, factor);

    const QPointF p1mouse = mapFromScene(p0scene);
    const QPointF move = p1mouse - this->mapFromGlobal(QCursor::pos()); // The move
    horizontalScrollBar()->setValue(static_cast<qint32>(move.x()) + horizontalScrollBar()->value());
    verticalScrollBar()->setValue(static_cast<qint32>(move.y()) + verticalScrollBar()->value());

    VAbstractTool::NewSceneRect(this->scene(), this);

    emit NewFactor(factor);
}
예제 #11
0
void ByteViewText::paintEvent(QPaintEvent *)
{
    QPainter painter(viewport());
    painter.translate(-horizontalScrollBar()->value() * font_width_, 0);
    painter.setFont(font());

    // Pixel offset of this row
    int row_y = 0;

    // Starting byte offset
    guint offset = (guint) verticalScrollBar()->value() * row_width_;

    // Clear the area
    painter.fillRect(viewport()->rect(), palette().base());

    // Offset background
    offset_normal_fg_.setColor(ColorUtils::alphaBlend(palette().windowText(), palette().window(), 0.35));
    offset_field_fg_.setColor(ColorUtils::alphaBlend(palette().windowText(), palette().window(), 0.65));
    if (show_offset_) {
        QRect offset_rect = QRect(viewport()->rect());
        offset_rect.setWidth(offsetPixels());
        painter.fillRect(offset_rect, palette().window());
    }

    if (!tvb_) {
        return;
    }

    // Map window coordinates to byte offsets
    x_pos_to_column_.clear();
    for (guint i = 0; i < row_width_; i++) {
        int sep_width = (i / separator_interval_) * font_width_;
        if (show_hex_) {
            // Hittable pixels extend 1/2 space on either side of the hex digits
            int pixels_per_byte = (recent.gui_bytes_view == BYTES_HEX ? 3 : 9) * font_width_;
            int hex_x = offsetPixels() + margin_ + sep_width + (i * pixels_per_byte) - (font_width_ / 2);
            for (int j = 0; j <= pixels_per_byte; j++) {
                x_pos_to_column_[hex_x + j] = i;
            }
        }
        if (show_ascii_) {
            int ascii_x = offsetPixels() + hexPixels() + margin_ + sep_width + (i * font_width_);
            for (int j = 0; j <= font_width_; j++) {
                x_pos_to_column_[ascii_x + j] = i;
            }
        }
    }

    // Data rows
    int widget_height = height();
    painter.save();
    while(row_y + line_spacing_ < widget_height && offset < tvb_captured_length(tvb_)) {
        drawOffsetLine(painter, offset, row_y);
        offset += row_width_;
        row_y += line_spacing_;
    }
    painter.restore();
}
예제 #12
0
void
ScrollZoomer::layoutScrollBars(const QRect& rect)
{
  int hPos = xAxis();
  if (hScrollBarPosition() == OppositeToScale)
    hPos = oppositeAxis(hPos);

  int vPos = yAxis();
  if (vScrollBarPosition() == OppositeToScale)
    vPos = oppositeAxis(vPos);

  ScrollBar* hScrollBar = horizontalScrollBar();
  ScrollBar* vScrollBar = verticalScrollBar();

  const int hdim = hScrollBar ? hScrollBar->extent() : 0;
  const int vdim = vScrollBar ? vScrollBar->extent() : 0;

  if (hScrollBar && hScrollBar->isVisible()) {
    int x = rect.x();
    int y = (hPos == QwtPlot::xTop) ? rect.top() : rect.bottom() - hdim + 1;
    int w = rect.width();

    if (vScrollBar && vScrollBar->isVisible()) {
      if (vPos == QwtPlot::yLeft)
        x += vdim;
      w -= vdim;
    }

    hScrollBar->setGeometry(x, y, w, hdim);
  }
  if (vScrollBar && vScrollBar->isVisible()) {
    int pos = yAxis();
    if (vScrollBarPosition() == OppositeToScale)
      pos = oppositeAxis(pos);

    int x = (vPos == QwtPlot::yLeft) ? rect.left() : rect.right() - vdim + 1;
    int y = rect.y();

    int h = rect.height();

    if (hScrollBar && hScrollBar->isVisible()) {
      if (hPos == QwtPlot::xTop)
        y += hdim;

      h -= hdim;
    }

    vScrollBar->setGeometry(x, y, vdim, h);
  }
  if (hScrollBar && hScrollBar->isVisible() && vScrollBar &&
      vScrollBar->isVisible()) {
    if (d_cornerWidget) {
      QRect cornerRect(
        vScrollBar->pos().x(), hScrollBar->pos().y(), vdim, hdim);
      d_cornerWidget->setGeometry(cornerRect);
    }
  }
}
void SpaceWidgetScrollAbstract::ensureVisibleImpl(const ID& visibleItem, const CacheSpace *cacheSpace, bool validateItem)
{
    if (cacheSpace != m_scrollableCacheSpace.data())
    {
        // should be implemented by descendant class
        Q_ASSERT(false);
        return;
    }

    // calculate scroll size and position if needed
    validateCacheItemsLayout();

    QSize visibleSize = viewport()->size();
    if (visibleSize.isEmpty())
        return;

    QPoint scrollPos(horizontalScrollBar()->value(), verticalScrollBar()->value());
    QRect itemRect = cacheSpace->space().itemRect(visibleItem);

    if ((itemRect.width() >= visibleSize.width()) || (itemRect.left() < scrollPos.x()))
        scrollPos.rx() = itemRect.left();
    else if (itemRect.right() > (scrollPos.x() + visibleSize.width()))
        scrollPos.rx() = itemRect.right() - visibleSize.width();

    if ((itemRect.height() >= visibleSize.height()) || (itemRect.top() < scrollPos.y()))
        scrollPos.ry() = itemRect.top();
    else if (itemRect.bottom() > (scrollPos.y() + visibleSize.height()))
        scrollPos.ry() = itemRect.bottom() - visibleSize.height();

    // scroll to new position
    horizontalScrollBar()->setValue(scrollPos.x());
    verticalScrollBar()->setValue(scrollPos.y());

    if (validateItem)
    {
        validateCacheItemsLayout();

        // validate cache views
        CacheItem* cacheItem = const_cast<CacheItem*>(cacheSpace->cacheItem(visibleItem));
        if (!cacheItem)
            return;

        cacheItem->validateCacheView(guiContext(), &cacheSpace->window());
    }
}
예제 #14
0
AbstractTableView::AbstractTableView(QWidget* parent) : QAbstractScrollArea(parent)
{
    // Class variable initialization
    mTableOffset = 0;
    mPrevTableOffset = mTableOffset + 1;
    Header_t data;
    data.isVisible = true;
    data.height = 20;
    data.activeButtonIndex = -1;
    mHeader = data;

    // Paint cell content only when debugger is running
    setDrawDebugOnly(true);

    mRowCount = 0;

    mHeaderButtonSytle.setStyleSheet(" QPushButton {\n     background-color: rgb(192, 192, 192);\n     border-style: outset;\n     border-width: 2px;\n     border-color: rgb(128, 128, 128);\n }\n QPushButton:pressed {\n     background-color: rgb(192, 192, 192);\n     border-style: inset;\n }");

    mNbrOfLineToPrint = 0;

    memset(&mColResizeData, 0, sizeof(mColResizeData));

    mGuiState = AbstractTableView::NoState;

    mShouldReload = true;
    mAllowPainting = true;

    // ScrollBar Init
    setVerticalScrollBar(new AbstractTableScrollBar(verticalScrollBar()));
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    memset(&mScrollBarAttributes, 0, sizeof(mScrollBarAttributes));
    horizontalScrollBar()->setRange(0, 0);
    horizontalScrollBar()->setPageStep(650);
    mMouseWheelScrollDelta = 4;
    setMouseTracking(true);

    // Slots
    connect(verticalScrollBar(), SIGNAL(actionTriggered(int)), this, SLOT(vertSliderActionSlot(int)));
    connect(Config(), SIGNAL(colorsUpdated()), this, SLOT(slot_updateColors()));
    connect(Config(), SIGNAL(fontsUpdated()), this, SLOT(slot_updateFonts()));
    connect(Config(), SIGNAL(shortcutsUpdated()), this, SLOT(slot_updateShortcuts()));

    // todo: try Qt::QueuedConnection to init
    Initialize();
}
예제 #15
0
ClientLogBox::ClientLogBox(QWidget *parent)
    : QTextEdit(parent)
{
    setReadOnly(true);

    const QString style = StyleHelper::styleSheetOfScrollBar();
    verticalScrollBar()->setStyleSheet(style);
    horizontalScrollBar()->setStyleSheet(style);
}
예제 #16
0
TiledListView::TiledListView(QWidget *parent)
    : QAbstractItemView(parent), idealWidth(0), idealHeight(0),
      hashIsDirty(false)
{
    setFocusPolicy(Qt::WheelFocus);
    setFont(QApplication::font("QListView"));
    horizontalScrollBar()->setRange(0, 0);
    verticalScrollBar()->setRange(0, 0);
}
예제 #17
0
void FMSampleTextView::mouseMoveEvent ( QMouseEvent * e )
{
	if ( isPanning )
	{
		QPointF pos ( e->pos() );
		int vDelta ( qRound(mouseStartPoint.y() - pos.y()) );
		int hDelta ( qRound(mouseStartPoint.x() - pos.x()) );
		verticalScrollBar()->setValue ( verticalScrollBar()->value() + vDelta );
		horizontalScrollBar()->setValue ( horizontalScrollBar()->value() + hDelta );
		mouseStartPoint = pos;
		return;
	}
	if ( !isSelecting )
		return;

	QRectF r ( mouseStartPoint,mapToScene ( e->pos() ) );
	theRect->setRect ( r );
}
예제 #18
0
void GameTreeWidget::scrollTo(const QModelIndex& index, ScrollHint hint)
{
    Q_UNUSED(hint);

    QRect viewRect = viewport()->rect();
    QRect itemRect = visualRect(index);

    if(itemRect.left() < viewRect.left())
        horizontalScrollBar()->setValue(horizontalScrollBar()->value() + itemRect.left() - viewRect.left());
    else if(itemRect.right() > viewRect.right())
        horizontalScrollBar()->setValue(horizontalScrollBar()->value() + qMin(itemRect.right() - viewRect.right(), itemRect.left() - viewRect.left()));

    if(itemRect.top() < viewRect.top())
        verticalScrollBar()->setValue(verticalScrollBar()->value() + itemRect.top() - viewRect.top());
    else if(itemRect.bottom() > viewRect.bottom())
        verticalScrollBar()->setValue(verticalScrollBar()->value() + qMin(itemRect.bottom() - viewRect.bottom(), itemRect.top() - viewRect.top()));
    viewport()->update();
}
예제 #19
0
void MyTextBrowser::tbSetText(QString &text)
{
#ifdef NO_WEBKIT            
  int vPos = verticalScrollBar()->value();   // make cursor not jumping (ernst murnleitner)
  int hPos = horizontalScrollBar()->value();
  QTextDocument *doc = document();
  if(doc != NULL) doc->setHtml(text); // ,url);
  verticalScrollBar()->setValue(vPos);
  horizontalScrollBar()->setValue(hPos);
#else              
  if(page() != NULL && page()->mainFrame() != NULL)
  {
    xOldScroll = page()->mainFrame()->scrollBarValue(Qt::Horizontal);
    yOldScroll = page()->mainFrame()->scrollBarValue(Qt::Vertical);
  }
  setHTML(text);
#endif          
}
예제 #20
0
QModelIndex PieView::indexAt(const QPoint &point) const
{
    if (validItems == 0)
        return QModelIndex();

    int wx = point.x() + horizontalScrollBar()->value();
    int wy = point.y() + verticalScrollBar()->value();

    if (wx < totalSize) {
        double cx = wx - totalSize/2;
        double cy = totalSize/2 - wy;

        double d = pow(pow(cx, 2) + pow(cy, 2), 0.5);

        if (d == 0 || d > pieSize/2)
            return QModelIndex();

        double angle = (180 / M_PI) * acos(cx/d);
        if (cy < 0)
            angle = 360 - angle;

        double startAngle = 0.0;

        for (int row = 0; row < model()->rowCount(rootIndex()); ++row) {

            QModelIndex index = model()->index(row, 1, rootIndex());
            double value = model()->data(index).toDouble();

            if (value > 0.0) {
                double sliceAngle = 360*value/totalValue;

                if (angle >= startAngle && angle < (startAngle + sliceAngle))
                    return model()->index(row, 1, rootIndex());

                startAngle += sliceAngle;
            }
        }
    } else {
        double itemHeight = QFontMetrics(viewOptions().font).height();
        int listItem = int((wy - margin) / itemHeight);
        int validRow = 0;

        for (int row = 0; row < model()->rowCount(rootIndex()); ++row) {

            QModelIndex index = model()->index(row, 1, rootIndex());
            if (model()->data(index).toDouble() > 0.0) {

                if (listItem == validRow)
                    return model()->index(row, 0, rootIndex());

                validRow++;
            }
        }
    }

    return QModelIndex();
}
예제 #21
0
void Pageview::updateGeometries (void)
   {
   QScrollBar *vs = verticalScrollBar ();
   QScrollBar *hs = horizontalScrollBar ();

   QListView::updateGeometries ();
   vs->setSingleStep (30);
   hs->setSingleStep (30);
   }
예제 #22
0
// Keep the list of message headers scrolled hard to the left
void MailListView::scrollToLeft(int)
{
    // In right to left mode when the horizontal header is hidden a
    // phantom 70 pixel column appears. Scroll this out of the way.
    // It would be better to fix this elsewhere (in QTableWidget?)
    if (currentColumn() != 0)
        setCurrentCell( currentRow(), 0 );
    horizontalScrollBar()->setValue( 0 );
}
//-----------------------------------------------------------------------------
QRectF vktraceviewer_QTimelineView::viewportRect(const QModelIndex &index) const
{
    QRectF rectf = itemRect(index);
    if (rectf.isValid())
    {
        rectf.moveLeft( rectf.left() * m_zoomFactor);
        rectf.setWidth( rectf.width() * m_zoomFactor);

        rectf.adjust(-horizontalScrollBar()->value(), 0,
                     -horizontalScrollBar()->value(), 0);

        // the margin is added last so that it is NOT scaled
        rectf.adjust(m_margin, 0,
                     m_margin, 0);
    }

    return rectf;
}
예제 #24
0
Gist::Gist(Execution* execution, QWidget* parent)
    : QWidget(parent), execution(execution) {
  layout = new QGridLayout(this);

  auto scrollArea = new QAbstractScrollArea(this);
  scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
  scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
  scrollArea->setAutoFillBackground(true);

  myPalette = new QPalette(scrollArea->palette());

  myPalette->setColor(QPalette::Window, Qt::white);
  scrollArea->setPalette(*myPalette);

  setLayout(layout);

  m_Canvas = new TreeCanvas(execution, layout, CanvasType::REGULAR,
                            scrollArea->viewport());
  m_Canvas->setPalette(*myPalette);
  m_Canvas->setObjectName("canvas");

  layout->addWidget(scrollArea, 0, 0, -1, 1);
  layout->addWidget(m_Canvas->scaleBar, 1, 1, Qt::AlignHCenter);
  layout->addWidget(m_Canvas->smallBox, 1, 2, Qt::AlignBottom);

  addActions();

  connect(scrollArea->horizontalScrollBar(), SIGNAL(valueChanged(int)),
          m_Canvas, SLOT(scroll(void)));
  connect(scrollArea->verticalScrollBar(), SIGNAL(valueChanged(int)), m_Canvas,
          SLOT(scroll(void)));

  connect(this, SIGNAL(doneReceiving()), m_Canvas, SLOT(statusFinished()));

  connect(m_Canvas, SIGNAL(addedBookmark(const QString&)), this, SLOT(addBookmark(const QString&)));
  connect(m_Canvas, SIGNAL(removedBookmark(int)), this, SLOT(removeBookmark(int)));
  connect(m_Canvas, SIGNAL(needActionsUpdate(VisualNode*, bool)),
          this, SLOT(updateActions(VisualNode*, bool)));

  connect(m_Canvas, SIGNAL(statusChanged(VisualNode*, const Statistics&, bool)),
          this, SLOT(on_canvas_statusChanged(VisualNode*, const Statistics&, bool)));

  nodeStatInspector = new NodeStatInspector(this);

  m_Canvas->show();

  resize(500, 400);

  auto sa_layout = new QVBoxLayout();
  sa_layout->setContentsMargins(0, 0, 0, 0);
  sa_layout->addWidget(m_Canvas);

  scrollArea->viewport()->setLayout(sa_layout);

  // enables on_<sender>_<signal>() mechanism
  QMetaObject::connectSlotsByName(this);
}
예제 #25
0
PlaylistView::PlaylistView(QWidget *parent)
  : QTreeView(parent),
    style_(new PlaylistProxyStyle(style())),
    playlist_(NULL),
    header_(new PlaylistHeader(Qt::Horizontal, this)),
    setting_initial_header_layout_(false),
    upgrading_from_qheaderview_(false),
    read_only_settings_(true),
    glow_enabled_(true),
    currently_glowing_(false),
    glow_intensity_step_(0),
    rating_delegate_(NULL),
    inhibit_autoscroll_timer_(new QTimer(this)),
    inhibit_autoscroll_(false),
    currently_autoscrolling_(false),
    row_height_(-1),
    currenttrack_play_(":currenttrack_play.png"),
    currenttrack_pause_(":currenttrack_pause.png"),
    cached_current_row_row_(-1),
    drop_indicator_row_(-1),
    drag_over_(false),
    dynamic_controls_(new DynamicPlaylistControls(this))
{
  setHeader(header_);
  header_->setMovable(true);
  setStyle(style_);
  setMouseTracking(true);

  connect(header_, SIGNAL(sectionResized(int,int,int)), SLOT(SaveGeometry()));
  connect(header_, SIGNAL(sectionMoved(int,int,int)), SLOT(SaveGeometry()));
  connect(header_, SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), SLOT(SaveGeometry()));
  connect(header_, SIGNAL(SectionVisibilityChanged(int,bool)), SLOT(SaveGeometry()));
  connect(header_, SIGNAL(sectionResized(int,int,int)), SLOT(InvalidateCachedCurrentPixmap()));
  connect(header_, SIGNAL(sectionMoved(int,int,int)), SLOT(InvalidateCachedCurrentPixmap()));
  connect(header_, SIGNAL(SectionVisibilityChanged(int,bool)), SLOT(InvalidateCachedCurrentPixmap()));
  connect(header_, SIGNAL(StretchEnabledChanged(bool)), SLOT(SaveSettings()));
  connect(header_, SIGNAL(ColumnAlignmentChanged()), SLOT(SaveSettings()));
  connect(header_, SIGNAL(StretchEnabledChanged(bool)), SLOT(StretchChanged(bool)));
  connect(header_, SIGNAL(MouseEntered()), SLOT(RatingHoverOut()));

  inhibit_autoscroll_timer_->setInterval(kAutoscrollGraceTimeout * 1000);
  inhibit_autoscroll_timer_->setSingleShot(true);
  connect(inhibit_autoscroll_timer_, SIGNAL(timeout()), SLOT(InhibitAutoscrollTimeout()));

  horizontalScrollBar()->installEventFilter(this);
  verticalScrollBar()->installEventFilter(this);

  setAlternatingRowColors(true);

  setAttribute(Qt::WA_MacShowFocusRect, false);

  dynamic_controls_->hide();

#ifdef Q_OS_DARWIN
  setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
#endif
}
예제 #26
0
파일: view.cpp 프로젝트: Fale/qtmoko
QRect LinearView::itemViewportRect(const QModelIndex &index) const
{
    QRect rect = itemRect(index);
    QRect result(rect.left() - horizontalScrollBar()->value(),
                 rect.top() - verticalScrollBar()->value(),
                 rect.width(), viewport()->height());

    return result;
}
예제 #27
0
void ColorGridView::mouseMoveEvent(QMouseEvent *event)
{
    setCurrentIndex(indexAt(event->pos()));
    //    QRect rect = viewport()->rect();
    QRect rect2 = rect();
    rect2.translate(horizontalScrollBar()->value(), verticalScrollBar()->value());
    update(rect2);
    //    update();
}
ScalableWrapper::ScalableWrapper(QTextEdit* _editor, QWidget* _parent) :
	QGraphicsView(_parent),
	m_scene(new QGraphicsScene),
	m_editor(_editor),
	m_zoomRange(1),
	m_gestureZoomInertionBreak(0)
{
	//
	// Отслеживаем жесты
	//
	grabGesture(Qt::PinchGesture);

	//
	// Всегда показываем полосы прокрутки
	//
	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);

	//
	// Предварительная настройка редактора текста
	//
	// FIXME: непонятно как быть с предком, у встраиваемого виджета не должно быть родителя,
	//		  но как в таком случае освобождать память?
	//
	m_editor->setParent(0);
	m_editor->setContextMenuPolicy(Qt::PreventContextMenu);
	m_editor->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
	m_editor->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
	m_editor->installEventFilter(this);

	//
	// Настраиваем само представление
	//
	m_rect = m_scene->addRect(0, 0, 1, 1, QPen(), Qt::red);
	m_editorProxy = m_scene->addWidget(m_editor);
	setScene(m_scene);

	//
	// Отключаем действия полос прокрутки, чтобы в дальнейшем проксировать ими
	// полосы прокрутки самого редактора текста
	//
	horizontalScrollBar()->disconnect();
	verticalScrollBar()->disconnect();

	//
	// Синхронизация значения ролика в обе стороны
	//
	setupScrollingSynchronization(true);

	//
	// Добавляем возможность масштабирования при помощи комбинаций Ctrl +/-
	//
	QShortcut* zoomInShortcut = new QShortcut(QKeySequence("Ctrl++"), this);
	connect(zoomInShortcut, SIGNAL(activated()), this, SLOT(zoomIn()));
	QShortcut* zoomOutShortcut = new QShortcut(QKeySequence("Ctrl+-"), this);
	connect(zoomOutShortcut, SIGNAL(activated()), this, SLOT(zoomOut()));
}
예제 #29
0
void Viewer::zoomReset()
{
    _image->adjustSize();
    zoomInOut(1.0);
    QScrollBar *hbar = horizontalScrollBar();
    QScrollBar *vbar = verticalScrollBar();
    hbar->setValue(int(hbar->maximum() / 2));
    vbar->setValue(int(vbar->maximum() / 2));
}
예제 #30
0
NTouchListWidget::NTouchListWidget(QWidget *parent)
{
    Q_UNUSED(parent);
    verticalScrollBar()->setVisible(false);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    horizontalScrollBar()->setVisible(false);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    isMoved = false;
}