Skip to content

Commit 2b9625f

Browse files
committed
Merge fd725c2 into merged_master (Bitcoin PR bitcoin-core/gui#204)
Some GUI changes that conflict with commented-out code. I made an educated guess as to what new stuff should be commented out or not but honestly I have no idea what the GUI is supposed to do or show.
2 parents 01e64b2 + fd725c2 commit 2b9625f

File tree

6 files changed

+4
-183
lines changed

6 files changed

+4
-183
lines changed

src/qt/guiutil.cpp

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

src/qt/guiutil.h

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -183,45 +183,6 @@ namespace GUIUtil
183183
bool eventFilter(QObject* watched, QEvent* event) override;
184184
};
185185

186-
/**
187-
* Makes a QTableView last column feel as if it was being resized from its left border.
188-
* Also makes sure the column widths are never larger than the table's viewport.
189-
* In Qt, all columns are resizable from the right, but it's not intuitive resizing the last column from the right.
190-
* Usually our second to last columns behave as if stretched, and when on stretch mode, columns aren't resizable
191-
* interactively or programmatically.
192-
*
193-
* This helper object takes care of this issue.
194-
*
195-
*/
196-
class TableViewLastColumnResizingFixer: public QObject
197-
{
198-
Q_OBJECT
199-
200-
public:
201-
TableViewLastColumnResizingFixer(QTableView* table, int lastColMinimumWidth, int allColsMinimumWidth, QObject *parent);
202-
void stretchColumnWidth(int column);
203-
204-
private:
205-
QTableView* tableView;
206-
int lastColumnMinimumWidth;
207-
int allColumnsMinimumWidth;
208-
int lastColumnIndex;
209-
int columnCount;
210-
int secondToLastColumnIndex;
211-
212-
void adjustTableColumnsWidth();
213-
int getAvailableWidthForColumn(int column);
214-
int getColumnsWidth();
215-
void connectViewHeadersSignals();
216-
void disconnectViewHeadersSignals();
217-
void setViewHeaderResizeMode(int logicalIndex, QHeaderView::ResizeMode resizeMode);
218-
void resizeColumn(int nColumnIndex, int width);
219-
220-
private Q_SLOTS:
221-
void on_sectionResized(int logicalIndex, int oldSize, int newSize);
222-
void on_geometriesChanged();
223-
};
224-
225186
bool GetStartOnSystemStartup();
226187
bool SetStartOnSystemStartup(bool fAutoStart);
227188

