[Differential] [Request, 4 lines] D4406: Fix header content size when sorting is disabled
Elvis Stansvik
noreply at phabricator.kde.org
Thu Feb 2 14:40:12 UTC 2017
astan created this revision.
astan added a reviewer: Breeze.
Restricted Application added a project: Plasma.
Restricted Application added a subscriber: plasma-devel.
REVISION SUMMARY
Instead of always adding space for the sorting indicator in item view
headers, only add it if sorting is enabled. Without this fix, operations
such as QTreeView::resizeColumnToContents(..) will not result in a snug
fit when the header section is wider than all items in the column.
TEST PLAN
#include <QApplication>
#include <QTreeView>
#include <QStandardItemModel>
#include <QStandardItem>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
// Test model
QStandardItemModel model(3, 2);
model.setHorizontalHeaderLabels({ "Header 1", "Header 2" });
for (int row = 0; row < 3; ++row) {
for (int column = 0; column < 2; ++column) {
model.setItem(row, column, new QStandardItem("Foo"));
}
}
// View with sorting disabled
QTreeView view;
view.setWindowTitle("Sorting Disabled");
view.setModel(&model);
view.show();
view.resizeColumnToContents(0);
// View with sorting enabled
QTreeView viewWithSorting;
viewWithSorting.setWindowTitle("Sorting Enabled");
viewWithSorting.setModel(&model);
viewWithSorting.setSortingEnabled(true);
viewWithSorting.show();
viewWithSorting.resizeColumnToContents(0);
return app.exec();
}
Notice how before applying this fix, there's space reserved for the sorting
indicator even on the QTreeView that has sorting disabled.
REPOSITORY
R31 Breeze
BRANCH
fix-unsortable-item-view-header-size (branched from master)
REVISION DETAIL
https://phabricator.kde.org/D4406
AFFECTED FILES
kstyle/breezestyle.cpp
EMAIL PREFERENCES
https://phabricator.kde.org/settings/panel/emailpreferences/
To: astan, #breeze
Cc: plasma-devel, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20170202/bcd901a2/attachment.html>
More information about the Plasma-devel
mailing list