#include <QPropertyAnimation>
#include <QStyleOption>
-KItemListWidget::KItemListWidget(QGraphicsItem* parent) :
+KItemListWidgetInformant::KItemListWidgetInformant()
+{
+}
+
+KItemListWidgetInformant::~KItemListWidgetInformant()
+{
+}
+
+KItemListWidget::KItemListWidget(KItemListWidgetInformant* informant, QGraphicsItem* parent) :
QGraphicsWidget(parent, 0),
+ m_informant(informant),
m_index(-1),
m_selected(false),
m_current(false),
m_hoverAnimation = new QPropertyAnimation(this, "hoverOpacity", this);
const int duration = (KGlobalSettings::graphicEffectsLevel() == KGlobalSettings::NoEffects) ? 1 : 200;
m_hoverAnimation->setDuration(duration);
- connect(m_hoverAnimation, SIGNAL(finished()), this, SLOT(slotHoverAnimationFinished()));
+ connect(m_hoverAnimation, &QPropertyAnimation::finished, this, &KItemListWidget::slotHoverAnimationFinished);
}
m_hoverAnimation->stop();
return QRectF();
}
+QPixmap KItemListWidget::createDragPixmap(const QStyleOptionGraphicsItem* option,
+ QWidget* widget)
+{
+ QPixmap pixmap(size().toSize());
+ pixmap.fill(Qt::transparent);
+
+ QPainter painter(&pixmap);
+
+ const bool oldAlternateBackground = m_alternateBackground;
+ const bool wasSelected = m_selected;
+ const bool wasHovered = m_hovered;
+
+ setAlternateBackground(false);
+ setSelected(false);
+ setHovered(false);
+
+ paint(&painter, option, widget);
+
+ setAlternateBackground(oldAlternateBackground);
+ setSelected(wasSelected);
+ setHovered(wasHovered);
+
+ return pixmap;
+}
+
void KItemListWidget::dataChanged(const QHash<QByteArray, QVariant>& current,
const QSet<QByteArray>& roles)
{
{
QGraphicsWidget::resizeEvent(event);
clearHoverCache();
+
+ if (m_selectionToggle) {
+ const QRectF& toggleRect = selectionToggleRect();
+ m_selectionToggle->setPos(toggleRect.topLeft());
+ m_selectionToggle->resize(toggleRect.size());
+ }
}
qreal KItemListWidget::hoverOpacity() const