2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Sami Rämö - sami.ramo@ixonos.com
7 Situare is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 version 2 as published by the Free Software Foundation.
11 Situare 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.
16 You should have received a copy of the GNU General Public License
17 along with Situare; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22 #ifndef LISTITEMCONTEXTBUTTONBAR_H
23 #define LISTITEMCONTEXTBUTTONBAR_H
28 class QPropertyAnimation;
31 * @brief Button bar for list item relatex context buttons
33 * @author Sami Rämö - sami.ramo (at) ixonos.com
35 class ListItemContextButtonBar : public QWidget
42 * @param parent Parent
44 explicit ListItemContextButtonBar(QWidget *parent = 0);
51 ~ListItemContextButtonBar();
53 /*******************************************************************************
54 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
55 ******************************************************************************/
58 * @brief Paint the background of the item
60 * @param event Paint event
62 void paintEvent(QPaintEvent *event);
64 /*******************************************************************************
65 * MEMBER FUNCTIONS AND SLOTS
66 ******************************************************************************/
69 * @brief Start hiding animation
71 void hideContextButtonBar();
74 * @brief Set new context buttons
76 * If bar is hidden, then changeButtons() is called. Otherwise pointer to new buttons is saved
77 * and hideContextButtonBar() is called.
79 * @param contextButtons Pointer to new context buttons
81 void setContextButtons(QWidget *contextButtons);
84 * @brief Start showing animation
86 * Animation is started only if the bar contains buttons.
88 void showContextButtonBar();
92 * @brief Shows and hides the bar when item selection is changed
94 * Calls showContextButtonBar() or hideContextButtonBar() if changing the state of the bar is
95 * required. If there is a pointer to new buttons, then request is remembered instead of
96 * changing the state immediately.
98 * @param itemIsSelected True is any item is selected
100 void onListItemSelectionChanged(bool itemIsSelected);
104 * @brief Do the actual changing of the buttons
106 * Does also re-sizing and re-positioning of the bar and sets new values for animation.
108 void changeButtons();
114 * If bar was just hidden, then calls changeButtons() if there is a pointer to new buttons
115 * saved. If changing the buttons was done, then also checks if showing the bar was requested
116 * and calls showContextButtonBar() if needed.
118 void onAnimationFinished();
120 /*******************************************************************************
122 ******************************************************************************/
125 * @brief States for the animation
127 * @enum AnimationState
129 enum AnimationState {
136 bool m_waitForOpen; ///< Is showing requested while chaging buttons is not ready
138 QHBoxLayout *m_barLayout; ///< Main layout of this widget
140 QPixmap *m_backgroundLeft; ///< Background picture, left part
141 QPixmap *m_backgroundMiddle; ///< Background picture, center part
142 QPixmap *m_backgroundRight; ///< Background picture, right part
144 QPropertyAnimation *m_animation; ///< Sliding animation for show/hide
146 QWidget *m_contextButtons; ///< Widget for context buttons
147 QWidget *m_newContextButtons; ///< Temporary pointer for new context buttons
149 AnimationState m_state; ///< Current state of the animation
152 #endif // LISTITEMCONTEXTBUTTONBAR_H