// Add a new blank anemometer after the selected or after the last if there is // no selection void AnemView::addAnem() { DEBUG_FUNC_NAME int currCol = currentIndex().column(); int lastCol = anemCount(); if (currCol == -1) currCol = lastCol; else ++currCol; // cast the model(), but it's not stricly necessary because // model() already returns the setModel() assigned to the view instance AnemModel *concreteModel = static_cast<AnemModel *>(model()); concreteModel->insertColumns(currCol, 1, QModelIndex()); updateGeometries(); concreteModel->flush(); setCurrentIndex(concreteModel->index(AnemModel::MANUFACTURER, currCol)); }
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(); }
bool WidgetBoxTreeWidget::load(QDesignerWidgetBox::LoadMode loadMode) { switch (loadMode) { case QDesignerWidgetBox::LoadReplace: clear(); break; case QDesignerWidgetBox::LoadCustomWidgetsOnly: addCustomCategories(true); updateGeometries(); return true; default: break; } const QString name = fileName(); QFile f(name); if (!f.open(QIODevice::ReadOnly)) // Might not exist at first startup return false; const QString contents = QString::fromUtf8(f.readAll()); return loadContents(contents); }
/* SearchLineEdit is an enhanced QLineEdit - A Search icon on the left with optional menu - When there is no text and doesn't have focus an "inactive text" is displayed - When there is text a clear button is displayed on the right hand side */ SearchLineEdit::SearchLineEdit(QWidget *parent) : LineEdit(parent) , m_searchButton(0) { setUpdatesEnabled(false); m_searchButton = new SearchButton(this); updateGeometries(); addWidget(m_searchButton, LeftSide); m_inactiveText = tr("Search"); QSizePolicy policy = sizePolicy(); setSizePolicy(QSizePolicy::Preferred, policy.verticalPolicy()); // clear button on the right ClearButton *m_clearButton = new ClearButton(this); connect(m_clearButton, SIGNAL(clicked()), this, SLOT(clear())); connect(this, SIGNAL(textChanged(const QString&)), m_clearButton, SLOT(textChanged(const QString&))); addWidget(m_clearButton, RightSide); m_clearButton->hide(); updateTextMargins(); setUpdatesEnabled(true); }
//----------------------------------------------------------------------------- void vktraceviewer_QTimelineView::scrollContentsBy(int dx, int dy) { deletePixmap(); if (dy != 0) { QPoint pos = m_mousePosition; int focusX = pos.x(); if (pos.isNull()) { // If the mouse position is NULL (ie, the mouse is not in the viewport) // zooming will happen around the center of the timeline focusX = (viewport()->width() - m_scrollBarWidth) / 2; } int x = focusX + horizontalScrollBar()->value(); float wx = (float)x / m_zoomFactor; // The zoom factor is a smoothed interpolation (based on the vertical scroll bar value and max) // between the m_durationToViewportScale (which fits the entire timeline into the viewport width) // and m_maxZoom (which is initialized to 1/1000) float zoomRatio = (float)verticalScrollBar()->value() / (float)verticalScrollBar()->maximum(); zoomRatio = 1-cos(zoomRatio*M_PI_2); float diff = m_maxZoom - m_durationToViewportScale; m_zoomFactor = m_durationToViewportScale + zoomRatio * diff; updateGeometries(); int newValue = (wx * m_zoomFactor) - focusX; horizontalScrollBar()->setValue(newValue); } viewport()->update(); // scrollDirtyRegion(dx, 0); // viewport()->scroll(dx, 0); }
//----------------------------------------------------------------------------- void vktraceviewer_QTimelineView::resizeEvent(QResizeEvent *event) { m_hashIsDirty = true; deletePixmap(); // The duration to viewport scale should allow us to map the entire timeline into the current window width. if (m_lineLength > 0) { // Calculate zoom ratio prior to the resize float ratio = m_zoomFactor / m_durationToViewportScale; // Adjust scale that fits the timeline duration to the viewport area int timelineViewportWidth = viewport()->width() - 2*m_margin - m_scrollBarWidth; m_durationToViewportScale = (float)timelineViewportWidth / u64ToFloat(m_lineLength); // Adjust the zoom factor based on the new duration to viewport scale and the previous ratio m_zoomFactor = m_durationToViewportScale * ratio; // Adjust horizontal scroll bar to maintain current view as best as possible float hRatio = (float)horizontalScrollBar()->value() / qMax(1.0f,(float)horizontalScrollBar()->maximum()); updateGeometries(); horizontalScrollBar()->setValue(hRatio * horizontalScrollBar()->maximum()); } }
void LinearView::resizeEvent(QResizeEvent * /* event */) { updateGeometries(); }
void Ui::Ui_MainWindow::setupUi(){ raw = 0; if (this->objectName().isEmpty()) this->setObjectName(QString::fromUtf8("MainWindow")); QSettings settings(QSettings::IniFormat, QSettings::UserScope,"brainpower", "bp-nfoview"); settings.setDefaultFormat(QSettings::IniFormat); resize(settings.value("general/width", 680).toInt(),settings.value("general/height", 720).toInt()); QIcon mainIcon(":/img/logo.png"); setWindowIcon(mainIcon); actionOpen = new QAction(this); actionOpen->setObjectName(QString::fromUtf8("actionOpen")); actionOpen->setShortcut(QKeySequence(QKeySequence::Open)); actionSaveImage = new QAction(this); actionQuit = new QAction(this); actionQuit->setObjectName(QString::fromUtf8("actionQuit")); actionQuit->setShortcut(QKeySequence(QKeySequence::Quit)); actionAbout = new QAction(this); actionAbout->setObjectName(QString::fromUtf8("actionAbout")); actionSB = new QAction(this); actionSB->setObjectName(QString::fromUtf8("actionSB")); actionSB->setCheckable(true); actionColor = new QAction(this); actionDefaultColor = new QAction(this); actionFont = new QAction(this); actionDefaultFont = new QAction(this); actionCodecUTF8 = new QAction(this); actionCodecUTF8->setCheckable(true); actionCodecCP437 = new QAction(this); actionCodecCP437->setCheckable(true); agCodec = new QActionGroup(this); actionCodecUTF8->setActionGroup(agCodec); actionCodecCP437->setActionGroup(agCodec); centralwidget = new QWidget(this); centralwidget->setObjectName(QString::fromUtf8("centralwidget")); textEdit = new QTextEdit(centralwidget); textEdit->setObjectName(QString::fromUtf8("textEdit")); textEdit->setGeometry(QRect(0, 0, 671, 641)); //sizePolicy.setHeightForWidth(textEdit->sizePolicy().hasHeightForWidth()); //textEdit->setSizePolicy(sizePolicy); //QFont font = defaultFont; defaultFont.setFamily(QString::fromUtf8("DejaVu Sans Mono")); defaultFont.setPointSize(10); defaultFont.setStyleHint(QFont::Monospace); cFont = settings.value("GUI/font", defaultFont).value<QFont>(); textEdit->setFont(cFont); textEdit->setAcceptDrops(false); textEdit->setFrameShape(QFrame::NoFrame); textEdit->setFrameShadow(QFrame::Plain); textEdit->setUndoRedoEnabled(false); textEdit->setReadOnly(true); textEdit->setLineWrapMode(QTextEdit::NoWrap); textEdit->setPalette(settings.value("GUI/colors", defaultPalette).value<QPalette>()); //defaultPalette = textEdit->palette(); setCentralWidget(centralwidget); menubar = new QMenuBar(this); menubar->setObjectName(QString::fromUtf8("menubar")); menubar->setGeometry(QRect(0, 0, 682, 28)); menuFile = new QMenu(menubar); menuFile->setObjectName(QString::fromUtf8("menuFile")); menuView = new QMenu(menubar); menuViewCodec = new QMenu(menuView); menuHelp = new QMenu(menubar); menuHelp->setObjectName(QString::fromUtf8("menuHelp")); setMenuBar(menubar); statusbar = new QStatusBar(this); statusbar->setObjectName(QString::fromUtf8("statusbar")); //statusbar->setBackgroundRole(QPalette::Highlight); //statusbar->setAutoFillBackground(true); setStatusBar(statusbar); if(settings.value("general/sb", 23) == 23){ actionSB->setChecked(true); sboffset = 23; } else{ sboffset = 0; SBaction(false); } menubar->addAction(menuFile->menuAction()); menubar->addAction(menuView->menuAction()); menubar->addAction(menuHelp->menuAction()); menuFile->addAction(actionOpen); menuFile->addAction(actionSaveImage); menuFile->addAction(actionQuit); menuView->addAction(actionSB); menuView->addAction(actionColor); menuView->addAction(actionDefaultColor); menuView->addAction(actionFont); menuView->addAction(actionDefaultFont); menuView->addAction(menuViewCodec->menuAction()); menuHelp->addAction(actionAbout); menuViewCodec->addAction(actionCodecCP437); menuViewCodec->addAction(actionCodecUTF8); retranslateUi(); updateGeometries(); connect(actionSB, SIGNAL(toggled(bool)),this, SLOT(SBaction(bool))); connect(actionQuit, SIGNAL(triggered()),qApp, SLOT(quit())); connect(actionOpen, SIGNAL(triggered()),this, SLOT(OpenAction())); connect(actionAbout, SIGNAL(triggered()),this, SLOT(AboutAction())); connect(actionColor, SIGNAL(triggered()),this, SLOT(ColorAction())); connect(actionDefaultColor, SIGNAL(triggered()),this, SLOT(DefaultColorAction())); connect(actionFont, SIGNAL(triggered()),this, SLOT(FontAction())); connect(actionDefaultFont, SIGNAL(triggered()),this, SLOT(DefaultFontAction())); connect(actionSaveImage, SIGNAL(triggered()),this,SLOT(saveImageAction())); connect(actionCodecUTF8, SIGNAL(triggered()), this, SLOT(switchCodecUTF8Action())); connect(actionCodecCP437, SIGNAL(triggered()), this, SLOT(switchCodecCP437Action())); QMetaObject::connectSlotsByName(this); } // setupUi
void KNMusicAlbumView::paintEvent(QPaintEvent *event) { Q_UNUSED(event) //Initial the painter. QPainter painter(viewport()); painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, true); //Get the option view item. QStyleOptionViewItem option=viewOptions(); //Check if we need to paint the background. if(autoFillBackground()) { painter.fillRect(rect(), option.palette.base()); } //Update the parameters of the view first. updateParameters(); //Check the model first. if(m_proxyModel==nullptr) { return; } //Get the row count. int albumCount=m_proxyModel->rowCount(); //Calculate the line count. m_lineCount=(albumCount+m_maxColumnCount-1)/m_maxColumnCount; //Check the album count first. if(albumCount==0) { return; } int currentColumn=0, currentLeft=m_spacing, currentLine=verticalScrollBar()->value()/m_itemSpacingHeight, //Skip the before. currentTop=m_spacing+currentLine*m_itemSpacingHeight, currentRow=currentLine*m_maxColumnCount, heightSurplus=height()+m_itemSpacingHeight; //Change the origin of coordinate. painter.translate(0, -verticalScrollBar()->value()); //Draw all the albums. while(currentRow < albumCount && heightSurplus > 0) { //Get the source index of the item. QModelIndex proxyIndex=m_proxyModel->index(currentRow, 0); //If the source index is not the current index, then draw the album. if(m_proxyModel->mapToSource(proxyIndex)!=m_selectedIndex) { paintAlbum(painter, QPoint(currentLeft, currentTop), proxyIndex); } //Add current row and column. currentRow++; currentColumn++; //Check if we need to move to next row. if(currentColumn>=m_maxColumnCount) { //Add one line. currentLine++; //Reset the column. currentColumn=0; //Change the position. currentLeft=m_spacing; currentTop+=m_itemSpacingHeight; heightSurplus-=m_itemSpacingHeight; } else { //Move to next column position. currentLeft+=m_itemSpacingWidth; } } //Update the scroll bar value. updateGeometries(); }
void WLibraryTableView::setVScrollBarPosState(int position){ updateGeometries(); verticalScrollBar()->setValue(position); }
void ExLineEdit::resizeEvent(QResizeEvent *event) { updateGeometries(); QWidget::resizeEvent(event); }
void KNMusicAlbumView::paintEvent(QPaintEvent *event) { Q_UNUSED(event) //Initial the painter. QPainter painter(viewport()); painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, true); //Check if we need to paint the background. if(autoFillBackground()) { painter.fillRect(rect(), viewOptions().palette.base()); } //Check the model first. if(m_proxyModel==nullptr) { return; } //Get the row count. int albumCount=m_proxyModel->rowCount(); //Check the album count first. if(albumCount==0) { return; } //Calculate the line count. m_lineCount=(albumCount+m_maxColumnCount-1)/m_maxColumnCount; //Generate the parameters. int currentColumn=0, currentLeft=m_spacing, currentLine=verticalScrollBar()->value()/m_itemSpacingHeight, currentTop=m_spacing+currentLine*m_itemSpacingHeight, currentRow=currentLine*m_maxColumnCount, heightSurplus=height()+m_itemSpacingHeight; /* * currentColumn * | * +-------------------------------------------------+ * | +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ | * | | | | | | | | | | | | | | | | | | * | +---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+ | * | | * | +---+ +---+ xxxxx-currentTop | * | | | | | xxxxx | - currentLine * | +---+ +---+ xxxxx | * | | | | -+ * | currentLeft-+ | | | * | +--QModelIndex(25252, 0) | | * | | | | * | currentRow | +-heightSurplus * | | | * | | | * | | | * +-------------------------------------------------+ -+ */ //Change the origin of coordinate. painter.translate(0, -verticalScrollBar()->value()); //Draw all the albums, until there's no album left, no height surplus. while(currentRow < albumCount && heightSurplus > 0) { //Get the source index of the item. QModelIndex &&proxyIndex=m_proxyModel->index(currentRow, 0); //If the source index is not the current index, then draw the album. if(m_proxyModel->mapToSource(proxyIndex)!=m_selectedIndex) { //Draw the unselect album. paintAlbum(painter, currentLeft, currentTop, proxyIndex); } //Add current row to the next album model row. ++currentRow; //Add current column to the next position. ++currentColumn; //Check if we need to move to next row. if(currentColumn>=m_maxColumnCount) { //Add current line. ++currentLine; //Reset the column. currentColumn=0; //Change the position. currentLeft=m_spacing; currentTop+=m_itemSpacingHeight; heightSurplus-=m_itemSpacingHeight; } else { //Move to next column position. currentLeft+=m_itemSpacingWidth; } } //Update the scroll bar value. updateGeometries(); }
void SearchLineEdit::resizeEvent(QResizeEvent *e) { updateGeometries(); ExLineEdit::resizeEvent(e); }
void Ui::Ui_MainWindow::resizeEvent(QResizeEvent*){ updateGeometries(); } // resizeEvent
void SearchLineEdit::resizeEvent(QResizeEvent *event) { updateGeometries(); LineEdit::resizeEvent(event); }
void TiledListView::resizeEvent(QResizeEvent*) { hashIsDirty = true; calculateRectsIfNecessary(); updateGeometries(); }
void ImageView::resizeEvent(QResizeEvent*) { updateGeometries(); }
int QAbstractItemView::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QAbstractScrollArea::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: pressed((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 1: clicked((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 2: doubleClicked((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 3: activated((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 4: entered((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 5: viewportEntered(); break; case 6: reset(); break; case 7: setRootIndex((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 8: doItemsLayout(); break; case 9: selectAll(); break; case 10: edit((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 11: clearSelection(); break; case 12: setCurrentIndex((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 13: scrollToTop(); break; case 14: scrollToBottom(); break; case 15: update((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 16: dataChanged((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< const QModelIndex(*)>(_a[2]))); break; case 17: rowsInserted((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 18: rowsAboutToBeRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 19: selectionChanged((*reinterpret_cast< const QItemSelection(*)>(_a[1])),(*reinterpret_cast< const QItemSelection(*)>(_a[2]))); break; case 20: currentChanged((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< const QModelIndex(*)>(_a[2]))); break; case 21: updateEditorData(); break; case 22: updateEditorGeometries(); break; case 23: updateGeometries(); break; case 24: verticalScrollbarAction((*reinterpret_cast< int(*)>(_a[1]))); break; case 25: horizontalScrollbarAction((*reinterpret_cast< int(*)>(_a[1]))); break; case 26: verticalScrollbarValueChanged((*reinterpret_cast< int(*)>(_a[1]))); break; case 27: horizontalScrollbarValueChanged((*reinterpret_cast< int(*)>(_a[1]))); break; case 28: closeEditor((*reinterpret_cast< QWidget*(*)>(_a[1])),(*reinterpret_cast< QAbstractItemDelegate::EndEditHint(*)>(_a[2]))); break; case 29: commitData((*reinterpret_cast< QWidget*(*)>(_a[1]))); break; case 30: editorDestroyed((*reinterpret_cast< QObject*(*)>(_a[1]))); break; case 31: d_func()->_q_columnsAboutToBeRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 32: d_func()->_q_columnsRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 33: d_func()->_q_rowsRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 34: d_func()->_q_modelDestroyed(); break; case 35: d_func()->_q_layoutChanged(); break; case 36: d_func()->_q_fetchMore(); break; } _id -= 37; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< bool*>(_v) = hasAutoScroll(); break; case 1: *reinterpret_cast< int*>(_v) = autoScrollMargin(); break; case 2: *reinterpret_cast<int*>(_v) = QFlag(editTriggers()); break; case 3: *reinterpret_cast< bool*>(_v) = tabKeyNavigation(); break; case 4: *reinterpret_cast< bool*>(_v) = showDropIndicator(); break; case 5: *reinterpret_cast< bool*>(_v) = dragEnabled(); break; case 6: *reinterpret_cast< bool*>(_v) = dragDropOverwriteMode(); break; case 7: *reinterpret_cast< DragDropMode*>(_v) = dragDropMode(); break; case 8: *reinterpret_cast< bool*>(_v) = alternatingRowColors(); break; case 9: *reinterpret_cast< SelectionMode*>(_v) = selectionMode(); break; case 10: *reinterpret_cast< SelectionBehavior*>(_v) = selectionBehavior(); break; case 11: *reinterpret_cast< QSize*>(_v) = iconSize(); break; case 12: *reinterpret_cast< Qt::TextElideMode*>(_v) = textElideMode(); break; case 13: *reinterpret_cast< ScrollMode*>(_v) = verticalScrollMode(); break; case 14: *reinterpret_cast< ScrollMode*>(_v) = horizontalScrollMode(); break; } _id -= 15; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setAutoScroll(*reinterpret_cast< bool*>(_v)); break; case 1: setAutoScrollMargin(*reinterpret_cast< int*>(_v)); break; case 2: setEditTriggers(QFlag(*reinterpret_cast<int*>(_v))); break; case 3: setTabKeyNavigation(*reinterpret_cast< bool*>(_v)); break; case 4: setDropIndicatorShown(*reinterpret_cast< bool*>(_v)); break; case 5: setDragEnabled(*reinterpret_cast< bool*>(_v)); break; case 6: setDragDropOverwriteMode(*reinterpret_cast< bool*>(_v)); break; case 7: setDragDropMode(*reinterpret_cast< DragDropMode*>(_v)); break; case 8: setAlternatingRowColors(*reinterpret_cast< bool*>(_v)); break; case 9: setSelectionMode(*reinterpret_cast< SelectionMode*>(_v)); break; case 10: setSelectionBehavior(*reinterpret_cast< SelectionBehavior*>(_v)); break; case 11: setIconSize(*reinterpret_cast< QSize*>(_v)); break; case 12: setTextElideMode(*reinterpret_cast< Qt::TextElideMode*>(_v)); break; case 13: setVerticalScrollMode(*reinterpret_cast< ScrollMode*>(_v)); break; case 14: setHorizontalScrollMode(*reinterpret_cast< ScrollMode*>(_v)); break; } _id -= 15; } else if (_c == QMetaObject::ResetProperty) { _id -= 15; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 15; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 15; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 15; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 15; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 15; } #endif // QT_NO_PROPERTIES return _id; }
void WLibraryTableView::restoreVScrollBarPos() { //Restore the scrollbar's position (scroll to that spot) //when the search has been cleared updateGeometries(); verticalScrollBar()->setValue(m_iSavedVScrollBarPos); }
void PieView::resizeEvent(QResizeEvent * /* event */) { updateGeometries(); }
void SearchLineEdit::setMenu(QMenu *menu) { if (searchButton->m_menu) searchButton->m_menu->deleteLater(); searchButton->m_menu = menu; updateGeometries(); }
void ExLineEdit::resizeEvent(QResizeEvent *event) { Q_ASSERT(m_leftWidget); updateGeometries(); QWidget::resizeEvent(event); }
inline void tst_updateGeometries() { updateGeometries(); }