@@ -477,120 +477,6 @@ bool LabelOutOfFocusEventFilter::eventFilter(QObject* watched, QEvent* event)
477477 return QObject::eventFilter (watched, event);
478478}
479479
480- void TableViewLastColumnResizingFixer::connectViewHeadersSignals ()
481- {
482- connect (tableView->horizontalHeader (), &QHeaderView::sectionResized, this , &TableViewLastColumnResizingFixer::on_sectionResized);
483- connect (tableView->horizontalHeader (), &QHeaderView::geometriesChanged, this , &TableViewLastColumnResizingFixer::on_geometriesChanged);
484- }
485-
486- // We need to disconnect these while handling the resize events, otherwise we can enter infinite loops.
487- void TableViewLastColumnResizingFixer::disconnectViewHeadersSignals ()
488- {
489- disconnect (tableView->horizontalHeader (), &QHeaderView::sectionResized, this , &TableViewLastColumnResizingFixer::on_sectionResized);
490- disconnect (tableView->horizontalHeader (), &QHeaderView::geometriesChanged, this , &TableViewLastColumnResizingFixer::on_geometriesChanged);
491- }
492-
493- // Setup the resize mode, handles compatibility for Qt5 and below as the method signatures changed.
494- // Refactored here for readability.
495- void TableViewLastColumnResizingFixer::setViewHeaderResizeMode (int logicalIndex, QHeaderView::ResizeMode resizeMode)
496- {
497- tableView->horizontalHeader ()->setSectionResizeMode (logicalIndex, resizeMode);
498- }
499-
500- void TableViewLastColumnResizingFixer::resizeColumn (int nColumnIndex, int width)
501- {
502- tableView->setColumnWidth (nColumnIndex, width);
503- tableView->horizontalHeader ()->resizeSection (nColumnIndex, width);
504- }
505-
506- int TableViewLastColumnResizingFixer::getColumnsWidth ()
507- {
508- int nColumnsWidthSum = 0 ;
509- for (int i = 0 ; i < columnCount; i++)
510- {
511- nColumnsWidthSum += tableView->horizontalHeader ()->sectionSize (i);
512- }
513- return nColumnsWidthSum;
514- }
515-
516- int TableViewLastColumnResizingFixer::getAvailableWidthForColumn (int column)
517- {
518- int nResult = lastColumnMinimumWidth;
519- int nTableWidth = tableView->horizontalHeader ()->width ();
520-
521- if (nTableWidth > 0 )
522- {
523- int nOtherColsWidth = getColumnsWidth () - tableView->horizontalHeader ()->sectionSize (column);
524- nResult = std::max (nResult, nTableWidth - nOtherColsWidth);
525- }
526-
527- return nResult;
528- }
529-
530- // Make sure we don't make the columns wider than the table's viewport width.
531- void TableViewLastColumnResizingFixer::adjustTableColumnsWidth ()
532- {
533- disconnectViewHeadersSignals ();
534- resizeColumn (lastColumnIndex, getAvailableWidthForColumn (lastColumnIndex));
535- connectViewHeadersSignals ();
536-
537- int nTableWidth = tableView->horizontalHeader ()->width ();
538- int nColsWidth = getColumnsWidth ();
539- if (nColsWidth > nTableWidth)
540- {
541- resizeColumn (secondToLastColumnIndex,getAvailableWidthForColumn (secondToLastColumnIndex));
542- }
543- }
544-
545- // Make column use all the space available, useful during window resizing.
546- void TableViewLastColumnResizingFixer::stretchColumnWidth (int column)
547- {
548- disconnectViewHeadersSignals ();
549- resizeColumn (column, getAvailableWidthForColumn (column));
550- connectViewHeadersSignals ();
551- }
552-
553- // When a section is resized this is a slot-proxy for ajustAmountColumnWidth().
554- void TableViewLastColumnResizingFixer::on_sectionResized (int logicalIndex, int oldSize, int newSize)
555- {
556- adjustTableColumnsWidth ();
557- int remainingWidth = getAvailableWidthForColumn (logicalIndex);
558- if (newSize > remainingWidth)
559- {
560- resizeColumn (logicalIndex, remainingWidth);
561- }
562- }
563-
564- // When the table's geometry is ready, we manually perform the stretch of the "Message" column,
565- // as the "Stretch" resize mode does not allow for interactive resizing.
566- void TableViewLastColumnResizingFixer::on_geometriesChanged ()
567- {
568- if ((getColumnsWidth () - this ->tableView ->horizontalHeader ()->width ()) != 0 )
569- {
570- disconnectViewHeadersSignals ();
571- resizeColumn (secondToLastColumnIndex, getAvailableWidthForColumn (secondToLastColumnIndex));
572- connectViewHeadersSignals ();
573- }
574- }
575-
576- /* *
577- * Initializes all internal variables and prepares the
578- * the resize modes of the last 2 columns of the table and
579- */
580- TableViewLastColumnResizingFixer::TableViewLastColumnResizingFixer (QTableView* table, int lastColMinimumWidth, int allColsMinimumWidth, QObject *parent) :
581- QObject (parent),
582- tableView (table),
583- lastColumnMinimumWidth (lastColMinimumWidth),
584- allColumnsMinimumWidth (allColsMinimumWidth)
585- {
586- columnCount = tableView->horizontalHeader ()->count ();
587- lastColumnIndex = columnCount - 1 ;
588- secondToLastColumnIndex = columnCount - 2 ;
589- tableView->horizontalHeader ()->setMinimumSectionSize (allColumnsMinimumWidth);
590- setViewHeaderResizeMode (secondToLastColumnIndex, QHeaderView::Interactive);
591- setViewHeaderResizeMode (lastColumnIndex, QHeaderView::Interactive);
592- }
593-
594480#ifdef WIN32
595481fs::path static StartupShortcutPath ()
596482{
0 commit comments