Merge branch 'master' into new_panels
authorPekka Nissinen <pekka.nissinen@ixonos.com>
Thu, 12 Aug 2010 08:03:20 +0000 (11:03 +0300)
committerPekka Nissinen <pekka.nissinen@ixonos.com>
Thu, 12 Aug 2010 08:03:20 +0000 (11:03 +0300)
13 files changed:
doc/testing/functionality-tests.doc
scripts/filtering_patterns_for_unit_tests_output.txt [new file with mode: 0644]
scripts/run_unit_tests.sh
src/application.cpp
src/application.h
src/map/mapengine.cpp
src/map/mapengine.h
src/ui/fullscreenbutton.cpp
src/ui/fullscreenbutton.h
src/ui/indicatorbutton.h
src/ui/indicatorbuttonpanel.h
src/ui/mainwindow.cpp
tests/map/mapengine/testmapengine.cpp

index b74b9b7..5799763 100644 (file)
Binary files a/doc/testing/functionality-tests.doc and b/doc/testing/functionality-tests.doc differ
diff --git a/scripts/filtering_patterns_for_unit_tests_output.txt b/scripts/filtering_patterns_for_unit_tests_output.txt
new file mode 100644 (file)
index 0000000..94ffde4
--- /dev/null
@@ -0,0 +1,2 @@
+atk_object_set_name..assertion
+gtk_widget_set_sensitive: assertion
index dae1672..fa2d8dd 100755 (executable)
@@ -9,6 +9,10 @@ REPORT_FILE="unit_test_results.txt"
 TEMP_FILE_EXEC_NOT_FOUND="temp_exec_not_found.txt"
 TEMP_REPORT_FILE="temp_report.txt"
 
+MAKE_OPTIONS="-j3 -k -s -w"
+
+SCRIPT_DIR=(`pwd`)
+
 # check that directories are found
 if [[ -d $REPORT_PATH && -d $UNIT_TESTS_ROOT_DIR ]]; then
     # convert relational paths to absolute ones
@@ -49,7 +53,7 @@ if [[ -d $REPORT_PATH && -d $UNIT_TESTS_ROOT_DIR ]]; then
     # run qmake
     cd $UNIT_TESTS_ROOT_DIR_ABSOLUTE
     qmake -r
-    make
+    make $MAKE_OPTIONS
     cd -
 
     echo ""
@@ -67,11 +71,12 @@ if [[ -d $REPORT_PATH && -d $UNIT_TESTS_ROOT_DIR ]]; then
                 # go to unit test directory
                 cd "`echo $PROJECT | grep --perl-regexp -o .*\(?=/\)`"
                 # run unit test, save to temp file, ignore strerr stream
-                $PROJECT -silent -o $REPORT_PATH_ABSOLUTE/$TEMP_REPORT_FILE 2>&1 | grep -v "atk_object_set_name..assertion"
+                $PROJECT -silent -o $REPORT_PATH_ABSOLUTE/$TEMP_REPORT_FILE 2>&1 | grep -v -f $SCRIPT_DIR/filtering_patterns_for_unit_tests_output.txt
                 cd - > /dev/null
                 # print to screen and append to summary
                 cat $REPORT_PATH_ABSOLUTE/$TEMP_REPORT_FILE
                 cat $REPORT_PATH_ABSOLUTE/$TEMP_REPORT_FILE >> $REPORT_PATH_ABSOLUTE/$REPORT_FILE
+                echo ""
                 echo "" >> $REPORT_PATH_ABSOLUTE/$REPORT_FILE
             else
                 # save path of missing test to temporary file
index 7f537a5..f331c39 100644 (file)
@@ -86,22 +86,34 @@ bool Application::x11EventFilter(XEvent *event)
     qDebug() << __PRETTY_FUNCTION__;
 
     static Qt::HANDLE rootWindow = QX11Info::appRootWindow();
