Fix header content size when sorting is disabled
ClosedPublic

Authored by astan on Feb 2 2017, 5:06 PM.

Details

Summary

This fixes the same problem as described in D4406 for Breeze.

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();
}

Before the fix:

After the fix:

Diff Detail

Repository
R113 Oxygen Theme
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
astan updated this revision to Diff 10857.Feb 2 2017, 5:06 PM
astan retitled this revision from to Fix header content size when sorting is disabled.
astan updated this object.
astan edited the test plan for this revision. (Show Details)
astan added a reviewer: Breeze.
Restricted Application added a project: Plasma. · View Herald TranscriptFeb 2 2017, 5:06 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
astan edited the test plan for this revision. (Show Details)Feb 2 2017, 5:08 PM
astan removed a reviewer: Breeze.
astan added a reviewer: Breeze.
cfeck accepted this revision.Feb 3 2017, 12:16 PM
cfeck added a reviewer: cfeck.
This revision is now accepted and ready to land.Feb 3 2017, 12:16 PM
This revision was automatically updated to reflect the committed changes.