00001 /* 00002 Situare - A location system for Facebook 00003 Copyright (C) 2010 Ixonos Plc. Authors: 00004 00005 Pekka Nissinen - pekka.nissinen@ixonos.com 00006 Kaj Wallin - kaj.wallin@ixonos.com 00007 Katri Kaikkonen - katri.kaikkonen@ixonos.com 00008 00009 Situare is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License 00011 version 2 as published by the Free Software Foundation. 00012 00013 Situare is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with Situare; if not, write to the Free Software 00020 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 00021 USA. 00022 */ 00023 00024 #ifndef INDICATORBUTTONPANEL_H 00025 #define INDICATORBUTTONPANEL_H 00026 00027 #include <QGraphicsItem> 00028 #include <QGridLayout> 00029 #include <QLabel> 00030 #include <QMouseEvent> 00031 #include <QTimer> 00032 #include <QWidget> 00033 00034 #include "indicatorbutton.h" 00035 00043 class IndicatorButtonPanel : public QWidget 00044 { 00045 Q_OBJECT 00046 00047 public: 00053 IndicatorButtonPanel(QWidget *parent = 0); 00054 00059 ~IndicatorButtonPanel(); 00060 00061 /******************************************************************************* 00062 * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS 00063 ******************************************************************************/ 00064 protected: 00070 void mouseMoveEvent(QMouseEvent *event); 00071 00077 void mousePressEvent(QMouseEvent *event); 00078 00084 void mouseReleaseEvent(QMouseEvent *event); 00085 00092 void paintEvent(QPaintEvent *event); 00093 00094 /******************************************************************************* 00095 * MEMBER FUNCTIONS AND SLOTS 00096 ******************************************************************************/ 00097 public slots: 00106 void updateValues(qreal direction, qreal distance, bool draw); 00107 00113 void setIndicatorButtonEnabled(bool enabled); 00114 00121 void setDraggable(bool mode, QPoint eventPosition = QPoint(0,0)); 00122 00128 void screenResized(const QSize &size); 00129 00130 private slots: 00134 void forceMouseRelease(); 00135 00139 void timerExpired(); 00140 00141 /******************************************************************************* 00142 * SIGNALS 00143 ******************************************************************************/ 00144 signals: 00150 void autoCenteringTriggered(bool enabled); 00151 00160 void directionIndicatorValuesUpdate(qreal direction, qreal distance, bool draw); 00161 00165 void draggingModeTriggered(); 00166 00167 /******************************************************************************* 00168 * DATA MEMBERS 00169 ******************************************************************************/ 00170 private: 00171 bool m_isDraggable; 00172 00173 qreal m_distance; 00174 00175 QColor *m_normalColor; 00176 00177 QLabel *m_distanceTextLabel; 00178 00179 QPoint m_dragPosition; 00180 00181 QSize m_screenSize; 00182 00183 QString m_distanceText; 00184 00185 QTimer *m_dragStartTimer; 00186 QTimer *m_forceReleaseTimer; 00187 00188 IndicatorButton *m_indicatorButton; 00189 }; 00190 00191 #endif // INDICATORBUTTONPANEL_H