-    static Atom activeAppAtom = XInternAtom(QX11Info::display(),
-                                            ACTIVE_APP_ATOM, false);
-
-    if (event->type == PropertyNotify) {
-        XPropertyEvent *pevent = (XPropertyEvent*)event;
-        if (pevent->window == rootWindow) {
-            if (pevent->atom == activeAppAtom) {
-                WId activeWindow = activeDesktopWindow(pevent->display,
-                                                       rootWindow);
-
-                if(m_topmost != m_windows.contains(activeWindow)) {
-                    m_topmost = !m_topmost;
-                    emit topmostChanged(!m_topmost);
+    static Atom activeAppAtom = XInternAtom(QX11Info::display(), ACTIVE_APP_ATOM, false);
+
+    switch (event->type) {
+    case PropertyNotify: {
+            XPropertyEvent *pevent = (XPropertyEvent*)event;
+            if (pevent->window == rootWindow) {
+                if (pevent->atom == activeAppAtom) {
+                    WId activeWindow = activeDesktopWindow(pevent->display, rootWindow);
+
+                    if(m_topmost != m_windows.contains(activeWindow)) {
+                        m_topmost = !m_topmost;
+                        emit topmostChanged(!m_topmost);
+                    }
                 }
             }
         }
+        break;
+    case KeyPress:
+    case KeyRelease:
+    case ButtonPress:
+    case ButtonRelease:
+    case MotionNotify:
+    case EnterNotify: // required when returning from statusbar menu
+    case FocusIn: // required when returning from update location dialog
+        emit showFullScreenButton();
+        break;
     }
+
+    // don't block any events here, so false is returned
     return false;
 }
index 4c6deff..32d5e03 100644 (file)
@@ -32,8 +32,8 @@
 class Application : public QApplication
 {
     Q_OBJECT
-public:
 
+public:
     /**
     * @brief Constructor
     *
@@ -42,6 +42,10 @@ public:
     */
     Application(int &argc, char **argv);
 
+/*******************************************************************************
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
+public:
     /**
     * @brief Registers window
     *
@@ -57,7 +61,6 @@ public:
     void unregisterWindow(WId wId);
 
 private:
-
     /**
     * @brief Return active window
     *
@@ -76,7 +79,18 @@ private:
     */
     bool x11EventFilter(XEvent *event);
 
+/*******************************************************************************
+ * SIGNALS
+ ******************************************************************************/
 signals:
+    /**
+    * @brief Signal is emitted when full screen button must be invoked and it's hiding timer
+             cleared.
+    *
+    * Signal is emitted when user interacts with keyboard or with mouse/finger, or when the
+    * main window is exposed.
+    */
+    void showFullScreenButton();
 
     /**
     * @brief Signals when window state is changed
@@ -85,11 +99,13 @@ signals:
     */
     void topmostChanged(bool topmost);
 
+/*******************************************************************************
+ * DATA MEMBERS
+ ******************************************************************************/
 private:
+    bool m_topmost;             ///< Flag for topmost
 
-    bool m_topmost; ///< Flag for topmost
-
-    QList<WId> m_windows; ///< List of window ids
+    QList<WId> m_windows;       ///< List of window ids
 };
 
 #endif // APPLICATION_H
index 98a9504..ce2faf0 100644 (file)
@@ -187,7 +187,7 @@ QRectF MapEngine::currentViewSceneRect() const
 
     const QPoint ONE_PIXEL = QPoint(1, 1);
 
-    QGraphicsView *view = m_mapScene->views().at(0);
+    QGraphicsView *view = m_mapScene->views().first();
     QPointF sceneTopLeft = view->mapToScene(0, 0);
     QPoint viewBottomRight = QPoint(view->size().width(), view->size().height()) - ONE_PIXEL;
     QPointF sceneBottomRight = view->mapToScene(viewBottomRight);
index f05254e..bf73850 100644 (file)
@@ -50,6 +50,8 @@ class User;
  * Logic for controlling map functionality. Does also include static methods for
  * converting coordinates.
  *
+ * NOTE: MapEngine must have a view attached before using it!
+ *
  * @author Sami Rämö - sami.ramo (at) ixonos.com
  * @author Jussi Laitinen - jussi.laitinen (at) ixonos.com
  * @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
index 6ca4806..5d84dde 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <QDebug>
 #include <QPainter>
+#include <QTimer>
 
 #include "math.h"
 
@@ -38,6 +39,8 @@ FullScreenButton::FullScreenButton(QWidget *parent) :
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+    const int HIDING_DELAY_MS = 5000;
+
     setIcon(QIcon::fromTheme(QLatin1String("general_fullsize")));
     setFixedSize(sizeHint());
 
@@ -61,6 +64,16 @@ FullScreenButton::FullScreenButton(QWidget *parent) :
     m_backgroundPath.lineTo(0, this->height());             // Bottom left corner
     m_backgroundPath.lineTo(this->width(), this->height()); // Bottom right corner
     m_backgroundPath.closeSubpath();                        // Back to the beginning
+
+    // Timer for hiding the button automatically after a delay
+    m_hidingTimer = new QTimer(this);
+    if (m_hidingTimer) {
+        m_hidingTimer->setSingleShot(true);
+        m_hidingTimer->setInterval(HIDING_DELAY_MS);
+
+        connect(m_hidingTimer, SIGNAL(timeout()),
+                this, SLOT(hide()));
+    }
 }
 
 FullScreenButton::~FullScreenButton()
@@ -71,6 +84,17 @@ FullScreenButton::~FullScreenButton()
     delete m_selectedGradient;
 }
 
+void FullScreenButton::invoke()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    if (isHidden())
+        show();
+
+    if (m_hidingTimer)
+        m_hidingTimer->start();
+}
+
 void FullScreenButton::paintEvent(QPaintEvent *event)
 {
     qDebug() << __PRETTY_FUNCTION__;
index 7df499e..c447af1 100644 (file)
@@ -25,6 +25,8 @@
 
 #include <QToolButton>
 
+class QTimer;
+
 /**
  * @brief Fullscreen button class
  *
@@ -63,12 +65,22 @@ protected:
     void paintEvent(QPaintEvent *event);
 
 /*******************************************************************************
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
+public slots:
+    /**
+    * @brief Invoke the button (if not already visible) and set hiding timer
+    */
+    void invoke();
+
+/*******************************************************************************
  * DATA MEMBERS
  ******************************************************************************/
 private:
     QColor *m_normalColor;                  ///< Normal background color
     QLinearGradient *m_selectedGradient;    ///< Selected background
     QPainterPath m_backgroundPath;          ///< Item shape path
+    QTimer *m_hidingTimer;                  ///< Timer for hiding the button after a delay
 };
 
 #endif // FULLSCREENBUTTON_H
