Adding defines for magic numbers default tip
authorWes Thierry <wesleyt@symbian.org>
Fri, 05 Nov 2010 11:32:03 +0000
changeset 8 a593fb7f78c0
parent 7 99c3932ca5e6
Adding defines for magic numbers
MixedView/MixedView.pro
MixedView/mainwindow.cpp
Mywebwidget3/mywebwidget.cpp
Mywebwidget3/mywebwidget3.pro
--- a/MixedView/MixedView.pro	Thu Oct 28 10:48:20 2010 -0700
+++ b/MixedView/MixedView.pro	Fri Nov 05 11:32:03 2010 +0000
@@ -26,7 +26,7 @@
 symbian {
     TARGET.UID3 = 0xe4cef592
     LIBS += -lcone -leikcore -lavkon
-    TARGET.CAPABILITY += LocalServices ReadUserData WriteUserData NetworkServices UserEnvironment Location ReadDeviceData
+   # TARGET.CAPABILITY += LocalServices ReadUserData WriteUserData NetworkServices UserEnvironment Location ReadDeviceData
     TARGET.EPOCSTACKSIZE = 0x14000
     TARGET.EPOCHEAPSIZE = 0x020000 0x10000000
 }
--- a/MixedView/mainwindow.cpp	Thu Oct 28 10:48:20 2010 -0700
+++ b/MixedView/mainwindow.cpp	Fri Nov 05 11:32:03 2010 +0000
@@ -10,6 +10,15 @@
 #include <QStringList>
 #include <QSound>
 
+// define the borders of the image
+#define LEFT_EDGE -103
+#define RIGHT_EDGE 180
+#define TOP_EDGE -156
+#define BOTTOM_EDGE 145
+// The number of Hits is always at least 2
+// since there is a visible and invisible image
+// on top of each other at the same coordinates
+#define HITS 2
 
 MainWindow::MainWindow(QWidget *parent) :
     QMainWindow(parent),
@@ -52,8 +61,6 @@
     mPacman->setSpanAngle(4500);
     mScene->addItem(mPacman);
 
-
-
     // lets place a pause button in the view
     pauseButton = new QPushButton("Pause");
     connect(pauseButton, SIGNAL(clicked()), this, SLOT(pause()));
@@ -85,8 +92,6 @@
 void MainWindow::updateGraphics() {
     if (mPause)
         return;
-
-
     // update the pacman mouth state
     // will eventually change this to a graphic
     switch (mPacState) {
@@ -119,10 +124,12 @@
 
 }
 
+
 void MainWindow::checkCollisions() {
 
+
     mNumHits = mPacCollider->collidingItems().count();
-    if (mNumHits == 2)
+    if (mNumHits == HITS)
         mLastPt = mPacCollider->pos();
 
     QPointF pt =  mPacCollider->pos();
@@ -130,19 +137,18 @@
     pt.setX(pt.x()-xAxis);
     pt.setY(pt.y()+yAxis);
 
-    if (pt.x()<-103)
-        pt.setX(-103);
-    else if (pt.x()>180)
-        pt.setX(180);
+    if (pt.x()< LEFT_EDGE)
+        pt.setX(LEFT_EDGE);
+    else if (pt.x()>RIGHT_EDGE)
+        pt.setX(RIGHT_EDGE);
 
-    if (pt.y()<-156)
-        pt.setY(-156);
-    else if (pt.y()>145)
-        pt.setY(145);
+    if (pt.y()<TOP_EDGE)
+        pt.setY(TOP_EDGE);
+    else if (pt.y()>BOTTOM_EDGE)
+        pt.setY(BOTTOM_EDGE);
 
-    if (mNumHits == 2) {
+    if (mNumHits == HITS) {
         mPacCollider->setPos(pt);
-       // mPacman->setPos(pt);
     }
     else {
         mPacCollider->setPos(mLastPt);
--- a/Mywebwidget3/mywebwidget.cpp	Thu Oct 28 10:48:20 2010 -0700
+++ b/Mywebwidget3/mywebwidget.cpp	Fri Nov 05 11:32:03 2010 +0000
@@ -54,6 +54,7 @@
     connect(m_lineEdit,SIGNAL(editingFinished()),SLOT(openUrl()));
     connect(m_view,SIGNAL(loadFinished(bool)),SLOT(onLoadFinished(bool)));
 
+
     //connect the toolbar as well
     connect(m_toolbar,SIGNAL(goBack()),SLOT(loadPreviousPage()));
 }
@@ -74,6 +75,7 @@
 
 void MyWebWidget::openUrl()
 {
+
     QString url(m_lineEdit->text());
     if(!url.contains("http://",Qt::CaseInsensitive))
         url.prepend("http://");
--- a/Mywebwidget3/mywebwidget3.pro	Thu Oct 28 10:48:20 2010 -0700
+++ b/Mywebwidget3/mywebwidget3.pro	Fri Nov 05 11:32:03 2010 +0000
@@ -22,7 +22,7 @@
 
 symbian {
     TARGET.UID3 = 0xe1b774b2
-    TARGET.CAPABILITY += LocalServices ReadUserData WriteUserData NetworkServices UserEnvironment Location ReadDeviceData
+    TARGET.CAPABILITY += LocalServices ReadUserData WriteUserData NetworkServices UserEnvironment Location
     TARGET.EPOCSTACKSIZE = 0x14000
     TARGET.EPOCHEAPSIZE = 0x020000 0x4000000
 }