@@ -493,140 +493,6 @@ bool ToolTipToRichTextFilter::eventFilter(QObject* obj, QEvent* evt)
493493 return QObject::eventFilter (obj, evt);
494494}
495495
496- void TableViewLastColumnResizingFixer::connectViewHeadersSignals ()
497- {
498- connect (tableView->horizontalHeader (), &QHeaderView::sectionResized, this , &TableViewLastColumnResizingFixer::on_sectionResized);
499- connect (tableView->horizontalHeader (), &QHeaderView::geometriesChanged, this , &TableViewLastColumnResizingFixer::on_geometriesChanged);
500- }
501-
502- // We need to disconnect these while handling the resize events, otherwise we can enter infinite loops.
503- void TableViewLastColumnResizingFixer::disconnectViewHeadersSignals ()
504- {
505- disconnect (tableView->horizontalHeader (), &QHeaderView::sectionResized, this , &TableViewLastColumnResizingFixer::on_sectionResized);
506- disconnect (tableView->horizontalHeader (), &QHeaderView::geometriesChanged, this , &TableViewLastColumnResizingFixer::on_geometriesChanged);
507- }
508-
509- // Setup the resize mode, handles compatibility for Qt5 and below as the method signatures changed.
510- // Refactored here for readability.
511- void TableViewLastColumnResizingFixer::setViewHeaderResizeMode (int logicalIndex, QHeaderView::ResizeMode resizeMode)
512- {
513- tableView->horizontalHeader ()->setSectionResizeMode (logicalIndex, resizeMode);
514- }
515-
516- void TableViewLastColumnResizingFixer::resizeColumn (int nColumnIndex, int width)
517- {
518- tableView->setColumnWidth (nColumnIndex, width);
519- tableView->horizontalHeader ()->resizeSection (nColumnIndex, width);
520- }
521-
522- int TableViewLastColumnResizingFixer::getColumnsWidth ()
523- {
524- int nColumnsWidthSum = 0 ;
525- for (int i = 0 ; i < columnCount; i++) {
526- nColumnsWidthSum += tableView->horizontalHeader ()->sectionSize (i);
527- }
528- return nColumnsWidthSum;
529- }
530-
531- int TableViewLastColumnResizingFixer::getAvailableWidthForColumn (int column)
532- {
533- int nResult = lastColumnMinimumWidth;
534- int nTableWidth = tableView->horizontalHeader ()->width ();
535-
536- if (nTableWidth > 0 ) {
537- int nOtherColsWidth = getColumnsWidth () - tableView->horizontalHeader ()->sectionSize (column);
538- nResult = std::max (nResult, nTableWidth - nOtherColsWidth);
539- }
540-
541- return nResult;
542- }
543-
544- // Make sure we don't make the columns wider than the tables viewport width.
545- void TableViewLastColumnResizingFixer::adjustTableColumnsWidth ()
546- {
547- disconnectViewHeadersSignals ();
548- resizeColumn (lastColumnIndex, getAvailableWidthForColumn (lastColumnIndex));
549- connectViewHeadersSignals ();
550-
551- int nTableWidth = tableView->horizontalHeader ()->width ();
552- int nColsWidth = getColumnsWidth ();
553- if (nColsWidth > nTableWidth) {
554- resizeColumn (secondToLastColumnIndex, getAvailableWidthForColumn (secondToLastColumnIndex));
555- }
556- }
557-
558- // Make column use all the space available, useful during window resizing.
559- void TableViewLastColumnResizingFixer::stretchColumnWidth (int column)
560- {
561- disconnectViewHeadersSignals ();
562- resizeColumn (column, getAvailableWidthForColumn (column));
563- connectViewHeadersSignals ();
564- }
565-
566- // When a section is resized this is a slot-proxy for ajustAmountColumnWidth().
567- void TableViewLastColumnResizingFixer::on_sectionResized (int logicalIndex, int oldSize, int newSize)
568- {
569- adjustTableColumnsWidth ();
570- int remainingWidth = getAvailableWidthForColumn (logicalIndex);
571- if (newSize > remainingWidth) {
572- resizeColumn (logicalIndex, remainingWidth);
573- }
574- }
575-
576- // When the tabless geometry is ready, we manually perform the stretch of the "Message" column,
577- // as the "Stretch" resize mode does not allow for interactive resizing.
578- void TableViewLastColumnResizingFixer::on_geometriesChanged ()
579- {
580- if ((getColumnsWidth () - this ->tableView ->horizontalHeader ()->width ()) != 0 ) {
581- disconnectViewHeadersSignals ();
582- resizeColumn (secondToLastColumnIndex, getAvailableWidthForColumn (secondToLastColumnIndex));
583- connectViewHeadersSignals ();
584- }
585- }
586-
587- /* *
588- * Initializes all internal variables and prepares the
589- * the resize modes of the last 2 columns of the table and
590- */
591- TableViewLastColumnResizingFixer::TableViewLastColumnResizingFixer (QTableView* table, int lastColMinimumWidth, int allColsMinimumWidth) : tableView(table),
592- lastColumnMinimumWidth(lastColMinimumWidth),
593- allColumnsMinimumWidth(allColsMinimumWidth)
594- {
595- columnCount = tableView->horizontalHeader ()->count ();
596- lastColumnIndex = columnCount - 1 ;
597- secondToLastColumnIndex = columnCount - 2 ;
598- tableView->horizontalHeader ()->setMinimumSectionSize (allColumnsMinimumWidth);
599- setViewHeaderResizeMode (secondToLastColumnIndex, QHeaderView::Interactive);
600- setViewHeaderResizeMode (lastColumnIndex, QHeaderView::Interactive);
601- }
602-
603- /* *
604- * Class constructor.
605- * @param[in] seconds Number of seconds to convert to a DHMS string
606- */
607- DHMSTableWidgetItem::DHMSTableWidgetItem (const int64_t seconds) : QTableWidgetItem(),
608- value(seconds)
609- {
610- this ->setText (QString::fromStdString (DurationToDHMS (seconds)));
611- }
612-
613- /* *
614- * Comparator overload to ensure that the "DHMS"-type durations as used in
615- * the "active-since" list in the masternode tab are sorted by the elapsed
616- * duration (versus the string value being sorted).
617- * @param[in] item Right hand side of the less than operator
618- */
619- bool DHMSTableWidgetItem::operator <(QTableWidgetItem const & item) const
620- {
621- DHMSTableWidgetItem const * rhs =
622- dynamic_cast <DHMSTableWidgetItem const *>(&item);
623-
624- if (!rhs)
625- return QTableWidgetItem::operator <(item);
626-
627- return value < rhs->value ;
628- }
629-
630496#ifdef WIN32
631497fs::path static StartupShortcutPath ()
632498{
0 commit comments