File: contact-view-hover-button.h

package info (click to toggle)
ktp-contact-list 15.08.3-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 448 kB
  • ctags: 404
  • sloc: cpp: 4,466; makefile: 5; sh: 3
file content (74 lines) | stat: -rw-r--r-- 2,273 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
    Qt item view mouse hover button

    Copyright (C) 2008 Peter Penz <peter dot penz at gmx dot at>
    Copyright (C) 2009 Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
    Copyright (C) 2011 Martin Klapetek <martin dot klapetek at gmail dot com>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/

#ifndef CONTACTVIEWHOVERBUTTON_H
#define CONTACTVIEWHOVERBUTTON_H

// Qt includes

#include <QAbstractButton>
#include <QAbstractItemView>

// Local includes

class QTimeLine;

class ContactViewHoverButton : public QAbstractButton
{
    Q_OBJECT

public:
    ContactViewHoverButton(QAbstractItemView *parentView);
    void initIcon();
    void reset();
    void setIndex(const QModelIndex &index);
    QModelIndex index() const;
    void setVisible(bool visible);

    /// Reimplement to match the size of your icon
    virtual QSize sizeHint() const = 0;

protected:
    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;
    /// Optionally update tooltip here. Will be called again on state change.
    virtual void updateToolTip();

protected Q_SLOTS:
    void setFadingValue(int value);
    void refreshIcon();
    void startFading();
    void stopFading();

protected:
    QPersistentModelIndex m_index;
    bool                  m_isHovered;
    int                   m_fadingValue;
    QPixmap               m_icon;
    QTimeLine            *m_fadingTimeLine;
};

#endif /* CONTACTVIEWHOVERBUTTON_H */