index 24b5efd..5affe55 100644 (file)
@@ -98,8 +98,9 @@ public slots:
      * @brief Sets direction information for the distance indicator button
      *
      * Paints the button and its icon
-     * @param Direction to the GPS position (in degrees)
-     * @param Draw direction triangle
+     *
+     * @param direction Direction to the GPS position (in degrees)
+     * @param draw True if direction triangle should be drawn
      */
     void setDirection(qreal direction, bool draw);
 
index 5b29bcf..3dcaecf 100644 (file)
@@ -110,7 +110,7 @@ public slots:
      * @brief Toggle indicator button panel draggability
      *
      * @param mode True if draggable, otherwise false
-     * @param distance Start value for dragging
+     * @param eventPosition Start position of the dragging
      */
     void setDraggable(bool mode, QPoint eventPosition = QPoint(0,0));
 
index d40e185..7aa8c76 100644 (file)
@@ -144,10 +144,17 @@ void MainWindow::automaticUpdateDialogFinished(int result)
 void MainWindow::buildFullScreenButton()
 {
     qDebug() << __PRETTY_FUNCTION__;
+
 #ifdef Q_WS_MAEMO_5
     m_fullScreenButton = new FullScreenButton(this);
-    connect(m_fullScreenButton, SIGNAL(clicked()),
-            this, SLOT(toggleFullScreen()));
+
+    if (m_fullScreenButton) {
+        connect(m_fullScreenButton, SIGNAL(clicked()),
+                this, SLOT(toggleFullScreen()));
+
+        connect(qApp, SIGNAL(showFullScreenButton()),
+                m_fullScreenButton, SLOT(invoke()));
+    }
 #endif // Q_WS_MAEMO_5
 }
 
