Skip to content

Commit d787b25

Browse files
committed
Cleanup: Remove unused TableViewLastColumnResizingFixer and DHMSTableWidgetItem from guiutil.h/cpp
1 parent fce12cf commit d787b25

File tree

2 files changed

+0
-188
lines changed

2 files changed

+0
-188
lines changed

src/qt/guiutil.cpp

Lines changed: 0 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -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
631497
fs::path static StartupShortcutPath()
632498
{

src/qt/guiutil.h

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -168,60 +168,6 @@ class ToolTipToRichTextFilter : public QObject
168168
int size_threshold;
169169
};
170170

171-
/**
172-
* Makes a QTableView last column feel as if it was being resized from its left border.
173-
* Also makes sure the column widths are never larger than the table's viewport.
174-
* In Qt, all columns are resizable from the right, but it's not intuitive resizing the last column from the right.
175-
* Usually our second to last columns behave as if stretched, and when on strech mode, columns aren't resizable
176-
* interactively or programatically.
177-
*
178-
* This helper object takes care of this issue.
179-
*
180-
*/
181-
class TableViewLastColumnResizingFixer : public QObject
182-
{
183-
Q_OBJECT
184-
185-
public:
186-
TableViewLastColumnResizingFixer(QTableView* table, int lastColMinimumWidth, int allColsMinimumWidth);
187-
void stretchColumnWidth(int column);
188-
189-
private:
190-
QTableView* tableView;
191-
int lastColumnMinimumWidth;
192-
int allColumnsMinimumWidth;
193-
int lastColumnIndex;
194-
int columnCount;
195-
int secondToLastColumnIndex;
196-
197-
void adjustTableColumnsWidth();
198-
int getAvailableWidthForColumn(int column);
199-
int getColumnsWidth();
200-
void connectViewHeadersSignals();
201-
void disconnectViewHeadersSignals();
202-
void setViewHeaderResizeMode(int logicalIndex, QHeaderView::ResizeMode resizeMode);
203-
void resizeColumn(int nColumnIndex, int width);
204-
205-
private Q_SLOTS:
206-
void on_sectionResized(int logicalIndex, int oldSize, int newSize);
207-
void on_geometriesChanged();
208-
};
209-
210-
/**
211-
* Extension to QTableWidgetItem that facilitates proper ordering for "DHMS"
212-
* strings (primarily used in the masternode's "active" listing).
213-
*/
214-
class DHMSTableWidgetItem : public QTableWidgetItem
215-
{
216-
public:
217-
DHMSTableWidgetItem(const int64_t seconds);
218-
virtual bool operator<(QTableWidgetItem const& item) const;
219-
220-
private:
221-
// Private backing value for DHMS string, used for sorting.
222-
int64_t value;
223-
};
224-
225171
bool GetStartOnSystemStartup();
226172
bool SetStartOnSystemStartup(bool fAutoStart);
227173

0 commit comments

Comments
 (0)