Example #1
0
 virtual QSize sizeHint() const
 {
     int width = sizeHintForColumn(0) + frameWidth() * 2 + 5;
     if (verticalScrollBar()->isVisible())
         width += verticalScrollBar()->width();
     return QSize(width, 100);
 }
QSize KisCategorizedListView::sizeHint() const
{
    const QSize sh = QListView::sizeHint();
    const int width = sizeHintForColumn(0);

    return QSize(width, sh.height());
}
void MsgListView::slotFixSize()
{
    if (!m_autoResizeSections)
        return;

    if (header()->visualIndex(Imap::Mailbox::MsgListModel::SEEN) == -1) {
        // calling setResizeMode() would assert()
        return;
    }
    header()->setStretchLastSection(false);

    for (int i = 0; i < Imap::Mailbox::MsgListModel::COLUMN_COUNT; ++i) {
        QHeaderView::ResizeMode resizeMode = QHeaderView::Interactive;
        switch (i) {
        case Imap::Mailbox::MsgListModel::SUBJECT:
            resizeMode = QHeaderView::Stretch;
            break;
        case Imap::Mailbox::MsgListModel::SEEN:
            resizeMode = QHeaderView::Fixed;
            break;
        }
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
        header()->setSectionResizeMode(i, resizeMode);
#else
        header()->setResizeMode(i, resizeMode);
#endif
        setColumnWidth(i, sizeHintForColumn(i));
    }
}
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);
}
Example #5
0
// the default list mode of QListView handles column widths
// very badly (worse than gtk+) and it's not very flexible.
// so, let's handle column widths outselves.
void FolderViewTreeView::layoutColumns() {
  // qDebug("layoutColumns");
  if(!model())
    return;
  doingLayout_ = true;
  QHeaderView* headerView = header();
  // the width that's available for showing the columns.
  int availWidth = viewport()->contentsRect().width();
  int desiredWidth = 0;

  // get the width that every column want
  int numCols = headerView->count();
  int* widths = new int[numCols]; // array to store the widths every column needs
  int column;
  for(column = 0; column < numCols; ++column) {
    int columnId = headerView->logicalIndex(column);
    // get the size that the column needs
    widths[column] = sizeHintForColumn(columnId);
  }

  // the best case is every column can get its full width
  for(column = 0; column < numCols; ++column) {
    desiredWidth += widths[column];
  }

  // if the total witdh we want exceeds the available space
  if(desiredWidth > availWidth) {
    // we don't have that much space for every column
    int filenameColumn = headerView->visualIndex(FolderModel::ColumnFileName);
    // shrink the filename column first
    desiredWidth -= widths[filenameColumn]; // total width of all other columns

    // see if setting the width of the filename column to 200 solve the problem
    if(desiredWidth + 200 > availWidth) {
      // even when we reduce the width of the filename column to 200,
      // the available space is not enough. So we give up trying.
      widths[filenameColumn] = 200;
      desiredWidth += 200;
    }
    else { // we still have more space, so the width of filename column can be increased
      // expand the filename column to fill all available space.
      widths[filenameColumn] = availWidth - desiredWidth;
      desiredWidth = availWidth;
    }
  }

  // really do the resizing for every column
  for(int column = 0; column < numCols; ++column) {
    headerView->resizeSection(column, widths[column]);
  }

  delete []widths;
  doingLayout_ = false;
  
  if(layoutTimer_) {
    delete layoutTimer_;
    layoutTimer_ = NULL;
  }
}
int KateArgumentHintTree::resizeColumns() {
  int totalSize = 0;
  for( int a  = 0; a < header()->count(); a++ ) {
    int columnSize = sizeHintForColumn(a);
    setColumnWidth(a, columnSize);
    totalSize += columnSize;
  }
  return totalSize;
}
Example #7
0
void DataTable::resizeColumnsToFitContents()
{
    setUpdatesEnabled(false);
    for(int i=0; i<horizontalHeader()->count(); ++i){
        int sizeHint = qMax(sizeHintForColumn(i), horizontalHeader()->sectionSizeHint(i));
        setColumnWidth(i, qMin(sizeHint+10, this->maxColumnWidth));
    }
    setUpdatesEnabled(true);
}
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)),
    };
}
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;
}
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);
}
Example #11
0
QSize SidePane::sizeHint() const
{
    if (!model()) {
        return QSize(0, 0);
    }

    const int width = sizeHintForColumn(0);
    const int height = QListView::sizeHint().height();

    return QSize(width, height);
}
Example #12
0
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;
}
Q_SLOT void ToolTipWidget::computeSize() 
{
    int columns = 0;
    for (int i = 0; i < 3; ++i) {
        resizeColumnToContents(i);
        columns += sizeHintForColumn(i);
    }
    int rows = computeHeight(QModelIndex());
    m_size = QSize(columns + 5, rows + 5);
    setMinimumSize(m_size);
    setMaximumSize(m_size);
}
//-----------------------------------------------------------------------------
// 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);
}
Example #15
0
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 ) );
}
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);
}
/** 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 );
}
Example #18
0
// BOTTLENECK
// find Max width of a column
// called by
//		1.  void HeadedTable::setNumCols(int cols)
int HeadedTable::updateColWidth(int col)
{
    int w = 0;
    int sw = 0;
    int hw = 0;
    int i = 0;
    int rows = numRows();
    bool treecol = (treemode && col == 0);

    if ((w = sizeHintForColumn(col)) < 0) // width
    {
        if (w < 0)
            w = -w; // trick.
        // if(w<0) printf("w = %d\n",w);
        // harsh, if procs more than 1000
        for (i = 0; i < rows; i++)
        {
            sw = fontMetrics().width(text(i, col)) + 10;

            if (treecol)
                sw += treestep * rowDepth(i);
            if (sw > w)
                w = sw;
        }

        if (treecol)
        {
            w += gadget_space;
        }
    }
    // don't forget the width of the heading
    hw = fontMetrics().width(title(col)) + 12;
    // return 0;
    if (hw > w)
        w = hw;

    // sw=fontmetric.width("0") * colWidth(col);
    // if(sw>w) w=sw;

    max_widths[col] = w;
    return 0;
}
Example #19
0
void UiGenerator::generateUi() {
    auto paraListWidgetPtr = mPanel->getParaListWidget();
    auto stackedViewPtr = mPanel->getStackedWidget();
    auto parent = mPanel.get();

    for(auto& paraPtr : mParasManager->getParaSet()) {
        auto& para = *paraPtr;
        QWidget* specialWidget = createSpecialParaWidget(para, parent);
        if(specialWidget != nullptr) {
            stackedViewPtr->addWidget(specialWidget);
        } else {
            stackedViewPtr->addWidget(generateUi(para, parent));
        }
        paraListWidgetPtr->addItem(createListWidgetItem(para, paraListWidgetPtr));
    }
    paraListWidgetPtr->setMinimumWidth(paraListWidgetPtr->sizeHintForColumn(0));
    QObject::connect(paraListWidgetPtr, &QListWidget::currentRowChanged, [this](int row){
        changeIcon(mParasManager->getParaSet()[row].get());
    });
    auto multiPara = mParasManager->getMultiSelPara();
    if(multiPara != nullptr)
        changeParasExclusive(multiPara);
}
Example #20
0
 QSize sizeHint() const {
     return QListWidget::sizeHint().expandedTo(
         QSize(sizeHintForColumn(0) + verticalScrollBar()->sizeHint().width() + 4, 0));
 }
Example #21
0
QSize QxtConfigTableWidget::sizeHint() const
{
    return QSize(sizeHintForColumn(0), sizeHintForRow(0));
}
Example #22
0
void MovableTableWidget::resizeColumnToContents(int column)
{
  int content = sizeHintForColumn(column);
  int header = horizontalHeader()->sectionSizeHint(column);
  horizontalHeader()->resizeSection(column, qMax(content, header));
}