@@ -597,125 +597,6 @@ bool ToolTipToRichTextFilter::eventFilter(QObject *obj, QEvent *evt)
597
597
return QObject::eventFilter (obj, evt);
598
598
}
599
599
600
- void TableViewLastColumnResizingFixer::connectViewHeadersSignals ()
601
- {
602
- connect (tableView->horizontalHeader (), SIGNAL (sectionResized (int ,int ,int )), this , SLOT (on_sectionResized (int ,int ,int )));
603
- connect (tableView->horizontalHeader (), SIGNAL (geometriesChanged ()), this , SLOT (on_geometriesChanged ()));
604
- }
605
-
606
- // We need to disconnect these while handling the resize events, otherwise we can enter infinite loops.
607
- void TableViewLastColumnResizingFixer::disconnectViewHeadersSignals ()
608
- {
609
- disconnect (tableView->horizontalHeader (), SIGNAL (sectionResized (int ,int ,int )), this , SLOT (on_sectionResized (int ,int ,int )));
610
- disconnect (tableView->horizontalHeader (), SIGNAL (geometriesChanged ()), this , SLOT (on_geometriesChanged ()));
611
- }
612
-
613
- // Setup the resize mode, handles compatibility for Qt5 and below as the method signatures changed.
614
- // Refactored here for readability.
615
- void TableViewLastColumnResizingFixer::setViewHeaderResizeMode (int logicalIndex, QHeaderView::ResizeMode resizeMode)
616
- {
617
- #if QT_VERSION < 0x050000
618
- tableView->horizontalHeader ()->setResizeMode (logicalIndex, resizeMode);
619
- #else
620
- tableView->horizontalHeader ()->setSectionResizeMode (logicalIndex, resizeMode);
621
- #endif
622
- }
623
-
624
- void TableViewLastColumnResizingFixer::resizeColumn (int nColumnIndex, int width)
625
- {
626
- tableView->setColumnWidth (nColumnIndex, width);
627
- tableView->horizontalHeader ()->resizeSection (nColumnIndex, width);
628
- }
629
-
630
- int TableViewLastColumnResizingFixer::getColumnsWidth ()
631
- {
632
- int nColumnsWidthSum = 0 ;
633
- for (int i = 0 ; i < columnCount; i++)
634
- {
635
- nColumnsWidthSum += tableView->horizontalHeader ()->sectionSize (i);
636
- }
637
- return nColumnsWidthSum;
638
- }
639
-
640
- int TableViewLastColumnResizingFixer::getAvailableWidthForColumn (int column)
641
- {
642
- int nResult = lastColumnMinimumWidth;
643
- int nTableWidth = tableView->horizontalHeader ()->width ();
644
-
645
- if (nTableWidth > 0 )
646
- {
647
- int nOtherColsWidth = getColumnsWidth () - tableView->horizontalHeader ()->sectionSize (column);
648
- nResult = std::max (nResult, nTableWidth - nOtherColsWidth);
649
- }
650
-
651
- return nResult;
652
- }
653
-
654
- // Make sure we don't make the columns wider than the table's viewport width.
655
- void TableViewLastColumnResizingFixer::adjustTableColumnsWidth ()
656
- {
657
- disconnectViewHeadersSignals ();
658
- resizeColumn (lastColumnIndex, getAvailableWidthForColumn (lastColumnIndex));
659
- connectViewHeadersSignals ();
660
-
661
- int nTableWidth = tableView->horizontalHeader ()->width ();
662
- int nColsWidth = getColumnsWidth ();
663
- if (nColsWidth > nTableWidth)
664
- {
665
- resizeColumn (secondToLastColumnIndex,getAvailableWidthForColumn (secondToLastColumnIndex));
666
- }
667
- }
668
-
669
- // Make column use all the space available, useful during window resizing.
670
- void TableViewLastColumnResizingFixer::stretchColumnWidth (int column)
671
- {
672
- disconnectViewHeadersSignals ();
673
- resizeColumn (column, getAvailableWidthForColumn (column));
674
- connectViewHeadersSignals ();
675
- }
676
-
677
- // When a section is resized this is a slot-proxy for ajustAmountColumnWidth().
678
- void TableViewLastColumnResizingFixer::on_sectionResized (int logicalIndex, int oldSize, int newSize)
679
- {
680
- adjustTableColumnsWidth ();
681
- int remainingWidth = getAvailableWidthForColumn (logicalIndex);
682
- if (newSize > remainingWidth)
683
- {
684
- resizeColumn (logicalIndex, remainingWidth);
685
- }
686
- }
687
-
688
- // When the table's geometry is ready, we manually perform the stretch of the "Message" column,
689
- // as the "Stretch" resize mode does not allow for interactive resizing.
690
- void TableViewLastColumnResizingFixer::on_geometriesChanged ()
691
- {
692
- if ((getColumnsWidth () - this ->tableView ->horizontalHeader ()->width ()) != 0 )
693
- {
694
- disconnectViewHeadersSignals ();
695
- resizeColumn (secondToLastColumnIndex, getAvailableWidthForColumn (secondToLastColumnIndex));
696
- connectViewHeadersSignals ();
697
- }
698
- }
699
-
700
- /* *
701
- * Initializes all internal variables and prepares the
702
- * the resize modes of the last 2 columns of the table and
703
- */
704
- TableViewLastColumnResizingFixer::TableViewLastColumnResizingFixer (QTableView* table, int lastColMinimumWidth, int allColsMinimumWidth, QObject *parent) :
705
- QObject (parent),
706
- tableView (table),
707
- lastColumnMinimumWidth (lastColMinimumWidth),
708
- allColumnsMinimumWidth (allColsMinimumWidth)
709
- {
710
- columnCount = tableView->horizontalHeader ()->count ();
711
- lastColumnIndex = columnCount - 1 ;
712
- secondToLastColumnIndex = columnCount - 2 ;
713
- tableView->horizontalHeader ()->setMinimumSectionSize (allColumnsMinimumWidth);
714
- setViewHeaderResizeMode (columnCount - 3 , QHeaderView::ResizeToContents);
715
- setViewHeaderResizeMode (secondToLastColumnIndex, QHeaderView::ResizeToContents);
716
- setViewHeaderResizeMode (lastColumnIndex, QHeaderView::Stretch);
717
- }
718
-
719
600
#ifdef WIN32
720
601
fs::path static StartupShortcutPath ()
721
602
{
0 commit comments