void HexView::paintOffsets(QPainter *painter, int &left,int first, int last) { QPen pen; for (int i=first; i<=last ; ++i) { QRect offsets(left,rowHeight() * i,offsetsWidth(),rowHeight()); if (showGuidelines_) { pen.setColor(Qt::green); painter->setPen(pen); painter->drawRect(offsets); } pen.setColor(Qt::black); painter->setPen(pen); QString offset = getHexNumber(i * bytesPerRow(),offsetLen(),true); painter->drawText( offsets ,Qt::AlignCenter ,offset ); } left += offsetsWidth(); if (showGuidelines_) { QRect space(left,0,spacer() ,contentHeight()); pen.setColor(Qt::blue); painter->setPen(pen); painter->drawRect(space); } left += spacer(); }
QRectF ODrawClient::getRect(const MSO::OfficeArtClientAnchor& clientAnchor) { const MSO::XlsOfficeArtClientAnchor* anchor = clientAnchor.anon.get<MSO::XlsOfficeArtClientAnchor>(); if (anchor) { QRectF r; qreal colWidth = columnWidth(m_sheet, anchor->colL); r.setLeft(offset(colWidth, anchor->dxL, 1024)); if (anchor->colR == anchor->colL) { r.setRight(offset(colWidth, anchor->dxR, 1024)); } else { qreal width = colWidth - r.left(); for (int col = anchor->colL + 1; col < anchor->colR; ++col) { width += columnWidth(m_sheet, col); } width += offset(columnWidth(m_sheet, anchor->colR), anchor->dxR, 1024); r.setWidth(width); } qreal rowHgt = rowHeight(m_sheet, anchor->rwT); r.setTop(offset(rowHgt, anchor->dyT, 256)); if (anchor->rwT == anchor->rwB) { r.setBottom(offset(rowHgt, anchor->dyB, 256)); } else { qreal height = rowHgt - r.top(); for (int row = anchor->rwT + 1; row < anchor->rwB; ++row) { height += rowHeight(m_sheet, row); } height += offset(rowHeight(m_sheet, anchor->rwB), anchor->dyB, 256); r.setHeight(height); } return r; } else { qDebug() << "Invalid client anchor!"; } return QRectF(); }
void KWQTableView::adjustRow(int row) { // we want to make the row high enough to display content, but // if the user already made it even higher we keep that height //int r = currentIndex().row(); int rh = rowHeight(row); resizeRowToContents(row); if (rh > rowHeight(row)) setRowHeight(row, rh); }
QSize PlaylistHeaderView::sectionSizeFromContents(int logicalIndex) const { if (logicalIndex == 5) { QSize s = QHeaderView::sectionSizeFromContents(logicalIndex); auto playlist = qobject_cast<Playlist*>(parentWidget()); if (playlist->rowHeight(0) != 0) { s.setWidth(5 * playlist->rowHeight(0)); } return s; } return QHeaderView::sectionSizeFromContents(logicalIndex); }
void MusicQueryTableWidget::paintEvent(QPaintEvent *event) { MusicAbstractTableWidget::paintEvent(event); QPainter painter(viewport()); painter.setRenderHint(QPainter::Antialiasing, true); painter.setPen(QPen(QBrush(QColor(0, 0, 0)), 0.1, Qt::SolidLine)); for(int i=0; i<rowCount(); ++i) { painter.drawLine(10, rowHeight(0)*(i + 1), width() - 15, rowHeight(0)*(i + 1)); } }
void IrgaTableView::showEvent(QShowEvent *event) { setViewportMargins(m_header->sizeHint().width() - 2, rowHeight(0) + 2, 0, 0); m_header->setGeometry(0, static_cast<int>(rowHeight(0) / 2.0) + 2, m_header->sizeHint().width() + 10, rowHeight(0) * m_header->sectionCount()); horizontalHeader()->setMinimumWidth(horizontalHeader()->count() * horizontalHeader()->sectionSize(1)); horizontalScrollBar()->setMaximum((horizontalHeader()->count() - 1) * horizontalHeader()->sectionSize(1)); horizontalScrollBar()->updateGeometry(); viewport()->update(); QWidget::showEvent(event); }
void HexView::paintAscii(QPainter *painter, int &left,int first, int last) { for (int i=first ;i<=last;++i) { for (int j=0;j<bytesPerRow_;++j) { int validx = (i * bytesPerRow()) + j; if (validx < contentLength_) { int valueint = value(validx); QRectF ascii(left + (j * asciiSpacer()),i * rowHeight(),asciiSpacer(),rowHeight()); QPen pen; pen.setColor(Qt::black); painter->setPen(pen); if (std::isprint(valueint)) { QChar c(valueint); painter->drawText( ascii ,Qt::AlignCenter,QString(c) ); } else { painter->drawText( ascii ,Qt::AlignCenter,"." ); } } } } }
QSize QwtDynGridLayout::sizeHint() const { if ( isEmpty() ) return QSize(); const uint numCols = (d_data->maxCols > 0 ) ? d_data->maxCols : itemCount(); uint numRows = itemCount() / numCols; if ( itemCount() % numCols ) numRows++; QwtArray<int> rowHeight(numRows); QwtArray<int> colWidth(numCols); layoutGrid(numCols, rowHeight, colWidth); int h = 2 * margin() + (numRows - 1) * spacing(); for ( int row = 0; row < (int)numRows; row++ ) h += rowHeight[row]; int w = 2 * margin() + (numCols - 1) * spacing(); for ( int col = 0; col < (int)numCols; col++ ) w += colWidth[col]; return QSize(w, h); }
QSize ActivityItemDelegate::sizeHint(const QStyleOptionViewItem & option , const QModelIndex & /* index */) const { QFont font = option.font; return QSize( 0, rowHeight() ); }
int CalculationController::indexFromCumulatedHeight(KDCoordinate offsetY) { KDCoordinate height = rowHeight(0); if (height == 0) { return 0; } return (offsetY - 1) / height; }
KDCoordinate TableViewDataSource::cumulatedHeightFromIndex(int j) { int result = 0; for (int k = 0; k < j; k++) { result += rowHeight(k); } return result; }
int ToolTipWidget::computeHeight(const QModelIndex &index) const { int s = rowHeight(index); for (int i = 0; i < model()->rowCount(index); ++i) s += computeHeight(model()->index(i, 0, index)); return s; }
void KoTableRowStyle::saveOdf(KoGenStyle &style) const { QList<int> keys = d->stylesPrivate.keys(); foreach(int key, keys) { if (key == QTextFormat::BackgroundBrush) { QBrush backBrush = background(); if (backBrush.style() != Qt::NoBrush) style.addProperty("fo:background-color", backBrush.color().name(), KoGenStyle::TableRowType); else style.addProperty("fo:background-color", "transparent", KoGenStyle::TableRowType); } else if (key == MinimumRowHeight) { style.addPropertyPt("style:min-row-height", minimumRowHeight(), KoGenStyle::TableRowType); } else if (key == RowHeight) { style.addPropertyPt("style:row-height", rowHeight(), KoGenStyle::TableRowType); } else if (key == UseOptimalHeight) { style.addProperty("style:use-optimal-row-height", useOptimalHeight(), KoGenStyle::TableRowType); } else if (key == BreakBefore) { style.addProperty("fo:break-before", KoText::textBreakToString(breakBefore()), KoGenStyle::TableRowType); } else if (key == BreakAfter) { style.addProperty("fo:break-after", KoText::textBreakToString(breakAfter()), KoGenStyle::TableRowType); } else if (key == KeepTogether) { if (keepTogether()) style.addProperty("fo:keep-together", "always", KoGenStyle::TableRowType); else style.addProperty("fo:keep-together", "auto", KoGenStyle::TableRowType); } } }
void cCustomShotTable::mouseMoveEvent(QMouseEvent *event) { if (IsDragOn!=1) { setCursor(Qt::ArrowCursor); QTableWidget::mouseMoveEvent(event); } else { if ((columnCount()==0)||(DiaporamaObject==NULL)) return; int ThumbHeight=rowHeight(0); int ThumbWidth =columnWidth(0); int NbrX =width()/ThumbWidth; int NbrY =height()/ThumbHeight; if (NbrY>rowCount()) NbrY=rowCount(); int ToUse =DragItemDest; if (DragItemDest==columnCount()) ToUse--; // Try to scroll left if ((event->pos().x()<0)&&(horizontalScrollBar()->value()>0)) horizontalScrollBar()->setValue(horizontalScrollBar()->value()-1); // Try to scroll right else if ((event->pos().x()>=NbrX*ThumbWidth)&&(horizontalScrollBar()->value()<horizontalScrollBar()->maximum())) horizontalScrollBar()->setValue(horizontalScrollBar()->value()+1); else { // Get item number under mouse int Selected=(event->pos().x()+horizontalOffset())/ThumbWidth; if ((Selected>NbrItem())||(Selected==DragItemSource)||((Selected==DragItemSource+1)&&(Selected!=NbrItem()))) { DragItemDest=-1; setCursor(Qt::ForbiddenCursor); } else { setCursor(Qt::ClosedHandCursor); DragItemDest=Selected; } } // Force a repaint setUpdatesEnabled(false); setUpdatesEnabled(true); } }
int TracksView::frozenRowHeight() { int height = 0; for (int row = 0; row != _frozenRowCount; ++row) height += rowHeight(row); return height; }
static void vscrollto(struct table *t, intptr_t newpos) { SCROLLINFO si; RECT scrollArea; if (newpos < 0) newpos = 0; if (newpos > (t->count - t->pagesize)) newpos = (t->count - t->pagesize); scrollArea = realClientRect(t); // negative because ScrollWindowEx() is "backwards" if (ScrollWindowEx(t->hwnd, 0, (-(newpos - t->firstVisible)) * rowHeight(t), &scrollArea, &scrollArea, NULL, NULL, SW_ERASE | SW_INVALIDATE) == ERROR) abort(); t->firstVisible = newpos; ZeroMemory(&si, sizeof (SCROLLINFO)); si.cbSize = sizeof (SCROLLINFO); si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE; si.nPage = t->pagesize; si.nMin = 0; si.nMax = t->count - 1; // nMax is inclusive si.nPos = t->firstVisible; SetScrollInfo(t->hwnd, SB_VERT, &si, TRUE); }
int TableViewDataSource::indexFromCumulatedHeight(KDCoordinate offsetY) { int result = 0; int j = 0; while (result < offsetY && j < numberOfRows()) { result += rowHeight(j++); } return (result < offsetY || offsetY == 0) ? j : j - 1; }
void CTableView::adjustSizeToContents() { resizeColumnsToContents(); resizeRowsToContents(); int32_t h = rowHeight(1) * model()->rowCount() + 2; int32_t w = columnWidth(1) * model()->columnCount() + 2; setFixedSize(w, h); }
QList<QRect> QwtDynGridLayout::layoutItems( const QRect &rect, uint numCols ) const { QList<QRect> itemGeometries; if ( numCols == 0 || isEmpty() ) return itemGeometries; uint numRows = itemCount() / numCols; if ( numRows % itemCount() ) numRows++; QVector<int> rowHeight( numRows ); QVector<int> colWidth( numCols ); layoutGrid( numCols, rowHeight, colWidth ); bool expandH, expandV; expandH = expandingDirections() & Qt::Horizontal; expandV = expandingDirections() & Qt::Vertical; if ( expandH || expandV ) stretchGrid( rect, numCols, rowHeight, colWidth ); const int maxCols = d_data->maxCols; d_data->maxCols = numCols; const QRect alignedRect = alignmentRect( rect ); d_data->maxCols = maxCols; const int xOffset = expandH ? 0 : alignedRect.x(); const int yOffset = expandV ? 0 : alignedRect.y(); QVector<int> colX( numCols ); QVector<int> rowY( numRows ); const int xySpace = spacing(); rowY[0] = yOffset + margin(); for ( int r = 1; r < ( int )numRows; r++ ) rowY[r] = rowY[r-1] + rowHeight[r-1] + xySpace; colX[0] = xOffset + margin(); for ( int c = 1; c < ( int )numCols; c++ ) colX[c] = colX[c-1] + colWidth[c-1] + xySpace; const int itemCount = d_data->itemList.size(); for ( int i = 0; i < itemCount; i++ ) { const int row = i / numCols; const int col = i % numCols; QRect itemGeometry( colX[col], rowY[row], colWidth[col], rowHeight[row] ); itemGeometries.append( itemGeometry ); } return itemGeometries; }
ConstraintTable::ConstraintTable(QWidget * parent, ConstraintCanvas * c) : Q3Table(c->elements.count(), 4, parent) { setSorting(true); setSelectionMode(NoSelection); setRowMovingEnabled(FALSE); horizontalHeader()->setLabel(0, TR("visible")); horizontalHeader()->setLabel(1, " "); horizontalHeader()->setLabel(2, TR("element")); horizontalHeader()->setLabel(3, TR("constraint")); setColumnStretchable(0, FALSE); setColumnStretchable(1, FALSE); int row; bool v = c->indicate_visible; Q3ValueList<BrowserNode *> & hv = c->hidden_visible; BrowserNodeList & elts = c->elements; BrowserNode * bn; QString yes = TR(" yes"); QString empty; elts.sort(); for (bn = elts.first(), row = 0; bn != 0; bn = elts.next(), row += 1) { if ((v) ? hv.findIndex(bn) != -1 : hv.findIndex(bn) == -1) setText(row, 0, yes); setPixmap(row, 1, *(bn->pixmap(0))); TableItem * ti; ti = new TableItem(this, Q3TableItem::Never, bn->full_name(TRUE)); ti->setReplaceable(FALSE); setItem(row, 2, ti); QString s = toUnicode(bn->constraint()); int n = s.count('\n'); ti = new TableItem(this, Q3TableItem::Never, s); ti->setReplaceable(FALSE); setItem(row, 3, ti); if (n != 0) { // note : adjustRow(row) does nothing setRowHeight(row, rowHeight(row) * (n + 1)); } } adjustColumn(0); adjustColumn(1); setColumnStretchable(2, TRUE); setColumnStretchable(3, TRUE); connect(this, SIGNAL(pressed(int, int, int, const QPoint &)), this, SLOT(button_pressed(int, int, int, const QPoint &))); }
int NTrashTree::calculateHeightRec(QTreeWidgetItem * item) { if(!item) return 0; QModelIndex index = indexFromItem(item); if(!item->isExpanded()) { return rowHeight(index); } int h = item->sizeHint(0).height() + 2 + rowHeight(index); int childCount = item->childCount(); for(int i = 0; i<childCount; i++) { h += calculateHeightRec(item->child(i)); } return h; }
void HexView::paintHex(QPainter *painter, int &left,int first, int last) { QPen pen; for (int i=first ;i<=last;++i) { for (int j=0;j<bytesPerRow_;++j) { int validx = (i * bytesPerRow()) + j; if (validx < contentLength_) { int valueint = value(validx); QRectF hex(left + (j * hexSpacer()),i * rowHeight() , hexSpacer(),rowHeight()); if (showGuidelines_) { pen.setColor(Qt::green); painter->setPen(pen); painter->drawRect(hex); } QString valuestr = getHexNumber(valueint,2); pen.setColor(Qt::black); painter->setPen(pen); painter->drawText( hex ,Qt::AlignCenter,valuestr ); } } } left += (bytesPerRow() * hexSpacer()); if (showGuidelines_) { QRect space(left,0,spacer() ,contentHeight()); pen.setColor(Qt::blue); painter->setPen(pen); painter->drawRect(space); } left += spacer(); }
//----------------------------------------------------------------------------- //! //----------------------------------------------------------------------------- void tAbstractChannelTable::resizeEvent(QResizeEvent* pEvent) { TRACE_FUNCTION; QSize s = pEvent->size(); m_RowHeight = rowHeight(0); m_TotalVisibleHeight = s.height(); QTableWidget::resizeEvent(pEvent); // qDebug("tAbstractChannelTable::resizeEvent height = %d\n", m_TotalVisibleHeight); }
void PageItem_Table::distributeRows(int startRow, int endRow) { if (startRow < 0 || endRow > rows() - 1 || startRow > endRow) return; const int numRows = endRow - startRow + 1; const double newHeight = (rowPosition(endRow) + rowHeight(endRow) - rowPosition(startRow)) / numRows; for (int row = startRow; row <= endRow; ++row) resizeRow(row, newHeight); }
void QCustomTableWidget::scrollTo(int row, int column) { repaint(); int row_count = rowCount(), column_count = columnCount(); if (row > -1 && row < row_count) { int y = rowViewportPosition(row); QScrollBar *bar = verticalScrollBar(); if (y < 0) { bar->setValue(bar->value()+y); } else { int dy = y + rowHeight(row) - viewport()->height(); if (columnViewportPosition(column_count-1) + columnWidth(column_count-1) > viewport()->width()) { dy += horizontalScrollBar()->height() + 3; } if (dy > 0) { int value = bar->value() + dy; if (value > bar->maximum()) { bar->setMaximum(value); } bar->setValue(value); } } } if (column > -1 && column < column_count) { int x = columnViewportPosition(column); QScrollBar *bar = horizontalScrollBar(); if (x < 0) { bar->setValue(bar->value()+x); } else { int dx = x + columnWidth(column) - viewport()->width(); if (dx > 0) { int value = bar->value() + dx; if (value > bar->maximum()) { bar->setMaximum(value); } bar->setValue(value); } } } }
ConstraintTable::ConstraintTable(QWidget * parent, ConstraintCanvas * c) : QTableWidget(c->elements.count(), 4, parent) { setSelectionMode(NoSelection); //setSortingEnabled(true); verticalHeader()->setSectionsMovable(false); QStringList headerLabels; headerLabels<<tr("visible") <<" " <<tr("element") <<tr("constraint"); /* horizontalHeader()->setLabel(0, TR("visible")); horizontalHeader()->setLabel(1, " "); horizontalHeader()->setLabel(2, TR("element")); horizontalHeader()->setLabel(3, TR("constraint")); */ setHorizontalHeaderLabels(headerLabels); horizontalHeader()->setSectionResizeMode(0, QHeaderView::Interactive); horizontalHeader()->setSectionResizeMode(1, QHeaderView::Interactive); bool v = c->indicate_visible; QList<BrowserNode *> & hv = c->hidden_visible; BrowserNodeList & elts = c->elements; QString yes = tr(" yes"); elts.sort(); int row = 0; foreach (BrowserNode *bn, elts) { setItem(row, 0, new QTableWidgetItem()); setItem(row, 1, new QTableWidgetItem()); if ((v) ? hv.indexOf(bn) != -1 : hv.indexOf(bn) == -1) item( row, 0)->setText( yes); item(row, 1)->setIcon( *(bn->pixmap(0))); TableItem * ti; ti = new TableItem(TableItem::Never, bn->full_name(TRUE), TableItem::TableItemType); setItem(row, 2, ti); QString s = toUnicode(bn->constraint()); int n = s.count('\n'); ti = new TableItem(TableItem::Never, s, TableItem::TableItemType); setItem(row, 3, ti); if (n != 0) { // note : adjustRow(row) does nothing setRowHeight(row, rowHeight(row) * (n + 1)); } ++row; }
void GrowingTableWidget::DataChanged(const QModelIndex& tl, const QModelIndex& br) { Q_UNUSED(tl); Q_UNUSED(br); resizeRowsToContents(); resizeColumnsToContents(); int h = contentsMargins().top() + contentsMargins().bottom(); h += horizontalHeader()->height(); for(int i = 0; i < rowCount(); i++) h += rowHeight(i); setMinimumHeight(h); }
QRectF ODrawClient::getGlobalRect(const MSO::OfficeArtClientAnchor &clientAnchor) { const MSO::XlsOfficeArtClientAnchor* anchor = clientAnchor.anon.get<MSO::XlsOfficeArtClientAnchor>(); if (!anchor) return QRectF(); QRectF r = getRect(clientAnchor); qreal x = 0, y = 0; for (int row = 0; row < anchor->rwT; row++) { y += rowHeight(m_sheet, row); } for (int col = 0; col < anchor->colL; col++) { x += columnWidth(m_sheet, col); } return r.adjusted(x, y, x, y); }
QSize LDFCommonTableWidget::GetTableWidgetSize() { int w = verticalHeader()->width() + 4; // +4 seems to be needed for (int i = 0; i < columnCount(); i++) { w += columnWidth(i); // seems to include gridline (on my machine) } int h = horizontalHeader()->height() + 4; for (int i = 0; i < rowCount(); i++) { h += rowHeight(i); } return QSize(w, h); }
static void drawItems(struct table *t, HDC dc, RECT cliprect) { HFONT thisfont, prevfont; LONG height; LONG y; intptr_t i; RECT controlSize; // for filling the entire selected row intptr_t first, last; if (GetClientRect(t->hwnd, &controlSize) == 0) abort(); height = rowHeight(t); thisfont = t->font; // in case WM_SETFONT happens before we return prevfont = (HFONT) SelectObject(dc, thisfont); if (prevfont == NULL) abort(); // ignore anything beneath the header if (cliprect.top < t->headerHeight) cliprect.top = t->headerHeight; // now let's pretend the header isn't there // we only need it in (or rather, before) the drawItem() calls below cliprect.top -= t->headerHeight; cliprect.bottom -= t->headerHeight; // see http://blogs.msdn.com/b/oldnewthing/archive/2003/07/29/54591.aspx and http://blogs.msdn.com/b/oldnewthing/archive/2003/07/30/54600.aspx // we need to add t->firstVisible here because cliprect is relative to the visible area first = (cliprect.top / height) + t->firstVisible; if (first < 0) first = 0; last = lastVisible(t, cliprect, height); // now for the first y, discount firstVisible y = (first - t->firstVisible) * height; // and offset by the header height y += t->headerHeight; for (i = first; i < last; i++) { drawItem(t, dc, i, y, height, controlSize); y += height; } // reset everything if (SelectObject(dc, prevfont) != (HGDIOBJ) (thisfont)) abort(); }