diff --git a/src/kitemviews/kitemliststyleoption.h b/src/kitemviews/kitemliststyleoption.h --- a/src/kitemviews/kitemliststyleoption.h +++ b/src/kitemviews/kitemliststyleoption.h @@ -45,6 +45,11 @@ bool extendedSelectionRegion; int maxTextLines; int maxTextWidth; + + bool operator==(const KItemListStyleOption& other) const; + bool operator!=(const KItemListStyleOption& other) const; + + }; #endif diff --git a/src/kitemviews/kitemliststyleoption.cpp b/src/kitemviews/kitemliststyleoption.cpp --- a/src/kitemviews/kitemliststyleoption.cpp +++ b/src/kitemviews/kitemliststyleoption.cpp @@ -53,3 +53,23 @@ KItemListStyleOption::~KItemListStyleOption() { } + +bool KItemListStyleOption::operator==(const KItemListStyleOption& other) const +{ + return rect == other.rect + && font == other.font + && fontMetrics == other.fontMetrics + && palette == other.palette + && padding == other.padding + && horizontalMargin == other.horizontalMargin + && verticalMargin == other.verticalMargin + && iconSize == other.iconSize + && extendedSelectionRegion == other.extendedSelectionRegion + && maxTextLines == other.maxTextLines + && maxTextWidth == other.maxTextWidth; +} + +bool KItemListStyleOption::operator!=(const KItemListStyleOption& other) const +{ + return !(*this == other); +} diff --git a/src/kitemviews/kitemlistview.cpp b/src/kitemviews/kitemlistview.cpp --- a/src/kitemviews/kitemlistview.cpp +++ b/src/kitemviews/kitemlistview.cpp @@ -752,6 +752,10 @@ void KItemListView::setStyleOption(const KItemListStyleOption& option) { + if (m_styleOption == option) { + return; + } + const KItemListStyleOption previousOption = m_styleOption; m_styleOption = option;