~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to krunner/interfaces/quicksand/qs_matchview.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *   Copyright (C) 2007-2008 Ryan P. Bitanga <ryan.bitanga@gmail.com>
 
3
 *
 
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.
 
8
 *
 
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.
 
13
 *
 
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 .
 
18
 */
 
19
 
 
20
#ifndef QS_MATCHVIEW_H
 
21
#define QS_MATCHVIEW_H
 
22
 
 
23
#include <QList>
 
24
#include <QWidget>
 
25
 
 
26
class QFocusEvent;
 
27
class QKeyPressEvent;
 
28
class QResizeEvent;
 
29
 
 
30
namespace QuickSand {
 
31
 
 
32
    class MatchItem;
 
33
 
 
34
    /**
 
35
     * @class QsMatchView
 
36
     * @short A class to visualize a set of items
 
37
     *
 
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.
 
44
     */
 
45
    class QsMatchView : public QWidget
 
46
    {
 
47
        Q_OBJECT
 
48
        public:
 
49
            QsMatchView(QWidget *parent = 0);
 
50
            ~QsMatchView();
 
51
 
 
52
            /**
 
53
             * Removes all items from the scene
 
54
             */
 
55
            void clear(bool deleteItems = false);
 
56
            /**
 
57
             * Removes items from the scene and places default find message
 
58
             */
 
59
            void reset();
 
60
            /**
 
61
             * Shows the loading animation
 
62
             */
 
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
 
69
             */
 
70
            void setItems(const QList<MatchItem*> &items, bool popup = true, bool append = false);
 
71
 
 
72
            /**
 
73
             * Sets the item count text on the upper right hand corner
 
74
             * Defaults to "items"
 
75
             */
 
76
             void setCountingActions(bool actions);
 
77
 
 
78
        public slots:
 
79
            /**
 
80
             * Sets the title text on the upper left hand corner of the widget
 
81
             */
 
82
            void setTitle(const QString &title);
 
83
            /**
 
84
             * Display the popup
 
85
             */
 
86
            void showPopup();
 
87
        private slots:
 
88
            /**
 
89
             * Switches between Icon Parade and Selected Item modes
 
90
             */
 
91
            void toggleView();
 
92
            void scrollToItem(int index);
 
93
            /**
 
94
             * Uses whole view to display selected item and hides all other matches
 
95
             */
 
96
            void showSelected();
 
97
            /**
 
98
             * Shows a scrolling list of icons for each match
 
99
             */
 
100
            void showList();
 
101
            /**
 
102
             * Paste the content of the clipboard to the lineedit
 
103
             */
 
104
            void pasteClipboard();
 
105
        signals:
 
106
            /**
 
107
             * Emitted when the user presser enter
 
108
             */
 
109
            void itemActivated(MatchItem *item);
 
110
            /**
 
111
             * Emitted when the user changes selection through either the completion
 
112
             * box or the scrolling icon view
 
113
             */
 
114
            void selectionChanged(MatchItem *item);
 
115
            /**
 
116
             * Emitted when the internal query string changes
 
117
             */
 
118
            void textChanged(const QString &text);
 
119
        private:
 
120
            /**
 
121
             * Sets the text in the bottom portion of the widget
 
122
             * @param text Text to display
 
123
             * @param color Color of the rectangle behind the text
 
124
             */
 
125
            void setDescriptionText(const QString &text, const QColor &color);
 
126
            /**
 
127
             * Convenience method. Calls setDescriptionText(text, Plasma::Theme.color())
 
128
             */
 
129
            void setDescriptionText(const QString &text);
 
130
 
 
131
            /**
 
132
             * Removes match items from scene but does not delete them
 
133
             */
 
134
            void clearItems();
 
135
 
 
136
            /**
 
137
             * Selects item at the specified index
 
138
             */
 
139
            void selectItem(int index);
 
140
            /**
 
141
             * Highlights item and centers item when in scrolling icon mode
 
142
             */
 
143
            void focusItem(int index);
 
144
            void scrollLeft();
 
145
            void scrollRight();
 
146
 
 
147
            void setItemCount(int items);
 
148
 
 
149
            void resizeEvent(QResizeEvent *e);
 
150
            void focusInEvent(QFocusEvent *event);
 
151
            void focusOutEvent(QFocusEvent *event);
 
152
            void keyPressEvent(QKeyEvent *event);
 
153
 
 
154
            /**
 
155
             * If there is already an animation and a new one should start, then the old
 
156
             * will be finished
 
157
             */
 
158
            void finishAnimation();
 
159
 
 
160
            class Private;
 
161
            Private* const d;
 
162
    };
 
163
}
 
164
 
 
165
#endif