FreezeTableWidget::FreezeTableWidget( QAbstractItemModel * model, QWidget * parent ) { setModel(model); frozenTableView = new QTableView(this); init(); //connect the headers and scrollbars of both tableviews together connect(horizontalHeader(),SIGNAL(sectionResized(int,int,int)), this, SLOT(updateSectionWidth(int,int,int))); connect(verticalHeader(),SIGNAL(sectionResized(int,int,int)), this, SLOT(updateSectionHeight(int,int,int))); connect(frozenTableView->verticalScrollBar(), SIGNAL(valueChanged(int)), verticalScrollBar(), SLOT(setValue(int))); connect(verticalScrollBar(), SIGNAL(valueChanged(int)), frozenTableView->verticalScrollBar(), SLOT(setValue(int))); connect(frozenTableView->horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(keepFrozenHorizonalScroll()) ); }
void TileSelectionWidget::select(int xpos, int ypos) { xpos += horizontalScrollBar()->value(); ypos += verticalScrollBar()->value(); if (xpos < 40) xpos = 40; if (xpos >= 40 + tileSetLabel->width()) xpos = tileSetLabel->width(); if (ypos < 40) ypos = 40; if (ypos >= 40 + tileSetLabel->height()) ypos = tileSetLabel->height(); xpos = round40(xpos); ypos = round40(ypos); cursor->move(xpos, ypos); id = (ypos - 40) / 40 * (tileSetLabel->width() / 40) + (xpos - 40) / 40 + 1; emit selected(id); emit selected(tileSetPixmap.copy(xpos - 40, ypos - 40, 40, 40)); }
PHIAGraphicsView::PHIAGraphicsView( QWidget *parent ) : QGraphicsView( parent ) { qDebug( "PHIAGraphicsView::PHIAGraphicsView()" ); setAcceptDrops( true ); setInteractive( true ); setDragMode( NoDrag ); setRenderHint( QPainter::Antialiasing, true ); setRenderHint( QPainter::SmoothPixmapTransform, true ); setRenderHint( QPainter::TextAntialiasing, true ); setFrameShape( QFrame::NoFrame ); setFrameShadow( QFrame::Plain ); setViewportUpdateMode( QGraphicsView::SmartViewportUpdate ); setCacheMode( CacheNone ); setAlignment( Qt::AlignHCenter | Qt::AlignTop ); connect( horizontalScrollBar(), SIGNAL( valueChanged( int ) ), this, SLOT( slotSliderChanged( int ) ) ); connect( verticalScrollBar(), SIGNAL( valueChanged( int ) ), this, SLOT( slotSliderChanged( int ) ) ); }
void Robot25DWindow::mousePressEvent(QMouseEvent *event) { const QScrollBar * vert = verticalScrollBar(); const QScrollBar * horiz = horizontalScrollBar(); bool scrollable = vert->maximum() + horiz->maximum() > 0; if (scrollable) { if (event->button() == Qt::LeftButton) { setCursor(Qt::ClosedHandCursor); mousePressPosition_ = event->pos(); } else { setCursor(Qt::OpenHandCursor); } event->accept(); } else { setCursor(Qt::ArrowCursor); event->ignore(); } }
IntervalSummaryWindow::IntervalSummaryWindow(Context *context) : context(context) { setWindowTitle(tr("Interval Summary")); setReadOnly(true); setFrameStyle(QFrame::NoFrame); #ifdef Q_OS_WIN QStyle *cde = QStyleFactory::create(OS_STYLE); verticalScrollBar()->setStyle(cde); #endif #ifdef Q_OS_MAC setAttribute(Qt::WA_MacShowFocusRect, 0); #endif connect(context, SIGNAL(intervalsChanged()), this, SLOT(intervalSelected())); connect(context, SIGNAL(intervalSelected()), this, SLOT(intervalSelected())); connect(context, SIGNAL(intervalHover(IntervalItem*)), this, SLOT(intervalHover(IntervalItem*))); connect(context, SIGNAL(configChanged(qint32)), this, SLOT(intervalSelected())); setHtml(GCColor::css() + "<body></body>"); }
void chat::_cond_scroll_prepare() { // Chack that if the last line before new text is entered is not visible, // then do not do the scrolling because it means user has scrolled the // buffer back and wants to view older text. QScrollBar *vbar = verticalScrollBar(); int maximum = vbar->maximum(); int value = vbar->value(); int single_step = vbar->singleStep(); _saved_pre_insert_vertical_value = value; _allow_scroll = (maximum - value < single_step); ACE_DEBUG((LM_DEBUG, "chat::_cond_scroll_prepare: max %d, val %d, singleStep %d, allow_scroll: %d\n", maximum, value, single_step, _allow_scroll)); // Ensure text is inserted at the end of the buffer QTextCursor c = this->textCursor(); c.movePosition(QTextCursor::End); setTextCursor(c); }
ColorGridView::ColorGridView(QWidget *parent) : QAbstractItemView(parent), menu(this), colorWheel(0), margin(5), gridMargin(2), gridWidth(16), gridCount(10), gridsSize((gridMargin+gridWidth)*gridCount, (gridMargin+gridWidth)*gridCount) { // we do not support multi selection or row selection setSelectionMode(QAbstractItemView::SingleSelection); setSelectionBehavior(QAbstractItemView::SelectItems); horizontalScrollBar()->setRange(0, 0); verticalScrollBar()->setRange(0, 0); setMouseTracking(true); initGridBackgroundImg(); initContextMenu(); resize(gridsSize); }
//------------------------------------------------------------------------------ // Name: paintEvent //------------------------------------------------------------------------------ void NandView::paintEvent(QPaintEvent *) { QPainter painter(viewport()); int font_width_ = 12; int chars_per_row = 8; int origin_ = 0; painter.translate(-horizontalScrollBar()->value() * font_width_, 0); // current actual offset (in bytes) quint64 offset = (quint64)verticalScrollBar()->value() * chars_per_row; if(origin_ != 0) { if(offset > 0) { offset += origin_; offset -= chars_per_row; } else { origin_ = 0; updateScrollbars(); } } }
void SortableView::scrollTimeout() { if(m_scrollDelta == 0) { // Nothing to do m_scrollTimer.stop(); return; } QScrollBar *bar = verticalScrollBar(); bar->setValue(bar->value() + m_scrollDelta); // Move the indicator int before = sortableIndexAtPos( m_curMousePos + getScrollOffset(), m_curLevel, true); moveIndicator(before); if(isIndexValidForLevel(before, m_curLevel)) m_indicator.show(); else m_indicator.hide(); }
int FastoHexEdit::positionAtPoint(const QPoint &point) const { const int px = point.x(); const int py = point.y(); const int charW = charWidth(); const int charH = charHeight(); const QRect rect = stableRect(viewport()->rect()); const int yPosStart = rect.top(); const int xPosStart = rect.left(); const int yPosEnd = rect.bottom(); const int xPosEnd = rect.right(); const int wid = xPosEnd - xPosStart; const int widchars = wid - TextMarginXY * 2; const int xPosAscii = widchars/4 * 3; // line pos int acharInLine = asciiCharInLine(widchars); if (acharInLine < 0) { acharInLine = 0; } if ((px >= xPosStart && px < xPosAscii) && (py >= yPosStart && py < yPosEnd)) { int posx = (xPosStart + px) / charW; int div = posx / 3; int mod = posx % 3; int pos = 0; // symbol pos in data; if (mod == 0) { pos = div * 2; } else { pos = (div * 2) + 1; } int firstLineIdx = verticalScrollBar()->value(); int posy = (py - yPosStart) / charH; pos = pos + (firstLineIdx + posy) * acharInLine * 2; return pos; } return -1; }
void KNMusicAlbumView::scrollTo(const QModelIndex &index, ScrollHint hint) { //Check the index and the max column count. if(!index.isValid() || m_maxColumnCount==0) { return; } //Check whether we need to move the vertical scroll bar. if(hint==QAbstractItemView::EnsureVisible && rect().contains(visualRect(index), true)) { return; } //Use timeline to move to the position. m_scrollTimeLine->stop(); m_scrollTimeLine->setFrameRange(verticalScrollBar()->value(), indexScrollBarValue(index, hint)); m_scrollTimeLine->start(); //Update. viewport()->update(); }
/** * @brief Sets the view settings for this view. * * When they change, the view is updated accordingly. * * @param view_settings The settings to watch. */ void TilesetView::set_view_settings(ViewSettings& view_settings) { this->view_settings = &view_settings; connect(&view_settings, SIGNAL(zoom_changed(double)), this, SLOT(update_zoom())); update_zoom(); connect(this->view_settings, SIGNAL(grid_visibility_changed(bool)), this, SLOT(update_grid_visibility())); connect(this->view_settings, SIGNAL(grid_size_changed(QSize)), this, SLOT(update_grid_visibility())); connect(this->view_settings, SIGNAL(grid_style_changed(GridStyle)), this, SLOT(update_grid_visibility())); connect(this->view_settings, SIGNAL(grid_color_changed(QColor)), this, SLOT(update_grid_visibility())); update_grid_visibility(); horizontalScrollBar()->setValue(0); verticalScrollBar()->setValue(0); }
CWizFolderView::CWizFolderView(CWizExplorerApp& app, QWidget *parent) : QTreeWidget(parent) , m_app(app) , m_dbMgr(app.databaseManager()) { header()->hide(); setAnimated(true); setAttribute(Qt::WA_MacShowFocusRect, false); setStyle(::WizGetStyle(m_app.userSettings().skin())); setVerticalScrollMode(QAbstractItemView::ScrollPerItem); #ifdef WIZNOTE_CUSTOM_SCROLLBAR setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_vScroll = new CWizScrollBar(this); m_vScroll->syncWith(verticalScrollBar()); #endif initFolders(); }
void ConsoleWidget::prompt(QString text) { QString text2 = text; moveCursor(QTextCursor::End); handleColor(); // change to default color // add space because it looks better text2 += " "; // go to new line if line isn't empty emptyLine(); insertPlainText(text2); m_lastLine = ""; // if we have trouble keeping viewport QScrollBar *sb = verticalScrollBar(); sb->setSliderPosition(sb->maximum()); m_prompt = text2; }
NotifierWindowTab::NotifierWindowTab(KviWindow * pWnd, QTabWidget * pParent) : QScrollArea(pParent) { m_pWnd = pWnd; if(m_pWnd) { m_szLabel = m_pWnd->windowName(); connect(pWnd, SIGNAL(windowNameChanged()), this, SLOT(labelChanged())); connect(pWnd, SIGNAL(destroyed()), this, SLOT(closeMe())); } else { m_szLabel = "----"; } if(pParent) { m_pParent = pParent; m_pParent->addTab(this, m_szLabel); } setFocusPolicy(Qt::NoFocus); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); if(verticalScrollBar()) connect(verticalScrollBar(), SIGNAL(rangeChanged(int, int)), this, SLOT(scrollRangeChanged(int, int))); QPalette pal = palette(); pal.setColor(backgroundRole(), Qt::transparent); setPalette(pal); m_pVWidget = new QWidget(viewport()); m_pVBox = new QVBoxLayout(m_pVWidget); m_pVBox->setSizeConstraint(QLayout::SetFixedSize); m_pVBox->setSpacing(SPACING); m_pVBox->setMargin(SPACING); setWidget(m_pVWidget); }
WLibraryTableView::WLibraryTableView(QWidget* parent, ConfigObject<ConfigValue>* pConfig, ConfigKey vScrollBarPosKey) : QTableView(parent), m_pConfig(pConfig), m_vScrollBarPosKey(vScrollBarPosKey) { // Setup properties for table // Editing starts when clicking on an already selected item. setEditTriggers(QAbstractItemView::SelectedClicked); //Enable selection by rows and extended selection (ctrl/shift click) setSelectionBehavior(QAbstractItemView::SelectRows); setSelectionMode(QAbstractItemView::ExtendedSelection); setWordWrap(false); setShowGrid(false); setCornerButtonEnabled(false); setSortingEnabled(true); // Used by delegates (e.g. StarDelegate) to tell when the mouse enters a // cell. setMouseTracking(true); //Work around a Qt bug that lets you make your columns so wide you //can't reach the divider to make them small again. setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); verticalHeader()->hide(); int rowHeight = m_pConfig->getValueString(ConfigKey("[Library]","RowHeight"), "20").toInt(); verticalHeader()->setDefaultSectionSize(rowHeight); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); setAlternatingRowColors(true); loadVScrollBarPosState(); connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SIGNAL(scrollValueChanged(int))); setTabKeyNavigation(false); }
void Canvas::keyPressEvent(QKeyEvent* event) { if (!event) { return; } int mult = 1; if ((event->modifiers() & Qt::ControlModifier)) { mult = 10; } switch (event->key()) { case Qt::Key_Right: { horizontalScrollBar()->setValue(horizontalScrollBar()->value() + horizontalScrollBar()->singleStep()*mult); break; } case Qt::Key_Left: { horizontalScrollBar()->setValue(horizontalScrollBar()->value() - horizontalScrollBar()->singleStep()*mult); break; } case Qt::Key_Up: { verticalScrollBar()->setValue(verticalScrollBar()->value() - verticalScrollBar()->singleStep()*mult); break; } case Qt::Key_Down: { verticalScrollBar()->setValue(verticalScrollBar()->value() + verticalScrollBar()->singleStep()*mult); break; } default: { event->ignore(); break; } } }
/** * @param x x coordinate * @param y y coordinate */ void EditorView::moveDrag(int x, int y) { const int dx = dragx_ - x; const int dy = dragy_ - y; if(isdragging_==ROTATE) { qreal preva = atan2( width()/2 - dragx_, height()/2 - dragy_ ); qreal a = atan2( width()/2 - x, height()/2 - y ); setRotation(rotation() + (preva-a) * (180.0 / M_PI)); } else { QScrollBar *ver = verticalScrollBar(); ver->setSliderPosition(ver->sliderPosition()+dy); QScrollBar *hor = horizontalScrollBar(); hor->setSliderPosition(hor->sliderPosition()+dx); } dragx_ = x; dragy_ = y; // notify of scene change sceneChanged(); }
void Pageview::slotPagePartChanged (const QModelIndex &index, const QImage &image, int scaled_linenum) { const Pagedelegate *del = (Pagedelegate *)itemDelegate (); QStyleOptionViewItem option = getViewOptions (); int hvalue = horizontalScrollBar()->value(); int vvalue = verticalScrollBar()->value(); QRect rect = rectForIndex (index); QRect part_rect; option.rect = rect; del->getPagePart (option, index, scaled_linenum, image.height (), part_rect); part_rect.translate (-hvalue, -vvalue); QWidget *vp = viewport (); // qDebug () << "repaint" << part_rect; // part_rect.setHeight (part_rect.height () - 1); // leave blank line (for testing!) // vp->repaint (part_rect); vp->update (part_rect); }
void ScrollArea::scrollToY(int toTop, int toBottom) { int toMin = 0, toMax = scrollTopMax(); if (toTop < toMin) { toTop = toMin; } else if (toTop > toMax) { toTop = toMax; } bool exact = (toBottom < 0); int curTop = scrollTop(), curHeight = height(), curBottom = curTop + curHeight, scToTop = toTop; if (!exact && toTop >= curTop) { if (toBottom < toTop) toBottom = toTop; if (toBottom <= curBottom) return; scToTop = toBottom - curHeight; if (scToTop > toTop) scToTop = toTop; if (scToTop == curTop) return; } else { scToTop = toTop; } verticalScrollBar()->setValue(scToTop); }
void gestureEvent(QGestureEvent *event) { QPanGesture *pan = static_cast<QPanGesture *>(event->gesture(Qt::PanGesture)); if (pan) { switch(pan->state()) { case Qt::GestureStarted: qDebug() << this << "Pan: started"; break; case Qt::GestureFinished: qDebug() << this << "Pan: finished"; break; case Qt::GestureCanceled: qDebug() << this << "Pan: canceled"; break; case Qt::GestureUpdated: break; default: qDebug() << this << "Pan: <unknown state>"; break; } if (pan->state() == Qt::GestureStarted) outside = false; event->ignore(); event->ignore(pan); if (outside) return; const QPointF delta = pan->delta(); const QPointF totalOffset = pan->offset(); QScrollBar *vbar = verticalScrollBar(); QScrollBar *hbar = horizontalScrollBar(); if ((vbar->value() == vbar->minimum() && totalOffset.y() > 10) || (vbar->value() == vbar->maximum() && totalOffset.y() < -10)) { outside = true; return; } if ((hbar->value() == hbar->minimum() && totalOffset.x() > 10) || (hbar->value() == hbar->maximum() && totalOffset.x() < -10)) { outside = true; return; } vbar->setValue(vbar->value() - delta.y()); hbar->setValue(hbar->value() - delta.x()); event->accept(pan); } }
void TracksView::initConnections() { connect(horizontalHeader(), SIGNAL(sectionResized(int,int,int)), this, SLOT(updateMainViewSectionWidth(int,int,int))); connect(verticalHeader(), SIGNAL(sectionResized(int,int,int)), this, SLOT(updateMainViewSectionHeight(int,int,int))); connect(verticalHeader(), SIGNAL(sectionMoved(int,int,int)), SLOT(onVSectionMove(int,int,int))); connect(horizontalHeader(), SIGNAL(sectionMoved(int,int,int)), SLOT(onHSectionMove(int,int,int))); connect(horizontalScrollBar(), SIGNAL(valueChanged(int)), _frozenHTableView->horizontalScrollBar(), SLOT(setValue(int))); connect(_frozenHTableView->horizontalScrollBar(), SIGNAL(valueChanged(int)), horizontalScrollBar(), SLOT(setValue(int))); connect(verticalScrollBar(), SIGNAL(valueChanged(int)), _frozenVTableView->verticalScrollBar(), SLOT(setValue(int))); connect(_frozenVTableView->verticalScrollBar(), SIGNAL(valueChanged(int)), verticalScrollBar(), SLOT(setValue(int))); }
ConsoleWidget::~ConsoleWidget() { output = toPlainText(); consoleWidget = 0; if(consoleView.loadAndSaveOutput) { QSettings& settings = RoboCupCtrl::application->getLayoutSettings(); settings.beginGroup(consoleView.fullName); settings.setValue("Output", output); QTextCursor cursor = textCursor(); settings.setValue("selectionStart", cursor.anchor()); settings.setValue("selectionEnd", cursor.position()); QScrollBar* scrollBar = verticalScrollBar(); settings.setValue("verticalScrollPosition", scrollBar->value()); settings.setValue("verticalScrollMaximum", scrollBar->maximum()); settings.endGroup(); output.clear(); } }
void ThumbnailView::rowsInserted( const QModelIndex &parent, int start, int end ) { QListView::rowsInserted( parent, start, end ); if( !Qtopia::mousePreferred() ) { if( !currentIndex().isValid() ) selectionModel()->setCurrentIndex( model()->index( 0, 0, parent ), QItemSelectionModel::ClearAndSelect ); } else selectionModel()->clearSelection(); QScrollBar *vScroll = verticalScrollBar(); int startY = visualRect( model()->index( start, 0 ) ).top(); int endY = visualRect( model()->index( end + 1, 0 ) ).top(); int scrollValue = vScroll->value() + endY - startY; if( startY <= 0 ) vScroll->setValue( scrollValue ); }
/** * @param x x coordinate * @param y y coordinate */ void CanvasView::moveDrag(int x, int y) { const int dx = _dragx - x; const int dy = _dragy - y; if(_isdragging==ROTATE) { qreal preva = qAtan2( width()/2 - _dragx, height()/2 - _dragy ); qreal a = qAtan2( width()/2 - x, height()/2 - y ); setRotation(rotation() + qRadiansToDegrees(preva-a)); } else { QScrollBar *ver = verticalScrollBar(); ver->setSliderPosition(ver->sliderPosition()+dy); QScrollBar *hor = horizontalScrollBar(); hor->setSliderPosition(hor->sliderPosition()+dx); } _dragx = x; _dragy = y; // notify of scene change sceneChanged(); }
QSize viewportSize( int w, int h ) const { const int sbHeight = horizontalScrollBar()->sizeHint().height(); const int sbWidth = verticalScrollBar()->sizeHint().width(); const int cw = contentsRect().width(); const int ch = contentsRect().height(); int vw = cw; int vh = ch; if ( w > vw ) vh -= sbHeight; if ( h > vh ) { vw -= sbWidth; if ( w > vw && vh == ch ) vh -= sbHeight; } return QSize( vw, vh ); }
/*!\brief reimplementation of the mouseMoveEvent * * ... */ void LaunchFileView::mouseMoveEvent(QMouseEvent *event) { /// Otherwise we get SegFault after adding an item and selecting Linemode before clicking once to the graphicsview if (_handScrolling) { QPoint delta = event->pos() - _handScrollingOrigin; horizontalScrollBar()->setValue(_handScrollingValueX - delta.x()); verticalScrollBar()->setValue(_handScrollingValueY - delta.y()); event->accept(); return; }else if (myMode == InsertLine && line != 0) { QLineF newLine(line->line().p1(), mapToScene(event->pos())); line->setLine(newLine); } else if (myMode == DragItem) { QGraphicsView::mouseMoveEvent(event); } else{ event->setAccepted(false); } }
void AMScanThumbnailGridView::scrollTo(const QModelIndex &index, QAbstractItemView::ScrollHint hint) { // Note: currently ignores the scroll hint. Places the corresponding scan as close to the top of // the view as is possible Q_UNUSED(hint); if(!index.isValid()) return; // If the passed index refers to a thumbnail (i.e. its parent is valid) then we need to // scrollTo the index of the parent scan if(index.parent().isValid()) { scrollTo(index.parent(), hint); return; } // Obtian the geometry of the index int itemCellIndex = index.row(); QRect indexCellGeometry = geometryManager_->cellGeometryAt(itemCellIndex, horizontalOffset(), verticalOffset()); verticalScrollBar()->setValue(indexCellGeometry.y()); horizontalScrollBar()->setValue(indexCellGeometry.x()); }
CurveView::CurveView(QWidget *parent) : QAbstractItemView(parent) { horizontalScrollBar()->setRange(0, 0); verticalScrollBar()->setRange(0, 0); /* Sizes */ m_nMargin = 10; m_nLabelSize[0] = 75; m_nLabelSize[1] = 15; m_nTickSize[0] = 64; m_nTickSize[1] = 2; m_nDrawAreaMinimum[0] = 256; m_nDrawAreaMinimum[1] = 100; m_nAxisArrow[0] = 3; m_nAxisArrow[1] = 3; m_nTickSpace[0] = 50; m_nTickSpace[1] = 20; m_nBase = -1; updateGeometries(); }
SmartList::SmartList(QWidget *parent) : QTreeView(parent) { verticalScrollBar()->hide(); connect(this, &QAbstractItemView::entered, [this](const QModelIndex & index) { auto widget = indexWidget(index); if (!widget) { ComBar* bar = new ComBar(); setIndexWidget(index, bar); connect(bar, &ComBar::btnVideoClicked, this, [=](){ emit btnVideoClicked(); }); } else if (index.isValid()) indexWidget(index)->setVisible(true); if(hoveredRow_.isValid() and indexWidget(hoveredRow_)) indexWidget(hoveredRow_)->setVisible(false); hoveredRow_ = index; }); setVerticalScrollMode(ScrollPerPixel); }