LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
reorderablepage.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 
22 #ifndef REORDERABLEPAGE_H_
23 #define REORDERABLEPAGE_H_
24 
25 #include "page.h"
26 #include <QPointer>
27 #include "thing.h"
28 #include "icon.h"
29 
31 class PixmapObject;
32 class TextBox;
33 class PictureBox;
34 
35 class ReorderablePage : public Page
36 {
37  Q_OBJECT
38 
39 public:
40 
42 
43  friend class ReorderableIconLayout;
44  friend class LauncherObject;
45 
46  Q_INVOKABLE ReorderablePage(const QRectF& pageGeometry,LauncherObject * p_belongsTo);
47  void commonCtor();
48 
49  virtual ~ReorderablePage();
50 
51  //returns true if at least 1 item was laid out, false for a total fail
52  virtual bool layoutFromItemList(const ThingList& items);
53  virtual bool layoutFromItemList(const IconList& items);
54 
55  virtual bool canAcceptIcons() const;
56 
57  virtual bool offer(Thing * p_offer,Thing * p_offeringThing);
58  virtual bool take(Thing * p_takerThing);
59  virtual bool taking(Thing * p_victimThing, Thing * p_takerThing);
60  virtual void taken(Thing * p_takenThing,Thing * p_takerThing);
61  virtual void externalIconMoveTerminated();
62 
63  virtual PageMode::Enum pageMode() const;
64  virtual void setPageMode(PageMode::Enum v);
65 
66  virtual bool resize(quint32 w, quint32 h);
67 
68  //specific to this page...
69  //TODO: possibly a common base class under Page that encompasses Pages that have layouts with "grids"
70  // or at least icon coordinates that can be expressed as <int,int> (i.e. a QPoint)
71  virtual IconBase * iconAtLayoutCoordinate(const QPointF& layoutCoord,QPoint& r_gridCoordinate,QPointF * r_p_intraIconCoord = 0);
72 
73  virtual qint32 rowAtPageCoordinate(const QPointF& pageCoord);
74 
75  virtual void redirectedTouchTrackedPointMoved(Thing * p_sourceThing,int id,const QPointF& scenePosition,const QPointF& lastScenePosition,const QPointF& initialPosition,const RedirectContext& redirContext);
76  virtual void redirectedTouchTrackedPointReleased(Thing * p_sourceThing,int id,const QPointF& scenePosition,const QPointF& lastScenePosition,const QPointF& initialPosition,const RedirectContext& redirContext);
77 
78  virtual bool acceptIncomingIcon(IconBase * p_newIcon);
79  virtual bool releaseTransferredIcon(IconBase * p_transferredIcon);
80 
81  //for property IsReorderingLayoutBoolPropertyName opaqueness
82  virtual bool isLayoutReorderingCurrently() const;
83 
84 protected Q_SLOTS:
85 
86 // the reorder layout uses this to tell me that the tracking has been canceled/lost
87 // DON'T USE TO DO ANYTHING "HEAVY"...it's just meant for dealing with the Page's version of tracking
88 // the icon(s) being moved by the user's touch point inputs
89  virtual void slotTrackedIconCancelTrack(const QUuid& uid);
90 
91  virtual void slotReorderInLayoutStarted();
92  virtual void slotReorderInLayoutEnded();
93 
94  virtual void slotLauncherCmdStartReorderMode();
95  virtual void slotLauncherCmdEndReorderMode();
96 
97 protected:
98 
99  Q_INVOKABLE ReorderablePage(const QUuid& specificUid,const QRectF& pageGeometry,LauncherObject * p_belongsTo);
100 
101  virtual bool tapGesture(QTapGesture *tapEvent,QGestureEvent * baseGestureEvent);
102  virtual bool tapAndHoldGesture(QTapAndHoldGesture *tapHoldEvent,QGestureEvent * baseGestureEvent);
103  virtual bool flickGesture(FlickGesture *flickEvent,QGestureEvent * baseGestureEvent);
104 
105  //passing in id, but really for now only 1 id can be tracked
106  virtual void touchTrackedPointStarted(int id,const QPointF& scenePosition,const QPointF& lastScenePosition,const QPointF& initialPosition);
107  virtual void touchTrackedPointMoved(int id,const QPointF& scenePosition,const QPointF& lastScenePosition,const QPointF& initialPosition);
108  virtual void touchTrackedPointReleased(int id,const QPointF& scenePosition,const QPointF& lastScenePosition,const QPointF& initialPosition);
109  virtual void iconRelease();
110 
111  virtual void paintOffscreen(QPainter *painter);
112 
113  virtual bool detectAndHandleSpecialMoveAreas(int id,const QPointF& pageCoordinate,const RedirectContext& redirContext);
114  virtual bool handleTopBorderSpecialMoveArea(int id,const QPointF& pageCoordinate,const RedirectContext& redirContext);
115  virtual bool handleBottomBorderSpecialMoveArea(int id,const QPointF& pageCoordinate,const RedirectContext& redirContext);
116  virtual bool handleLeftBorderSpecialMoveArea(int id,const QPointF& pageCoordinate,const RedirectContext& redirContext);
117  virtual bool handleRightBorderSpecialMoveArea(int id,const QPointF& pageCoordinate,const RedirectContext& redirContext);
118  virtual bool handleQuickLaunchSpecialMoveArea(int id,const QPointF& pageCoordinate,const RedirectContext& redirContext);
119  virtual bool handlePageTabBarSpecialMoveArea(int id,const QPointF& pageCoordinate,const RedirectContext& redirContext);
120 
121  virtual void switchToNormalMode();
122  virtual void switchToReorderMode();
123 
124  //addIcon goes right through to addIconNoAnimation... these are used to add to this page from the launcher/appmonitor for appinstalls,etc.
125  // otherwise, for reorders, acceptIncomingIcon does the adding.
126  virtual bool addIcon(IconBase * p_icon);
127  virtual bool addIconNoAnimations(IconBase * p_icon);
128  virtual bool removeIcon(const QUuid& iconUid);
129  virtual bool removeIconNoAnimations(const QUuid& iconUid);
130 
131 protected:
132 
133  QPointer<TextBox> m_qp_emptyPageText;
134  QPointer<PictureBox> m_qp_emptyPageIcon;
135 
137 
139  //TODO: implement a better system; this is just done ad-hoc for scaffolding to get page reorder going
140  // in particular, I'd like multi-touch support.
141  QPointer<IconBase> m_qp_iconInMotion;
143 
144 };
145 
146 #endif /* REORDERABLEPAGE_H_ */