LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
pagetabbar.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2010-2012 Hewlett-Packard Development Company, L.P.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * LICENSE@@@ */
18 
19 
20 
21 
23 
24 #ifndef PAGETABBAR_H_
25 #define PAGETABBAR_H_
26 
27 #include <QUuid>
28 #include <QRectF>
29 #include <QSize>
30 #include <QPointer>
31 #include <QString>
32 #include <QTimer>
33 #include <QSet>
34 #include <QFont>
35 
36 #include "thingpaintable.h"
37 #include "pixmapobject.h"
38 
39 class LauncherObject;
40 class QGraphicsSceneMouseEvent;
41 class QGesture;
42 class QGestureEvent;
43 class QTouchEvent;
44 class QPanGesture;
45 class QSwipeGesture;
46 class QPinchGesture;
47 class QTapAndHoldGesture;
48 class QTapGesture;
49 class FlickGesture;
50 class PageTab;
51 class Page;
52 
53 class PageTabBar : public ThingPaintable
54 {
55  Q_OBJECT
56  Q_INTERFACES(QGraphicsItem)
57 
58 public:
59  friend class LauncherObject;
60 
61  PageTabBar(const QRectF& pageBarGeometry,LauncherObject * p_belongsTo);
62  virtual ~PageTabBar();
63 
64  //returns old pixmapobject
65  PixmapObject * setBackground(PixmapObject * p_newBackground);
67 
68  static QSize PageTabSizeFromLauncherSize(quint32 launcherWidth,quint32 launcherHeight);
69 
70  //TODO: temporary; remove when a better system (like styles) goes in place
71  static QFont staticLabelFontForTabs();
72 
73  //used by the launcher; specifically by the redirectTouch movement handler, while an icon is being moved.
74  // it will test the coordinate given (it's in Scene CS) against the space being occupied by the tabs and return the Page ptr
75  // of the page whos tab is "hit".
76  // if the optional "highlight" parameter is true, then a positive test will also result in the tab getting highlighted
77  virtual Page * testForIntersectOnPageTab(const QPointF& sceneCoordinate,bool highlight=false);
78  virtual Page * testForIntersectOnPageTab(const QPointF& sceneCoordinate,PageTab ** r_p_pageTab,bool highlight=false);
79  virtual void highlightTabForPage(Page * p_page);
80  virtual void unHighlightTabForPage(Page * p_page);
81 
82 Q_SIGNALS:
83 
86 
87  void signalAllTabHighlightsOff(); //Tab bar -> Tabs
88 
91 
92 public Q_SLOTS:
93 
94  void slotAddTab(const QString& labelString,Page * p_refersToPage=0); //outside -> Tab bar
95  void slotUnHighlightAll(); //outside -> Tab bar
96 
97 protected Q_SLOTS:
98 
99  virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
100  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
101  virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
102 
103  virtual void slotAnimationFinished() {}
104 
105  virtual void slotTabActivatedTap();
106  virtual void slotTabActivatedTapAndHold();
107 
108  virtual void slotHighlighted();
109 
110  virtual void slotLauncherBlockedInteractions();
111  virtual void slotLauncherAllowedInteractions();
112 
113 protected:
114 
115  virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option=0,QWidget *widget=0);
116  virtual void paintOffscreen(QPainter *painter);
117 
118  virtual bool resize(quint32 newWidth,quint32 newHeight);
119  virtual bool resize(const QSize& s);
120 
121  virtual bool touchEvent(QTouchEvent * event) { return true; }
122  virtual bool touchStartEvent(QTouchEvent *event) { return true; }
123  virtual bool touchUpdateEvent(QTouchEvent *event) { return true; }
124  virtual bool touchEndEvent(QTouchEvent *event) { return true; }
125 
126  virtual bool sceneEvent(QEvent * event);
127  virtual bool gestureEvent(QGestureEvent *gestureEvent) { return true; }
128  virtual bool panGesture(QPanGesture *panEvent) { return true; }
129  virtual bool swipeGesture(QSwipeGesture *swipeEvent);
130  virtual bool flickGesture(FlickGesture *flickEvent);
131  virtual bool pinchGesture(QPinchGesture *pinchEvent) { return true; }
132  virtual bool tapAndHoldGesture(QTapAndHoldGesture *tapHoldEvent) { return true; }
133  virtual bool tapGesture(QTapGesture *tapEvent) { return true; }
134  virtual bool customGesture(QGesture *customGesture) { return true; }
135 
136  virtual QList<QPointer<PageTab> > tabs();
137  virtual PageTab * tabByPage(Page * p_page);
138 
139  virtual void relayoutExistingTabs();
140  virtual void relayoutExistingTabs(const qreal toWidth,const qreal toHeight);
141 
142  //sets m_geomUnusedTabSpace full allowed tab space, and m_geomUsedTabSpace to empty
143  // (used by things like relayout__() )
144  virtual void resetTabSpaces();
145  // sets m_geomUnusedTabSpace relative to what the current m_geomUsedTabSpace is set to
146  virtual void recalculateUnusedSpace();
147 
148 private:
149 
150  QSize newTabMaxSize();
151 
152  QRectF m_unusedTabSpace;
153  QRectF m_usedTabSpace;
154  quint32 m_maxTabWidth;
155  QString m_pageTabBarUiState; //container for ui info the owner needs to store here
156 
157  bool m_interactionsBlocked;
158  QRectF m_backgroundGeom;
159  QRectF m_backgroundShadowGeom;
160 
161  QPointer<LauncherObject> m_qp_currentUIOwner;
162  QPointer<PixmapObject> m_qp_backgroundPmo;
163  QPointer<PixmapObject> m_qp_backgroundShadowPmo;
164 
165  typedef QList<QPointer<PageTab> >::const_iterator PageTabConstIterator;
166  typedef QList<QPointer<PageTab> >::iterator PageTabIterator;
167  QList<QPointer<PageTab> > m_pageTabs;
168 };
169 
170 
171 #endif /* PAGETABBAR_H_ */