src/qt/receivecoinsdialog.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
ReceiveCoinsDialog::ReceiveCoinsDialog(const PlatformStyle *_platformStyle, QWidget *parent) :
2525
QDialog(parent, GUIUtil::dialog_flags),
2626
ui(new Ui::ReceiveCoinsDialog),
27-
columnResizingFixer(nullptr),
2827
model(nullptr),
2928
platformStyle(_platformStyle)
3029
{
@@ -83,7 +82,6 @@ void ReceiveCoinsDialog::setModel(WalletModel *_model)
8382
QTableView* tableView = ui->recentRequestsView;
8483

8584
tableView->verticalHeader()->hide();
86-
tableView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
8785
tableView->setModel(_model->getRecentRequestsTableModel());
8886
tableView->setAlternatingRowColors(true);
8987
tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
@@ -93,15 +91,13 @@ void ReceiveCoinsDialog::setModel(WalletModel *_model)
9391
#if 0
9492
tableView->setColumnWidth(RecentRequestsTableModel::Label, LABEL_COLUMN_WIDTH);
9593
tableView->setColumnWidth(RecentRequestsTableModel::Amount, AMOUNT_MINIMUM_COLUMN_WIDTH);
94+
tableView->horizontalHeader()->setMinimumSectionSize(MINIMUM_COLUMN_WIDTH);
95+
tableView->horizontalHeader()->setStretchLastSection(true);
9696
#endif
9797

9898
connect(tableView->selectionModel(),
9999
&QItemSelectionModel::selectionChanged, this,
100100
&ReceiveCoinsDialog::recentRequestsView_selectionChanged);
101-
#if 0
102-
// Last 2 columns are set by the columnResizingFixer, when the table geometry is ready.
103-
columnResizingFixer = new GUIUtil::TableViewLastColumnResizingFixer(tableView, AMOUNT_MINIMUM_COLUMN_WIDTH, DATE_COLUMN_WIDTH, this);
104-
#endif
105101

106102
if (model->wallet().getDefaultAddressType() == OutputType::BECH32) {
107103
ui->useBech32->setCheckState(Qt::Checked);
@@ -245,13 +241,6 @@ void ReceiveCoinsDialog::on_removeRequestButton_clicked()
245241
model->getRecentRequestsTableModel()->removeRows(firstIndex.row(), selection.length(), firstIndex.parent());
246242
}
247243

248-
// We override the virtual resizeEvent of the QWidget to adjust tables column
249-
// sizes as the tables width is proportional to the dialogs width.
250-
void ReceiveCoinsDialog::resizeEvent(QResizeEvent *event)
251-
{
252-
QWidget::resizeEvent(event);
253-
}
254-
255244
QModelIndex ReceiveCoinsDialog::selectedRow()
256245
{
257246
if(!model || !model->getRecentRequestsTableModel() || !ui->recentRequestsView->selectionModel())

src/qt/receivecoinsdialog.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,12 @@ public Q_SLOTS:
5151

5252
private:
5353
Ui::ReceiveCoinsDialog *ui;
54-
GUIUtil::TableViewLastColumnResizingFixer *columnResizingFixer;
5554
WalletModel *model;
5655
QMenu *contextMenu;
5756
const PlatformStyle *platformStyle;
5857

5958
QModelIndex selectedRow();
6059
void copyColumnToClipboard(int column);
61-
virtual void resizeEvent(QResizeEvent *event) override;
6260

6361
private Q_SLOTS:
6462
void on_receiveButton_clicked();

src/qt/transactionview.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ void TransactionView::setModel(WalletModel *_model)
217217

218218
transactionProxyModel->setSortRole(Qt::EditRole);
219219

220-
transactionView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
221220
transactionView->setModel(transactionProxyModel);
222221
transactionView->setAlternatingRowColors(true);
223222
transactionView->setSelectionBehavior(QAbstractItemView::SelectRows);
@@ -231,8 +230,8 @@ void TransactionView::setModel(WalletModel *_model)
231230
transactionView->setColumnWidth(TransactionTableModel::Date, DATE_COLUMN_WIDTH);
232231
transactionView->setColumnWidth(TransactionTableModel::Type, TYPE_COLUMN_WIDTH);
233232
transactionView->setColumnWidth(TransactionTableModel::Amount, AMOUNT_MINIMUM_COLUMN_WIDTH);
234-
235-
columnResizingFixer = new GUIUtil::TableViewLastColumnResizingFixer(transactionView, AMOUNT_MINIMUM_COLUMN_WIDTH, MINIMUM_COLUMN_WIDTH, this);
233+
transactionView->horizontalHeader()->setMinimumSectionSize(MINIMUM_COLUMN_WIDTH);
234+
transactionView->horizontalHeader()->setStretchLastSection(true);
236235

237236
if (_model->getOptionsModel())
238237
{
@@ -623,14 +622,6 @@ void TransactionView::focusTransaction(const uint256& txid)
623622
}
624623
}
625624

626-
// We override the virtual resizeEvent of the QWidget to adjust tables column
627-
// sizes as the tables width is proportional to the dialogs width.
628-
void TransactionView::resizeEvent(QResizeEvent* event)
629-
{
630-
QWidget::resizeEvent(event);
631-
columnResizingFixer->stretchColumnWidth(TransactionTableModel::ToAddress);
632-
}
633-
634625
// Need to override default Ctrl+C action for amount as default behaviour is just to copy DisplayRole text
635626
bool TransactionView::eventFilter(QObject *obj, QEvent *event)
636627
{

src/qt/transactionview.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,6 @@ class TransactionView : public QWidget
8282

8383
QWidget *createDateRangeWidget();
8484

85-
GUIUtil::TableViewLastColumnResizingFixer *columnResizingFixer{nullptr};
86-
87-
virtual void resizeEvent(QResizeEvent* event) override;
88-
8985
bool eventFilter(QObject *obj, QEvent *event) override;
9086

9187
private Q_SLOTS:

0 commit comments

Comments
 (0)