index 67d3407..1b5d78a 100644 (file)
@@ -20,6 +20,7 @@
 */
 
 #include <QGraphicsScene>
+#include <QGraphicsView>
 #include <QtTest/QtTest>
 
 #include "common.h"
@@ -43,9 +44,9 @@ private slots:
     void convertTileNumberToSceneCoordinate_data();
     void setLocationNewTilesCount();
     void setLocationRemovedTilesCount();
-    void zoomOutRemovedTilesCount();
-    void zoomInRemovedTilesCount();
     void usingLastLocation();
+    void zoomInRemovedTilesCount();
+    void zoomOutRemovedTilesCount();
 
 signals:
     void setCenterPosition(SceneCoordinate); // a way to call a private slot
@@ -81,6 +82,8 @@ void TestMapEngine::convertTileNumberToSceneCoordinate_data()
 void TestMapEngine::setLocationNewTilesCount()
 {
     MapEngine engine;
+    QGraphicsView view;
+    view.setScene(engine.scene());
     engine.viewResized(QSize(800, 480));
     connect(this, SIGNAL(setCenterPosition(SceneCoordinate)),
             &engine, SLOT(setCenterPosition(SceneCoordinate)));
@@ -109,6 +112,8 @@ void TestMapEngine::setLocationNewTilesCount()
 void TestMapEngine::setLocationRemovedTilesCount()
 {
     MapEngine engine;
+    QGraphicsView view;
+    view.setScene(engine.scene());
     engine.viewResized(QSize(800, 480));
     connect(this, SIGNAL(setCenterPosition(SceneCoordinate)),
             &engine, SLOT(setCenterPosition(SceneCoordinate)));
@@ -133,6 +138,8 @@ void TestMapEngine::setLocationRemovedTilesCount()
 void TestMapEngine::zoomInRemovedTilesCount()
 {
     MapEngine engine;
+    QGraphicsView view;
+    view.setScene(engine.scene());
     engine.viewResized(QSize(800, 480));
     connect(this, SIGNAL(setCenterPosition(SceneCoordinate)),
             &engine, SLOT(setCenterPosition(SceneCoordinate)));
@@ -156,6 +163,8 @@ void TestMapEngine::zoomInRemovedTilesCount()
 void TestMapEngine::zoomOutRemovedTilesCount()
 {
     MapEngine engine;
+    QGraphicsView view;
+    view.setScene(engine.scene());
     engine.viewResized(QSize(800, 480));
     connect(this, SIGNAL(setCenterPosition(SceneCoordinate)),
             &engine, SLOT(setCenterPosition(SceneCoordinate)));
@@ -181,6 +190,8 @@ void TestMapEngine::usingLastLocation()
 {
     // Create mapengine and start monitoring zoomLevelChanged-signal
     MapEngine *mapengine = new MapEngine;
+    QGraphicsView view;
+    view.setScene(mapengine->scene());
     QSignalSpy mapEngineSpy(mapengine, SIGNAL(zoomLevelChanged(int)));
     connect(this, SIGNAL(setCenterPosition(SceneCoordinate)),
             mapengine, SLOT(setCenterPosition(SceneCoordinate)));