add more spacing
[personal-kdebase.git] / workspace / krunner / interfaces / quicksand / qs_matchview.h
blob7e8f0de1b5502fd2fa8c9f4bc1ec49e581067e82
1 /*
2 * Copyright (C) 2007-2008 Ryan P. Bitanga <ryan.bitanga@gmail.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA .
20 #ifndef QS_MATCHVIEW_H
21 #define QS_MATCHVIEW_H
23 #include <QList>
24 #include <QWidget>
26 class QFocusEvent;
27 class QKeyPressEvent;
28 class QResizeEvent;
30 namespace QuickSand {
32 class MatchItem;
34 /**
35 * @class QsMatchView
36 * @short A class to visualize a set of items
38 * QsMatchView is composed of a title label, an item count label,
39 * a visualization box, and a popup completion box. The visualization
40 * box has three modes: scrolling icon, selected item, and text mode.
41 * The scrolling icon mode visualizes all items as a single horizontal
42 * row of icons. Scrolling is controlled by either the completion box
43 * or the view itself.
45 class QsMatchView : public QWidget
47 Q_OBJECT
48 public:
49 QsMatchView(QWidget *parent = 0);
50 ~QsMatchView();
52 /**
53 * Removes all items from the scene
55 void clear(bool deleteItems = false);
56 /**
57 * Removes items from the scene and places default find message
59 void reset();
60 /**
61 * Shows the loading animation
63 void showLoading();
64 /**
65 * Sets the list of items to be displayed on screen
66 * @param items The list of items to display
67 * @param popup Display the popup completion box
68 * @param append Append items to the current list instead of replacing it
70 void setItems(const QList<MatchItem*> &items, bool popup = true, bool append = false);
72 /**
73 * Sets the item count text on the upper right hand corner
74 * Defaults to "items"
76 void setItemCountSuffix(const QString &suffix);
77 public slots:
78 /**
79 * Sets the title text on the upper left hand corner of the widget
81 void setTitle(const QString &title);
82 /**
83 * Display the popup
85 void showPopup();
86 private slots:
87 /**
88 * Switches between Icon Parade and Selected Item modes
90 void toggleView();
91 void scrollToItem(int index);
92 /**
93 * Uses whole view to display selected item and hides all other matches
95 void showSelected();
96 /**
97 * Shows a scrolling list of icons for each match
99 void showList();
100 signals:
102 * Emitted when the user presser enter
104 void itemActivated(MatchItem *item);
106 * Emitted when the user changes selection through either the completion
107 * box or the scrolling icon view
109 void selectionChanged(MatchItem *item);
111 * Emitted when the internal query string changes
113 void textChanged(const QString &text);
114 private:
116 * Sets the text in the bottom portion of the widget
117 * @param text Text to display
118 * @param color Color of the rectangle behind the text
120 void setDescriptionText(const QString &text, const QColor &color);
122 * Convenience method. Calls setDescriptionText(text, QColor(Qt::white)
124 void setDescriptionText(const QString &text);
127 * Removes match items from scene but does not delete them
129 void clearItems();
132 * Selects item at the specified index
134 void selectItem(int index);
136 * Highlights item and centers item when in scrolling icon mode
138 void focusItem(int index);
139 void scrollLeft();
140 void scrollRight();
142 void setItemCount(int items);
144 void resizeEvent(QResizeEvent *e);
145 void focusInEvent(QFocusEvent *event);
146 void focusOutEvent(QFocusEvent *event);
147 void keyPressEvent(QKeyEvent *event);
149 class Private;
150 Private* const d;
154 #endif