mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-24 02:42:48 +00:00
kio: fix an issue with the metadata displaying
sometimes with metadata that has many small value entries the widget rows were overlapping. in the process of fixing this a minor cleanup was done - two less temporary variables are assigned
This commit is contained in:
parent
123432aec9
commit
adf0bfef8f
1 changed files with 3 additions and 17 deletions
|
@ -106,7 +106,7 @@ void KFileMetaDataWidget::Private::initMetaInfoSettings()
|
||||||
KConfig config("kmetainformationrc", KConfig::NoGlobals);
|
KConfig config("kmetainformationrc", KConfig::NoGlobals);
|
||||||
if (config.group("Misc").readEntry("version", 0) < currentVersion) {
|
if (config.group("Misc").readEntry("version", 0) < currentVersion) {
|
||||||
// The resource file is read the first time. Assure
|
// The resource file is read the first time. Assure
|
||||||
// that some meta information is disabled per default.
|
// that some meta information is enabled per default.
|
||||||
|
|
||||||
// clear old info
|
// clear old info
|
||||||
config.deleteGroup("Show");
|
config.deleteGroup("Show");
|
||||||
|
@ -302,11 +302,8 @@ QSize KFileMetaDataWidget::sizeHint() const
|
||||||
// Calculate the required width for the labels and values
|
// Calculate the required width for the labels and values
|
||||||
int leftWidthMax = 0;
|
int leftWidthMax = 0;
|
||||||
int rightWidthMax = 0;
|
int rightWidthMax = 0;
|
||||||
int rightWidthAverage = 0;
|
|
||||||
foreach (const Private::Row& row, d->m_rows) {
|
foreach (const Private::Row& row, d->m_rows) {
|
||||||
const QWidget* valueWidget = row.value;
|
const int rightWidth = row.value->sizeHint().width();
|
||||||
const int rightWidth = valueWidget->sizeHint().width();
|
|
||||||
rightWidthAverage += rightWidth;
|
|
||||||
if (rightWidth > rightWidthMax) {
|
if (rightWidth > rightWidthMax) {
|
||||||
rightWidthMax = rightWidth;
|
rightWidthMax = rightWidth;
|
||||||
}
|
}
|
||||||
|
@ -317,22 +314,11 @@ QSize KFileMetaDataWidget::sizeHint() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some value widgets might return a very huge width for the size hint.
|
|
||||||
// Limit the maximum width to the double width of the overall average
|
|
||||||
// to assure a less messed layout.
|
|
||||||
if (d->m_rows.count() > 1) {
|
|
||||||
rightWidthAverage /= d->m_rows.count();
|
|
||||||
if (rightWidthMax > rightWidthAverage * 2) {
|
|
||||||
rightWidthMax = rightWidthAverage * 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Based on the available width calculate the required height
|
// Based on the available width calculate the required height
|
||||||
int height = d->m_gridLayout->margin() * 2 + d->m_gridLayout->spacing() * (d->m_rows.count() - 1);
|
int height = d->m_gridLayout->margin() * 2 + d->m_gridLayout->spacing() * (d->m_rows.count() - 1);
|
||||||
foreach (const Private::Row& row, d->m_rows) {
|
foreach (const Private::Row& row, d->m_rows) {
|
||||||
const QWidget* valueWidget = row.value;
|
|
||||||
const int rowHeight = qMax(row.label->heightForWidth(leftWidthMax),
|
const int rowHeight = qMax(row.label->heightForWidth(leftWidthMax),
|
||||||
valueWidget->heightForWidth(rightWidthMax));
|
row.value->heightForWidth(rightWidthMax));
|
||||||
height += rowHeight;
|
height += rowHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue