corrections to "make sure a playlist column will appear in the UI even if it's width was somehow set to 0"
This commit is contained in:
parent
0f3b8156f3
commit
80e8fc8d60
@ -24,7 +24,7 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
|
|
||||||
const float StretchHeaderView::kMinimumColumnWidth = 0.01;
|
const int StretchHeaderView::kMinimumColumnWidth = 10;
|
||||||
|
|
||||||
StretchHeaderView::StretchHeaderView(Qt::Orientation orientation, QWidget* parent)
|
StretchHeaderView::StretchHeaderView(Qt::Orientation orientation, QWidget* parent)
|
||||||
: QHeaderView(orientation, parent),
|
: QHeaderView(orientation, parent),
|
||||||
@ -86,8 +86,10 @@ void StretchHeaderView::UpdateWidths(const QList<int>& sections) {
|
|||||||
|
|
||||||
if (pixels == 0 && !isSectionHidden(i))
|
if (pixels == 0 && !isSectionHidden(i))
|
||||||
hideSection(i);
|
hideSection(i);
|
||||||
else if (pixels != 0 && isSectionHidden(i))
|
else if (pixels != 0 && isSectionHidden(i)) {
|
||||||
showSection(i);
|
showSection(i);
|
||||||
|
AssertMinimalColumnWidth(i);
|
||||||
|
}
|
||||||
|
|
||||||
if (pixels != 0)
|
if (pixels != 0)
|
||||||
resizeSection(i, pixels);
|
resizeSection(i, pixels);
|
||||||
@ -118,11 +120,6 @@ void StretchHeaderView::HideSection(int logical) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StretchHeaderView::ShowSection(int logical) {
|
void StretchHeaderView::ShowSection(int logical) {
|
||||||
// makes sure the column will apear no matter what
|
|
||||||
if (sectionSize(logical) < 10) {
|
|
||||||
resizeSection(logical, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!stretch_enabled_) {
|
if (!stretch_enabled_) {
|
||||||
showSection(logical);
|
showSection(logical);
|
||||||
return;
|
return;
|
||||||
@ -142,7 +139,12 @@ void StretchHeaderView::ShowSection(int logical) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StretchHeaderView::SetSectionHidden(int logical, bool hidden) {
|
void StretchHeaderView::SetSectionHidden(int logical, bool hidden) {
|
||||||
hidden ? HideSection(logical) : ShowSection(logical);
|
if(hidden) {
|
||||||
|
HideSection(logical);
|
||||||
|
} else {
|
||||||
|
ShowSection(logical);
|
||||||
|
AssertMinimalColumnWidth(logical);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StretchHeaderView::resizeEvent(QResizeEvent* event) {
|
void StretchHeaderView::resizeEvent(QResizeEvent* event) {
|
||||||
@ -220,3 +222,10 @@ void StretchHeaderView::SetColumnWidth(int logical, float width) {
|
|||||||
other_columns << i;
|
other_columns << i;
|
||||||
NormaliseWidths(other_columns);
|
NormaliseWidths(other_columns);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// makes sure the column will apear no matter what
|
||||||
|
void StretchHeaderView::AssertMinimalColumnWidth(int logical) {
|
||||||
|
if (sectionSize(logical) < kMinimumColumnWidth) {
|
||||||
|
resizeSection(logical, kMinimumColumnWidth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -26,7 +26,7 @@ class StretchHeaderView : public QHeaderView {
|
|||||||
public:
|
public:
|
||||||
StretchHeaderView(Qt::Orientation orientation, QWidget* parent = 0);
|
StretchHeaderView(Qt::Orientation orientation, QWidget* parent = 0);
|
||||||
|
|
||||||
static const float kMinimumColumnWidth;
|
static const int kMinimumColumnWidth;
|
||||||
|
|
||||||
void setModel(QAbstractItemModel* model);
|
void setModel(QAbstractItemModel* model);
|
||||||
|
|
||||||
@ -49,6 +49,7 @@ protected:
|
|||||||
void resizeEvent(QResizeEvent* event);
|
void resizeEvent(QResizeEvent* event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void AssertMinimalColumnWidth(int logical);
|
||||||
void NormaliseWidths(const QList<int>& sections = QList<int>());
|
void NormaliseWidths(const QList<int>& sections = QList<int>());
|
||||||
void UpdateWidths(const QList<int>& sections = QList<int>());
|
void UpdateWidths(const QList<int>& sections = QList<int>());
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user