[SCM] ktp-contact-list packaging branch, master, updated. debian/15.12.1-2-1070-g6c56f91

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:10:39 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-contact-list.git;a=commitdiff;h=8348dda

The following commit has been merged in the master branch:
commit 8348dda8de679adc91ff3ea63a34b0221d0e7978
Author: Martin Klapetek <martin.klapetek at gmail.com>
Date:   Sat May 12 15:50:16 2012 +0200

    Make the delegate overlays code signicitantly simpler, fixes crash in the process
    
    The overlays were in several classes, all deriving one from another. This commit merges several of the classes into one and removes unused and/or useless methods, thus simplifying the code and making it more readable, effective and easier to maintain.
    
    Reviewed-by: David Edmundson
    REVIEW: 104887
    BUG: 293886
---
 contact-delegate-overlay.cpp  | 272 +++++++++++++-----------------------------
 contact-delegate-overlay.h    | 165 +++++++------------------
 contact-delegate.cpp          |   5 +-
 contact-list-widget.cpp       |  16 +--
 contact-overlays.cpp          |  22 ++--
 contact-overlays.h            |  15 ++-
 contact-view-hover-button.cpp |   6 +-
 contact-view-hover-button.h   |  16 +--
 8 files changed, 154 insertions(+), 363 deletions(-)

diff --git a/contact-delegate-overlay.cpp b/contact-delegate-overlay.cpp
index 4733cdd..c75e3ea 100644
--- a/contact-delegate-overlay.cpp
+++ b/contact-delegate-overlay.cpp
@@ -29,106 +29,39 @@
 
 #include "contact-view-hover-button.h"
 
-ContactDelegateOverlay::ContactDelegateOverlay(QObject* parent)
-    : QObject(parent), m_view(0), m_delegate(0)
-{
-}
-
-ContactDelegateOverlay::~ContactDelegateOverlay()
-{
-}
-
-void ContactDelegateOverlay::setActive(bool)
-{
-}
-
-void ContactDelegateOverlay::visualChange()
-{
-    kDebug();
-}
-
-void ContactDelegateOverlay::mouseMoved(QMouseEvent*, const QRect&, const QModelIndex&)
-{
-}
-
-void ContactDelegateOverlay::paint(QPainter*, const QStyleOptionViewItem&, const QModelIndex&)
-{
-}
-
-void ContactDelegateOverlay::setView(QAbstractItemView* view)
-{
-    if (m_view) {
-        disconnect(this, SIGNAL(update(QModelIndex)),
-                   m_view, SLOT(update(QModelIndex)));
-    }
-
-    m_view = view;
-
-    if (m_view) {
-        connect(this, SIGNAL(update(QModelIndex)),
-                m_view, SLOT(update(QModelIndex)));
-    }
-}
-
-QAbstractItemView* ContactDelegateOverlay::view() const
-{
-    return m_view;
-}
-
-void ContactDelegateOverlay::setDelegate(QAbstractItemDelegate* delegate)
-{
-//     if (m_delegate) {
-//         disconnect(m_delegate, SIGNAL(visualChange()),
-//                    this, SLOT(visualChange()));
-//     }
-
-    m_delegate = delegate;
-
-//     if (m_delegate) {
-//         connect(m_delegate, SIGNAL(visualChange()),
-//                 this, SLOT(visualChange()));
-//     }
-}
-
-QAbstractItemDelegate* ContactDelegateOverlay::delegate() const
-{
-    return m_delegate;
-}
-
-// -----------------------------
-
-AbstractWidgetDelegateOverlay::AbstractWidgetDelegateOverlay(QObject* parent)
-    : ContactDelegateOverlay(parent),
+ContactDelegateOverlay::ContactDelegateOverlay(QObject *parent)
+    : QObject(parent),
+      m_view(0),
+      m_delegate(0),
       m_mouseButtonPressedOnWidget(false)
 {
 }
 
-AbstractWidgetDelegateOverlay::~AbstractWidgetDelegateOverlay()
+ContactDelegateOverlay::~ContactDelegateOverlay()
 {
-
 }
 
