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