add more spacing
[personal-kdebase.git] / workspace / krunner / interfaces / default / resultitem.h
blobfaca5279a88a6d17dc98e96f55838512e8da1e06
1 /***************************************************************************
2 * Copyright 2007 by Enrico Ros <enrico.ros@gmail.com> *
3 * Copyright 2007 by Riccardo Iaconelli <ruphy@kde.org> *
4 * Copyright 2008 by Davide Bettio <davide.bettio@kdemail.net> *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
20 ***************************************************************************/
22 #ifndef __ResultItem_h__
23 #define __ResultItem_h__
25 #include <QtGui/QGraphicsWidget>
26 #include <QtGui/QIcon>
28 #include <Plasma/QueryMatch>
30 class QGraphicsLinearLayout;
32 namespace Plasma
34 class FrameSvg;
35 class RunnerManager;
36 } // namespace Plasma
38 class ResultItemSignaller : public QObject
40 Q_OBJECT
42 public:
43 ResultItemSignaller(QObject *parent = 0)
44 : QObject(parent)
49 void startAnimations()
51 emit animate();
54 Q_SIGNALS:
55 void animate();
58 class ResultItem : public QGraphicsWidget
60 Q_OBJECT
62 public:
63 ResultItem(const Plasma::QueryMatch &match, QGraphicsWidget *parent, Plasma::FrameSvg *frame);
65 void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
66 void setMatch(const Plasma::QueryMatch &match);
68 // getters
69 QString id() const;
70 QString name() const;
71 QString description() const;
72 QString data() const;
73 QIcon icon() const;
74 Plasma::QueryMatch::Type group() const;
75 qreal priority() const;
76 bool isFavorite() const;
77 void setIndex(int index);
78 int index() const;
79 void setRowStride(int stride);
80 int rowStride() const;
81 void remove();
82 void run(Plasma::RunnerManager *manager);
84 static bool compare(const ResultItem *one, const ResultItem *other);
85 bool operator<(const ResultItem &other) const;
87 static const int ITEM_SIZE = 68;
88 static const int PADDING = 2;
89 static const int MARGIN = 3;
90 static const int TEXT_MARGIN = 1;
91 static const int BOUNDING_WIDTH = ITEM_SIZE + MARGIN*2;
92 static const int BOUNDING_HEIGHT = ITEM_SIZE + MARGIN*3 + TEXT_MARGIN*2;
94 signals:
95 void indexReleased(int index);
96 void activated(ResultItem *item);
97 void hoverEnter(ResultItem *item);
98 void hoverLeave(ResultItem *item);
100 protected:
101 void hoverLeaveEvent(QGraphicsSceneHoverEvent *e);
102 void hoverEnterEvent(QGraphicsSceneHoverEvent *e);
103 void timerEvent(QTimerEvent *e);
104 void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
105 void focusInEvent(QFocusEvent *event);
106 void focusOutEvent(QFocusEvent *event);
107 void keyPressEvent(QKeyEvent *event);
108 QVariant itemChange(GraphicsItemChange change, const QVariant &value);
110 private:
111 // must always call remove()
112 ~ResultItem();
113 class Private;
114 Private * const d;
115 // Q_PRIVATE_SLOT(d, void animationComplete())
117 private slots:
118 void slotTestTransp();
119 void animationComplete();
120 void animate();
121 void becomeVisible();
124 #endif