add more spacing
[personal-kdebase.git] / workspace / krunner / interfaces / default / resultscene.h
blob1848645a5224cadb1158ffb2c53d968bb9247714
1 /***************************************************************************
2 * Copyright 2007 by Enrico Ros <enrico.ros@gmail.com> *
3 * Copyright 2007 by Riccardo Iaconelli <ruphy@kde.org> *
4 * Copyright 2008 by Aaron Seigo <aseigo@kde.org> *
5 * Copyright 2008 by Davide Bettio <davide.bettio@kdemail.net> *
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the *
19 * Free Software Foundation, Inc., *
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
21 ***************************************************************************/
23 #ifndef __ResultScene_h__
24 #define __ResultScene_h__
26 #include <QtCore/QList>
27 #include <QtCore/QMultiMap>
28 #include <QtCore/QTimer>
29 #include <QtGui/QGraphicsScene>
30 #include <QtGui/QIcon>
31 #include <QtGui/QPixmap>
33 #include <Plasma/QueryMatch>
35 namespace Plasma
37 class RunnerManager;
38 class FrameSvg;
41 class ResultItem;
43 class ResultScene : public QGraphicsScene
45 Q_OBJECT
47 public:
48 explicit ResultScene(Plasma::RunnerManager *runnerManager, QObject *parent = 0);
49 ~ResultScene();
51 void resize(int width, int height);
52 ResultItem* defaultResultItem() const;
53 void run(ResultItem* item) const;
54 QSize minimumSizeHint() const;
56 Plasma::RunnerManager* manager() const;
58 uint pageCount() const;
60 public slots:
61 void nextPage();
62 void previousPage();
63 void setPage(uint index);
64 void setQueryMatches(const QList<Plasma::QueryMatch> &matches);
65 void launchQuery(const QString &term);
66 void launchQuery(const QString &term, const QString &runner);
67 void clearQuery();
69 signals:
70 void itemActivated(ResultItem *item);
71 void itemHoverEnter(ResultItem *item);
72 void itemHoverLeave(ResultItem *item);
73 void matchCountChanged(int count);
75 protected:
76 void keyPressEvent(QKeyEvent * keyEvent);
77 void focusOutEvent(QFocusEvent *focusEvent);
78 void wheelEvent(QGraphicsSceneWheelEvent * wheelEvent);
80 private:
81 ResultItem* addQueryMatch(const Plasma::QueryMatch &match, bool useAnyId);
82 void performResize(int width, int height);
84 Plasma::RunnerManager *m_runnerManager;
86 QSize m_size;
87 QPixmap m_backPixmap;
88 QPixmap m_forePixmap1;
89 QPixmap m_forePixmap2;
91 // for resize optimization
92 QTimer m_resizeTimer;
93 QTimer m_clearTimer;
94 bool m_successfullyResized;
95 int m_resizeW;
96 int m_resizeH;
98 QList<ResultItem *> m_items;
99 QMultiMap<QString, ResultItem *> m_itemsById;
101 int m_cIndex;
102 int m_rowStride;
103 int m_pageStride;
104 uint m_pageCount;
105 uint m_currentPage;
106 Plasma::FrameSvg *m_frame;
108 private slots:
109 void layoutIcons();
110 void slotArrowResultItemPressed();
111 void slotArrowResultItemReleased();
112 void clearMatches();
115 #endif