-void AbstractWidgetDelegateOverlay::setActive(bool active)
+void ContactDelegateOverlay::setActive(bool active)
 {
     if (active) {
-        if (!m_widget.isNull()) {
-            m_widget.data()->deleteLater();
+        if (!m_button.isNull()) {
+            m_button.data()->deleteLater();
         }
 
-        m_widget = createWidget();
+        m_button = createButton();
 
-        m_widget.data()->setFocusPolicy(Qt::NoFocus);
-        m_widget.data()->hide(); // hide per default
+        m_button.data()->setFocusPolicy(Qt::NoFocus);
+        m_button.data()->hide(); // hide per default
+        m_button.data()->initIcon();
 
         m_view->viewport()->installEventFilter(this);
-        m_widget.data()->installEventFilter(this);
 
         if (view()->model()) {
             connect(m_view->model(), SIGNAL(rowsRemoved(QModelIndex,int,int)),
-                    this, SLOT(slotRowsRemoved(QModelIndex,int,int)));
+                    this, SLOT(slotHideButton()));
 
             connect(m_view->model(), SIGNAL(layoutChanged()),
-                    this, SLOT(slotLayoutChanged()));
+                    this, SLOT(slotHideButton()));
 
             connect(m_view->model(), SIGNAL(modelReset()),
                     this, SLOT(slotReset()));
@@ -138,9 +71,9 @@ void AbstractWidgetDelegateOverlay::setActive(bool active)
                 this, SLOT(slotEntered(QModelIndex)));
 
         connect(m_view, SIGNAL(viewportEntered()),
-                this, SLOT(slotViewportEntered()));
+                this, SLOT(slotHideButton()));
     } else {
-        m_widget.data()->deleteLater();
+        m_button.data()->deleteLater();
 
         if (m_view) {
             m_view->viewport()->removeEventFilter(this);
@@ -153,75 +86,93 @@ void AbstractWidgetDelegateOverlay::setActive(bool active)
                        this, SLOT(slotEntered(QModelIndex)));
 
             disconnect(m_view, SIGNAL(viewportEntered()),
-                       this, SLOT(slotViewportEntered()));
+                       this, SLOT(slotHideButton()));
         }
     }
 }
 
