QSize PipelineTreeWidget::sizeHint() const { int height = 0; // First of all, sum up the heights of top-level items and their children for (int i = 0; i < model()->rowCount(); i++) { QModelIndex index = model()->index(i, 0); height += sizeHintForRow(i); if (model()->hasChildren(index)) { for (int j = 0; j < model()->rowCount(index); ++j) { QModelIndex cIndex = index.child(j, 0); height += sizeHintForIndex(cIndex).height(); if (model()->hasChildren(cIndex)) { height += model()->rowCount(cIndex) * sizeHintForIndex(cIndex.child(0, 0)).height(); } } } } // Next, add the heights of the horizontal scrollbar, header, and frame height += horizontalScrollBar()->sizeHint().height(); height += 2 * header()->sizeHint().height(); height += 2 * frameWidth(); return QSize(QTreeView::sizeHint().width(), std::max(height, 200)); }
/** ***************************************************************************/ QSize ProposalList::sizeHint() const { if (model() == nullptr) return QSize(); int cnt = model()->rowCount(rootIndex()); int nToShow = (_maxItems < cnt) ? _maxItems : cnt; return QSize(width(), nToShow*sizeHintForRow(0)); }
QSize MyCompletionBox::sizeHint() const { int h = count()?(sizeHintForRow(0)):0; h=qMin(count()*h,10*h) + 2*frameWidth(); int w = sizeHintForColumn(0) + verticalScrollBar()->width() + 2*frameWidth(); return QSize(w, h); }
QSize FiltersBase::sizeHint() const { QSize size; // Height should be exactly the height of the content size.setHeight(((sizeHintForRow(0) + 2 * spacing()) * (count() + 0.5))); // Width should be exactly the width of the content size.setWidth(sizeHintForColumn(0)); return size; }
QSize BaseFilterWidget::sizeHint() const { return { // Width should be exactly the width of the content sizeHintForColumn(0), // Height should be exactly the height of the content static_cast<int>((sizeHintForRow(0) + 2 * spacing()) * (count() + 0.5)), }; }
void UIBootTable::adjustSizeToFitContent() { int h = 2 * frameWidth(); int w = h; #if QT_VERSION < 0x040700 w += 4; // WTF? #endif /* QT_VERSION < 0x040700 */ setFixedSize(sizeHintForColumn(0) + w, sizeHintForRow(0) * count() + h); }
/** Automatically adjust minimum size of table to provide * readability of all cells. * Should be called each time data cells are changed. */ void GroupTable::adjustSize( ) { int width = 0; for ( int i = 0; i < columnCount(); i ++ ) { width += sizeHintForColumn( i ); } int height = 0; for ( int i = 0; i < rowCount(); i ++ ) { height += sizeHintForRow( i ); } // ditry hack: we need some more space height += 4 * sizeHintForRow( 0 ); // 5% is for inter-cell lines setMinimumWidth( width + width * 0.15 ); setMinimumHeight( height + height * 0.15 ); }
QSize CategoryFilterWidget::sizeHint() const { // The sizeHint must depend on viewportSizeHint, // otherwise widget will not correctly adjust the // size when subcategories are used. const QSize viewportSize {viewportSizeHint()}; return { viewportSize.width(), viewportSize.height() + static_cast<int>(0.5 * sizeHintForRow(0)) }; }
void NowPlayingListWidget::resizeEvent(QResizeEvent* event) { QListWidget::resizeEvent(event); int height = sizeHintForRow(0) + 2 * ( frameWidth() + 3 ); // add 2*3 for top/bottom padding if (horizontalScrollBar() && horizontalScrollBar()->isVisible()) { height += horizontalScrollBar()->size().height(); } setMaximumHeight(height); }
void ColorList::addItem(const QString& text, const QColor& color) { QListWidgetItem* item = new QListWidgetItem(this); item->setText(text); if(count() == 1) { setIconSize(QSize(100, sizeHintForRow(0) - 4)); } setItemColor(item, color); }
QSize ActionView::viewportSizeHint() const { const int count = mProxy->rowCount(); QSize s{0, 0}; if (0 < count) { const bool scrollable = mMaxItemsToShow < count; s.setWidth(sizeHintForColumn(0) + (scrollable ? verticalScrollBar()->sizeHint().width() : 0)); s.setHeight(sizeHintForRow(0) * (scrollable ? mMaxItemsToShow : count)); } return s; }
//----------------------------------------------------------------------------- // Function: fitToContents() //----------------------------------------------------------------------------- void TextContentAssistWidget::fitToContents() { if (count() == 0) { return; } int visibleRowCount = qMin(count(), maxVisibleItems_); int height = visibleRowCount * sizeHintForRow(0) + frameWidth() * 2; int width = sizeHintForColumn(0) + frameWidth() * 2 + verticalScrollBar()->sizeHint().width(); setFixedSize(width, height); }
void AddressBarMenu::show() { static const int maxBeforeScrolling = 18; static const int margin = 4; if (count() < maxBeforeScrolling) { int h = count() * sizeHintForRow(0) + margin; if (_hasSeparator) { h = (count() - 1) * sizeHintForRow(0) + 9 + margin; } else { h = count() * sizeHintForRow(0) + margin; } this->setMinimumHeight(h); this->setMaximumHeight(h); } else { this->setMinimumHeight(maxBeforeScrolling * sizeHintForRow(0) + margin); this->setMaximumHeight(maxBeforeScrolling * sizeHintForRow(0) + margin); } if (count() > 0) { QListWidget::show(); } else { QListWidget::hide(); } }
void KColorCells::resizeEvent( QResizeEvent* ) { // According to the Qt doc: // If you need to set the width of a given column to a fixed value, call // QHeaderView::resizeSection() on the table's {horizontal,vertical} // header. // Therefore we iterate over each row and column and set the header section // size, as the sizeHint does indeed appear to be ignored in favor of a // minimum size that is larger than what we want. for ( int index = 0 ; index < columnCount() ; index++ ) horizontalHeader()->resizeSection( index, sizeHintForColumn( index ) ); for ( int index = 0 ; index < rowCount() ; index++ ) verticalHeader()->resizeSection( index, sizeHintForRow( index ) ); }
int toResultTableView::visibleRows() const { // TODO this is ugly hack and needs some validation //this->visibleRegion(); int h = sizeHintForRow(0); QAbstractItemDelegate *d = itemDelegate(); QSize s = d->sizeHint(QStyleOptionViewItem(), QModelIndex()); int hh = height(); int hhh = s.height(); int rows = hh / s.height() + 1; if (rows < toConfigurationNewSingle::Instance().option(ToConfiguration::Database::InitialFetchInt).toInt()) return toConfigurationNewSingle::Instance().option(ToConfiguration::Database::InitialFetchInt).toInt(); return rows; }
void UIBootTable::adjustSizeToFitContent() { int h = 2 * frameWidth(); int w = h; #if QT_VERSION < 0x040700 # ifdef Q_WS_MAC int left, top, right, bottom; getContentsMargins(&left, &top, &right, &bottom); h += top + bottom; w += left + right; # else /* Q_WS_MAC */ w += 4; # endif /* !Q_WS_MAC */ #endif /* QT_VERSION < 0x040700 */ setFixedSize(sizeHintForColumn(0) + w, sizeHintForRow(0) * count() + h); }
void DependenciesView::updateSizeHint() { if (!model()) { m_sizeHint = QSize(250, 250); return; } int heightOffset = size().height() - viewport()->height(); int heightPerRow = sizeHintForRow(0); if (heightPerRow == -1) heightPerRow = 30; int rows = qMin(qMax(model()->rowCount(), 2), 10); int height = rows * heightPerRow + heightOffset; if (m_sizeHint.height() != height) { m_sizeHint.setHeight(height); updateGeometry(); } }
QSize ProposalListView::sizeHint() const { if (model()->rowCount() == 0) return QSize(width(), 0); int nToShow = std::min(_nItemsToShow, model()->rowCount()); return QSize(width(), nToShow*sizeHintForRow(0)); }
QSize QxtConfigTableWidget::sizeHint() const { return QSize(sizeHintForColumn(0), sizeHintForRow(0)); }