Files
qt5-legatus-legacy/Lts/Plugins/ParticipantManagement/Gui/Common/participant_beautify_view.cpp
T
2026-08-13 18:33:10 +02:00

37 lines
1.0 KiB
C++
Executable File

/**
* @RDE_HEADER@
* Microsoft does strange things.
* $Id: participant_edit_model.h 52287 2020-10-08 11:54:01Z biedziak_f $
* $HeadURL: svn://192.168.133.21/TDS/branches/product/features/commaster/Lts/Plugins/ParticipantManagement/Gui/Common/participant_edit_model.h $
* $Author: biedziak_f $
* Created by Mike Lennart Wille, SLTE, 2023-07-14
*/
#include <Common/participant_beautify_view.h>
#include <QTreeView>
#include <QHeaderView>
#include <QModelIndex>
namespace ParticipantManagement
{
/*
* Column widths are adjusted to the displayed content. Keeps all items expanded
* after identifying the optimal column width if 'keepExpanded' is true.
*/
void beautifyTreeView(QTreeView *tv, QAbstractItemModel *pModel, bool keepExpanded)
{
tv->expandAll();
int colCount = pModel->columnCount(QModelIndex());
for (int i = 0; i < colCount; ++i)
tv->resizeColumnToContents(i);
tv->header()->resizeSection(0, tv->columnWidth(0) + tv->iconSize().width() + 10);
if (!keepExpanded)
tv->collapseAll();
}
} // namespace ParticipantManagement