-void AbstractWidgetDelegateOverlay::hide()
+void ContactDelegateOverlay::visualChange()
 {
-    if (!m_widget.isNull()) {
-        m_widget.data()->hide();
+    if (!m_button.isNull() && m_button.data()->isVisible()) {
+        updateButton(button()->index());
     }
 }
 
-QWidget* AbstractWidgetDelegateOverlay::parentWidget() const
+void ContactDelegateOverlay::setView(QAbstractItemView *view)
 {
-    return m_view->viewport();
+    if (m_view) {
+        disconnect(this, SIGNAL(update(QModelIndex)),
+                   m_view, SLOT(update(QModelIndex)));
+    }
+
+    m_view = view;
+
+    if (m_view) {
+        connect(this, SIGNAL(update(QModelIndex)),
+                m_view, SLOT(update(QModelIndex)));
+    }
 }
 
-void AbstractWidgetDelegateOverlay::slotReset()
+QAbstractItemView* ContactDelegateOverlay::view() const
 {
-    hide();
+    return m_view;
 }
 
-void AbstractWidgetDelegateOverlay::slotEntered(const QModelIndex& index)
+void ContactDelegateOverlay::setDelegate(QAbstractItemDelegate *delegate)
 {
-    hide();
+//     if (m_delegate) {
+//         disconnect(m_delegate, SIGNAL(visualChange()),
+//                    this, SLOT(visualChange()));
+//     }
 
-    if (index.isValid() && checkIndex(index)) {
-//         QTimer::singleShot(500, m_widget, SLOT(show()));
-        m_widget.data()->show();
-        emit overlayActivated(index);
-    }
-}
+    m_delegate = delegate;
 
-void AbstractWidgetDelegateOverlay::slotWidgetAboutToShow(const QModelIndex& index)
-{
-    Q_UNUSED(index);
-    m_widget.data()->show();
+//     if (m_delegate) {
+//         connect(m_delegate, SIGNAL(visualChange()),
+//                 this, SLOT(visualChange()));
+//     }
 }
 
-bool AbstractWidgetDelegateOverlay::checkIndex(const QModelIndex& index) const
+QAbstractItemDelegate* ContactDelegateOverlay::delegate() const
 {
-    Q_UNUSED(index);
-    return true;
+    return m_delegate;
 }
 
-void AbstractWidgetDelegateOverlay::slotViewportEntered()
+void ContactDelegateOverlay::slotHideButton()
 {
-    hide();
+    if (!m_button.isNull()) {
+        m_button.data()->hide();
+    }
 }
 
-void AbstractWidgetDelegateOverlay::slotRowsRemoved(const QModelIndex&, int, int)
+void ContactDelegateOverlay::slotReset()
 {
-    hide();
+    slotHideButton();
+    button()->reset();
 }
 
-void AbstractWidgetDelegateOverlay::slotLayoutChanged()
+void ContactDelegateOverlay::slotEntered(const QModelIndex& index)
 {
-    hide();
+    slotHideButton();
+
+    if (index.isValid() && checkIndex(index)) {
+        m_button.data()->setIndex(index);
+        updateButton(index);
+        QTimer::singleShot(0, m_button.data(), SLOT(show()));
+//        m_button.data()->show();
+        emit overlayActivated(index);
+    }
 }
 
-void AbstractWidgetDelegateOverlay::viewportLeaveEvent(QObject*, QEvent*)
+bool ContactDelegateOverlay::checkIndex(const QModelIndex& index) const
 {
-    hide();
-    emit overlayHidden();
+    Q_UNUSED(index);
+    return true;
 }
 
-bool AbstractWidgetDelegateOverlay::eventFilter(QObject* obj, QEvent* event)
+bool ContactDelegateOverlay::eventFilter(QObject *obj, QEvent *event)
 {
-    if (!m_widget.isNull() && obj == m_widget.data()) {
+    if (!m_button.isNull() && obj == m_button.data()) {
         switch (event->type()) {
             case QEvent::MouseButtonPress:
                 if (static_cast<QMouseEvent*>(event)->buttons() & Qt::LeftButton) {
@@ -237,7 +188,9 @@ bool AbstractWidgetDelegateOverlay::eventFilter(QObject* obj, QEvent* event)
     } else {   // events on view's viewport
         switch (event->type()) {
             case QEvent::Leave:
-                viewportLeaveEvent(obj, event);
+                slotHideButton();
+                emit overlayHidden();
+                //viewportLeaveEvent(obj, event);
                 break;
             case QEvent::MouseMove:
                 if (m_mouseButtonPressedOnWidget) {
@@ -256,59 +209,12 @@ bool AbstractWidgetDelegateOverlay::eventFilter(QObject* obj, QEvent* event)
         }
     }
 
-    return ContactDelegateOverlay::eventFilter(obj, event);
-}
-
-// -----------------------------
-
-HoverButtonDelegateOverlay::HoverButtonDelegateOverlay(QObject* parent)
-    : AbstractWidgetDelegateOverlay(parent)
-{
-}
-
-ContactViewHoverButton* HoverButtonDelegateOverlay::button() const
-{
-    return qobject_cast<ContactViewHoverButton*>(m_widget.data());
-}
-
-void HoverButtonDelegateOverlay::setActive(bool active)
-{
-    AbstractWidgetDelegateOverlay::setActive(active);
-
-    if (active) {
-        button()->initIcon();
-    }
-}
-
-QWidget* HoverButtonDelegateOverlay::createWidget()
-{
-    return createButton();
-}
-
-void HoverButtonDelegateOverlay::visualChange()
-{
-    if (!m_widget.isNull() && m_widget.data()->isVisible()) {
-        updateButton(button()->index());
-    }
-}
-
-void HoverButtonDelegateOverlay::slotReset()
-{
-    AbstractWidgetDelegateOverlay::slotReset();
-
-    button()->reset();
+    return false;
 }
 
-void HoverButtonDelegateOverlay::slotEntered(const QModelIndex& index)
+ContactViewHoverButton* ContactDelegateOverlay::button() const
 {
-    AbstractWidgetDelegateOverlay::slotEntered(index);
-
-    if (index.isValid() && checkIndex(index)) {
-        button()->setIndex(index);
-        updateButton(index);
-    } else {
-        button()->setIndex(index);
-    }
+    return m_button.data();
 }
 
 // -----------------------------
@@ -317,7 +223,7 @@ ContactDelegateOverlayContainer::~ContactDelegateOverlayContainer()
 {
 }
 
-void ContactDelegateOverlayContainer::installOverlay(ContactDelegateOverlay* overlay)
+void ContactDelegateOverlayContainer::installOverlay(ContactDelegateOverlay *overlay)
 {
     if (!overlay->acceptsDelegate(asDelegate())) {
         kError() << "Cannot accept delegate" << asDelegate() << "for installing" << overlay;
@@ -332,7 +238,7 @@ void ContactDelegateOverlayContainer::installOverlay(ContactDelegateOverlay* ove
 //                      asDelegate(), SLOT(overlayDestroyed(QObject*)));
 }
 
-void ContactDelegateOverlayContainer::removeOverlay(ContactDelegateOverlay* overlay)
+void ContactDelegateOverlayContainer::removeOverlay(ContactDelegateOverlay *overlay)
 {
     overlay->setActive(false);
     overlay->setDelegate(0);
@@ -342,21 +248,21 @@ void ContactDelegateOverlayContainer::removeOverlay(ContactDelegateOverlay* over
 
 void ContactDelegateOverlayContainer::setAllOverlaysActive(bool active)
 {
-    foreach (ContactDelegateOverlay* overlay, m_overlays) {
+    foreach (ContactDelegateOverlay *overlay, m_overlays) {
         overlay->setActive(active);
     }
 }
 
-void ContactDelegateOverlayContainer::setViewOnAllOverlays(QAbstractItemView* view)
+void ContactDelegateOverlayContainer::setViewOnAllOverlays(QAbstractItemView *view)
 {
-    foreach (ContactDelegateOverlay* overlay, m_overlays) {
+    foreach (ContactDelegateOverlay *overlay, m_overlays) {
         overlay->setView(view);
     }
 }
 
 void ContactDelegateOverlayContainer::removeAllOverlays()
 {
-    foreach (ContactDelegateOverlay* overlay, m_overlays) {
+    foreach (ContactDelegateOverlay *overlay, m_overlays) {
         overlay->setActive(false);
         overlay->setDelegate(0);
         overlay->setView(0);
@@ -364,26 +270,12 @@ void ContactDelegateOverlayContainer::removeAllOverlays()
     m_overlays.clear();
 }
 
-void ContactDelegateOverlayContainer::overlayDestroyed(QObject* o)
+void ContactDelegateOverlayContainer::overlayDestroyed(QObject *o)
 {
-    ContactDelegateOverlay* overlay = qobject_cast<ContactDelegateOverlay*>(o);
+    ContactDelegateOverlay *overlay = qobject_cast<ContactDelegateOverlay*>(o);
     if (overlay) {
         removeOverlay(overlay);
     }
 }
 
-void ContactDelegateOverlayContainer::mouseMoved(QMouseEvent* e, const QRect& visualRect, const QModelIndex& index)
-{
-    foreach (ContactDelegateOverlay* overlay, m_overlays) {
-        overlay->mouseMoved(e, visualRect, index);
-    }
-}
-
-void ContactDelegateOverlayContainer::drawDelegates(QPainter* p, const QStyleOptionViewItem& option, const QModelIndex& index) const
-{
-    foreach (ContactDelegateOverlay* overlay, m_overlays) {
-        overlay->paint(p, option, index);
-    }
-}
-
 #include "contact-delegate-overlay.moc"
diff --git a/contact-delegate-overlay.h b/contact-delegate-overlay.h
index 2307044..1550cc0 100644
--- a/contact-delegate-overlay.h
+++ b/contact-delegate-overlay.h
@@ -33,93 +33,22 @@ class ContactDelegateOverlay : public QObject
     Q_OBJECT
 
 public:
-
-    ContactDelegateOverlay(QObject* parent = 0);
+    ContactDelegateOverlay(QObject *parent = 0);
     ~ContactDelegateOverlay();
 
-    /** Called when the overlay was installed and shall begin working,
-     *  and before it is removed and shall stop.
-     *  Setup your connections to view and delegate here.
-     *  You will be disconnected automatically on removal. */
-    virtual void setActive(bool active);
-
-    /** Only these two methods are implemented as virtual methods.
-     *  For all other events, connect to the view's signals.
-     *  There are a few signals specifically for overlays and all
-     *  QAbstractItemView standard signals. */
-    virtual void mouseMoved(QMouseEvent* e, const QRect& visualRect, const QModelIndex& index);
-    virtual void paint(QPainter* p, const QStyleOptionViewItem& option, const QModelIndex& index);
-
-    void setView(QAbstractItemView* view);
-    QAbstractItemView* view() const;
-    void setDelegate(QAbstractItemDelegate* delegate);
-    QAbstractItemDelegate* delegate() const;
-    virtual bool acceptsDelegate(QAbstractItemDelegate*) const { return true; }
-
-Q_SIGNALS:
-
-    void update(const QModelIndex& index);
-
-protected Q_SLOTS:
-
-    /** Called when any change from the delegate occurs - when the overlay is installed,
-     *  when size hints, styles or fonts change */
-    virtual void visualChange();
-
-protected:
-
-    QAbstractItemView     *m_view;
-    QAbstractItemDelegate *m_delegate;
-};
-
-#define REQUIRE_DELEGATE(Delegate) \
-public: \
-    void setDelegate(Delegate* delegate) { ContactDelegateOverlay::setDelegate(delegate); } \
-    Delegate* delegate() const { return static_cast<Delegate*>(ContactDelegateOverlay::delegate()); } \
-    virtual bool acceptsDelegate(QAbstractItemDelegate*d) const { return dynamic_cast<Delegate*>(d); } \
-private:
-
-
-// -------------------------------------------------------------------------------------------
-
-class AbstractWidgetDelegateOverlay : public ContactDelegateOverlay
-{
-    Q_OBJECT
-
-public:
-
-    /** This class provides functionality for using a widget in an overlay.
-     *  You must reimplement at least createWidget to return your widget.
-     *  Per default it will be shown when the cursor enters an index and hidden when left.
-     *  Reimplement slotEntered() and mouseMove() for more fine grained control. */
-    AbstractWidgetDelegateOverlay(QObject* parent);
-    virtual ~AbstractWidgetDelegateOverlay();
-
     /** If active is true, this will call createWidget(), initialize the widget for use,
      *  and setup connections for the virtual slots.
      *  If active is false, this will delete the widget and
      *  disconnect all signal from model and view to this object (!) */
     virtual void setActive(bool active);
 
-protected:
-
-    /** Create your widget here. When creating the object, pass parentWidget() as parent widget.
-     *  Ownership of the object is passed. It will be deleted in setActive(false). */
-    virtual QWidget* createWidget() = 0;
-    /** Called when the widget shall be hidden (mouse cursor left index, viewport, uninstalled etc.).
-     *  Default implementation hide()s m_widget. */
-    virtual void hide();
-
-    /// Returns the widget to be used as parent for your widget created in createWidget()
-    QWidget* parentWidget() const;
-
-    /** Return true here if you want to show the overlay for the given index.
-     *  The default implementation returns true. */
-    virtual bool checkIndex(const QModelIndex& index) const;
+    ContactViewHoverButton* button() const;
 
-    /** Called when a QEvent::Leave of the viewport is received.
-     *  The default implementation hide()s. */
-    virtual void viewportLeaveEvent(QObject* obj, QEvent* event);
+    void setView(QAbstractItemView *view);
+    QAbstractItemView* view() const;
+    void setDelegate(QAbstractItemDelegate *delegate);
+    QAbstractItemDelegate* delegate() const;
+    virtual bool acceptsDelegate(QAbstractItemDelegate*) const { return true; }
 
 Q_SIGNALS:
     /// Emitted when the overlay is shown
@@ -128,62 +57,56 @@ Q_SIGNALS:
     /// Emitted when the overlay is hidden
     void overlayHidden();
 
+    void update(const QModelIndex &index);
+
 protected Q_SLOTS:
+    /** Called when any change from the delegate occurs - when the overlay is installed,
+     *  when size hints, styles or fonts change */
+    virtual void visualChange();
 
     /** Default implementation shows the widget iff the index is valid and checkIndex returns true. */
-    virtual void slotEntered(const QModelIndex& index);
-    /** Default implementations of these three slots call hide() */
-    virtual void slotReset();
-    virtual void slotViewportEntered();
-    virtual void slotRowsRemoved(const QModelIndex& parent, int start, int end);
-    virtual void slotLayoutChanged();
-    virtual void slotWidgetAboutToShow(const QModelIndex& index);
-
-protected:
-
-    bool eventFilter(QObject* obj, QEvent* event);
-
-    QWeakPointer<QWidget> m_widget;
-
-    bool m_mouseButtonPressedOnWidget;
-};
-
-class HoverButtonDelegateOverlay : public AbstractWidgetDelegateOverlay
-{
-    Q_OBJECT
-
-public:
-
-    HoverButtonDelegateOverlay(QObject* parent);
+    virtual void slotEntered(const QModelIndex &index);
 
-    /** Will call createButton(). */
-    virtual void setActive(bool active);
+    /** Hides and resets the button */
+    virtual void slotReset();
 
-    ContactViewHoverButton* button() const;
+    /** Called when the widget shall be hidden (mouse cursor left index, viewport, uninstalled etc.).
+     *  Default implementation hide()s m_widget. */
+    virtual void slotHideButton();
 
 protected:
+    /** Return true here if you want to show the overlay for the given index.
+     *  The default implementation returns true. */
+    virtual bool checkIndex(const QModelIndex &index) const;
 
     /** Create your widget here. Pass view() as parent. */
     virtual ContactViewHoverButton* createButton() = 0;
+
     /** Called when a new index is entered. Reposition your button here,
      *  adjust and store state. */
-    virtual void updateButton(const QModelIndex& index) = 0;
+    virtual void updateButton(const QModelIndex &index) = 0;
 
-    virtual QWidget* createWidget();
-    virtual void visualChange();
+    bool eventFilter(QObject *obj, QEvent *event);
 
+    QAbstractItemView     *m_view;
+    QAbstractItemDelegate *m_delegate;
+    QWeakPointer<ContactViewHoverButton> m_button;
+    bool m_mouseButtonPressedOnWidget;
+};
 
-protected Q_SLOTS:
+#define REQUIRE_DELEGATE(Delegate) \
+public: \
+    void setDelegate(Delegate* delegate) { ContactDelegateOverlay::setDelegate(delegate); } \
+    Delegate* delegate() const { return static_cast<Delegate*>(ContactDelegateOverlay::delegate()); } \
+    virtual bool acceptsDelegate(QAbstractItemDelegate*d) const { return dynamic_cast<Delegate*>(d); } \
+private:
 
-    virtual void slotEntered(const QModelIndex& index);
-    virtual void slotReset();
 
-};
+// -------------------------------------------------------------------------------------------
 
 class ContactDelegateOverlayContainer
 {
 public:
-
     /**
      * This is a sample implementation for
      * delegate management methods, to be inherited by a delegate.
@@ -192,28 +115,20 @@ public:
 
     virtual ~ContactDelegateOverlayContainer();
 
-    void installOverlay(ContactDelegateOverlay* overlay);
-    void removeOverlay(ContactDelegateOverlay* overlay);
+    void installOverlay(ContactDelegateOverlay *overlay);
+    void removeOverlay(ContactDelegateOverlay *overlay);
     void setAllOverlaysActive(bool active);
-    void setViewOnAllOverlays(QAbstractItemView* view);
+    void setViewOnAllOverlays(QAbstractItemView *view);
     void removeAllOverlays();
-    void mouseMoved(QMouseEvent* e, const QRect& visualRect, const QModelIndex& index);
-
-    /// Provide as signal in the delegate:
-    ///  void visualChange();
 
 protected:
-
-    virtual void drawDelegates(QPainter* p, const QStyleOptionViewItem& option, const QModelIndex& index) const;
-
     /// Declare as slot in the derived class calling this method
-    virtual void overlayDestroyed(QObject* o);
+    virtual void overlayDestroyed(QObject *o);
 
     /// Returns the delegate, typically, the derived class
     virtual QAbstractItemDelegate* asDelegate() = 0;
 
 protected:
-
     QList<ContactDelegateOverlay*> m_overlays;
 
 };
diff --git a/contact-delegate.cpp b/contact-delegate.cpp
index 8c6aebe..9a8d69a 100644
--- a/contact-delegate.cpp
+++ b/contact-delegate.cpp
@@ -56,7 +56,7 @@ ContactDelegate::~ContactDelegate()
 
 }
 
-void ContactDelegate::paintContact(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
+void ContactDelegate::paintContact(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
 {
     QStyleOptionViewItemV4 optV4 = option;
     initStyleOption(&optV4, index);
@@ -178,6 +178,9 @@ void ContactDelegate::fadeOutStatusMessageSlot()
 
     connect(a, SIGNAL(valueChanged(QVariant)),
             this, SLOT(triggerRepaint()));
+
+    connect(a, SIGNAL(finished()),
+            a, SLOT(deleteLater()));
 }
 
 int ContactDelegate::fadingValue() const
diff --git a/contact-list-widget.cpp b/contact-list-widget.cpp
index 73be93c..3422ddd 100644
--- a/contact-list-widget.cpp
+++ b/contact-list-widget.cpp
@@ -271,20 +271,8 @@ void ContactListWidget::addOverlayButtons()
     d->delegate->installOverlay(fileOverlay);
     d->delegate->installOverlay(desktopOverlay);
 
-    textOverlay->setView(this);
-    textOverlay->setActive(true);
-
-    audioOverlay->setView(this);
-    audioOverlay->setActive(true);
-
-    videoOverlay->setView(this);
-    videoOverlay->setActive(true);
-
-    fileOverlay->setView(this);
-    fileOverlay->setActive(true);
-
-    desktopOverlay->setView(this);
-    desktopOverlay->setActive(true);
+    d->delegate->setViewOnAllOverlays(this);
+    d->delegate->setAllOverlaysActive(true);
 
     connect(textOverlay, SIGNAL(overlayActivated(QModelIndex)),
             d->delegate, SLOT(hideStatusMessageSlot(QModelIndex)));
diff --git a/contact-overlays.cpp b/contact-overlays.cpp
index 4200b46..b6faeda 100644
--- a/contact-overlays.cpp
+++ b/contact-overlays.cpp
@@ -32,7 +32,7 @@ class GuiItemContactViewHoverButton : public ContactViewHoverButton
 {
 public:
 
-    GuiItemContactViewHoverButton(QAbstractItemView* parentView, const KGuiItem& gui);
+    GuiItemContactViewHoverButton(QAbstractItemView *parentView, const KGuiItem &gui);
     virtual QSize sizeHint() const;
 
 protected:
@@ -45,7 +45,7 @@ private:
     KGuiItem m_guiItem;
 };
 
-GuiItemContactViewHoverButton::GuiItemContactViewHoverButton(QAbstractItemView* parentView, const KGuiItem& gui)
+GuiItemContactViewHoverButton::GuiItemContactViewHoverButton(QAbstractItemView *parentView, const KGuiItem &gui)
     : ContactViewHoverButton(parentView), m_guiItem(gui)
 {
 }
@@ -69,9 +69,9 @@ void GuiItemContactViewHoverButton::updateToolTip()
 
 // -------------------------------------------------------------------------
 
-StartChannelContactOverlay::StartChannelContactOverlay(QObject* parent, const KGuiItem & gui,
+StartChannelContactOverlay::StartChannelContactOverlay(QObject *parent, const KGuiItem &gui,
                                                        int capabilityRole, int xpos)
-    : HoverButtonDelegateOverlay(parent),
+    : ContactDelegateOverlay(parent),
       m_gui(gui),
       m_capabilityRole(capabilityRole),
       m_xpos(xpos)
@@ -80,7 +80,7 @@ StartChannelContactOverlay::StartChannelContactOverlay(QObject* parent, const KG
 
 void StartChannelContactOverlay::setActive(bool active)
 {
-    HoverButtonDelegateOverlay::setActive(active);
+    ContactDelegateOverlay::setActive(active);
 
     if (active) {
         connect(button(), SIGNAL(clicked(bool)),
@@ -95,7 +95,7 @@ ContactViewHoverButton* StartChannelContactOverlay::createButton()
     return new GuiItemContactViewHoverButton(view(), m_gui);
 }
 
-void StartChannelContactOverlay::updateButton(const QModelIndex& index)
+void StartChannelContactOverlay::updateButton(const QModelIndex &index)
 {
     const QRect rect = m_view->visualRect(index);
     const QSize size = button()->size();
@@ -126,7 +126,7 @@ bool StartChannelContactOverlay::checkIndex(const QModelIndex& index) const
 
 // ------------------------------------------------------------------------
 
-TextChannelContactOverlay::TextChannelContactOverlay(QObject* parent)
+TextChannelContactOverlay::TextChannelContactOverlay(QObject *parent)
     : StartChannelContactOverlay(
         parent,
         KGuiItem(i18n("Start Chat"), "text-x-generic",
@@ -138,7 +138,7 @@ TextChannelContactOverlay::TextChannelContactOverlay(QObject* parent)
 
 // ------------------------------------------------------------------------
 
-AudioChannelContactOverlay::AudioChannelContactOverlay(QObject* parent)
+AudioChannelContactOverlay::AudioChannelContactOverlay(QObject *parent)
     : StartChannelContactOverlay(
         parent,
         KGuiItem(i18n("Start Audio Call"), "audio-headset",
@@ -151,7 +151,7 @@ AudioChannelContactOverlay::AudioChannelContactOverlay(QObject* parent)
 
 // -------------------------------------------------------------------------
 
-VideoChannelContactOverlay::VideoChannelContactOverlay(QObject* parent)
+VideoChannelContactOverlay::VideoChannelContactOverlay(QObject *parent)
     : StartChannelContactOverlay(
         parent,
         KGuiItem(i18n("Start Video Call"), "camera-web",
@@ -163,7 +163,7 @@ VideoChannelContactOverlay::VideoChannelContactOverlay(QObject* parent)
 
 // -------------------------------------------------------------------------
 
-FileTransferContactOverlay::FileTransferContactOverlay(QObject* parent)
+FileTransferContactOverlay::FileTransferContactOverlay(QObject *parent)
     : StartChannelContactOverlay(
         parent,
         KGuiItem(i18n("Send File..."), "mail-attachment",
@@ -175,7 +175,7 @@ FileTransferContactOverlay::FileTransferContactOverlay(QObject* parent)
 
 // -------------------------------------------------------------------------
 
-DesktopSharingContactOverlay::DesktopSharingContactOverlay(QObject* parent)
+DesktopSharingContactOverlay::DesktopSharingContactOverlay(QObject *parent)
     : StartChannelContactOverlay(
         parent,
         KGuiItem(i18n("Share my desktop"), "krfb",
diff --git a/contact-overlays.h b/contact-overlays.h
index f232c5c..6f9c3b2 100644
--- a/contact-overlays.h
+++ b/contact-overlays.h
@@ -29,13 +29,12 @@
 
 class ContactModelItem;
 
-class StartChannelContactOverlay : public HoverButtonDelegateOverlay
+class StartChannelContactOverlay : public ContactDelegateOverlay
 {
     Q_OBJECT
 
 public:
-
-    StartChannelContactOverlay(QObject* parent, const KGuiItem & gui,
+    StartChannelContactOverlay(QObject *parent, const KGuiItem &gui,
                                int capabilityRole, int xpos);
 
 public Q_SLOTS:
@@ -68,7 +67,7 @@ class TextChannelContactOverlay : public StartChannelContactOverlay
     Q_OBJECT
 
 public:
-    TextChannelContactOverlay(QObject* parent);
+    TextChannelContactOverlay(QObject *parent);
 };
 
 // ---------------------------------------------------------------------
@@ -78,7 +77,7 @@ class AudioChannelContactOverlay : public StartChannelContactOverlay
     Q_OBJECT
 
 public:
-    AudioChannelContactOverlay(QObject* parent);
+    AudioChannelContactOverlay(QObject *parent);
 };
 
 // ---------------------------------------------------------------------
@@ -88,7 +87,7 @@ class VideoChannelContactOverlay : public StartChannelContactOverlay
     Q_OBJECT
 
 public:
-    VideoChannelContactOverlay(QObject* parent);
+    VideoChannelContactOverlay(QObject *parent);
 };
 
 // ---------------------------------------------------------------------
@@ -98,7 +97,7 @@ class FileTransferContactOverlay : public StartChannelContactOverlay
     Q_OBJECT
 
 public:
-    FileTransferContactOverlay(QObject* parent);
+    FileTransferContactOverlay(QObject *parent);
 };
 
 // ---------------------------------------------------------------------
@@ -108,7 +107,7 @@ class DesktopSharingContactOverlay : public StartChannelContactOverlay
     Q_OBJECT
 
 public:
-    DesktopSharingContactOverlay(QObject* parent);
+    DesktopSharingContactOverlay(QObject *parent);
 };
 
 #endif // VERSIONSOVERLAYS_H
diff --git a/contact-view-hover-button.cpp b/contact-view-hover-button.cpp
index fd411b2..0f8887f 100644
--- a/contact-view-hover-button.cpp
+++ b/contact-view-hover-button.cpp
@@ -39,7 +39,7 @@
 #include <klocale.h>
 #include <KDebug>
 
-ContactViewHoverButton::ContactViewHoverButton(QAbstractItemView* view)
+ContactViewHoverButton::ContactViewHoverButton(QAbstractItemView *view)
     : QAbstractButton(view->viewport()),
       m_isHovered(false),
       m_fadingValue(0),
@@ -47,7 +47,7 @@ ContactViewHoverButton::ContactViewHoverButton(QAbstractItemView* view)
       m_fadingTimeLine(0)
 {
     const bool animate = KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects;
-    const int duration = animate ? 600 : 1;
+    const int duration = animate ? 300 : 1;
     m_fadingTimeLine   = new QTimeLine(duration, this);
     m_fadingTimeLine->setFrameRange(0, 255);
 
@@ -78,7 +78,7 @@ void ContactViewHoverButton::updateToolTip()
 void ContactViewHoverButton::reset()
 {
     m_index = QModelIndex();
-    hide();
+//     hide();
 }
 
 void ContactViewHoverButton::setIndex(const QModelIndex& index)
diff --git a/contact-view-hover-button.h b/contact-view-hover-button.h
index 4248987..78fd226 100644
--- a/contact-view-hover-button.h
+++ b/contact-view-hover-button.h
@@ -36,11 +36,10 @@ class ContactViewHoverButton : public QAbstractButton
     Q_OBJECT
 
 public:
-
-    ContactViewHoverButton(QAbstractItemView* parentView);
+    ContactViewHoverButton(QAbstractItemView *parentView);
     void initIcon();
     void reset();
-    void setIndex(const QModelIndex& index);
+    void setIndex(const QModelIndex &index);
     QModelIndex index() const;
     void setVisible(bool visible);
 
@@ -48,10 +47,9 @@ public:
     virtual QSize sizeHint() const = 0;
 
 protected:
-
-    void enterEvent(QEvent* event);
-    void leaveEvent(QEvent* event);
-    void paintEvent(QPaintEvent* event);
+    void enterEvent(QEvent *event);
+    void leaveEvent(QEvent *event);
+    void paintEvent(QPaintEvent *event);
 
     /// Return your icon here. Will be queried again on toggle.
     virtual QPixmap icon() = 0;
@@ -59,16 +57,12 @@ protected:
     virtual void updateToolTip();
 
 protected Q_SLOTS:
-
     void setFadingValue(int value);
     void refreshIcon();
     void startFading();
     void stopFading();
 
-Q_SIGNALS:
-
 protected:
-
     QPersistentModelIndex m_index;
     bool                  m_isHovered;
     int                   m_fadingValue;

-- 
ktp-contact-list packaging



More information about the pkg-kde-commits mailing list