ginebra2/Charms/ExternalEventCharm.h
changeset 10 232fbd5a2dcb
child 16 3c88a81ff781
equal deleted inserted replaced
6:1c3b8676e58c 10:232fbd5a2dcb
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 *
       
     5 * This program is free software: you can redistribute it and/or modify
       
     6 * it under the terms of the GNU Lesser General Public License as published by
       
     7 * the Free Software Foundation, version 2.1 of the License.
       
     8 *
       
     9 * This program is distributed in the hope that it will be useful,
       
    10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12 * GNU Lesser General Public License for more details.
       
    13 *
       
    14 * You should have received a copy of the GNU Lesser General Public License
       
    15 * along with this program.  If not,
       
    16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
       
    17 *
       
    18 * Description:
       
    19 */
       
    20 
       
    21 #ifndef EXTERNALEVENTCHAR_H
       
    22 #define EXTERNALEVENTCHAR_H
       
    23 
       
    24 #include "ObjectCharm.h"
       
    25 
       
    26 namespace GVA {
       
    27 
       
    28 /*!
       
    29  * This class emits a signal when the user clicks outside of the given graphics object.
       
    30  */
       
    31 class ExternalEventCharm : public ObjectCharm {
       
    32     Q_OBJECT
       
    33   public:
       
    34     ExternalEventCharm(QGraphicsObject *object);
       
    35 
       
    36     static const QString s_mouseClick;
       
    37 
       
    38   signals:
       
    39     /*! This signal is emitted when the user clicks outside of the object.
       
    40      * \param type The Qt event type.
       
    41      * \param name The Qt event name (or "MouseClick" if click gesture is detected).
       
    42      * \param description The Qt event description.
       
    43      */
       
    44     void externalMouseEvent(
       
    45             QEvent * ev,
       
    46             const QString & name,
       
    47             const QString & description);
       
    48   private:
       
    49     void checkForExternalEvent(QObject * o, QEvent * e);
       
    50     void emitExternalEvent(QEvent * e);
       
    51     bool eventFilter(QObject *object, QEvent *event);
       
    52     QGraphicsScene *scene();
       
    53 
       
    54   private:
       
    55     QPointF m_pressPos;
       
    56     bool m_pressed;
       
    57 };
       
    58 
       
    59 }   // end GVA namepace
       
    60 
       
    61 #endif // EXTERNALEVENTCHAR_H