ruphy / raptor

menu for KDE 4

This URL has Read+Write access

Bruno Abinader (author)
Wed Apr 22 06:36:10 -0700 2009
ruphy (committer)
Sun Apr 26 10:35:37 -0700 2009
raptor / view / raptorgraphicsview.h
100644 92 lines (68 sloc) 2.614 kb
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/* This file is part of the KDE project
 
Copyright (C) 2009 Alessandro Diaferia <alediaferia@gmail.com>
Copyright (C) 2009 Lukas Appelhans <l.appelhans@gmx.de>
 
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
*/
#ifndef RAPTORGRAPHICSVIEW_H
#define RAPTORGRAPHICSVIEW_H
 
#include "raptormenuitem.h"
 
#include <QGraphicsWidget>
#include <QModelIndex>
 
#include <KUrl>
 
class QAbstractItemModel;
class QGraphicsSceneResizeEvent;
class QGraphicsSceneHoverEvent;
 
class RaptorGraphicsView : public QGraphicsWidget
{
    Q_OBJECT
public:
    enum ViewMode //FIXME: Feel free to change the names here...
    {
        SingleApp = 0, //http://nuno-icons.com/images/estilo/raptor/oneapp.png
        TwoApps = 1, //http://nuno-icons.com/images/estilo/raptor/menu2enteries.png
        Normal = 2, //http://nuno-icons.com/images/estilo/raptor/main menu.png
        Search = 4 //http://nuno-icons.com/images/estilo/raptor/find.png
    };
    
    RaptorGraphicsView(QGraphicsItem *parent = 0);
    ~RaptorGraphicsView();
 
    QModelIndex rootIndex() const;
 
    QList<RaptorMenuItem*> items() const;
    QList<RaptorMenuItem*> shownItems() const;
 
    void setModel(QAbstractItemModel *model);
    QAbstractItemModel* model();
    
    void setViewMode(ViewMode mode);
    ViewMode viewMode();
 
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
 
public slots:
    void reset();
    void setRootIndex(const QModelIndex &);
    void scrollRight();
    void scrollLeft();
 
protected slots:
    void slotAddFavorite(const QModelIndex &);
    void addRows(const QModelIndex &, int, int);
    void removeRows(const QModelIndex &, int, int);
 
signals:
    void enteredItem(const QModelIndex &);
    void applicationClicked(const KUrl &);
    void favoriteClicked(const QString &);
 
protected:
    void getItems();
    void setupItems();
    void scrollItems();
 
    void resizeEvent(QGraphicsSceneResizeEvent *event);
 
    void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
    void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
    void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
 
    void mousePressEvent(QGraphicsSceneMouseEvent *event);
    void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
    void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
 
    ViewMode viewModeFromItemCount();
 
private:
    class Private;
    Private *d;
};
 
#endif