-
Notifications
You must be signed in to change notification settings - Fork 304
Fix transaction view/table #662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e9f3b5f
Bugfix: GUI: When restoring table columns, still set their minimum co…
luke-jr a3dbdda
Revert "qt: Move transactionView properties settings to constructor"
luke-jr 379728e
Revert "qt: Move recentRequestsView properties settings to constructor"
luke-jr 8e428cc
Revert "qt: Drop buggy TableViewLastColumnResizingFixer class"
luke-jr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -499,6 +499,120 @@ bool LabelOutOfFocusEventFilter::eventFilter(QObject* watched, QEvent* event) | |||
return QObject::eventFilter(watched, event); | ||||
} | ||||
|
||||
void TableViewLastColumnResizingFixer::connectViewHeadersSignals() | ||||
{ | ||||
connect(tableView->horizontalHeader(), &QHeaderView::sectionResized, this, &TableViewLastColumnResizingFixer::on_sectionResized); | ||||
connect(tableView->horizontalHeader(), &QHeaderView::geometriesChanged, this, &TableViewLastColumnResizingFixer::on_geometriesChanged); | ||||
} | ||||
|
||||
// We need to disconnect these while handling the resize events, otherwise we can enter infinite loops. | ||||
void TableViewLastColumnResizingFixer::disconnectViewHeadersSignals() | ||||
{ | ||||
disconnect(tableView->horizontalHeader(), &QHeaderView::sectionResized, this, &TableViewLastColumnResizingFixer::on_sectionResized); | ||||
disconnect(tableView->horizontalHeader(), &QHeaderView::geometriesChanged, this, &TableViewLastColumnResizingFixer::on_geometriesChanged); | ||||
} | ||||
|
||||
// Setup the resize mode, handles compatibility for Qt5 and below as the method signatures changed. | ||||
// Refactored here for readability. | ||||
void TableViewLastColumnResizingFixer::setViewHeaderResizeMode(int logicalIndex, QHead 8000 erView::ResizeMode resizeMode) | ||||
{ | ||||
tableView->horizontalHeader()->setSectionResizeMode(logicalIndex, resizeMode); | ||||
} | ||||
|
||||
void TableViewLastColumnResizingFixer::resizeColumn(int nColumnIndex, int width) | ||||
{ | ||||
tableView->setColumnWidth(nColumnIndex, width); | ||||
tableView->horizontalHeader()->resizeSection(nColumnIndex, width); | ||||
} | ||||
|
||||
int TableViewLastColumnResizingFixer::getColumnsWidth() | ||||
{ | ||||
int nColumnsWidthSum = 0; | ||||
for (int i = 0; i < columnCount; i++) | ||||
{ | ||||
nColumnsWidthSum += tableView->horizontalHeader()->sectionSize(i); | ||||
} | ||||
return nColumnsWidthSum; | ||||
} | ||||
|
||||
int TableViewLastColumnResizingFixer::getAvailableWidthForColumn(int column) | ||||
{ | ||||
int nResult = lastColumnMinimumWidth; | ||||
int nTableWidth = tableView->horizontalHeader()->width(); | ||||
|
||||
if (nTableWidth > 0) | ||||
{ | ||||
int nOtherColsWidth = getColumnsWidth() - tableView->horizontalHeader()->sectionSize(column); | ||||
nResult = std::max(nResult, nTableWidth - nOtherColsWidth); | ||||
} | ||||
|
||||
return nResult; | ||||
} | ||||
|
||||
// Make sure we don't make the columns wider than the table's viewport width. | ||||
void TableViewLastColumnResizingFixer::adjustTableColumnsWidth() | ||||
{ | ||||
disconnectViewHeadersSignals(); | ||||
resizeColumn(lastColumnIndex, getAvailableWidthForColumn(lastColumnIndex)); | ||||
connectViewHeadersSignals(); | ||||
|
||||
int nTableWidth = tableView->horizontalHeader()->width(); | ||||
int nColsWidth = getColumnsWidth(); | ||||
if (nColsWidth > nTableWidth) | ||||
{ | ||||
resizeColumn(secondToLastColumnIndex,getAvailableWidthForColumn(secondToLastColumnIndex)); | ||||
} | ||||
} | ||||
|
||||
// Make column use all the space available, useful during window resizing. | ||||
void TableViewLastColumnResizingFixer::stretchColumnWidth(int column) | ||||
{ | ||||
disconnectViewHeadersSignals(); | ||||
resizeColumn(column, getAvailableWidthForColumn(column)); | ||||
connectViewHeadersSignals(); | ||||
} | ||||
|
||||
// When a section is resized this is a slot-proxy for ajustAmountColumnWidth(). | ||||
void TableViewLastColumnResizingFixer:: 8000 on_sectionResized(int logicalIndex, int oldSize, int newSize) | ||||
{ | ||||
adjustTableColumnsWidth(); | ||||
int remainingWidth = getAvailableWidthForColumn(logicalIndex); | ||||
if (newSize > remainingWidth) | ||||
{ | ||||
resizeColumn(logicalIndex, remainingWidth); | ||||
} | ||||
} | ||||
|
||||
// When the table's geometry is ready, we manually perform the stretch of the "Message" column, | ||||
// as the "Stretch" resize mode does not allow for interactive resizing. | ||||
void TableViewLastColumnResizingFixer::on_geometriesChanged() | ||||
{ | ||||
if ((getColumnsWidth() - this->tableView->horizontalHeader()->width()) != 0) | ||||
{ | ||||
disconnectViewHeadersSignals(); | ||||
resizeColumn(secondToLastColumnIndex, getAvailableWidthForColumn(secondToLastColumnIndex)); | ||||
connectViewHeadersSignals(); | ||||
} | ||||
} | ||||
|
||||
/** | ||||
* Initializes all internal variables and prepares the | ||||
* the resize modes of the last 2 columns of the table and | ||||
*/ | ||||
TableViewLastColumnResizingFixer::TableViewLastColumnResizingFixer(QTableView* table, int lastColMinimumWidth, int allColsMinimumWidth, QObject *parent) : | ||||
QObject(parent), | ||||
tableView(table), | ||||
lastColumnMinimumWidth(lastColMinimumWidth), | ||||
allColumnsMinimumWidth(allColsMinimumWidth) | ||||
{ | ||||
columnCount = tableView->horizontalHeader()->count(); | ||||
lastColumnIndex = columnCount - 1; | ||||
secondToLastColumnIndex = columnCount - 2; | ||||
tableView->horizontalHeader()->setMinimumSectionSize(allColumnsMinimumWidth); | ||||
setViewHeaderResizeMode(secondToLastColumnIndex, QHeaderView::Interactive); | ||||
setViewHeaderResizeMode(lastColumnIndex, QHeaderView::Interactive); | 8000||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line doesn't make any difference, user still can't change the last column size manually.
Suggested change
|
||||
} | ||||
|
||||
#ifdef WIN32 | ||||
fs::path static StartupShortcutPath() | ||||
{ | ||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What the "Message" column would be? Sounds like something dynamic but it's fixed to the
secondToLastColumIndex
(which is the Label column in the transactions table).